book-index-ui 0.52.4 → 0.52.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +56 -56
- package/dist/index.js +2121 -2119
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var zp=Object.create;var gs=Object.defineProperty;var Np=Object.getOwnPropertyDescriptor;var Ip=Object.getOwnPropertyNames;var Rp=Object.getPrototypeOf,Ep=Object.prototype.hasOwnProperty;var Lp=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Ip(n))!Ep.call(e,s)&&s!==i&&gs(e,s,{get:()=>n[s],enumerable:!(o=Np(n,s))||o.enumerable});return e};var ii=(e,n,i)=>(i=e!=null?zp(Rp(e)):{},Lp(n||!e||!e.__esModule?gs(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Se=require("./storage-entry-4WXkdkaK.cjs"),t=require("react/jsx-runtime"),g=require("react"),Ap=require("opencc-js/t2cn"),Za=require("./variant-supplement.cjs"),Mp=require("react-markdown"),Pp=require("remark-gfm"),Bp=e=>`/book-index?id=${e}`,Ja=g.createContext(Bp);function Wp({buildUrl:e,children:n}){const i=g.useMemo(()=>e,[e]);return t.jsx(Ja.Provider,{value:i,children:n})}function tt(){return g.useContext(Ja)}const Qa="",el="";function Vr(e){const n=[];let i=!1,o=e;for(;o.length;){const s=i?el:Qa,a=o.indexOf(s);if(a===-1){n.push({text:o,marked:i});break}a>0&&n.push({text:o.slice(0,a),marked:i}),o=o.slice(a+1),i=!i}return n}function lt(e,n){return{title:e,tokens:n}}const fs='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',Op=[lt("基础(VS Code 环境下跟随 --vscode-*)",{bg:{value:"#ffffff",vscode:"--vscode-editor-background"},fg:{value:"#333333",vscode:"--vscode-foreground"},"input-bg":{value:"#ffffff",vscode:"--vscode-input-background"},"input-fg":{value:"#333333",vscode:"--vscode-input-foreground"},"input-border":{value:"#cccccc",vscode:"--vscode-input-border"},"widget-border":{value:"#e0e0e0",vscode:"--vscode-widget-border"},"link-fg":{value:"#0066cc",vscode:"--vscode-textLink-foreground"},"desc-fg":{value:"#717171",vscode:"--vscode-descriptionForeground"},primary:{value:"#0078d4",vscode:"--vscode-button-background"},"primary-fg":{value:"#ffffff",vscode:"--vscode-button-foreground"},"primary-soft":{value:"rgba(0, 120, 212, 0.15)",css:"color-mix(in srgb, var(--bim-primary) 15%, transparent)"},danger:{value:"#f44336"},warning:{value:"#ff9800"},success:{value:"#4caf50"},"sidebar-bg":{value:"#f3f3f3",vscode:"--vscode-sideBar-background"},"list-hover-bg":{value:"rgba(0, 0, 0, 0.04)",vscode:"--vscode-list-hoverBackground"},"list-active-bg":{value:"rgba(0, 120, 212, 0.1)",vscode:"--vscode-list-activeSelectionBackground"},"focus-border":{value:"#0078d4",vscode:"--vscode-focusBorder"}}),lt("底色层次 / 文字与描边 / 链接",{"bg-subtle":{value:"#fafafa"},"widget-bg":{value:"#f8f8f8"},muted:{value:"#888888"},border:{value:"#e5e5e5"},"primary-bg":{value:"#fdf4f4"},link:{value:"#1976d2"},"tag-bg":{value:"#f0f0f0"},"accent-bg":{value:"#1976d2"},"on-color-fg":{value:"#ffffff",note:"彩色底(徽章、选中态按钮)上的文字"}}),lt("提示与警告",{"info-fg":{value:"#0c5380"},"info-bg":{value:"#e7f3ff"},"info-border":{value:"#b3dbff"},"warn-fg":{value:"#856404"},"warn-bg":{value:"#fff3cd"},"warn-border":{value:"#ffc107"},"danger-bg":{value:"rgba(244, 67, 54, 0.08)",note:"错误提示条底色"},"danger-soft-bg":{value:"rgba(244, 67, 54, 0.03)",note:"编辑器危险区块"},"danger-soft-border":{value:"rgba(244, 67, 54, 0.13)"}}),lt("遮罩与阴影",{backdrop:{value:"rgba(0, 0, 0, 0.5)",note:"对话框遮罩"},"overlay-bg":{value:"#00000010",note:"轻量遮罩底(图片占位等)"},"shadow-dialog":{value:"0 4px 20px rgba(0, 0, 0, 0.3)"},"shadow-dropdown":{value:"0 4px 12px rgba(0, 0, 0, 0.1)"},"shadow-tooltip":{value:"0 2px 8px rgba(0, 0, 0, 0.08)"},"shadow-fab":{value:"0 2px 8px rgba(0, 0, 0, 0.25)",note:"悬浮按钮(反馈)"},"shadow-card":{value:"0 1px 4px rgba(0, 0, 0, 0.06)",note:"展开的卡片"},"shadow-node":{value:"0 1px 3px rgba(0, 0, 0, 0.1)",note:"谱系图节点"},"shadow-node-selected":{value:"0 0 0 3px rgba(0, 120, 212, 0.2), 0 2px 8px rgba(0, 120, 212, 0.3)"}}),lt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),lt("资源",{"restype-text":{value:"#2196f3"},"restype-image":{value:"#ff9800"},"restype-text-image":{value:"#9c27b0"},"restype-physical":{value:"#795548"},"missing-fg":{value:"#e67e22",note:"资源缺册提示"},"colormode-bw-bg":{value:"#f5f5f5",note:"影印件色彩模式标记(黑白 / 彩色)"},"colormode-bw-fg":{value:"#757575"},"colormode-color-bg":{value:"#fff8e1"},"colormode-color-fg":{value:"#f57f17"},"progress-active":{value:"#f59e0b",note:"资源导入进度"},"progress-done":{value:"#10b981"},"progress-todo":{value:"#9ca3af"},"check-fine-bg":{value:"#e8f5e9",note:"文字资源校对程度徽章(精校 / 粗校 / AI整理)"},"check-fine-fg":{value:"#2e7d32"},"check-rough-bg":{value:"#fff3e0"},"check-rough-fg":{value:"#e65100"},"check-ai-bg":{value:"#e3f2fd"},"check-ai-fg":{value:"#1565c0"}}),lt("整理本(CollatedEdition)",{"highlight-bg":{value:"#fff59d",note:"搜索命中高亮底"},"highlight-fg":{value:"inherit",root:!1},"section-lei":{value:"#8e6f3e",note:"章节类型标记:类 / 书 / 序 / 结语 / 考证 / 注释"},"section-shu":{value:"#c0392b"},"section-xu":{value:"#1a5276"},"section-jieyu":{value:"#7d6608"},"section-kaozhen":{value:"#5d6d7e"},"section-zhushi":{value:"#6c5b7b"},"section-tag-fg":{value:"#e74c3c",note:"章节标记(△ 等)"},"matchstate-fg":{value:"#b78900",note:"与底本匹配状态提示"},"quality-source":{value:"#1b5e20",note:"文本质量等级(底本 / OCR / 粗校 / 精校 / 暂无正文 / 占位)"},"quality-ocr":{value:"#e65100"},"quality-rough":{value:"#1565c0"},"quality-fine":{value:"#2e7d32"},"quality-none":{value:"#5f6368",note:"中性灰:暂无正文"},"quality-placeholder":{value:"#757575",note:"中性灰:占位"}}),lt("版本传承(VersionLineageGraph / List) / 关系方向(RelationPanel)",{"lost-fg":{value:"#c62828",note:"佚失标记"},"confidence-certain":{value:"#2e7d32",note:"关系置信度"},"confidence-consensus":{value:"#1976d2"},"confidence-probable":{value:"#ed6c02"},"confidence-disputed":{value:"#c62828"},"lineage-edge-consensus":{value:"#555555",note:"⚠️ 同为 consensus,List 徽章用 --bim-confidence-consensus(蓝),Graph 连线用这个(灰)。若要统一,覆盖成 var(--bim-confidence-consensus)"},"relation-up":{value:"#2196f3"},"relation-down":{value:"#4caf50"},"relation-flat":{value:"#ff9800"}}),lt("编辑器视图(主要在 guji-platform 插件中可见)",{"editor-type-work":{value:"#4caf50",note:"⚠️ 与展示视图的 --bim-type-* 是两套配色(历史如此)。若要统一,覆盖成对应的 var(--bim-type-*)"},"editor-type-collection":{value:"#2196f3"},"editor-type-book":{value:"#ff9800"},"editor-type-entity":{value:"#9c27b0"},"source-url":{value:"#2196f3",note:"来源类型(SourceEditor)"},"source-bookid":{value:"#4caf50"},"mode-active-bg":{value:"#2196f3",note:"模式指示器当前态(ModeIndicator)"},"cover-accent":{value:"#8e6f3e",note:'书目卡片「封面」点缀(IndexBrowser resultVariant="card")'}}),lt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --bim-primary 等控件色",{"page-bg":{value:"#fbf9f3",note:"纸"},"row-hover-bg":{value:"#f5f1e5"},"selection-bg":{value:"#ecdcbc",note:"选区"},"band-bg":{value:"#f0e4cb",note:"全文入口横幅(暖沙)"},"band-bg-hover":{value:"#e6d5b4"},ink:{value:"#2a231c",note:"文字层次:墨 → 正文 → 提要 → meta → 标签 → 提示"},"body-fg":{value:"#3b3228"},"quiet-fg":{value:"#5b4f40"},"meta-fg":{value:"#7b6a54"},"label-fg":{value:"#6f6457",note:"标签 / 提示:2026-09 N3a 调深,纸底与斑马底上对比度均 ≥4.5(原 #a3937b 2.8、#b3a385 2.3)"},"hint-fg":{value:"#756a5e"},accent:{value:"#9c3a2c",note:"朱"},"accent-deep":{value:"#6f2a20",note:"链接 hover"},"rule-strong":{value:"#2a231c",note:"分隔线:强 → 常规 → 虚线 → 提要左线"},rule:{value:"#e4dbc9"},"rule-dashed":{value:"#d6c9ae"},"rule-accent-soft":{value:"#e0d3b6"},"aux-fg":{value:"#6f6457",note:"辅助字(元数据、注记、「·」分隔的浅色小字)。须在 page-bg / zebra-bg 上对比度 ≥4.5(Q5 巡检)"},"card-bg":{value:"#fffdf9",note:"提要卡:抬起的面"},"zebra-bg":{value:"#f6f2eb",note:"表格斑马纹 / 左栏分组底(不画格线,靠这一阶底色分行)"},"tint-bg":{value:"#f3eee6",note:"检索框、悬停"},"shadow-summary":{value:"0 10px 32px rgba(60, 50, 40, 0.07)",note:"提要卡投影"},"flag-bg":{value:"rgba(158, 42, 43, 0.08)",note:"唯一的状态色块「有影印」"},"theme-dot-zhusha":{value:"#9c3a2c",note:"主题切换控件的色点:朱砂(不随主题变,两套主题下都要认得出)"},"theme-dot-indigo":{value:"#2e5266",note:"主题切换控件的色点:靛青"},"theme-dot-ink":{value:"#3b4a58",note:"主题切换控件的色点:墨"},"sect-jing":{value:"#2e5266",note:"四部分布条:經部(人物页提要卡;无别处使用)"},"sect-shi":{value:"#9a7a3b",note:"四部分布条:史部"},"sect-zi":{value:"#4f7a5c",note:"四部分布条:子部"},"sect-ji":{value:"#9fb3bc",note:"四部分布条:集部"},"table-border":{value:"color-mix(in srgb, currentColor 28%, transparent)",root:!1,note:"古籍表格(跟随当前文字色)"},"table-head-bg":{value:"color-mix(in srgb, currentColor 8%, transparent)",root:!1}}),lt('版式(v4 外观系统,overview#291):疏朗=留白分区(默认,下列值即疏朗);界栏=框线分区(`<html data-layout="boxed">`)',{"fr-bd":{value:"0 solid transparent",note:"区块外框(border 简写)。疏朗无框;界栏 1px 实线"},"fr-bg":{value:"transparent",note:"区块底。界栏=卡面色"},"fr-hd-pad":{value:"14px 18px",note:"区块标题栏内边距。10-01 起疏朗也有淡染底的标题栏(--bim-fr-hd-bg),故疏朗 14px 18px,界栏 12px 18px"},"fr-hd-bd":{value:"0 solid transparent",note:"区块标题栏下沿线(border 简写)"},"fr-bd-pad":{value:"0",note:"区块正文内边距"},"fr-gap":{value:"56px",note:"区块之间的间距。界栏收紧到 24px(框线本身已分隔)"},"fr-side-gap":{value:"34px",note:"侧栏各块之间的间距;界栏 20px"},"fr-shadow":{value:"0 1px 0 var(--bim-rule), 0 12px 32px -18px rgba(40, 36, 31, 0.25)",note:"抬起的面(提要卡)的投影;界栏不用投影,靠框线"},"fr-tab-bd":{value:"transparent",note:"页签行下沿线颜色(疏朗不画,界栏画)"},"fr-hd-size":{value:"24px",note:"分区标题字号。界栏标题在框顶标题栏里,小一档 19px"},"fr-hd-bg":{value:"color-mix(in srgb, var(--bim-accent) 7%, var(--bim-page-bg))",note:"分区标题栏底色(淡染主色)。疏朗混进页面底,界栏 6% 混进卡面底。主色取 accent(primary 是 VS Code 按钮蓝,不随配色)"},"fr-card-bd":{value:"1px solid transparent",note:"卡片边框。疏朗不画(靠卡面底与淡投影);界栏 1px"},"fr-card-bg":{value:"var(--bim-card-bg)",note:"卡片底"},"fr-row-bd":{value:"1px solid transparent",note:"列表行线、块内小分割线。疏朗不画(靠行距);界栏 1px"},"fr-row-pad":{value:"10px 2px",note:"列表行内边距。界栏收紧 7px 2px"},"fr-chrome-bd":{value:"1px solid transparent",note:"顶栏、分区导航(吸顶锚点条)的线"},"fr-tag-bd":{value:"1px solid transparent",note:"标签、版本签、计数签、工具按钮的边框。疏朗浅底无框;界栏透明底加框"},"fr-tag-bg":{value:"var(--bim-tint-bg)",note:"标签底"},"fr-tbl-cell-bd":{value:"0 solid transparent",note:"表格格线。疏朗不画(靠斑马纹);界栏全格线"},"fr-tbl-zebra":{value:"var(--bim-tint-bg)",note:"表格斑马纹(只在疏朗下有)"},"fr-rail-bd":{value:"1px solid transparent",note:"侧栏里的块、提示块的边框"},"fr-rail-bg":{value:"var(--bim-tint-bg)",note:"侧栏块底。疏朗浅底;界栏卡面底"},"fr-spine-bd":{value:"1px solid transparent",note:"题签、书脊(竖排书名)的边框。界栏是强调色浅线"},"fr-spine-bg":{value:"var(--bim-flag-bg)",note:"题签、书脊底。疏朗浅色实底;界栏卡面底(正史原志两种版式都是强调色实底)"},"fr-plank":{value:"0 solid transparent",note:"书架架板(border 简写)。只在界栏下画 3px"},"fr-axis-bd":{value:"0 solid transparent",note:"时间轴轴线。界栏 1px"},"fr-axis-band":{value:"6px",note:"时间轴底带高度。疏朗用 6px 浅色带代替轴线;界栏 0"},"fr-tick":{value:"0",note:"时间轴刻度短线长度。界栏 5px"},"fr-band-gap":{value:"3px",note:"年代带各段之间的空隙。疏朗 3px;界栏紧贴"},"fr-band-bd":{value:"0 solid transparent",note:"年代带外框与段间分隔。界栏 1px"}}),lt("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"},"reader-warm":{value:"#c9a24a",note:"阅读设置侧栏的暖黄:只做底色(8%)与选中态(24%),与朱/靛/墨三套主色都不冲"},"warp-bg":{value:"#faf8f5",note:"古籍矫正底本书影画布底色"},"warp-box-shadow":{value:"0 2px 12px rgba(0, 0, 0, 0.08)",note:"古籍底本书影浮雕阴影"},"warp-sel-bg":{value:"rgba(196, 148, 76, 0.45)",note:"古籍对读字框选中高亮底色"},"warp-sel-stroke":{value:"#a06e1c",note:"古籍对读字框选中描边"},"warp-hover-bg":{value:"rgba(217, 185, 106, 0.25)",note:"古籍对读字框悬停高亮底色"},"warp-hover-stroke":{value:"#c4944c",note:"古籍对读字框悬停描边"},"warp-badge-bg":{value:"rgba(184, 134, 54, 0.12)",note:"图文对读徽章背景"},"warp-badge-fg":{value:"#8c6820",note:"图文对读徽章文字颜色"},"warp-badge-bd":{value:"rgba(184, 134, 54, 0.3)",note:"图文对读徽章边框"},"warp-banxin-border":{value:"#8a8070",note:"版心分界线"},"warp-banxin-fold":{value:"rgba(160, 110, 28, 0.65)",note:"版心中缝对折线"},"warp-banxin-outer":{value:"#c9c3b4",note:"版心外边线"}}),lt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),lt("字体(全站无衬线,2026-09-05 定)",{"font-ui":{value:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif'},"font-body":{value:"system-ui, sans-serif",css:"var(--bim-font-ui)"},"font-serif":{value:fs,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:fs,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],Fp=Object.assign({},...Op.map(e=>e.tokens)),tl={};for(const[e,n]of Object.entries(Fp))tl[e]=`var(--bim-${e}, ${n.value})`;function r(e){const n=tl[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function Mt(e){return e.types&&e.types.length>0?e.types:[]}function Hp(e,n){return Mt(e).includes(n)}const Dp={source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暫無正文",placeholder:"占位"};r("quality-source"),r("quality-ocr"),r("quality-rough"),r("quality-fine"),r("quality-none"),r("quality-placeholder");const Up={"commons.wikimedia.org":"維基共享","zh.wikisource.org":"維基文庫","taiwanebook.ncl.edu.tw":"臺灣華文電子書庫","ctext.org":"中國哲學書電子化計劃","www.shidianguji.com":"識典古籍","shidianguji.com":"識典古籍","archive.org":"Internet Archive","www.shuge.org":"書格","shuge.org":"書格","pan.baidu.com":"百度網盤"};function fn(e){try{return Up[new URL(e).hostname]}catch{return}}const xs={text:0,image:1,physical:2};function Gr(e){return e.length===0?"physical":[...e].sort((n,i)=>(xs[n]??99)-(xs[i]??99)).join("+")}function Vp(e){return e.includes("text")&&e.includes("image")?"text+image":e[0]||"physical"}function Yr(e){var l;const n=d=>{const c=d.match(/^(.+?)·第(\d+)[冊册]$/);if(c)return[c[1],parseInt(c[2])];const p=d.match(/^(.+?)[·(](\d+)[)]?$/);return p?[p[1],parseInt(p[2])]:null},i=new Map;for(let d=0;d<e.length;d++){const c=e[d];if(c.volumes&&c.volumes.length>0)continue;const p=n(c.name);if(!p)continue;const[h,u]=p,m=`${h}|${Gr(Mt(c))}`;i.has(m)||i.set(m,{base:{...c,name:h,url:"",volumes:[]},volumes:[],indices:[]});const f=i.get(m);f.volumes.push({volume:u,url:c.url||void 0,status:"found"}),f.indices.push(d)}const o=[],s=new Set;for(const d of i.values())if(!(d.volumes.length<2)){d.volumes.sort((c,p)=>c.volume-p.volume),d.base.volumes=d.volumes,d.base.expected_volumes=d.volumes.length,d.base.url||(d.base.url=((l=d.volumes.find(c=>c.url))==null?void 0:l.url)??""),o.push(d.base);for(const c of d.indices)s.add(c)}const a=[...o];for(let d=0;d<e.length;d++)s.has(d)||a.push(e[d]);return a}function nl(e){if(e.url)return e.url;for(const[n,i]of Object.entries(e))if(n.endsWith("_url")&&typeof i=="string")return i}function il(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||nl(n)}))}function ki(e){const n=il(e);if(!n)return null;const i=new Set(n.filter(s=>s.status!=="missing").map(s=>s.volume)).size,o=new Set(n.filter(s=>s.status==="missing").map(s=>s.volume)).size;return{found:i,missing:o,expected:e.expected_volumes??i+o}}function qr(e){if(!e)return;const n=e.file_page_range||e.page_range;if(!n||typeof n!="string")return;const i=n.match(/^(\d+)/);return i?parseInt(i[1],10):void 0}function Kr(e,n){try{if(new URL(e).hostname.includes("wikimedia.org")){const o=e.match(/\/wiki\/File:(.+?)(?:#|$)/);if(o)return`https://commons.wikimedia.org/w/index.php?title=File%3A${encodeURIComponent(decodeURIComponent(o[1]))}&page=${n}`;const s=new URL(e);return s.searchParams.set("page",String(n)),s.toString()}return e}catch{return e}}function xn(e){if(!e.url)return;const n=qr(e.metadata);return n?Kr(e.url,n):e.url}const Tt=g.createContext(null),rl=["曹霑"];function Gp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Yp(e,n=rl){const i=[...new Set(n.filter(Boolean))].sort((a,l)=>l.length-a.length);if(!i.length)return e;const o=new RegExp(`(${i.map(Gp).join("|")})`,"g"),s=new Set(i);return a=>{if(!a)return e(a);const l=a.split(o);return l.length===1?e(a):l.map((d,c)=>c%2===1&&s.has(d)?d:d&&e(d)).join("")}}let wn=null;function ol(){if(wn)return wn;try{const e=Ap.Converter({from:"t",to:"cn"});wn=Yp(n=>e(Se.normalizeVariants(n)))}catch{wn=e=>e}return wn}const qp={indexType:{work:"作品",book:"書籍",collection:"叢編",entity:"人物"},resourceType:{text:"文字資源",image:"圖片資源",textImage:"文字+圖片資源",physical:"館藏"},resourceTypeShort:{text:"文字",image:"圖片",textImage:"文字+圖片",physical:"館藏"},rootType:{catalog:"目錄式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:r("check-fine-bg"),fg:r("check-fine-fg")},粗校:{label:"粗校",bg:r("check-rough-bg"),fg:r("check-rough-fg")},AI整理:{label:"AI整理",bg:r("check-ai-bg"),fg:r("check-ai-fg")}},action:{save:"保存",delete:"刪除",newEntry:"+ 新建",viewAll:"查看全部 →",visit:"訪問 →",view:"查看 →",viewEntity:"查看",copy:"複製 ID",copied:"已複製",linkExisting:"+ 關聯現有",createAndLink:"+ 創建並關聯",remove:"刪除",clearAll:"清除全部",reselect:"重選",changeType:"更換類型",expand:"展開",collapse:"收起",expandMore:"展開更多",addSubWork:"添加子作品",addVersion:"添加新版本",addBook:"添加書籍",addSubCollection:"添加子叢編",addCollectionImpl:"添加叢編實現",addSource:"添加來源",addResource:"添加資源",addIndexedBy:"+ 添加收錄來源",addEmendatedBy:"+ 添加考證來源",addAdditionalWork:"+ 添加附屬作品",selectBookOrWork:"選擇書籍/作品",clickToSelectBookOrWork:"點擊選擇書籍/作品",unlink:"解除關聯"},label:{id:"ID:",author:"作者 (Author)",dynasty:"朝代/年份 (Dynasty/Year)",edition:"版本",juanCount:"卷數",pageCount:"頁數 (Pages)",volumeCount:"冊數 (Volumes)",holder:"現藏於 (Holder)",firstImage:"首頁圖片 (First Image URL)",year:"年代",currentLocation:"現藏",parentWork:"上級作品",relatedWorks:"相關作品",type:"類型",rootType:"根類型",coverageLevel:"覆蓋層級",coverageRange:"覆蓋範圍",metadata:"元數據",optionalInfo:"可選信息",details:"詳細說明",detailsOptional:"詳細說明 (可選)",positionOptional:"位置/頁碼 (可選)",dataVersionOptional:"數據版本 (可選)",processorVersionOptional:"處理器版本 (可選)",sourceName:"來源名稱",sourceBid:"來源 BID",titleInfo:"題名",authorInfo:"著者",urlAddress:"URL 地址"},section:{basicInfo:"📊 基本信息",description:"📝 介紹 (Description)",additionalWorks:"📑 附屬作品 (Additional Works)",indexedBy:"📖 著錄於",emendatedBy:"📝 考證",resources:"資源",textResources:"📝 文字資源 (Text Resources)",imageResources:"🖼️ 圖片資源 (Image Resources)",sources:"📚 資料來源 (Sources)",provenance:"📜 收藏歷史 (Provenance)",relatedVersions:"相關版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危險區域 (Danger Zone)",aliases:"別名",attachedTexts:"附載篇目",appendix:"附錄",containedIn:"收入叢編",collectedIn:"收入叢編",belongsToWork:"所屬作品",locationHistory:"流轉歷史",historyOverview:"歷史沿革",containedBooks:"收錄書籍",relations:"關聯關係",summary:"提要",comment:"按語",additionalComment:"附按",indexed:"收錄於",emendated:"考證",relatedWorks:"相關作品",containedWorks:"包含作品",adaptations:"改編作品",derivativeWorks:"續書與評註",studies:"所考典籍"},relation:{belongsToWork:"所屬作品 (Work)",containedInCollection:"收入叢編",siblingVersions:"同作品其他版本",addVersionForWork:"為此作品添加新版本",parentWork:"父作品 (Parent Work)",childWorks:"子作品",collectionImpl:"叢編實現",allVersions:"所有版本",correspondingWork:"對應作品 (Work)",parentCollection:"父叢編 (Parent Collection)",childCollections:"子叢編",containedBooks:"包含書籍",notLinked:"(未關聯)",none:"(暫無)"},search:{placeholder:"搜索作品、書籍、叢編...",searching:"搜索中...",loading:"加載中...",noResults:"無匹配結果",noResultsFor:"未找到與「{query}」相關的結果",tryOther:"試試其他關鍵詞、別名或作者名",recentBrowse:"最近瀏覽",history:"搜索歷史",clearAll:"清除全部",clearRecent:"清除最近瀏覽",itemNotFound:"無法找到,可能已刪除",removeFromRecent:"移除",searchTitle:"搜索古籍索引",allTab:"全部",resultTabs:"結果分類",searchSubtitle:"輸入關鍵詞搜索作品、書籍或叢編",searchBookName:"搜索書名...",alias:"別名"},searchV4:{filterTitle:"篩選",dynasty:"朝代",classification:"部類",resources:"資源",extant:"存佚",clearAllFilters:"清除全部篩選",hasImage:"有影印",hasText:"有文本",hasCollated:"有文本",filterButton:"篩選",filterSelected:"{n} 項已選",expand:"展開",collapse:"收起",filteredCount:"篩出 {n} 條",removeFilter:"取消篩選:{name}",viewLabel:"結果視圖",viewTable:"表格",viewCard:"卡片",colTitle:"題名",colType:"類型",colAuthor:"責任者",colEra:"年代",colClass:"部類",colResource:"資源",tagImage:"影印",tagText:"文本",tagCollated:"文本",tagLost:"佚",pageInfo:"共 {total} 條 · 每頁 {size} 條 · 第 {page} / {pages} 頁",pagerLabel:"翻頁",prevPage:"上一頁",nextPage:"下一頁",emptyFiltered:"沒有找到匹配的條目。試試更短的書名、減少篩選,或切換繁 / 簡。",limitedNote:"各類只列前幾條,點上方分類頁籤看全部。",sortLabel:"排序",sortRelevance:"相關度",sortEra:"年代",sortTitle:"書名",sortEraAsc:"由早到晚",sortEraDesc:"由晚到早",sortTitleAsc:"拼音 A→Z",sortTitleDesc:"拼音 Z→A"},home:{title:"古籍索引",subtitle:"從左側搜索框輸入關鍵詞,查找作品、書籍或叢編",recommendedBrowse:"推薦瀏覽",catalogTab:"目錄",collectionTab:"叢編",siteTab:"在線資源",recommendTab:"推薦",feedbackTab:"反饋",statusInProgress:"進行中",statusDone:"已完成",statusTodo:"未開始",typeCatalog:"目錄",typeCollection:"資源集合",totalPending:"待統計",progressFormat:"{imported} / {total}",siteCoverage:"資源覆蓋"},browser:{title:"古籍資源索引",subtitle:""},detailTab:{basicInfo:"概覽",catalog:"目錄",collectionCatalog:"叢編目錄",collatedEdition:"文本",catalogSuffix:"·目錄",fullText:"文本",lineage:"版本傳承",feedback:"勘誤反饋",dataSource:"數據源",backToIndex:"典籍版本索引",submitVersion:"提交新版本",dataLicense:"數據源與授權"},metadata:{edition:"版本",version:"修訂版本",quality:"資源質量",check_type:"校對",image_source:"影像來源",team:"所屬團隊",publisher:"出版社",year:"出版年份",format:"格式",note:"備註",total_page:"頁數",total_pages:"總頁數",page_range:"頁碼範圍",page_count:"頁數",file_page_range:"文件頁碼",file_page_count:"文件頁數",content_page_range:"影印頁碼",volume:"冊",color_mode:"色彩",paragraph_count:"段落數",has_translation:"翻譯"},editor:{untitled:"未命名",workTitle:"作品名 (Work Title)",collectionTitle:"叢書名 (Collection Title)",bookTitle:"書名 (Book Title)",belongsToWork:"所屬作品 (Work)",authorLabel:"作者 (Author)",publicationYearLabel:"出版年 (Publication year)",containedIn:"收入叢編",holderLabel:"現藏於 (Holder)",pageLabel:"頁數 (Pages)",volumeLabel:"冊數 (Volumes)",firstImageLabel:"首頁圖片 (First Image URL)",descriptionPlaceholder:"簡要介紹...",provenancePlaceholder:"該資源的流轉與收藏記錄...",otherEditionsPlaceholder:"相關版本的 ID...",dangerZoneDesc:"從索引庫中永久刪除該實體的所有元數據文件。",deleteEntity:"刪除該實體 (Delete Entity)",selectToLink:"選擇要關聯的",unnamedSource:"(未命名來源)",selectSourceType:"選擇來源類型",fromExistingBook:"從現有書籍選擇",enterUrl:"輸入網址鏈接",sourceNamePlaceholder:"如: 維基文庫、中國基本古籍庫",deleteThisSource:"刪除此來源",deleteThisResource:"刪除此資源",resourcePlaceholder:"資源",idAutoExtract:"ID (自動從URL提取)",resourceName:"資源名稱",resourceUrl:"資源鏈接 (URL)",structurePlaceholder:"層級結構 (如: 冊、卷)",coverageRangePlaceholder:"如: 2,3,5-8",detailsPlaceholder:"詳細說明",summaryPlaceholder:"提要...",commentPlaceholder:"按語...",additionalCommentPlaceholder:"附按...",imageResourceLink:"圖片資源鏈接",bookNameLabel:"書名",sourcePlaceholder:"來源"},download:{completed:"下載完成",downloading:"下載中",downloadThis:"下載此資源"},mode:{localMode:"本地模式",syncMode:"同步模式:",githubSync:"GitHub 同步",switchToSync:"點擊切換到同步模式",switchToLocal:"點擊切換到本地模式",switchToGithub:"點擊切換到 GitHub 同步模式",switchToDraft:"點擊切換到 draft 倉庫",switchToOfficial:"點擊切換到 official 倉庫",selectFolder:"選擇本地文件夾",configurePath:"配置同步路徑"},catalog:{totalVolumes:"共",processed:"已處理",contains:"收錄",matched:"已匹配",unmatched:"待匹配",source:"來源:",all:"全部",loading:"加載叢編目錄...",notFound:"未找到叢編目錄數據",loadFailed:"加載失敗",noMatch:"無匹配結果",unmatched_label:"未匹配",volume:"第 {n} 冊"},unit:{juan:"卷",volume:"冊",bu:"部",items:"條"},workSubtype:{book:"書",article:"篇",poem:"詩",chapter:"篇章"},colorMode:{bw:"黑白",color:"彩色"},misc:{noResources:"暫無資源信息",hasTranslation:"有",noTranslation:"無",structure:"層級",coverage:"覆蓋",notFoundEntry:"未找到該條目",loadFailed:"加載失敗",textResource:"文字資源",imageResource:"圖片資源"}},Kp={indexType:{work:"作品",book:"书籍",collection:"丛编",entity:"人物"},resourceType:{text:"文字资源",image:"图片资源",textImage:"文字+图片资源",physical:"馆藏"},resourceTypeShort:{text:"文字",image:"图片",textImage:"文字+图片",physical:"馆藏"},rootType:{catalog:"目录式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:r("check-fine-bg"),fg:r("check-fine-fg")},粗校:{label:"粗校",bg:r("check-rough-bg"),fg:r("check-rough-fg")},AI整理:{label:"AI整理",bg:r("check-ai-bg"),fg:r("check-ai-fg")}},action:{save:"保存",delete:"删除",newEntry:"+ 新建",viewAll:"查看全部 →",visit:"访问 →",view:"查看 →",viewEntity:"查看",copy:"复制 ID",copied:"已复制",linkExisting:"+ 关联现有",createAndLink:"+ 创建并关联",remove:"删除",clearAll:"清除全部",reselect:"重选",changeType:"更换类型",expand:"展开",collapse:"收起",expandMore:"展开更多",addSubWork:"添加子作品",addVersion:"添加新版本",addBook:"添加书籍",addSubCollection:"添加子丛编",addCollectionImpl:"添加丛编实现",addSource:"添加来源",addResource:"添加资源",addIndexedBy:"+ 添加收录来源",addEmendatedBy:"+ 添加考证来源",addAdditionalWork:"+ 添加附属作品",selectBookOrWork:"选择书籍/作品",clickToSelectBookOrWork:"点击选择书籍/作品",unlink:"解除关联"},label:{id:"ID:",author:"作者 (Author)",dynasty:"朝代/年份 (Dynasty/Year)",edition:"版本",juanCount:"卷数",pageCount:"页数 (Pages)",volumeCount:"册数 (Volumes)",holder:"现藏于 (Holder)",firstImage:"首页图片 (First Image URL)",year:"年代",currentLocation:"现藏",parentWork:"上级作品",relatedWorks:"相关作品",type:"类型",rootType:"根类型",coverageLevel:"覆盖层级",coverageRange:"覆盖范围",metadata:"元数据",optionalInfo:"可选信息",details:"详细说明",detailsOptional:"详细说明 (可选)",positionOptional:"位置/页码 (可选)",dataVersionOptional:"数据版本 (可选)",processorVersionOptional:"处理器版本 (可选)",sourceName:"来源名称",sourceBid:"来源 BID",titleInfo:"题名",authorInfo:"著者",urlAddress:"URL 地址"},section:{basicInfo:"📊 基本信息",description:"📝 介绍 (Description)",additionalWorks:"📑 附属作品 (Additional Works)",indexedBy:"📖 著录于",emendatedBy:"📝 考证",resources:"资源",textResources:"📝 文字资源 (Text Resources)",imageResources:"🖼️ 图片资源 (Image Resources)",sources:"📚 资料来源 (Sources)",provenance:"📜 收藏历史 (Provenance)",relatedVersions:"相关版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危险区域 (Danger Zone)",aliases:"别名",attachedTexts:"附载篇目",appendix:"附录",containedIn:"收入丛编",collectedIn:"收入丛编",belongsToWork:"所属作品",locationHistory:"流转历史",historyOverview:"历史沿革",containedBooks:"收录书籍",relations:"关联关系",summary:"提要",comment:"按语",additionalComment:"附按",indexed:"收录于",emendated:"考证",relatedWorks:"相关作品",containedWorks:"包含作品",adaptations:"改编作品",derivativeWorks:"续书与评注",studies:"所考典籍"},relation:{belongsToWork:"所属作品 (Work)",containedInCollection:"收入丛编",siblingVersions:"同作品其他版本",addVersionForWork:"为此作品添加新版本",parentWork:"父作品 (Parent Work)",childWorks:"子作品",collectionImpl:"丛编实现",allVersions:"所有版本",correspondingWork:"对应作品 (Work)",parentCollection:"父丛编 (Parent Collection)",childCollections:"子丛编",containedBooks:"包含书籍",notLinked:"(未关联)",none:"(暂无)"},search:{placeholder:"搜索作品、书籍、丛编...",searching:"搜索中...",loading:"加载中...",noResults:"无匹配结果",noResultsFor:"未找到与「{query}」相关的结果",tryOther:"试试其他关键词、别名或作者名",recentBrowse:"最近浏览",history:"搜索历史",clearAll:"清除全部",clearRecent:"清除最近浏览",itemNotFound:"无法找到,可能已删除",removeFromRecent:"移除",searchTitle:"搜索古籍索引",allTab:"全部",resultTabs:"结果分类",searchSubtitle:"输入关键词搜索作品、书籍或丛编",searchBookName:"搜索书名...",alias:"别名"},searchV4:{filterTitle:"筛选",dynasty:"朝代",classification:"部类",resources:"资源",extant:"存佚",clearAllFilters:"清除全部筛选",hasImage:"有影印",hasText:"有文本",hasCollated:"有文本",filterButton:"筛选",filterSelected:"{n} 项已选",expand:"展开",collapse:"收起",filteredCount:"筛出 {n} 条",removeFilter:"取消筛选:{name}",viewLabel:"结果视图",viewTable:"表格",viewCard:"卡片",colTitle:"题名",colType:"类型",colAuthor:"责任者",colEra:"年代",colClass:"部类",colResource:"资源",tagImage:"影印",tagText:"文本",tagCollated:"文本",tagLost:"佚",pageInfo:"共 {total} 条 · 每页 {size} 条 · 第 {page} / {pages} 页",pagerLabel:"翻页",prevPage:"上一页",nextPage:"下一页",emptyFiltered:"没有找到匹配的条目。试试更短的书名、减少筛选,或切换繁 / 简。",limitedNote:"各类只列前几条,点上方分类页签看全部。",sortLabel:"排序",sortRelevance:"相关度",sortEra:"年代",sortTitle:"书名",sortEraAsc:"由早到晚",sortEraDesc:"由晚到早",sortTitleAsc:"拼音 A→Z",sortTitleDesc:"拼音 Z→A"},home:{title:"古籍索引",subtitle:"从左侧搜索框输入关键词,查找作品、书籍或丛编",recommendedBrowse:"推荐浏览",catalogTab:"目录",collectionTab:"丛编",siteTab:"在线资源",recommendTab:"推荐",feedbackTab:"反馈",statusInProgress:"进行中",statusDone:"已完成",statusTodo:"未开始",typeCatalog:"目录",typeCollection:"资源集合",totalPending:"待统计",progressFormat:"{imported} / {total}",siteCoverage:"资源覆盖"},browser:{title:"古籍资源索引",subtitle:""},detailTab:{basicInfo:"概览",catalog:"目录",collectionCatalog:"丛编目录",collatedEdition:"文本",catalogSuffix:"·目录",fullText:"文本",lineage:"版本传承",feedback:"勘误反馈",dataSource:"数据源",backToIndex:"典籍版本索引",submitVersion:"提交新版本",dataLicense:"数据源与授权"},metadata:{edition:"版本",version:"修订版本",quality:"资源质量",check_type:"校对",image_source:"影像来源",team:"所属团队",publisher:"出版社",year:"出版年份",format:"格式",note:"备注",total_page:"页数",total_pages:"总页数",page_range:"页码范围",page_count:"页数",file_page_range:"文件页码",file_page_count:"文件页数",content_page_range:"影印页码",volume:"册",color_mode:"色彩",paragraph_count:"段落数",has_translation:"翻译"},editor:{untitled:"未命名",workTitle:"作品名 (Work Title)",collectionTitle:"丛书名 (Collection Title)",bookTitle:"书名 (Book Title)",belongsToWork:"所属作品 (Work)",authorLabel:"作者 (Author)",publicationYearLabel:"出版年 (Publication year)",containedIn:"收入丛编",holderLabel:"现藏于 (Holder)",pageLabel:"页数 (Pages)",volumeLabel:"册数 (Volumes)",firstImageLabel:"首页图片 (First Image URL)",descriptionPlaceholder:"简要介绍...",provenancePlaceholder:"该资源的流转与收藏记录...",otherEditionsPlaceholder:"相关版本的 ID...",dangerZoneDesc:"从索引库中永久删除该实体的所有元数据文件。",deleteEntity:"删除该实体 (Delete Entity)",selectToLink:"选择要关联的",unnamedSource:"(未命名来源)",selectSourceType:"选择来源类型",fromExistingBook:"从现有书籍选择",enterUrl:"输入网址链接",sourceNamePlaceholder:"如: 维基文库、中国基本古籍库",deleteThisSource:"删除此来源",deleteThisResource:"删除此资源",resourcePlaceholder:"资源",idAutoExtract:"ID (自动从URL提取)",resourceName:"资源名称",resourceUrl:"资源链接 (URL)",structurePlaceholder:"层级结构 (如: 册、卷)",coverageRangePlaceholder:"如: 2,3,5-8",detailsPlaceholder:"详细说明",summaryPlaceholder:"提要...",commentPlaceholder:"按语...",additionalCommentPlaceholder:"附按...",imageResourceLink:"图片资源链接",bookNameLabel:"书名",sourcePlaceholder:"来源"},download:{completed:"下载完成",downloading:"下载中",downloadThis:"下载此资源"},mode:{localMode:"本地模式",syncMode:"同步模式:",githubSync:"GitHub 同步",switchToSync:"点击切换到同步模式",switchToLocal:"点击切换到本地模式",switchToGithub:"点击切换到 GitHub 同步模式",switchToDraft:"点击切换到 draft 仓库",switchToOfficial:"点击切换到 official 仓库",selectFolder:"选择本地文件夹",configurePath:"配置同步路径"},catalog:{totalVolumes:"共",processed:"已处理",contains:"收录",matched:"已匹配",unmatched:"待匹配",source:"来源:",all:"全部",loading:"加载丛编目录...",notFound:"未找到丛编目录数据",loadFailed:"加载失败",noMatch:"无匹配结果",unmatched_label:"未匹配",volume:"第 {n} 册"},unit:{juan:"卷",volume:"册",bu:"部",items:"条"},workSubtype:{book:"书",article:"篇",poem:"诗",chapter:"篇章"},colorMode:{bw:"黑白",color:"彩色"},misc:{noResources:"暂无资源信息",hasTranslation:"有",noTranslation:"无",structure:"层级",coverage:"覆盖",notFoundEntry:"未找到该条目",loadFailed:"加载失败",textResource:"文字资源",imageResource:"图片资源"}};function dt(e,n,i){return{"zh-Hant":e,"zh-Hans":n}}const Xp=dt({toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主題",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加載中",repoSourceLink:"在 GitHub 查看本條目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分冊",expandVolumes:"展開分冊",collapseArrow:"收起 ▲",expandArrow:"展開 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年號",office:"官職",anonymous:"佚名",collective:"集體"},cbdbTitle:"CBDB 中國歷代人物傳記數據庫",entityPlaceholderNote:"人物信息暫缺。該 Entity 僅作為作者佔位,詳細生平資料尚待補充。",otherVersions:"其他版本",switchToEdit:"切換到編輯模式",switchToView:"切換到查看模式",modeEdit:"✏️ 編輯",modeView:"👁 查看",noData:"無數據"},{toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主题",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加载中",repoSourceLink:"在 GitHub 查看本条目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分册",expandVolumes:"展开分册",collapseArrow:"收起 ▲",expandArrow:"展开 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年号",office:"官职",anonymous:"佚名",collective:"集体"},cbdbTitle:"CBDB 中国历代人物传记数据库",entityPlaceholderNote:"人物信息暂缺。该 Entity 仅作为作者占位,详细生平资料尚待补充。",otherVersions:"其他版本",switchToEdit:"切换到编辑模式",switchToView:"切换到查看模式",modeEdit:"✏️ 编辑",modeView:"👁 查看",noData:"无数据"}),wi=dt({relation:{part_of:"所屬",has_part:"包含",contains_text_of:"收錄",collected_in:"叢編",text_carried_by:"載錄",studied_by:"研究",studies:"所考",preceded_by:"前承",followed_by:"後繼",derived_from:"衍生",has_adaptation:"改編",related:"相關"},lossStatus:{extant:"今存",fragment:"殘存",partial:"殘存",lost:"已佚",unknown:"未詳"},resourceKind:{text:"文本",image:"影印",textImage:"圖文",physical:"館藏"},otherImages:"其他影印",fragmentTag:"殘片",collapseVolumes:"收起分冊",expandVolumes:"展開 {n} 冊",mirror:"鏡像",volumeStats:"{found} / {expected} 冊",volumeStatsMissing:"{found} / {expected} 冊 缺 {missing}",pageNav:"本頁導航",thisPage:"本頁",more:"更多",expandRest:"展開其餘 {n} {unit}",read:"閱讀",showMore:"顯示更多({n})",review:{reviewed:"已審核",disputed:"有爭議",unreviewed:"未審核",draft:"草稿"},dataVersion:"數據版本",todoCount:"待核 {n} 項",lacuna:"闕文",lacunaWith:"闕文:{label}",composedChar:"組字:{label}",bce:"前{n}",roleAll:"全部",loading:"加載中…",noLineageGraph:"暫無版本圖數據",notFound:"找不到該條目,可能已被刪除或 ID 不正確",workInfo:"作品信息"},{relation:{part_of:"所属",has_part:"包含",contains_text_of:"收录",collected_in:"丛编",text_carried_by:"载录",studied_by:"研究",studies:"所考",preceded_by:"前承",followed_by:"后继",derived_from:"衍生",has_adaptation:"改编",related:"相关"},lossStatus:{extant:"今存",fragment:"残存",partial:"残存",lost:"已佚",unknown:"未详"},resourceKind:{text:"文本",image:"影印",textImage:"图文",physical:"馆藏"},otherImages:"其他影印",fragmentTag:"残片",collapseVolumes:"收起分册",expandVolumes:"展开 {n} 册",mirror:"镜像",volumeStats:"{found} / {expected} 册",volumeStatsMissing:"{found} / {expected} 册 缺 {missing}",pageNav:"本页导航",thisPage:"本页",more:"更多",expandRest:"展开其余 {n} {unit}",read:"阅读",showMore:"显示更多({n})",review:{reviewed:"已审核",disputed:"有争议",unreviewed:"未审核",draft:"草稿"},dataVersion:"数据版本",todoCount:"待核 {n} 项",lacuna:"阙文",lacunaWith:"阙文:{label}",composedChar:"组字:{label}",bce:"前{n}",roleAll:"全部",loading:"加载中…",noLineageGraph:"暂无版本图数据",notFound:"找不到该条目,可能已被删除或 ID 不正确",workInfo:"作品信息"}),Zp=dt({kind:"版本",fact:{editionType:"版本類型",publication:"刊印",era:"刊寫年代",measure:"卷帙",volumes:"冊次",baseEdition:"底本",holdings:"存藏",callNumber:"索書號",seals:"藏印",leafStyle:"行款",binding:"裝幀",dimensions:"尺寸",condition:"品相",aliases:"又名"},inferredFromEdition:"據版本題名推斷",volumesValue:"第 {range} {unit}({n} {unit})",andMorePlaces:" 等 {n} 處",viewImages:"看原書影印",sec:{fulltext:"文本",images:"影印",physical:"館藏",lineage:"版本源流",empty:"影印與文本"},chapterUnit:"章",chapterCount:"{n} {unit}",sourceBy:"據{src}",readFrom:"從{ch}讀起",firstChapter:"第一章",enterReader:"進入閱讀頁",externalText:"站外文本",groupCount:"{n} 組",placeCount:"{n} 處",lineageMeta:"據版本傳承著錄",lineageView:"源流視圖",viewCards:"卡片",viewGraph:"關係圖",totalOf:"全 {n} {unit}",emptyText:"尚未著錄該版本的影印、文本與收藏信息。",editionCount:"{n} 種版本",siblings:"同作品版本",byEra:"按年代",kindCount:"{n} 種",viewAllInWork:"在作品頁看全部 {n} 種 →",volumeRange:"第 {range} {unit}",volumeCount:"{n} {unit}",confidence:{certain:"確證",consensus:"通說",probable:"可能",disputed:"有爭議"},confidenceNote:"({c})",lineage:{ancestor:"祖本",reconstructed:"擬構祖本",thisEdition:"本版",derivatives:"翻刻 · 衍生",appendix:"附記"}},{kind:"版本",fact:{editionType:"版本类型",publication:"刊印",era:"刊写年代",measure:"卷帙",volumes:"册次",baseEdition:"底本",holdings:"存藏",callNumber:"索书号",seals:"藏印",leafStyle:"行款",binding:"装帧",dimensions:"尺寸",condition:"品相",aliases:"又名"},inferredFromEdition:"据版本题名推断",volumesValue:"第 {range} {unit}({n} {unit})",andMorePlaces:" 等 {n} 处",viewImages:"看原书影印",sec:{fulltext:"文本",images:"影印",physical:"馆藏",lineage:"版本源流",empty:"影印与文本"},chapterUnit:"章",chapterCount:"{n} {unit}",sourceBy:"据{src}",readFrom:"从{ch}读起",firstChapter:"第一章",enterReader:"进入阅读页",externalText:"站外文本",groupCount:"{n} 组",placeCount:"{n} 处",lineageMeta:"据版本传承著录",lineageView:"源流视图",viewCards:"卡片",viewGraph:"关系图",totalOf:"全 {n} {unit}",emptyText:"尚未著录该版本的影印、文本与收藏信息。",editionCount:"{n} 种版本",siblings:"同作品版本",byEra:"按年代",kindCount:"{n} 种",viewAllInWork:"在作品页看全部 {n} 种 →",volumeRange:"第 {range} {unit}",volumeCount:"{n} {unit}",confidence:{certain:"确证",consensus:"通说",probable:"可能",disputed:"有争议"},confidenceNote:"({c})",lineage:{ancestor:"祖本",reconstructed:"拟构祖本",thisEdition:"本版",derivatives:"翻刻 · 衍生",appendix:"附记"}}),Jp=dt({fact:{written:"成書",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考證",alias:"又名",attached:"附載",appendix:"附錄"},inferredFromEdition:"據版本題名推斷",loading:"載入中",emendationCount:"{n} 條",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著錄"},classifiedBy:"據《{source}》",sec:{versions:"版本",catalogs:"著錄",collected:"收入叢編",related:"相關書目",resources:"在線資源"},versionsTotal:"共 {n} 種",versionsWithImage:"{n} 種有影印",versionsCurrent:"當前 {n} 種",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著錄順序",col:{edition:"版本",era:"年代",holder:"館藏",image:"影印"},noVersionsFiltered:"當前篩選下沒有版本",noVersions:"暫無版本著錄",moreUnit:"種版本",inferredEraNote:"部分年代據版本題名推斷,非著錄原文",empty:"尚未著錄該作品的版本與書目收錄。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"歷代書目 {n} 家",tablist:"著錄書目",titleOnly:"僅著錄書名,無提要。",prev:"上一家:{name}",next:"下一家:{name}"}},{fact:{written:"成书",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考证",alias:"又名",attached:"附载",appendix:"附录"},inferredFromEdition:"据版本题名推断",loading:"载入中",emendationCount:"{n} 条",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著录"},classifiedBy:"据《{source}》",sec:{versions:"版本",catalogs:"著录",collected:"收入丛编",related:"相关书目",resources:"在线资源"},versionsTotal:"共 {n} 种",versionsWithImage:"{n} 种有影印",versionsCurrent:"当前 {n} 种",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著录顺序",col:{edition:"版本",era:"年代",holder:"馆藏",image:"影印"},noVersionsFiltered:"当前筛选下没有版本",noVersions:"暂无版本著录",moreUnit:"种版本",inferredEraNote:"部分年代据版本题名推断,非著录原文",empty:"尚未著录该作品的版本与书目收录。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"历代书目 {n} 家",tablist:"著录书目",titleOnly:"仅著录书名,无提要。",prev:"上一家:{name}",next:"下一家:{name}"}}),Qp=dt({kind:"叢編",workCollection:"作品集",stat:{titles:"子目"},fact:{publication:"刊印",expected:"應收",measure:"卷帙"},member:{Book:"所收版本",Work:"所收作品",other:"成員"},memberNote:"子目與其各版本合計",nZhong:"{n} 種",nHan:"{n} 函",dist:{head:"全帙冊次分佈",segTitle:"{section} 第 {from}–{to} 冊",only:"只看{section}",unclassified:"未分類",hint:"點色段篩選部類"},sec:{titles:"子目",resources:"影印與文本"},totalVolumes:"全帙 {n} {unit}",currentN:"當前 {n} {unit}",loadAllTitle:"將載入全部 {n} {unit}",grouping:"正在按部類分組…",groupBySection:"按部類分組",find:"在本叢編中檢索",col:{volumes:"冊次",title:"書名",versions:"版本"},volumeRange:"第 {range} {unit}",resourcesCount:"{n} 處",text:"文本",empty:"尚未著錄該叢編的子目。",parent:"上級叢編"},{kind:"丛编",workCollection:"作品集",stat:{titles:"子目"},fact:{publication:"刊印",expected:"应收",measure:"卷帙"},member:{Book:"所收版本",Work:"所收作品",other:"成员"},memberNote:"子目与其各版本合计",nZhong:"{n} 种",nHan:"{n} 函",dist:{head:"全帙册次分布",segTitle:"{section} 第 {from}–{to} 册",only:"只看{section}",unclassified:"未分类",hint:"点色段筛选部类"},sec:{titles:"子目",resources:"影印与文本"},totalVolumes:"全帙 {n} {unit}",currentN:"当前 {n} {unit}",loadAllTitle:"将载入全部 {n} {unit}",grouping:"正在按部类分组…",groupBySection:"按部类分组",find:"在本丛编中检索",col:{volumes:"册次",title:"书名",versions:"版本"},volumeRange:"第 {range} {unit}",resourcesCount:"{n} 处",text:"文本",empty:"尚未著录该丛编的子目。",parent:"上级丛编"}),eu=dt({subtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年號",office:"官職",anonymous:"佚名",collective:"群體"},bce:"前{n}",floruit:"活躍於 {from}—{to}",zi:"字{name}",hao:"號{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 種",moreNames:"更多別名({n})",dist:"著作分佈",autoMatch:"自動匹配",sec:{featured:"著作舉要",allWorks:"全部著作",works:"著作",external:"站外資料"},featuredSub:"存世版本最多的三部",versionsUnit:"種版本",hasImage:"有影印",empty:"尚未著錄該人物的關聯作品。",total:"共 {n} 種",current:"當前 {n} 種",sortByVersions:"按版本數排列",sortByCatalog:"按著錄順序",col:{work:"作品",section:"部類",role:"職任",versions:"存世版本",image:"影印"},notRecorded:"未著錄",emptyRole:"該職任下的著作尚未著錄。",moreUnit:"種著作",cbdbAuto:"CBDB 為自動匹配,未經人工核對"},{subtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年号",office:"官职",anonymous:"佚名",collective:"群体"},bce:"前{n}",floruit:"活跃于 {from}—{to}",zi:"字{name}",hao:"号{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 种",moreNames:"更多别名({n})",dist:"著作分布",autoMatch:"自动匹配",sec:{featured:"著作举要",allWorks:"全部著作",works:"著作",external:"站外资料"},featuredSub:"存世版本最多的三部",versionsUnit:"种版本",hasImage:"有影印",empty:"尚未著录该人物的关联作品。",total:"共 {n} 种",current:"当前 {n} 种",sortByVersions:"按版本数排列",sortByCatalog:"按著录顺序",col:{work:"作品",section:"部类",role:"职任",versions:"存世版本",image:"影印"},notRecorded:"未著录",emptyRole:"该职任下的著作尚未著录。",moreUnit:"种著作",cbdbAuto:"CBDB 为自动匹配,未经人工核对"}),tu=dt({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",settingsShort:"設置",closeSettings:"收起設置",groupText:"文字",groupMark:"標註",groupLayout:"版面",font:"字體",fontSong:"宋體",fontKai:"楷體",fontSystem:"系統默認",script:"繁簡",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最後一{unit}",toc:"目錄",images:"書影",fontSmaller:"縮小字號",fontLarger:"放大字號",paragraphTitle:"條目分行 ↔ 自然段",paragraph:"自然段",workLinks:"標出作品鏈接",properNameTitle:"書名加波浪線",properName:"專名線",properNameOff:"不顯示",properNameLite:"精簡",properNameFull:"完整",properNameLiteTitle:"只標人名、地名、朝代",showWorks:"標註書名",bookTitleStyle:"書名樣式",bookTitleWavy:"波浪線",bookTitleBracket:"書名號",scriptOrig:"原字",scriptOrigShort:"原",scriptQuick:"字形",scriptHant:"通行繁體",scriptHans:"簡體",quoteStyle:"引號",quoteModern:"“”‘’",quoteClassic:"「」『』",quoteOriginal:"原樣",pageBreaks:"顯示分葉分割線",pageIndicator:"頁指示頭(上下鍵調整位置)",preserveMargins:"書影保留空白",facsimilePager:"書影翻頁",facsimilePageInput:"書影葉碼(輸入數字後按 Enter 或離開輸入框跳轉)",vertical:"豎排",closeToc:"收起目錄",sourceLabel:"出處",licenseOf:"授權 {license}",revisedAt:"最近校訂 {date}",reportError:"報告錯字",pagerNav:"翻卷",rail:"本卷",bottomBar:"閱讀工具",tocShort:"卷目",fontSize:"字號",close:"關閉",loading:"加載中…",noText:"暫無文本",tocFailed:"無法加載目錄",tocLoading:"加載目錄…",viewEntry:"查看條目",defaultRole:"撰",tocCaption:"目錄 · {n} {unit}",searchChapters:"搜索全部章節",searchChaptersPlaceholder:"搜索全部章節…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"來源",originalSource:"本站獨立整理",charGuess:"殘字(推測)",upstream:"上游",chapterFailed:"無法加載章節內容",references:"參考文獻",entityDetail:"查看詳情 →"},{imagesLoading:"加载书影…",noImages:"暂无书影",noImagesHint:"这一卷还没有配上影像;接入后在此与正文逐页对看",imageAlt:"书影 第 {label} 页",prevImage:"上一页书影",nextImage:"下一页书影",back:"阅读",backAria:"返回{label}首页",skipToText:"跳到正文",settings:"阅读设置",settingsShort:"设置",closeSettings:"收起设置",groupText:"文字",groupMark:"标注",groupLayout:"版面",font:"字体",fontSong:"宋体",fontKai:"楷体",fontSystem:"系统默认",script:"繁简",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最后一{unit}",toc:"目录",images:"书影",fontSmaller:"缩小字号",fontLarger:"放大字号",paragraphTitle:"条目分行 ↔ 自然段",paragraph:"自然段",workLinks:"标出作品链接",properNameTitle:"书名加波浪线",properName:"专名线",properNameOff:"不显示",properNameLite:"精简",properNameFull:"完整",properNameLiteTitle:"只标人名、地名、朝代",showWorks:"标注书名",bookTitleStyle:"书名样式",bookTitleWavy:"波浪线",bookTitleBracket:"书名号",scriptOrig:"原字",scriptOrigShort:"原",scriptQuick:"字形",scriptHant:"通行繁体",scriptHans:"简体",quoteStyle:"引号",quoteModern:"“”‘’",quoteClassic:"「」『』",quoteOriginal:"原样",pageBreaks:"显示分叶分割线",pageIndicator:"页指示头(上下键调整位置)",preserveMargins:"书影保留空白",facsimilePager:"书影翻页",facsimilePageInput:"书影叶码(输入数字后按 Enter 或离开输入框跳转)",vertical:"竖排",closeToc:"收起目录",sourceLabel:"出处",licenseOf:"授权 {license}",revisedAt:"最近校订 {date}",reportError:"报告错字",pagerNav:"翻卷",rail:"本卷",bottomBar:"阅读工具",tocShort:"卷目",fontSize:"字号",close:"关闭",loading:"加载中…",noText:"暂无文本",tocFailed:"无法加载目录",tocLoading:"加载目录…",viewEntry:"查看条目",defaultRole:"撰",tocCaption:"目录 · {n} {unit}",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",originalSource:"本站独立整理",charGuess:"残字(推测)",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献",entityDetail:"查看详情 →"}),nu=dt({nJuan:"{n}卷",viewWork:"查看作品",viewWorkOf:"查看作品:{title}",workArrow:"作品 →",arrowWork:"→作品",nWorks:"{n}部作品",unlinked:"未關聯",summary:"提要",comment:"按語",additionalComment:"附按",noMatch:"無匹配結果",sectionType:{类:"類",书:"書",序:"序",结语:"結語",注释:"註釋",考证:"考證",诗:"詩",小计:"小計"},countTiao:"{n} 條",countTiaoOf:"{m} / {n} 條",countPoems:"{n} 首",countPoemsOf:"{m} / {n} 首",countBooks:"{n} 部書",countBooksOf:"{m} / {n} 部書",kaozhenTarget:"考證對象 {target}",baseText:"底本 {note}",textQuality:"文本質量",qualityLabel:{source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暫無正文",placeholder:"占位"},qualityCriteria:{source:"照錄來源原文,本站未另行校對",ocr:"保持大意和結構,錯誤率在百分之十以內",rough:"保證文意基本正確,錯誤率在百分之三以內",fine:"通讀無障礙,錯誤率在百分之一以內",none:"質量未評定",placeholder:"占位條目,正文尚未錄入"},originalSource:"原文來源",viewsGroup:"看法",viewText:"正文",viewEntries:"條目",rowHeadNo:"序",rowHeadTitle:"書名",rowHeadWork:"作品",railCap:"本卷",railUnitPoems:"首",railUnitBooks:"部書",linkedN:"已關聯 {n}",linkedOf:"已關聯 {n} / {total}",railEntriesNav:"本卷條目"},{nJuan:"{n}卷",viewWork:"查看作品",viewWorkOf:"查看作品:{title}",workArrow:"作品 →",arrowWork:"→作品",nWorks:"{n}部作品",unlinked:"未关联",summary:"提要",comment:"按语",additionalComment:"附按",noMatch:"无匹配结果",sectionType:{类:"类",书:"书",序:"序",结语:"结语",注释:"注释",考证:"考证",诗:"诗",小计:"小计"},countTiao:"{n} 条",countTiaoOf:"{m} / {n} 条",countPoems:"{n} 首",countPoemsOf:"{m} / {n} 首",countBooks:"{n} 部书",countBooksOf:"{m} / {n} 部书",kaozhenTarget:"考证对象 {target}",baseText:"底本 {note}",textQuality:"文本质量",qualityLabel:{source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暂无正文",placeholder:"占位"},qualityCriteria:{source:"照录来源原文,本站未另行校对",ocr:"保持大意和结构,错误率在百分之十以内",rough:"保证文意基本正确,错误率在百分之三以内",fine:"通读无障碍,错误率在百分之一以内",none:"质量未评定",placeholder:"占位条目,正文尚未录入"},originalSource:"原文来源",viewsGroup:"看法",viewText:"正文",viewEntries:"条目",rowHeadNo:"序",rowHeadTitle:"书名",rowHeadWork:"作品",railCap:"本卷",railUnitPoems:"首",railUnitBooks:"部书",linkedN:"已关联 {n}",linkedOf:"已关联 {n} / {total}",railEntriesNav:"本卷条目"}),iu=dt({typeShort:{work:"作",book:"版",collection:"叢",entity:"人"},typeLabel:{work:"作品",book:"版本",collection:"叢編",entity:"人物"},typeAll:"全部",typeChipsLabel:"按類型檢索",recentTitle:"最近瀏覽",recentClear:"清除",recentItemLabel:"{type} {title}",recentEmpty:"還沒有瀏覽記錄。打開任一條目後會出現在這裏。",status:{done:"已完成",in_progress:"進行中",todo:"計劃中"},siteStatus:{done:"已對接",in_progress:"進行中"},catalogTitle:"書目著錄進度",catalogNote:"每條著錄對到作品條目",colCatalog:"書目",colRecords:"著錄條目",colMatched:"已對上作品",colProgress:"進度",colStatus:"狀態",relatedTitle:"同類書目與考證",relatedNote:"不在書架上的",allNWorks:"全部 {n} 部",nKinds:"{n} 種",allNKinds:"全部 {n} 種",pavilion:"閣",yearBC:"前{n}",missingLife:"生卒年未錄、未上軸:{names}",viewLineage:"看版本譜系 →",plannedSites:"計劃接入:{names}",loss:{extant:"存",partially_extant:"殘",lost:"佚",unknown:"未詳"},lossNote:{extant:"今有傳本",partially_extant:"部分存世",lost:"僅見著錄",unknown:"尚未判定"},lossCount:"{n} 部 · {note}",stat:{works:"作品",books:"版本",collections:"叢編",entities:"人物",has_image:"有影印",has_text:"有文本",article:"單篇文",poem:"單篇詩"},dataScale:"數據規模",byLoss:"按存佚檢索",license:"古籍元數據以 CC0 公有領域發布,可自由複製、改編、再發布。",repo:"數據倉庫:",repoNote:"(GitHub,CC0)",version:"當前數據版本:",download:"引用方式與數據下載 →",navLabel:"元數據首頁分區",nav:{zhi:"歷代史志",sibu:"四部",cong:"叢編",people:"人物",lineage:"版本譜系",sites:"在線資源",data:"數據與授權"},zhiSub:"正史藝文志、經籍志與後人補志,按所志朝代排列;每部志的著錄逐條對到作品",shelfLegendCount:"脊下數字=著錄條目",shelfLegendClick:"點書脊進作品頁",sibuSub:"全部作品按經史子集分類;與「目錄」頁同一棵分類樹",toCatalog:"進入目錄 →",unclassifiedNote:"多為只見於史志著錄、尚未歸類的書",congSub:"大型叢書、影印彙編、出土文獻與館藏,逐種列到版本",allNKindsMore:"全部 {n} 種 →",peopleSub:"歷代目錄學家,按生卒年排在一條時間軸上",allNPeopleMore:"全部 {n} 人 →",lineageSub:"版本多的作品,看各本的源流與異同",sitesSub:"外部數字圖書館與本站條目的對接",dataSub:"規模、存佚、許可與版本"},{typeShort:{work:"作",book:"版",collection:"丛",entity:"人"},typeLabel:{work:"作品",book:"版本",collection:"丛编",entity:"人物"},typeAll:"全部",typeChipsLabel:"按类型检索",recentTitle:"最近浏览",recentClear:"清除",recentItemLabel:"{type} {title}",recentEmpty:"还没有浏览记录。打开任一条目后会出现在这里。",status:{done:"已完成",in_progress:"进行中",todo:"计划中"},siteStatus:{done:"已对接",in_progress:"进行中"},catalogTitle:"书目著录进度",catalogNote:"每条著录对到作品条目",colCatalog:"书目",colRecords:"著录条目",colMatched:"已对上作品",colProgress:"进度",colStatus:"状态",relatedTitle:"同类书目与考证",relatedNote:"不在书架上的",allNWorks:"全部 {n} 部",nKinds:"{n} 种",allNKinds:"全部 {n} 种",pavilion:"阁",yearBC:"前{n}",missingLife:"生卒年未录、未上轴:{names}",viewLineage:"看版本谱系 →",plannedSites:"计划接入:{names}",loss:{extant:"存",partially_extant:"残",lost:"佚",unknown:"未详"},lossNote:{extant:"今有传本",partially_extant:"部分存世",lost:"仅见著录",unknown:"尚未判定"},lossCount:"{n} 部 · {note}",stat:{works:"作品",books:"版本",collections:"丛编",entities:"人物",has_image:"有影印",has_text:"有文本",article:"单篇文",poem:"单篇诗"},dataScale:"数据规模",byLoss:"按存佚检索",license:"古籍元数据以 CC0 公有领域发布,可自由复制、改编、再发布。",repo:"数据仓库:",repoNote:"(GitHub,CC0)",version:"当前数据版本:",download:"引用方式与数据下载 →",navLabel:"元数据首页分区",nav:{zhi:"历代史志",sibu:"四部",cong:"丛编",people:"人物",lineage:"版本谱系",sites:"在线资源",data:"数据与授权"},zhiSub:"正史艺文志、经籍志与后人补志,按所志朝代排列;每部志的著录逐条对到作品",shelfLegendCount:"脊下数字=著录条目",shelfLegendClick:"点书脊进作品页",sibuSub:"全部作品按经史子集分类;与「目录」页同一棵分类树",toCatalog:"进入目录 →",unclassifiedNote:"多为只见于史志著录、尚未归类的书",congSub:"大型丛书、影印汇编、出土文献与馆藏,逐种列到版本",allNKindsMore:"全部 {n} 种 →",peopleSub:"历代目录学家,按生卒年排在一条时间轴上",allNPeopleMore:"全部 {n} 人 →",lineageSub:"版本多的作品,看各本的源流与异同",sitesSub:"外部数字图书馆与本站条目的对接",dataSub:"规模、存佚、许可与版本"}),Xr=dt({readable:"部可讀",pieces:"篇單篇詩文",startReading:"開始閱讀 →",nCopies:"{n}本",shelfHint:"按所志朝代排列,一脊一部",shelfLegendCount:"脊下「2本」=站內有幾個本子",shelfOther:"其他",shelfRegion:"{label}書架,可橫向滾動",origZhi:"正史原志",laterZhi:"後人補撰、續補",spineBy:"{name} 撰",spineRecords:"著錄 {n} 條",spineOnSite:"站內 {n}",nWorks:"{n} 部",allNWorks:"全部 {n} 部",nCopiesCard:"{n} 個本子",workPageLink:"作品頁:{title}的源流與全部版本 →",sibuUnclassifiedNote:"書目分類還沒補齊,其中多數是單篇詩文,已單列在下方。",subClasses:"{label}子類",allNClasses:"{label}全部 {n} 類 →",unclassified:"未分類",viewUnclassified:"查看未分類 →",periodItem:"{label},{n} 部",periodUnknown:"另有 {n} 部作者無朝代,在「四部」和搜索裏能找到",hoverHint:"窄段懸停看全名",nPieces:"{n} 篇",authorAll:"{name}全部 {n} 篇 →",period:{xianqin:"先秦",qinhan:"秦漢",weijin:"魏晉南北朝",suitang:"隋唐五代",song:"宋",liaojinyuan:"遼金元",ming:"明",qing:"清",modern:"近現代"},navLabel:"閱讀首頁分區",nav:{picks:"推薦閱讀",topics:"專題",famous:"名著與版本",sibu:"四部",period:"按年代",pieces:"單篇詩文"},picksSub:"編輯挑選,定期輪換",topicsSub:"按作品類型歸組;小說見下方「名著與版本」",famousSub:"一部作品一張卡,卡上列出站內能讀的各個本子",sibuSub:"按古籍總目的分類樹,只計站內可讀的作品",periodSub:"按作者朝代歸段,寬度與部數成比例",piecesSub:"單篇的詩、文、賦、表,按作者歸組",piecesMore:"按作者瀏覽全部 →"},{readable:"部可读",pieces:"篇单篇诗文",startReading:"开始阅读 →",nCopies:"{n}本",shelfHint:"按所志朝代排列,一脊一部",shelfLegendCount:"脊下「2本」=站内有几个本子",shelfOther:"其他",shelfRegion:"{label}书架,可横向滚动",origZhi:"正史原志",laterZhi:"后人补撰、续补",spineBy:"{name} 撰",spineRecords:"著录 {n} 条",spineOnSite:"站内 {n}",nWorks:"{n} 部",allNWorks:"全部 {n} 部",nCopiesCard:"{n} 个本子",workPageLink:"作品页:{title}的源流与全部版本 →",sibuUnclassifiedNote:"书目分类还没补齐,其中多数是单篇诗文,已单列在下方。",subClasses:"{label}子类",allNClasses:"{label}全部 {n} 类 →",unclassified:"未分类",viewUnclassified:"查看未分类 →",periodItem:"{label},{n} 部",periodUnknown:"另有 {n} 部作者无朝代,在「四部」和搜索里能找到",hoverHint:"窄段悬停看全名",nPieces:"{n} 篇",authorAll:"{name}全部 {n} 篇 →",period:{xianqin:"先秦",qinhan:"秦汉",weijin:"魏晋南北朝",suitang:"隋唐五代",song:"宋",liaojinyuan:"辽金元",ming:"明",qing:"清",modern:"近现代"},navLabel:"阅读首页分区",nav:{picks:"推荐阅读",topics:"专题",famous:"名著与版本",sibu:"四部",period:"按年代",pieces:"单篇诗文"},picksSub:"编辑挑选,定期轮换",topicsSub:"按作品类型归组;小说见下方「名著与版本」",famousSub:"一部作品一张卡,卡上列出站内能读的各个本子",sibuSub:"按古籍总目的分类树,只计站内可读的作品",periodSub:"按作者朝代归段,宽度与部数成比例",piecesSub:"单篇的诗、文、赋、表,按作者归组",piecesMore:"按作者浏览全部 →"}),ru=dt({sideNav:"分類導航",classification:"分類",drawerLabel:"分類:{path}",all:"全部",allTitle:"全部典籍",stat:"共 {total} 種 · 每頁 {size} 條",statPage:" · 第 {page} / {pages} 頁",viewLabel:"呈現方式",viewCard:"卡片",viewList:"列表",juanN:"{n}卷",pagerLabel:"分頁",prevPage:"上一頁",nextPage:"下一頁",pageN:"第 {n} 頁",emptyWorks:"此類暫無作品",zhulu:"著錄",cunmu:"存目",categoriesN:"{n} 類",divisionStat:"{cats} 類 · {books} 部",categoryJuan:"卷{n}",booksN:"{n} 部",expandAllN:"展開全部 {n} 條"},{sideNav:"分类导航",classification:"分类",drawerLabel:"分类:{path}",all:"全部",allTitle:"全部典籍",stat:"共 {total} 种 · 每页 {size} 条",statPage:" · 第 {page} / {pages} 页",viewLabel:"呈现方式",viewCard:"卡片",viewList:"列表",juanN:"{n}卷",pagerLabel:"分页",prevPage:"上一页",nextPage:"下一页",pageN:"第 {n} 页",emptyWorks:"此类暂无作品",zhulu:"著录",cunmu:"存目",categoriesN:"{n} 类",divisionStat:"{cats} 类 · {books} 部",categoryJuan:"卷{n}",booksN:"{n} 部",expandAllN:"展开全部 {n} 条"}),ou=dt({loss:{all:"全部",extant:"存",partially_extant:"殘",lost:"佚"},unclassified:"未分類",statBook:"書",statComma:",",statBookCopies:"本",statArticle:"文章",statArticleUnit:"篇",statPoem:"詩詞",statPoemUnit:"首",statCollection:"叢編",submit:"搜索"},{loss:{all:"全部",extant:"存",partially_extant:"残",lost:"佚"},unclassified:"未分类",statBook:"书",statComma:",",statBookCopies:"本",statArticle:"文章",statArticleUnit:"篇",statPoem:"诗词",statPoemUnit:"首",statCollection:"丛编",submit:"搜索"}),su=dt({title:"反饋",close:"關閉",submitType:{bug:"反饋錯誤",resource:"添加資源",suggestion:"功能建議",contact:"想參與"},placeholder:{bug:"請描述您發現的錯誤,包括頁面位置和具體內容",resource:"請提供完整資源鏈接和簡要版本說明",suggestion:"您希望網站增加或改進什麼?",contact:"想參與整理、校對或合作?簡單介紹一下您自己,並留下聯繫方式(此類留言不公開)"},chooseTypeFirst:"請先選擇反饋類型",contactPlaceholder:"郵箱(選填,僅站方可見,方便我們回覆您)",contactLabel:"聯繫方式(選填)",submitFailedRetry:"提交失敗,請稍後重試",submitFailed:"提交失敗",thanks:"感謝您的反饋!",viewList:"查看反饋列表 →",continueSubmit:"繼續提交",submitting:"提交中...",submit:"提交",submitFeedback:"提交反饋",listType:{bug:"錯誤反饋",resource:"資源建議",suggestion:"功能建議",other:"其他"},status:{pending:"待處理",in_progress:"處理中",resolved:"已處理",wontfix:"不採納",duplicate:"重複"},empty:"暫無反饋",reply:"回覆"},{title:"反馈",close:"关闭",submitType:{bug:"反馈错误",resource:"添加资源",suggestion:"功能建议",contact:"想参与"},placeholder:{bug:"请描述您发现的错误,包括页面位置和具体内容",resource:"请提供完整资源链接和简要版本说明",suggestion:"您希望网站增加或改进什么?",contact:"想参与整理、校对或合作?简单介绍一下您自己,并留下联系方式(此类留言不公开)"},chooseTypeFirst:"请先选择反馈类型",contactPlaceholder:"邮箱(选填,仅站方可见,方便我们回复您)",contactLabel:"联系方式(选填)",submitFailedRetry:"提交失败,请稍后重试",submitFailed:"提交失败",thanks:"感谢您的反馈!",viewList:"查看反馈列表 →",continueSubmit:"继续提交",submitting:"提交中...",submit:"提交",submitFeedback:"提交反馈",listType:{bug:"错误反馈",resource:"资源建议",suggestion:"功能建议",other:"其他"},status:{pending:"待处理",in_progress:"处理中",resolved:"已处理",wontfix:"不采纳",duplicate:"重复"},empty:"暂无反馈",reply:"回复"}),au=dt({empty:"暫無版本傳承數據",emptyGraph:"暫無版本圖數據",modeList:"列表",modeGraph:"關係圖",collectionLabel:"集合:",collectionAll:"全部",collectionAllDesc:"顯示該作品所有版本(含橋接節點)",graphLoading:"加載圖組件中…",graphMissing:"圖組件未安裝。請安裝 {xyflow} 與 {dagre}。",graphMissingHint:"或使用 {list} 列表視圖。",bridgeTitle:"橋接節點:本身不在核心集,為保持派生鏈完整而顯示",otherGroup:"其他",lost:"已佚",fragment:"殘本",hypothetical:"假想祖本",bridge:"橋接",extant:"現存:{juan}",sources:"來源:",related:"關聯:",confidence:{certain:"確定",consensus:"共識",probable:"推測",disputed:"有爭議"}},{empty:"暂无版本传承数据",emptyGraph:"暂无版本图数据",modeList:"列表",modeGraph:"关系图",collectionLabel:"集合:",collectionAll:"全部",collectionAllDesc:"显示该作品所有版本(含桥接节点)",graphLoading:"加载图组件中…",graphMissing:"图组件未安装。请安装 {xyflow} 与 {dagre}。",graphMissingHint:"或使用 {list} 列表视图。",bridgeTitle:"桥接节点:本身不在核心集,为保持派生链完整而显示",otherGroup:"其他",lost:"已佚",fragment:"残本",hypothetical:"假想祖本",bridge:"桥接",extant:"现存:{juan}",sources:"来源:",related:"关联:",confidence:{certain:"确定",consensus:"共识",probable:"推测",disputed:"有争议"}}),lu={common:Xp,detail:wi,bookPage:Zp,workPage:Jp,collectionPage:Qp,entityPage:eu,reader:tu,collated:nu,metaHome:iu,readHome:Xr,catalogPage:ru,searchPage:ou,feedback:su,lineage:au};function cu(e){const n={};for(const[i,o]of Object.entries(lu))n[i]=o[e];return n}function gt(e,n){return e.replace(/\{(\w+)\}/g,(i,o)=>String(n[o]??""))}const bs=new Map;function bn(e){let n=bs.get(e);return n||(n={...e==="zh-Hans"?Kp:qp,...cu(e)},bs.set(e,n)),n}function ys(e,n){let i=e;for(const o of n.split(".")){if(i==null||typeof i!="object")return;i=i[o]}return typeof i=="string"?i:void 0}function sl(e){return(n,i)=>{const o=ys(e,n)??ys(bn("zh-Hant"),n)??n;return i?gt(o,i):o}}const js=new Map;function yn(e){let n=js.get(e);return n||(n=sl(bn(e)),js.set(e,n)),n}const al="bim-locale";function du(){try{const e=localStorage.getItem(al);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function pu(e){try{localStorage.setItem(al,e)}catch{}}const uu="zh-Hans",mu=({locale:e,onLocaleChange:n,converter:i,children:o})=>{const[s,a]=g.useState(e??uu),l=e??s;g.useEffect(()=>{if(e)return;const h=du();h&&h!==s&&a(h)},[]);const d=g.useMemo(()=>l==="zh-Hans"?i??ol():null,[l,i]),c=g.useCallback(h=>{a(h),pu(h),n==null||n(h)},[n]),p=g.useMemo(()=>({locale:l,setLocale:c,messages:bn(l),converter:d}),[l,c,d]);return t.jsx(Tt.Provider,{value:p,children:o})};function Ee(){const e=g.useContext(Tt);return(e==null?void 0:e.messages)??bn("zh-Hant")}const hu=2e3;function Pe(){const e=g.useContext(Tt),n=(e==null?void 0:e.locale)??"zh-Hant",i=(e==null?void 0:e.converter)??null,o=g.useRef(new Map),s=g.useRef(n),a=g.useRef(i);(s.current!==n||a.current!==i)&&(o.current.clear(),s.current=n,a.current=i);const l=g.useCallback(d=>{if(!d)return"";if(!i)return d;const c=o.current.get(d);if(c!==void 0)return c;const p=i(d);if(o.current.size>=hu){const h=o.current.keys().next().value;h!==void 0&&o.current.delete(h)}return o.current.set(d,p),p},[i]);return g.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function ne(){const e=g.useContext(Tt),{convert:n,locale:i,isSimplified:o}=Pe(),s=(e==null?void 0:e.messages)??bn("zh-Hant"),a=g.useMemo(()=>e?sl(s):yn("zh-Hant"),[e,s]);return g.useMemo(()=>({t:a,convert:n,locale:i,isSimplified:o,messages:s}),[a,n,i,o,s])}const ll=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),gu=new Set([...ll,...Object.keys(Se.VARIANT_CHARS),...Object.keys(Za.VARIANT_SUPPLEMENT)]),cl=[...rl,"切換為繁體","漢籍リポジトリ"];function fu(e,n=cl){let i=e;for(const a of n)a&&(i=i.split(a).join(" "));const o=[],s=Array.from(i);return s.forEach((a,l)=>{gu.has(a)&&o.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),o}function xu(e,n,i){return e?e==="orig"?null:n==="zh-Hans"?i??ol():e==="hant"?Se.normalizeVariants:i:i}const bu=({mode:e,children:n})=>{const i=g.useContext(Tt),o=g.useMemo(()=>!i||!e?i:{...i,converter:xu(e,i.locale,i.converter)},[i,e]);return t.jsx(Tt.Provider,{value:o,children:n})};function yu(e){if(!e)return"";try{const n=new URL(e).hostname,i={"zh.wikisource.org":"wikisource","www.shidianguji.com":"shidianguji","shidianguji.com":"shidianguji","archive.org":"archive","ctext.org":"ctext","read.nlc.cn":"nlc","www.digital.archives.go.jp":"japan_archives"};if(i[n])return i[n];const o=n.split(".");return o.length>=2?o[o.length-2]:n}catch{return""}}function vs(e){return e==="text+image"?["text","image"]:[e]}function ks(e){const n=Mt(e);return n.length===0?"text":Vp(n)}function ju(){return{id:"",name:"",url:"",types:["text"],details:""}}const jr=({items:e,onChange:n,onDownload:i,downloadStatuses:o,filterType:s})=>{const a=Ee(),[l,d]=g.useState(null),c=[{value:"text",label:a.resourceTypeShort.text},{value:"image",label:a.resourceTypeShort.image},{value:"text+image",label:a.resourceTypeShort.textImage},{value:"physical",label:a.resourceTypeShort.physical}],p=[{value:"catalog",label:a.rootType.catalog},{value:"search",label:a.rootType.search}],h=w=>{if(!s)return!0;const j=Mt(w);return s==="text"?j.includes("text"):s==="image"?j.includes("image")||j.includes("physical"):s==="physical"?j.includes("physical"):j.includes(s)},u=e.map((w,j)=>({item:w,originalIndex:j})).filter(({item:w})=>h(w)),m=()=>{const w=ju();s&&(w.types=vs(s)),n([...e,w]),d(e.length)},f=w=>{n(e.filter((j,k)=>k!==w)),d(null)},x=(w,j,k)=>{const $=[...e];if($[w]={...$[w],[j]:k},j==="url"&&!$[w].id){const C=yu(k);C&&($[w].id=C)}n($)},v=(w,j)=>{const k=[...e],{type:$,...C}=k[w];k[w]={...C,types:vs(j)},n(k)},y=(w,j,k)=>{const C={...e[w].metadata||{}};k?C[j]=k:delete C[j],x(w,"metadata",Object.keys(C).length>0?C:void 0)},S=(w,j)=>{const k=j.trim()?j.split(/[,,、]/).map($=>$.trim()).filter(Boolean):void 0;x(w,"structure",k)},b=(w,j,k)=>{const C=e[w].coverage||{level:1,ranges:""};j==="level"?C.level=parseInt(k)||1:C.ranges=k,x(w,"coverage",C.ranges?C:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[u.map(({item:w,originalIndex:j})=>{var k,$,C;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>d(l===j?null:j),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:l===j?"▼":"▶"}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:vu(ks(w)),color:r("on-color-fg")},children:(()=>{var E,z;const _=Mt(w);return _.length===0?"text":_.length===1?((E=c.find(T=>T.value===_[0]))==null?void 0:E.label)??_[0]:_.includes("text")&&_.includes("image")?((z=c.find(T=>T.value==="text+image"))==null?void 0:z.label)??"text+image":_.join("+")})()}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:w.name||`${a.editor.resourcePlaceholder} ${j+1}`}),w.id&&t.jsx("span",{style:{fontSize:"11px",opacity:.5},children:w.id}),w.url&&t.jsx("a",{href:w.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),i&&w.url&&ku(j,o==null?void 0:o[j],i,a),t.jsx("button",{onClick:_=>{_.stopPropagation(),f(j)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:a.editor.deleteThisResource,children:"✕"})]}),l===j&&t.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:[Hp(w,"image")&&w.url&&wu(w,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Sn,children:[t.jsx("span",{style:_n,children:a.label.type}),t.jsx("select",{value:ks(w),onChange:_=>v(j,_.target.value),style:{...St,flex:1},children:c.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]}),t.jsxs("label",{style:Sn,children:[t.jsx("span",{style:_n,children:a.label.rootType}),t.jsx("select",{value:w.root_type||"catalog",onChange:_=>x(j,"root_type",_.target.value),style:{...St,flex:1},children:p.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:w.id,onChange:_=>x(j,"id",_.target.value),placeholder:a.editor.idAutoExtract,style:{...St,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:w.name,onChange:_=>x(j,"name",_.target.value),placeholder:a.editor.resourceName,style:{...St,flex:1}})]}),t.jsx("input",{type:"text",value:w.url,onChange:_=>x(j,"url",_.target.value),placeholder:a.editor.resourceUrl,style:St}),t.jsx("input",{type:"text",value:((k=w.structure)==null?void 0:k.join("、"))||"",onChange:_=>S(j,_.target.value),placeholder:a.editor.structurePlaceholder,style:St}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Sn,children:[t.jsx("span",{style:_n,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:(($=w.coverage)==null?void 0:$.level)??"",onChange:_=>b(j,"level",_.target.value),placeholder:"1",style:{...St,width:"60px"}})]}),t.jsxs("label",{style:{...Sn,flex:1},children:[t.jsx("span",{style:_n,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:((C=w.coverage)==null?void 0:C.ranges)||"",onChange:_=>b(j,"ranges",_.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...St,flex:1}})]})]}),t.jsx("textarea",{value:w.details||"",onChange:_=>x(j,"details",_.target.value),placeholder:a.editor.detailsPlaceholder,style:{...St,minHeight:"60px",resize:"vertical"}}),t.jsxs("div",{style:{borderTop:`1px solid ${r("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"6px"},children:a.label.metadata}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(a.metadata).map(([_,E])=>{var z;return t.jsxs("label",{style:{...Sn,gap:"4px"},children:[t.jsx("span",{style:{..._n,minWidth:"56px"},children:E}),t.jsx("input",{type:"text",value:((z=w.metadata)==null?void 0:z[_])||"",onChange:T=>y(j,_,T.target.value),placeholder:E,style:{...St,flex:1}})]},_)})})]})]})]})]},j)}),t.jsxs("button",{onClick:m,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:a.action.addResource})]})]})};function vu(e){switch(e){case"text":return r("restype-text");case"image":return r("restype-image");case"text+image":return r("restype-text-image");case"physical":return r("restype-physical")}}function ku(e,n,i,o){const s=(n==null?void 0:n.status)==="downloading",a=(n==null?void 0:n.status)==="completed";return t.jsx("button",{onClick:l=>{l.stopPropagation(),s||i(e,"")},disabled:s,style:{background:"transparent",border:"none",color:r(a?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:a?o.download.completed:s?`${o.download.downloading} ${(n==null?void 0:n.progress)||0}%`:o.download.downloadThis,children:a?"✓":s?"⏳":"⬇"})}function wu(e,n){const i=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(e.url)||e.url.includes("iiif")||e.url.includes("image");return t.jsx("div",{style:{marginBottom:"12px"},children:i?t.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:r("overlay-bg")},children:t.jsx("img",{src:e.url,alt:e.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:o=>{o.target.style.display="none"}})}):t.jsx("div",{style:{padding:"12px",background:r("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:r("desc-fg")},children:n.editor.imageResourceLink})})}const St={width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},Sn={display:"flex",alignItems:"center",gap:"6px"},_n={fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap"},ws={text:r("restype-text"),image:r("restype-image"),"text+image":r("restype-text-image"),physical:r("restype-physical")};function Su(e){return e.includes("text")&&e.includes("image")?ws["text+image"]:ws[e[0]||"physical"]}const Zr=({items:e,groupByType:n=!0,resourceGroups:i,onNavigate:o,renderLink:s})=>{const a=Ee(),{convert:l}=Pe(),d=g.useMemo(()=>Yr(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=g.useMemo(()=>{const y=new Map,S=[];for(const b of d){const w=b.group;w?(y.has(w)||y.set(w,[]),y.get(w).push(b)):S.push(b)}for(const b of y.values())b.sort((w,j)=>{const k=$=>$.group_role==="origin"?0:$.group_role==="mirror"?1:2;return k(w)-k(j)});return{mirrorGroups:y,ungroupedItems:S}},[d]),h={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},u=y=>h[y]?h[y]:y.split("+").map(S=>h[S]||S).join("+");if(!d||d.length===0)return t.jsx("div",{style:{padding:"16px",color:r("desc-fg"),fontSize:"13px",textAlign:"center"},children:a.misc.noResources});if(!n)return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:d.map((y,S)=>t.jsx(tr,{item:y},y.id||S))});const m=(y,S)=>{const b=i==null?void 0:i[y],w=(b==null?void 0:b.label)||y,j=b==null?void 0:b.description;return t.jsxs("div",{style:{padding:"10px 12px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:r("input-bg"),display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(w)}),j&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.5},children:l(j)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:S.map((k,$)=>t.jsx(tr,{item:k,onNavigate:o,renderLink:s},k.id||$))})]},`group-${y}`)},f=new Map;for(const y of p){const S=Gr(Mt(y));f.has(S)||f.set(S,[]),f.get(S).push(y)}const x=["text","image","text+image","physical"],v=[...x.filter(y=>f.has(y)),...[...f.keys()].filter(y=>!x.includes(y)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,S])=>m(y,S)),v.map(y=>{const S=f.get(y),b=Su(y.split("+"));return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:b,whiteSpace:"nowrap",flexShrink:0},children:u(y)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:S.map((w,j)=>t.jsx(tr,{item:w,onNavigate:o,renderLink:s},w.id||j))})]},y)})]})},_u={bw:{label:"",bg:r("colormode-bw-bg"),fg:r("colormode-bw-fg")},color:{label:"",bg:r("colormode-color-bg"),fg:r("colormode-color-fg")}},tr=({item:e})=>{const n=Ee(),{convert:i}=Pe(),[o,s]=g.useState(!1),a=g.useMemo(()=>(e.url?fn(e.url):void 0)||i(e.name),[e.url,e.name,i]),l=g.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||nl(x)})),[e.volumes]),d=l&&l.length>0,c=d?new Set(l.filter(x=>x.status!=="missing").map(x=>x.volume)).size:0,p=d?new Set(l.filter(x=>x.status==="missing").map(x=>x.volume)).size:0,h=e.expected_volumes??(d?c+p:0),u=e.color_mode?{..._u[e.color_mode],label:n.colorMode[e.color_mode]}:null,m=e.details&&!d?i(e.details):null,f={display:"inline-flex",alignItems:"center",gap:"5px",padding:"4px 10px",border:`1px solid ${r("widget-border")}`,borderRadius:"5px",background:r("input-bg"),fontSize:"12px",color:r("fg"),lineHeight:1.4,verticalAlign:"middle"};return t.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[t.jsxs("div",{style:f,children:[t.jsx("span",{style:{fontWeight:500},children:a}),u&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:u.bg,color:u.fg},children:u.label}),m&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:m}),d&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[c,"/",h,n.unit.volume,p>0&&t.jsx("span",{style:{color:r("missing-fg"),marginLeft:"3px"},children:gt(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=qr(e.metadata);return x?Kr(e.url,x):e.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:r("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),d&&t.jsx("button",{onClick:()=>s(!o),style:{padding:"0 6px",fontSize:"11px",border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",lineHeight:1.4},children:o?"▲":"▼"})]}),d&&o&&t.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${r("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:l.map(x=>{const v=x.status==="missing";return x.url&&!v?t.jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",borderRadius:"3px",border:`1px solid ${r("widget-border")}`,color:r("link-fg"),textDecoration:"none"},children:x.volume},x.volume):t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:r(v?"missing-fg":"desc-fg"),textDecoration:v?"line-through":"none",opacity:v?.6:1},children:x.volume},x.volume)})})]})},dl=({indexSource:e,syncConfig:n,variant:i="index-browser",onSwitchMode:o,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=Ee(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,h=(n==null?void 0:n.repoPath)||"",u=h?h.split(/[/\\]/).pop()||h:"",m={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:r("primary-soft"),color:r("primary")},f={onMouseOver:v=>v.currentTarget.style.opacity="0.8",onMouseOut:v=>v.currentTarget.style.opacity="1"},x=t.jsxs("div",{onClick:s,title:p?d.mode.switchToOfficial:d.mode.switchToDraft,style:{...m,background:r(p?"warning":"success"),color:r("on-color-fg")},...f,children:[t.jsx("span",{children:p?"📝":"📚"}),t.jsx("span",{children:p?"draft":"official"})]});return i==="index-browser"?c?t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[x,t.jsxs("div",{onClick:o,title:d.mode.switchToSync,style:m,...f,children:[t.jsx("span",{children:"📁"}),t.jsx("span",{children:d.mode.localMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsxs("div",{onClick:l,title:h||d.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px"},...f,children:[t.jsx("span",{children:"📂"}),u&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:u})]})]}):t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.jsxs("div",{onClick:o,title:d.mode.switchToLocal,style:m,...f,children:[t.jsx("span",{children:"🌐"}),t.jsx("span",{children:d.mode.syncMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsx("div",{onClick:a,title:u||d.mode.configurePath,style:{...m,background:"transparent",padding:"6px",fontSize:"12px"},...f,children:t.jsx("span",{children:"⚙️"})})]})]}):t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[t.jsxs("div",{onClick:o,title:c?d.mode.switchToGithub:d.mode.switchToLocal,style:m,...f,children:[t.jsx("span",{children:c?"📁":"🌐"}),t.jsx("span",{children:c?d.mode.localMode:d.mode.githubSync}),t.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&t.jsxs("div",{onClick:l,title:h||d.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px",minWidth:h?"100px":"auto",justifyContent:"space-between"},...f,children:[t.jsx("span",{children:"📂"}),u&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:u})]}),!c&&u&&t.jsxs("div",{style:{...m,background:r("mode-active-bg"),color:r("on-color-fg"),cursor:"default"},title:h,children:[t.jsx("span",{children:"📂"}),t.jsx("span",{style:{fontSize:"11px"},children:u})]})]})},Si="bim-search-history",Ss=10,_s=8;function Rn(){try{const e=localStorage.getItem(Si);return e?JSON.parse(e):[]}catch{return[]}}function pl(e){try{const n=Rn().filter(i=>i!==e);n.unshift(e),n.length>Ss&&(n.length=Ss),localStorage.setItem(Si,JSON.stringify(n))}catch{}}function $u(e){try{const n=Rn().filter(i=>i!==e);localStorage.setItem(Si,JSON.stringify(n))}catch{}}function Cu(){try{localStorage.removeItem(Si)}catch{}}const ul=({transport:e,value:n,onChange:i,onSearch:o,onEntrySelect:s,placeholder:a})=>{const l=Ee(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,h]=g.useState(!1),[u,m]=g.useState([]),[f,x]=g.useState(-1),[v,y]=g.useState(Rn),S=g.useRef(null),b=g.useRef(null),w=g.useRef(null),j=g.useRef(!1);g.useEffect(()=>{x(-1);const T=n.trim();if(!T){m(v.map(N=>({type:"history",text:N})));return}if(!e.searchAll){m([]);return}let B=!1;const W=setTimeout(()=>{e.searchAll(T,_s).then(N=>{if(B)return;const A=[...N.works,...N.books,...N.collections,...N.entities??[]];m(A.slice(0,_s).map(F=>({type:"entry",text:F.title||F.id,entry:F})))}).catch(()=>{B||m([])})},80);return()=>{B=!0,clearTimeout(W)}},[n,v,e]),g.useEffect(()=>{const T=B=>{w.current&&!w.current.contains(B.target)&&h(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]),g.useEffect(()=>{const T=B=>{var W,N;if(B.key==="/"&&document.activeElement!==S.current){const A=(W=document.activeElement)==null?void 0:W.tagName;if(A==="INPUT"||A==="TEXTAREA"||A==="SELECT")return;B.preventDefault(),(N=S.current)==null||N.focus()}};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[]);const k=g.useCallback(T=>{T.trim()&&(pl(T.trim()),y(Rn())),o(T),h(!1)},[o]),$=g.useCallback(T=>{T.type==="history"?(i(T.text),k(T.text)):T.entry&&(s?(s(T.entry),h(!1)):(i(T.text),k(T.text)))},[i,k,s]),C=g.useCallback(T=>{if(!p||u.length===0){T.key==="Enter"&&k(n);return}switch(T.key){case"ArrowDown":T.preventDefault(),x(B=>(B+1)%u.length);break;case"ArrowUp":T.preventDefault(),x(B=>(B-1+u.length)%u.length);break;case"Enter":T.preventDefault(),f>=0&&f<u.length?$(u[f]):k(n);break;case"Escape":T.preventDefault(),h(!1);break}},[p,u,f,n,k,$]),_=g.useCallback((T,B)=>{B.stopPropagation(),$u(T),y(Rn()),m(W=>W.filter(N=>!(N.type==="history"&&N.text===T)))},[]),E=g.useCallback(T=>{T.stopPropagation(),Cu(),y([]),m([])},[]);g.useEffect(()=>{if(f>=0&&b.current){const T=b.current.children;T[f]&&T[f].scrollIntoView({block:"nearest"})}},[f]);const z=!n.trim()&&v.length>0;return t.jsxs("div",{ref:w,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:S,type:"text",placeholder:d,value:n,onChange:T=>{i(T.target.value),h(!0)},onCompositionStart:()=>{j.current=!0},onCompositionEnd:()=>{j.current=!1},onFocus:()=>{h(!0)},onKeyDown:C,style:{width:"100%",padding:"8px 12px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),fontSize:"14px",boxSizing:"border-box"}}),p&&u.length>0&&t.jsxs("div",{ref:b,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:r("input-bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"6px",boxShadow:r("shadow-dropdown"),zIndex:100,maxHeight:"320px",overflow:"auto"},children:[z&&t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 12px",fontSize:"11px",color:r("desc-fg"),borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("span",{children:l.search.history}),t.jsx("button",{onClick:E,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),u.map((T,B)=>t.jsxs("div",{onClick:()=>$(T),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:r("fg"),background:B===f?r("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:T.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T.text}),T.entry&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:[c[T.entry.type],T.entry.edition&&` · ${T.entry.edition}`,T.entry.author&&` · ${T.entry.author}`]}),T.type==="history"&&t.jsx("button",{onClick:W=>_(T.text,W),style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:l.action.remove,children:"×"})]},`${T.type}-${T.text}-${B}`))]})]})},jn=({type:e,size:n=9})=>t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:r(`type-${e}`),verticalAlign:"middle"}}),_i={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},ml=new Set(["work","book","entity"]);function Tu(e){return fl(e)||!!e.sort}function zu(e,n){return n.sort&&ml.has(e)?n.sort:void 0}const $i=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],Ci=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],hl=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],gl={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function Ti(e){return e.dynasty.length+e.classification.length+(e.hasImage?1:0)+(e.hasText?1:0)+(e.hasCollated?1:0)+(e.loss?1:0)}function fl(e){return Ti(e)>0}function Nu(e){const n=[];return e.dynasty.length&&n.push("dynasty"),e.classification.length&&n.push("classification"),e.hasImage&&n.push("hasImage"),e.hasText&&n.push("hasText"),e.hasCollated&&n.push("hasCollated"),e.loss&&n.push("loss"),n}function xl(e,n){const i=gl[e];return Nu(n).every(o=>i.has(o))}const $n=e=>JSON.stringify(e);function Iu(e,n){if(!xl(n,e))return null;const i=[];if(e.dynasty.length){const o=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=$i.find(l=>l.key===s))==null?void 0:a.values)??[]})));o.length===1?i.push(`dynasty = ${$n(o[0])}`):o.length>1&&i.push(`dynasty IN [${o.map($n).join(", ")}]`)}return e.classification.length&&i.push(e.classification.length===1?`classification = ${$n(e.classification[0])}`:`classification IN [${e.classification.map($n).join(", ")}]`),e.hasImage&&i.push("has_image = true"),e.hasText&&i.push("has_text = true"),e.hasCollated&&i.push("has_collated = true"),e.loss&&i.push(`loss_status = ${$n(e.loss)}`),i.join(" AND ")}const at={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},bl="_";function gi(e,n=new URLSearchParams){for(const i of Object.values(at))n.delete(i);return e.dynasty.length&&n.set(at.dynasty,e.dynasty.join(",")),e.classification.length&&n.set(at.classification,e.classification.map(i=>i||bl).join(",")),e.hasImage&&n.set(at.hasImage,"1"),e.hasText&&n.set(at.hasText,"1"),e.hasCollated&&n.set(at.hasCollated,"1"),e.loss&&n.set(at.loss,e.loss),e.sort&&n.set(at.sort,e.sort),n}function Ru(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),i=new Set($i.map(a=>a.key)),o=new Set(Ci.map(a=>a.value)),s=e.get(at.loss);return{dynasty:Array.from(new Set(n(at.dynasty).filter(a=>i.has(a)))),classification:Array.from(new Set(n(at.classification).map(a=>a===bl?"":a).filter(a=>o.has(a)))),hasImage:e.get(at.hasImage)==="1",hasText:e.get(at.hasText)==="1"||e.get(at.hasCollated)==="1",hasCollated:!1,loss:s==="extant"||s==="partially_extant"||s==="lost"?s:"",sort:["era:asc","era:desc","title:asc","title:desc"].find(a=>a===e.get(at.sort))??""}}function Eu(e,n){return JSON.stringify([e.dynasty.slice().sort(),e.classification.slice().sort(),e.hasImage,e.hasText,e.hasCollated,e.loss,e.sort])===JSON.stringify([n.dynasty.slice().sort(),n.classification.slice().sort(),n.hasImage,n.hasText,n.hasCollated,n.loss,n.sort])}function $s(e,n){return e.includes(n)?e.filter(i=>i!==n):[...e,n]}const Lu=({filters:e,onChange:n})=>{const i=Ee(),o=i.searchV4,{convert:s}=Pe(),[a,l]=g.useState(!1),d=g.useId(),c=Ti(e),p=h=>n({...e,...h});return t.jsxs("aside",{className:"bim-sr-aside","aria-label":s(o.filterTitle),children:[t.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":a,"aria-controls":d,onClick:()=>l(h=>!h),children:[t.jsxs("span",{children:[s(o.filterButton),c>0&&t.jsx("span",{className:"bim-sr-fn",children:s(gt(o.filterSelected,{n:c}))})]}),t.jsxs("span",{className:"bim-sr-fa","aria-hidden":"true",children:[s(a?o.collapse:o.expand)," ",a?"▴":"▾"]})]}),t.jsxs("div",{className:"bim-sr-filters",id:d,"data-open":a?"true":"false",...a?{}:{"data-collapsed":"true"},children:[t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.dynasty)}),t.jsx("div",{className:"bim-sr-chips",children:$i.map(h=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(h.key),onClick:()=>p({dynasty:$s(e.dynasty,h.key)}),children:s(h.key)},h.key))})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.classification)}),Ci.map(h=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(h.value),onChange:()=>p({classification:$s(e.classification,h.value)})}),h.value?s(h.label):i.searchPage.unclassified]},h.value||"_"))]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.resources)}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasImage,onChange:h=>p({hasImage:h.target.checked})}),s(o.hasImage)]}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasText,onChange:h=>p({hasText:h.target.checked})}),s(o.hasText)]})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{id:`${d}-loss`,children:s(o.extant)}),t.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${d}-loss`,children:hl.map(h=>t.jsx("button",{type:"button","aria-pressed":e.loss===h.value,onClick:()=>p({loss:h.value}),children:i.searchPage.loss[h.value||"all"]},h.value||"all"))})]}),c>0&&t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({..._i,sort:e.sort}),children:s(o.clearAllFilters)})]})]})};function yl({text:e,query:n}){const i=(n??"").trim();if(!i||!e)return t.jsx(t.Fragment,{children:e});const o=e.toLowerCase(),s=i.toLowerCase(),a=[];let l=0,d=0;for(;l<e.length;){const c=o.indexOf(s,l);if(c<0){a.push(e.slice(l));break}c>l&&a.push(e.slice(l,c)),a.push(t.jsx("mark",{className:"bim-sr-hl",children:e.slice(c,c+s.length)},d++)),l=c+s.length}return t.jsx(t.Fragment,{children:a})}const Cs=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ee(),a=s.searchV4,{convert:l}=Pe(),d=tt();return t.jsx("div",{className:"bim-sr-tablewrap",children:t.jsxs("table",{className:"bim-sr-table",children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:"34%"}}),t.jsx("col",{style:{width:"8%"}}),t.jsx("col",{style:{width:"19%"}}),t.jsx("col",{style:{width:"13%"}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"14%"}})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:l(a.colTitle)}),t.jsx("th",{scope:"col",children:l(a.colType)}),t.jsx("th",{scope:"col",children:l(a.colAuthor)}),t.jsx("th",{scope:"col",children:l(a.colEra)}),t.jsx("th",{scope:"col",children:l(a.colClass)}),t.jsx("th",{scope:"col",style:{textAlign:"right"},children:l(a.colResource)})]})}),t.jsx("tbody",{children:e.map(c=>{const p=l(c.title||c.primary_name||c.id),h=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",u=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${l(c.author)}${c.role&&c.role!=="author"?` ${l(c.role)}`:""}`:"",m=c.type==="book"?c.era??c.dynasty:c.dynasty,f=m?l(m):"",x=c.classification?l(c.classification):"",v=[];c.has_image&&v.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&v.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&v.push({label:a.tagLost,cls:"bim-sr-tag--lost"});const y=[u,f,x].filter(Boolean).join(" · ");return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-sr-c-title",children:[t.jsxs("div",{className:"bim-sr-tl",children:[t.jsx("a",{href:d(c.id),onClick:S=>i(c,S),children:t.jsx(yl,{text:p,query:n?l(n):void 0})}),h&&t.jsx("span",{className:"bim-sr-measure",children:h})]}),y&&t.jsx("span",{className:"bim-sr-sub",children:y})]}),t.jsxs("td",{className:"bim-sr-c-type",children:[t.jsx(jn,{type:c.type,size:6})," ",o(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:u||"—"}),t.jsx("td",{className:"bim-sr-c-era",children:f||"—"}),t.jsx("td",{className:"bim-sr-c-cls",children:x||"—"}),t.jsx("td",{className:"bim-sr-c-res",children:v.map(S=>t.jsx("span",{className:`bim-sr-tag ${S.cls}`,children:l(S.label)},S.label))})]},c.id)})})]})})},Au=`
|
|
1
|
+
"use strict";var Np=Object.create;var fs=Object.defineProperty;var Ip=Object.getOwnPropertyDescriptor;var Rp=Object.getOwnPropertyNames;var Ep=Object.getPrototypeOf,Lp=Object.prototype.hasOwnProperty;var Ap=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Rp(n))!Lp.call(e,s)&&s!==i&&fs(e,s,{get:()=>n[s],enumerable:!(o=Ip(n,s))||o.enumerable});return e};var ii=(e,n,i)=>(i=e!=null?Np(Ep(e)):{},Ap(n||!e||!e.__esModule?fs(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Se=require("./storage-entry-4WXkdkaK.cjs"),t=require("react/jsx-runtime"),g=require("react"),Mp=require("opencc-js/t2cn"),Ja=require("./variant-supplement.cjs"),Pp=require("react-markdown"),Bp=require("remark-gfm"),Wp=e=>`/book-index?id=${e}`,Qa=g.createContext(Wp);function Op({buildUrl:e,children:n}){const i=g.useMemo(()=>e,[e]);return t.jsx(Qa.Provider,{value:i,children:n})}function tt(){return g.useContext(Qa)}const el="",tl="";function Vr(e){const n=[];let i=!1,o=e;for(;o.length;){const s=i?tl:el,a=o.indexOf(s);if(a===-1){n.push({text:o,marked:i});break}a>0&&n.push({text:o.slice(0,a),marked:i}),o=o.slice(a+1),i=!i}return n}function lt(e,n){return{title:e,tokens:n}}const xs='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',Fp=[lt("基础(VS Code 环境下跟随 --vscode-*)",{bg:{value:"#ffffff",vscode:"--vscode-editor-background"},fg:{value:"#333333",vscode:"--vscode-foreground"},"input-bg":{value:"#ffffff",vscode:"--vscode-input-background"},"input-fg":{value:"#333333",vscode:"--vscode-input-foreground"},"input-border":{value:"#cccccc",vscode:"--vscode-input-border"},"widget-border":{value:"#e0e0e0",vscode:"--vscode-widget-border"},"link-fg":{value:"#0066cc",vscode:"--vscode-textLink-foreground"},"desc-fg":{value:"#717171",vscode:"--vscode-descriptionForeground"},primary:{value:"#0078d4",vscode:"--vscode-button-background"},"primary-fg":{value:"#ffffff",vscode:"--vscode-button-foreground"},"primary-soft":{value:"rgba(0, 120, 212, 0.15)",css:"color-mix(in srgb, var(--bim-primary) 15%, transparent)"},danger:{value:"#f44336"},warning:{value:"#ff9800"},success:{value:"#4caf50"},"sidebar-bg":{value:"#f3f3f3",vscode:"--vscode-sideBar-background"},"list-hover-bg":{value:"rgba(0, 0, 0, 0.04)",vscode:"--vscode-list-hoverBackground"},"list-active-bg":{value:"rgba(0, 120, 212, 0.1)",vscode:"--vscode-list-activeSelectionBackground"},"focus-border":{value:"#0078d4",vscode:"--vscode-focusBorder"}}),lt("底色层次 / 文字与描边 / 链接",{"bg-subtle":{value:"#fafafa"},"widget-bg":{value:"#f8f8f8"},muted:{value:"#888888"},border:{value:"#e5e5e5"},"primary-bg":{value:"#fdf4f4"},link:{value:"#1976d2"},"tag-bg":{value:"#f0f0f0"},"accent-bg":{value:"#1976d2"},"on-color-fg":{value:"#ffffff",note:"彩色底(徽章、选中态按钮)上的文字"}}),lt("提示与警告",{"info-fg":{value:"#0c5380"},"info-bg":{value:"#e7f3ff"},"info-border":{value:"#b3dbff"},"warn-fg":{value:"#856404"},"warn-bg":{value:"#fff3cd"},"warn-border":{value:"#ffc107"},"danger-bg":{value:"rgba(244, 67, 54, 0.08)",note:"错误提示条底色"},"danger-soft-bg":{value:"rgba(244, 67, 54, 0.03)",note:"编辑器危险区块"},"danger-soft-border":{value:"rgba(244, 67, 54, 0.13)"}}),lt("遮罩与阴影",{backdrop:{value:"rgba(0, 0, 0, 0.5)",note:"对话框遮罩"},"overlay-bg":{value:"#00000010",note:"轻量遮罩底(图片占位等)"},"shadow-dialog":{value:"0 4px 20px rgba(0, 0, 0, 0.3)"},"shadow-dropdown":{value:"0 4px 12px rgba(0, 0, 0, 0.1)"},"shadow-tooltip":{value:"0 2px 8px rgba(0, 0, 0, 0.08)"},"shadow-fab":{value:"0 2px 8px rgba(0, 0, 0, 0.25)",note:"悬浮按钮(反馈)"},"shadow-card":{value:"0 1px 4px rgba(0, 0, 0, 0.06)",note:"展开的卡片"},"shadow-node":{value:"0 1px 3px rgba(0, 0, 0, 0.1)",note:"谱系图节点"},"shadow-node-selected":{value:"0 0 0 3px rgba(0, 120, 212, 0.2), 0 2px 8px rgba(0, 120, 212, 0.3)"}}),lt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),lt("资源",{"restype-text":{value:"#2196f3"},"restype-image":{value:"#ff9800"},"restype-text-image":{value:"#9c27b0"},"restype-physical":{value:"#795548"},"missing-fg":{value:"#e67e22",note:"资源缺册提示"},"colormode-bw-bg":{value:"#f5f5f5",note:"影印件色彩模式标记(黑白 / 彩色)"},"colormode-bw-fg":{value:"#757575"},"colormode-color-bg":{value:"#fff8e1"},"colormode-color-fg":{value:"#f57f17"},"progress-active":{value:"#f59e0b",note:"资源导入进度"},"progress-done":{value:"#10b981"},"progress-todo":{value:"#9ca3af"},"check-fine-bg":{value:"#e8f5e9",note:"文字资源校对程度徽章(精校 / 粗校 / AI整理)"},"check-fine-fg":{value:"#2e7d32"},"check-rough-bg":{value:"#fff3e0"},"check-rough-fg":{value:"#e65100"},"check-ai-bg":{value:"#e3f2fd"},"check-ai-fg":{value:"#1565c0"}}),lt("整理本(CollatedEdition)",{"highlight-bg":{value:"#fff59d",note:"搜索命中高亮底"},"highlight-fg":{value:"inherit",root:!1},"section-lei":{value:"#8e6f3e",note:"章节类型标记:类 / 书 / 序 / 结语 / 考证 / 注释"},"section-shu":{value:"#c0392b"},"section-xu":{value:"#1a5276"},"section-jieyu":{value:"#7d6608"},"section-kaozhen":{value:"#5d6d7e"},"section-zhushi":{value:"#6c5b7b"},"section-tag-fg":{value:"#e74c3c",note:"章节标记(△ 等)"},"matchstate-fg":{value:"#b78900",note:"与底本匹配状态提示"},"quality-source":{value:"#1b5e20",note:"文本质量等级(底本 / OCR / 粗校 / 精校 / 暂无正文 / 占位)"},"quality-ocr":{value:"#e65100"},"quality-rough":{value:"#1565c0"},"quality-fine":{value:"#2e7d32"},"quality-none":{value:"#5f6368",note:"中性灰:暂无正文"},"quality-placeholder":{value:"#757575",note:"中性灰:占位"}}),lt("版本传承(VersionLineageGraph / List) / 关系方向(RelationPanel)",{"lost-fg":{value:"#c62828",note:"佚失标记"},"confidence-certain":{value:"#2e7d32",note:"关系置信度"},"confidence-consensus":{value:"#1976d2"},"confidence-probable":{value:"#ed6c02"},"confidence-disputed":{value:"#c62828"},"lineage-edge-consensus":{value:"#555555",note:"⚠️ 同为 consensus,List 徽章用 --bim-confidence-consensus(蓝),Graph 连线用这个(灰)。若要统一,覆盖成 var(--bim-confidence-consensus)"},"relation-up":{value:"#2196f3"},"relation-down":{value:"#4caf50"},"relation-flat":{value:"#ff9800"}}),lt("编辑器视图(主要在 guji-platform 插件中可见)",{"editor-type-work":{value:"#4caf50",note:"⚠️ 与展示视图的 --bim-type-* 是两套配色(历史如此)。若要统一,覆盖成对应的 var(--bim-type-*)"},"editor-type-collection":{value:"#2196f3"},"editor-type-book":{value:"#ff9800"},"editor-type-entity":{value:"#9c27b0"},"source-url":{value:"#2196f3",note:"来源类型(SourceEditor)"},"source-bookid":{value:"#4caf50"},"mode-active-bg":{value:"#2196f3",note:"模式指示器当前态(ModeIndicator)"},"cover-accent":{value:"#8e6f3e",note:'书目卡片「封面」点缀(IndexBrowser resultVariant="card")'}}),lt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --bim-primary 等控件色",{"page-bg":{value:"#fbf9f3",note:"纸"},"row-hover-bg":{value:"#f5f1e5"},"selection-bg":{value:"#ecdcbc",note:"选区"},"band-bg":{value:"#f0e4cb",note:"全文入口横幅(暖沙)"},"band-bg-hover":{value:"#e6d5b4"},ink:{value:"#2a231c",note:"文字层次:墨 → 正文 → 提要 → meta → 标签 → 提示"},"body-fg":{value:"#3b3228"},"quiet-fg":{value:"#5b4f40"},"meta-fg":{value:"#7b6a54"},"label-fg":{value:"#6f6457",note:"标签 / 提示:2026-09 N3a 调深,纸底与斑马底上对比度均 ≥4.5(原 #a3937b 2.8、#b3a385 2.3)"},"hint-fg":{value:"#756a5e"},accent:{value:"#9c3a2c",note:"朱"},"accent-deep":{value:"#6f2a20",note:"链接 hover"},"rule-strong":{value:"#2a231c",note:"分隔线:强 → 常规 → 虚线 → 提要左线"},rule:{value:"#e4dbc9"},"rule-dashed":{value:"#d6c9ae"},"rule-accent-soft":{value:"#e0d3b6"},"aux-fg":{value:"#6f6457",note:"辅助字(元数据、注记、「·」分隔的浅色小字)。须在 page-bg / zebra-bg 上对比度 ≥4.5(Q5 巡检)"},"card-bg":{value:"#fffdf9",note:"提要卡:抬起的面"},"zebra-bg":{value:"#f6f2eb",note:"表格斑马纹 / 左栏分组底(不画格线,靠这一阶底色分行)"},"tint-bg":{value:"#f3eee6",note:"检索框、悬停"},"shadow-summary":{value:"0 10px 32px rgba(60, 50, 40, 0.07)",note:"提要卡投影"},"flag-bg":{value:"rgba(158, 42, 43, 0.08)",note:"唯一的状态色块「有影印」"},"theme-dot-zhusha":{value:"#9c3a2c",note:"主题切换控件的色点:朱砂(不随主题变,两套主题下都要认得出)"},"theme-dot-indigo":{value:"#2e5266",note:"主题切换控件的色点:靛青"},"theme-dot-ink":{value:"#3b4a58",note:"主题切换控件的色点:墨"},"sect-jing":{value:"#2e5266",note:"四部分布条:經部(人物页提要卡;无别处使用)"},"sect-shi":{value:"#9a7a3b",note:"四部分布条:史部"},"sect-zi":{value:"#4f7a5c",note:"四部分布条:子部"},"sect-ji":{value:"#9fb3bc",note:"四部分布条:集部"},"table-border":{value:"color-mix(in srgb, currentColor 28%, transparent)",root:!1,note:"古籍表格(跟随当前文字色)"},"table-head-bg":{value:"color-mix(in srgb, currentColor 8%, transparent)",root:!1}}),lt('版式(v4 外观系统,overview#291):疏朗=留白分区(默认,下列值即疏朗);界栏=框线分区(`<html data-layout="boxed">`)',{"fr-bd":{value:"0 solid transparent",note:"区块外框(border 简写)。疏朗无框;界栏 1px 实线"},"fr-bg":{value:"transparent",note:"区块底。界栏=卡面色"},"fr-hd-pad":{value:"14px 18px",note:"区块标题栏内边距。10-01 起疏朗也有淡染底的标题栏(--bim-fr-hd-bg),故疏朗 14px 18px,界栏 12px 18px"},"fr-hd-bd":{value:"0 solid transparent",note:"区块标题栏下沿线(border 简写)"},"fr-bd-pad":{value:"0",note:"区块正文内边距"},"fr-gap":{value:"56px",note:"区块之间的间距。界栏收紧到 24px(框线本身已分隔)"},"fr-side-gap":{value:"34px",note:"侧栏各块之间的间距;界栏 20px"},"fr-shadow":{value:"0 1px 0 var(--bim-rule), 0 12px 32px -18px rgba(40, 36, 31, 0.25)",note:"抬起的面(提要卡)的投影;界栏不用投影,靠框线"},"fr-tab-bd":{value:"transparent",note:"页签行下沿线颜色(疏朗不画,界栏画)"},"fr-hd-size":{value:"24px",note:"分区标题字号。界栏标题在框顶标题栏里,小一档 19px"},"fr-hd-bg":{value:"color-mix(in srgb, var(--bim-accent) 7%, var(--bim-page-bg))",note:"分区标题栏底色(淡染主色)。疏朗混进页面底,界栏 6% 混进卡面底。主色取 accent(primary 是 VS Code 按钮蓝,不随配色)"},"fr-card-bd":{value:"1px solid transparent",note:"卡片边框。疏朗不画(靠卡面底与淡投影);界栏 1px"},"fr-card-bg":{value:"var(--bim-card-bg)",note:"卡片底"},"fr-row-bd":{value:"1px solid transparent",note:"列表行线、块内小分割线。疏朗不画(靠行距);界栏 1px"},"fr-row-pad":{value:"10px 2px",note:"列表行内边距。界栏收紧 7px 2px"},"fr-chrome-bd":{value:"1px solid transparent",note:"顶栏、分区导航(吸顶锚点条)的线"},"fr-tag-bd":{value:"1px solid transparent",note:"标签、版本签、计数签、工具按钮的边框。疏朗浅底无框;界栏透明底加框"},"fr-tag-bg":{value:"var(--bim-tint-bg)",note:"标签底"},"fr-tbl-cell-bd":{value:"0 solid transparent",note:"表格格线。疏朗不画(靠斑马纹);界栏全格线"},"fr-tbl-zebra":{value:"var(--bim-tint-bg)",note:"表格斑马纹(只在疏朗下有)"},"fr-rail-bd":{value:"1px solid transparent",note:"侧栏里的块、提示块的边框"},"fr-rail-bg":{value:"var(--bim-tint-bg)",note:"侧栏块底。疏朗浅底;界栏卡面底"},"fr-spine-bd":{value:"1px solid transparent",note:"题签、书脊(竖排书名)的边框。界栏是强调色浅线"},"fr-spine-bg":{value:"var(--bim-flag-bg)",note:"题签、书脊底。疏朗浅色实底;界栏卡面底(正史原志两种版式都是强调色实底)"},"fr-plank":{value:"0 solid transparent",note:"书架架板(border 简写)。只在界栏下画 3px"},"fr-axis-bd":{value:"0 solid transparent",note:"时间轴轴线。界栏 1px"},"fr-axis-band":{value:"6px",note:"时间轴底带高度。疏朗用 6px 浅色带代替轴线;界栏 0"},"fr-tick":{value:"0",note:"时间轴刻度短线长度。界栏 5px"},"fr-band-gap":{value:"3px",note:"年代带各段之间的空隙。疏朗 3px;界栏紧贴"},"fr-band-bd":{value:"0 solid transparent",note:"年代带外框与段间分隔。界栏 1px"}}),lt("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"},"reader-warm":{value:"#c9a24a",note:"阅读设置侧栏的暖黄:只做底色(8%)与选中态(24%),与朱/靛/墨三套主色都不冲"},"warp-bg":{value:"#faf8f5",note:"古籍矫正底本书影画布底色"},"warp-box-shadow":{value:"0 2px 12px rgba(0, 0, 0, 0.08)",note:"古籍底本书影浮雕阴影"},"warp-sel-bg":{value:"rgba(196, 148, 76, 0.45)",note:"古籍对读字框选中高亮底色"},"warp-sel-stroke":{value:"#a06e1c",note:"古籍对读字框选中描边"},"warp-hover-bg":{value:"rgba(217, 185, 106, 0.25)",note:"古籍对读字框悬停高亮底色"},"warp-hover-stroke":{value:"#c4944c",note:"古籍对读字框悬停描边"},"warp-badge-bg":{value:"rgba(184, 134, 54, 0.12)",note:"图文对读徽章背景"},"warp-badge-fg":{value:"#8c6820",note:"图文对读徽章文字颜色"},"warp-badge-bd":{value:"rgba(184, 134, 54, 0.3)",note:"图文对读徽章边框"},"warp-banxin-border":{value:"#8a8070",note:"版心分界线"},"warp-banxin-fold":{value:"rgba(160, 110, 28, 0.65)",note:"版心中缝对折线"},"warp-banxin-outer":{value:"#c9c3b4",note:"版心外边线"}}),lt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),lt("字体(全站无衬线,2026-09-05 定)",{"font-ui":{value:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif'},"font-body":{value:"system-ui, sans-serif",css:"var(--bim-font-ui)"},"font-serif":{value:xs,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:xs,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],Hp=Object.assign({},...Fp.map(e=>e.tokens)),nl={};for(const[e,n]of Object.entries(Hp))nl[e]=`var(--bim-${e}, ${n.value})`;function r(e){const n=nl[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function Mt(e){return e.types&&e.types.length>0?e.types:[]}function Dp(e,n){return Mt(e).includes(n)}const Up={source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暫無正文",placeholder:"占位"};r("quality-source"),r("quality-ocr"),r("quality-rough"),r("quality-fine"),r("quality-none"),r("quality-placeholder");const Vp={"commons.wikimedia.org":"維基共享","zh.wikisource.org":"維基文庫","taiwanebook.ncl.edu.tw":"臺灣華文電子書庫","ctext.org":"中國哲學書電子化計劃","www.shidianguji.com":"識典古籍","shidianguji.com":"識典古籍","archive.org":"Internet Archive","www.shuge.org":"書格","shuge.org":"書格","pan.baidu.com":"百度網盤"};function fn(e){try{return Vp[new URL(e).hostname]}catch{return}}const bs={text:0,image:1,physical:2};function Gr(e){return e.length===0?"physical":[...e].sort((n,i)=>(bs[n]??99)-(bs[i]??99)).join("+")}function Gp(e){return e.includes("text")&&e.includes("image")?"text+image":e[0]||"physical"}function Yr(e){var l;const n=d=>{const c=d.match(/^(.+?)·第(\d+)[冊册]$/);if(c)return[c[1],parseInt(c[2])];const p=d.match(/^(.+?)[·(](\d+)[)]?$/);return p?[p[1],parseInt(p[2])]:null},i=new Map;for(let d=0;d<e.length;d++){const c=e[d];if(c.volumes&&c.volumes.length>0)continue;const p=n(c.name);if(!p)continue;const[h,u]=p,m=`${h}|${Gr(Mt(c))}`;i.has(m)||i.set(m,{base:{...c,name:h,url:"",volumes:[]},volumes:[],indices:[]});const f=i.get(m);f.volumes.push({volume:u,url:c.url||void 0,status:"found"}),f.indices.push(d)}const o=[],s=new Set;for(const d of i.values())if(!(d.volumes.length<2)){d.volumes.sort((c,p)=>c.volume-p.volume),d.base.volumes=d.volumes,d.base.expected_volumes=d.volumes.length,d.base.url||(d.base.url=((l=d.volumes.find(c=>c.url))==null?void 0:l.url)??""),o.push(d.base);for(const c of d.indices)s.add(c)}const a=[...o];for(let d=0;d<e.length;d++)s.has(d)||a.push(e[d]);return a}function il(e){if(e.url)return e.url;for(const[n,i]of Object.entries(e))if(n.endsWith("_url")&&typeof i=="string")return i}function rl(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||il(n)}))}function ki(e){const n=rl(e);if(!n)return null;const i=new Set(n.filter(s=>s.status!=="missing").map(s=>s.volume)).size,o=new Set(n.filter(s=>s.status==="missing").map(s=>s.volume)).size;return{found:i,missing:o,expected:e.expected_volumes??i+o}}function qr(e){if(!e)return;const n=e.file_page_range||e.page_range;if(!n||typeof n!="string")return;const i=n.match(/^(\d+)/);return i?parseInt(i[1],10):void 0}function Kr(e,n){try{if(new URL(e).hostname.includes("wikimedia.org")){const o=e.match(/\/wiki\/File:(.+?)(?:#|$)/);if(o)return`https://commons.wikimedia.org/w/index.php?title=File%3A${encodeURIComponent(decodeURIComponent(o[1]))}&page=${n}`;const s=new URL(e);return s.searchParams.set("page",String(n)),s.toString()}return e}catch{return e}}function xn(e){if(!e.url)return;const n=qr(e.metadata);return n?Kr(e.url,n):e.url}const Tt=g.createContext(null),ol=["曹霑"];function Yp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function qp(e,n=ol){const i=[...new Set(n.filter(Boolean))].sort((a,l)=>l.length-a.length);if(!i.length)return e;const o=new RegExp(`(${i.map(Yp).join("|")})`,"g"),s=new Set(i);return a=>{if(!a)return e(a);const l=a.split(o);return l.length===1?e(a):l.map((d,c)=>c%2===1&&s.has(d)?d:d&&e(d)).join("")}}let wn=null;function sl(){if(wn)return wn;try{const e=Mp.Converter({from:"t",to:"cn"});wn=qp(n=>e(Se.normalizeVariants(n)))}catch{wn=e=>e}return wn}const Kp={indexType:{work:"作品",book:"書籍",collection:"叢編",entity:"人物"},resourceType:{text:"文字資源",image:"圖片資源",textImage:"文字+圖片資源",physical:"館藏"},resourceTypeShort:{text:"文字",image:"圖片",textImage:"文字+圖片",physical:"館藏"},rootType:{catalog:"目錄式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:r("check-fine-bg"),fg:r("check-fine-fg")},粗校:{label:"粗校",bg:r("check-rough-bg"),fg:r("check-rough-fg")},AI整理:{label:"AI整理",bg:r("check-ai-bg"),fg:r("check-ai-fg")}},action:{save:"保存",delete:"刪除",newEntry:"+ 新建",viewAll:"查看全部 →",visit:"訪問 →",view:"查看 →",viewEntity:"查看",copy:"複製 ID",copied:"已複製",linkExisting:"+ 關聯現有",createAndLink:"+ 創建並關聯",remove:"刪除",clearAll:"清除全部",reselect:"重選",changeType:"更換類型",expand:"展開",collapse:"收起",expandMore:"展開更多",addSubWork:"添加子作品",addVersion:"添加新版本",addBook:"添加書籍",addSubCollection:"添加子叢編",addCollectionImpl:"添加叢編實現",addSource:"添加來源",addResource:"添加資源",addIndexedBy:"+ 添加收錄來源",addEmendatedBy:"+ 添加考證來源",addAdditionalWork:"+ 添加附屬作品",selectBookOrWork:"選擇書籍/作品",clickToSelectBookOrWork:"點擊選擇書籍/作品",unlink:"解除關聯"},label:{id:"ID:",author:"作者 (Author)",dynasty:"朝代/年份 (Dynasty/Year)",edition:"版本",juanCount:"卷數",pageCount:"頁數 (Pages)",volumeCount:"冊數 (Volumes)",holder:"現藏於 (Holder)",firstImage:"首頁圖片 (First Image URL)",year:"年代",currentLocation:"現藏",parentWork:"上級作品",relatedWorks:"相關作品",type:"類型",rootType:"根類型",coverageLevel:"覆蓋層級",coverageRange:"覆蓋範圍",metadata:"元數據",optionalInfo:"可選信息",details:"詳細說明",detailsOptional:"詳細說明 (可選)",positionOptional:"位置/頁碼 (可選)",dataVersionOptional:"數據版本 (可選)",processorVersionOptional:"處理器版本 (可選)",sourceName:"來源名稱",sourceBid:"來源 BID",titleInfo:"題名",authorInfo:"著者",urlAddress:"URL 地址"},section:{basicInfo:"📊 基本信息",description:"📝 介紹 (Description)",additionalWorks:"📑 附屬作品 (Additional Works)",indexedBy:"📖 著錄於",emendatedBy:"📝 考證",resources:"資源",textResources:"📝 文字資源 (Text Resources)",imageResources:"🖼️ 圖片資源 (Image Resources)",sources:"📚 資料來源 (Sources)",provenance:"📜 收藏歷史 (Provenance)",relatedVersions:"相關版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危險區域 (Danger Zone)",aliases:"別名",attachedTexts:"附載篇目",appendix:"附錄",containedIn:"收入叢編",collectedIn:"收入叢編",belongsToWork:"所屬作品",locationHistory:"流轉歷史",historyOverview:"歷史沿革",containedBooks:"收錄書籍",relations:"關聯關係",summary:"提要",comment:"按語",additionalComment:"附按",indexed:"收錄於",emendated:"考證",relatedWorks:"相關作品",containedWorks:"包含作品",adaptations:"改編作品",derivativeWorks:"續書與評註",studies:"所考典籍"},relation:{belongsToWork:"所屬作品 (Work)",containedInCollection:"收入叢編",siblingVersions:"同作品其他版本",addVersionForWork:"為此作品添加新版本",parentWork:"父作品 (Parent Work)",childWorks:"子作品",collectionImpl:"叢編實現",allVersions:"所有版本",correspondingWork:"對應作品 (Work)",parentCollection:"父叢編 (Parent Collection)",childCollections:"子叢編",containedBooks:"包含書籍",notLinked:"(未關聯)",none:"(暫無)"},search:{placeholder:"搜索作品、書籍、叢編...",searching:"搜索中...",loading:"加載中...",noResults:"無匹配結果",noResultsFor:"未找到與「{query}」相關的結果",tryOther:"試試其他關鍵詞、別名或作者名",recentBrowse:"最近瀏覽",history:"搜索歷史",clearAll:"清除全部",clearRecent:"清除最近瀏覽",itemNotFound:"無法找到,可能已刪除",removeFromRecent:"移除",searchTitle:"搜索古籍索引",allTab:"全部",resultTabs:"結果分類",searchSubtitle:"輸入關鍵詞搜索作品、書籍或叢編",searchBookName:"搜索書名...",alias:"別名"},searchV4:{filterTitle:"篩選",dynasty:"朝代",classification:"部類",resources:"資源",extant:"存佚",clearAllFilters:"清除全部篩選",hasImage:"有影印",hasText:"有文本",hasCollated:"有文本",filterButton:"篩選",filterSelected:"{n} 項已選",expand:"展開",collapse:"收起",filteredCount:"篩出 {n} 條",removeFilter:"取消篩選:{name}",viewLabel:"結果視圖",viewTable:"表格",viewCard:"卡片",colTitle:"題名",colType:"類型",colAuthor:"責任者",colEra:"年代",colClass:"部類",colResource:"資源",tagImage:"影印",tagText:"文本",tagCollated:"文本",tagLost:"佚",pageInfo:"共 {total} 條 · 每頁 {size} 條 · 第 {page} / {pages} 頁",pagerLabel:"翻頁",prevPage:"上一頁",nextPage:"下一頁",emptyFiltered:"沒有找到匹配的條目。試試更短的書名、減少篩選,或切換繁 / 簡。",limitedNote:"各類只列前幾條,點上方分類頁籤看全部。",sortLabel:"排序",sortRelevance:"相關度",sortEra:"年代",sortTitle:"書名",sortEraAsc:"由早到晚",sortEraDesc:"由晚到早",sortTitleAsc:"拼音 A→Z",sortTitleDesc:"拼音 Z→A"},home:{title:"古籍索引",subtitle:"從左側搜索框輸入關鍵詞,查找作品、書籍或叢編",recommendedBrowse:"推薦瀏覽",catalogTab:"目錄",collectionTab:"叢編",siteTab:"在線資源",recommendTab:"推薦",feedbackTab:"反饋",statusInProgress:"進行中",statusDone:"已完成",statusTodo:"未開始",typeCatalog:"目錄",typeCollection:"資源集合",totalPending:"待統計",progressFormat:"{imported} / {total}",siteCoverage:"資源覆蓋"},browser:{title:"古籍資源索引",subtitle:""},detailTab:{basicInfo:"概覽",catalog:"目錄",collectionCatalog:"叢編目錄",collatedEdition:"文本",catalogSuffix:"·目錄",fullText:"文本",lineage:"版本傳承",feedback:"勘誤反饋",dataSource:"數據源",backToIndex:"典籍版本索引",submitVersion:"提交新版本",dataLicense:"數據源與授權"},metadata:{edition:"版本",version:"修訂版本",quality:"資源質量",check_type:"校對",image_source:"影像來源",team:"所屬團隊",publisher:"出版社",year:"出版年份",format:"格式",note:"備註",total_page:"頁數",total_pages:"總頁數",page_range:"頁碼範圍",page_count:"頁數",file_page_range:"文件頁碼",file_page_count:"文件頁數",content_page_range:"影印頁碼",volume:"冊",color_mode:"色彩",paragraph_count:"段落數",has_translation:"翻譯"},editor:{untitled:"未命名",workTitle:"作品名 (Work Title)",collectionTitle:"叢書名 (Collection Title)",bookTitle:"書名 (Book Title)",belongsToWork:"所屬作品 (Work)",authorLabel:"作者 (Author)",publicationYearLabel:"出版年 (Publication year)",containedIn:"收入叢編",holderLabel:"現藏於 (Holder)",pageLabel:"頁數 (Pages)",volumeLabel:"冊數 (Volumes)",firstImageLabel:"首頁圖片 (First Image URL)",descriptionPlaceholder:"簡要介紹...",provenancePlaceholder:"該資源的流轉與收藏記錄...",otherEditionsPlaceholder:"相關版本的 ID...",dangerZoneDesc:"從索引庫中永久刪除該實體的所有元數據文件。",deleteEntity:"刪除該實體 (Delete Entity)",selectToLink:"選擇要關聯的",unnamedSource:"(未命名來源)",selectSourceType:"選擇來源類型",fromExistingBook:"從現有書籍選擇",enterUrl:"輸入網址鏈接",sourceNamePlaceholder:"如: 維基文庫、中國基本古籍庫",deleteThisSource:"刪除此來源",deleteThisResource:"刪除此資源",resourcePlaceholder:"資源",idAutoExtract:"ID (自動從URL提取)",resourceName:"資源名稱",resourceUrl:"資源鏈接 (URL)",structurePlaceholder:"層級結構 (如: 冊、卷)",coverageRangePlaceholder:"如: 2,3,5-8",detailsPlaceholder:"詳細說明",summaryPlaceholder:"提要...",commentPlaceholder:"按語...",additionalCommentPlaceholder:"附按...",imageResourceLink:"圖片資源鏈接",bookNameLabel:"書名",sourcePlaceholder:"來源"},download:{completed:"下載完成",downloading:"下載中",downloadThis:"下載此資源"},mode:{localMode:"本地模式",syncMode:"同步模式:",githubSync:"GitHub 同步",switchToSync:"點擊切換到同步模式",switchToLocal:"點擊切換到本地模式",switchToGithub:"點擊切換到 GitHub 同步模式",switchToDraft:"點擊切換到 draft 倉庫",switchToOfficial:"點擊切換到 official 倉庫",selectFolder:"選擇本地文件夾",configurePath:"配置同步路徑"},catalog:{totalVolumes:"共",processed:"已處理",contains:"收錄",matched:"已匹配",unmatched:"待匹配",source:"來源:",all:"全部",loading:"加載叢編目錄...",notFound:"未找到叢編目錄數據",loadFailed:"加載失敗",noMatch:"無匹配結果",unmatched_label:"未匹配",volume:"第 {n} 冊"},unit:{juan:"卷",volume:"冊",bu:"部",items:"條"},workSubtype:{book:"書",article:"篇",poem:"詩",chapter:"篇章"},colorMode:{bw:"黑白",color:"彩色"},misc:{noResources:"暫無資源信息",hasTranslation:"有",noTranslation:"無",structure:"層級",coverage:"覆蓋",notFoundEntry:"未找到該條目",loadFailed:"加載失敗",textResource:"文字資源",imageResource:"圖片資源"}},Xp={indexType:{work:"作品",book:"书籍",collection:"丛编",entity:"人物"},resourceType:{text:"文字资源",image:"图片资源",textImage:"文字+图片资源",physical:"馆藏"},resourceTypeShort:{text:"文字",image:"图片",textImage:"文字+图片",physical:"馆藏"},rootType:{catalog:"目录式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:r("check-fine-bg"),fg:r("check-fine-fg")},粗校:{label:"粗校",bg:r("check-rough-bg"),fg:r("check-rough-fg")},AI整理:{label:"AI整理",bg:r("check-ai-bg"),fg:r("check-ai-fg")}},action:{save:"保存",delete:"删除",newEntry:"+ 新建",viewAll:"查看全部 →",visit:"访问 →",view:"查看 →",viewEntity:"查看",copy:"复制 ID",copied:"已复制",linkExisting:"+ 关联现有",createAndLink:"+ 创建并关联",remove:"删除",clearAll:"清除全部",reselect:"重选",changeType:"更换类型",expand:"展开",collapse:"收起",expandMore:"展开更多",addSubWork:"添加子作品",addVersion:"添加新版本",addBook:"添加书籍",addSubCollection:"添加子丛编",addCollectionImpl:"添加丛编实现",addSource:"添加来源",addResource:"添加资源",addIndexedBy:"+ 添加收录来源",addEmendatedBy:"+ 添加考证来源",addAdditionalWork:"+ 添加附属作品",selectBookOrWork:"选择书籍/作品",clickToSelectBookOrWork:"点击选择书籍/作品",unlink:"解除关联"},label:{id:"ID:",author:"作者 (Author)",dynasty:"朝代/年份 (Dynasty/Year)",edition:"版本",juanCount:"卷数",pageCount:"页数 (Pages)",volumeCount:"册数 (Volumes)",holder:"现藏于 (Holder)",firstImage:"首页图片 (First Image URL)",year:"年代",currentLocation:"现藏",parentWork:"上级作品",relatedWorks:"相关作品",type:"类型",rootType:"根类型",coverageLevel:"覆盖层级",coverageRange:"覆盖范围",metadata:"元数据",optionalInfo:"可选信息",details:"详细说明",detailsOptional:"详细说明 (可选)",positionOptional:"位置/页码 (可选)",dataVersionOptional:"数据版本 (可选)",processorVersionOptional:"处理器版本 (可选)",sourceName:"来源名称",sourceBid:"来源 BID",titleInfo:"题名",authorInfo:"著者",urlAddress:"URL 地址"},section:{basicInfo:"📊 基本信息",description:"📝 介绍 (Description)",additionalWorks:"📑 附属作品 (Additional Works)",indexedBy:"📖 著录于",emendatedBy:"📝 考证",resources:"资源",textResources:"📝 文字资源 (Text Resources)",imageResources:"🖼️ 图片资源 (Image Resources)",sources:"📚 资料来源 (Sources)",provenance:"📜 收藏历史 (Provenance)",relatedVersions:"相关版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危险区域 (Danger Zone)",aliases:"别名",attachedTexts:"附载篇目",appendix:"附录",containedIn:"收入丛编",collectedIn:"收入丛编",belongsToWork:"所属作品",locationHistory:"流转历史",historyOverview:"历史沿革",containedBooks:"收录书籍",relations:"关联关系",summary:"提要",comment:"按语",additionalComment:"附按",indexed:"收录于",emendated:"考证",relatedWorks:"相关作品",containedWorks:"包含作品",adaptations:"改编作品",derivativeWorks:"续书与评注",studies:"所考典籍"},relation:{belongsToWork:"所属作品 (Work)",containedInCollection:"收入丛编",siblingVersions:"同作品其他版本",addVersionForWork:"为此作品添加新版本",parentWork:"父作品 (Parent Work)",childWorks:"子作品",collectionImpl:"丛编实现",allVersions:"所有版本",correspondingWork:"对应作品 (Work)",parentCollection:"父丛编 (Parent Collection)",childCollections:"子丛编",containedBooks:"包含书籍",notLinked:"(未关联)",none:"(暂无)"},search:{placeholder:"搜索作品、书籍、丛编...",searching:"搜索中...",loading:"加载中...",noResults:"无匹配结果",noResultsFor:"未找到与「{query}」相关的结果",tryOther:"试试其他关键词、别名或作者名",recentBrowse:"最近浏览",history:"搜索历史",clearAll:"清除全部",clearRecent:"清除最近浏览",itemNotFound:"无法找到,可能已删除",removeFromRecent:"移除",searchTitle:"搜索古籍索引",allTab:"全部",resultTabs:"结果分类",searchSubtitle:"输入关键词搜索作品、书籍或丛编",searchBookName:"搜索书名...",alias:"别名"},searchV4:{filterTitle:"筛选",dynasty:"朝代",classification:"部类",resources:"资源",extant:"存佚",clearAllFilters:"清除全部筛选",hasImage:"有影印",hasText:"有文本",hasCollated:"有文本",filterButton:"筛选",filterSelected:"{n} 项已选",expand:"展开",collapse:"收起",filteredCount:"筛出 {n} 条",removeFilter:"取消筛选:{name}",viewLabel:"结果视图",viewTable:"表格",viewCard:"卡片",colTitle:"题名",colType:"类型",colAuthor:"责任者",colEra:"年代",colClass:"部类",colResource:"资源",tagImage:"影印",tagText:"文本",tagCollated:"文本",tagLost:"佚",pageInfo:"共 {total} 条 · 每页 {size} 条 · 第 {page} / {pages} 页",pagerLabel:"翻页",prevPage:"上一页",nextPage:"下一页",emptyFiltered:"没有找到匹配的条目。试试更短的书名、减少筛选,或切换繁 / 简。",limitedNote:"各类只列前几条,点上方分类页签看全部。",sortLabel:"排序",sortRelevance:"相关度",sortEra:"年代",sortTitle:"书名",sortEraAsc:"由早到晚",sortEraDesc:"由晚到早",sortTitleAsc:"拼音 A→Z",sortTitleDesc:"拼音 Z→A"},home:{title:"古籍索引",subtitle:"从左侧搜索框输入关键词,查找作品、书籍或丛编",recommendedBrowse:"推荐浏览",catalogTab:"目录",collectionTab:"丛编",siteTab:"在线资源",recommendTab:"推荐",feedbackTab:"反馈",statusInProgress:"进行中",statusDone:"已完成",statusTodo:"未开始",typeCatalog:"目录",typeCollection:"资源集合",totalPending:"待统计",progressFormat:"{imported} / {total}",siteCoverage:"资源覆盖"},browser:{title:"古籍资源索引",subtitle:""},detailTab:{basicInfo:"概览",catalog:"目录",collectionCatalog:"丛编目录",collatedEdition:"文本",catalogSuffix:"·目录",fullText:"文本",lineage:"版本传承",feedback:"勘误反馈",dataSource:"数据源",backToIndex:"典籍版本索引",submitVersion:"提交新版本",dataLicense:"数据源与授权"},metadata:{edition:"版本",version:"修订版本",quality:"资源质量",check_type:"校对",image_source:"影像来源",team:"所属团队",publisher:"出版社",year:"出版年份",format:"格式",note:"备注",total_page:"页数",total_pages:"总页数",page_range:"页码范围",page_count:"页数",file_page_range:"文件页码",file_page_count:"文件页数",content_page_range:"影印页码",volume:"册",color_mode:"色彩",paragraph_count:"段落数",has_translation:"翻译"},editor:{untitled:"未命名",workTitle:"作品名 (Work Title)",collectionTitle:"丛书名 (Collection Title)",bookTitle:"书名 (Book Title)",belongsToWork:"所属作品 (Work)",authorLabel:"作者 (Author)",publicationYearLabel:"出版年 (Publication year)",containedIn:"收入丛编",holderLabel:"现藏于 (Holder)",pageLabel:"页数 (Pages)",volumeLabel:"册数 (Volumes)",firstImageLabel:"首页图片 (First Image URL)",descriptionPlaceholder:"简要介绍...",provenancePlaceholder:"该资源的流转与收藏记录...",otherEditionsPlaceholder:"相关版本的 ID...",dangerZoneDesc:"从索引库中永久删除该实体的所有元数据文件。",deleteEntity:"删除该实体 (Delete Entity)",selectToLink:"选择要关联的",unnamedSource:"(未命名来源)",selectSourceType:"选择来源类型",fromExistingBook:"从现有书籍选择",enterUrl:"输入网址链接",sourceNamePlaceholder:"如: 维基文库、中国基本古籍库",deleteThisSource:"删除此来源",deleteThisResource:"删除此资源",resourcePlaceholder:"资源",idAutoExtract:"ID (自动从URL提取)",resourceName:"资源名称",resourceUrl:"资源链接 (URL)",structurePlaceholder:"层级结构 (如: 册、卷)",coverageRangePlaceholder:"如: 2,3,5-8",detailsPlaceholder:"详细说明",summaryPlaceholder:"提要...",commentPlaceholder:"按语...",additionalCommentPlaceholder:"附按...",imageResourceLink:"图片资源链接",bookNameLabel:"书名",sourcePlaceholder:"来源"},download:{completed:"下载完成",downloading:"下载中",downloadThis:"下载此资源"},mode:{localMode:"本地模式",syncMode:"同步模式:",githubSync:"GitHub 同步",switchToSync:"点击切换到同步模式",switchToLocal:"点击切换到本地模式",switchToGithub:"点击切换到 GitHub 同步模式",switchToDraft:"点击切换到 draft 仓库",switchToOfficial:"点击切换到 official 仓库",selectFolder:"选择本地文件夹",configurePath:"配置同步路径"},catalog:{totalVolumes:"共",processed:"已处理",contains:"收录",matched:"已匹配",unmatched:"待匹配",source:"来源:",all:"全部",loading:"加载丛编目录...",notFound:"未找到丛编目录数据",loadFailed:"加载失败",noMatch:"无匹配结果",unmatched_label:"未匹配",volume:"第 {n} 册"},unit:{juan:"卷",volume:"册",bu:"部",items:"条"},workSubtype:{book:"书",article:"篇",poem:"诗",chapter:"篇章"},colorMode:{bw:"黑白",color:"彩色"},misc:{noResources:"暂无资源信息",hasTranslation:"有",noTranslation:"无",structure:"层级",coverage:"覆盖",notFoundEntry:"未找到该条目",loadFailed:"加载失败",textResource:"文字资源",imageResource:"图片资源"}};function dt(e,n,i){return{"zh-Hant":e,"zh-Hans":n}}const Zp=dt({toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主題",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加載中",repoSourceLink:"在 GitHub 查看本條目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分冊",expandVolumes:"展開分冊",collapseArrow:"收起 ▲",expandArrow:"展開 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年號",office:"官職",anonymous:"佚名",collective:"集體"},cbdbTitle:"CBDB 中國歷代人物傳記數據庫",entityPlaceholderNote:"人物信息暫缺。該 Entity 僅作為作者佔位,詳細生平資料尚待補充。",otherVersions:"其他版本",switchToEdit:"切換到編輯模式",switchToView:"切換到查看模式",modeEdit:"✏️ 編輯",modeView:"👁 查看",noData:"無數據"},{toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主题",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加载中",repoSourceLink:"在 GitHub 查看本条目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分册",expandVolumes:"展开分册",collapseArrow:"收起 ▲",expandArrow:"展开 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年号",office:"官职",anonymous:"佚名",collective:"集体"},cbdbTitle:"CBDB 中国历代人物传记数据库",entityPlaceholderNote:"人物信息暂缺。该 Entity 仅作为作者占位,详细生平资料尚待补充。",otherVersions:"其他版本",switchToEdit:"切换到编辑模式",switchToView:"切换到查看模式",modeEdit:"✏️ 编辑",modeView:"👁 查看",noData:"无数据"}),wi=dt({relation:{part_of:"所屬",has_part:"包含",contains_text_of:"收錄",collected_in:"叢編",text_carried_by:"載錄",studied_by:"研究",studies:"所考",preceded_by:"前承",followed_by:"後繼",derived_from:"衍生",has_adaptation:"改編",related:"相關"},lossStatus:{extant:"今存",fragment:"殘存",partial:"殘存",lost:"已佚",unknown:"未詳"},resourceKind:{text:"文本",image:"影印",textImage:"圖文",physical:"館藏"},otherImages:"其他影印",fragmentTag:"殘片",collapseVolumes:"收起分冊",expandVolumes:"展開 {n} 冊",mirror:"鏡像",volumeStats:"{found} / {expected} 冊",volumeStatsMissing:"{found} / {expected} 冊 缺 {missing}",pageNav:"本頁導航",thisPage:"本頁",more:"更多",expandRest:"展開其餘 {n} {unit}",read:"閱讀",showMore:"顯示更多({n})",review:{reviewed:"已審核",disputed:"有爭議",unreviewed:"未審核",draft:"草稿"},dataVersion:"數據版本",todoCount:"待核 {n} 項",lacuna:"闕文",lacunaWith:"闕文:{label}",composedChar:"組字:{label}",bce:"前{n}",roleAll:"全部",loading:"加載中…",noLineageGraph:"暫無版本圖數據",notFound:"找不到該條目,可能已被刪除或 ID 不正確",workInfo:"作品信息"},{relation:{part_of:"所属",has_part:"包含",contains_text_of:"收录",collected_in:"丛编",text_carried_by:"载录",studied_by:"研究",studies:"所考",preceded_by:"前承",followed_by:"后继",derived_from:"衍生",has_adaptation:"改编",related:"相关"},lossStatus:{extant:"今存",fragment:"残存",partial:"残存",lost:"已佚",unknown:"未详"},resourceKind:{text:"文本",image:"影印",textImage:"图文",physical:"馆藏"},otherImages:"其他影印",fragmentTag:"残片",collapseVolumes:"收起分册",expandVolumes:"展开 {n} 册",mirror:"镜像",volumeStats:"{found} / {expected} 册",volumeStatsMissing:"{found} / {expected} 册 缺 {missing}",pageNav:"本页导航",thisPage:"本页",more:"更多",expandRest:"展开其余 {n} {unit}",read:"阅读",showMore:"显示更多({n})",review:{reviewed:"已审核",disputed:"有争议",unreviewed:"未审核",draft:"草稿"},dataVersion:"数据版本",todoCount:"待核 {n} 项",lacuna:"阙文",lacunaWith:"阙文:{label}",composedChar:"组字:{label}",bce:"前{n}",roleAll:"全部",loading:"加载中…",noLineageGraph:"暂无版本图数据",notFound:"找不到该条目,可能已被删除或 ID 不正确",workInfo:"作品信息"}),Jp=dt({kind:"版本",fact:{editionType:"版本類型",publication:"刊印",era:"刊寫年代",measure:"卷帙",volumes:"冊次",baseEdition:"底本",holdings:"存藏",callNumber:"索書號",seals:"藏印",leafStyle:"行款",binding:"裝幀",dimensions:"尺寸",condition:"品相",aliases:"又名"},inferredFromEdition:"據版本題名推斷",volumesValue:"第 {range} {unit}({n} {unit})",andMorePlaces:" 等 {n} 處",viewImages:"看原書影印",sec:{fulltext:"文本",images:"影印",physical:"館藏",lineage:"版本源流",empty:"影印與文本"},chapterUnit:"章",chapterCount:"{n} {unit}",sourceBy:"據{src}",readFrom:"從{ch}讀起",firstChapter:"第一章",enterReader:"進入閱讀頁",externalText:"站外文本",groupCount:"{n} 組",placeCount:"{n} 處",lineageMeta:"據版本傳承著錄",lineageView:"源流視圖",viewCards:"卡片",viewGraph:"關係圖",totalOf:"全 {n} {unit}",emptyText:"尚未著錄該版本的影印、文本與收藏信息。",editionCount:"{n} 種版本",siblings:"同作品版本",byEra:"按年代",kindCount:"{n} 種",viewAllInWork:"在作品頁看全部 {n} 種 →",volumeRange:"第 {range} {unit}",volumeCount:"{n} {unit}",confidence:{certain:"確證",consensus:"通說",probable:"可能",disputed:"有爭議"},confidenceNote:"({c})",lineage:{ancestor:"祖本",reconstructed:"擬構祖本",thisEdition:"本版",derivatives:"翻刻 · 衍生",appendix:"附記"}},{kind:"版本",fact:{editionType:"版本类型",publication:"刊印",era:"刊写年代",measure:"卷帙",volumes:"册次",baseEdition:"底本",holdings:"存藏",callNumber:"索书号",seals:"藏印",leafStyle:"行款",binding:"装帧",dimensions:"尺寸",condition:"品相",aliases:"又名"},inferredFromEdition:"据版本题名推断",volumesValue:"第 {range} {unit}({n} {unit})",andMorePlaces:" 等 {n} 处",viewImages:"看原书影印",sec:{fulltext:"文本",images:"影印",physical:"馆藏",lineage:"版本源流",empty:"影印与文本"},chapterUnit:"章",chapterCount:"{n} {unit}",sourceBy:"据{src}",readFrom:"从{ch}读起",firstChapter:"第一章",enterReader:"进入阅读页",externalText:"站外文本",groupCount:"{n} 组",placeCount:"{n} 处",lineageMeta:"据版本传承著录",lineageView:"源流视图",viewCards:"卡片",viewGraph:"关系图",totalOf:"全 {n} {unit}",emptyText:"尚未著录该版本的影印、文本与收藏信息。",editionCount:"{n} 种版本",siblings:"同作品版本",byEra:"按年代",kindCount:"{n} 种",viewAllInWork:"在作品页看全部 {n} 种 →",volumeRange:"第 {range} {unit}",volumeCount:"{n} {unit}",confidence:{certain:"确证",consensus:"通说",probable:"可能",disputed:"有争议"},confidenceNote:"({c})",lineage:{ancestor:"祖本",reconstructed:"拟构祖本",thisEdition:"本版",derivatives:"翻刻 · 衍生",appendix:"附记"}}),Qp=dt({fact:{written:"成書",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考證",alias:"又名",attached:"附載",appendix:"附錄"},inferredFromEdition:"據版本題名推斷",loading:"載入中",emendationCount:"{n} 條",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著錄"},classifiedBy:"據《{source}》",sec:{versions:"版本",catalogs:"著錄",collected:"收入叢編",related:"相關書目",resources:"在線資源"},versionsTotal:"共 {n} 種",versionsWithImage:"{n} 種有影印",versionsCurrent:"當前 {n} 種",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著錄順序",col:{edition:"版本",era:"年代",holder:"館藏",image:"影印"},noVersionsFiltered:"當前篩選下沒有版本",noVersions:"暫無版本著錄",moreUnit:"種版本",inferredEraNote:"部分年代據版本題名推斷,非著錄原文",empty:"尚未著錄該作品的版本與書目收錄。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"歷代書目 {n} 家",tablist:"著錄書目",titleOnly:"僅著錄書名,無提要。",prev:"上一家:{name}",next:"下一家:{name}"}},{fact:{written:"成书",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考证",alias:"又名",attached:"附载",appendix:"附录"},inferredFromEdition:"据版本题名推断",loading:"载入中",emendationCount:"{n} 条",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著录"},classifiedBy:"据《{source}》",sec:{versions:"版本",catalogs:"著录",collected:"收入丛编",related:"相关书目",resources:"在线资源"},versionsTotal:"共 {n} 种",versionsWithImage:"{n} 种有影印",versionsCurrent:"当前 {n} 种",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著录顺序",col:{edition:"版本",era:"年代",holder:"馆藏",image:"影印"},noVersionsFiltered:"当前筛选下没有版本",noVersions:"暂无版本著录",moreUnit:"种版本",inferredEraNote:"部分年代据版本题名推断,非著录原文",empty:"尚未著录该作品的版本与书目收录。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"历代书目 {n} 家",tablist:"著录书目",titleOnly:"仅著录书名,无提要。",prev:"上一家:{name}",next:"下一家:{name}"}}),eu=dt({kind:"叢編",workCollection:"作品集",stat:{titles:"子目"},fact:{publication:"刊印",expected:"應收",measure:"卷帙"},member:{Book:"所收版本",Work:"所收作品",other:"成員"},memberNote:"子目與其各版本合計",nZhong:"{n} 種",nHan:"{n} 函",dist:{head:"全帙冊次分佈",segTitle:"{section} 第 {from}–{to} 冊",only:"只看{section}",unclassified:"未分類",hint:"點色段篩選部類"},sec:{titles:"子目",resources:"影印與文本"},totalVolumes:"全帙 {n} {unit}",currentN:"當前 {n} {unit}",loadAllTitle:"將載入全部 {n} {unit}",grouping:"正在按部類分組…",groupBySection:"按部類分組",find:"在本叢編中檢索",col:{volumes:"冊次",title:"書名",versions:"版本"},volumeRange:"第 {range} {unit}",resourcesCount:"{n} 處",text:"文本",empty:"尚未著錄該叢編的子目。",parent:"上級叢編"},{kind:"丛编",workCollection:"作品集",stat:{titles:"子目"},fact:{publication:"刊印",expected:"应收",measure:"卷帙"},member:{Book:"所收版本",Work:"所收作品",other:"成员"},memberNote:"子目与其各版本合计",nZhong:"{n} 种",nHan:"{n} 函",dist:{head:"全帙册次分布",segTitle:"{section} 第 {from}–{to} 册",only:"只看{section}",unclassified:"未分类",hint:"点色段筛选部类"},sec:{titles:"子目",resources:"影印与文本"},totalVolumes:"全帙 {n} {unit}",currentN:"当前 {n} {unit}",loadAllTitle:"将载入全部 {n} {unit}",grouping:"正在按部类分组…",groupBySection:"按部类分组",find:"在本丛编中检索",col:{volumes:"册次",title:"书名",versions:"版本"},volumeRange:"第 {range} {unit}",resourcesCount:"{n} 处",text:"文本",empty:"尚未著录该丛编的子目。",parent:"上级丛编"}),tu=dt({subtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年號",office:"官職",anonymous:"佚名",collective:"群體"},bce:"前{n}",floruit:"活躍於 {from}—{to}",zi:"字{name}",hao:"號{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 種",moreNames:"更多別名({n})",dist:"著作分佈",autoMatch:"自動匹配",sec:{featured:"著作舉要",allWorks:"全部著作",works:"著作",external:"站外資料"},featuredSub:"存世版本最多的三部",versionsUnit:"種版本",hasImage:"有影印",empty:"尚未著錄該人物的關聯作品。",total:"共 {n} 種",current:"當前 {n} 種",sortByVersions:"按版本數排列",sortByCatalog:"按著錄順序",col:{work:"作品",section:"部類",role:"職任",versions:"存世版本",image:"影印"},notRecorded:"未著錄",emptyRole:"該職任下的著作尚未著錄。",moreUnit:"種著作",cbdbAuto:"CBDB 為自動匹配,未經人工核對"},{subtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年号",office:"官职",anonymous:"佚名",collective:"群体"},bce:"前{n}",floruit:"活跃于 {from}—{to}",zi:"字{name}",hao:"号{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 种",moreNames:"更多别名({n})",dist:"著作分布",autoMatch:"自动匹配",sec:{featured:"著作举要",allWorks:"全部著作",works:"著作",external:"站外资料"},featuredSub:"存世版本最多的三部",versionsUnit:"种版本",hasImage:"有影印",empty:"尚未著录该人物的关联作品。",total:"共 {n} 种",current:"当前 {n} 种",sortByVersions:"按版本数排列",sortByCatalog:"按著录顺序",col:{work:"作品",section:"部类",role:"职任",versions:"存世版本",image:"影印"},notRecorded:"未著录",emptyRole:"该职任下的著作尚未著录。",moreUnit:"种著作",cbdbAuto:"CBDB 为自动匹配,未经人工核对"}),nu=dt({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",settingsShort:"設置",closeSettings:"收起設置",groupText:"文字",groupMark:"標註",groupLayout:"版面",font:"字體",fontSong:"宋體",fontKai:"楷體",fontSystem:"系統默認",script:"繁簡",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最後一{unit}",toc:"目錄",images:"書影",fontSmaller:"縮小字號",fontLarger:"放大字號",paragraphTitle:"條目分行 ↔ 自然段",paragraph:"自然段",workLinks:"標出作品鏈接",properNameTitle:"書名加波浪線",properName:"專名線",properNameOff:"不顯示",properNameLite:"精簡",properNameFull:"完整",properNameLiteTitle:"只標人名、地名、朝代",showWorks:"標註書名",bookTitleStyle:"書名樣式",bookTitleWavy:"波浪線",bookTitleBracket:"書名號",scriptOrig:"原字",scriptOrigShort:"原",scriptQuick:"字形",scriptHant:"通行繁體",scriptHans:"簡體",quoteStyle:"引號",quoteModern:"“”‘’",quoteClassic:"「」『』",quoteOriginal:"原樣",pageBreaks:"顯示分葉分割線",pageIndicator:"頁指示頭(上下鍵調整位置)",preserveMargins:"書影保留空白",facsimilePager:"書影翻頁",facsimilePageInput:"書影葉碼(輸入數字後按 Enter 或離開輸入框跳轉)",vertical:"豎排",closeToc:"收起目錄",sourceLabel:"出處",licenseOf:"授權 {license}",revisedAt:"最近校訂 {date}",reportError:"報告錯字",pagerNav:"翻卷",rail:"本卷",bottomBar:"閱讀工具",tocShort:"卷目",fontSize:"字號",close:"關閉",loading:"加載中…",noText:"暫無文本",tocFailed:"無法加載目錄",tocLoading:"加載目錄…",viewEntry:"查看條目",defaultRole:"撰",tocCaption:"目錄 · {n} {unit}",searchChapters:"搜索全部章節",searchChaptersPlaceholder:"搜索全部章節…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"來源",originalSource:"本站獨立整理",charGuess:"殘字(推測)",upstream:"上游",chapterFailed:"無法加載章節內容",references:"參考文獻",entityDetail:"查看詳情 →"},{imagesLoading:"加载书影…",noImages:"暂无书影",noImagesHint:"这一卷还没有配上影像;接入后在此与正文逐页对看",imageAlt:"书影 第 {label} 页",prevImage:"上一页书影",nextImage:"下一页书影",back:"阅读",backAria:"返回{label}首页",skipToText:"跳到正文",settings:"阅读设置",settingsShort:"设置",closeSettings:"收起设置",groupText:"文字",groupMark:"标注",groupLayout:"版面",font:"字体",fontSong:"宋体",fontKai:"楷体",fontSystem:"系统默认",script:"繁简",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最后一{unit}",toc:"目录",images:"书影",fontSmaller:"缩小字号",fontLarger:"放大字号",paragraphTitle:"条目分行 ↔ 自然段",paragraph:"自然段",workLinks:"标出作品链接",properNameTitle:"书名加波浪线",properName:"专名线",properNameOff:"不显示",properNameLite:"精简",properNameFull:"完整",properNameLiteTitle:"只标人名、地名、朝代",showWorks:"标注书名",bookTitleStyle:"书名样式",bookTitleWavy:"波浪线",bookTitleBracket:"书名号",scriptOrig:"原字",scriptOrigShort:"原",scriptQuick:"字形",scriptHant:"通行繁体",scriptHans:"简体",quoteStyle:"引号",quoteModern:"“”‘’",quoteClassic:"「」『』",quoteOriginal:"原样",pageBreaks:"显示分叶分割线",pageIndicator:"页指示头(上下键调整位置)",preserveMargins:"书影保留空白",facsimilePager:"书影翻页",facsimilePageInput:"书影叶码(输入数字后按 Enter 或离开输入框跳转)",vertical:"竖排",closeToc:"收起目录",sourceLabel:"出处",licenseOf:"授权 {license}",revisedAt:"最近校订 {date}",reportError:"报告错字",pagerNav:"翻卷",rail:"本卷",bottomBar:"阅读工具",tocShort:"卷目",fontSize:"字号",close:"关闭",loading:"加载中…",noText:"暂无文本",tocFailed:"无法加载目录",tocLoading:"加载目录…",viewEntry:"查看条目",defaultRole:"撰",tocCaption:"目录 · {n} {unit}",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",originalSource:"本站独立整理",charGuess:"残字(推测)",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献",entityDetail:"查看详情 →"}),iu=dt({nJuan:"{n}卷",viewWork:"查看作品",viewWorkOf:"查看作品:{title}",workArrow:"作品 →",arrowWork:"→作品",nWorks:"{n}部作品",unlinked:"未關聯",summary:"提要",comment:"按語",additionalComment:"附按",noMatch:"無匹配結果",sectionType:{类:"類",书:"書",序:"序",结语:"結語",注释:"註釋",考证:"考證",诗:"詩",小计:"小計"},countTiao:"{n} 條",countTiaoOf:"{m} / {n} 條",countPoems:"{n} 首",countPoemsOf:"{m} / {n} 首",countBooks:"{n} 部書",countBooksOf:"{m} / {n} 部書",kaozhenTarget:"考證對象 {target}",baseText:"底本 {note}",textQuality:"文本質量",qualityLabel:{source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暫無正文",placeholder:"占位"},qualityCriteria:{source:"照錄來源原文,本站未另行校對",ocr:"保持大意和結構,錯誤率在百分之十以內",rough:"保證文意基本正確,錯誤率在百分之三以內",fine:"通讀無障礙,錯誤率在百分之一以內",none:"質量未評定",placeholder:"占位條目,正文尚未錄入"},originalSource:"原文來源",viewsGroup:"看法",viewText:"正文",viewEntries:"條目",rowHeadNo:"序",rowHeadTitle:"書名",rowHeadWork:"作品",railCap:"本卷",railUnitPoems:"首",railUnitBooks:"部書",linkedN:"已關聯 {n}",linkedOf:"已關聯 {n} / {total}",railEntriesNav:"本卷條目"},{nJuan:"{n}卷",viewWork:"查看作品",viewWorkOf:"查看作品:{title}",workArrow:"作品 →",arrowWork:"→作品",nWorks:"{n}部作品",unlinked:"未关联",summary:"提要",comment:"按语",additionalComment:"附按",noMatch:"无匹配结果",sectionType:{类:"类",书:"书",序:"序",结语:"结语",注释:"注释",考证:"考证",诗:"诗",小计:"小计"},countTiao:"{n} 条",countTiaoOf:"{m} / {n} 条",countPoems:"{n} 首",countPoemsOf:"{m} / {n} 首",countBooks:"{n} 部书",countBooksOf:"{m} / {n} 部书",kaozhenTarget:"考证对象 {target}",baseText:"底本 {note}",textQuality:"文本质量",qualityLabel:{source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暂无正文",placeholder:"占位"},qualityCriteria:{source:"照录来源原文,本站未另行校对",ocr:"保持大意和结构,错误率在百分之十以内",rough:"保证文意基本正确,错误率在百分之三以内",fine:"通读无障碍,错误率在百分之一以内",none:"质量未评定",placeholder:"占位条目,正文尚未录入"},originalSource:"原文来源",viewsGroup:"看法",viewText:"正文",viewEntries:"条目",rowHeadNo:"序",rowHeadTitle:"书名",rowHeadWork:"作品",railCap:"本卷",railUnitPoems:"首",railUnitBooks:"部书",linkedN:"已关联 {n}",linkedOf:"已关联 {n} / {total}",railEntriesNav:"本卷条目"}),ru=dt({typeShort:{work:"作",book:"版",collection:"叢",entity:"人"},typeLabel:{work:"作品",book:"版本",collection:"叢編",entity:"人物"},typeAll:"全部",typeChipsLabel:"按類型檢索",recentTitle:"最近瀏覽",recentClear:"清除",recentItemLabel:"{type} {title}",recentEmpty:"還沒有瀏覽記錄。打開任一條目後會出現在這裏。",status:{done:"已完成",in_progress:"進行中",todo:"計劃中"},siteStatus:{done:"已對接",in_progress:"進行中"},catalogTitle:"書目著錄進度",catalogNote:"每條著錄對到作品條目",colCatalog:"書目",colRecords:"著錄條目",colMatched:"已對上作品",colProgress:"進度",colStatus:"狀態",relatedTitle:"同類書目與考證",relatedNote:"不在書架上的",allNWorks:"全部 {n} 部",nKinds:"{n} 種",allNKinds:"全部 {n} 種",pavilion:"閣",yearBC:"前{n}",missingLife:"生卒年未錄、未上軸:{names}",viewLineage:"看版本譜系 →",plannedSites:"計劃接入:{names}",loss:{extant:"存",partially_extant:"殘",lost:"佚",unknown:"未詳"},lossNote:{extant:"今有傳本",partially_extant:"部分存世",lost:"僅見著錄",unknown:"尚未判定"},lossCount:"{n} 部 · {note}",stat:{works:"作品",books:"版本",collections:"叢編",entities:"人物",has_image:"有影印",has_text:"有文本",article:"單篇文",poem:"單篇詩"},dataScale:"數據規模",byLoss:"按存佚檢索",license:"古籍元數據以 CC0 公有領域發布,可自由複製、改編、再發布。",repo:"數據倉庫:",repoNote:"(GitHub,CC0)",version:"當前數據版本:",download:"引用方式與數據下載 →",navLabel:"元數據首頁分區",nav:{zhi:"歷代史志",sibu:"四部",cong:"叢編",people:"人物",lineage:"版本譜系",sites:"在線資源",data:"數據與授權"},zhiSub:"正史藝文志、經籍志與後人補志,按所志朝代排列;每部志的著錄逐條對到作品",shelfLegendCount:"脊下數字=著錄條目",shelfLegendClick:"點書脊進作品頁",sibuSub:"全部作品按經史子集分類;與「目錄」頁同一棵分類樹",toCatalog:"進入目錄 →",unclassifiedNote:"多為只見於史志著錄、尚未歸類的書",congSub:"大型叢書、影印彙編、出土文獻與館藏,逐種列到版本",allNKindsMore:"全部 {n} 種 →",peopleSub:"歷代目錄學家,按生卒年排在一條時間軸上",allNPeopleMore:"全部 {n} 人 →",lineageSub:"版本多的作品,看各本的源流與異同",sitesSub:"外部數字圖書館與本站條目的對接",dataSub:"規模、存佚、許可與版本"},{typeShort:{work:"作",book:"版",collection:"丛",entity:"人"},typeLabel:{work:"作品",book:"版本",collection:"丛编",entity:"人物"},typeAll:"全部",typeChipsLabel:"按类型检索",recentTitle:"最近浏览",recentClear:"清除",recentItemLabel:"{type} {title}",recentEmpty:"还没有浏览记录。打开任一条目后会出现在这里。",status:{done:"已完成",in_progress:"进行中",todo:"计划中"},siteStatus:{done:"已对接",in_progress:"进行中"},catalogTitle:"书目著录进度",catalogNote:"每条著录对到作品条目",colCatalog:"书目",colRecords:"著录条目",colMatched:"已对上作品",colProgress:"进度",colStatus:"状态",relatedTitle:"同类书目与考证",relatedNote:"不在书架上的",allNWorks:"全部 {n} 部",nKinds:"{n} 种",allNKinds:"全部 {n} 种",pavilion:"阁",yearBC:"前{n}",missingLife:"生卒年未录、未上轴:{names}",viewLineage:"看版本谱系 →",plannedSites:"计划接入:{names}",loss:{extant:"存",partially_extant:"残",lost:"佚",unknown:"未详"},lossNote:{extant:"今有传本",partially_extant:"部分存世",lost:"仅见著录",unknown:"尚未判定"},lossCount:"{n} 部 · {note}",stat:{works:"作品",books:"版本",collections:"丛编",entities:"人物",has_image:"有影印",has_text:"有文本",article:"单篇文",poem:"单篇诗"},dataScale:"数据规模",byLoss:"按存佚检索",license:"古籍元数据以 CC0 公有领域发布,可自由复制、改编、再发布。",repo:"数据仓库:",repoNote:"(GitHub,CC0)",version:"当前数据版本:",download:"引用方式与数据下载 →",navLabel:"元数据首页分区",nav:{zhi:"历代史志",sibu:"四部",cong:"丛编",people:"人物",lineage:"版本谱系",sites:"在线资源",data:"数据与授权"},zhiSub:"正史艺文志、经籍志与后人补志,按所志朝代排列;每部志的著录逐条对到作品",shelfLegendCount:"脊下数字=著录条目",shelfLegendClick:"点书脊进作品页",sibuSub:"全部作品按经史子集分类;与「目录」页同一棵分类树",toCatalog:"进入目录 →",unclassifiedNote:"多为只见于史志著录、尚未归类的书",congSub:"大型丛书、影印汇编、出土文献与馆藏,逐种列到版本",allNKindsMore:"全部 {n} 种 →",peopleSub:"历代目录学家,按生卒年排在一条时间轴上",allNPeopleMore:"全部 {n} 人 →",lineageSub:"版本多的作品,看各本的源流与异同",sitesSub:"外部数字图书馆与本站条目的对接",dataSub:"规模、存佚、许可与版本"}),Xr=dt({readable:"部可讀",pieces:"篇單篇詩文",startReading:"開始閱讀 →",nCopies:"{n}本",shelfHint:"按所志朝代排列,一脊一部",shelfLegendCount:"脊下「2本」=站內有幾個本子",shelfOther:"其他",shelfRegion:"{label}書架,可橫向滾動",origZhi:"正史原志",laterZhi:"後人補撰、續補",spineBy:"{name} 撰",spineRecords:"著錄 {n} 條",spineOnSite:"站內 {n}",nWorks:"{n} 部",allNWorks:"全部 {n} 部",nCopiesCard:"{n} 個本子",workPageLink:"作品頁:{title}的源流與全部版本 →",sibuUnclassifiedNote:"書目分類還沒補齊,其中多數是單篇詩文,已單列在下方。",subClasses:"{label}子類",allNClasses:"{label}全部 {n} 類 →",unclassified:"未分類",viewUnclassified:"查看未分類 →",periodItem:"{label},{n} 部",periodUnknown:"另有 {n} 部作者無朝代,在「四部」和搜索裏能找到",hoverHint:"窄段懸停看全名",nPieces:"{n} 篇",authorAll:"{name}全部 {n} 篇 →",period:{xianqin:"先秦",qinhan:"秦漢",weijin:"魏晉南北朝",suitang:"隋唐五代",song:"宋",liaojinyuan:"遼金元",ming:"明",qing:"清",modern:"近現代"},navLabel:"閱讀首頁分區",nav:{picks:"推薦閱讀",topics:"專題",famous:"名著與版本",sibu:"四部",period:"按年代",pieces:"單篇詩文"},picksSub:"編輯挑選,定期輪換",topicsSub:"按作品類型歸組;小說見下方「名著與版本」",famousSub:"一部作品一張卡,卡上列出站內能讀的各個本子",sibuSub:"按古籍總目的分類樹,只計站內可讀的作品",periodSub:"按作者朝代歸段,寬度與部數成比例",piecesSub:"單篇的詩、文、賦、表,按作者歸組",piecesMore:"按作者瀏覽全部 →"},{readable:"部可读",pieces:"篇单篇诗文",startReading:"开始阅读 →",nCopies:"{n}本",shelfHint:"按所志朝代排列,一脊一部",shelfLegendCount:"脊下「2本」=站内有几个本子",shelfOther:"其他",shelfRegion:"{label}书架,可横向滚动",origZhi:"正史原志",laterZhi:"后人补撰、续补",spineBy:"{name} 撰",spineRecords:"著录 {n} 条",spineOnSite:"站内 {n}",nWorks:"{n} 部",allNWorks:"全部 {n} 部",nCopiesCard:"{n} 个本子",workPageLink:"作品页:{title}的源流与全部版本 →",sibuUnclassifiedNote:"书目分类还没补齐,其中多数是单篇诗文,已单列在下方。",subClasses:"{label}子类",allNClasses:"{label}全部 {n} 类 →",unclassified:"未分类",viewUnclassified:"查看未分类 →",periodItem:"{label},{n} 部",periodUnknown:"另有 {n} 部作者无朝代,在「四部」和搜索里能找到",hoverHint:"窄段悬停看全名",nPieces:"{n} 篇",authorAll:"{name}全部 {n} 篇 →",period:{xianqin:"先秦",qinhan:"秦汉",weijin:"魏晋南北朝",suitang:"隋唐五代",song:"宋",liaojinyuan:"辽金元",ming:"明",qing:"清",modern:"近现代"},navLabel:"阅读首页分区",nav:{picks:"推荐阅读",topics:"专题",famous:"名著与版本",sibu:"四部",period:"按年代",pieces:"单篇诗文"},picksSub:"编辑挑选,定期轮换",topicsSub:"按作品类型归组;小说见下方「名著与版本」",famousSub:"一部作品一张卡,卡上列出站内能读的各个本子",sibuSub:"按古籍总目的分类树,只计站内可读的作品",periodSub:"按作者朝代归段,宽度与部数成比例",piecesSub:"单篇的诗、文、赋、表,按作者归组",piecesMore:"按作者浏览全部 →"}),ou=dt({sideNav:"分類導航",classification:"分類",drawerLabel:"分類:{path}",all:"全部",allTitle:"全部典籍",stat:"共 {total} 種 · 每頁 {size} 條",statPage:" · 第 {page} / {pages} 頁",viewLabel:"呈現方式",viewCard:"卡片",viewList:"列表",juanN:"{n}卷",pagerLabel:"分頁",prevPage:"上一頁",nextPage:"下一頁",pageN:"第 {n} 頁",emptyWorks:"此類暫無作品",zhulu:"著錄",cunmu:"存目",categoriesN:"{n} 類",divisionStat:"{cats} 類 · {books} 部",categoryJuan:"卷{n}",booksN:"{n} 部",expandAllN:"展開全部 {n} 條"},{sideNav:"分类导航",classification:"分类",drawerLabel:"分类:{path}",all:"全部",allTitle:"全部典籍",stat:"共 {total} 种 · 每页 {size} 条",statPage:" · 第 {page} / {pages} 页",viewLabel:"呈现方式",viewCard:"卡片",viewList:"列表",juanN:"{n}卷",pagerLabel:"分页",prevPage:"上一页",nextPage:"下一页",pageN:"第 {n} 页",emptyWorks:"此类暂无作品",zhulu:"著录",cunmu:"存目",categoriesN:"{n} 类",divisionStat:"{cats} 类 · {books} 部",categoryJuan:"卷{n}",booksN:"{n} 部",expandAllN:"展开全部 {n} 条"}),su=dt({loss:{all:"全部",extant:"存",partially_extant:"殘",lost:"佚"},unclassified:"未分類",statBook:"書",statComma:",",statBookCopies:"本",statArticle:"文章",statArticleUnit:"篇",statPoem:"詩詞",statPoemUnit:"首",statCollection:"叢編",submit:"搜索"},{loss:{all:"全部",extant:"存",partially_extant:"残",lost:"佚"},unclassified:"未分类",statBook:"书",statComma:",",statBookCopies:"本",statArticle:"文章",statArticleUnit:"篇",statPoem:"诗词",statPoemUnit:"首",statCollection:"丛编",submit:"搜索"}),au=dt({title:"反饋",close:"關閉",submitType:{bug:"反饋錯誤",resource:"添加資源",suggestion:"功能建議",contact:"想參與"},placeholder:{bug:"請描述您發現的錯誤,包括頁面位置和具體內容",resource:"請提供完整資源鏈接和簡要版本說明",suggestion:"您希望網站增加或改進什麼?",contact:"想參與整理、校對或合作?簡單介紹一下您自己,並留下聯繫方式(此類留言不公開)"},chooseTypeFirst:"請先選擇反饋類型",contactPlaceholder:"郵箱(選填,僅站方可見,方便我們回覆您)",contactLabel:"聯繫方式(選填)",submitFailedRetry:"提交失敗,請稍後重試",submitFailed:"提交失敗",thanks:"感謝您的反饋!",viewList:"查看反饋列表 →",continueSubmit:"繼續提交",submitting:"提交中...",submit:"提交",submitFeedback:"提交反饋",listType:{bug:"錯誤反饋",resource:"資源建議",suggestion:"功能建議",other:"其他"},status:{pending:"待處理",in_progress:"處理中",resolved:"已處理",wontfix:"不採納",duplicate:"重複"},empty:"暫無反饋",reply:"回覆"},{title:"反馈",close:"关闭",submitType:{bug:"反馈错误",resource:"添加资源",suggestion:"功能建议",contact:"想参与"},placeholder:{bug:"请描述您发现的错误,包括页面位置和具体内容",resource:"请提供完整资源链接和简要版本说明",suggestion:"您希望网站增加或改进什么?",contact:"想参与整理、校对或合作?简单介绍一下您自己,并留下联系方式(此类留言不公开)"},chooseTypeFirst:"请先选择反馈类型",contactPlaceholder:"邮箱(选填,仅站方可见,方便我们回复您)",contactLabel:"联系方式(选填)",submitFailedRetry:"提交失败,请稍后重试",submitFailed:"提交失败",thanks:"感谢您的反馈!",viewList:"查看反馈列表 →",continueSubmit:"继续提交",submitting:"提交中...",submit:"提交",submitFeedback:"提交反馈",listType:{bug:"错误反馈",resource:"资源建议",suggestion:"功能建议",other:"其他"},status:{pending:"待处理",in_progress:"处理中",resolved:"已处理",wontfix:"不采纳",duplicate:"重复"},empty:"暂无反馈",reply:"回复"}),lu=dt({empty:"暫無版本傳承數據",emptyGraph:"暫無版本圖數據",modeList:"列表",modeGraph:"關係圖",collectionLabel:"集合:",collectionAll:"全部",collectionAllDesc:"顯示該作品所有版本(含橋接節點)",graphLoading:"加載圖組件中…",graphMissing:"圖組件未安裝。請安裝 {xyflow} 與 {dagre}。",graphMissingHint:"或使用 {list} 列表視圖。",bridgeTitle:"橋接節點:本身不在核心集,為保持派生鏈完整而顯示",otherGroup:"其他",lost:"已佚",fragment:"殘本",hypothetical:"假想祖本",bridge:"橋接",extant:"現存:{juan}",sources:"來源:",related:"關聯:",confidence:{certain:"確定",consensus:"共識",probable:"推測",disputed:"有爭議"}},{empty:"暂无版本传承数据",emptyGraph:"暂无版本图数据",modeList:"列表",modeGraph:"关系图",collectionLabel:"集合:",collectionAll:"全部",collectionAllDesc:"显示该作品所有版本(含桥接节点)",graphLoading:"加载图组件中…",graphMissing:"图组件未安装。请安装 {xyflow} 与 {dagre}。",graphMissingHint:"或使用 {list} 列表视图。",bridgeTitle:"桥接节点:本身不在核心集,为保持派生链完整而显示",otherGroup:"其他",lost:"已佚",fragment:"残本",hypothetical:"假想祖本",bridge:"桥接",extant:"现存:{juan}",sources:"来源:",related:"关联:",confidence:{certain:"确定",consensus:"共识",probable:"推测",disputed:"有争议"}}),cu={common:Zp,detail:wi,bookPage:Jp,workPage:Qp,collectionPage:eu,entityPage:tu,reader:nu,collated:iu,metaHome:ru,readHome:Xr,catalogPage:ou,searchPage:su,feedback:au,lineage:lu};function du(e){const n={};for(const[i,o]of Object.entries(cu))n[i]=o[e];return n}function gt(e,n){return e.replace(/\{(\w+)\}/g,(i,o)=>String(n[o]??""))}const ys=new Map;function bn(e){let n=ys.get(e);return n||(n={...e==="zh-Hans"?Xp:Kp,...du(e)},ys.set(e,n)),n}function js(e,n){let i=e;for(const o of n.split(".")){if(i==null||typeof i!="object")return;i=i[o]}return typeof i=="string"?i:void 0}function al(e){return(n,i)=>{const o=js(e,n)??js(bn("zh-Hant"),n)??n;return i?gt(o,i):o}}const vs=new Map;function yn(e){let n=vs.get(e);return n||(n=al(bn(e)),vs.set(e,n)),n}const ll="bim-locale";function pu(){try{const e=localStorage.getItem(ll);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function uu(e){try{localStorage.setItem(ll,e)}catch{}}const mu="zh-Hans",hu=({locale:e,onLocaleChange:n,converter:i,children:o})=>{const[s,a]=g.useState(e??mu),l=e??s;g.useEffect(()=>{if(e)return;const h=pu();h&&h!==s&&a(h)},[]);const d=g.useMemo(()=>l==="zh-Hans"?i??sl():null,[l,i]),c=g.useCallback(h=>{a(h),uu(h),n==null||n(h)},[n]),p=g.useMemo(()=>({locale:l,setLocale:c,messages:bn(l),converter:d}),[l,c,d]);return t.jsx(Tt.Provider,{value:p,children:o})};function Ee(){const e=g.useContext(Tt);return(e==null?void 0:e.messages)??bn("zh-Hant")}const gu=2e3;function Pe(){const e=g.useContext(Tt),n=(e==null?void 0:e.locale)??"zh-Hant",i=(e==null?void 0:e.converter)??null,o=g.useRef(new Map),s=g.useRef(n),a=g.useRef(i);(s.current!==n||a.current!==i)&&(o.current.clear(),s.current=n,a.current=i);const l=g.useCallback(d=>{if(!d)return"";if(!i)return d;const c=o.current.get(d);if(c!==void 0)return c;const p=i(d);if(o.current.size>=gu){const h=o.current.keys().next().value;h!==void 0&&o.current.delete(h)}return o.current.set(d,p),p},[i]);return g.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function ne(){const e=g.useContext(Tt),{convert:n,locale:i,isSimplified:o}=Pe(),s=(e==null?void 0:e.messages)??bn("zh-Hant"),a=g.useMemo(()=>e?al(s):yn("zh-Hant"),[e,s]);return g.useMemo(()=>({t:a,convert:n,locale:i,isSimplified:o,messages:s}),[a,n,i,o,s])}const cl=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),fu=new Set([...cl,...Object.keys(Se.VARIANT_CHARS),...Object.keys(Ja.VARIANT_SUPPLEMENT)]),dl=[...ol,"切換為繁體","漢籍リポジトリ"];function xu(e,n=dl){let i=e;for(const a of n)a&&(i=i.split(a).join(" "));const o=[],s=Array.from(i);return s.forEach((a,l)=>{fu.has(a)&&o.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),o}function bu(e,n,i){return e?e==="orig"?null:n==="zh-Hans"?i??sl():e==="hant"?Se.normalizeVariants:i:i}const yu=({mode:e,children:n})=>{const i=g.useContext(Tt),o=g.useMemo(()=>!i||!e?i:{...i,converter:bu(e,i.locale,i.converter)},[i,e]);return t.jsx(Tt.Provider,{value:o,children:n})};function ju(e){if(!e)return"";try{const n=new URL(e).hostname,i={"zh.wikisource.org":"wikisource","www.shidianguji.com":"shidianguji","shidianguji.com":"shidianguji","archive.org":"archive","ctext.org":"ctext","read.nlc.cn":"nlc","www.digital.archives.go.jp":"japan_archives"};if(i[n])return i[n];const o=n.split(".");return o.length>=2?o[o.length-2]:n}catch{return""}}function ks(e){return e==="text+image"?["text","image"]:[e]}function ws(e){const n=Mt(e);return n.length===0?"text":Gp(n)}function vu(){return{id:"",name:"",url:"",types:["text"],details:""}}const jr=({items:e,onChange:n,onDownload:i,downloadStatuses:o,filterType:s})=>{const a=Ee(),[l,d]=g.useState(null),c=[{value:"text",label:a.resourceTypeShort.text},{value:"image",label:a.resourceTypeShort.image},{value:"text+image",label:a.resourceTypeShort.textImage},{value:"physical",label:a.resourceTypeShort.physical}],p=[{value:"catalog",label:a.rootType.catalog},{value:"search",label:a.rootType.search}],h=w=>{if(!s)return!0;const j=Mt(w);return s==="text"?j.includes("text"):s==="image"?j.includes("image")||j.includes("physical"):s==="physical"?j.includes("physical"):j.includes(s)},u=e.map((w,j)=>({item:w,originalIndex:j})).filter(({item:w})=>h(w)),m=()=>{const w=vu();s&&(w.types=ks(s)),n([...e,w]),d(e.length)},f=w=>{n(e.filter((j,k)=>k!==w)),d(null)},x=(w,j,k)=>{const $=[...e];if($[w]={...$[w],[j]:k},j==="url"&&!$[w].id){const C=ju(k);C&&($[w].id=C)}n($)},v=(w,j)=>{const k=[...e],{type:$,...C}=k[w];k[w]={...C,types:ks(j)},n(k)},y=(w,j,k)=>{const C={...e[w].metadata||{}};k?C[j]=k:delete C[j],x(w,"metadata",Object.keys(C).length>0?C:void 0)},S=(w,j)=>{const k=j.trim()?j.split(/[,,、]/).map($=>$.trim()).filter(Boolean):void 0;x(w,"structure",k)},b=(w,j,k)=>{const C=e[w].coverage||{level:1,ranges:""};j==="level"?C.level=parseInt(k)||1:C.ranges=k,x(w,"coverage",C.ranges?C:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[u.map(({item:w,originalIndex:j})=>{var k,$,C;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>d(l===j?null:j),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:l===j?"▼":"▶"}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:ku(ws(w)),color:r("on-color-fg")},children:(()=>{var E,z;const _=Mt(w);return _.length===0?"text":_.length===1?((E=c.find(T=>T.value===_[0]))==null?void 0:E.label)??_[0]:_.includes("text")&&_.includes("image")?((z=c.find(T=>T.value==="text+image"))==null?void 0:z.label)??"text+image":_.join("+")})()}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:w.name||`${a.editor.resourcePlaceholder} ${j+1}`}),w.id&&t.jsx("span",{style:{fontSize:"11px",opacity:.5},children:w.id}),w.url&&t.jsx("a",{href:w.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),i&&w.url&&wu(j,o==null?void 0:o[j],i,a),t.jsx("button",{onClick:_=>{_.stopPropagation(),f(j)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:a.editor.deleteThisResource,children:"✕"})]}),l===j&&t.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:[Dp(w,"image")&&w.url&&Su(w,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Sn,children:[t.jsx("span",{style:_n,children:a.label.type}),t.jsx("select",{value:ws(w),onChange:_=>v(j,_.target.value),style:{...St,flex:1},children:c.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]}),t.jsxs("label",{style:Sn,children:[t.jsx("span",{style:_n,children:a.label.rootType}),t.jsx("select",{value:w.root_type||"catalog",onChange:_=>x(j,"root_type",_.target.value),style:{...St,flex:1},children:p.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:w.id,onChange:_=>x(j,"id",_.target.value),placeholder:a.editor.idAutoExtract,style:{...St,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:w.name,onChange:_=>x(j,"name",_.target.value),placeholder:a.editor.resourceName,style:{...St,flex:1}})]}),t.jsx("input",{type:"text",value:w.url,onChange:_=>x(j,"url",_.target.value),placeholder:a.editor.resourceUrl,style:St}),t.jsx("input",{type:"text",value:((k=w.structure)==null?void 0:k.join("、"))||"",onChange:_=>S(j,_.target.value),placeholder:a.editor.structurePlaceholder,style:St}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Sn,children:[t.jsx("span",{style:_n,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:(($=w.coverage)==null?void 0:$.level)??"",onChange:_=>b(j,"level",_.target.value),placeholder:"1",style:{...St,width:"60px"}})]}),t.jsxs("label",{style:{...Sn,flex:1},children:[t.jsx("span",{style:_n,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:((C=w.coverage)==null?void 0:C.ranges)||"",onChange:_=>b(j,"ranges",_.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...St,flex:1}})]})]}),t.jsx("textarea",{value:w.details||"",onChange:_=>x(j,"details",_.target.value),placeholder:a.editor.detailsPlaceholder,style:{...St,minHeight:"60px",resize:"vertical"}}),t.jsxs("div",{style:{borderTop:`1px solid ${r("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"6px"},children:a.label.metadata}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(a.metadata).map(([_,E])=>{var z;return t.jsxs("label",{style:{...Sn,gap:"4px"},children:[t.jsx("span",{style:{..._n,minWidth:"56px"},children:E}),t.jsx("input",{type:"text",value:((z=w.metadata)==null?void 0:z[_])||"",onChange:T=>y(j,_,T.target.value),placeholder:E,style:{...St,flex:1}})]},_)})})]})]})]})]},j)}),t.jsxs("button",{onClick:m,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:a.action.addResource})]})]})};function ku(e){switch(e){case"text":return r("restype-text");case"image":return r("restype-image");case"text+image":return r("restype-text-image");case"physical":return r("restype-physical")}}function wu(e,n,i,o){const s=(n==null?void 0:n.status)==="downloading",a=(n==null?void 0:n.status)==="completed";return t.jsx("button",{onClick:l=>{l.stopPropagation(),s||i(e,"")},disabled:s,style:{background:"transparent",border:"none",color:r(a?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:a?o.download.completed:s?`${o.download.downloading} ${(n==null?void 0:n.progress)||0}%`:o.download.downloadThis,children:a?"✓":s?"⏳":"⬇"})}function Su(e,n){const i=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(e.url)||e.url.includes("iiif")||e.url.includes("image");return t.jsx("div",{style:{marginBottom:"12px"},children:i?t.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:r("overlay-bg")},children:t.jsx("img",{src:e.url,alt:e.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:o=>{o.target.style.display="none"}})}):t.jsx("div",{style:{padding:"12px",background:r("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:r("desc-fg")},children:n.editor.imageResourceLink})})}const St={width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},Sn={display:"flex",alignItems:"center",gap:"6px"},_n={fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap"},Ss={text:r("restype-text"),image:r("restype-image"),"text+image":r("restype-text-image"),physical:r("restype-physical")};function _u(e){return e.includes("text")&&e.includes("image")?Ss["text+image"]:Ss[e[0]||"physical"]}const Zr=({items:e,groupByType:n=!0,resourceGroups:i,onNavigate:o,renderLink:s})=>{const a=Ee(),{convert:l}=Pe(),d=g.useMemo(()=>Yr(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=g.useMemo(()=>{const y=new Map,S=[];for(const b of d){const w=b.group;w?(y.has(w)||y.set(w,[]),y.get(w).push(b)):S.push(b)}for(const b of y.values())b.sort((w,j)=>{const k=$=>$.group_role==="origin"?0:$.group_role==="mirror"?1:2;return k(w)-k(j)});return{mirrorGroups:y,ungroupedItems:S}},[d]),h={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},u=y=>h[y]?h[y]:y.split("+").map(S=>h[S]||S).join("+");if(!d||d.length===0)return t.jsx("div",{style:{padding:"16px",color:r("desc-fg"),fontSize:"13px",textAlign:"center"},children:a.misc.noResources});if(!n)return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:d.map((y,S)=>t.jsx(tr,{item:y},y.id||S))});const m=(y,S)=>{const b=i==null?void 0:i[y],w=(b==null?void 0:b.label)||y,j=b==null?void 0:b.description;return t.jsxs("div",{style:{padding:"10px 12px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:r("input-bg"),display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(w)}),j&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.5},children:l(j)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:S.map((k,$)=>t.jsx(tr,{item:k,onNavigate:o,renderLink:s},k.id||$))})]},`group-${y}`)},f=new Map;for(const y of p){const S=Gr(Mt(y));f.has(S)||f.set(S,[]),f.get(S).push(y)}const x=["text","image","text+image","physical"],v=[...x.filter(y=>f.has(y)),...[...f.keys()].filter(y=>!x.includes(y)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,S])=>m(y,S)),v.map(y=>{const S=f.get(y),b=_u(y.split("+"));return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:b,whiteSpace:"nowrap",flexShrink:0},children:u(y)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:S.map((w,j)=>t.jsx(tr,{item:w,onNavigate:o,renderLink:s},w.id||j))})]},y)})]})},$u={bw:{label:"",bg:r("colormode-bw-bg"),fg:r("colormode-bw-fg")},color:{label:"",bg:r("colormode-color-bg"),fg:r("colormode-color-fg")}},tr=({item:e})=>{const n=Ee(),{convert:i}=Pe(),[o,s]=g.useState(!1),a=g.useMemo(()=>(e.url?fn(e.url):void 0)||i(e.name),[e.url,e.name,i]),l=g.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||il(x)})),[e.volumes]),d=l&&l.length>0,c=d?new Set(l.filter(x=>x.status!=="missing").map(x=>x.volume)).size:0,p=d?new Set(l.filter(x=>x.status==="missing").map(x=>x.volume)).size:0,h=e.expected_volumes??(d?c+p:0),u=e.color_mode?{...$u[e.color_mode],label:n.colorMode[e.color_mode]}:null,m=e.details&&!d?i(e.details):null,f={display:"inline-flex",alignItems:"center",gap:"5px",padding:"4px 10px",border:`1px solid ${r("widget-border")}`,borderRadius:"5px",background:r("input-bg"),fontSize:"12px",color:r("fg"),lineHeight:1.4,verticalAlign:"middle"};return t.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[t.jsxs("div",{style:f,children:[t.jsx("span",{style:{fontWeight:500},children:a}),u&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:u.bg,color:u.fg},children:u.label}),m&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:m}),d&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[c,"/",h,n.unit.volume,p>0&&t.jsx("span",{style:{color:r("missing-fg"),marginLeft:"3px"},children:gt(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=qr(e.metadata);return x?Kr(e.url,x):e.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:r("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),d&&t.jsx("button",{onClick:()=>s(!o),style:{padding:"0 6px",fontSize:"11px",border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",lineHeight:1.4},children:o?"▲":"▼"})]}),d&&o&&t.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${r("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:l.map(x=>{const v=x.status==="missing";return x.url&&!v?t.jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",borderRadius:"3px",border:`1px solid ${r("widget-border")}`,color:r("link-fg"),textDecoration:"none"},children:x.volume},x.volume):t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:r(v?"missing-fg":"desc-fg"),textDecoration:v?"line-through":"none",opacity:v?.6:1},children:x.volume},x.volume)})})]})},pl=({indexSource:e,syncConfig:n,variant:i="index-browser",onSwitchMode:o,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=Ee(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,h=(n==null?void 0:n.repoPath)||"",u=h?h.split(/[/\\]/).pop()||h:"",m={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:r("primary-soft"),color:r("primary")},f={onMouseOver:v=>v.currentTarget.style.opacity="0.8",onMouseOut:v=>v.currentTarget.style.opacity="1"},x=t.jsxs("div",{onClick:s,title:p?d.mode.switchToOfficial:d.mode.switchToDraft,style:{...m,background:r(p?"warning":"success"),color:r("on-color-fg")},...f,children:[t.jsx("span",{children:p?"📝":"📚"}),t.jsx("span",{children:p?"draft":"official"})]});return i==="index-browser"?c?t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[x,t.jsxs("div",{onClick:o,title:d.mode.switchToSync,style:m,...f,children:[t.jsx("span",{children:"📁"}),t.jsx("span",{children:d.mode.localMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsxs("div",{onClick:l,title:h||d.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px"},...f,children:[t.jsx("span",{children:"📂"}),u&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:u})]})]}):t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.jsxs("div",{onClick:o,title:d.mode.switchToLocal,style:m,...f,children:[t.jsx("span",{children:"🌐"}),t.jsx("span",{children:d.mode.syncMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsx("div",{onClick:a,title:u||d.mode.configurePath,style:{...m,background:"transparent",padding:"6px",fontSize:"12px"},...f,children:t.jsx("span",{children:"⚙️"})})]})]}):t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[t.jsxs("div",{onClick:o,title:c?d.mode.switchToGithub:d.mode.switchToLocal,style:m,...f,children:[t.jsx("span",{children:c?"📁":"🌐"}),t.jsx("span",{children:c?d.mode.localMode:d.mode.githubSync}),t.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&t.jsxs("div",{onClick:l,title:h||d.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px",minWidth:h?"100px":"auto",justifyContent:"space-between"},...f,children:[t.jsx("span",{children:"📂"}),u&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:u})]}),!c&&u&&t.jsxs("div",{style:{...m,background:r("mode-active-bg"),color:r("on-color-fg"),cursor:"default"},title:h,children:[t.jsx("span",{children:"📂"}),t.jsx("span",{style:{fontSize:"11px"},children:u})]})]})},Si="bim-search-history",_s=10,$s=8;function Rn(){try{const e=localStorage.getItem(Si);return e?JSON.parse(e):[]}catch{return[]}}function ul(e){try{const n=Rn().filter(i=>i!==e);n.unshift(e),n.length>_s&&(n.length=_s),localStorage.setItem(Si,JSON.stringify(n))}catch{}}function Cu(e){try{const n=Rn().filter(i=>i!==e);localStorage.setItem(Si,JSON.stringify(n))}catch{}}function Tu(){try{localStorage.removeItem(Si)}catch{}}const ml=({transport:e,value:n,onChange:i,onSearch:o,onEntrySelect:s,placeholder:a})=>{const l=Ee(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,h]=g.useState(!1),[u,m]=g.useState([]),[f,x]=g.useState(-1),[v,y]=g.useState(Rn),S=g.useRef(null),b=g.useRef(null),w=g.useRef(null),j=g.useRef(!1);g.useEffect(()=>{x(-1);const T=n.trim();if(!T){m(v.map(N=>({type:"history",text:N})));return}if(!e.searchAll){m([]);return}let B=!1;const W=setTimeout(()=>{e.searchAll(T,$s).then(N=>{if(B)return;const A=[...N.works,...N.books,...N.collections,...N.entities??[]];m(A.slice(0,$s).map(F=>({type:"entry",text:F.title||F.id,entry:F})))}).catch(()=>{B||m([])})},80);return()=>{B=!0,clearTimeout(W)}},[n,v,e]),g.useEffect(()=>{const T=B=>{w.current&&!w.current.contains(B.target)&&h(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]),g.useEffect(()=>{const T=B=>{var W,N;if(B.key==="/"&&document.activeElement!==S.current){const A=(W=document.activeElement)==null?void 0:W.tagName;if(A==="INPUT"||A==="TEXTAREA"||A==="SELECT")return;B.preventDefault(),(N=S.current)==null||N.focus()}};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[]);const k=g.useCallback(T=>{T.trim()&&(ul(T.trim()),y(Rn())),o(T),h(!1)},[o]),$=g.useCallback(T=>{T.type==="history"?(i(T.text),k(T.text)):T.entry&&(s?(s(T.entry),h(!1)):(i(T.text),k(T.text)))},[i,k,s]),C=g.useCallback(T=>{if(!p||u.length===0){T.key==="Enter"&&k(n);return}switch(T.key){case"ArrowDown":T.preventDefault(),x(B=>(B+1)%u.length);break;case"ArrowUp":T.preventDefault(),x(B=>(B-1+u.length)%u.length);break;case"Enter":T.preventDefault(),f>=0&&f<u.length?$(u[f]):k(n);break;case"Escape":T.preventDefault(),h(!1);break}},[p,u,f,n,k,$]),_=g.useCallback((T,B)=>{B.stopPropagation(),Cu(T),y(Rn()),m(W=>W.filter(N=>!(N.type==="history"&&N.text===T)))},[]),E=g.useCallback(T=>{T.stopPropagation(),Tu(),y([]),m([])},[]);g.useEffect(()=>{if(f>=0&&b.current){const T=b.current.children;T[f]&&T[f].scrollIntoView({block:"nearest"})}},[f]);const z=!n.trim()&&v.length>0;return t.jsxs("div",{ref:w,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:S,type:"text",placeholder:d,value:n,onChange:T=>{i(T.target.value),h(!0)},onCompositionStart:()=>{j.current=!0},onCompositionEnd:()=>{j.current=!1},onFocus:()=>{h(!0)},onKeyDown:C,style:{width:"100%",padding:"8px 12px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),fontSize:"14px",boxSizing:"border-box"}}),p&&u.length>0&&t.jsxs("div",{ref:b,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:r("input-bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"6px",boxShadow:r("shadow-dropdown"),zIndex:100,maxHeight:"320px",overflow:"auto"},children:[z&&t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 12px",fontSize:"11px",color:r("desc-fg"),borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("span",{children:l.search.history}),t.jsx("button",{onClick:E,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),u.map((T,B)=>t.jsxs("div",{onClick:()=>$(T),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:r("fg"),background:B===f?r("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:T.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T.text}),T.entry&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:[c[T.entry.type],T.entry.edition&&` · ${T.entry.edition}`,T.entry.author&&` · ${T.entry.author}`]}),T.type==="history"&&t.jsx("button",{onClick:W=>_(T.text,W),style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:l.action.remove,children:"×"})]},`${T.type}-${T.text}-${B}`))]})]})},jn=({type:e,size:n=9})=>t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:r(`type-${e}`),verticalAlign:"middle"}}),_i={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},hl=new Set(["work","book","entity"]);function zu(e){return xl(e)||!!e.sort}function Nu(e,n){return n.sort&&hl.has(e)?n.sort:void 0}const $i=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],Ci=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],gl=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],fl={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function Ti(e){return e.dynasty.length+e.classification.length+(e.hasImage?1:0)+(e.hasText?1:0)+(e.hasCollated?1:0)+(e.loss?1:0)}function xl(e){return Ti(e)>0}function Iu(e){const n=[];return e.dynasty.length&&n.push("dynasty"),e.classification.length&&n.push("classification"),e.hasImage&&n.push("hasImage"),e.hasText&&n.push("hasText"),e.hasCollated&&n.push("hasCollated"),e.loss&&n.push("loss"),n}function bl(e,n){const i=fl[e];return Iu(n).every(o=>i.has(o))}const $n=e=>JSON.stringify(e);function Ru(e,n){if(!bl(n,e))return null;const i=[];if(e.dynasty.length){const o=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=$i.find(l=>l.key===s))==null?void 0:a.values)??[]})));o.length===1?i.push(`dynasty = ${$n(o[0])}`):o.length>1&&i.push(`dynasty IN [${o.map($n).join(", ")}]`)}return e.classification.length&&i.push(e.classification.length===1?`classification = ${$n(e.classification[0])}`:`classification IN [${e.classification.map($n).join(", ")}]`),e.hasImage&&i.push("has_image = true"),e.hasText&&i.push("has_text = true"),e.hasCollated&&i.push("has_collated = true"),e.loss&&i.push(`loss_status = ${$n(e.loss)}`),i.join(" AND ")}const at={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},yl="_";function gi(e,n=new URLSearchParams){for(const i of Object.values(at))n.delete(i);return e.dynasty.length&&n.set(at.dynasty,e.dynasty.join(",")),e.classification.length&&n.set(at.classification,e.classification.map(i=>i||yl).join(",")),e.hasImage&&n.set(at.hasImage,"1"),e.hasText&&n.set(at.hasText,"1"),e.hasCollated&&n.set(at.hasCollated,"1"),e.loss&&n.set(at.loss,e.loss),e.sort&&n.set(at.sort,e.sort),n}function Eu(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),i=new Set($i.map(a=>a.key)),o=new Set(Ci.map(a=>a.value)),s=e.get(at.loss);return{dynasty:Array.from(new Set(n(at.dynasty).filter(a=>i.has(a)))),classification:Array.from(new Set(n(at.classification).map(a=>a===yl?"":a).filter(a=>o.has(a)))),hasImage:e.get(at.hasImage)==="1",hasText:e.get(at.hasText)==="1"||e.get(at.hasCollated)==="1",hasCollated:!1,loss:s==="extant"||s==="partially_extant"||s==="lost"?s:"",sort:["era:asc","era:desc","title:asc","title:desc"].find(a=>a===e.get(at.sort))??""}}function Lu(e,n){return JSON.stringify([e.dynasty.slice().sort(),e.classification.slice().sort(),e.hasImage,e.hasText,e.hasCollated,e.loss,e.sort])===JSON.stringify([n.dynasty.slice().sort(),n.classification.slice().sort(),n.hasImage,n.hasText,n.hasCollated,n.loss,n.sort])}function Cs(e,n){return e.includes(n)?e.filter(i=>i!==n):[...e,n]}const Au=({filters:e,onChange:n})=>{const i=Ee(),o=i.searchV4,{convert:s}=Pe(),[a,l]=g.useState(!1),d=g.useId(),c=Ti(e),p=h=>n({...e,...h});return t.jsxs("aside",{className:"bim-sr-aside","aria-label":s(o.filterTitle),children:[t.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":a,"aria-controls":d,onClick:()=>l(h=>!h),children:[t.jsxs("span",{children:[s(o.filterButton),c>0&&t.jsx("span",{className:"bim-sr-fn",children:s(gt(o.filterSelected,{n:c}))})]}),t.jsxs("span",{className:"bim-sr-fa","aria-hidden":"true",children:[s(a?o.collapse:o.expand)," ",a?"▴":"▾"]})]}),t.jsxs("div",{className:"bim-sr-filters",id:d,"data-open":a?"true":"false",...a?{}:{"data-collapsed":"true"},children:[t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.dynasty)}),t.jsx("div",{className:"bim-sr-chips",children:$i.map(h=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(h.key),onClick:()=>p({dynasty:Cs(e.dynasty,h.key)}),children:s(h.key)},h.key))})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.classification)}),Ci.map(h=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(h.value),onChange:()=>p({classification:Cs(e.classification,h.value)})}),h.value?s(h.label):i.searchPage.unclassified]},h.value||"_"))]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.resources)}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasImage,onChange:h=>p({hasImage:h.target.checked})}),s(o.hasImage)]}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasText,onChange:h=>p({hasText:h.target.checked})}),s(o.hasText)]})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{id:`${d}-loss`,children:s(o.extant)}),t.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${d}-loss`,children:gl.map(h=>t.jsx("button",{type:"button","aria-pressed":e.loss===h.value,onClick:()=>p({loss:h.value}),children:i.searchPage.loss[h.value||"all"]},h.value||"all"))})]}),c>0&&t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({..._i,sort:e.sort}),children:s(o.clearAllFilters)})]})]})};function jl({text:e,query:n}){const i=(n??"").trim();if(!i||!e)return t.jsx(t.Fragment,{children:e});const o=e.toLowerCase(),s=i.toLowerCase(),a=[];let l=0,d=0;for(;l<e.length;){const c=o.indexOf(s,l);if(c<0){a.push(e.slice(l));break}c>l&&a.push(e.slice(l,c)),a.push(t.jsx("mark",{className:"bim-sr-hl",children:e.slice(c,c+s.length)},d++)),l=c+s.length}return t.jsx(t.Fragment,{children:a})}const Ts=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ee(),a=s.searchV4,{convert:l}=Pe(),d=tt();return t.jsx("div",{className:"bim-sr-tablewrap",children:t.jsxs("table",{className:"bim-sr-table",children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:"34%"}}),t.jsx("col",{style:{width:"8%"}}),t.jsx("col",{style:{width:"19%"}}),t.jsx("col",{style:{width:"13%"}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"14%"}})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:l(a.colTitle)}),t.jsx("th",{scope:"col",children:l(a.colType)}),t.jsx("th",{scope:"col",children:l(a.colAuthor)}),t.jsx("th",{scope:"col",children:l(a.colEra)}),t.jsx("th",{scope:"col",children:l(a.colClass)}),t.jsx("th",{scope:"col",style:{textAlign:"right"},children:l(a.colResource)})]})}),t.jsx("tbody",{children:e.map(c=>{const p=l(c.title||c.primary_name||c.id),h=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",u=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${l(c.author)}${c.role&&c.role!=="author"?` ${l(c.role)}`:""}`:"",m=c.type==="book"?c.era??c.dynasty:c.dynasty,f=m?l(m):"",x=c.classification?l(c.classification):"",v=[];c.has_image&&v.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&v.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&v.push({label:a.tagLost,cls:"bim-sr-tag--lost"});const y=[u,f,x].filter(Boolean).join(" · ");return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-sr-c-title",children:[t.jsxs("div",{className:"bim-sr-tl",children:[t.jsx("a",{href:d(c.id),onClick:S=>i(c,S),children:t.jsx(jl,{text:p,query:n?l(n):void 0})}),h&&t.jsx("span",{className:"bim-sr-measure",children:h})]}),y&&t.jsx("span",{className:"bim-sr-sub",children:y})]}),t.jsxs("td",{className:"bim-sr-c-type",children:[t.jsx(jn,{type:c.type,size:6})," ",o(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:u||"—"}),t.jsx("td",{className:"bim-sr-c-era",children:f||"—"}),t.jsx("td",{className:"bim-sr-c-cls",children:x||"—"}),t.jsx("td",{className:"bim-sr-c-res",children:v.map(S=>t.jsx("span",{className:`bim-sr-tag ${S.cls}`,children:l(S.label)},S.label))})]},c.id)})})]})})},Mu=`
|
|
2
2
|
.bim-sc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 10px; }
|
|
3
3
|
.bim-sc { display: flex; flex-direction: column; min-width: 0; padding: 14px 16px 12px; border: 1px solid ${r("rule")}; background: ${r("card-bg")}; color: inherit; text-decoration: none; }
|
|
4
4
|
.bim-sc:hover { border-color: ${r("rule-dashed")}; box-shadow: ${r("fr-shadow")}; }
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
.bim-sc-fl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: ${r("aux-fg")}; }
|
|
13
13
|
.bim-sc-tags { display: flex; gap: 4px; flex: none; }
|
|
14
14
|
:root[data-layout="boxed"] .bim-sc { box-shadow: none; }
|
|
15
|
-
`,
|
|
15
|
+
`,zs=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ee(),a=s.searchV4,{convert:l}=Pe(),d=tt();return t.jsxs("div",{className:"bim-sc-grid",children:[t.jsx("style",{children:Mu}),e.map(c=>{const p=l(c.title||c.primary_name||c.id),h=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",m=[c.type==="entity"?c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:"":`${c.dynasty?`〔${l(c.dynasty)}〕`:""}${c.author?l(c.author):""}`,c.type==="book"&&c.edition?l(c.edition):"",h].filter(Boolean).join(" · "),f=[o(c.type),c.classification?l(c.classification):""].filter(Boolean).join(" · "),x=[];return c.has_image&&x.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&x.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&x.push({label:a.tagLost,cls:"bim-sr-tag--lost"}),t.jsxs("a",{className:"bim-sc",href:d(c.id),onClick:v=>i(c,v),children:[t.jsx("span",{className:"bim-sc-t",children:t.jsx(jl,{text:p,query:n?l(n):void 0})}),m&&t.jsx("span",{className:"bim-sc-m",children:m}),c.descriptionSnippet&&t.jsx("p",{className:"bim-sc-s",children:Vr(c.descriptionSnippet).map((v,y)=>v.marked?t.jsx("mark",{children:l(v.text)},y):t.jsx(g.Fragment,{children:l(v.text)},y))}),t.jsx("span",{className:"bim-sc-sp"}),t.jsxs("div",{className:"bim-sc-f",children:[t.jsx("span",{className:"bim-sc-fl",children:f}),t.jsx("span",{className:"bim-sc-tags",children:x.map(v=>t.jsx("span",{className:`bim-sr-tag ${v.cls}`,children:l(v.label)},v.label))})]})]},c.id)})]})};function Pu(e,n){const i=new Set([1,n,e-1,e,e+1].filter(a=>a>=1&&a<=n)),o=Array.from(i).sort((a,l)=>a-l),s=[];return o.forEach((a,l)=>{l>0&&a-o[l-1]>1&&s.push("gap"),s.push(a)}),s}function Bu(e,n,i){const o=Math.max(1,Math.ceil(n/i));return Math.min(Math.max(1,e),o)}const Wu=({page:e,pageSize:n,total:i,totalLabel:o,onPage:s})=>{const a=Ee().searchV4,{convert:l}=Pe(),d=Math.max(1,Math.ceil(i/n));return i<=0?null:t.jsxs("nav",{className:"bim-sr-pager","aria-label":l(a.pagerLabel),children:[t.jsx("span",{className:"bim-sr-info",children:l(gt(a.pageInfo,{total:o??i.toLocaleString(),size:n,page:e,pages:d}))}),d>1&&t.jsxs("ul",{children:[t.jsx("li",{children:t.jsx("button",{type:"button",disabled:e<=1,onClick:()=>s(e-1),children:l(a.prevPage)})}),Pu(e,d).map((c,p)=>c==="gap"?t.jsx("li",{className:"bim-sr-gap","aria-hidden":"true",children:"…"},`g${p}`):t.jsx("li",{children:t.jsx("button",{type:"button","aria-current":c===e?"page":void 0,"aria-label":`${c}`,onClick:()=>s(c),children:c})},c)),t.jsx("li",{children:t.jsx("button",{type:"button",disabled:e>=d,onClick:()=>s(e+1),children:l(a.nextPage)})})]})]})},vl="(max-width: 719px)",Ou=`${vl}, (pointer: coarse)`,Fu=`
|
|
16
16
|
.bim-sr-layout { display: grid; grid-template-columns: 208px minmax(0, 1fr); column-gap: 40px; align-items: start; padding: 0 20px; }
|
|
17
17
|
.bim-sr-layout[data-nofilters] { grid-template-columns: minmax(0, 1fr); }
|
|
18
18
|
.bim-sr-aside { position: sticky; top: calc(${r("reader-top")} + 16px); padding-top: 2px; }
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
.bim-sr-pager .bim-sr-gap { color: ${r("aux-fg")}; padding: 0 2px; }
|
|
82
82
|
.bim-sr-empty { padding: 60px 0; text-align: center; font-size: 14px; color: ${r("meta-fg")}; }
|
|
83
83
|
|
|
84
|
-
@media ${
|
|
84
|
+
@media ${vl} {
|
|
85
85
|
.bim-sr-layout { grid-template-columns: minmax(0, 1fr); row-gap: 16px; padding: 0 16px; }
|
|
86
86
|
.bim-sr-aside { position: static; }
|
|
87
87
|
.bim-sr-fbtn {
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
.bim-sr-table td.bim-sr-c-res { text-align: left; padding-bottom: 2px; }
|
|
103
103
|
.bim-sr-table td.bim-sr-c-res:empty { display: none; }
|
|
104
104
|
}
|
|
105
|
-
@media ${
|
|
105
|
+
@media ${Ou} {
|
|
106
106
|
.bim-sr-chip { min-height: 36px; }
|
|
107
107
|
.bim-sr-opt { min-height: 44px; }
|
|
108
108
|
.bim-sr-seg button { min-height: 44px; }
|
|
@@ -117,10 +117,10 @@
|
|
|
117
117
|
:root[data-layout="boxed"] .bim-sr-table th { background: ${r("fr-bg")}; }
|
|
118
118
|
/* 墨:主色与正文对比不到 3:1,标题链接另加下划线 */
|
|
119
119
|
:root[data-theme="ink"] .bim-sr-table td.bim-sr-c-title a { text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); text-underline-offset: 3px; }
|
|
120
|
-
`,Jr="bim-search-view",nr=50,zs=5,En=1e3;function ci(e){return e>=En?`${En.toLocaleString()}+`:e.toLocaleString()}const Fu={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function Hu(e){return e&&Fu[e.toLowerCase()]||"all"}function Du(e){return e==="all"?null:e}const Ns=["work","collection","book","entity"],Uu={work:"works",collection:"collections",book:"books",entity:"entities"},Vu={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function Gu(){try{return window.localStorage.getItem(Jr)==="card"?"card":"table"}catch{return"table"}}function Yu(e){try{window.localStorage.setItem(Jr,e)}catch{}}const an=(e,n)=>(e==null?void 0:e[Vu[n]])??0,ir=(e,n)=>(e==null?void 0:e[Uu[n]])??[],vl=({transport:e,query:n,filters:i,onFiltersChange:o,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const h=Ee(),u=h.searchV4,{convert:m}=Pe(),f=!!e.supportsSearchFilters,x=g.useMemo(()=>f?i:_i,[f,i]),[v,y]=g.useState("table");g.useEffect(()=>{y(Gu())},[]);const S=H=>{y(H),Yu(H)},[b,w]=g.useState(l??"all"),j=g.useRef(b);j.current=b,g.useEffect(()=>{l!==void 0&&l!==j.current&&(w(l),$(1))},[l]);const[k,$]=g.useState(c&&c>0?c:1),C=g.useRef(k);C.current=k,g.useEffect(()=>{c!==void 0&&c>0&&c!==C.current&&$(c)},[c]);const _=g.useRef(null),E=g.useCallback(H=>{var xe;$(H),p==null||p(H);const G=_.current;G&&G.getBoundingClientRect().top<0&&((xe=G.scrollIntoView)==null||xe.call(G,{block:"start",behavior:"instant"}))},[p]),[z,T]=g.useState(null),[B,W]=g.useState(null),[N,A]=g.useState(!1),[F,Y]=g.useState(""),ee=gi(x).toString(),se=Ti(x)>0,D=gi({...x,sort:""}).toString(),V=g.useRef({query:n,filterOnlyKey:D,sort:x.sort});g.useEffect(()=>{const H=V.current;H.query!==n||H.filterOnlyKey!==D?(w("all"),$(1)):H.sort!==x.sort&&$(1),V.current={query:n,filterOnlyKey:D,sort:x.sort}},[n,D,x.sort]),g.useEffect(()=>{let H=!1;return A(!0),Y(""),(async()=>{try{let G;if(e.searchAll)G=await e.searchAll(n,zs,x);else{const xe=["work","book","collection","entity"],K=await Promise.all(xe.map(L=>e.search(n,L,{page:1,pageSize:zs,filters:x})));G={works:K[0].entries,books:K[1].entries,collections:K[2].entries,entities:K[3].entries,totalWorks:K[0].total,totalBooks:K[1].total,totalCollections:K[2].total,totalEntities:K[3].total}}H||T(G)}catch(G){H||(Y(G instanceof Error?G.message:String(G)),T(null))}finally{H||A(!1)}})(),()=>{H=!0}},[e,n,ee]);const he=b;g.useEffect(()=>{if(b==="all"){W(null);return}let H=!1;return A(!0),(async()=>{try{const G=await e.search(n,b,{page:k,pageSize:nr,filters:x});H||W({key:he,entries:G.entries,total:G.total})}catch(G){H||(Y(G instanceof Error?G.message:String(G)),W(null))}finally{H||A(!1)}})(),()=>{H=!0}},[e,n,ee,b,k]);const Z=B&&B.key===he?B:null;g.useEffect(()=>{if(b==="all"||!Z||N)return;const H=Math.min(Z.total,En),G=Pu(k,H,nr);Z.entries.length===0&&H>0&&G!==k&&($(G),p==null||p(G))},[b,Z,N,k]);const M=g.useMemo(()=>Ns.filter(H=>an(z,H)>0),[z]),_e=M.reduce((H,G)=>H+an(z,G),0),ce=M.some(H=>an(z,H)>=En)?`${_e.toLocaleString()}+`:_e.toLocaleString(),ge=!N&&!F&&z!==null&&_e===0,le=g.useCallback(H=>{w(H),$(1),d==null||d(H)},[d]),Be=g.useMemo(()=>{const H=[];return x.dynasty.forEach(G=>H.push({name:G,remove:()=>o({...x,dynasty:x.dynasty.filter(xe=>xe!==G)})})),x.classification.forEach(G=>{var xe;return H.push({name:G?((xe=Ci.find(K=>K.value===G))==null?void 0:xe.label)??G:h.searchPage.unclassified,remove:()=>o({...x,classification:x.classification.filter(K=>K!==G)})})}),x.hasImage&&H.push({name:u.hasImage,remove:()=>o({...x,hasImage:!1})}),x.hasText&&H.push({name:u.hasText,remove:()=>o({...x,hasText:!1})}),x.hasCollated&&H.push({name:u.hasCollated,remove:()=>o({...x,hasCollated:!1})}),x.loss&&H.push({name:`${u.extant}:${h.searchPage.loss[x.loss]}`,remove:()=>o({...x,loss:""})}),H},[x,o,u,h]),ze={query:n,onEntryLinkClick:s,typeName:a},Fe=H=>v==="table"?t.jsx(Cs,{entries:H,...ze}):t.jsx(Ts,{entries:H,...ze}),te=Ns.flatMap(H=>ir(z,H));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":f?void 0:"true",children:[t.jsx("style",{children:Ou}),f&&t.jsx(Lu,{filters:x,onChange:o}),t.jsxs("div",{className:"bim-sr-main","aria-busy":N,ref:_,children:[M.length>0&&t.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":h.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${r("rule")}`},children:[t.jsxs(Is,{on:b==="all",onClick:()=>le("all"),children:[h.search.allTab," ",t.jsx("small",{children:ce})]}),M.map(H=>t.jsxs(Is,{on:b===H,onClick:()=>le(H),children:[a(H)," ",t.jsx("small",{children:ci(an(z,H))})]},H))]}),t.jsxs("div",{className:"bim-sr-tools",children:[f&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":m(u.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>o({...x,sort:""}),children:m(u.sortRelevance)}),["era","title"].map(H=>{const G=x.sort.startsWith(`${H}:`)?x.sort.endsWith("desc")?"desc":"asc":null,xe=H==="era"?u.sortEra:u.sortTitle,K=H==="era"?G==="desc"?u.sortEraDesc:u.sortEraAsc:G==="desc"?u.sortTitleDesc:u.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":G!==null,title:m(K),onClick:()=>o({...x,sort:`${H}:${G==="asc"?"desc":"asc"}`}),children:[m(xe),G?t.jsxs("span",{"aria-hidden":"true",children:[" ",G==="asc"?"↑":"↓"]}):null]},H)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":m(u.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":v==="table",onClick:()=>S("table"),children:m(u.viewTable)}),t.jsx("button",{type:"button","aria-pressed":v==="card",onClick:()=>S("card"),children:m(u.viewCard)})]})]}),se&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:m(gt(u.filteredCount,{n:ce}))}),Be.map(H=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":m(gt(u.removeFilter,{name:H.name})),onClick:H.remove,children:[m(H.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},H.name))]}),F&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:F}),ge&&t.jsx("div",{className:"bim-sr-empty",children:m(se?u.emptyFiltered:gt(h.search.noResultsFor,{query:n}))}),!F&&!ge&&b==="all"&&z&&(v==="table"?t.jsxs(t.Fragment,{children:[t.jsx(Cs,{entries:te,...ze}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:m(u.limitedNote)})]}):t.jsx(t.Fragment,{children:M.map(H=>t.jsxs("section",{style:{marginTop:22},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,marginBottom:10},children:[t.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,letterSpacing:".1em",display:"flex",alignItems:"center",gap:8},children:[t.jsx(jn,{type:H,size:8}),a(H),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:r("meta-fg")},children:[ci(an(z,H))," ",h.unit.items]})]}),an(z,H)>ir(z,H).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>le(H),children:h.action.viewAll})]}),t.jsx(Ts,{entries:ir(z,H),...ze})]},H))})),!F&&b!=="all"&&!Z&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:h.search.loading}),!F&&b!=="all"&&Z&&Z.entries.length>0&&t.jsxs(t.Fragment,{children:[Fe(Z.entries),t.jsx(Bu,{page:k,pageSize:nr,total:Math.min(Z.total,En),totalLabel:ci(Z.total),onPage:E})]}),!F&&b!=="all"&&Z&&Z.entries.length===0&&!N&&t.jsxs("div",{className:"bim-sr-empty",children:[m(se?u.emptyFiltered:gt(h.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>le("all"),children:h.search.allTab})})]})]})]})};function Is({on:e,onClick:n,children:i}){return t.jsx("button",{type:"button","aria-pressed":e,onClick:n,style:{border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:14.5,minHeight:44,padding:"8px 12px",letterSpacing:".06em",color:r(e?"ink":"meta-fg"),fontWeight:e?700:400,boxShadow:e?`inset 0 -2px 0 ${r("accent")}`:"none"},children:i})}const un="bim-recent-ids",Rs="bim-recent-entries",Es=50;function Ut(){try{const e=localStorage.getItem(un);if(e)return JSON.parse(e);const n=localStorage.getItem(Rs);if(n){const i=JSON.parse(n).map(o=>o.id);return localStorage.setItem(un,JSON.stringify(i)),localStorage.removeItem(Rs),i}return[]}catch{return[]}}function vr(e){try{const n=Ut().filter(i=>i!==e);n.unshift(e),n.length>Es&&(n.length=Es),localStorage.setItem(un,JSON.stringify(n))}catch{}}function kl(e){try{const n=Ut().filter(i=>i!==e);localStorage.setItem(un,JSON.stringify(n))}catch{}}function Qr(){try{localStorage.removeItem(un)}catch{}}async function eo(e,n){var i,o,s;try{if(e.getEntry){const l=await e.getEntry(n);if(l)return l}const a=await e.getItem(n);if(a){const l=a.authors;return{id:n,title:a.title||n,type:a.type||"work",author:(i=l==null?void 0:l[0])==null?void 0:i.name,dynasty:(o=l==null?void 0:l[0])==null?void 0:o.dynasty,role:(s=l==null?void 0:l[0])==null?void 0:s.role,edition:a.edition||void 0}}}catch{}return{id:n,title:n,type:"work",notFound:!0}}const rr=5,qu=50,Ku=200,Ls={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},kr=({transport:e,indexSource:n="local",syncConfig:i,onEntryClick:o,onNewEntry:s,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c,hideModeIndicator:p,resultVariant:h="compact",renderEntry:u,initialQuery:m,onQueryChange:f,headerRight:x,reserveViewportHeight:v=!1,filtersEnabled:y=!1,filters:S=_i,onFiltersChange:b,resultTab:w,onResultTabChange:j,resultPage:k,onResultPageChange:$})=>{const C=Ee(),_=[{type:"work",name:C.indexType.work,key:"works"},{type:"book",name:C.indexType.book,key:"books"},{type:"collection",name:C.indexType.collection,key:"collections"},{type:"entity",name:C.indexType.entity,key:"entities"}],E=["work","collection","book","entity"],[z,T]=g.useState(m??""),[B,W]=g.useState(null),[N,A]=g.useState(m??""),F=gi(S).toString(),[Y,ee]=g.useState(S);g.useEffect(()=>{ee(S)},[F]);const se=I=>{ee(I),b==null||b(I)},[D,V]=g.useState(null),[he,Z]=g.useState("all"),[M,_e]=g.useState(!1),[ce,ge]=g.useState(null),[le,Be]=g.useState(""),[ze,Fe]=g.useState(!(m!=null&&m.trim())),[te,H]=g.useState(Ut),[G,xe]=g.useState([]),[K,L]=g.useState(!1),[q,ae]=g.useState(!1),[be,X]=g.useState(null),[re,Ce]=g.useState(null),We=g.useRef(void 0),O=g.useRef(!1),ie=g.useCallback(async(I,U)=>{if(!I.trim()){Fe(!0),W(null),V(null);return}if(Fe(!1),y){A(I);return}_e(!0),Be("");try{if(e.searchAll){const pe=await e.searchAll(I,U??rr);W(pe)}else{const pe=["work","book","collection","entity"],$e=await Promise.all(pe.map(ye=>e.search(I,ye,{page:1,pageSize:U??rr})));W({works:$e[0].entries,books:$e[1].entries,collections:$e[2].entries,entities:$e[3].entries,totalWorks:$e[0].total,totalBooks:$e[1].total,totalCollections:$e[2].total,totalEntities:$e[3].total})}}catch(pe){Be(pe instanceof Error?pe.message:String(pe)),W(null)}finally{_e(!1)}},[e,y]);g.useEffect(()=>{let I=!1;const U=()=>{var Ve,Q;const pe=["work","book","collection","entity"],$e=Promise.all(pe.map(ve=>e.loadEntries(ve,{page:1,pageSize:1}).catch(()=>({total:0})))),ye=((Ve=e.getResourceCounts)==null?void 0:Ve.call(e).catch(()=>null))??Promise.resolve(null),ue=((Q=e.getSubtypeStats)==null?void 0:Q.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([$e,ye,ue]).then(([ve,Ae,Oe])=>{I||(X({works:ve[0].total,books:ve[1].total,collections:ve[2].total,entities:ve[3].total,hasText:Ae==null?void 0:Ae.hasText,hasImage:Ae==null?void 0:Ae.hasImage}),Oe&&Ce(Oe))})};return e.getCounts?e.getCounts().then(pe=>{var $e,ye;I||(X({works:pe.works,books:pe.books,collections:pe.collections,entities:pe.entities,hasText:($e=pe.resourceCounts)==null?void 0:$e.hasText,hasImage:(ye=pe.resourceCounts)==null?void 0:ye.hasImage}),pe.subtypeStats&&Ce(pe.subtypeStats))}).catch(()=>{I||U()}):U(),()=>{I=!0}},[e]),g.useEffect(()=>{O.current||!(m!=null&&m.trim())||(O.current=!0,ie(m))},[m,ie]);const je=g.useCallback(I=>{if(T(I),!I.trim()){f==null||f(I),Fe(!0),W(null),V(null),Z("all");return}We.current&&clearTimeout(We.current),We.current=setTimeout(()=>{V(null),Z("all"),f==null||f(I),ie(I)},Ku)},[ie,f]),ke=g.useCallback(I=>{We.current&&clearTimeout(We.current),Z("all"),f==null||f(I),ie(I)},[ie,f]),P=g.useCallback(I=>{V(I),ie(z,qu)},[z,ie]);g.useEffect(()=>{if(!te.length){xe([]);return}let I=!1;return L(!0),Promise.all(te.slice(0,10).map(U=>eo(e,U))).then(U=>{I||(xe(U),L(!1))}),()=>{I=!0}},[te,e]);const fe=I=>{ge(I.id),vr(I.id),H(Ut()),o==null||o(I)},oe=(I,U)=>{if(o&&Zu(U)){U.preventDefault(),fe(I);return}vr(I.id),H(Ut())},we=I=>{kl(I),H(Ut())},Le=()=>{Qr(),H([])},He=I=>_.find(U=>U.type===I),Ge=!ze&&!B&&!le,Ye=B&&(B.works.length>0||B.books.length>0||B.collections.length>0),Xe=t.jsxs(t.Fragment,{children:[t.jsx(ul,{transport:e,value:z,onChange:je,onSearch:ke,onEntrySelect:fe}),y&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const I=z.trim();I&&pl(I),ke(z)},children:C.searchPage.submit}),s&&t.jsx("button",{onClick:()=>s("work"),style:{padding:"8px 14px",border:`1px solid ${r("primary")}`,borderRadius:"6px",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"13px"},children:C.action.newEntry})]});return t.jsxs("div",{className:"bim-browser-container",style:v?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:Ju+(y?Qu:"")}),(!y||x||!p)&&t.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[y?t.jsx("span",{}):t.jsx("h1",{style:{margin:0,fontSize:"18px",color:r("fg")},children:C.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!p&&t.jsx(dl,{variant:"index-browser",indexSource:n,syncConfig:i,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c})]})]})}),y?t.jsxs("div",{className:"bim-ib-bar","data-nofilters":e.supportsSearchFilters?void 0:"true",children:[t.jsx("span",{"aria-hidden":"true"}),t.jsx("div",{className:"bim-ib-bar-main",children:Xe})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:Xe}),ze&&t.jsx("div",{className:"bim-ib-stats",style:{padding:"0 20px 8px",fontSize:"12px",color:r("desc-fg"),display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:"4px"},children:be&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:re?t.jsxs(t.Fragment,{children:[(re.book??0)>0&&t.jsxs(t.Fragment,{children:[C.searchPage.statBook," ",t.jsx("strong",{style:{color:r("fg")},children:re.book.toLocaleString()})," ",C.unit.bu,C.searchPage.statComma,t.jsx("strong",{style:{color:r("fg")},children:be.books.toLocaleString()})," ",C.searchPage.statBookCopies]}),re.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.searchPage.statArticle," ",t.jsx("strong",{style:{color:r("fg")},children:re.article.toLocaleString()})," ",C.searchPage.statArticleUnit]}):null,re.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.searchPage.statPoem," ",t.jsx("strong",{style:{color:r("fg")},children:re.poem.toLocaleString()})," ",C.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.searchPage.statCollection," ",t.jsx("strong",{style:{color:r("fg")},children:be.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[C.indexType.work," ",t.jsx("strong",{style:{color:r("fg")},children:be.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.indexType.book," ",t.jsx("strong",{style:{color:r("fg")},children:be.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.indexType.collection," ",t.jsx("strong",{style:{color:r("fg")},children:be.collections.toLocaleString()}),be.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.indexType.entity," ",t.jsx("strong",{style:{color:r("fg")},children:be.entities.toLocaleString()})]})]})}),be.hasImage!=null&&be.hasText!=null&&t.jsxs("span",{children:[C.resourceType.image," ",t.jsx("strong",{style:{color:r("fg")},children:be.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.resourceType.text," ",t.jsx("strong",{style:{color:r("fg")},children:be.hasText.toLocaleString()})]})]})}),y&&!ze&&t.jsx(vl,{transport:e,query:N,filters:Y,onFiltersChange:se,onEntryLinkClick:oe,typeName:I=>He(I).name,tab:w,onTabChange:j,page:k,onPageChange:$}),!(y&&!ze)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:M||Ge?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg"),minHeight:Xu,boxSizing:"border-box"},children:C.search.searching}):le?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:r("desc-fg")},children:le})}):ze?t.jsx("div",{style:{flex:1},children:K?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg")},children:C.search.loading}):G.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:r("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{children:C.search.recentBrowse}),t.jsx("button",{onClick:Le,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:C.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:G.slice(0,q?10:3).map(I=>I.notFound?t.jsx(im,{id:I.id,onRemove:we,t:C},I.id):t.jsx(As,{entry:I,selected:ce===I.id,onClick:oe,getConfig:He,onRemove:we},I.id))}),!q&&G.length>3&&t.jsx("button",{onClick:()=>ae(!0),style:{display:"block",margin:"8px auto 0",padding:"4px 16px",fontSize:"12px",color:r("primary"),background:"transparent",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:C.action.expandMore})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:C.search.searchTitle}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:C.search.searchSubtitle})]})}):Ye?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:em}),(()=>{const I=ue=>B[Ls[ue]]??0,U=E.map(ue=>_.find(Ve=>Ve.type===ue)).filter(ue=>I(ue.key)>0);if(U.length<2)return null;const pe=U.reduce((ue,Ve)=>ue+I(Ve.key),0),$e=ue=>{if(Z(ue),ue!=="all"&&D!==ue){const Ve=_.find(ve=>ve.type===ue),Q=(B[Ve.key]??[]).length;I(Ve.key)>Q&&P(ue)}},ye=ue=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:r(ue?"fg":"desc-fg"),fontWeight:ue?700:400,boxShadow:ue?`inset 0 -2px 0 ${r("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":C.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":he==="all",style:ye(he==="all"),onClick:()=>$e("all"),children:[C.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:pe.toLocaleString()})]}),U.map(ue=>t.jsxs("button",{type:"button","aria-pressed":he===ue.type,style:ye(he===ue.type),onClick:()=>$e(ue.type),children:[ue.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:I(ue.key).toLocaleString()})]},ue.type))]})})(),_.map(({type:I,name:U,key:pe})=>{const $e=B[pe]??[],ye=Ls[pe],ue=B[ye]??0;if($e.length===0||he!=="all"&&he!==I)return null;const Q=he==="all"&&!(D===I)&&ue>rr;return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:`1px solid ${r("widget-border")}`,marginBottom:"6px"},children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:[t.jsx(jn,{type:I})," ",U,t.jsxs("span",{style:{fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:[ue," ",C.unit.items]})]}),Q&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>P(I),style:{border:"none",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"12px"},children:C.action.viewAll})]}),t.jsx("div",{style:h==="list"?{display:"flex",flexDirection:"column",gap:0}:h==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:$e.map(ve=>{if(u)return t.jsx(g.Fragment,{children:u(ve)},ve.id);const Ae=h==="card"?nm:As;return t.jsx(Ae,{entry:ve,selected:ce===ve.id,onClick:oe,getConfig:He,query:z},ve.id)})})]},I)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:gt(C.search.noResultsFor,{query:z})}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:C.search.tryOther})]})})]})},Xu=240;function Zu(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const Ju=`
|
|
120
|
+
`,Jr="bim-search-view",nr=50,Ns=5,En=1e3;function ci(e){return e>=En?`${En.toLocaleString()}+`:e.toLocaleString()}const Hu={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function Du(e){return e&&Hu[e.toLowerCase()]||"all"}function Uu(e){return e==="all"?null:e}const Is=["work","collection","book","entity"],Vu={work:"works",collection:"collections",book:"books",entity:"entities"},Gu={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function Yu(){try{return window.localStorage.getItem(Jr)==="card"?"card":"table"}catch{return"table"}}function qu(e){try{window.localStorage.setItem(Jr,e)}catch{}}const an=(e,n)=>(e==null?void 0:e[Gu[n]])??0,ir=(e,n)=>(e==null?void 0:e[Vu[n]])??[],kl=({transport:e,query:n,filters:i,onFiltersChange:o,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const h=Ee(),u=h.searchV4,{convert:m}=Pe(),f=!!e.supportsSearchFilters,x=g.useMemo(()=>f?i:_i,[f,i]),[v,y]=g.useState("table");g.useEffect(()=>{y(Yu())},[]);const S=H=>{y(H),qu(H)},[b,w]=g.useState(l??"all"),j=g.useRef(b);j.current=b,g.useEffect(()=>{l!==void 0&&l!==j.current&&(w(l),$(1))},[l]);const[k,$]=g.useState(c&&c>0?c:1),C=g.useRef(k);C.current=k,g.useEffect(()=>{c!==void 0&&c>0&&c!==C.current&&$(c)},[c]);const _=g.useRef(null),E=g.useCallback(H=>{var xe;$(H),p==null||p(H);const G=_.current;G&&G.getBoundingClientRect().top<0&&((xe=G.scrollIntoView)==null||xe.call(G,{block:"start",behavior:"instant"}))},[p]),[z,T]=g.useState(null),[B,W]=g.useState(null),[N,A]=g.useState(!1),[F,Y]=g.useState(""),te=gi(x).toString(),se=Ti(x)>0,D=gi({...x,sort:""}).toString(),V=g.useRef({query:n,filterOnlyKey:D,sort:x.sort});g.useEffect(()=>{const H=V.current;H.query!==n||H.filterOnlyKey!==D?(w("all"),$(1)):H.sort!==x.sort&&$(1),V.current={query:n,filterOnlyKey:D,sort:x.sort}},[n,D,x.sort]),g.useEffect(()=>{let H=!1;return A(!0),Y(""),(async()=>{try{let G;if(e.searchAll)G=await e.searchAll(n,Ns,x);else{const xe=["work","book","collection","entity"],K=await Promise.all(xe.map(L=>e.search(n,L,{page:1,pageSize:Ns,filters:x})));G={works:K[0].entries,books:K[1].entries,collections:K[2].entries,entities:K[3].entries,totalWorks:K[0].total,totalBooks:K[1].total,totalCollections:K[2].total,totalEntities:K[3].total}}H||T(G)}catch(G){H||(Y(G instanceof Error?G.message:String(G)),T(null))}finally{H||A(!1)}})(),()=>{H=!0}},[e,n,te]);const he=b;g.useEffect(()=>{if(b==="all"){W(null);return}let H=!1;return A(!0),(async()=>{try{const G=await e.search(n,b,{page:k,pageSize:nr,filters:x});H||W({key:he,entries:G.entries,total:G.total})}catch(G){H||(Y(G instanceof Error?G.message:String(G)),W(null))}finally{H||A(!1)}})(),()=>{H=!0}},[e,n,te,b,k]);const Z=B&&B.key===he?B:null;g.useEffect(()=>{if(b==="all"||!Z||N)return;const H=Math.min(Z.total,En),G=Bu(k,H,nr);Z.entries.length===0&&H>0&&G!==k&&($(G),p==null||p(G))},[b,Z,N,k]);const M=g.useMemo(()=>Is.filter(H=>an(z,H)>0),[z]),_e=M.reduce((H,G)=>H+an(z,G),0),ce=M.some(H=>an(z,H)>=En)?`${_e.toLocaleString()}+`:_e.toLocaleString(),ge=!N&&!F&&z!==null&&_e===0,le=g.useCallback(H=>{w(H),$(1),d==null||d(H)},[d]),Be=g.useMemo(()=>{const H=[];return x.dynasty.forEach(G=>H.push({name:G,remove:()=>o({...x,dynasty:x.dynasty.filter(xe=>xe!==G)})})),x.classification.forEach(G=>{var xe;return H.push({name:G?((xe=Ci.find(K=>K.value===G))==null?void 0:xe.label)??G:h.searchPage.unclassified,remove:()=>o({...x,classification:x.classification.filter(K=>K!==G)})})}),x.hasImage&&H.push({name:u.hasImage,remove:()=>o({...x,hasImage:!1})}),x.hasText&&H.push({name:u.hasText,remove:()=>o({...x,hasText:!1})}),x.hasCollated&&H.push({name:u.hasCollated,remove:()=>o({...x,hasCollated:!1})}),x.loss&&H.push({name:`${u.extant}:${h.searchPage.loss[x.loss]}`,remove:()=>o({...x,loss:""})}),H},[x,o,u,h]),ze={query:n,onEntryLinkClick:s,typeName:a},Fe=H=>v==="table"?t.jsx(Ts,{entries:H,...ze}):t.jsx(zs,{entries:H,...ze}),Q=Is.flatMap(H=>ir(z,H));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":f?void 0:"true",children:[t.jsx("style",{children:Fu}),f&&t.jsx(Au,{filters:x,onChange:o}),t.jsxs("div",{className:"bim-sr-main","aria-busy":N,ref:_,children:[M.length>0&&t.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":h.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${r("rule")}`},children:[t.jsxs(Rs,{on:b==="all",onClick:()=>le("all"),children:[h.search.allTab," ",t.jsx("small",{children:ce})]}),M.map(H=>t.jsxs(Rs,{on:b===H,onClick:()=>le(H),children:[a(H)," ",t.jsx("small",{children:ci(an(z,H))})]},H))]}),t.jsxs("div",{className:"bim-sr-tools",children:[f&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":m(u.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>o({...x,sort:""}),children:m(u.sortRelevance)}),["era","title"].map(H=>{const G=x.sort.startsWith(`${H}:`)?x.sort.endsWith("desc")?"desc":"asc":null,xe=H==="era"?u.sortEra:u.sortTitle,K=H==="era"?G==="desc"?u.sortEraDesc:u.sortEraAsc:G==="desc"?u.sortTitleDesc:u.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":G!==null,title:m(K),onClick:()=>o({...x,sort:`${H}:${G==="asc"?"desc":"asc"}`}),children:[m(xe),G?t.jsxs("span",{"aria-hidden":"true",children:[" ",G==="asc"?"↑":"↓"]}):null]},H)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":m(u.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":v==="table",onClick:()=>S("table"),children:m(u.viewTable)}),t.jsx("button",{type:"button","aria-pressed":v==="card",onClick:()=>S("card"),children:m(u.viewCard)})]})]}),se&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:m(gt(u.filteredCount,{n:ce}))}),Be.map(H=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":m(gt(u.removeFilter,{name:H.name})),onClick:H.remove,children:[m(H.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},H.name))]}),F&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:F}),ge&&t.jsx("div",{className:"bim-sr-empty",children:m(se?u.emptyFiltered:gt(h.search.noResultsFor,{query:n}))}),!F&&!ge&&b==="all"&&z&&(v==="table"?t.jsxs(t.Fragment,{children:[t.jsx(Ts,{entries:Q,...ze}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:m(u.limitedNote)})]}):t.jsx(t.Fragment,{children:M.map(H=>t.jsxs("section",{style:{marginTop:22},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,marginBottom:10},children:[t.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,letterSpacing:".1em",display:"flex",alignItems:"center",gap:8},children:[t.jsx(jn,{type:H,size:8}),a(H),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:r("meta-fg")},children:[ci(an(z,H))," ",h.unit.items]})]}),an(z,H)>ir(z,H).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>le(H),children:h.action.viewAll})]}),t.jsx(zs,{entries:ir(z,H),...ze})]},H))})),!F&&b!=="all"&&!Z&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:h.search.loading}),!F&&b!=="all"&&Z&&Z.entries.length>0&&t.jsxs(t.Fragment,{children:[Fe(Z.entries),t.jsx(Wu,{page:k,pageSize:nr,total:Math.min(Z.total,En),totalLabel:ci(Z.total),onPage:E})]}),!F&&b!=="all"&&Z&&Z.entries.length===0&&!N&&t.jsxs("div",{className:"bim-sr-empty",children:[m(se?u.emptyFiltered:gt(h.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>le("all"),children:h.search.allTab})})]})]})]})};function Rs({on:e,onClick:n,children:i}){return t.jsx("button",{type:"button","aria-pressed":e,onClick:n,style:{border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:14.5,minHeight:44,padding:"8px 12px",letterSpacing:".06em",color:r(e?"ink":"meta-fg"),fontWeight:e?700:400,boxShadow:e?`inset 0 -2px 0 ${r("accent")}`:"none"},children:i})}const un="bim-recent-ids",Es="bim-recent-entries",Ls=50;function Ut(){try{const e=localStorage.getItem(un);if(e)return JSON.parse(e);const n=localStorage.getItem(Es);if(n){const i=JSON.parse(n).map(o=>o.id);return localStorage.setItem(un,JSON.stringify(i)),localStorage.removeItem(Es),i}return[]}catch{return[]}}function vr(e){try{const n=Ut().filter(i=>i!==e);n.unshift(e),n.length>Ls&&(n.length=Ls),localStorage.setItem(un,JSON.stringify(n))}catch{}}function wl(e){try{const n=Ut().filter(i=>i!==e);localStorage.setItem(un,JSON.stringify(n))}catch{}}function Qr(){try{localStorage.removeItem(un)}catch{}}async function eo(e,n){var i,o,s;try{if(e.getEntry){const l=await e.getEntry(n);if(l)return l}const a=await e.getItem(n);if(a){const l=a.authors;return{id:n,title:a.title||n,type:a.type||"work",author:(i=l==null?void 0:l[0])==null?void 0:i.name,dynasty:(o=l==null?void 0:l[0])==null?void 0:o.dynasty,role:(s=l==null?void 0:l[0])==null?void 0:s.role,edition:a.edition||void 0}}}catch{}return{id:n,title:n,type:"work",notFound:!0}}const rr=5,Ku=50,Xu=200,As={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},kr=({transport:e,indexSource:n="local",syncConfig:i,onEntryClick:o,onNewEntry:s,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c,hideModeIndicator:p,resultVariant:h="compact",renderEntry:u,initialQuery:m,onQueryChange:f,headerRight:x,reserveViewportHeight:v=!1,filtersEnabled:y=!1,filters:S=_i,onFiltersChange:b,resultTab:w,onResultTabChange:j,resultPage:k,onResultPageChange:$})=>{const C=Ee(),_=[{type:"work",name:C.indexType.work,key:"works"},{type:"book",name:C.indexType.book,key:"books"},{type:"collection",name:C.indexType.collection,key:"collections"},{type:"entity",name:C.indexType.entity,key:"entities"}],E=["work","collection","book","entity"],[z,T]=g.useState(m??""),[B,W]=g.useState(null),[N,A]=g.useState(m??""),F=gi(S).toString(),[Y,te]=g.useState(S);g.useEffect(()=>{te(S)},[F]);const se=I=>{te(I),b==null||b(I)},[D,V]=g.useState(null),[he,Z]=g.useState("all"),[M,_e]=g.useState(!1),[ce,ge]=g.useState(null),[le,Be]=g.useState(""),[ze,Fe]=g.useState(!(m!=null&&m.trim())),[Q,H]=g.useState(Ut),[G,xe]=g.useState([]),[K,L]=g.useState(!1),[q,ae]=g.useState(!1),[be,X]=g.useState(null),[re,Ce]=g.useState(null),We=g.useRef(void 0),O=g.useRef(!1),ie=g.useCallback(async(I,U)=>{if(!I.trim()){Fe(!0),W(null),V(null);return}if(Fe(!1),y){A(I);return}_e(!0),Be("");try{if(e.searchAll){const pe=await e.searchAll(I,U??rr);W(pe)}else{const pe=["work","book","collection","entity"],$e=await Promise.all(pe.map(ye=>e.search(I,ye,{page:1,pageSize:U??rr})));W({works:$e[0].entries,books:$e[1].entries,collections:$e[2].entries,entities:$e[3].entries,totalWorks:$e[0].total,totalBooks:$e[1].total,totalCollections:$e[2].total,totalEntities:$e[3].total})}}catch(pe){Be(pe instanceof Error?pe.message:String(pe)),W(null)}finally{_e(!1)}},[e,y]);g.useEffect(()=>{let I=!1;const U=()=>{var Ve,ee;const pe=["work","book","collection","entity"],$e=Promise.all(pe.map(ve=>e.loadEntries(ve,{page:1,pageSize:1}).catch(()=>({total:0})))),ye=((Ve=e.getResourceCounts)==null?void 0:Ve.call(e).catch(()=>null))??Promise.resolve(null),ue=((ee=e.getSubtypeStats)==null?void 0:ee.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([$e,ye,ue]).then(([ve,Ae,Oe])=>{I||(X({works:ve[0].total,books:ve[1].total,collections:ve[2].total,entities:ve[3].total,hasText:Ae==null?void 0:Ae.hasText,hasImage:Ae==null?void 0:Ae.hasImage}),Oe&&Ce(Oe))})};return e.getCounts?e.getCounts().then(pe=>{var $e,ye;I||(X({works:pe.works,books:pe.books,collections:pe.collections,entities:pe.entities,hasText:($e=pe.resourceCounts)==null?void 0:$e.hasText,hasImage:(ye=pe.resourceCounts)==null?void 0:ye.hasImage}),pe.subtypeStats&&Ce(pe.subtypeStats))}).catch(()=>{I||U()}):U(),()=>{I=!0}},[e]),g.useEffect(()=>{O.current||!(m!=null&&m.trim())||(O.current=!0,ie(m))},[m,ie]);const je=g.useCallback(I=>{if(T(I),!I.trim()){f==null||f(I),Fe(!0),W(null),V(null),Z("all");return}We.current&&clearTimeout(We.current),We.current=setTimeout(()=>{V(null),Z("all"),f==null||f(I),ie(I)},Xu)},[ie,f]),ke=g.useCallback(I=>{We.current&&clearTimeout(We.current),Z("all"),f==null||f(I),ie(I)},[ie,f]),P=g.useCallback(I=>{V(I),ie(z,Ku)},[z,ie]);g.useEffect(()=>{if(!Q.length){xe([]);return}let I=!1;return L(!0),Promise.all(Q.slice(0,10).map(U=>eo(e,U))).then(U=>{I||(xe(U),L(!1))}),()=>{I=!0}},[Q,e]);const fe=I=>{ge(I.id),vr(I.id),H(Ut()),o==null||o(I)},oe=(I,U)=>{if(o&&Ju(U)){U.preventDefault(),fe(I);return}vr(I.id),H(Ut())},we=I=>{wl(I),H(Ut())},Le=()=>{Qr(),H([])},He=I=>_.find(U=>U.type===I),Ge=!ze&&!B&&!le,Ye=B&&(B.works.length>0||B.books.length>0||B.collections.length>0),Xe=t.jsxs(t.Fragment,{children:[t.jsx(ml,{transport:e,value:z,onChange:je,onSearch:ke,onEntrySelect:fe}),y&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const I=z.trim();I&&ul(I),ke(z)},children:C.searchPage.submit}),s&&t.jsx("button",{onClick:()=>s("work"),style:{padding:"8px 14px",border:`1px solid ${r("primary")}`,borderRadius:"6px",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"13px"},children:C.action.newEntry})]});return t.jsxs("div",{className:"bim-browser-container",style:v?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:Qu+(y?em:"")}),(!y||x||!p)&&t.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[y?t.jsx("span",{}):t.jsx("h1",{style:{margin:0,fontSize:"18px",color:r("fg")},children:C.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!p&&t.jsx(pl,{variant:"index-browser",indexSource:n,syncConfig:i,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c})]})]})}),y?t.jsxs("div",{className:"bim-ib-bar","data-nofilters":e.supportsSearchFilters?void 0:"true",children:[t.jsx("span",{"aria-hidden":"true"}),t.jsx("div",{className:"bim-ib-bar-main",children:Xe})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:Xe}),ze&&t.jsx("div",{className:"bim-ib-stats",style:{padding:"0 20px 8px",fontSize:"12px",color:r("desc-fg"),display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:"4px"},children:be&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:re?t.jsxs(t.Fragment,{children:[(re.book??0)>0&&t.jsxs(t.Fragment,{children:[C.searchPage.statBook," ",t.jsx("strong",{style:{color:r("fg")},children:re.book.toLocaleString()})," ",C.unit.bu,C.searchPage.statComma,t.jsx("strong",{style:{color:r("fg")},children:be.books.toLocaleString()})," ",C.searchPage.statBookCopies]}),re.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.searchPage.statArticle," ",t.jsx("strong",{style:{color:r("fg")},children:re.article.toLocaleString()})," ",C.searchPage.statArticleUnit]}):null,re.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.searchPage.statPoem," ",t.jsx("strong",{style:{color:r("fg")},children:re.poem.toLocaleString()})," ",C.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.searchPage.statCollection," ",t.jsx("strong",{style:{color:r("fg")},children:be.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[C.indexType.work," ",t.jsx("strong",{style:{color:r("fg")},children:be.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.indexType.book," ",t.jsx("strong",{style:{color:r("fg")},children:be.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.indexType.collection," ",t.jsx("strong",{style:{color:r("fg")},children:be.collections.toLocaleString()}),be.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.indexType.entity," ",t.jsx("strong",{style:{color:r("fg")},children:be.entities.toLocaleString()})]})]})}),be.hasImage!=null&&be.hasText!=null&&t.jsxs("span",{children:[C.resourceType.image," ",t.jsx("strong",{style:{color:r("fg")},children:be.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.resourceType.text," ",t.jsx("strong",{style:{color:r("fg")},children:be.hasText.toLocaleString()})]})]})}),y&&!ze&&t.jsx(kl,{transport:e,query:N,filters:Y,onFiltersChange:se,onEntryLinkClick:oe,typeName:I=>He(I).name,tab:w,onTabChange:j,page:k,onPageChange:$}),!(y&&!ze)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:M||Ge?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg"),minHeight:Zu,boxSizing:"border-box"},children:C.search.searching}):le?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:r("desc-fg")},children:le})}):ze?t.jsx("div",{style:{flex:1},children:K?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg")},children:C.search.loading}):G.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:r("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{children:C.search.recentBrowse}),t.jsx("button",{onClick:Le,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:C.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:G.slice(0,q?10:3).map(I=>I.notFound?t.jsx(rm,{id:I.id,onRemove:we,t:C},I.id):t.jsx(Ms,{entry:I,selected:ce===I.id,onClick:oe,getConfig:He,onRemove:we},I.id))}),!q&&G.length>3&&t.jsx("button",{onClick:()=>ae(!0),style:{display:"block",margin:"8px auto 0",padding:"4px 16px",fontSize:"12px",color:r("primary"),background:"transparent",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:C.action.expandMore})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:C.search.searchTitle}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:C.search.searchSubtitle})]})}):Ye?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:tm}),(()=>{const I=ue=>B[As[ue]]??0,U=E.map(ue=>_.find(Ve=>Ve.type===ue)).filter(ue=>I(ue.key)>0);if(U.length<2)return null;const pe=U.reduce((ue,Ve)=>ue+I(Ve.key),0),$e=ue=>{if(Z(ue),ue!=="all"&&D!==ue){const Ve=_.find(ve=>ve.type===ue),ee=(B[Ve.key]??[]).length;I(Ve.key)>ee&&P(ue)}},ye=ue=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:r(ue?"fg":"desc-fg"),fontWeight:ue?700:400,boxShadow:ue?`inset 0 -2px 0 ${r("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":C.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":he==="all",style:ye(he==="all"),onClick:()=>$e("all"),children:[C.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:pe.toLocaleString()})]}),U.map(ue=>t.jsxs("button",{type:"button","aria-pressed":he===ue.type,style:ye(he===ue.type),onClick:()=>$e(ue.type),children:[ue.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:I(ue.key).toLocaleString()})]},ue.type))]})})(),_.map(({type:I,name:U,key:pe})=>{const $e=B[pe]??[],ye=As[pe],ue=B[ye]??0;if($e.length===0||he!=="all"&&he!==I)return null;const ee=he==="all"&&!(D===I)&&ue>rr;return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:`1px solid ${r("widget-border")}`,marginBottom:"6px"},children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:[t.jsx(jn,{type:I})," ",U,t.jsxs("span",{style:{fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:[ue," ",C.unit.items]})]}),ee&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>P(I),style:{border:"none",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"12px"},children:C.action.viewAll})]}),t.jsx("div",{style:h==="list"?{display:"flex",flexDirection:"column",gap:0}:h==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:$e.map(ve=>{if(u)return t.jsx(g.Fragment,{children:u(ve)},ve.id);const Ae=h==="card"?im:Ms;return t.jsx(Ae,{entry:ve,selected:ce===ve.id,onClick:oe,getConfig:He,query:z},ve.id)})})]},I)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:gt(C.search.noResultsFor,{query:z})}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:C.search.tryOther})]})})]})},Zu=240;function Ju(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const Qu=`
|
|
121
121
|
.bim-ib-stats { min-height: 25px; box-sizing: content-box; }
|
|
122
122
|
@media (max-width: 719px) { .bim-ib-stats { min-height: 46px; } }
|
|
123
|
-
`,
|
|
123
|
+
`,em=`
|
|
124
124
|
.bim-ib-bar { display: grid; grid-template-columns: 208px minmax(0, 1fr); column-gap: 40px; padding: 0 20px 16px; }
|
|
125
125
|
.bim-ib-bar[data-nofilters] { grid-template-columns: minmax(0, 1fr); }
|
|
126
126
|
.bim-ib-bar[data-nofilters] > [aria-hidden] { display: none; }
|
|
@@ -135,20 +135,20 @@
|
|
|
135
135
|
.bim-ib-bar-main { max-width: none; }
|
|
136
136
|
.bim-ib-submit { min-height: 44px; padding: 0 16px; }
|
|
137
137
|
}
|
|
138
|
-
`,
|
|
138
|
+
`,tm=`
|
|
139
139
|
@media (max-width: 719px), (pointer: coarse) {
|
|
140
140
|
.bim-ib-viewall { position: relative; }
|
|
141
141
|
.bim-ib-viewall::after {
|
|
142
142
|
content: ""; position: absolute; left: 50%; top: 50%;
|
|
143
143
|
width: max(calc(100% + 8px), 44px); height: max(100%, 44px); transform: translate(-50%, -50%);
|
|
144
144
|
}
|
|
145
|
-
}`,wl={color:"inherit",textDecoration:"none"},tm=({snippet:e})=>{const{convert:n}=Pe();return t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.6},children:Vr(e).map((i,o)=>i.marked?t.jsx("mark",{style:{background:r("highlight-bg"),color:r("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(i.text)},o):t.jsx(g.Fragment,{children:n(i.text)},o))})},nm=({entry:e,selected:n,onClick:i,getConfig:o,query:s})=>{const a=Ee(),{convert:l}=Pe(),d=l(e.title||e.primary_name||e.id),c=e.measure_info?l(e.measure_info):e.juan_count!=null&&e.juan_count>0?`${e.juan_count}${a.unit.juan}`:"",p=[...e.additional_titles||[],...e.attached_texts||[]],h=s&&p.length?p.find(f=>{const x=typeof f=="string"?f:f==null?void 0:f.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,u=r("cover-accent"),m=tt();return t.jsxs("a",{href:m(e.id),onClick:f=>i(e,f),className:"bim-result-card",style:{...wl,display:"flex",gap:"1.2rem",alignItems:"stretch",padding:"1.1rem 1.3rem",borderRadius:"12px",cursor:"pointer",background:r("bg"),border:n?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,transition:"border-color .2s ease, transform .2s ease, box-shadow .2s ease"},children:[t.jsxs("div",{"aria-hidden":"true",style:{position:"relative",width:"92px",minHeight:"126px",flexShrink:0,borderRadius:"4px",border:`1px solid color-mix(in srgb, ${u} 50%, ${r("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${u} 14%, ${r("bg")}), color-mix(in srgb, ${u} 7%, ${r("bg")}))`,display:"flex",alignItems:"center",justifyContent:"center",padding:"0.6rem 0.3rem"},children:[t.jsx("span",{style:{position:"absolute",left:"6px",top:0,bottom:0,borderLeft:`1px dashed color-mix(in srgb, ${u} 45%, transparent)`}}),t.jsx("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",height:"108px",flexShrink:0,overflow:"hidden",fontSize:"1.05rem",fontWeight:700,lineHeight:1.25,color:u},children:Array.from(d).map((f,x)=>t.jsx("span",{children:f},x))})]}),t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"17px",fontWeight:600,color:r("fg")},children:d}),c&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg")},children:c})]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"13px",color:r("desc-fg")},children:[e.dynasty&&t.jsxs("span",{children:["〔",l(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:l(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",l(e.role)]})]}),(e.era||e.edition)&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg")},children:[e.era&&t.jsxs("span",{children:["〔",l(e.era),"〕"]}),e.edition&&t.jsx("span",{children:l(e.edition)})]}),h&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg")},children:[a.search.alias,":",l(typeof h=="string"?h:h.book_title||"")]}),e.descriptionSnippet&&t.jsx(tm,{snippet:e.descriptionSnippet}),t.jsxs("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"auto",paddingTop:"4px"},children:[t.jsxs("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:[t.jsx(jn,{type:e.type,size:8})," ",o(e.type).name]}),e.has_text&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:a.misc.textResource}),e.has_image&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:a.misc.imageResource})]})]})]})},As=({entry:e,selected:n,onClick:i,getConfig:o,query:s,onRemove:a})=>{const l=Ee(),{convert:d}=Pe(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(u=>{const m=typeof u=="string"?u:u==null?void 0:u.book_title;return m==null?void 0:m.toLowerCase().includes(s.toLowerCase())}):void 0,h=tt();return t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",borderRadius:"6px",border:n?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("a",{href:h(e.id),onClick:u=>i(e,u),className:"bim-result-card",style:{...wl,flex:1,minWidth:0,display:"flex",alignItems:"flex-start",gap:"10px",padding:a?"10px 0 10px 12px":"10px 12px",borderRadius:"6px",cursor:"pointer"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",marginTop:"2px"},children:[t.jsx(jn,{type:e.type,size:12}),t.jsx("span",{style:{fontSize:"9px",color:r("desc-fg"),lineHeight:1},children:o(e.type).name})]}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg")},children:d(e.title||e.primary_name||e.id)}),t.jsxs("span",{style:{display:"flex",gap:"2px",fontSize:"12px",opacity:.7},children:[e.has_text&&t.jsx("span",{children:l.misc.textResource}),e.has_image&&t.jsx("span",{children:l.misc.imageResource})]}),(e.era||e.edition)&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[e.era&&t.jsxs(t.Fragment,{children:["〔",d(e.era),"〕"]}),e.edition&&d(e.edition)]}),e.measure_info?t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:d(e.measure_info)}):e.juan_count!=null&&e.juan_count>0?t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[e.juan_count,l.unit.juan]}):null]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"2px"},children:[e.dynasty&&t.jsxs("span",{children:["〔",d(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:d(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",d(e.role)]}),e.type==="entity"&&(e.birth_year!=null||e.death_year!=null)&&t.jsxs("span",{style:{marginLeft:e.dynasty?"4px":0},children:[e.birth_year??"?","—",e.death_year??"?"]})]}),p&&t.jsxs("div",{style:{fontSize:"11px",color:r("desc-fg"),marginTop:"2px"},children:[l.search.alias,":",d(p)]})]}),!a&&t.jsx("span",{"aria-hidden":"true",style:{opacity:.4,marginTop:"2px"},children:"→"})]}),a&&t.jsx("button",{type:"button",onClick:()=>a(e.id),title:l.search.removeFromRecent,"aria-label":l.search.removeFromRecent,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"12px 12px 12px 8px",lineHeight:1,opacity:.5},children:"×"})]})},im=({id:e,onRemove:n,t:i})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${r("widget-border")}`,background:r("input-bg"),opacity:.6},children:[t.jsx("span",{style:{fontSize:"16px"},children:"❓"}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:"13px",color:r("fg"),fontFamily:"monospace"},children:e}),t.jsx("div",{style:{fontSize:"11px",color:r("desc-fg"),marginTop:"2px"},children:i.search.itemNotFound})]}),t.jsx("button",{onClick:()=>n(e),title:i.search.removeFromRecent,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"2px 4px",lineHeight:1},children:"×"})]});function rm(e){var n;return!e.dynasty&&!e.birth_year&&!e.death_year&&(!e.alt_names||e.alt_names.length===0)&&!((n=e.description)!=null&&n.text)}function om({data:e}){const{convert:n}=Pe(),{dynasty:i,birth_year:o,death_year:s}=e,a=[];return i&&a.push(`〔${n(i)}〕`),o!==void 0&&s!==void 0?a.push(`${o}—${s}`):o!==void 0?a.push(`${o}—?`):s!==void 0&&a.push(`?—${s}`),a.length===0?null:t.jsx("span",{style:{fontSize:"14px",color:r("desc-fg"),marginLeft:"8px",fontWeight:"normal"},children:a.join(" ")})}function sm({alt_names:e}){const{convert:n}=Pe(),i=new Map;for(const a of e){const l=a.type||"別名";i.has(l)||i.set(l,[]),i.get(l).push(a.name)}const o=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...i.keys()].sort((a,l)=>{const d=o.indexOf(a),c=o.indexOf(l);return d===-1&&c===-1?0:d===-1?1:c===-1?-1:d-c});return t.jsx("div",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(a=>{const l=i.get(a);return t.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[t.jsx("span",{style:{color:r("desc-fg"),fontSize:"12px",minWidth:"36px",paddingTop:"2px"},children:n(a)}),t.jsx("span",{children:l.map((d,c)=>t.jsxs("span",{children:[c>0&&t.jsx("span",{style:{color:r("desc-fg"),margin:"0 4px"},children:"·"}),n(d)]},c))})]},a)})})}function am({data:e}){const n=Ee(),i=e.external_ids;if(!i)return null;const o=[];return i.cbdb_id&&o.push(t.jsxs("a",{href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${i.cbdb_id}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"2px 8px",fontSize:"12px",color:r("link-fg"),border:`1px solid ${r("link-fg")}40`,borderRadius:"3px",textDecoration:"none",background:`${r("link-fg")}08`},title:n.common.cbdbTitle,children:["CBDB ",i.cbdb_id]},"cbdb")),o.length===0?null:t.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:o})}function lm({works:e,transport:n,onNavigate:i,renderLink:o}){const s=Ee(),{convert:a}=Pe(),l=tt(),[d,c]=g.useState(new Map);g.useEffect(()=>{if(!n)return;let m=!1;const f=e.map(v=>v.work_id);return(async()=>{const v=new Map;if(n.getEntriesByIds)try{const w=await n.getEntriesByIds(f);let j=!0;for(let k=0;k<f.length;k++){const $=w[k];$!=null&&$.title?v.set(f[k],$.title):$!=null&&$.primary_name?v.set(f[k],$.primary_name):j=!1}if(j)return v}catch{}const y=[...f],S=8,b=new Array(S).fill(0).map(async()=>{for(;y.length;){const w=y.shift();if(!w)break;if(!v.has(w))try{if(n.getEntry){const $=await n.getEntry(w);if($!=null&&$.title){v.set(w,$.title);continue}}const j=await n.getItem(w),k=j&&(j.title||j.primary_name)||w;v.set(w,k)}catch{v.set(w,w)}}});return await Promise.all(b),v})().then(v=>{m||c(v)}),()=>{m=!0}},[e,n]);const p=new Map;for(const m of e){const f=m.role||"";p.has(f)||p.set(f,[]),p.get(f).push(m)}const h=["撰","編","注","輯","集","校","評","譯","述","作",""],u=[...p.keys()].sort((m,f)=>{const x=h.indexOf(m),v=h.indexOf(f);return x===-1&&v===-1?m.localeCompare(f):x===-1?1:v===-1?-1:x-v});return t.jsxs("div",{style:{marginTop:"12px"},children:[t.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:r("fg"),margin:"0 0 8px",paddingBottom:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[s.label.relatedWorks," ",t.jsxs("span",{style:{color:r("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",e.length,")"]})]}),u.map(m=>{const f=p.get(m);return t.jsxs("div",{style:{marginBottom:"8px"},children:[m&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"2px"},children:[a(m)," ",t.jsxs("span",{style:{color:r("desc-fg")},children:["(",f.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:m?"16px":"0",listStyle:m?"disc":"none",fontSize:"14px",lineHeight:1.8},children:f.map((x,v)=>{const y=a(d.get(x.work_id)||x.work_id);return o?t.jsx("li",{children:o(x.work_id,y)},v):i?t.jsx("li",{children:t.jsx("a",{href:l(x.work_id),onClick:S=>{S.metaKey||S.ctrlKey||(S.preventDefault(),i(x.work_id))},style:{color:r("link-fg"),textDecoration:"underline",cursor:"pointer"},children:y})},v):t.jsx("li",{children:y},v)})})]},m)})]})}const Sl=({data:e,transport:n,onNavigate:i,renderLink:o,headerExtra:s,hideHeader:a})=>{var u;const l=Ee(),{convert:d}=Pe();let c=!1;try{c=Se.extractStatus(e.id)==="draft"}catch{}const p=rm(e),h=e.subtype&&e.subtype in l.common.entitySubtype?l.common.entitySubtype[e.subtype]:d(e.subtype);return t.jsxs("div",{children:[!a&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"4px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:600,margin:0,lineHeight:1.3,color:r("fg")},children:[d(e.primary_name),t.jsx(om,{data:e})]}),s]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:r("type-entity"),border:`1px solid color-mix(in srgb, ${r("type-entity")} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${r("type-entity")} 3%, transparent)`},children:l.indexType.entity}),h&&e.subtype!=="people"&&t.jsx("span",{children:h}),c&&t.jsx("span",{style:{padding:"1px 6px",background:r("warn-bg"),border:`1px solid ${r("warn-border")}`,borderRadius:"2px",color:r("warn-fg")},children:l.status.draft}),t.jsx("span",{style:{fontFamily:"monospace",opacity:.6},children:e.id})]})]}),p&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),fontStyle:"italic",padding:"8px 12px",background:r("widget-bg"),border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",margin:"8px 0"},children:l.common.entityPlaceholderNote}),e.alt_names&&e.alt_names.length>0&&t.jsx(sm,{alt_names:e.alt_names}),t.jsx(am,{data:e}),((u=e.description)==null?void 0:u.text)&&t.jsx("p",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:d(e.description.text)}),e.works&&e.works.length>0&&t.jsx(lm,{works:e.works,transport:n,onNavigate:i,renderLink:o})]})},cm=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function dm(e){const n=e.search(cm);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const _l={p:({children:e})=>t.jsx("p",{style:{margin:"0 0 0.5em"},children:e}),ul:({children:e})=>t.jsx("ul",{style:{margin:"0 0 0.5em",paddingLeft:"1.4em"},children:e}),ol:({children:e})=>t.jsx("ol",{style:{margin:"0 0 0.5em",paddingLeft:"1.6em"},children:e}),li:({children:e})=>t.jsx("li",{style:{marginBottom:"2px"},children:e}),a:({href:e,children:n})=>{let i=e,o="",s=n;if(e&&typeof n=="string"&&(n===e||n===pm(e))){const[a,l]=dm(n);l&&(i=encodeURI(a),s=a,o=l)}return t.jsxs(t.Fragment,{children:[t.jsx("a",{href:i,target:i!=null&&i.startsWith("http")?"_blank":void 0,rel:i!=null&&i.startsWith("http")?"noopener noreferrer":void 0,style:{color:r("link")},children:s}),o]})},code:({children:e})=>t.jsx("code",{style:{background:r("bg-subtle"),padding:"1px 4px",borderRadius:3,fontSize:"0.92em"},children:e})};function pm(e){try{return decodeURI(e)}catch{return e}}const um={..._l,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},Pt=({text:e,plainStrong:n,style:i,className:o})=>{const{convert:s}=Pe(),a=n?um:_l;return t.jsx("div",{className:o,style:i,children:t.jsx(Mp,{remarkPlugins:[Pp],components:a,children:s(e)})})},mm=["〇","一","二","三","四","五","六","七","八","九"],Ms=["","十","百","千"];function $l(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),i=n.length;let o="",s=!1;for(let a=0;a<i;a++){const l=parseInt(n[a]),d=i-1-a;l===0?s=!0:(s&&o&&(o+="〇"),s=!1,l===1&&d===1&&a===0?o+=Ms[d]:o+=mm[l]+Ms[d])}return o}function Cl(e){return{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:e,border:`1px solid color-mix(in srgb, ${e} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${e} 3%, transparent)`}}const hm={book:r("type-book"),work:r("type-work"),collection:r("type-collection"),entity:r("type-entity")};function gm({type:e}){const n=Ee();return t.jsx("span",{style:Cl(hm[e]),children:n.indexType[e]})}function fm({isDraft:e}){const n=Ee(),i=r(e?"status-draft":"status-official");return t.jsx("span",{style:Cl(i),children:e?n.status.draft:n.status.official})}function xm({id:e}){const n=Ee(),[i,o]=g.useState(!1),s=()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})};return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:r("desc-fg"),background:r("bg-subtle"),border:`1px solid ${r("widget-border")}`,borderRadius:"2px"},children:[t.jsx("span",{children:n.label.id}),t.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:r("fg")},children:e}),t.jsx("span",{onClick:s,title:i?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"11px",opacity:i?1:.5,transition:"opacity 0.15s"},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity=i?"1":"0.5",children:i?"✓":"⧉"})]})}function xt({children:e,extra:n}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"20px",marginBottom:"8px"},children:[t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:r("desc-fg"),letterSpacing:"1px"},children:e}),t.jsx("span",{style:{flex:1}}),n]})}function $t({label:e,children:n}){return t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[t.jsx("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:e}),t.jsx("span",{style:{color:r("fg")},children:n})]})}function Tl({authors:e,type:n,onNavigate:i,renderLink:o}){const{convert:s}=Pe();return t.jsx("span",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.6},children:e.map((a,l)=>{const d=s(a.name),c=a.entity_id?t.jsx(wt,{id:a.entity_id,label:d,onNavigate:i,renderLink:o}):t.jsx("span",{style:{fontWeight:500},children:d});return t.jsxs("span",{children:[l>0&&t.jsx("span",{style:{color:r("desc-fg"),margin:"0 4px"},children:"·"}),a.dynasty&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:["〔",s(a.dynasty),"〕"]}),c,a.role&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px",marginLeft:"2px"},children:[" ",s(a.role)]})]},l)})})}function wt({id:e,label:n,onNavigate:i,renderLink:o}){const s=tt();return o?t.jsx(t.Fragment,{children:o(e,n)}):i?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i(e))},style:{color:r("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`,paddingBottom:"1px"},onMouseEnter:a=>a.currentTarget.style.borderBottomStyle="solid",onMouseLeave:a=>a.currentTarget.style.borderBottomStyle="dashed",children:n||e}):t.jsx("span",{children:n||e})}function bm({id:e,title:n,edition:i,type:o,isDraft:s,authors:a,volumeText:l,meta:d,headerExtra:c,onNavigate:p,renderLink:h}){return t.jsxs("div",{style:{marginBottom:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:700,color:r("fg"),margin:"0 0 6px",lineHeight:1.4,letterSpacing:"0.5px",wordBreak:"break-word",flex:1,minWidth:0},children:[n,i&&t.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:i}),l&&t.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:r("desc-fg"),marginLeft:"8px"},children:l})]}),c&&t.jsx("div",{style:{flexShrink:0,paddingTop:"2px"},children:c})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"4px"},children:[t.jsx(gm,{type:o}),t.jsx(fm,{isDraft:s}),t.jsx(xm,{id:e})]}),((a==null?void 0:a.length)||d.length>0)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"12px",marginTop:"6px"},children:[a&&a.length>0&&t.jsx(Tl,{authors:a,type:o,onNavigate:p,renderLink:h}),d]})]})}function zl({items:e,label:n,showMeta:i,onNavigate:o,renderLink:s}){const a=Ee(),{convert:l}=Pe();if(!e.length)return null;const[d,c]=g.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(xt,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((p,h)=>{const u=d===h;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...u?{boxShadow:r("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(u?null:h),style:{padding:"8px 12px",background:r("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.15s",transform:u?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(p.source)}),!u&&i&&p.title_info&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l(p.title_info)}),p.source_bid&&t.jsx("span",{onClick:m=>m.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(wt,{id:p.source_bid,label:a.action.view,onNavigate:o,renderLink:s})})]}),u&&t.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${r("widget-border")}`},children:[i&&(p.title_info||p.author_info||p.edition)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[p.title_info&&t.jsx($t,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx($t,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx($t,{label:a.label.edition,children:l(p.edition)})]}),p.summary&&t.jsxs("div",{style:{marginTop:"6px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.summary}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:l(p.summary)})]}),p.comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.comment}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.comment)})]}),p.additional_comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.additionalComment}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.additional_comment)})]})]})]},h)})})]})}function ym({items:e,onNavigate:n,renderLink:i}){const o=Ee();return t.jsx(zl,{items:e,label:o.section.indexed,showMeta:!0,onNavigate:n,renderLink:i})}function Nl({items:e,onNavigate:n,renderLink:i}){const o=Ee();return t.jsx(zl,{items:e,label:o.section.emendated,onNavigate:n,renderLink:i})}function Il({label:e,items:n}){const{convert:i}=Pe();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(xt,{children:e}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:n.map((o,s)=>{const a=typeof o=="string"?o:o.book_title;return t.jsx("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:r("fg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:i(a)},s)})})]}):null}function jm({items:e}){const n=Ee();return t.jsx(Il,{label:n.section.aliases,items:e})}function vm({items:e}){const n=Ee();return t.jsx(Il,{label:n.section.attachedTexts,items:e})}function km({items:e}){const n=Ee(),{convert:i}=Pe();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(xt,{children:n.section.appendix}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:e.map((o,s)=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:r("fg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:["《",i(o.book_title),"》",o.n_juan!=null&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:[o.n_juan,n.unit.juan]})]},s))})]}):null}function wm({items:e}){const n=Ee(),{convert:i}=Pe();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(xt,{children:n.section.locationHistory}),t.jsxs("div",{style:{position:"relative",paddingLeft:"18px"},children:[t.jsx("div",{style:{position:"absolute",left:"4px",top:"6px",bottom:"6px",width:"1px",background:r("widget-border")}}),e.map((o,s)=>t.jsxs("div",{style:{position:"relative",marginBottom:"10px"},children:[t.jsx("div",{style:{position:"absolute",left:"-16px",top:"5px",width:"7px",height:"7px",borderRadius:"50%",background:r("primary"),border:`1.5px solid ${r("input-bg")}`}}),t.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:r("fg")},children:i(o.name)}),o.description&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),marginLeft:"8px"},children:i(o.description)})]},s))]})]}):null}function Sm({items:e}){const n=Ee(),{convert:i}=Pe();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(xt,{children:n.section.historyOverview}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map((o,s)=>t.jsxs("div",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[t.jsx("span",{style:{position:"absolute",left:0,top:0,color:r("desc-fg")},children:"·"}),i(o)]},s))})]}):null}function Ps({title:e,ids:n,transport:i,onNavigate:o,renderLink:s}){const{convert:a}=Pe(),[l,d]=g.useState([]);return g.useEffect(()=>{if(!n.length){d([]);return}if(!i){d(n.map(p=>({id:p})));return}let c=!1;return Promise.all(n.map(p=>i.getItem(p).then(h=>({id:p,title:h?h.title:void 0,edition:h?h.edition:void 0,type:h?h.type:void 0})).catch(()=>({id:p})))).then(p=>{c||d(p)}),()=>{c=!0}},[n,i]),n.length?t.jsxs(t.Fragment,{children:[t.jsxs(xt,{children:[e,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",n.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:(l.length?l:n.map(c=>({id:c}))).map(c=>{const p=c.edition?`${a(c.title)||c.id}(${a(c.edition)})`:a(c.title)||void 0;return t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),transition:"border-color 0.15s"},children:t.jsx(wt,{id:c.id,label:p,onNavigate:o,renderLink:s})},c.id)})})]}):null}function or({book:e,onNavigate:n,renderLink:i}){const o=Ee(),{convert:s}=Pe(),[a,l]=g.useState(!1),d=e.resources&&e.resources.length>0,c=e.edition?s(e.edition):s(e.title)||void 0;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:r("input-bg")},children:[t.jsxs("div",{style:{padding:"6px 12px",borderBottom:d&&!a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:t.jsx(wt,{id:e.id,label:c,onNavigate:n,renderLink:i})}),d&&t.jsx("span",{onClick:()=>l(p=>!p),style:{cursor:"pointer",fontSize:"10px",color:r("desc-fg"),userSelect:"none",transition:"transform 0.15s",transform:a?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:a?o.action.expand:o.action.collapse,children:"▼"})]}),d&&!a&&t.jsx("div",{style:{padding:"10px 14px"},children:t.jsx(Zr,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:i})})]})}function _m({ids:e,workData:n,transport:i,onNavigate:o,renderLink:s,footer:a}){const l=Ee(),{convert:d}=Pe(),[c,p]=g.useState([]);if(g.useEffect(()=>{if(!e.length){p([]);return}if(!i){p(e.map(v=>({id:v})));return}let x=!1;return Promise.all(e.map(v=>i.getItem(v).then(y=>({id:v,title:y?y.title:void 0,edition:y?y.edition:void 0,resources:y?y.resources:void 0,resource_groups:y?y.resource_groups:void 0})).catch(()=>({id:v})))).then(v=>{x||p(v)}),()=>{x=!0}},[e,i]),!e.length)return null;const h=c.length?c:e.map(x=>({id:x})),u=new Map(h.map(x=>[x.id,x])),m=n==null?void 0:n.version_graph,f=$m(e,m,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(xt,{children:[l.section.relatedVersions,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",e.length,")"]})]}),a,f.useGrouping?t.jsxs(t.Fragment,{children:[f.coreIds.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:f.coreIds.map(x=>{const v=u.get(x);return v?t.jsx(or,{book:v,onNavigate:o,renderLink:s},x):null})}),f.groupedIds.map(x=>t.jsxs("details",{style:{marginTop:12,border:`1px solid ${r("widget-border")}`,borderRadius:6,background:r("bg-subtle")},children:[t.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:r("fg"),userSelect:"none"},children:[d(x.label),t.jsxs("span",{style:{marginLeft:6,fontSize:12,color:r("desc-fg"),fontWeight:400},children:["(",x.ids.length,")"]}),x.description&&t.jsx("span",{style:{marginLeft:8,fontSize:12,color:r("desc-fg"),fontWeight:400},children:d(x.description)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"0 12px 12px"},children:x.ids.map(v=>{const y=u.get(v);return y?t.jsx(or,{book:y,onNavigate:o,renderLink:s},v):null})})]},x.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:h.map(x=>t.jsx(or,{book:x,onNavigate:o,renderLink:s},x.id))})]})}function $m(e,n,i){var S,b;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const o=(S=n.collections)==null?void 0:S[n.default_collection],s=(o==null?void 0:o.groups)??[],a=(o==null?void 0:o.book_ids)??[],l=s.length>0||a.length>0,d=!l&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!l&&d.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const c=new Set(s),p=new Set([...a,...d]),h=w=>{if(p.has(w))return!0;const j=n.node_groups[w];return j!=null&&c.has(j)},u=[],m=new Map,f=[];for(const w of e)if(!((b=n.excluded_books)!=null&&b.includes(w)))if(h(w))u.push(w);else{const j=n.node_groups[w];j?(m.has(j)||m.set(j,[]),m.get(j).push(w)):f.push(w)}if(f.length+[...m.values()].reduce((w,j)=>w+j.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const v=new Map((n.groups??[]).map(w=>[w.id,w])),y=[...m.entries()].map(([w,j])=>{const k=v.get(w);return{id:w,label:(k==null?void 0:k.label)??w,description:k==null?void 0:k.description,ids:j}});return f.length>0&&y.push({id:"__other__",label:i,description:void 0,ids:f}),{useGrouping:!0,coreIds:u,groupedIds:y}}function Cm({workData:e,onNavigate:n,renderLink:i}){var l,d,c,p;const o=Ee(),{convert:s}=Pe(),a=!!((l=e.description)!=null&&l.text)||!!e.parent_work;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:r("input-bg"),marginTop:"4px"},children:[t.jsxs("div",{style:{padding:"6px 14px",borderBottom:a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`},children:[t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:r("fg")},children:t.jsx(wt,{id:e.id,label:s(e.title),onNavigate:n,renderLink:i})}),e.measure_info?t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg")},children:s(e.measure_info)}):((d=e.juan_count)==null?void 0:d.number)!=null&&e.juan_count.number>0?t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg")},children:[$l(e.juan_count.number),o.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(Tl,{authors:e.authors,type:"work",onNavigate:n,renderLink:i})})]}),a&&t.jsxs("div",{style:{padding:"8px 14px"},children:[((c=e.description)==null?void 0:c.text)&&t.jsx(Pt,{text:e.description.text,style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,textAlign:"justify"}}),e.parent_work&&t.jsx("div",{style:{marginTop:(p=e.description)!=null&&p.text?"8px":0,fontSize:"13px"},children:t.jsx($t,{label:o.label.parentWork,children:t.jsx(wt,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:i})})})]})]})}function Tm({items:e,onNavigate:n,renderLink:i}){const o=Ee(),{convert:s}=Pe();return e.length?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"6px"},children:e.map(a=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid color-mix(in srgb, ${r("type-collection")} 25%, transparent)`,borderRadius:"4px",background:`color-mix(in srgb, ${r("type-collection")} 3%, transparent)`},children:[t.jsx("span",{style:{fontSize:"11px",color:r("type-collection")},children:o.indexType.collection}),t.jsx(wt,{id:a.id,label:s(a.title)||a.id,onNavigate:n,renderLink:i}),a.volume_index!=null&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),marginLeft:"2px"},children:gt(o.catalog.volume,{n:a.volume_index})})]},a.id))}):null}const to=({data:e,id:n,transport:i,onNavigate:o,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var B,W,N,A,F,Y,ee,se;const p=Ee(),{convert:h}=Pe(),[u,m]=g.useState(null),[f,x]=g.useState(!1),[v,y]=g.useState(null),[S,b]=g.useState(null),[w,j]=g.useState([]),k=e||u;if(g.useEffect(()=>{if(e||!n||!i)return;let D=!1;return x(!0),y(null),i.getItem(n).then(V=>{D||(V?m(V):y(p.misc.notFoundEntry))}).catch(V=>{D||y(V instanceof Error?V.message:p.misc.loadFailed)}).finally(()=>{D||x(!1)}),()=>{D=!0}},[e,n,i]),g.useEffect(()=>{if(!k||!i){b(null),j([]);return}let D=!1;const V=k.type==="book"||k.type==="collection"?k.work_id:void 0;if(V?i.getItem(V).then(he=>{!D&&he&&he.type==="work"&&b(he)}).catch(()=>{}):b(null),k.type==="book"){const he=k;he.contained_in&&he.contained_in.length>0?Promise.all(he.contained_in.map(Z=>{const M=typeof Z=="string"?Z:Z.id,_e=typeof Z=="string"?void 0:Z.volume_index;return i.getItem(M).then(ce=>({id:M,title:ce&&ce.title||M,volume_index:_e})).catch(()=>({id:M,title:M,volume_index:_e}))})).then(Z=>{D||j(Z)}):j([])}else j([]);return()=>{D=!0}},[k,i]),f)return t.jsx("div",{className:d,style:{...c,padding:"24px"},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((D,V)=>t.jsx("div",{style:{height:V===1?"32px":"16px",width:`${D}px`,background:r("widget-border"),borderRadius:"4px",opacity:.4}},V))})});if(v)return t.jsx("div",{className:d,style:{...c,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:v});if(!k)return null;if(k.type==="entity")return t.jsx("div",{className:d,style:c,children:t.jsx(Sl,{data:k,transport:i,onNavigate:o,renderLink:s,headerExtra:a})});const $=k.type==="book"?k:null,C=k.type==="collection"?k:null,_=k.type==="work"?k:null;let E=!1;try{E=Se.extractStatus(k.id)==="draft"}catch{}let z="";k.measure_info?z=h(k.measure_info):(B=k.juan_count)!=null&&B.number?z=$l(k.juan_count.number)+p.unit.juan:(W=k.juan_count)!=null&&W.description&&(z=h(k.juan_count.description));const T=[];return(N=k.publication_info)!=null&&N.year&&T.push(t.jsx($t,{label:p.label.year,children:k.publication_info.year},"year")),(A=k.current_location)!=null&&A.name&&T.push(t.jsx($t,{label:p.label.currentLocation,children:h(k.current_location.name)},"loc")),(F=k.page_count)!=null&&F.description&&T.push(t.jsx($t,{label:p.label.pageCount,children:k.page_count.description},"page")),$!=null&&$.edition&&T.push(t.jsx($t,{label:p.label.edition,children:h($.edition)},"ver")),_!=null&&_.parent_work&&T.push(t.jsx($t,{label:p.label.parentWork,children:t.jsx(wt,{id:_.parent_work.id,label:h(_.parent_work.title),onNavigate:o,renderLink:s})},"pw")),_!=null&&_.parent_works&&_.parent_works.length>0&&!_.parent_work&&T.push(t.jsx($t,{label:p.label.parentWork,children:_.parent_works.map((D,V)=>t.jsxs("span",{children:[V>0&&"、",t.jsx(wt,{id:D,onNavigate:o,renderLink:s})]},D))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(bm,{id:k.id,title:h(k.title),edition:k.edition?h(k.edition):void 0,type:k.type,isDraft:E,authors:k.authors,volumeText:z,meta:T,headerExtra:a,onNavigate:o,renderLink:s}),((Y=k.description)==null?void 0:Y.text)&&t.jsx(Pt,{text:k.description.text,style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),k.appendix&&k.appendix.length>0&&t.jsx("div",{style:{marginTop:8,marginBottom:4},children:k.appendix.map((D,V)=>t.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:r("bg-subtle"),borderRadius:4,border:`1px solid ${r("widget-border")}`},children:[t.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:r("muted")},children:h(D.title)}),t.jsx(Pt,{text:D.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:r("fg")}})]},V))}),w.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(xt,{children:p.section.containedIn}),t.jsx(Tm,{items:w,onNavigate:o,renderLink:s})]}),S&&t.jsxs(t.Fragment,{children:[t.jsx(xt,{children:p.section.belongsToWork}),t.jsx(Cm,{workData:S,onNavigate:o,renderLink:s})]}),k.additional_works&&k.additional_works.length>0&&t.jsx(km,{items:k.additional_works}),k.additional_titles&&k.additional_titles.length>0&&t.jsx(jm,{items:k.additional_titles}),k.attached_texts&&k.attached_texts.length>0&&t.jsx(vm,{items:k.attached_texts}),k.indexed_by&&k.indexed_by.length>0&&t.jsx(ym,{items:k.indexed_by,onNavigate:o,renderLink:s}),k.emendated_by&&k.emendated_by.length>0&&t.jsx(Nl,{items:k.emendated_by,onNavigate:o,renderLink:s}),k.resources&&k.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(xt,{children:p.section.resources}),t.jsx(Zr,{items:k.resources,resourceGroups:k.resource_groups,groupByType:!0,onNavigate:o,renderLink:s})]}),($==null?void 0:$.location_history)&&$.location_history.length>0&&t.jsx(wm,{items:$.location_history}),(C==null?void 0:C.history)&&C.history.length>0&&t.jsx(Sm,{items:C.history}),($==null?void 0:$.related_books)&&$.related_books.length>0&&t.jsx(Ps,{title:p.section.relatedVersions,ids:$.related_books,transport:i,onNavigate:o,renderLink:s}),(C==null?void 0:C.books)&&C.books.length>0&&t.jsx(Ps,{title:p.section.containedBooks,ids:C.books,transport:i,onNavigate:o,renderLink:s}),(C==null?void 0:C.contained_works)&&C.contained_works.length>0&&t.jsxs("div",{children:[t.jsxs(xt,{children:[p.section.containedWorks,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",C.contained_works.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:C.contained_works.map(D=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:t.jsx(wt,{id:D.id,label:h(D.title),onNavigate:o,renderLink:s})},D.id))})]}),(((ee=_==null?void 0:_.books)==null?void 0:ee.length)||0)+(((se=_==null?void 0:_.collections)==null?void 0:se.length)||0)>0&&t.jsx(_m,{ids:[...(_==null?void 0:_.books)||[],...(_==null?void 0:_.collections)||[]],workData:_??void 0,transport:i,onNavigate:o,renderLink:s,footer:l}),(_==null?void 0:_.related_works)&&_.related_works.length>0&&(()=>{const D=[],V=_.related_works.filter(ge=>ge.relation==="part_of"),he=_.related_works.filter(ge=>ge.relation==="has_part"),Z=_.related_works.filter(ge=>ge.relation==="has_adaptation"),M=_.related_works.filter(ge=>ge.relation==="text_carried_by"),_e=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),ce=_.related_works.filter(ge=>!ge.relation||!_e.has(ge.relation));return V.length>0&&D.push({label:p.section.belongsToWork,items:V}),he.length>0&&D.push({label:p.section.containedWorks,items:he}),Z.length>0&&D.push({label:p.section.adaptations,items:Z}),M.length>0&&D.push({label:p.section.derivativeWorks,items:M}),ce.length>0&&D.push({label:p.section.relatedWorks,items:ce}),D.map(ge=>t.jsxs("div",{children:[t.jsxs(xt,{children:[ge.label,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",ge.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:ge.items.map(le=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:t.jsx(wt,{id:le.id,label:h(le.title),onNavigate:o,renderLink:s})},le.id))})]},ge.label))})()]})};function zm({data:e}){const n=Ee(),{convert:i}=Pe(),{stats:o}=e,s=o.processed_volumes??o.total_found_volumes,a=s!=null&&e.total_volumes>0?Math.round(s/e.total_volumes*100):null;return t.jsxs("div",{style:{marginBottom:"24px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:r("fg"),margin:"0 0 8px"},children:i(e.title)}),e.resource_name&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"6px"},children:i(e.resource_name)}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:r("desc-fg")},children:[t.jsxs("span",{children:[n.catalog.totalVolumes," ",t.jsx("strong",{style:{color:r("fg")},children:e.total_volumes})," ",n.unit.volume]}),a!=null&&t.jsxs("span",{children:[n.catalog.processed," ",t.jsx("strong",{style:{color:r("fg")},children:s})," ",n.unit.volume," (",a,"%)"]}),t.jsxs("span",{children:[n.catalog.contains," ",t.jsx("strong",{style:{color:r("fg")},children:o.total_books})," ",n.unit.bu]}),o.matched_works!=null&&o.matched_works>0&&t.jsxs("span",{children:[n.catalog.matched," ",t.jsx("strong",{style:{color:r("fg")},children:o.matched_works})," ",n.unit.bu]}),o.unmatched_works!=null&&o.unmatched_works>0&&t.jsxs("span",{children:[n.catalog.unmatched," ",t.jsx("strong",{style:{color:r("missing-fg")},children:o.unmatched_works})," ",n.unit.bu]})]}),e.source&&t.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:r("desc-fg")},children:[n.catalog.source," ",e.source]})]})}function Nm({sections:e,activeSection:n,onSelect:i}){const o=Ee();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>i(null),style:Bs(n===null),children:o.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>i(s.name),style:Bs(n===s.name),children:[s.name,s.volume_range&&t.jsxs("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"4px"},children:[s.volume_range[0],"–",s.volume_range[1]]})]},s.name))]})}function Bs(e){return{padding:"4px 12px",border:e?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:e?`color-mix(in srgb, ${r("primary")} 8%, transparent)`:"transparent",color:r(e?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}function Im({id:e,label:n,onNavigate:i,renderLink:o}){const s=tt();return o?t.jsx(t.Fragment,{children:o(e,n)}):i?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i(e))},style:{color:r("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`,paddingBottom:"1px",fontSize:"12px"},onMouseEnter:a=>a.currentTarget.style.borderBottomStyle="solid",onMouseLeave:a=>a.currentTarget.style.borderBottomStyle="dashed",children:n||e}):t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg")},children:n||e})}function Rm(e,n){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const i=e[0],o=e[e.length-1];return o-i+1===e.length?`${i}–${o}`:e.length<=3?e.join(", "):`${i}–${o} (${e.length}${n})`}function Ws({book:e,onNavigate:n,renderLink:i,showVolumes:o}){const s=Ee(),{convert:a}=Pe(),l=e.book_id||e.work_id,d=o&&e.volumes.length>0?Rm(e.volumes,s.unit.volume):null,c=e.missing_volumes&&e.missing_volumes.length>0;return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",padding:"6px 12px",borderBottom:`1px solid ${r("widget-border")}`,fontSize:"14px",lineHeight:1.8},children:[o&&t.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:r("desc-fg"),textAlign:"right"},children:d}),t.jsxs("span",{style:{flex:1,fontWeight:500,color:r("fg")},children:[a(e.title),e.sub_items&&e.sub_items.length>0&&t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400,marginLeft:"6px"},children:["(",e.sub_items.map(p=>a(p)).join("、"),")"]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),fontWeight:400,marginLeft:"8px"},children:a(e.edition)})]}),e.expected_volumes!=null&&t.jsxs("span",{style:{fontSize:"11px",color:r(c?"missing-fg":"desc-fg"),flexShrink:0},children:[e.found_volumes??0,"/",e.expected_volumes,s.unit.volume]}),l&&t.jsx(Im,{id:l,label:e.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:i}),!l&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const no=({data:e,collectionId:n,transport:i,onNavigate:o,renderLink:s,className:a,style:l})=>{const d=Ee(),[c,p]=g.useState(null),[h,u]=g.useState(!1),[m,f]=g.useState(null),[x,v]=g.useState(null),[y,S]=g.useState(""),b=e||c;g.useEffect(()=>{if(e||!n||!(i!=null&&i.getCollectionCatalog))return;let C=!1;return u(!0),f(null),i.getCollectionCatalog(n).then(_=>{C||(_?p(_):f(d.catalog.notFound))}).catch(_=>{C||f(_ instanceof Error?_.message:d.catalog.loadFailed)}).finally(()=>{C||u(!1)}),()=>{C=!0}},[e,n,i,d]);const w=(b==null?void 0:b.sections)&&b.sections.length>0,j=g.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const C=b.books.map(E=>E.volumes[0]).filter(E=>E!=null);return new Set(C).size<C.length},[b]),k=g.useMemo(()=>{if(!b)return[];let C=b.books;if(x&&(C=C.filter(_=>_.section===x)),y.trim()){const _=y.trim().toLowerCase();C=C.filter(E=>E.title.toLowerCase().includes(_)||E.sub_items&&E.sub_items.some(z=>z.toLowerCase().includes(_))||E.edition&&E.edition.toLowerCase().includes(_))}return C},[b,x,y]),$=g.useMemo(()=>{if(!j)return null;const C=[],_=new Map;for(const z of k){if(!z.volumes||z.volumes.length===0)continue;const T=z.volumes[0];_.has(T)||_.set(T,[]),_.get(T).push(z)}const E=[..._.keys()].sort((z,T)=>z-T);for(const z of E)C.push({volume:z,books:_.get(z)});return C},[k,j]);return h?t.jsx("div",{className:a,style:{...l,padding:"24px"},children:t.jsx("div",{style:{color:r("desc-fg"),fontSize:"13px"},children:d.catalog.loading})}):m?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:m}):b?t.jsxs("div",{className:a,style:l,children:[t.jsx(zm,{data:b}),w&&t.jsx(Nm,{sections:b.sections,activeSection:x,onSelect:v}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:d.search.searchBookName,value:y,onChange:C=>S(C.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"}}),t.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:r("desc-fg")},children:[k.length," ",d.unit.bu]})]}),t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[$?$.map((C,_)=>t.jsxs("div",{children:[t.jsx("div",{style:{padding:"4px 12px",background:r("bg"),borderBottom:`1px solid ${r("widget-border")}`,fontSize:"12px",fontWeight:600,color:r("desc-fg"),position:"sticky",top:0,zIndex:1},children:gt(d.catalog.volume,{n:C.volume})}),C.books.map((E,z)=>t.jsx(Ws,{book:E,onNavigate:o,renderLink:s,showVolumes:E.volumes.length>1},`${C.volume}-${z}`))]},`${C.volume}-${_}`)):k.map((C,_)=>t.jsx(Ws,{book:C,onNavigate:o,renderLink:s,showVolumes:!0},_)),k.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},sr=e=>e?e.catch(()=>null):Promise.resolve(null);function Rl(e){const n=new Map;function i(o){var a;let s=n.get(o);return s||(s=sr((a=e.getTextManifest)==null?void 0:a.call(e,o)).then(l=>{const d=l&&Array.isArray(l.versions)&&l.versions.length>0?l:null;return d||n.delete(o),d}),n.set(o,s)),s}return{getManifest(o){return Se.isSafeSegment(o)?i(o):Promise.resolve(null)},async getIndex(o,s){return!Se.isSafeSegment(o)||!Se.isSafeSegment(s)||!e.getTextIndex?null:sr(e.getTextIndex(o,s))},async getChapter(o,s,a,l){return!Se.isSafeSegment(o)||!Se.isSafeSegment(s)||!Se.isSafeSegment(a)||!e.getChapter?null:sr(e.getChapter(o,s,a,l))}}}const nn=()=>{const{t:e}=ne(),[n,i]=g.useState(1);return g.useEffect(()=>{const o=setInterval(()=>i(s=>s>=3?1:s+1),500);return()=>clearInterval(o)},[]),t.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:r("desc-fg"),fontSize:"14px"},children:e("common.loading")+".".repeat(n)})},ar=String.raw`https?:\/\/[^\s()()<>"]+`,Em=new RegExp(String.raw`\[([^\]\n]+)\]\((${ar})\)`+String.raw`|(《[^》\n]+》)\s?[((](${ar})[))]`+`|(${ar})`,"g");function Lm(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function Am(e){const n=[];let i=0;for(const o of e.matchAll(Em)){const s=o.index??0;s>i&&n.push({text:e.slice(i,s)}),o[1]!==void 0?n.push({text:o[1],url:o[2]}):o[3]!==void 0?n.push({text:o[3],url:o[4]}):n.push({text:Lm(o[5]),url:o[5]}),i=s+o[0].length}return i<e.length&&n.push({text:e.slice(i)}),n}function El({text:e,convert:n,className:i="bim-rd-link"}){return t.jsx(t.Fragment,{children:Am(e).map((o,s)=>o.url?t.jsx("a",{className:i,href:o.url,target:"_blank",rel:"noopener noreferrer",children:n(o.text)},s):t.jsx(g.Fragment,{children:n(o.text)},s))})}const Ll="(min-width: 1100px)",Al="(max-width: 719px)",Ml="(max-width: 859px)",Mm=`${Al}, (pointer: coarse)`,_t=r("reader-top"),Pm="48px",Pl=`
|
|
145
|
+
}`,Sl={color:"inherit",textDecoration:"none"},nm=({snippet:e})=>{const{convert:n}=Pe();return t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.6},children:Vr(e).map((i,o)=>i.marked?t.jsx("mark",{style:{background:r("highlight-bg"),color:r("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(i.text)},o):t.jsx(g.Fragment,{children:n(i.text)},o))})},im=({entry:e,selected:n,onClick:i,getConfig:o,query:s})=>{const a=Ee(),{convert:l}=Pe(),d=l(e.title||e.primary_name||e.id),c=e.measure_info?l(e.measure_info):e.juan_count!=null&&e.juan_count>0?`${e.juan_count}${a.unit.juan}`:"",p=[...e.additional_titles||[],...e.attached_texts||[]],h=s&&p.length?p.find(f=>{const x=typeof f=="string"?f:f==null?void 0:f.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,u=r("cover-accent"),m=tt();return t.jsxs("a",{href:m(e.id),onClick:f=>i(e,f),className:"bim-result-card",style:{...Sl,display:"flex",gap:"1.2rem",alignItems:"stretch",padding:"1.1rem 1.3rem",borderRadius:"12px",cursor:"pointer",background:r("bg"),border:n?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,transition:"border-color .2s ease, transform .2s ease, box-shadow .2s ease"},children:[t.jsxs("div",{"aria-hidden":"true",style:{position:"relative",width:"92px",minHeight:"126px",flexShrink:0,borderRadius:"4px",border:`1px solid color-mix(in srgb, ${u} 50%, ${r("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${u} 14%, ${r("bg")}), color-mix(in srgb, ${u} 7%, ${r("bg")}))`,display:"flex",alignItems:"center",justifyContent:"center",padding:"0.6rem 0.3rem"},children:[t.jsx("span",{style:{position:"absolute",left:"6px",top:0,bottom:0,borderLeft:`1px dashed color-mix(in srgb, ${u} 45%, transparent)`}}),t.jsx("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",height:"108px",flexShrink:0,overflow:"hidden",fontSize:"1.05rem",fontWeight:700,lineHeight:1.25,color:u},children:Array.from(d).map((f,x)=>t.jsx("span",{children:f},x))})]}),t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"17px",fontWeight:600,color:r("fg")},children:d}),c&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg")},children:c})]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"13px",color:r("desc-fg")},children:[e.dynasty&&t.jsxs("span",{children:["〔",l(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:l(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",l(e.role)]})]}),(e.era||e.edition)&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg")},children:[e.era&&t.jsxs("span",{children:["〔",l(e.era),"〕"]}),e.edition&&t.jsx("span",{children:l(e.edition)})]}),h&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg")},children:[a.search.alias,":",l(typeof h=="string"?h:h.book_title||"")]}),e.descriptionSnippet&&t.jsx(nm,{snippet:e.descriptionSnippet}),t.jsxs("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"auto",paddingTop:"4px"},children:[t.jsxs("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:[t.jsx(jn,{type:e.type,size:8})," ",o(e.type).name]}),e.has_text&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:a.misc.textResource}),e.has_image&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:a.misc.imageResource})]})]})]})},Ms=({entry:e,selected:n,onClick:i,getConfig:o,query:s,onRemove:a})=>{const l=Ee(),{convert:d}=Pe(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(u=>{const m=typeof u=="string"?u:u==null?void 0:u.book_title;return m==null?void 0:m.toLowerCase().includes(s.toLowerCase())}):void 0,h=tt();return t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",borderRadius:"6px",border:n?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("a",{href:h(e.id),onClick:u=>i(e,u),className:"bim-result-card",style:{...Sl,flex:1,minWidth:0,display:"flex",alignItems:"flex-start",gap:"10px",padding:a?"10px 0 10px 12px":"10px 12px",borderRadius:"6px",cursor:"pointer"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",marginTop:"2px"},children:[t.jsx(jn,{type:e.type,size:12}),t.jsx("span",{style:{fontSize:"9px",color:r("desc-fg"),lineHeight:1},children:o(e.type).name})]}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg")},children:d(e.title||e.primary_name||e.id)}),t.jsxs("span",{style:{display:"flex",gap:"2px",fontSize:"12px",opacity:.7},children:[e.has_text&&t.jsx("span",{children:l.misc.textResource}),e.has_image&&t.jsx("span",{children:l.misc.imageResource})]}),(e.era||e.edition)&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[e.era&&t.jsxs(t.Fragment,{children:["〔",d(e.era),"〕"]}),e.edition&&d(e.edition)]}),e.measure_info?t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:d(e.measure_info)}):e.juan_count!=null&&e.juan_count>0?t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[e.juan_count,l.unit.juan]}):null]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"2px"},children:[e.dynasty&&t.jsxs("span",{children:["〔",d(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:d(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",d(e.role)]}),e.type==="entity"&&(e.birth_year!=null||e.death_year!=null)&&t.jsxs("span",{style:{marginLeft:e.dynasty?"4px":0},children:[e.birth_year??"?","—",e.death_year??"?"]})]}),p&&t.jsxs("div",{style:{fontSize:"11px",color:r("desc-fg"),marginTop:"2px"},children:[l.search.alias,":",d(p)]})]}),!a&&t.jsx("span",{"aria-hidden":"true",style:{opacity:.4,marginTop:"2px"},children:"→"})]}),a&&t.jsx("button",{type:"button",onClick:()=>a(e.id),title:l.search.removeFromRecent,"aria-label":l.search.removeFromRecent,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"12px 12px 12px 8px",lineHeight:1,opacity:.5},children:"×"})]})},rm=({id:e,onRemove:n,t:i})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${r("widget-border")}`,background:r("input-bg"),opacity:.6},children:[t.jsx("span",{style:{fontSize:"16px"},children:"❓"}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:"13px",color:r("fg"),fontFamily:"monospace"},children:e}),t.jsx("div",{style:{fontSize:"11px",color:r("desc-fg"),marginTop:"2px"},children:i.search.itemNotFound})]}),t.jsx("button",{onClick:()=>n(e),title:i.search.removeFromRecent,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"2px 4px",lineHeight:1},children:"×"})]});function om(e){var n;return!e.dynasty&&!e.birth_year&&!e.death_year&&(!e.alt_names||e.alt_names.length===0)&&!((n=e.description)!=null&&n.text)}function sm({data:e}){const{convert:n}=Pe(),{dynasty:i,birth_year:o,death_year:s}=e,a=[];return i&&a.push(`〔${n(i)}〕`),o!==void 0&&s!==void 0?a.push(`${o}—${s}`):o!==void 0?a.push(`${o}—?`):s!==void 0&&a.push(`?—${s}`),a.length===0?null:t.jsx("span",{style:{fontSize:"14px",color:r("desc-fg"),marginLeft:"8px",fontWeight:"normal"},children:a.join(" ")})}function am({alt_names:e}){const{convert:n}=Pe(),i=new Map;for(const a of e){const l=a.type||"別名";i.has(l)||i.set(l,[]),i.get(l).push(a.name)}const o=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...i.keys()].sort((a,l)=>{const d=o.indexOf(a),c=o.indexOf(l);return d===-1&&c===-1?0:d===-1?1:c===-1?-1:d-c});return t.jsx("div",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(a=>{const l=i.get(a);return t.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[t.jsx("span",{style:{color:r("desc-fg"),fontSize:"12px",minWidth:"36px",paddingTop:"2px"},children:n(a)}),t.jsx("span",{children:l.map((d,c)=>t.jsxs("span",{children:[c>0&&t.jsx("span",{style:{color:r("desc-fg"),margin:"0 4px"},children:"·"}),n(d)]},c))})]},a)})})}function lm({data:e}){const n=Ee(),i=e.external_ids;if(!i)return null;const o=[];return i.cbdb_id&&o.push(t.jsxs("a",{href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${i.cbdb_id}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"2px 8px",fontSize:"12px",color:r("link-fg"),border:`1px solid ${r("link-fg")}40`,borderRadius:"3px",textDecoration:"none",background:`${r("link-fg")}08`},title:n.common.cbdbTitle,children:["CBDB ",i.cbdb_id]},"cbdb")),o.length===0?null:t.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:o})}function cm({works:e,transport:n,onNavigate:i,renderLink:o}){const s=Ee(),{convert:a}=Pe(),l=tt(),[d,c]=g.useState(new Map);g.useEffect(()=>{if(!n)return;let m=!1;const f=e.map(v=>v.work_id);return(async()=>{const v=new Map;if(n.getEntriesByIds)try{const w=await n.getEntriesByIds(f);let j=!0;for(let k=0;k<f.length;k++){const $=w[k];$!=null&&$.title?v.set(f[k],$.title):$!=null&&$.primary_name?v.set(f[k],$.primary_name):j=!1}if(j)return v}catch{}const y=[...f],S=8,b=new Array(S).fill(0).map(async()=>{for(;y.length;){const w=y.shift();if(!w)break;if(!v.has(w))try{if(n.getEntry){const $=await n.getEntry(w);if($!=null&&$.title){v.set(w,$.title);continue}}const j=await n.getItem(w),k=j&&(j.title||j.primary_name)||w;v.set(w,k)}catch{v.set(w,w)}}});return await Promise.all(b),v})().then(v=>{m||c(v)}),()=>{m=!0}},[e,n]);const p=new Map;for(const m of e){const f=m.role||"";p.has(f)||p.set(f,[]),p.get(f).push(m)}const h=["撰","編","注","輯","集","校","評","譯","述","作",""],u=[...p.keys()].sort((m,f)=>{const x=h.indexOf(m),v=h.indexOf(f);return x===-1&&v===-1?m.localeCompare(f):x===-1?1:v===-1?-1:x-v});return t.jsxs("div",{style:{marginTop:"12px"},children:[t.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:r("fg"),margin:"0 0 8px",paddingBottom:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[s.label.relatedWorks," ",t.jsxs("span",{style:{color:r("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",e.length,")"]})]}),u.map(m=>{const f=p.get(m);return t.jsxs("div",{style:{marginBottom:"8px"},children:[m&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"2px"},children:[a(m)," ",t.jsxs("span",{style:{color:r("desc-fg")},children:["(",f.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:m?"16px":"0",listStyle:m?"disc":"none",fontSize:"14px",lineHeight:1.8},children:f.map((x,v)=>{const y=a(d.get(x.work_id)||x.work_id);return o?t.jsx("li",{children:o(x.work_id,y)},v):i?t.jsx("li",{children:t.jsx("a",{href:l(x.work_id),onClick:S=>{S.metaKey||S.ctrlKey||(S.preventDefault(),i(x.work_id))},style:{color:r("link-fg"),textDecoration:"underline",cursor:"pointer"},children:y})},v):t.jsx("li",{children:y},v)})})]},m)})]})}const _l=({data:e,transport:n,onNavigate:i,renderLink:o,headerExtra:s,hideHeader:a})=>{var u;const l=Ee(),{convert:d}=Pe();let c=!1;try{c=Se.extractStatus(e.id)==="draft"}catch{}const p=om(e),h=e.subtype&&e.subtype in l.common.entitySubtype?l.common.entitySubtype[e.subtype]:d(e.subtype);return t.jsxs("div",{children:[!a&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"4px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:600,margin:0,lineHeight:1.3,color:r("fg")},children:[d(e.primary_name),t.jsx(sm,{data:e})]}),s]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:r("type-entity"),border:`1px solid color-mix(in srgb, ${r("type-entity")} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${r("type-entity")} 3%, transparent)`},children:l.indexType.entity}),h&&e.subtype!=="people"&&t.jsx("span",{children:h}),c&&t.jsx("span",{style:{padding:"1px 6px",background:r("warn-bg"),border:`1px solid ${r("warn-border")}`,borderRadius:"2px",color:r("warn-fg")},children:l.status.draft}),t.jsx("span",{style:{fontFamily:"monospace",opacity:.6},children:e.id})]})]}),p&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),fontStyle:"italic",padding:"8px 12px",background:r("widget-bg"),border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",margin:"8px 0"},children:l.common.entityPlaceholderNote}),e.alt_names&&e.alt_names.length>0&&t.jsx(am,{alt_names:e.alt_names}),t.jsx(lm,{data:e}),((u=e.description)==null?void 0:u.text)&&t.jsx("p",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:d(e.description.text)}),e.works&&e.works.length>0&&t.jsx(cm,{works:e.works,transport:n,onNavigate:i,renderLink:o})]})},dm=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function pm(e){const n=e.search(dm);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const $l={p:({children:e})=>t.jsx("p",{style:{margin:"0 0 0.5em"},children:e}),ul:({children:e})=>t.jsx("ul",{style:{margin:"0 0 0.5em",paddingLeft:"1.4em"},children:e}),ol:({children:e})=>t.jsx("ol",{style:{margin:"0 0 0.5em",paddingLeft:"1.6em"},children:e}),li:({children:e})=>t.jsx("li",{style:{marginBottom:"2px"},children:e}),a:({href:e,children:n})=>{let i=e,o="",s=n;if(e&&typeof n=="string"&&(n===e||n===um(e))){const[a,l]=pm(n);l&&(i=encodeURI(a),s=a,o=l)}return t.jsxs(t.Fragment,{children:[t.jsx("a",{href:i,target:i!=null&&i.startsWith("http")?"_blank":void 0,rel:i!=null&&i.startsWith("http")?"noopener noreferrer":void 0,style:{color:r("link")},children:s}),o]})},code:({children:e})=>t.jsx("code",{style:{background:r("bg-subtle"),padding:"1px 4px",borderRadius:3,fontSize:"0.92em"},children:e})};function um(e){try{return decodeURI(e)}catch{return e}}const mm={...$l,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},Pt=({text:e,plainStrong:n,style:i,className:o})=>{const{convert:s}=Pe(),a=n?mm:$l;return t.jsx("div",{className:o,style:i,children:t.jsx(Pp,{remarkPlugins:[Bp],components:a,children:s(e)})})},hm=["〇","一","二","三","四","五","六","七","八","九"],Ps=["","十","百","千"];function Cl(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),i=n.length;let o="",s=!1;for(let a=0;a<i;a++){const l=parseInt(n[a]),d=i-1-a;l===0?s=!0:(s&&o&&(o+="〇"),s=!1,l===1&&d===1&&a===0?o+=Ps[d]:o+=hm[l]+Ps[d])}return o}function Tl(e){return{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:e,border:`1px solid color-mix(in srgb, ${e} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${e} 3%, transparent)`}}const gm={book:r("type-book"),work:r("type-work"),collection:r("type-collection"),entity:r("type-entity")};function fm({type:e}){const n=Ee();return t.jsx("span",{style:Tl(gm[e]),children:n.indexType[e]})}function xm({isDraft:e}){const n=Ee(),i=r(e?"status-draft":"status-official");return t.jsx("span",{style:Tl(i),children:e?n.status.draft:n.status.official})}function bm({id:e}){const n=Ee(),[i,o]=g.useState(!1),s=()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})};return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:r("desc-fg"),background:r("bg-subtle"),border:`1px solid ${r("widget-border")}`,borderRadius:"2px"},children:[t.jsx("span",{children:n.label.id}),t.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:r("fg")},children:e}),t.jsx("span",{onClick:s,title:i?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"11px",opacity:i?1:.5,transition:"opacity 0.15s"},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity=i?"1":"0.5",children:i?"✓":"⧉"})]})}function xt({children:e,extra:n}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"20px",marginBottom:"8px"},children:[t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:r("desc-fg"),letterSpacing:"1px"},children:e}),t.jsx("span",{style:{flex:1}}),n]})}function $t({label:e,children:n}){return t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[t.jsx("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:e}),t.jsx("span",{style:{color:r("fg")},children:n})]})}function zl({authors:e,type:n,onNavigate:i,renderLink:o}){const{convert:s}=Pe();return t.jsx("span",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.6},children:e.map((a,l)=>{const d=s(a.name),c=a.entity_id?t.jsx(wt,{id:a.entity_id,label:d,onNavigate:i,renderLink:o}):t.jsx("span",{style:{fontWeight:500},children:d});return t.jsxs("span",{children:[l>0&&t.jsx("span",{style:{color:r("desc-fg"),margin:"0 4px"},children:"·"}),a.dynasty&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:["〔",s(a.dynasty),"〕"]}),c,a.role&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px",marginLeft:"2px"},children:[" ",s(a.role)]})]},l)})})}function wt({id:e,label:n,onNavigate:i,renderLink:o}){const s=tt();return o?t.jsx(t.Fragment,{children:o(e,n)}):i?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i(e))},style:{color:r("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`,paddingBottom:"1px"},onMouseEnter:a=>a.currentTarget.style.borderBottomStyle="solid",onMouseLeave:a=>a.currentTarget.style.borderBottomStyle="dashed",children:n||e}):t.jsx("span",{children:n||e})}function ym({id:e,title:n,edition:i,type:o,isDraft:s,authors:a,volumeText:l,meta:d,headerExtra:c,onNavigate:p,renderLink:h}){return t.jsxs("div",{style:{marginBottom:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:700,color:r("fg"),margin:"0 0 6px",lineHeight:1.4,letterSpacing:"0.5px",wordBreak:"break-word",flex:1,minWidth:0},children:[n,i&&t.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:i}),l&&t.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:r("desc-fg"),marginLeft:"8px"},children:l})]}),c&&t.jsx("div",{style:{flexShrink:0,paddingTop:"2px"},children:c})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"4px"},children:[t.jsx(fm,{type:o}),t.jsx(xm,{isDraft:s}),t.jsx(bm,{id:e})]}),((a==null?void 0:a.length)||d.length>0)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"12px",marginTop:"6px"},children:[a&&a.length>0&&t.jsx(zl,{authors:a,type:o,onNavigate:p,renderLink:h}),d]})]})}function Nl({items:e,label:n,showMeta:i,onNavigate:o,renderLink:s}){const a=Ee(),{convert:l}=Pe();if(!e.length)return null;const[d,c]=g.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(xt,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((p,h)=>{const u=d===h;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...u?{boxShadow:r("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(u?null:h),style:{padding:"8px 12px",background:r("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.15s",transform:u?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(p.source)}),!u&&i&&p.title_info&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l(p.title_info)}),p.source_bid&&t.jsx("span",{onClick:m=>m.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(wt,{id:p.source_bid,label:a.action.view,onNavigate:o,renderLink:s})})]}),u&&t.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${r("widget-border")}`},children:[i&&(p.title_info||p.author_info||p.edition)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[p.title_info&&t.jsx($t,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx($t,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx($t,{label:a.label.edition,children:l(p.edition)})]}),p.summary&&t.jsxs("div",{style:{marginTop:"6px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.summary}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:l(p.summary)})]}),p.comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.comment}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.comment)})]}),p.additional_comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.additionalComment}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.additional_comment)})]})]})]},h)})})]})}function jm({items:e,onNavigate:n,renderLink:i}){const o=Ee();return t.jsx(Nl,{items:e,label:o.section.indexed,showMeta:!0,onNavigate:n,renderLink:i})}function Il({items:e,onNavigate:n,renderLink:i}){const o=Ee();return t.jsx(Nl,{items:e,label:o.section.emendated,onNavigate:n,renderLink:i})}function Rl({label:e,items:n}){const{convert:i}=Pe();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(xt,{children:e}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:n.map((o,s)=>{const a=typeof o=="string"?o:o.book_title;return t.jsx("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:r("fg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:i(a)},s)})})]}):null}function vm({items:e}){const n=Ee();return t.jsx(Rl,{label:n.section.aliases,items:e})}function km({items:e}){const n=Ee();return t.jsx(Rl,{label:n.section.attachedTexts,items:e})}function wm({items:e}){const n=Ee(),{convert:i}=Pe();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(xt,{children:n.section.appendix}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:e.map((o,s)=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:r("fg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:["《",i(o.book_title),"》",o.n_juan!=null&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:[o.n_juan,n.unit.juan]})]},s))})]}):null}function Sm({items:e}){const n=Ee(),{convert:i}=Pe();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(xt,{children:n.section.locationHistory}),t.jsxs("div",{style:{position:"relative",paddingLeft:"18px"},children:[t.jsx("div",{style:{position:"absolute",left:"4px",top:"6px",bottom:"6px",width:"1px",background:r("widget-border")}}),e.map((o,s)=>t.jsxs("div",{style:{position:"relative",marginBottom:"10px"},children:[t.jsx("div",{style:{position:"absolute",left:"-16px",top:"5px",width:"7px",height:"7px",borderRadius:"50%",background:r("primary"),border:`1.5px solid ${r("input-bg")}`}}),t.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:r("fg")},children:i(o.name)}),o.description&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),marginLeft:"8px"},children:i(o.description)})]},s))]})]}):null}function _m({items:e}){const n=Ee(),{convert:i}=Pe();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(xt,{children:n.section.historyOverview}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map((o,s)=>t.jsxs("div",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[t.jsx("span",{style:{position:"absolute",left:0,top:0,color:r("desc-fg")},children:"·"}),i(o)]},s))})]}):null}function Bs({title:e,ids:n,transport:i,onNavigate:o,renderLink:s}){const{convert:a}=Pe(),[l,d]=g.useState([]);return g.useEffect(()=>{if(!n.length){d([]);return}if(!i){d(n.map(p=>({id:p})));return}let c=!1;return Promise.all(n.map(p=>i.getItem(p).then(h=>({id:p,title:h?h.title:void 0,edition:h?h.edition:void 0,type:h?h.type:void 0})).catch(()=>({id:p})))).then(p=>{c||d(p)}),()=>{c=!0}},[n,i]),n.length?t.jsxs(t.Fragment,{children:[t.jsxs(xt,{children:[e,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",n.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:(l.length?l:n.map(c=>({id:c}))).map(c=>{const p=c.edition?`${a(c.title)||c.id}(${a(c.edition)})`:a(c.title)||void 0;return t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),transition:"border-color 0.15s"},children:t.jsx(wt,{id:c.id,label:p,onNavigate:o,renderLink:s})},c.id)})})]}):null}function or({book:e,onNavigate:n,renderLink:i}){const o=Ee(),{convert:s}=Pe(),[a,l]=g.useState(!1),d=e.resources&&e.resources.length>0,c=e.edition?s(e.edition):s(e.title)||void 0;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:r("input-bg")},children:[t.jsxs("div",{style:{padding:"6px 12px",borderBottom:d&&!a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:t.jsx(wt,{id:e.id,label:c,onNavigate:n,renderLink:i})}),d&&t.jsx("span",{onClick:()=>l(p=>!p),style:{cursor:"pointer",fontSize:"10px",color:r("desc-fg"),userSelect:"none",transition:"transform 0.15s",transform:a?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:a?o.action.expand:o.action.collapse,children:"▼"})]}),d&&!a&&t.jsx("div",{style:{padding:"10px 14px"},children:t.jsx(Zr,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:i})})]})}function $m({ids:e,workData:n,transport:i,onNavigate:o,renderLink:s,footer:a}){const l=Ee(),{convert:d}=Pe(),[c,p]=g.useState([]);if(g.useEffect(()=>{if(!e.length){p([]);return}if(!i){p(e.map(v=>({id:v})));return}let x=!1;return Promise.all(e.map(v=>i.getItem(v).then(y=>({id:v,title:y?y.title:void 0,edition:y?y.edition:void 0,resources:y?y.resources:void 0,resource_groups:y?y.resource_groups:void 0})).catch(()=>({id:v})))).then(v=>{x||p(v)}),()=>{x=!0}},[e,i]),!e.length)return null;const h=c.length?c:e.map(x=>({id:x})),u=new Map(h.map(x=>[x.id,x])),m=n==null?void 0:n.version_graph,f=Cm(e,m,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(xt,{children:[l.section.relatedVersions,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",e.length,")"]})]}),a,f.useGrouping?t.jsxs(t.Fragment,{children:[f.coreIds.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:f.coreIds.map(x=>{const v=u.get(x);return v?t.jsx(or,{book:v,onNavigate:o,renderLink:s},x):null})}),f.groupedIds.map(x=>t.jsxs("details",{style:{marginTop:12,border:`1px solid ${r("widget-border")}`,borderRadius:6,background:r("bg-subtle")},children:[t.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:r("fg"),userSelect:"none"},children:[d(x.label),t.jsxs("span",{style:{marginLeft:6,fontSize:12,color:r("desc-fg"),fontWeight:400},children:["(",x.ids.length,")"]}),x.description&&t.jsx("span",{style:{marginLeft:8,fontSize:12,color:r("desc-fg"),fontWeight:400},children:d(x.description)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"0 12px 12px"},children:x.ids.map(v=>{const y=u.get(v);return y?t.jsx(or,{book:y,onNavigate:o,renderLink:s},v):null})})]},x.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:h.map(x=>t.jsx(or,{book:x,onNavigate:o,renderLink:s},x.id))})]})}function Cm(e,n,i){var S,b;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const o=(S=n.collections)==null?void 0:S[n.default_collection],s=(o==null?void 0:o.groups)??[],a=(o==null?void 0:o.book_ids)??[],l=s.length>0||a.length>0,d=!l&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!l&&d.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const c=new Set(s),p=new Set([...a,...d]),h=w=>{if(p.has(w))return!0;const j=n.node_groups[w];return j!=null&&c.has(j)},u=[],m=new Map,f=[];for(const w of e)if(!((b=n.excluded_books)!=null&&b.includes(w)))if(h(w))u.push(w);else{const j=n.node_groups[w];j?(m.has(j)||m.set(j,[]),m.get(j).push(w)):f.push(w)}if(f.length+[...m.values()].reduce((w,j)=>w+j.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const v=new Map((n.groups??[]).map(w=>[w.id,w])),y=[...m.entries()].map(([w,j])=>{const k=v.get(w);return{id:w,label:(k==null?void 0:k.label)??w,description:k==null?void 0:k.description,ids:j}});return f.length>0&&y.push({id:"__other__",label:i,description:void 0,ids:f}),{useGrouping:!0,coreIds:u,groupedIds:y}}function Tm({workData:e,onNavigate:n,renderLink:i}){var l,d,c,p;const o=Ee(),{convert:s}=Pe(),a=!!((l=e.description)!=null&&l.text)||!!e.parent_work;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:r("input-bg"),marginTop:"4px"},children:[t.jsxs("div",{style:{padding:"6px 14px",borderBottom:a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`},children:[t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:r("fg")},children:t.jsx(wt,{id:e.id,label:s(e.title),onNavigate:n,renderLink:i})}),e.measure_info?t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg")},children:s(e.measure_info)}):((d=e.juan_count)==null?void 0:d.number)!=null&&e.juan_count.number>0?t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg")},children:[Cl(e.juan_count.number),o.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(zl,{authors:e.authors,type:"work",onNavigate:n,renderLink:i})})]}),a&&t.jsxs("div",{style:{padding:"8px 14px"},children:[((c=e.description)==null?void 0:c.text)&&t.jsx(Pt,{text:e.description.text,style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,textAlign:"justify"}}),e.parent_work&&t.jsx("div",{style:{marginTop:(p=e.description)!=null&&p.text?"8px":0,fontSize:"13px"},children:t.jsx($t,{label:o.label.parentWork,children:t.jsx(wt,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:i})})})]})]})}function zm({items:e,onNavigate:n,renderLink:i}){const o=Ee(),{convert:s}=Pe();return e.length?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"6px"},children:e.map(a=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid color-mix(in srgb, ${r("type-collection")} 25%, transparent)`,borderRadius:"4px",background:`color-mix(in srgb, ${r("type-collection")} 3%, transparent)`},children:[t.jsx("span",{style:{fontSize:"11px",color:r("type-collection")},children:o.indexType.collection}),t.jsx(wt,{id:a.id,label:s(a.title)||a.id,onNavigate:n,renderLink:i}),a.volume_index!=null&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),marginLeft:"2px"},children:gt(o.catalog.volume,{n:a.volume_index})})]},a.id))}):null}const to=({data:e,id:n,transport:i,onNavigate:o,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var B,W,N,A,F,Y,te,se;const p=Ee(),{convert:h}=Pe(),[u,m]=g.useState(null),[f,x]=g.useState(!1),[v,y]=g.useState(null),[S,b]=g.useState(null),[w,j]=g.useState([]),k=e||u;if(g.useEffect(()=>{if(e||!n||!i)return;let D=!1;return x(!0),y(null),i.getItem(n).then(V=>{D||(V?m(V):y(p.misc.notFoundEntry))}).catch(V=>{D||y(V instanceof Error?V.message:p.misc.loadFailed)}).finally(()=>{D||x(!1)}),()=>{D=!0}},[e,n,i]),g.useEffect(()=>{if(!k||!i){b(null),j([]);return}let D=!1;const V=k.type==="book"||k.type==="collection"?k.work_id:void 0;if(V?i.getItem(V).then(he=>{!D&&he&&he.type==="work"&&b(he)}).catch(()=>{}):b(null),k.type==="book"){const he=k;he.contained_in&&he.contained_in.length>0?Promise.all(he.contained_in.map(Z=>{const M=typeof Z=="string"?Z:Z.id,_e=typeof Z=="string"?void 0:Z.volume_index;return i.getItem(M).then(ce=>({id:M,title:ce&&ce.title||M,volume_index:_e})).catch(()=>({id:M,title:M,volume_index:_e}))})).then(Z=>{D||j(Z)}):j([])}else j([]);return()=>{D=!0}},[k,i]),f)return t.jsx("div",{className:d,style:{...c,padding:"24px"},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((D,V)=>t.jsx("div",{style:{height:V===1?"32px":"16px",width:`${D}px`,background:r("widget-border"),borderRadius:"4px",opacity:.4}},V))})});if(v)return t.jsx("div",{className:d,style:{...c,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:v});if(!k)return null;if(k.type==="entity")return t.jsx("div",{className:d,style:c,children:t.jsx(_l,{data:k,transport:i,onNavigate:o,renderLink:s,headerExtra:a})});const $=k.type==="book"?k:null,C=k.type==="collection"?k:null,_=k.type==="work"?k:null;let E=!1;try{E=Se.extractStatus(k.id)==="draft"}catch{}let z="";k.measure_info?z=h(k.measure_info):(B=k.juan_count)!=null&&B.number?z=Cl(k.juan_count.number)+p.unit.juan:(W=k.juan_count)!=null&&W.description&&(z=h(k.juan_count.description));const T=[];return(N=k.publication_info)!=null&&N.year&&T.push(t.jsx($t,{label:p.label.year,children:k.publication_info.year},"year")),(A=k.current_location)!=null&&A.name&&T.push(t.jsx($t,{label:p.label.currentLocation,children:h(k.current_location.name)},"loc")),(F=k.page_count)!=null&&F.description&&T.push(t.jsx($t,{label:p.label.pageCount,children:k.page_count.description},"page")),$!=null&&$.edition&&T.push(t.jsx($t,{label:p.label.edition,children:h($.edition)},"ver")),_!=null&&_.parent_work&&T.push(t.jsx($t,{label:p.label.parentWork,children:t.jsx(wt,{id:_.parent_work.id,label:h(_.parent_work.title),onNavigate:o,renderLink:s})},"pw")),_!=null&&_.parent_works&&_.parent_works.length>0&&!_.parent_work&&T.push(t.jsx($t,{label:p.label.parentWork,children:_.parent_works.map((D,V)=>t.jsxs("span",{children:[V>0&&"、",t.jsx(wt,{id:D,onNavigate:o,renderLink:s})]},D))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(ym,{id:k.id,title:h(k.title),edition:k.edition?h(k.edition):void 0,type:k.type,isDraft:E,authors:k.authors,volumeText:z,meta:T,headerExtra:a,onNavigate:o,renderLink:s}),((Y=k.description)==null?void 0:Y.text)&&t.jsx(Pt,{text:k.description.text,style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),k.appendix&&k.appendix.length>0&&t.jsx("div",{style:{marginTop:8,marginBottom:4},children:k.appendix.map((D,V)=>t.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:r("bg-subtle"),borderRadius:4,border:`1px solid ${r("widget-border")}`},children:[t.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:r("muted")},children:h(D.title)}),t.jsx(Pt,{text:D.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:r("fg")}})]},V))}),w.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(xt,{children:p.section.containedIn}),t.jsx(zm,{items:w,onNavigate:o,renderLink:s})]}),S&&t.jsxs(t.Fragment,{children:[t.jsx(xt,{children:p.section.belongsToWork}),t.jsx(Tm,{workData:S,onNavigate:o,renderLink:s})]}),k.additional_works&&k.additional_works.length>0&&t.jsx(wm,{items:k.additional_works}),k.additional_titles&&k.additional_titles.length>0&&t.jsx(vm,{items:k.additional_titles}),k.attached_texts&&k.attached_texts.length>0&&t.jsx(km,{items:k.attached_texts}),k.indexed_by&&k.indexed_by.length>0&&t.jsx(jm,{items:k.indexed_by,onNavigate:o,renderLink:s}),k.emendated_by&&k.emendated_by.length>0&&t.jsx(Il,{items:k.emendated_by,onNavigate:o,renderLink:s}),k.resources&&k.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(xt,{children:p.section.resources}),t.jsx(Zr,{items:k.resources,resourceGroups:k.resource_groups,groupByType:!0,onNavigate:o,renderLink:s})]}),($==null?void 0:$.location_history)&&$.location_history.length>0&&t.jsx(Sm,{items:$.location_history}),(C==null?void 0:C.history)&&C.history.length>0&&t.jsx(_m,{items:C.history}),($==null?void 0:$.related_books)&&$.related_books.length>0&&t.jsx(Bs,{title:p.section.relatedVersions,ids:$.related_books,transport:i,onNavigate:o,renderLink:s}),(C==null?void 0:C.books)&&C.books.length>0&&t.jsx(Bs,{title:p.section.containedBooks,ids:C.books,transport:i,onNavigate:o,renderLink:s}),(C==null?void 0:C.contained_works)&&C.contained_works.length>0&&t.jsxs("div",{children:[t.jsxs(xt,{children:[p.section.containedWorks,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",C.contained_works.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:C.contained_works.map(D=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:t.jsx(wt,{id:D.id,label:h(D.title),onNavigate:o,renderLink:s})},D.id))})]}),(((te=_==null?void 0:_.books)==null?void 0:te.length)||0)+(((se=_==null?void 0:_.collections)==null?void 0:se.length)||0)>0&&t.jsx($m,{ids:[...(_==null?void 0:_.books)||[],...(_==null?void 0:_.collections)||[]],workData:_??void 0,transport:i,onNavigate:o,renderLink:s,footer:l}),(_==null?void 0:_.related_works)&&_.related_works.length>0&&(()=>{const D=[],V=_.related_works.filter(ge=>ge.relation==="part_of"),he=_.related_works.filter(ge=>ge.relation==="has_part"),Z=_.related_works.filter(ge=>ge.relation==="has_adaptation"),M=_.related_works.filter(ge=>ge.relation==="text_carried_by"),_e=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),ce=_.related_works.filter(ge=>!ge.relation||!_e.has(ge.relation));return V.length>0&&D.push({label:p.section.belongsToWork,items:V}),he.length>0&&D.push({label:p.section.containedWorks,items:he}),Z.length>0&&D.push({label:p.section.adaptations,items:Z}),M.length>0&&D.push({label:p.section.derivativeWorks,items:M}),ce.length>0&&D.push({label:p.section.relatedWorks,items:ce}),D.map(ge=>t.jsxs("div",{children:[t.jsxs(xt,{children:[ge.label,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",ge.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:ge.items.map(le=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:t.jsx(wt,{id:le.id,label:h(le.title),onNavigate:o,renderLink:s})},le.id))})]},ge.label))})()]})};function Nm({data:e}){const n=Ee(),{convert:i}=Pe(),{stats:o}=e,s=o.processed_volumes??o.total_found_volumes,a=s!=null&&e.total_volumes>0?Math.round(s/e.total_volumes*100):null;return t.jsxs("div",{style:{marginBottom:"24px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:r("fg"),margin:"0 0 8px"},children:i(e.title)}),e.resource_name&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"6px"},children:i(e.resource_name)}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:r("desc-fg")},children:[t.jsxs("span",{children:[n.catalog.totalVolumes," ",t.jsx("strong",{style:{color:r("fg")},children:e.total_volumes})," ",n.unit.volume]}),a!=null&&t.jsxs("span",{children:[n.catalog.processed," ",t.jsx("strong",{style:{color:r("fg")},children:s})," ",n.unit.volume," (",a,"%)"]}),t.jsxs("span",{children:[n.catalog.contains," ",t.jsx("strong",{style:{color:r("fg")},children:o.total_books})," ",n.unit.bu]}),o.matched_works!=null&&o.matched_works>0&&t.jsxs("span",{children:[n.catalog.matched," ",t.jsx("strong",{style:{color:r("fg")},children:o.matched_works})," ",n.unit.bu]}),o.unmatched_works!=null&&o.unmatched_works>0&&t.jsxs("span",{children:[n.catalog.unmatched," ",t.jsx("strong",{style:{color:r("missing-fg")},children:o.unmatched_works})," ",n.unit.bu]})]}),e.source&&t.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:r("desc-fg")},children:[n.catalog.source," ",e.source]})]})}function Im({sections:e,activeSection:n,onSelect:i}){const o=Ee();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>i(null),style:Ws(n===null),children:o.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>i(s.name),style:Ws(n===s.name),children:[s.name,s.volume_range&&t.jsxs("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"4px"},children:[s.volume_range[0],"–",s.volume_range[1]]})]},s.name))]})}function Ws(e){return{padding:"4px 12px",border:e?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:e?`color-mix(in srgb, ${r("primary")} 8%, transparent)`:"transparent",color:r(e?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}function Rm({id:e,label:n,onNavigate:i,renderLink:o}){const s=tt();return o?t.jsx(t.Fragment,{children:o(e,n)}):i?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i(e))},style:{color:r("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`,paddingBottom:"1px",fontSize:"12px"},onMouseEnter:a=>a.currentTarget.style.borderBottomStyle="solid",onMouseLeave:a=>a.currentTarget.style.borderBottomStyle="dashed",children:n||e}):t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg")},children:n||e})}function Em(e,n){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const i=e[0],o=e[e.length-1];return o-i+1===e.length?`${i}–${o}`:e.length<=3?e.join(", "):`${i}–${o} (${e.length}${n})`}function Os({book:e,onNavigate:n,renderLink:i,showVolumes:o}){const s=Ee(),{convert:a}=Pe(),l=e.book_id||e.work_id,d=o&&e.volumes.length>0?Em(e.volumes,s.unit.volume):null,c=e.missing_volumes&&e.missing_volumes.length>0;return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",padding:"6px 12px",borderBottom:`1px solid ${r("widget-border")}`,fontSize:"14px",lineHeight:1.8},children:[o&&t.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:r("desc-fg"),textAlign:"right"},children:d}),t.jsxs("span",{style:{flex:1,fontWeight:500,color:r("fg")},children:[a(e.title),e.sub_items&&e.sub_items.length>0&&t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400,marginLeft:"6px"},children:["(",e.sub_items.map(p=>a(p)).join("、"),")"]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),fontWeight:400,marginLeft:"8px"},children:a(e.edition)})]}),e.expected_volumes!=null&&t.jsxs("span",{style:{fontSize:"11px",color:r(c?"missing-fg":"desc-fg"),flexShrink:0},children:[e.found_volumes??0,"/",e.expected_volumes,s.unit.volume]}),l&&t.jsx(Rm,{id:l,label:e.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:i}),!l&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const no=({data:e,collectionId:n,transport:i,onNavigate:o,renderLink:s,className:a,style:l})=>{const d=Ee(),[c,p]=g.useState(null),[h,u]=g.useState(!1),[m,f]=g.useState(null),[x,v]=g.useState(null),[y,S]=g.useState(""),b=e||c;g.useEffect(()=>{if(e||!n||!(i!=null&&i.getCollectionCatalog))return;let C=!1;return u(!0),f(null),i.getCollectionCatalog(n).then(_=>{C||(_?p(_):f(d.catalog.notFound))}).catch(_=>{C||f(_ instanceof Error?_.message:d.catalog.loadFailed)}).finally(()=>{C||u(!1)}),()=>{C=!0}},[e,n,i,d]);const w=(b==null?void 0:b.sections)&&b.sections.length>0,j=g.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const C=b.books.map(E=>E.volumes[0]).filter(E=>E!=null);return new Set(C).size<C.length},[b]),k=g.useMemo(()=>{if(!b)return[];let C=b.books;if(x&&(C=C.filter(_=>_.section===x)),y.trim()){const _=y.trim().toLowerCase();C=C.filter(E=>E.title.toLowerCase().includes(_)||E.sub_items&&E.sub_items.some(z=>z.toLowerCase().includes(_))||E.edition&&E.edition.toLowerCase().includes(_))}return C},[b,x,y]),$=g.useMemo(()=>{if(!j)return null;const C=[],_=new Map;for(const z of k){if(!z.volumes||z.volumes.length===0)continue;const T=z.volumes[0];_.has(T)||_.set(T,[]),_.get(T).push(z)}const E=[..._.keys()].sort((z,T)=>z-T);for(const z of E)C.push({volume:z,books:_.get(z)});return C},[k,j]);return h?t.jsx("div",{className:a,style:{...l,padding:"24px"},children:t.jsx("div",{style:{color:r("desc-fg"),fontSize:"13px"},children:d.catalog.loading})}):m?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:m}):b?t.jsxs("div",{className:a,style:l,children:[t.jsx(Nm,{data:b}),w&&t.jsx(Im,{sections:b.sections,activeSection:x,onSelect:v}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:d.search.searchBookName,value:y,onChange:C=>S(C.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"}}),t.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:r("desc-fg")},children:[k.length," ",d.unit.bu]})]}),t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[$?$.map((C,_)=>t.jsxs("div",{children:[t.jsx("div",{style:{padding:"4px 12px",background:r("bg"),borderBottom:`1px solid ${r("widget-border")}`,fontSize:"12px",fontWeight:600,color:r("desc-fg"),position:"sticky",top:0,zIndex:1},children:gt(d.catalog.volume,{n:C.volume})}),C.books.map((E,z)=>t.jsx(Os,{book:E,onNavigate:o,renderLink:s,showVolumes:E.volumes.length>1},`${C.volume}-${z}`))]},`${C.volume}-${_}`)):k.map((C,_)=>t.jsx(Os,{book:C,onNavigate:o,renderLink:s,showVolumes:!0},_)),k.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},sr=e=>e?e.catch(()=>null):Promise.resolve(null);function El(e){const n=new Map;function i(o){var a;let s=n.get(o);return s||(s=sr((a=e.getTextManifest)==null?void 0:a.call(e,o)).then(l=>{const d=l&&Array.isArray(l.versions)&&l.versions.length>0?l:null;return d||n.delete(o),d}),n.set(o,s)),s}return{getManifest(o){return Se.isSafeSegment(o)?i(o):Promise.resolve(null)},async getIndex(o,s){return!Se.isSafeSegment(o)||!Se.isSafeSegment(s)||!e.getTextIndex?null:sr(e.getTextIndex(o,s))},async getChapter(o,s,a,l){return!Se.isSafeSegment(o)||!Se.isSafeSegment(s)||!Se.isSafeSegment(a)||!e.getChapter?null:sr(e.getChapter(o,s,a,l))}}}const nn=()=>{const{t:e}=ne(),[n,i]=g.useState(1);return g.useEffect(()=>{const o=setInterval(()=>i(s=>s>=3?1:s+1),500);return()=>clearInterval(o)},[]),t.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:r("desc-fg"),fontSize:"14px"},children:e("common.loading")+".".repeat(n)})},ar=String.raw`https?:\/\/[^\s()()<>"]+`,Lm=new RegExp(String.raw`\[([^\]\n]+)\]\((${ar})\)`+String.raw`|(《[^》\n]+》)\s?[((](${ar})[))]`+`|(${ar})`,"g");function Am(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function Mm(e){const n=[];let i=0;for(const o of e.matchAll(Lm)){const s=o.index??0;s>i&&n.push({text:e.slice(i,s)}),o[1]!==void 0?n.push({text:o[1],url:o[2]}):o[3]!==void 0?n.push({text:o[3],url:o[4]}):n.push({text:Am(o[5]),url:o[5]}),i=s+o[0].length}return i<e.length&&n.push({text:e.slice(i)}),n}function Ll({text:e,convert:n,className:i="bim-rd-link"}){return t.jsx(t.Fragment,{children:Mm(e).map((o,s)=>o.url?t.jsx("a",{className:i,href:o.url,target:"_blank",rel:"noopener noreferrer",children:n(o.text)},s):t.jsx(g.Fragment,{children:n(o.text)},s))})}const Al="(min-width: 1100px)",Ml="(max-width: 719px)",Pl="(max-width: 859px)",Pm=`${Ml}, (pointer: coarse)`,_t=r("reader-top"),Bm="48px",Bl=`
|
|
146
146
|
.bim-rd {
|
|
147
147
|
position: relative;
|
|
148
148
|
background: ${r("page-bg")};
|
|
149
149
|
color: ${r("ink")};
|
|
150
150
|
font-family: ${r("font-ui")};
|
|
151
|
-
--bimrd-bar-h: ${
|
|
151
|
+
--bimrd-bar-h: ${Bm};
|
|
152
152
|
/* 设置侧栏的暖黄:与朱/靛/墨三套主色都不冲,只做底色与选中态 */
|
|
153
153
|
--bimrd-warm: ${r("reader-warm")};
|
|
154
154
|
--bimrd-warm-bg: color-mix(in srgb, var(--bimrd-warm) 8%, ${r("page-bg")});
|
|
@@ -441,7 +441,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
441
441
|
.bim-rd-sheet-head .bim-rd-t { margin-left: auto; min-width: 44px; min-height: 44px; justify-content: center; letter-spacing: 0; }
|
|
442
442
|
.bim-rd-sheet-img { display: flex; flex-direction: column; gap: 8px; min-height: 40vh; }
|
|
443
443
|
.bim-rd-sheet-img .bim-rd-img-fig img { max-height: 60vh; }
|
|
444
|
-
@media ${
|
|
444
|
+
@media ${Pl} {
|
|
445
445
|
.bim-rd[data-bb] .bim-rd-text { padding-bottom: calc(56px + 64px + env(safe-area-inset-bottom, 0px)); }
|
|
446
446
|
/* 底栏上已有的,工具条上不再重复(目录、字号) */
|
|
447
447
|
.bim-rd[data-bb] .bim-rd-bb-dup { display: none !important; }
|
|
@@ -486,7 +486,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
486
486
|
|
|
487
487
|
/* ── 点击区 ≥44×44(INT Q4):伪元素向外扩,按钮外观与排布不变;
|
|
488
488
|
A− A+ 挨着,两边各扩约 10px 会叠在一起,所以二者之间多留 12px ── */
|
|
489
|
-
@media ${
|
|
489
|
+
@media ${Pm} {
|
|
490
490
|
.bim-rd-tools .bim-rd-t, .bim-rd-toc-head .bim-rd-t { position: relative; }
|
|
491
491
|
.bim-rd-tools .bim-rd-t::after, .bim-rd-toc-head .bim-rd-t::after {
|
|
492
492
|
content: ""; position: absolute; left: 50%; top: 50%;
|
|
@@ -499,7 +499,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
499
499
|
}
|
|
500
500
|
|
|
501
501
|
/* ── 中屏以下:目录改抽屉 ── */
|
|
502
|
-
@media not all and ${
|
|
502
|
+
@media not all and ${Al} {
|
|
503
503
|
.bim-rd-toc {
|
|
504
504
|
position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; height: auto;
|
|
505
505
|
width: min(86vw, 320px);
|
|
@@ -513,7 +513,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
513
513
|
}
|
|
514
514
|
|
|
515
515
|
/* ── 窄屏:书影收起,只留正文 ── */
|
|
516
|
-
@media ${
|
|
516
|
+
@media ${Ml} {
|
|
517
517
|
.bim-rd-bar { padding: 0 12px; gap: 10px; }
|
|
518
518
|
.bim-rd-ttl span, .bim-rd-hide-narrow { display: none !important; }
|
|
519
519
|
/* 工具条放不下时(版本、自然段、标出作品链接都在)在条内左右滑,不撑宽页面 */
|
|
@@ -673,15 +673,15 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
673
673
|
letter-spacing: 0.05em;
|
|
674
674
|
margin-left: 6px;
|
|
675
675
|
}
|
|
676
|
-
`;function io(e,n){var i;return n?e.key===n?!0:!!((i=e.children)!=null&&i.some(o=>io(o,n))):!1}const Bm=()=>t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:t.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Wm({item:e,activeKey:n,onSelect:i,tabKey:o}){const s=io(e,n),[a,l]=g.useState(s||!!e.defaultExpanded);return g.useEffect(()=>{s&&l(!0)},[s]),g.useEffect(()=>{e.defaultExpanded&&l(!0)},[e.defaultExpanded]),t.jsxs("li",{children:[t.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":a,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>l(d=>!d),children:[t.jsx(Bm,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),a&&t.jsx(Bl,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]})}function Bl({items:e,activeKey:n,onSelect:i,tabKey:o}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(Wm,{item:s,activeKey:n,onSelect:i,tabKey:o},s.key):t.jsx("li",{children:t.jsxs("button",{type:"button",className:"bim-rd-ti","aria-current":s.key===n?"true":void 0,disabled:s.disabled,"data-rd-toc-key":s.key,tabIndex:o===s.key?0:-1,onClick:()=>i(s.key),children:[t.jsx("span",{children:s.label}),s.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:s.hint})]})},s.key))})}function Os(e,n){var i;for(const o of e)if(o.key===n||io(o,n))return o.key;return((i=e[0])==null?void 0:i.key)??null}function Wl({items:e,activeKey:n,onSelect:i,label:o}){const{t:s}=ne(),a=o??s("reader.toc"),l=g.useRef(null),[d,c]=g.useState(null);g.useEffect(()=>{c(null)},[n]);const p=g.useMemo(()=>d||(n??Os(e,n)),[d,n,e]);g.useEffect(()=>{const u=l.current;if(!u)return;const m=Array.from(u.querySelectorAll("[data-rd-toc-key]"));if(m.length===0)return;const f=m.find(x=>x.dataset.rdTocKey===p)??m.find(x=>x.dataset.rdTocKey===Os(e,n))??m.find(x=>!x.disabled)??m[0];for(const x of m)x.tabIndex=x===f?0:-1}),g.useEffect(()=>{const u=l.current,m=u==null?void 0:u.closest(".bim-rd-toc");if(!u||!m||!n)return;const f=Array.from(u.querySelectorAll("[data-rd-toc-key]")).find(v=>v.dataset.rdTocKey===n);if(!f)return;const x=f.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop;(x<m.scrollTop+80||x>m.scrollTop+m.clientHeight-40)&&(m.scrollTop=Math.max(0,x-m.clientHeight/3))},[n]);const h=g.useCallback(u=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(u.key))return;const f=l.current;if(!f)return;const x=Array.from(f.querySelectorAll("[data-rd-toc-key]")).filter(b=>!b.disabled),v=x.indexOf(document.activeElement);let y=v;if(u.key==="ArrowDown"?y=Math.min(x.length-1,v+1):u.key==="ArrowUp"?y=Math.max(0,v-1):u.key==="Home"?y=0:u.key==="End"&&(y=x.length-1),y<0||y===v)return;u.preventDefault();const S=x[y];for(const b of x)b.tabIndex=-1;S.tabIndex=0,S.focus(),c(S.dataset.rdTocKey??null)},[]);return t.jsx("div",{ref:l,role:"navigation","aria-label":a,onKeyDown:h,children:t.jsx(Bl,{items:e,activeKey:n,onSelect:i,tabKey:p})})}function Fs({page:e,crop:n}){var i;return!((i=e.boxes)!=null&&i.length)||!e.width||!e.height||e.boxFormat&&e.boxFormat!=="bim-charbox-v0"?null:t.jsx("svg",{viewBox:n?`${n.x} ${n.y} ${n.w} ${n.h}`:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:e.boxes.map((o,s)=>t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:"none",stroke:r("accent"),strokeOpacity:.55,vectorEffect:"non-scaling-stroke",strokeWidth:1},s))})}function Om(e){const{boxes:n,width:i,height:o}=e;if(!(n!=null&&n.length)||!i||!o||e.boxFormat&&e.boxFormat!=="bim-charbox-v0")return null;let s=1/0,a=1/0,l=-1/0,d=-1/0;for(const f of n)[f.x,f.y,f.w,f.h].every(Number.isFinite)&&(s=Math.min(s,f.x),a=Math.min(a,f.y),l=Math.max(l,f.x+f.w),d=Math.max(d,f.y+f.h));if(!(l>s)||!(d>a))return null;const c=Math.min(i,o)*.03,p=Math.min(i,Math.max(0,s-c)),h=Math.min(o,Math.max(0,a-c)),u=Math.min(i,Math.max(0,l+c))-p,m=Math.min(o,Math.max(0,d+c))-h;return!(u>0)||!(m>0)||u>=i*.98&&m>=o*.98?null:{x:p,y:h,w:u,h:m}}function wr({pages:e,loading:n,page:i,onPageChange:o,renderOverlay:s,preserveMargins:a=!0}){const{t:l}=ne(),[d,c]=g.useState(0),p=i??d,h=v=>{o?o(v):c(v)};if(g.useEffect(()=>{i===void 0&&c(0)},[e,i]),n)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsx("div",{className:"bim-rd-img-empty",children:l("reader.imagesLoading")})});if(!e||e.length===0)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsxs("div",{className:"bim-rd-img-empty",children:[t.jsx("div",{className:"bim-rd-img-frame","aria-hidden":"true"}),t.jsx("b",{children:l("reader.noImages")}),t.jsx("span",{children:l("reader.noImagesHint")})]})});const u=Math.max(0,Math.min(e.length-1,p)),m=e[u],f=m.label??`${u+1}`,x=!a&&!s?Om(m):null;return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-img-box",children:x?t.jsxs("figure",{className:"bim-rd-img-fig bim-rd-img-trimmed","data-trim":`${Math.round(x.x)},${Math.round(x.y)},${Math.round(x.w)},${Math.round(x.h)}`,style:{aspectRatio:`${x.w} / ${x.h}`,overflow:"hidden",width:"100%",maxWidth:`calc((100vh - 200px) * ${x.w/x.h})`},children:[t.jsx("img",{src:m.url,alt:m.alt??l("reader.imageAlt",{label:f}),decoding:"async",style:{position:"absolute",maxWidth:"none",maxHeight:"none",width:`${m.width/x.w*100}%`,left:`${-x.x/x.w*100}%`,top:`${-x.y/x.h*100}%`}}),t.jsx(Fs,{page:m,crop:x})]}):t.jsxs("figure",{className:"bim-rd-img-fig",children:[t.jsx("img",{src:m.url,alt:m.alt??l("reader.imageAlt",{label:f}),width:m.width,height:m.height,loading:"lazy",decoding:"async"}),t.jsx(Fs,{page:m}),s==null?void 0:s(m,u)]})}),e.length>1&&t.jsxs("div",{className:"bim-rd-img-pager",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.prevImage"),disabled:u===0,onClick:()=>h(u-1),children:"‹"}),t.jsx("span",{"aria-live":"polite",children:m.label??`${u+1} / ${e.length}`}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.nextImage"),disabled:u===e.length-1,onClick:()=>h(u+1),children:"›"})]})]})}function Fm(e){return e==="lite"||e==="full"}const Pn=[.1,.9],Ol=[{key:"song",stack:null},{key:"kai",stack:'"Kaiti SC", "Kaiti TC", STKaiti, "KaiTi", "AR PL UKai CN", "Noto Serif CJK SC", serif'},{key:"system",stack:"var(--bim-font-ui)"}];function Hm(e){var n;return((n=Ol.find(i=>i.key===e))==null?void 0:n.stack)??null}const ro={fontSize:null,readingMode:"line",properNameMode:null,writingMode:"horizontal",workLinks:!0,fontFamily:"song",pageBreaks:!0,pageIndicatorY:.33,bookTitleStyle:"wavy",showWorks:!0,quoteStyle:"original",scriptMode:null,preserveMargins:!0},Et=[15,16,17,18,20,22,24],Sr=18,Fl="bim-reader-prefs",Dm="bim-reading-mode";function Um(){const e={...ro};try{const n=localStorage.getItem(Fl),i=n?JSON.parse(n):{};typeof i.fontSize=="number"&&Et.includes(i.fontSize)&&(e.fontSize=i.fontSize),(i.readingMode??localStorage.getItem(Dm))==="paragraph"&&(e.readingMode="paragraph"),i.properNameMode==="off"||i.properNameMode==="lite"||i.properNameMode==="full"?e.properNameMode=i.properNameMode:i.properNames===!0?e.properNameMode="full":i.properNames===!1&&(e.properNameMode="off"),i.writingMode==="vertical"&&(e.writingMode="vertical"),i.workLinks===!1&&(e.workLinks=!1),(i.fontFamily==="kai"||i.fontFamily==="system")&&(e.fontFamily=i.fontFamily),i.pageBreaks===!1&&(e.pageBreaks=!1),typeof i.pageIndicatorY=="number"&&Number.isFinite(i.pageIndicatorY)&&i.pageIndicatorY>=Pn[0]&&i.pageIndicatorY<=Pn[1]&&(e.pageIndicatorY=i.pageIndicatorY),i.bookTitleStyle==="bracket"&&(e.bookTitleStyle="bracket"),i.showWorks===!1&&(e.showWorks=!1),(i.quoteStyle==="modern"||i.quoteStyle==="classic")&&(e.quoteStyle=i.quoteStyle),(i.scriptMode==="orig"||i.scriptMode==="hant"||i.scriptMode==="hans")&&(e.scriptMode=i.scriptMode),i.preserveMargins===!1&&(e.preserveMargins=!1)}catch{}return e}function Vm(e){try{localStorage.setItem(Fl,JSON.stringify(e))}catch{}}function ri(e,n){const i=e??Sr,o=Et;let s=o.indexOf(i);return s<0&&(s=o.indexOf(Sr)),o[Math.max(0,Math.min(o.length-1,s+n))]}function Hl(){const[e,n]=g.useState(ro);g.useEffect(()=>{n(Um())},[]);const i=g.useCallback(o=>{n(s=>{const a={...s,...o};return Vm(a),a})},[]);return[e,i]}function _r(e){if(e.optionLabel)return e.optionLabel;const n=e.label||e.key;return!e.sourceName||n.includes(e.sourceName)?n:`${n} · ${e.sourceName}`}function Dl(e,n){if(!(!e||e.length===0))return(n!=null?e.find(i=>i.key===n):void 0)??e.find(i=>i.primary)??e[0]}function Ul(e){const n=[],i=o=>{for(const s of o)s.children&&s.children.length>0?i(s.children):n.push(s)};return i(e),n}const Hs=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:t.jsx("path",{d:"M4 6h16M4 12h10M4 18h16"})}),Gm=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M15 5l-7 7 7 7"})}),Ym=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M9 5l7 7-7 7"})}),Ds=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M4 7h10M18 7h2M4 17h2M10 17h10"}),t.jsx("circle",{cx:"16",cy:"7",r:"2"}),t.jsx("circle",{cx:"8",cy:"17",r:"2"})]}),Us=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"4",y:"3",width:"16",height:"18",rx:"1.5"}),t.jsx("path",{d:"M9 3v18M13 7v10M16.5 7v10"})]});function Vs(e,n){if(!n)return;const i=Array.from(n.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(l=>l.tabIndex>=0);if(i.length===0)return;const o=i[0],s=i[i.length-1],a=document.activeElement;e.shiftKey&&(a===o||!n.contains(a))?(e.preventDefault(),s.focus()):!e.shiftKey&&(a===s||!n.contains(a))&&(e.preventDefault(),o.focus())}function Gs(e,n){const[i,o]=g.useState(n);return g.useEffect(()=>{var l;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(e);o(s.matches);const a=()=>o(s.matches);return(l=s.addEventListener)==null||l.call(s,"change",a),()=>{var d;return(d=s.removeEventListener)==null?void 0:d.call(s,"change",a)}},[e]),i}function qm({prefs:e,onPrefsChange:n}){const i=g.useContext(Tt),{t:o}=ne();if(!i)return null;const s=i.locale==="zh-Hans"?"hans":"hant",a=e.scriptMode==="orig"?"orig":s,l=[{key:"orig",short:o("reader.scriptOrigShort"),title:o("reader.scriptOrig")},{key:"hant",short:o("common.localeShortHant"),title:o("reader.scriptHant")},{key:"hans",short:o("common.localeShortHans"),title:o("reader.scriptHans")}];return t.jsx("span",{className:"bim-rd-script-sw",role:"group","aria-label":o("reader.scriptQuick"),children:l.map((d,c)=>t.jsxs(g.Fragment,{children:[c>0&&t.jsx("span",{className:"bim-rd-off","aria-hidden":"true",children:"|"}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":a===d.key,title:d.title,"aria-label":d.title,onClick:()=>{n({scriptMode:d.key}),d.key==="hant"?i.setLocale("zh-Hant"):d.key==="hans"&&i.setLocale("zh-Hans")},children:d.short})]},d.key))})}function di({label:e,value:n,options:i,onPick:o,title:s}){return t.jsxs("div",{className:"bim-rd-sp-row",role:"group","aria-label":e,title:s,children:[t.jsx("span",{className:"bim-rd-sp-l",children:e}),t.jsx("span",{className:"bim-rd-sp-fs",children:i.map(a=>t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":n===a.key,title:a.title,onClick:()=>o(a.key),children:a.label},a.key))})]})}function Km({prefs:e,onPrefsChange:n}){const i=g.useContext(Tt),{t:o}=ne(),s=(i==null?void 0:i.locale)==="zh-Hans"?"hans":"hant",a=e.scriptMode==="orig"?"orig":s;return t.jsx(di,{label:o("reader.script"),value:a,options:[{key:"orig",label:o("reader.scriptOrig")},{key:"hant",label:o("reader.scriptHant")},{key:"hans",label:o("reader.scriptHans")}],onPick:l=>{n({scriptMode:l}),l==="hant"?i==null||i.setLocale("zh-Hant"):l==="hans"&&(i==null||i.setLocale("zh-Hans"))}})}function Xm(e,n){if(!e)return;let i;for(const o of Array.from(e.querySelectorAll('[id^="rd-e-"]')))if(o.getBoundingClientRect().top<=n+8)i=o.id;else break;return i}function Zm(e){var a;if(typeof window>"u"||!e)return;const n=(a=window.getSelection)==null?void 0:a.call(window);if(!n||n.isCollapsed||n.rangeCount===0)return;const i=e.querySelector(".bim-rd-col"),o=l=>{const d=(l==null?void 0:l.nodeType)===1?l:l==null?void 0:l.parentElement;return!!l&&!!(i!=null&&i.contains(l))&&!(d!=null&&d.closest(".bim-rd-src, .bim-rd-pager"))};if(!o(n.anchorNode)||!o(n.focusNode))return;const s=n.toString().replace(/\s+/g," ").trim();return s?s.slice(0,500):void 0}function Vl({title:e,subtitle:n,toc:i,activeKey:o,onSelect:s,tocHeader:a,tocCaption:l,images:d,imagesLoading:c,renderImageOverlay:p,imagePanel:h="auto",prefs:u,onPrefsChange:m,paragraphToggle:f,properNameToggle:x=!0,allowVertical:v,byline:y,current:S,workLinkToggle:b,rail:w,onReportError:j,revisedAt:k,backHref:$,backLabel:C,bottomBar:_=!0,pager:E=!0,pagerUnit:z,versions:T,currentVersionKey:B,onVersionChange:W,versionSource:N=!0,keepChapterOnVersionChange:A=!1,customImagePanel:F,toolbarExtra:Y,settingsAnnotate:ee,settingsLayout:se,isWarpMode:D,children:V,className:he,style:Z}){const{t:M,convert:_e}=ne(),ce=C??M("reader.back"),ge=_e(z??M("reader.unitJuan")),le=g.useId().replace(/:/g,""),Be=`bim-rd-toc-${le}`,ze=`bim-rd-text-${le}`,Fe=g.useRef(null),te=g.useRef(null),H=g.useRef(null),G=g.useRef(null),xe=Gs(Ll,!0),K=Gs(Ml,!1),L=_&&K,[q,ae]=g.useState(null),[be,X]=g.useState(!1),re=g.useRef(null),Ce=`bim-rd-set-${le}`,We=g.useRef(null),O=g.useRef(null),ie=(J,Re)=>{O.current=Re,ae(qe=>qe===J?null:J)},je=g.useCallback(()=>{var J;ae(null),(J=O.current)==null||J.focus()},[]);g.useEffect(()=>{L||ae(null)},[L]),g.useEffect(()=>{var J,Re;q&&((Re=(J=We.current)==null?void 0:J.querySelector("button:not([disabled])"))==null||Re.focus())},[q]);const[ke,P]=g.useState("auto"),fe=ke==="auto"?xe:ke==="open",oe=!xe,we=!!F||!!d&&d.length>0,[Le,He]=g.useState(h);g.useEffect(()=>{He(h)},[h]);const Ge=Le==="auto"?we||!!c:Le==="open",Ye=g.useCallback(J=>{var Re;P("auto"),J&&((Re=G.current)==null||Re.focus())},[]),Xe=()=>P(fe?"closed":"open");g.useEffect(()=>{if(!oe||ke!=="open")return;const J=H.current,Re=J==null?void 0:J.querySelector('input, [data-rd-toc-key][tabindex="0"]');Re==null||Re.focus()},[oe,ke]);const I=g.useCallback(J=>{s(J),oe&&Ye(!1);const Re=te.current,qe=Fe.current;if(Re&&qe&&typeof window<"u"){const ot=Re.getBoundingClientRect().top-qe.getBoundingClientRect().bottom;ot<0&&window.scrollBy({top:ot})}},[s,oe,Ye]),U=g.useMemo(()=>Ul(i),[i]),[pe,$e]=g.useState(null),ye=Dl(T,B!==void 0?B:pe),ue=(ye==null?void 0:ye.key)??null,Ve=g.useMemo(()=>U.map(J=>J.key).join(`
|
|
677
|
-
`),[U]),Q=g.useRef(null),ve=J=>{J!==ue&&(A||(Q.current={key:J,sig:Ve,done:!1}),B===void 0&&$e(J),W==null||W(J))};g.useEffect(()=>{const J=Q.current;if(!J||J.key!==ue)return;const Re=U.find(ot=>!ot.disabled);if(!Re)return;const qe=Ve!==J.sig;!qe&&J.done||(qe?Q.current=null:J.done=!0,Re.key!==o&&I(Re.key))},[ue,Ve,U,o,I]);const Ae=U.find(J=>J.key===o),Oe=()=>{var J;j==null||j({chapterKey:o,chapterLabel:typeof(Ae==null?void 0:Ae.label)=="string"?Ae.label:void 0,anchor:Xm(te.current,((J=Fe.current)==null?void 0:J.getBoundingClientRect().bottom)??0),selectedText:Zm(te.current)})},Ie=U.findIndex(J=>J.key===o),me=Ie>0?U.slice(0,Ie).reverse().find(J=>!J.disabled):void 0,Te=Ie>=0?U.slice(Ie+1).find(J=>!J.disabled):void 0,De=u.fontSize??Sr,Me=Hm(u.fontFamily),yt={...Z,...u.fontSize?{"--bimrd-fs":`${u.fontSize}px`}:null,...Me?{"--bimrd-ff":Me}:null},jt={song:M("reader.fontSong"),kai:M("reader.fontKai"),system:M("reader.fontSystem")},on=x||!!ee,Wt=t.jsxs("div",{className:"bim-rd-sp",children:[t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Ce}-g1`,children:[t.jsx("h3",{id:`${Ce}-g1`,className:"bim-rd-sp-h",children:M("reader.groupText")}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:M("reader.font")}),t.jsx("select",{className:"bim-rd-sp-sel","aria-label":M("reader.font"),value:u.fontFamily,onChange:J=>m({fontFamily:J.target.value}),children:Ol.map(J=>t.jsx("option",{value:J.key,children:jt[J.key]},J.key))})]}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:M("reader.fontSize")}),t.jsxs("span",{className:"bim-rd-sp-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":M("reader.fontSmaller"),disabled:De<=Et[0],onClick:()=>m({fontSize:ri(u.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[De,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":M("reader.fontLarger"),disabled:De>=Et[Et.length-1],onClick:()=>m({fontSize:ri(u.fontSize,1)}),children:"A+"})]})]}),t.jsx(Km,{prefs:u,onPrefsChange:m}),t.jsx(di,{label:M("reader.quoteStyle"),value:u.quoteStyle,options:[{key:"modern",label:M("reader.quoteModern")},{key:"classic",label:M("reader.quoteClassic")},{key:"original",label:M("reader.quoteOriginal")}],onPick:J=>m({quoteStyle:J})})]}),on&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Ce}-g2`,children:[t.jsx("h3",{id:`${Ce}-g2`,className:"bim-rd-sp-h",children:M("reader.groupMark")}),x&&t.jsxs(t.Fragment,{children:[t.jsx(di,{label:M("reader.properName"),value:u.properNameMode,title:M("reader.properNameTitle"),options:[{key:"off",label:M("reader.properNameOff")},{key:"lite",label:M("reader.properNameLite"),title:M("reader.properNameLiteTitle")},{key:"full",label:M("reader.properNameFull")}],onPick:J=>m({properNameMode:J})}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.showWorks,onChange:J=>m({showWorks:J.target.checked})}),t.jsx("span",{children:M("reader.showWorks")})]}),t.jsx(di,{label:M("reader.bookTitleStyle"),value:u.bookTitleStyle,options:[{key:"wavy",label:M("reader.bookTitleWavy")},{key:"bracket",label:M("reader.bookTitleBracket")}],onPick:J=>m({bookTitleStyle:J})})]}),ee]}),t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Ce}-g3`,children:[t.jsx("h3",{id:`${Ce}-g3`,className:"bim-rd-sp-h",children:M("reader.groupLayout")}),f&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.readingMode==="paragraph",title:M("reader.paragraphTitle"),onClick:()=>m({readingMode:u.readingMode==="paragraph"?"line":"paragraph"}),children:M("reader.paragraph")}),b&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.workLinks,onChange:J=>m({workLinks:J.target.checked})}),t.jsx("span",{children:M("reader.workLinks")})]}),v&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.writingMode==="vertical",onClick:()=>m({writingMode:u.writingMode==="vertical"?"horizontal":"vertical"}),children:M("reader.vertical")}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.pageBreaks,onChange:J=>m({pageBreaks:J.target.checked})}),t.jsx("span",{children:M("reader.pageBreaks")})]}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.preserveMargins,onChange:J=>m({preserveMargins:J.target.checked})}),t.jsx("span",{children:M("reader.preserveMargins")})]}),se]})]});return t.jsxs("div",{className:["bim-rd",u.writingMode==="vertical"&&v?"bim-rd-vertical":"",he].filter(Boolean).join(" "),"data-toc":ke,"data-img":Ge?"open":"closed","data-bb":L?"":void 0,"data-set":!L&&be?"open":void 0,"data-warp":D?"true":void 0,style:yt,children:[t.jsx("style",{children:Pl}),t.jsx("a",{className:"bim-rd-skip",href:`#${ze}`,onClick:J=>{var Re,qe,ot;J.preventDefault(),(Re=te.current)==null||Re.focus(),(ot=(qe=te.current)==null?void 0:qe.scrollIntoView)==null||ot.call(qe,{block:"start"})},children:M("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:Fe,children:[$&&t.jsxs("a",{className:"bim-rd-back",href:$,"aria-label":M("reader.backAria",{label:ce}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:ce})]}),(e||n||y||S)&&t.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[e&&t.jsx("b",{children:e}),y&&t.jsx("span",{className:"bim-rd-by",children:y}),S&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-rd-cur",children:S})]}),n&&t.jsx("span",{className:"bim-rd-ttl-src",children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":M("reader.settings"),children:[T&&T.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:ye?_e(_r(ye)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:M("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:M("reader.versionShort")}),t.jsx("select",{"aria-label":M("reader.version"),value:ue??"",onChange:J=>ve(J.target.value),children:T.map(J=>t.jsx("option",{value:J.key,children:_e(_r(J))},J.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),E&&(me||Te)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":M("reader.pagerGroup",{unit:ge}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":M("reader.prevUnit",{unit:ge}),title:me?typeof me.label=="string"&&me.label?M("reader.prevUnitTitle",{unit:ge,label:me.label}):M("reader.prevUnit",{unit:ge}):M("reader.firstUnit",{unit:ge}),disabled:!me,onClick:()=>me&&I(me.key),children:t.jsx(Gm,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":M("reader.nextUnit",{unit:ge}),title:Te?typeof Te.label=="string"&&Te.label?M("reader.nextUnitTitle",{unit:ge,label:Te.label}):M("reader.nextUnit",{unit:ge}):M("reader.lastUnit",{unit:ge}),disabled:!Te,onClick:()=>Te&&I(Te.key),children:t.jsx(Ym,{})})]}),E&&(me||Te)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:G,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":fe,"aria-controls":Be,onClick:Xe,children:[t.jsx(Hs,{}),t.jsx("span",{className:"bim-rd-tlabel",children:M("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":Ge,onClick:()=>He(Ge?"closed":"open"),children:[t.jsx(Us,{}),M("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(qm,{prefs:u,onPrefsChange:m}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":M("reader.fontSmaller"),disabled:De<=Et[0],onClick:()=>m({fontSize:ri(u.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":M("reader.fontLarger"),disabled:De>=Et[Et.length-1],onClick:()=>m({fontSize:ri(u.fontSize,1)}),children:"A+"}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsxs("button",{ref:re,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":be,"aria-controls":Ce,onClick:()=>X(J=>!J),children:[t.jsx(Ds,{}),t.jsx("span",{className:"bim-rd-tlabel",children:M("reader.settings")})]}),Y]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:Be,ref:H,role:oe&&fe?"dialog":void 0,"aria-modal":oe&&fe?!0:void 0,"aria-label":oe&&fe?M("reader.toc"):void 0,onKeyDown:J=>{if(!(!oe||!fe)){if(J.key==="Escape"){J.stopPropagation(),Ye(!0);return}J.key==="Tab"&&Vs(J,H.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:l??M("reader.toc")}),oe&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":M("reader.closeToc"),onClick:()=>Ye(!0),children:"✕"})]}),a]}),t.jsx(Wl,{items:i,activeKey:o,onSelect:I})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>Ye(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":M("reader.images"),children:Ge&&(F||t.jsx(wr,{pages:d??null,loading:c,renderOverlay:p,preserveMargins:u.preserveMargins}))}),!L&&be&&t.jsxs("aside",{className:"bim-rd-set",id:Ce,"aria-label":M("reader.settings"),onKeyDown:J=>{var Re;J.key==="Escape"&&(J.stopPropagation(),X(!1),(Re=re.current)==null||Re.focus())},children:[t.jsxs("div",{className:"bim-rd-sp-top",children:[t.jsx("span",{children:M("reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":M("reader.closeSettings"),onClick:()=>{var J;X(!1),(J=re.current)==null||J.focus()},children:"✕"})]}),Wt]}),t.jsxs("div",{className:"bim-rd-text",id:ze,ref:te,tabIndex:-1,"data-rail":(w||j)&&!D?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[V,N&&ye&&(ye.sourceName||ye.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":ye.key,children:[ye.sourceName&&t.jsxs(t.Fragment,{children:[M("reader.sourceLabel")," ",ye.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:ye.sourceUrl,target:"_blank",rel:"noreferrer",children:_e(ye.sourceName)}):_e(ye.sourceName)]}),ye.sourceName&&ye.license&&t.jsx("span",{className:"bim-rd-dot"}),ye.license&&t.jsx(t.Fragment,{children:M("reader.licenseOf",{license:ye.license})})]}),k&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:M("reader.revisedAt",{date:k})}),j&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:J=>J.preventDefault(),onClick:Oe,children:M("reader.reportError")})}),E&&(me||Te)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":M("reader.pagerNav"),children:[me?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>I(me.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),M("reader.prevUnit",{unit:ge})]}),t.jsx("span",{className:"bim-rd-pglabel",children:me.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",M("reader.firstUnit",{unit:ge})]}),Te?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>I(Te.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[M("reader.nextUnit",{unit:ge}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:Te.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[M("reader.lastUnit",{unit:ge})," →"]})]})]}),(w||j)&&!D&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":M("reader.rail"),children:[w,j&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:J=>J.preventDefault(),onClick:Oe,children:M("reader.reportError")})})]})]})]}),L&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":M("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":fe,"aria-controls":Be,onClick:()=>{ae(null),Xe()},children:[t.jsx(Hs,{}),t.jsx("span",{children:M("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":q==="img","aria-haspopup":"dialog",onClick:J=>ie("img",J.currentTarget),children:[t.jsx(Us,{}),t.jsx("span",{children:M("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":q==="set","aria-haspopup":"dialog",onClick:J=>ie("set",J.currentTarget),children:[t.jsx(Ds,{}),t.jsx("span",{children:M("reader.settingsShort")})]}),j&&t.jsxs("button",{type:"button",onMouseDown:J=>J.preventDefault(),onClick:()=>{ae(null),Oe()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:M("reader.reportError")})]})]}),L&&q&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:je}),t.jsxs("div",{className:"bim-rd-sheet",ref:We,role:"dialog","aria-modal":"true","aria-label":M(q==="img"?"reader.images":"reader.settings"),onKeyDown:J=>{if(J.key==="Escape"){J.stopPropagation(),je();return}J.key==="Tab"&&Vs(J,We.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:M(q==="img"?"reader.images":"reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":M("reader.close"),onClick:je,children:"✕"})]}),q==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(wr,{pages:d??null,loading:c,renderOverlay:p,preserveMargins:u.preserveMargins})}):Wt]})]})]})}const Gl=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],Jm={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function nt(e){return Jm[e]??e}const mn=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],hn={熹平:172,建安:196,黃初:220,正始:240,廣政:938,太康:280,永和:345,開皇:581,貞觀:627,開元:713,天寶:742,貞元:785,元和:806,開成:836,會昌:841,咸通:860,建隆:960,太平興國:976,咸平:998,天禧:1017,慶曆:1041,皇祐:1049,嘉祐:1056,治平:1064,熙寧:1068,元豐:1078,元祐:1086,紹聖:1094,崇寧:1102,大觀:1107,政和:1111,宣和:1119,建炎:1127,紹興:1131,隆興:1163,乾道:1165,淳熙:1174,紹熙:1190,慶元:1195,嘉泰:1201,開禧:1205,嘉定:1208,寶慶:1225,紹定:1228,端平:1234,嘉熙:1237,淳祐:1241,寶祐:1253,開慶:1259,景定:1260,咸淳:1265,大定:1161,明昌:1190,至元:1264,大德:1297,皇慶:1312,延祐:1314,泰定:1324,天曆:1328,至順:1330,至正:1341,洪武:1368,永樂:1403,宣德:1426,正統:1436,景泰:1450,天順:1457,成化:1465,弘治:1488,正德:1506,嘉靖:1522,隆慶:1567,萬曆:1573,泰昌:1620,天啟:1621,崇禎:1628,弘光:1645,隆武:1645,紹武:1646,永曆:1647,順治:1644,康熙:1662,雍正:1723,乾隆:1736,嘉慶:1796,道光:1821,咸豐:1851,同治:1862,光緒:1875,宣統:1909,慶長:1596,寬永:1624,正保:1644,慶安:1648,承應:1652,明曆:1655,萬治:1658,寬文:1661,延寶:1673,天和:1681,貞享:1684,元祿:1688,寶永:1704,享保:1716,元文:1736,寬保:1741,延享:1744,寬延:1748,寶曆:1751,明和:1764,安永:1772,天明:1781,寬政:1789,享和:1801,文化:1804,文政:1818,天保:1830,弘化:1844,嘉永:1848,安政:1854,萬延:1860,文久:1861,元治:1864,慶應:1865,明治:1868,大正:1912,昭和:1926,天正:1573,文祿:1592,永祿:1558,天文:1532},Yl={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function zi(e){const n=e.match(/^\s*(\d{3,4})(?:\s*[-–—~至]\s*(\d{3,4}))?/);if(!n)return;const i=parseInt(n[1],10);if(i<100||i>2100)return;const o=n[2]?parseInt(n[2],10):void 0;return{from:i,to:o!=null&&o>=i&&o<=2100?o:void 0}}function Qm(e){return e>=1950?"":e>=1912?"民國":e>=1645?"清":e>=1368?"明":e>=1279?"元":e>=960?"宋":e>=907?"五代":e>=618?"唐":e>=581?"隋":e>=420?"南北朝":e>=265?"晉":e>=220?"三國":e>=-202?"漢":""}const eh=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,Ys={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function oo(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(Ys))if(n.startsWith(s))return Ys[s];const i=nt(n);if(Zt[i]!=null)return i;const o=At(n);if(o&&n.length<=o.length+1)return nt(o)}function Xt(e,n){if(n){const i=Yl[`${n}|${e}`];if(i!=null)return i}return hn[e]}const th=1911;function nh(e){const n=hn[e];if(n==null)return;const i=Ct[e];let o;for(const[s,a]of Object.entries(hn))Ct[s]===i&&a>n&&(o==null||a<o)&&(o=a);return o!=null?o-1:void 0}const ih={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function fi(e){if(!e)return;if(/^\d+$/.test(e))return parseInt(e,10);let n=0,i=0,o=!1;for(const a of e){const l=ih[a];if(l===void 0)return;o=!0,a==="十"?i=(i||1)*10:a==="廿"||a==="卅"?(n+=l,i=0):i>=10?(n+=i+l,i=0):i=i*10+l}const s=n+i;return o&&s>0?s:void 0}function At(e){for(const n of Gl)if(e.startsWith(n))return n}const Ct={};{const e=(n,i)=>{for(const o of i)Ct[o]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function Jt(e,n){const i=n==="北宋"||n==="南宋"?"宋":n;for(const o of Object.keys(hn))if(e.includes(o)&&!(i&&Ct[o]&&Ct[o]!==i&&Yl[`${i}|${o}`]==null))return o}function Wn(e){var l,d,c;const n={era:"",reign:"",source:"none"},i=e.dating;if(i!=null&&i.era||i!=null&&i.reign)return{era:i.era??"",reign:i.reign??"",source:i.certainty==="attested"?"catalog":"edition"};const o=(l=e.lineage)==null?void 0:l.year_text;if(o){const p=At(o)??"";return{era:nt(p),reign:Jt(o,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=zi(s);if(p)return{era:Qm(p.from),reign:"",source:"publication"};const h=At(s)??oo(s)??((c=mn.find(f=>f.pattern.test(s)))==null?void 0:c.era)??"",u=Jt(s,h)??"",m=h||(u?Ct[u]??"":"");if(m||u)return{era:nt(m),reign:u,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=At(a);if(p)return{era:nt(p),reign:Jt(a,p)??"",source:"edition"};const h=mn.find(u=>u.pattern.test(a));if(h)return{era:nt(h.era),reign:Jt(a,h.era)??h.reign??"",source:"edition"}}return n}function Ni(e){var o,s,a,l,d,c,p,h,u;if(((o=e.dating)==null?void 0:o.year)!=null)return e.dating.year;if(typeof((s=e.lineage)==null?void 0:s.year)=="number")return e.lineage.year;const n=(a=e.publication_info)==null?void 0:a.year;if(n){const m=zi(n);if(m)return m.from}const i=[(l=e.lineage)==null?void 0:l.year_text,(d=e.publication_info)==null?void 0:d.year,e.edition,e.edition?void 0:e.title].filter(Boolean);for(const m of i){const f=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(f&&m!==f&&(At(f)||oo(f)))break;const x=m.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??m.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(x){const w=parseInt(x[1],10);if(w>=100&&w<=2100)return w}const v=m.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(v){const w=At(m);if(!w||nt(w)==="民國"){const k=fi(v[1]);if(k!=null&&k>=1&&k<=120)return th+k}}const y=At(m)??((h=mn.find(w=>w.pattern.test(m)))==null?void 0:h.era),S=y?nt(y):void 0,b=Jt(m,S)??(At(m)||(u=mn.find(w=>w.pattern.test(m)))==null?void 0:u.reign);if(b){const w=Xt(b,S);if(w==null)continue;const j=m.indexOf(b),k=j>=0?m.slice(j+b.length):"",$=k.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??k.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),C=$?fi($[1]):void 0;return w+(C?C-1:0)}}}function so(e){var l,d,c,p,h,u;const n=(l=e.dating)==null?void 0:l.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const i=(d=e.lineage)==null?void 0:d.year_range;if(i&&i.length===2)return{from:i[0],to:i[1]};const o=(c=e.lineage)==null?void 0:c.year_text;if(o){const m=o.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(m){const f=$r[nt(m[1])],x=Zt[nt(m[2])];if(f!=null&&x!=null)return{from:Math.min(f,x)-20,to:Math.max(f,x)+40}}}const s=(p=e.publication_info)==null?void 0:p.year;if(s){const m=zi(s);if((m==null?void 0:m.to)!=null)return{from:m.from,to:m.to};const f=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(f){const x=$r[nt(f[1])],v=Zt[nt(f[2])];if(x!=null&&v!=null)return{from:Math.min(x,v)-20,to:Math.max(x,v)+40}}}const a=[(h=e.publication_info)==null?void 0:h.year,e.edition,e.title].filter(Boolean);for(const m of a){if(!/[間间]/.test(m))continue;const f=At(m)??oo(m)??((u=mn.find(y=>y.pattern.test(m)))==null?void 0:u.era),x=f?nt(f):void 0,v=[];for(const y of Object.keys(hn))m.includes(y)&&(x&&Ct[y]&&Ct[y]!==x||Xt(y,x)!=null&&v.push(y));if(v.length===0){const y=m.match(/([一-鿿])([一-鿿])[間间]/);if(y&&x){for(const S of[y[1],y[2]])for(const b of Object.keys(hn))if(Ct[b]===x&&!(b[0]!==S&&b[b.length-1]!==S)&&Xt(b,x)!=null){v.push(b);break}}}if(v.length>0){const y=v.map(j=>Xt(j,x)).filter(j=>j!=null),S=Math.min(...y),b=v.reduce((j,k)=>Xt(j,x)>=Xt(k,x)?j:k),w=nh(b)??lr(x??"")??Math.max(...y);return{from:S,to:w>S?w:lr(x??Ct[b]??"")??S}}if(x&&Zt[x]!=null)return{from:Zt[x],to:lr(x)??Zt[x]}}}const Zt={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},rh=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],oh=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,qs=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function Ks(e,n){for(const i of Gl){const o=e.indexOf(i);if(o<0)continue;if(i.length===1){const c=e[o+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!Jt(e.slice(o),nt(i)))continue}const s=nt(i);if(s===n)continue;const a=e.slice(o),l=Jt(a,s)??"";let d;if(l){const c=Xt(l,s);if(c!=null){const h=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),u=h?fi(h[1]):void 0;d=c+(u?u-1:0)}}return{era:s,reign:l,year:d}}for(const i of mn)if(i.pattern.test(e))return{era:nt(i.era),reign:i.reign??""}}function sh(e){var S,b,w,j,k;const n=Wn(e),i=((S=e.publication_info)==null?void 0:S.year)??"",o=i?zi(i):void 0;if(!n.era&&!n.reign&&!o)return;const s=e.edition||e.title||"",a=/[間间]/.test(s),l=((b=e.lineage)==null?void 0:b.year_text)??"",d=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(l),c=n.source==="publication"&&eh.test(i),p=n.source==="publication"&&/[間间]/.test(i),h=l.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let u;a||d||c||p?u=void 0:h?u=parseInt(h[2],10):u=Ni(e);const m=u==null?so(e):void 0;let f;n.source==="publication"&&(c||qs.test(i))?f="uncertain":n.source==="lineage"||n.source==="publication"?f="attested":qs.test(s)||!n.reign&&u==null?f="uncertain":f="inferred";const x=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((w=e.lineage)==null?void 0:w.year_text)??((j=e.lineage)==null?void 0:j.year)??""}」`:`出版著錄「${((k=e.publication_info)==null?void 0:k.year)??""}」`,v={era:n.era,reign:n.reign,year:u,yearRange:m,certainty:f,source:n.source==="edition"?"edition":"catalog",basis:x};if(h){const $=l.match(/[、,,]\s*([宋元明清])/);$&&$[1]!==v.era&&(v.laterRepair={era:$[1]})}if(!v.laterRepair&&oh.test(s)){const $=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);$&&$[1]!==n.era&&(v.laterRepair={era:$[1]})}const y=rh.find($=>$.re.test(s));if(y){const $=s.search(y.re),C=s.slice($),_=Ks(C,n.era)??Ks(s,n.era);_&&(v.basedOn={era:_.era,reign:_.reign,year:_.year,relation:y.relation})}return v}const $r={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function lr(e){return $r[e]}function xi(e){const n=Ni(e);if(n!=null)return n;const i=so(e);if(i)return i.from;const o=Wn(e).era;return o?Zt[o]:void 0}const Xs=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function Cr(e){const n=Xs.indexOf(e);return n===-1?Xs.length:n}function ah(e){const n={belongsTo:[],collected:[],contains:[],derivative:[],studies:[],related:[]};for(const s of e){const a=s.relation;a==="part_of"?n.belongsTo.push(s):a==="collected_in"?n.collected.push(s):a==="has_part"||a==="contains_text_of"?n.contains.push(s):a==="text_carried_by"||a==="studied_by"||a==="derived_from"||a==="followed_by"||a==="has_adaptation"?n.derivative.push(s):a==="studies"||a==="preceded_by"?n.studies.push(s):n.related.push(s)}const i=[],o=(s,a)=>{n[s].length&&i.push({key:s,labelKey:a,items:n[s]})};return o("belongsTo","belongsToWork"),o("collected","collectedIn"),o("contains","containedWorks"),o("derivative","derivativeWorks"),o("studies","studies"),o("related","relatedWorks"),i}function ao(e,n){const i=Yr(e||[]),o=new Map,s=[];for(const p of i)p.group?(o.has(p.group)||o.set(p.group,[]),o.get(p.group).push(p)):s.push(p);for(const p of o.values())p.sort((h,u)=>{const m=f=>f.group_role==="origin"?0:f.group_role==="mirror"?1:2;return m(h)-m(u)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const h=Mt(p),u=h.includes("text"),m=h.includes("image");u&&m?a.textImage.push(p):u?a.text.push(p):m?a.image.push(p):a.physical.push(p)}const d=["text","image","textImage","physical"].filter(p=>a[p].length>0).map(p=>({key:p,items:a[p]})),c=[...o.entries()].map(([p,h])=>{var u,m;return{key:p,label:((u=n==null?void 0:n[p])==null?void 0:u.label)||p,description:(m=n==null?void 0:n[p])==null?void 0:m.description,items:h}});return{buckets:d,mirrors:c,total:i.length}}function Ii(e,n=yn("zh-Hant")){const i=[],o=e.metadata||{};o.edition&&i.push(String(o.edition)),e.source_label&&i.push(e.source_label),e.details&&i.push(e.details);const s=ki(e);return s&&s.expected>0&&i.push(s.missing>0?n("detail.volumeStatsMissing",{found:s.found,expected:s.expected,missing:s.missing}):n("detail.volumeStats",{found:s.found,expected:s.expected})),o.version&&i.push(String(o.version)),i.join(" · ")}function ql(e,n){if(Ii(e)||n.filter(o=>o.name===e.name).length<2)return"";try{const o=new URL(e.url),s=o.searchParams.get("res")||o.searchParams.get("id");if(s)return s;const a=o.pathname.split("/").filter(Boolean).pop();if(a)return decodeURIComponent(a)}catch{}return""}function Kl(e,n){var a,l;const i=e.resources||[],o=[],s=[];for(const d of i){const c=Mt(d);c.includes("image")&&o.push(d),c.includes("physical")&&s.push(d)}return{id:e.id,name:e.edition||e.title||e.id,era:Wn(e),year:Ni(e),sortYear:xi(e),images:o,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,important:lh(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:o.length>0}}function lh(e,n){var d,c;if(!n)return!1;const i=n.default_collection;if(!i)return!1;const o=(d=n.collections)==null?void 0:d[i];if(((o==null?void 0:o.book_ids)??(i==="core"?n.core_books??[]:[])).includes(e))return!0;const a=(o==null?void 0:o.groups)??[],l=(c=n.node_groups)==null?void 0:c[e];return!!l&&a.includes(l)}function Xl(e,n,i={}){const o=new Set((n==null?void 0:n.excluded_books)??[]),s=e.filter(c=>!o.has(c.id)).map(c=>Kl(c,n));let a=s;i.era&&(a=a.filter(c=>c.era.era===i.era)),i.scanOnly&&(a=a.filter(c=>c.hasImage)),i.sort==="year"?a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const h=c.r.sortYear,u=p.r.sortYear;return h!=null&&u!=null?h-u||c.i-p.i:h!=null?-1:u!=null?1:c.i-p.i}).map(c=>c.r):a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const h=u=>(u.important?0:1)*2+(u.hasImage?0:1);return h(c.r)-h(p.r)||c.i-p.i}).map(c=>c.r);const d=[...new Set(s.map(c=>c.era.era).filter(Boolean))].sort((c,p)=>Cr(c)-Cr(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function ch(e,n){var y,S;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const i=(y=n.collections)==null?void 0:y[n.default_collection],o=(i==null?void 0:i.groups)??[],s=(i==null?void 0:i.book_ids)??[],a=o.length>0||s.length>0,l=!a&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!a&&l.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const d=new Set(o),c=new Set([...s,...l]),p=b=>{if(c.has(b))return!0;const w=n.node_groups[b];return w!=null&&d.has(w)},h=[],u=new Map,m=[];for(const b of e)if(!((S=n.excluded_books)!=null&&S.includes(b)))if(p(b))h.push(b);else{const w=n.node_groups[b];w?(u.has(w)||u.set(w,[]),u.get(w).push(b)):m.push(b)}if(m.length+[...u.values()].reduce((b,w)=>b+w.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const x=new Map((n.groups??[]).map(b=>[b.id,b])),v=[...u.entries()].map(([b,w])=>{const j=x.get(b);return{id:b,label:(j==null?void 0:j.label)??b,description:j==null?void 0:j.description,ids:w}});return m.length>0&&v.push({id:"__other__",label:"其他版本",description:void 0,ids:m}),{useGrouping:!0,coreIds:h,groupedIds:v}}const Zl=["撰","編","注","校","譯","繪","其他"],dh=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function lo(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n)return"撰";for(const{cls:i,re:o}of dh)if(o.test(n))return i;return"其他"}function co(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function Jl(e,n="全部"){const i=new Map;for(const s of e){const a=lo(s);i.set(a,(i.get(a)??0)+1)}const o=[{cls:"全部",label:n,count:e.length}];for(const s of Zl){const a=i.get(s);a&&o.push({cls:s,label:s,count:a})}return o.length>2?o:[]}function po(e){return(e._books??[]).map(n=>n.id).filter(n=>typeof n=="string")}function uo(e){const n=e._classifications??[],i=n.find(o=>o.scheme==="zongmu")??n[0];if(i)return{l1:i.l1??"",l2:i.l2??"",l3:i.l3??"",l4:i.l4??"",...i.source?{source:i.source}:{}}}function Ql(e){const n=e._members??[],i=typeof e._member_count=="number"?e._member_count:n.length;return{works:n.filter(o=>o.t==="work").map(o=>({id:o.id,title:o.title??"",volumes:Ln(o.vol)})),bookIds:n.filter(o=>o.t!=="work").map(o=>o.id).filter(o=>typeof o=="string"),total:i,truncated:i>n.length}}function ph(e){var n;return(e==null?void 0:e._member_count)||((n=e==null?void 0:e._members)==null?void 0:n.length)||0}function ec(e,n,i){if(n&&n.books&&n.books.length>0){const l=n.books.map(c=>({id:c.work_id||c.book_id||void 0,title:c.title,section:c.section,volumes:c.volumes||[],subItems:c.sub_items,edition:c.edition,found:c.found_volumes,expected:c.expected_volumes})),d=[...new Set(l.map(c=>c.section).filter(Boolean))];return{rows:l,source:"catalog",sections:d,totalVolumes:n.total_volumes}}const{works:o,bookIds:s}=Ql(e);return o.length>0?{rows:o.map(d=>({id:d.id,title:d.title,volumes:d.volumes})),source:"works",sections:[]}:{rows:s.map(l=>{var d,c;return{id:l,title:((d=i==null?void 0:i.get(l))==null?void 0:d.title)||l,edition:(c=i==null?void 0:i.get(l))==null?void 0:c.edition,volumes:[]}}),source:"books",sections:[]}}function Ln(e){if(e==null)return[];if(typeof e=="number")return[e];if(Array.isArray(e))return e.filter(n=>typeof n=="number");if(typeof e=="string"){const n=e.match(/^(\d+)\s*[-–~]\s*(\d+)$/);if(n){const[i,o]=[parseInt(n[1]),parseInt(n[2])];return Array.from({length:Math.max(0,o-i+1)},(s,a)=>i+a)}return e.split(/[,、]/).map(i=>parseInt(i.trim())).filter(i=>!isNaN(i))}return[]}function Ri(e,n="冊"){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const i=[...e].sort((a,l)=>a-l),o=i[0],s=i[i.length-1];return s-o+1===i.length?`${o}–${s}`:i.length<=3?i.join(", "):`${o}–${s} (${i.length}${n})`}const uh=["〇","一","二","三","四","五","六","七","八","九"],Zs=["","十","百","千"];function tc(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),i=n.length;let o="",s=!1;for(let a=0;a<i;a++){const l=parseInt(n[a]),d=i-1-a;l===0?s=!0:(s&&o&&(o+="〇"),s=!1,l===1&&d===1&&a===0?o+=Zs[d]:o+=uh[l]+Zs[d])}return o}function mh(e){return e==null?"":typeof e=="string"?e:"name"in e&&e.name?e.name:"title"in e&&e.title||""}function hh(e){if(e==null||typeof e=="string")return;const n="url"in e&&e.url?e.url:"type"in e&&e.type==="url"?e.details:void 0;return n&&/^https?:\/\//i.test(n)?n:void 0}function Bt(e,n="卷"){var o,s;const i=e;return i.measure_info?i.measure_info:(o=i.juan_count)!=null&&o.number?tc(i.juan_count.number)+n:(s=i.juan_count)!=null&&s.description?i.juan_count.description:""}function nc(e){var o;if(e.edition_type)return e.edition_type;if((o=e.lineage)!=null&&o.category)return e.lineage.category;const n=e.edition||e.title||"",i=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,a]of i)if(s.test(n))return a;return""}const gh=65536,fh="guji_markdown";function xh(e){const n=e==null?void 0:e.guji_markdown;if(typeof n!="string")return!1;const i=/^(\d+)\.(\d+)(?:\.\d+)?$/.exec(n.trim());if(!i)return!1;const o=parseInt(i[1],10),s=parseInt(i[2],10);return o>0||s>=2}const bh=/^□\{guess=([^\s{}]+)\}/;function yh(e,n){const i=e[n+1];return i!==void 0&&!/[A-Za-z/!?>\s]/.test(i)}function ic(e,n){let i=0;for(let o=n;o<e.length;o++){const s=e[o];if(s===`
|
|
678
|
-
`)return-1;if(s==="\\"){o++;continue}if(s==="[")i++;else if(s==="]"&&(i--,i===0))return o}return-1}function
|
|
679
|
-
`)<0?{node:{type:"qw",label:e.slice(n+2,o)},end:o+2}:null}if(i===":"&&e.startsWith(":zi[",n)){const o=
|
|
680
|
-
`)return null}const h=
|
|
681
|
-
.bim-d-main.bim-d-main-grid { max-width: ${
|
|
676
|
+
`;function io(e,n){var i;return n?e.key===n?!0:!!((i=e.children)!=null&&i.some(o=>io(o,n))):!1}const Wm=()=>t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:t.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Om({item:e,activeKey:n,onSelect:i,tabKey:o}){const s=io(e,n),[a,l]=g.useState(s||!!e.defaultExpanded);return g.useEffect(()=>{s&&l(!0)},[s]),g.useEffect(()=>{e.defaultExpanded&&l(!0)},[e.defaultExpanded]),t.jsxs("li",{children:[t.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":a,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>l(d=>!d),children:[t.jsx(Wm,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),a&&t.jsx(Wl,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]})}function Wl({items:e,activeKey:n,onSelect:i,tabKey:o}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(Om,{item:s,activeKey:n,onSelect:i,tabKey:o},s.key):t.jsx("li",{children:t.jsxs("button",{type:"button",className:"bim-rd-ti","aria-current":s.key===n?"true":void 0,disabled:s.disabled,"data-rd-toc-key":s.key,tabIndex:o===s.key?0:-1,onClick:()=>i(s.key),children:[t.jsx("span",{children:s.label}),s.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:s.hint})]})},s.key))})}function Fs(e,n){var i;for(const o of e)if(o.key===n||io(o,n))return o.key;return((i=e[0])==null?void 0:i.key)??null}function Ol({items:e,activeKey:n,onSelect:i,label:o}){const{t:s}=ne(),a=o??s("reader.toc"),l=g.useRef(null),[d,c]=g.useState(null);g.useEffect(()=>{c(null)},[n]);const p=g.useMemo(()=>d||(n??Fs(e,n)),[d,n,e]);g.useEffect(()=>{const u=l.current;if(!u)return;const m=Array.from(u.querySelectorAll("[data-rd-toc-key]"));if(m.length===0)return;const f=m.find(x=>x.dataset.rdTocKey===p)??m.find(x=>x.dataset.rdTocKey===Fs(e,n))??m.find(x=>!x.disabled)??m[0];for(const x of m)x.tabIndex=x===f?0:-1}),g.useEffect(()=>{const u=l.current,m=u==null?void 0:u.closest(".bim-rd-toc");if(!u||!m||!n)return;const f=Array.from(u.querySelectorAll("[data-rd-toc-key]")).find(v=>v.dataset.rdTocKey===n);if(!f)return;const x=f.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop;(x<m.scrollTop+80||x>m.scrollTop+m.clientHeight-40)&&(m.scrollTop=Math.max(0,x-m.clientHeight/3))},[n]);const h=g.useCallback(u=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(u.key))return;const f=l.current;if(!f)return;const x=Array.from(f.querySelectorAll("[data-rd-toc-key]")).filter(b=>!b.disabled),v=x.indexOf(document.activeElement);let y=v;if(u.key==="ArrowDown"?y=Math.min(x.length-1,v+1):u.key==="ArrowUp"?y=Math.max(0,v-1):u.key==="Home"?y=0:u.key==="End"&&(y=x.length-1),y<0||y===v)return;u.preventDefault();const S=x[y];for(const b of x)b.tabIndex=-1;S.tabIndex=0,S.focus(),c(S.dataset.rdTocKey??null)},[]);return t.jsx("div",{ref:l,role:"navigation","aria-label":a,onKeyDown:h,children:t.jsx(Wl,{items:e,activeKey:n,onSelect:i,tabKey:p})})}function Hs({page:e,crop:n}){var i;return!((i=e.boxes)!=null&&i.length)||!e.width||!e.height||e.boxFormat&&e.boxFormat!=="bim-charbox-v0"?null:t.jsx("svg",{viewBox:n?`${n.x} ${n.y} ${n.w} ${n.h}`:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:e.boxes.map((o,s)=>t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:"none",stroke:r("accent"),strokeOpacity:.55,vectorEffect:"non-scaling-stroke",strokeWidth:1},s))})}function Fm(e){const{boxes:n,width:i,height:o}=e;if(!(n!=null&&n.length)||!i||!o||e.boxFormat&&e.boxFormat!=="bim-charbox-v0")return null;let s=1/0,a=1/0,l=-1/0,d=-1/0;for(const f of n)[f.x,f.y,f.w,f.h].every(Number.isFinite)&&(s=Math.min(s,f.x),a=Math.min(a,f.y),l=Math.max(l,f.x+f.w),d=Math.max(d,f.y+f.h));if(!(l>s)||!(d>a))return null;const c=Math.min(i,o)*.03,p=Math.min(i,Math.max(0,s-c)),h=Math.min(o,Math.max(0,a-c)),u=Math.min(i,Math.max(0,l+c))-p,m=Math.min(o,Math.max(0,d+c))-h;return!(u>0)||!(m>0)||u>=i*.98&&m>=o*.98?null:{x:p,y:h,w:u,h:m}}function wr({pages:e,loading:n,page:i,onPageChange:o,renderOverlay:s,preserveMargins:a=!0}){const{t:l}=ne(),[d,c]=g.useState(0),p=i??d,h=v=>{o?o(v):c(v)};if(g.useEffect(()=>{i===void 0&&c(0)},[e,i]),n)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsx("div",{className:"bim-rd-img-empty",children:l("reader.imagesLoading")})});if(!e||e.length===0)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsxs("div",{className:"bim-rd-img-empty",children:[t.jsx("div",{className:"bim-rd-img-frame","aria-hidden":"true"}),t.jsx("b",{children:l("reader.noImages")}),t.jsx("span",{children:l("reader.noImagesHint")})]})});const u=Math.max(0,Math.min(e.length-1,p)),m=e[u],f=m.label??`${u+1}`,x=!a&&!s?Fm(m):null;return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-img-box",children:x?t.jsxs("figure",{className:"bim-rd-img-fig bim-rd-img-trimmed","data-trim":`${Math.round(x.x)},${Math.round(x.y)},${Math.round(x.w)},${Math.round(x.h)}`,style:{aspectRatio:`${x.w} / ${x.h}`,overflow:"hidden",width:"100%",maxWidth:`calc((100vh - 200px) * ${x.w/x.h})`},children:[t.jsx("img",{src:m.url,alt:m.alt??l("reader.imageAlt",{label:f}),decoding:"async",style:{position:"absolute",maxWidth:"none",maxHeight:"none",width:`${m.width/x.w*100}%`,left:`${-x.x/x.w*100}%`,top:`${-x.y/x.h*100}%`}}),t.jsx(Hs,{page:m,crop:x})]}):t.jsxs("figure",{className:"bim-rd-img-fig",children:[t.jsx("img",{src:m.url,alt:m.alt??l("reader.imageAlt",{label:f}),width:m.width,height:m.height,loading:"lazy",decoding:"async"}),t.jsx(Hs,{page:m}),s==null?void 0:s(m,u)]})}),e.length>1&&t.jsxs("div",{className:"bim-rd-img-pager",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.prevImage"),disabled:u===0,onClick:()=>h(u-1),children:"‹"}),t.jsx("span",{"aria-live":"polite",children:m.label??`${u+1} / ${e.length}`}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.nextImage"),disabled:u===e.length-1,onClick:()=>h(u+1),children:"›"})]})]})}function Hm(e){return e==="lite"||e==="full"}const Pn=[.1,.9],Fl=[{key:"song",stack:null},{key:"kai",stack:'"Kaiti SC", "Kaiti TC", STKaiti, "KaiTi", "AR PL UKai CN", "Noto Serif CJK SC", serif'},{key:"system",stack:"var(--bim-font-ui)"}];function Dm(e){var n;return((n=Fl.find(i=>i.key===e))==null?void 0:n.stack)??null}const ro={fontSize:null,readingMode:"line",properNameMode:null,writingMode:"horizontal",workLinks:!0,fontFamily:"song",pageBreaks:!0,pageIndicatorY:.33,bookTitleStyle:"wavy",showWorks:!0,quoteStyle:"original",scriptMode:null,preserveMargins:!0},Et=[15,16,17,18,20,22,24],Sr=18,Hl="bim-reader-prefs",Um="bim-reading-mode";function Vm(){const e={...ro};try{const n=localStorage.getItem(Hl),i=n?JSON.parse(n):{};typeof i.fontSize=="number"&&Et.includes(i.fontSize)&&(e.fontSize=i.fontSize),(i.readingMode??localStorage.getItem(Um))==="paragraph"&&(e.readingMode="paragraph"),i.properNameMode==="off"||i.properNameMode==="lite"||i.properNameMode==="full"?e.properNameMode=i.properNameMode:i.properNames===!0?e.properNameMode="full":i.properNames===!1&&(e.properNameMode="off"),i.writingMode==="vertical"&&(e.writingMode="vertical"),i.workLinks===!1&&(e.workLinks=!1),(i.fontFamily==="kai"||i.fontFamily==="system")&&(e.fontFamily=i.fontFamily),i.pageBreaks===!1&&(e.pageBreaks=!1),typeof i.pageIndicatorY=="number"&&Number.isFinite(i.pageIndicatorY)&&i.pageIndicatorY>=Pn[0]&&i.pageIndicatorY<=Pn[1]&&(e.pageIndicatorY=i.pageIndicatorY),i.bookTitleStyle==="bracket"&&(e.bookTitleStyle="bracket"),i.showWorks===!1&&(e.showWorks=!1),(i.quoteStyle==="modern"||i.quoteStyle==="classic")&&(e.quoteStyle=i.quoteStyle),(i.scriptMode==="orig"||i.scriptMode==="hant"||i.scriptMode==="hans")&&(e.scriptMode=i.scriptMode),i.preserveMargins===!1&&(e.preserveMargins=!1)}catch{}return e}function Gm(e){try{localStorage.setItem(Hl,JSON.stringify(e))}catch{}}function ri(e,n){const i=e??Sr,o=Et;let s=o.indexOf(i);return s<0&&(s=o.indexOf(Sr)),o[Math.max(0,Math.min(o.length-1,s+n))]}function Dl(){const[e,n]=g.useState(ro);g.useEffect(()=>{n(Vm())},[]);const i=g.useCallback(o=>{n(s=>{const a={...s,...o};return Gm(a),a})},[]);return[e,i]}function _r(e){if(e.optionLabel)return e.optionLabel;const n=e.label||e.key;return!e.sourceName||n.includes(e.sourceName)?n:`${n} · ${e.sourceName}`}function Ul(e,n){if(!(!e||e.length===0))return(n!=null?e.find(i=>i.key===n):void 0)??e.find(i=>i.primary)??e[0]}function Vl(e){const n=[],i=o=>{for(const s of o)s.children&&s.children.length>0?i(s.children):n.push(s)};return i(e),n}const Ds=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:t.jsx("path",{d:"M4 6h16M4 12h10M4 18h16"})}),Ym=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M15 5l-7 7 7 7"})}),qm=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M9 5l7 7-7 7"})}),Us=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M4 7h10M18 7h2M4 17h2M10 17h10"}),t.jsx("circle",{cx:"16",cy:"7",r:"2"}),t.jsx("circle",{cx:"8",cy:"17",r:"2"})]}),Vs=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"4",y:"3",width:"16",height:"18",rx:"1.5"}),t.jsx("path",{d:"M9 3v18M13 7v10M16.5 7v10"})]});function Gs(e,n){if(!n)return;const i=Array.from(n.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(l=>l.tabIndex>=0);if(i.length===0)return;const o=i[0],s=i[i.length-1],a=document.activeElement;e.shiftKey&&(a===o||!n.contains(a))?(e.preventDefault(),s.focus()):!e.shiftKey&&(a===s||!n.contains(a))&&(e.preventDefault(),o.focus())}function Ys(e,n){const[i,o]=g.useState(n);return g.useEffect(()=>{var l;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(e);o(s.matches);const a=()=>o(s.matches);return(l=s.addEventListener)==null||l.call(s,"change",a),()=>{var d;return(d=s.removeEventListener)==null?void 0:d.call(s,"change",a)}},[e]),i}function Km({prefs:e,onPrefsChange:n}){const i=g.useContext(Tt),{t:o}=ne();if(!i)return null;const s=i.locale==="zh-Hans"?"hans":"hant",a=e.scriptMode==="orig"?"orig":s,l=[{key:"orig",short:o("reader.scriptOrigShort"),title:o("reader.scriptOrig")},{key:"hant",short:o("common.localeShortHant"),title:o("reader.scriptHant")},{key:"hans",short:o("common.localeShortHans"),title:o("reader.scriptHans")}];return t.jsx("span",{className:"bim-rd-script-sw",role:"group","aria-label":o("reader.scriptQuick"),children:l.map((d,c)=>t.jsxs(g.Fragment,{children:[c>0&&t.jsx("span",{className:"bim-rd-off","aria-hidden":"true",children:"|"}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":a===d.key,title:d.title,"aria-label":d.title,onClick:()=>{n({scriptMode:d.key}),d.key==="hant"?i.setLocale("zh-Hant"):d.key==="hans"&&i.setLocale("zh-Hans")},children:d.short})]},d.key))})}function di({label:e,value:n,options:i,onPick:o,title:s}){return t.jsxs("div",{className:"bim-rd-sp-row",role:"group","aria-label":e,title:s,children:[t.jsx("span",{className:"bim-rd-sp-l",children:e}),t.jsx("span",{className:"bim-rd-sp-fs",children:i.map(a=>t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":n===a.key,title:a.title,onClick:()=>o(a.key),children:a.label},a.key))})]})}function Xm({prefs:e,onPrefsChange:n}){const i=g.useContext(Tt),{t:o}=ne(),s=(i==null?void 0:i.locale)==="zh-Hans"?"hans":"hant",a=e.scriptMode==="orig"?"orig":s;return t.jsx(di,{label:o("reader.script"),value:a,options:[{key:"orig",label:o("reader.scriptOrig")},{key:"hant",label:o("reader.scriptHant")},{key:"hans",label:o("reader.scriptHans")}],onPick:l=>{n({scriptMode:l}),l==="hant"?i==null||i.setLocale("zh-Hant"):l==="hans"&&(i==null||i.setLocale("zh-Hans"))}})}function Zm(e,n){if(!e)return;let i;for(const o of Array.from(e.querySelectorAll('[id^="rd-e-"]')))if(o.getBoundingClientRect().top<=n+8)i=o.id;else break;return i}function Jm(e){var a;if(typeof window>"u"||!e)return;const n=(a=window.getSelection)==null?void 0:a.call(window);if(!n||n.isCollapsed||n.rangeCount===0)return;const i=e.querySelector(".bim-rd-col"),o=l=>{const d=(l==null?void 0:l.nodeType)===1?l:l==null?void 0:l.parentElement;return!!l&&!!(i!=null&&i.contains(l))&&!(d!=null&&d.closest(".bim-rd-src, .bim-rd-pager"))};if(!o(n.anchorNode)||!o(n.focusNode))return;const s=n.toString().replace(/\s+/g," ").trim();return s?s.slice(0,500):void 0}function Gl({title:e,subtitle:n,toc:i,activeKey:o,onSelect:s,tocHeader:a,tocCaption:l,images:d,imagesLoading:c,renderImageOverlay:p,imagePanel:h="auto",prefs:u,onPrefsChange:m,paragraphToggle:f,properNameToggle:x=!0,allowVertical:v,byline:y,current:S,workLinkToggle:b,rail:w,onReportError:j,revisedAt:k,backHref:$,backLabel:C,bottomBar:_=!0,pager:E=!0,pagerUnit:z,versions:T,currentVersionKey:B,onVersionChange:W,versionSource:N=!0,keepChapterOnVersionChange:A=!1,customImagePanel:F,toolbarExtra:Y,settingsAnnotate:te,settingsLayout:se,isWarpMode:D,children:V,className:he,style:Z}){const{t:M,convert:_e}=ne(),ce=C??M("reader.back"),ge=_e(z??M("reader.unitJuan")),le=g.useId().replace(/:/g,""),Be=`bim-rd-toc-${le}`,ze=`bim-rd-text-${le}`,Fe=g.useRef(null),Q=g.useRef(null),H=g.useRef(null),G=g.useRef(null),xe=Ys(Al,!0),K=Ys(Pl,!1),L=_&&K,[q,ae]=g.useState(null),[be,X]=g.useState(!1),re=g.useRef(null),Ce=`bim-rd-set-${le}`,We=g.useRef(null),O=g.useRef(null),ie=(J,Re)=>{O.current=Re,ae(qe=>qe===J?null:J)},je=g.useCallback(()=>{var J;ae(null),(J=O.current)==null||J.focus()},[]);g.useEffect(()=>{L||ae(null)},[L]),g.useEffect(()=>{var J,Re;q&&((Re=(J=We.current)==null?void 0:J.querySelector("button:not([disabled])"))==null||Re.focus())},[q]);const[ke,P]=g.useState("auto"),fe=ke==="auto"?xe:ke==="open",oe=!xe,we=!!F||!!d&&d.length>0,[Le,He]=g.useState(h);g.useEffect(()=>{He(h)},[h]);const Ge=Le==="auto"?we||!!c:Le==="open",Ye=g.useCallback(J=>{var Re;P("auto"),J&&((Re=G.current)==null||Re.focus())},[]),Xe=()=>P(fe?"closed":"open");g.useEffect(()=>{if(!oe||ke!=="open")return;const J=H.current,Re=J==null?void 0:J.querySelector('input, [data-rd-toc-key][tabindex="0"]');Re==null||Re.focus()},[oe,ke]);const I=g.useCallback(J=>{s(J),oe&&Ye(!1);const Re=Q.current,qe=Fe.current;if(Re&&qe&&typeof window<"u"){const ot=Re.getBoundingClientRect().top-qe.getBoundingClientRect().bottom;ot<0&&window.scrollBy({top:ot})}},[s,oe,Ye]),U=g.useMemo(()=>Vl(i),[i]),[pe,$e]=g.useState(null),ye=Ul(T,B!==void 0?B:pe),ue=(ye==null?void 0:ye.key)??null,Ve=g.useMemo(()=>U.map(J=>J.key).join(`
|
|
677
|
+
`),[U]),ee=g.useRef(null),ve=J=>{J!==ue&&(A||(ee.current={key:J,sig:Ve,done:!1}),B===void 0&&$e(J),W==null||W(J))};g.useEffect(()=>{const J=ee.current;if(!J||J.key!==ue)return;const Re=U.find(ot=>!ot.disabled);if(!Re)return;const qe=Ve!==J.sig;!qe&&J.done||(qe?ee.current=null:J.done=!0,Re.key!==o&&I(Re.key))},[ue,Ve,U,o,I]);const Ae=U.find(J=>J.key===o),Oe=()=>{var J;j==null||j({chapterKey:o,chapterLabel:typeof(Ae==null?void 0:Ae.label)=="string"?Ae.label:void 0,anchor:Zm(Q.current,((J=Fe.current)==null?void 0:J.getBoundingClientRect().bottom)??0),selectedText:Jm(Q.current)})},Ie=U.findIndex(J=>J.key===o),me=Ie>0?U.slice(0,Ie).reverse().find(J=>!J.disabled):void 0,Te=Ie>=0?U.slice(Ie+1).find(J=>!J.disabled):void 0,De=u.fontSize??Sr,Me=Dm(u.fontFamily),yt={...Z,...u.fontSize?{"--bimrd-fs":`${u.fontSize}px`}:null,...Me?{"--bimrd-ff":Me}:null},jt={song:M("reader.fontSong"),kai:M("reader.fontKai"),system:M("reader.fontSystem")},on=x||!!te,Wt=t.jsxs("div",{className:"bim-rd-sp",children:[t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Ce}-g1`,children:[t.jsx("h3",{id:`${Ce}-g1`,className:"bim-rd-sp-h",children:M("reader.groupText")}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:M("reader.font")}),t.jsx("select",{className:"bim-rd-sp-sel","aria-label":M("reader.font"),value:u.fontFamily,onChange:J=>m({fontFamily:J.target.value}),children:Fl.map(J=>t.jsx("option",{value:J.key,children:jt[J.key]},J.key))})]}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:M("reader.fontSize")}),t.jsxs("span",{className:"bim-rd-sp-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":M("reader.fontSmaller"),disabled:De<=Et[0],onClick:()=>m({fontSize:ri(u.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[De,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":M("reader.fontLarger"),disabled:De>=Et[Et.length-1],onClick:()=>m({fontSize:ri(u.fontSize,1)}),children:"A+"})]})]}),t.jsx(Xm,{prefs:u,onPrefsChange:m}),t.jsx(di,{label:M("reader.quoteStyle"),value:u.quoteStyle,options:[{key:"modern",label:M("reader.quoteModern")},{key:"classic",label:M("reader.quoteClassic")},{key:"original",label:M("reader.quoteOriginal")}],onPick:J=>m({quoteStyle:J})})]}),on&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Ce}-g2`,children:[t.jsx("h3",{id:`${Ce}-g2`,className:"bim-rd-sp-h",children:M("reader.groupMark")}),x&&t.jsxs(t.Fragment,{children:[t.jsx(di,{label:M("reader.properName"),value:u.properNameMode,title:M("reader.properNameTitle"),options:[{key:"off",label:M("reader.properNameOff")},{key:"lite",label:M("reader.properNameLite"),title:M("reader.properNameLiteTitle")},{key:"full",label:M("reader.properNameFull")}],onPick:J=>m({properNameMode:J})}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.showWorks,onChange:J=>m({showWorks:J.target.checked})}),t.jsx("span",{children:M("reader.showWorks")})]}),t.jsx(di,{label:M("reader.bookTitleStyle"),value:u.bookTitleStyle,options:[{key:"wavy",label:M("reader.bookTitleWavy")},{key:"bracket",label:M("reader.bookTitleBracket")}],onPick:J=>m({bookTitleStyle:J})})]}),te]}),t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Ce}-g3`,children:[t.jsx("h3",{id:`${Ce}-g3`,className:"bim-rd-sp-h",children:M("reader.groupLayout")}),f&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.readingMode==="paragraph",title:M("reader.paragraphTitle"),onClick:()=>m({readingMode:u.readingMode==="paragraph"?"line":"paragraph"}),children:M("reader.paragraph")}),b&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.workLinks,onChange:J=>m({workLinks:J.target.checked})}),t.jsx("span",{children:M("reader.workLinks")})]}),v&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.writingMode==="vertical",onClick:()=>m({writingMode:u.writingMode==="vertical"?"horizontal":"vertical"}),children:M("reader.vertical")}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.pageBreaks,onChange:J=>m({pageBreaks:J.target.checked})}),t.jsx("span",{children:M("reader.pageBreaks")})]}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.preserveMargins,onChange:J=>m({preserveMargins:J.target.checked})}),t.jsx("span",{children:M("reader.preserveMargins")})]}),se]})]});return t.jsxs("div",{className:["bim-rd",u.writingMode==="vertical"&&v?"bim-rd-vertical":"",he].filter(Boolean).join(" "),"data-toc":ke,"data-img":Ge?"open":"closed","data-bb":L?"":void 0,"data-set":!L&&be?"open":void 0,"data-warp":D?"true":void 0,style:yt,children:[t.jsx("style",{children:Bl}),t.jsx("a",{className:"bim-rd-skip",href:`#${ze}`,onClick:J=>{var Re,qe,ot;J.preventDefault(),(Re=Q.current)==null||Re.focus(),(ot=(qe=Q.current)==null?void 0:qe.scrollIntoView)==null||ot.call(qe,{block:"start"})},children:M("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:Fe,children:[$&&t.jsxs("a",{className:"bim-rd-back",href:$,"aria-label":M("reader.backAria",{label:ce}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:ce})]}),(e||n||y||S)&&t.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[e&&t.jsx("b",{children:e}),y&&t.jsx("span",{className:"bim-rd-by",children:y}),S&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-rd-cur",children:S})]}),n&&t.jsx("span",{className:"bim-rd-ttl-src",children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":M("reader.settings"),children:[T&&T.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:ye?_e(_r(ye)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:M("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:M("reader.versionShort")}),t.jsx("select",{"aria-label":M("reader.version"),value:ue??"",onChange:J=>ve(J.target.value),children:T.map(J=>t.jsx("option",{value:J.key,children:_e(_r(J))},J.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),E&&(me||Te)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":M("reader.pagerGroup",{unit:ge}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":M("reader.prevUnit",{unit:ge}),title:me?typeof me.label=="string"&&me.label?M("reader.prevUnitTitle",{unit:ge,label:me.label}):M("reader.prevUnit",{unit:ge}):M("reader.firstUnit",{unit:ge}),disabled:!me,onClick:()=>me&&I(me.key),children:t.jsx(Ym,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":M("reader.nextUnit",{unit:ge}),title:Te?typeof Te.label=="string"&&Te.label?M("reader.nextUnitTitle",{unit:ge,label:Te.label}):M("reader.nextUnit",{unit:ge}):M("reader.lastUnit",{unit:ge}),disabled:!Te,onClick:()=>Te&&I(Te.key),children:t.jsx(qm,{})})]}),E&&(me||Te)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:G,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":fe,"aria-controls":Be,onClick:Xe,children:[t.jsx(Ds,{}),t.jsx("span",{className:"bim-rd-tlabel",children:M("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":Ge,onClick:()=>He(Ge?"closed":"open"),children:[t.jsx(Vs,{}),M("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(Km,{prefs:u,onPrefsChange:m}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":M("reader.fontSmaller"),disabled:De<=Et[0],onClick:()=>m({fontSize:ri(u.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":M("reader.fontLarger"),disabled:De>=Et[Et.length-1],onClick:()=>m({fontSize:ri(u.fontSize,1)}),children:"A+"}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsxs("button",{ref:re,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":be,"aria-controls":Ce,onClick:()=>X(J=>!J),children:[t.jsx(Us,{}),t.jsx("span",{className:"bim-rd-tlabel",children:M("reader.settings")})]}),Y]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:Be,ref:H,role:oe&&fe?"dialog":void 0,"aria-modal":oe&&fe?!0:void 0,"aria-label":oe&&fe?M("reader.toc"):void 0,onKeyDown:J=>{if(!(!oe||!fe)){if(J.key==="Escape"){J.stopPropagation(),Ye(!0);return}J.key==="Tab"&&Gs(J,H.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:l??M("reader.toc")}),oe&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":M("reader.closeToc"),onClick:()=>Ye(!0),children:"✕"})]}),a]}),t.jsx(Ol,{items:i,activeKey:o,onSelect:I})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>Ye(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":M("reader.images"),children:Ge&&(F||t.jsx(wr,{pages:d??null,loading:c,renderOverlay:p,preserveMargins:u.preserveMargins}))}),!L&&be&&t.jsxs("aside",{className:"bim-rd-set",id:Ce,"aria-label":M("reader.settings"),onKeyDown:J=>{var Re;J.key==="Escape"&&(J.stopPropagation(),X(!1),(Re=re.current)==null||Re.focus())},children:[t.jsxs("div",{className:"bim-rd-sp-top",children:[t.jsx("span",{children:M("reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":M("reader.closeSettings"),onClick:()=>{var J;X(!1),(J=re.current)==null||J.focus()},children:"✕"})]}),Wt]}),t.jsxs("div",{className:"bim-rd-text",id:ze,ref:Q,tabIndex:-1,"data-rail":(w||j)&&!D?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[V,N&&ye&&(ye.sourceName||ye.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":ye.key,children:[ye.sourceName&&t.jsxs(t.Fragment,{children:[M("reader.sourceLabel")," ",ye.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:ye.sourceUrl,target:"_blank",rel:"noreferrer",children:_e(ye.sourceName)}):_e(ye.sourceName)]}),ye.sourceName&&ye.license&&t.jsx("span",{className:"bim-rd-dot"}),ye.license&&t.jsx(t.Fragment,{children:M("reader.licenseOf",{license:ye.license})})]}),k&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:M("reader.revisedAt",{date:k})}),j&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:J=>J.preventDefault(),onClick:Oe,children:M("reader.reportError")})}),E&&(me||Te)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":M("reader.pagerNav"),children:[me?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>I(me.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),M("reader.prevUnit",{unit:ge})]}),t.jsx("span",{className:"bim-rd-pglabel",children:me.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",M("reader.firstUnit",{unit:ge})]}),Te?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>I(Te.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[M("reader.nextUnit",{unit:ge}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:Te.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[M("reader.lastUnit",{unit:ge})," →"]})]})]}),(w||j)&&!D&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":M("reader.rail"),children:[w,j&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:J=>J.preventDefault(),onClick:Oe,children:M("reader.reportError")})})]})]})]}),L&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":M("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":fe,"aria-controls":Be,onClick:()=>{ae(null),Xe()},children:[t.jsx(Ds,{}),t.jsx("span",{children:M("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":q==="img","aria-haspopup":"dialog",onClick:J=>ie("img",J.currentTarget),children:[t.jsx(Vs,{}),t.jsx("span",{children:M("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":q==="set","aria-haspopup":"dialog",onClick:J=>ie("set",J.currentTarget),children:[t.jsx(Us,{}),t.jsx("span",{children:M("reader.settingsShort")})]}),j&&t.jsxs("button",{type:"button",onMouseDown:J=>J.preventDefault(),onClick:()=>{ae(null),Oe()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:M("reader.reportError")})]})]}),L&&q&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:je}),t.jsxs("div",{className:"bim-rd-sheet",ref:We,role:"dialog","aria-modal":"true","aria-label":M(q==="img"?"reader.images":"reader.settings"),onKeyDown:J=>{if(J.key==="Escape"){J.stopPropagation(),je();return}J.key==="Tab"&&Gs(J,We.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:M(q==="img"?"reader.images":"reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":M("reader.close"),onClick:je,children:"✕"})]}),q==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(wr,{pages:d??null,loading:c,renderOverlay:p,preserveMargins:u.preserveMargins})}):Wt]})]})]})}const Yl=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],Qm={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function nt(e){return Qm[e]??e}const mn=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],hn={熹平:172,建安:196,黃初:220,正始:240,廣政:938,太康:280,永和:345,開皇:581,貞觀:627,開元:713,天寶:742,貞元:785,元和:806,開成:836,會昌:841,咸通:860,建隆:960,太平興國:976,咸平:998,天禧:1017,慶曆:1041,皇祐:1049,嘉祐:1056,治平:1064,熙寧:1068,元豐:1078,元祐:1086,紹聖:1094,崇寧:1102,大觀:1107,政和:1111,宣和:1119,建炎:1127,紹興:1131,隆興:1163,乾道:1165,淳熙:1174,紹熙:1190,慶元:1195,嘉泰:1201,開禧:1205,嘉定:1208,寶慶:1225,紹定:1228,端平:1234,嘉熙:1237,淳祐:1241,寶祐:1253,開慶:1259,景定:1260,咸淳:1265,大定:1161,明昌:1190,至元:1264,大德:1297,皇慶:1312,延祐:1314,泰定:1324,天曆:1328,至順:1330,至正:1341,洪武:1368,永樂:1403,宣德:1426,正統:1436,景泰:1450,天順:1457,成化:1465,弘治:1488,正德:1506,嘉靖:1522,隆慶:1567,萬曆:1573,泰昌:1620,天啟:1621,崇禎:1628,弘光:1645,隆武:1645,紹武:1646,永曆:1647,順治:1644,康熙:1662,雍正:1723,乾隆:1736,嘉慶:1796,道光:1821,咸豐:1851,同治:1862,光緒:1875,宣統:1909,慶長:1596,寬永:1624,正保:1644,慶安:1648,承應:1652,明曆:1655,萬治:1658,寬文:1661,延寶:1673,天和:1681,貞享:1684,元祿:1688,寶永:1704,享保:1716,元文:1736,寬保:1741,延享:1744,寬延:1748,寶曆:1751,明和:1764,安永:1772,天明:1781,寬政:1789,享和:1801,文化:1804,文政:1818,天保:1830,弘化:1844,嘉永:1848,安政:1854,萬延:1860,文久:1861,元治:1864,慶應:1865,明治:1868,大正:1912,昭和:1926,天正:1573,文祿:1592,永祿:1558,天文:1532},ql={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function zi(e){const n=e.match(/^\s*(\d{3,4})(?:\s*[-–—~至]\s*(\d{3,4}))?/);if(!n)return;const i=parseInt(n[1],10);if(i<100||i>2100)return;const o=n[2]?parseInt(n[2],10):void 0;return{from:i,to:o!=null&&o>=i&&o<=2100?o:void 0}}function eh(e){return e>=1950?"":e>=1912?"民國":e>=1645?"清":e>=1368?"明":e>=1279?"元":e>=960?"宋":e>=907?"五代":e>=618?"唐":e>=581?"隋":e>=420?"南北朝":e>=265?"晉":e>=220?"三國":e>=-202?"漢":""}const th=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,qs={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function oo(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(qs))if(n.startsWith(s))return qs[s];const i=nt(n);if(Zt[i]!=null)return i;const o=At(n);if(o&&n.length<=o.length+1)return nt(o)}function Xt(e,n){if(n){const i=ql[`${n}|${e}`];if(i!=null)return i}return hn[e]}const nh=1911;function ih(e){const n=hn[e];if(n==null)return;const i=Ct[e];let o;for(const[s,a]of Object.entries(hn))Ct[s]===i&&a>n&&(o==null||a<o)&&(o=a);return o!=null?o-1:void 0}const rh={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function fi(e){if(!e)return;if(/^\d+$/.test(e))return parseInt(e,10);let n=0,i=0,o=!1;for(const a of e){const l=rh[a];if(l===void 0)return;o=!0,a==="十"?i=(i||1)*10:a==="廿"||a==="卅"?(n+=l,i=0):i>=10?(n+=i+l,i=0):i=i*10+l}const s=n+i;return o&&s>0?s:void 0}function At(e){for(const n of Yl)if(e.startsWith(n))return n}const Ct={};{const e=(n,i)=>{for(const o of i)Ct[o]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function Jt(e,n){const i=n==="北宋"||n==="南宋"?"宋":n;for(const o of Object.keys(hn))if(e.includes(o)&&!(i&&Ct[o]&&Ct[o]!==i&&ql[`${i}|${o}`]==null))return o}function Wn(e){var l,d,c;const n={era:"",reign:"",source:"none"},i=e.dating;if(i!=null&&i.era||i!=null&&i.reign)return{era:i.era??"",reign:i.reign??"",source:i.certainty==="attested"?"catalog":"edition"};const o=(l=e.lineage)==null?void 0:l.year_text;if(o){const p=At(o)??"";return{era:nt(p),reign:Jt(o,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=zi(s);if(p)return{era:eh(p.from),reign:"",source:"publication"};const h=At(s)??oo(s)??((c=mn.find(f=>f.pattern.test(s)))==null?void 0:c.era)??"",u=Jt(s,h)??"",m=h||(u?Ct[u]??"":"");if(m||u)return{era:nt(m),reign:u,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=At(a);if(p)return{era:nt(p),reign:Jt(a,p)??"",source:"edition"};const h=mn.find(u=>u.pattern.test(a));if(h)return{era:nt(h.era),reign:Jt(a,h.era)??h.reign??"",source:"edition"}}return n}function Ni(e){var o,s,a,l,d,c,p,h,u;if(((o=e.dating)==null?void 0:o.year)!=null)return e.dating.year;if(typeof((s=e.lineage)==null?void 0:s.year)=="number")return e.lineage.year;const n=(a=e.publication_info)==null?void 0:a.year;if(n){const m=zi(n);if(m)return m.from}const i=[(l=e.lineage)==null?void 0:l.year_text,(d=e.publication_info)==null?void 0:d.year,e.edition,e.edition?void 0:e.title].filter(Boolean);for(const m of i){const f=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(f&&m!==f&&(At(f)||oo(f)))break;const x=m.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??m.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(x){const w=parseInt(x[1],10);if(w>=100&&w<=2100)return w}const v=m.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(v){const w=At(m);if(!w||nt(w)==="民國"){const k=fi(v[1]);if(k!=null&&k>=1&&k<=120)return nh+k}}const y=At(m)??((h=mn.find(w=>w.pattern.test(m)))==null?void 0:h.era),S=y?nt(y):void 0,b=Jt(m,S)??(At(m)||(u=mn.find(w=>w.pattern.test(m)))==null?void 0:u.reign);if(b){const w=Xt(b,S);if(w==null)continue;const j=m.indexOf(b),k=j>=0?m.slice(j+b.length):"",$=k.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??k.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),C=$?fi($[1]):void 0;return w+(C?C-1:0)}}}function so(e){var l,d,c,p,h,u;const n=(l=e.dating)==null?void 0:l.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const i=(d=e.lineage)==null?void 0:d.year_range;if(i&&i.length===2)return{from:i[0],to:i[1]};const o=(c=e.lineage)==null?void 0:c.year_text;if(o){const m=o.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(m){const f=$r[nt(m[1])],x=Zt[nt(m[2])];if(f!=null&&x!=null)return{from:Math.min(f,x)-20,to:Math.max(f,x)+40}}}const s=(p=e.publication_info)==null?void 0:p.year;if(s){const m=zi(s);if((m==null?void 0:m.to)!=null)return{from:m.from,to:m.to};const f=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(f){const x=$r[nt(f[1])],v=Zt[nt(f[2])];if(x!=null&&v!=null)return{from:Math.min(x,v)-20,to:Math.max(x,v)+40}}}const a=[(h=e.publication_info)==null?void 0:h.year,e.edition,e.title].filter(Boolean);for(const m of a){if(!/[間间]/.test(m))continue;const f=At(m)??oo(m)??((u=mn.find(y=>y.pattern.test(m)))==null?void 0:u.era),x=f?nt(f):void 0,v=[];for(const y of Object.keys(hn))m.includes(y)&&(x&&Ct[y]&&Ct[y]!==x||Xt(y,x)!=null&&v.push(y));if(v.length===0){const y=m.match(/([一-鿿])([一-鿿])[間间]/);if(y&&x){for(const S of[y[1],y[2]])for(const b of Object.keys(hn))if(Ct[b]===x&&!(b[0]!==S&&b[b.length-1]!==S)&&Xt(b,x)!=null){v.push(b);break}}}if(v.length>0){const y=v.map(j=>Xt(j,x)).filter(j=>j!=null),S=Math.min(...y),b=v.reduce((j,k)=>Xt(j,x)>=Xt(k,x)?j:k),w=ih(b)??lr(x??"")??Math.max(...y);return{from:S,to:w>S?w:lr(x??Ct[b]??"")??S}}if(x&&Zt[x]!=null)return{from:Zt[x],to:lr(x)??Zt[x]}}}const Zt={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},oh=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],sh=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,Ks=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function Xs(e,n){for(const i of Yl){const o=e.indexOf(i);if(o<0)continue;if(i.length===1){const c=e[o+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!Jt(e.slice(o),nt(i)))continue}const s=nt(i);if(s===n)continue;const a=e.slice(o),l=Jt(a,s)??"";let d;if(l){const c=Xt(l,s);if(c!=null){const h=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),u=h?fi(h[1]):void 0;d=c+(u?u-1:0)}}return{era:s,reign:l,year:d}}for(const i of mn)if(i.pattern.test(e))return{era:nt(i.era),reign:i.reign??""}}function ah(e){var S,b,w,j,k;const n=Wn(e),i=((S=e.publication_info)==null?void 0:S.year)??"",o=i?zi(i):void 0;if(!n.era&&!n.reign&&!o)return;const s=e.edition||e.title||"",a=/[間间]/.test(s),l=((b=e.lineage)==null?void 0:b.year_text)??"",d=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(l),c=n.source==="publication"&&th.test(i),p=n.source==="publication"&&/[間间]/.test(i),h=l.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let u;a||d||c||p?u=void 0:h?u=parseInt(h[2],10):u=Ni(e);const m=u==null?so(e):void 0;let f;n.source==="publication"&&(c||Ks.test(i))?f="uncertain":n.source==="lineage"||n.source==="publication"?f="attested":Ks.test(s)||!n.reign&&u==null?f="uncertain":f="inferred";const x=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((w=e.lineage)==null?void 0:w.year_text)??((j=e.lineage)==null?void 0:j.year)??""}」`:`出版著錄「${((k=e.publication_info)==null?void 0:k.year)??""}」`,v={era:n.era,reign:n.reign,year:u,yearRange:m,certainty:f,source:n.source==="edition"?"edition":"catalog",basis:x};if(h){const $=l.match(/[、,,]\s*([宋元明清])/);$&&$[1]!==v.era&&(v.laterRepair={era:$[1]})}if(!v.laterRepair&&sh.test(s)){const $=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);$&&$[1]!==n.era&&(v.laterRepair={era:$[1]})}const y=oh.find($=>$.re.test(s));if(y){const $=s.search(y.re),C=s.slice($),_=Xs(C,n.era)??Xs(s,n.era);_&&(v.basedOn={era:_.era,reign:_.reign,year:_.year,relation:y.relation})}return v}const $r={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function lr(e){return $r[e]}function xi(e){const n=Ni(e);if(n!=null)return n;const i=so(e);if(i)return i.from;const o=Wn(e).era;return o?Zt[o]:void 0}const Zs=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function Cr(e){const n=Zs.indexOf(e);return n===-1?Zs.length:n}function lh(e){const n={belongsTo:[],collected:[],contains:[],derivative:[],studies:[],related:[]};for(const s of e){const a=s.relation;a==="part_of"?n.belongsTo.push(s):a==="collected_in"?n.collected.push(s):a==="has_part"||a==="contains_text_of"?n.contains.push(s):a==="text_carried_by"||a==="studied_by"||a==="derived_from"||a==="followed_by"||a==="has_adaptation"?n.derivative.push(s):a==="studies"||a==="preceded_by"?n.studies.push(s):n.related.push(s)}const i=[],o=(s,a)=>{n[s].length&&i.push({key:s,labelKey:a,items:n[s]})};return o("belongsTo","belongsToWork"),o("collected","collectedIn"),o("contains","containedWorks"),o("derivative","derivativeWorks"),o("studies","studies"),o("related","relatedWorks"),i}function ao(e,n){const i=Yr(e||[]),o=new Map,s=[];for(const p of i)p.group?(o.has(p.group)||o.set(p.group,[]),o.get(p.group).push(p)):s.push(p);for(const p of o.values())p.sort((h,u)=>{const m=f=>f.group_role==="origin"?0:f.group_role==="mirror"?1:2;return m(h)-m(u)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const h=Mt(p),u=h.includes("text"),m=h.includes("image");u&&m?a.textImage.push(p):u?a.text.push(p):m?a.image.push(p):a.physical.push(p)}const d=["text","image","textImage","physical"].filter(p=>a[p].length>0).map(p=>({key:p,items:a[p]})),c=[...o.entries()].map(([p,h])=>{var u,m;return{key:p,label:((u=n==null?void 0:n[p])==null?void 0:u.label)||p,description:(m=n==null?void 0:n[p])==null?void 0:m.description,items:h}});return{buckets:d,mirrors:c,total:i.length}}function Ii(e,n=yn("zh-Hant")){const i=[],o=e.metadata||{};o.edition&&i.push(String(o.edition)),e.source_label&&i.push(e.source_label),e.details&&i.push(e.details);const s=ki(e);return s&&s.expected>0&&i.push(s.missing>0?n("detail.volumeStatsMissing",{found:s.found,expected:s.expected,missing:s.missing}):n("detail.volumeStats",{found:s.found,expected:s.expected})),o.version&&i.push(String(o.version)),i.join(" · ")}function Kl(e,n){if(Ii(e)||n.filter(o=>o.name===e.name).length<2)return"";try{const o=new URL(e.url),s=o.searchParams.get("res")||o.searchParams.get("id");if(s)return s;const a=o.pathname.split("/").filter(Boolean).pop();if(a)return decodeURIComponent(a)}catch{}return""}function Xl(e,n){var a,l;const i=e.resources||[],o=[],s=[];for(const d of i){const c=Mt(d);c.includes("image")&&o.push(d),c.includes("physical")&&s.push(d)}return{id:e.id,name:e.edition||e.title||e.id,era:Wn(e),year:Ni(e),sortYear:xi(e),images:o,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,important:ch(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:o.length>0}}function ch(e,n){var d,c;if(!n)return!1;const i=n.default_collection;if(!i)return!1;const o=(d=n.collections)==null?void 0:d[i];if(((o==null?void 0:o.book_ids)??(i==="core"?n.core_books??[]:[])).includes(e))return!0;const a=(o==null?void 0:o.groups)??[],l=(c=n.node_groups)==null?void 0:c[e];return!!l&&a.includes(l)}function Zl(e,n,i={}){const o=new Set((n==null?void 0:n.excluded_books)??[]),s=e.filter(c=>!o.has(c.id)).map(c=>Xl(c,n));let a=s;i.era&&(a=a.filter(c=>c.era.era===i.era)),i.scanOnly&&(a=a.filter(c=>c.hasImage)),i.sort==="year"?a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const h=c.r.sortYear,u=p.r.sortYear;return h!=null&&u!=null?h-u||c.i-p.i:h!=null?-1:u!=null?1:c.i-p.i}).map(c=>c.r):a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const h=u=>(u.important?0:1)*2+(u.hasImage?0:1);return h(c.r)-h(p.r)||c.i-p.i}).map(c=>c.r);const d=[...new Set(s.map(c=>c.era.era).filter(Boolean))].sort((c,p)=>Cr(c)-Cr(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function dh(e,n){var y,S;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const i=(y=n.collections)==null?void 0:y[n.default_collection],o=(i==null?void 0:i.groups)??[],s=(i==null?void 0:i.book_ids)??[],a=o.length>0||s.length>0,l=!a&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!a&&l.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const d=new Set(o),c=new Set([...s,...l]),p=b=>{if(c.has(b))return!0;const w=n.node_groups[b];return w!=null&&d.has(w)},h=[],u=new Map,m=[];for(const b of e)if(!((S=n.excluded_books)!=null&&S.includes(b)))if(p(b))h.push(b);else{const w=n.node_groups[b];w?(u.has(w)||u.set(w,[]),u.get(w).push(b)):m.push(b)}if(m.length+[...u.values()].reduce((b,w)=>b+w.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const x=new Map((n.groups??[]).map(b=>[b.id,b])),v=[...u.entries()].map(([b,w])=>{const j=x.get(b);return{id:b,label:(j==null?void 0:j.label)??b,description:j==null?void 0:j.description,ids:w}});return m.length>0&&v.push({id:"__other__",label:"其他版本",description:void 0,ids:m}),{useGrouping:!0,coreIds:h,groupedIds:v}}const Jl=["撰","編","注","校","譯","繪","其他"],ph=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function lo(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n)return"撰";for(const{cls:i,re:o}of ph)if(o.test(n))return i;return"其他"}function co(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function Ql(e,n="全部"){const i=new Map;for(const s of e){const a=lo(s);i.set(a,(i.get(a)??0)+1)}const o=[{cls:"全部",label:n,count:e.length}];for(const s of Jl){const a=i.get(s);a&&o.push({cls:s,label:s,count:a})}return o.length>2?o:[]}function po(e){return(e._books??[]).map(n=>n.id).filter(n=>typeof n=="string")}function uo(e){const n=e._classifications??[],i=n.find(o=>o.scheme==="zongmu")??n[0];if(i)return{l1:i.l1??"",l2:i.l2??"",l3:i.l3??"",l4:i.l4??"",...i.source?{source:i.source}:{}}}function ec(e){const n=e._members??[],i=typeof e._member_count=="number"?e._member_count:n.length;return{works:n.filter(o=>o.t==="work").map(o=>({id:o.id,title:o.title??"",volumes:Ln(o.vol)})),bookIds:n.filter(o=>o.t!=="work").map(o=>o.id).filter(o=>typeof o=="string"),total:i,truncated:i>n.length}}function uh(e){var n;return(e==null?void 0:e._member_count)||((n=e==null?void 0:e._members)==null?void 0:n.length)||0}function tc(e,n,i){if(n&&n.books&&n.books.length>0){const l=n.books.map(c=>({id:c.work_id||c.book_id||void 0,title:c.title,section:c.section,volumes:c.volumes||[],subItems:c.sub_items,edition:c.edition,found:c.found_volumes,expected:c.expected_volumes})),d=[...new Set(l.map(c=>c.section).filter(Boolean))];return{rows:l,source:"catalog",sections:d,totalVolumes:n.total_volumes}}const{works:o,bookIds:s}=ec(e);return o.length>0?{rows:o.map(d=>({id:d.id,title:d.title,volumes:d.volumes})),source:"works",sections:[]}:{rows:s.map(l=>{var d,c;return{id:l,title:((d=i==null?void 0:i.get(l))==null?void 0:d.title)||l,edition:(c=i==null?void 0:i.get(l))==null?void 0:c.edition,volumes:[]}}),source:"books",sections:[]}}function Ln(e){if(e==null)return[];if(typeof e=="number")return[e];if(Array.isArray(e))return e.filter(n=>typeof n=="number");if(typeof e=="string"){const n=e.match(/^(\d+)\s*[-–~]\s*(\d+)$/);if(n){const[i,o]=[parseInt(n[1]),parseInt(n[2])];return Array.from({length:Math.max(0,o-i+1)},(s,a)=>i+a)}return e.split(/[,、]/).map(i=>parseInt(i.trim())).filter(i=>!isNaN(i))}return[]}function Ri(e,n="冊"){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const i=[...e].sort((a,l)=>a-l),o=i[0],s=i[i.length-1];return s-o+1===i.length?`${o}–${s}`:i.length<=3?i.join(", "):`${o}–${s} (${i.length}${n})`}const mh=["〇","一","二","三","四","五","六","七","八","九"],Js=["","十","百","千"];function nc(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),i=n.length;let o="",s=!1;for(let a=0;a<i;a++){const l=parseInt(n[a]),d=i-1-a;l===0?s=!0:(s&&o&&(o+="〇"),s=!1,l===1&&d===1&&a===0?o+=Js[d]:o+=mh[l]+Js[d])}return o}function hh(e){return e==null?"":typeof e=="string"?e:"name"in e&&e.name?e.name:"title"in e&&e.title||""}function gh(e){if(e==null||typeof e=="string")return;const n="url"in e&&e.url?e.url:"type"in e&&e.type==="url"?e.details:void 0;return n&&/^https?:\/\//i.test(n)?n:void 0}function Bt(e,n="卷"){var o,s;const i=e;return i.measure_info?i.measure_info:(o=i.juan_count)!=null&&o.number?nc(i.juan_count.number)+n:(s=i.juan_count)!=null&&s.description?i.juan_count.description:""}function ic(e){var o;if(e.edition_type)return e.edition_type;if((o=e.lineage)!=null&&o.category)return e.lineage.category;const n=e.edition||e.title||"",i=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,a]of i)if(s.test(n))return a;return""}const fh=65536,xh="guji_markdown";function bh(e){const n=e==null?void 0:e.guji_markdown;if(typeof n!="string")return!1;const i=/^(\d+)\.(\d+)(?:\.\d+)?$/.exec(n.trim());if(!i)return!1;const o=parseInt(i[1],10),s=parseInt(i[2],10);return o>0||s>=2}const yh=/^□\{guess=([^\s{}]+)\}/;function jh(e,n){const i=e[n+1];return i!==void 0&&!/[A-Za-z/!?>\s]/.test(i)}function rc(e,n){let i=0;for(let o=n;o<e.length;o++){const s=e[o];if(s===`
|
|
678
|
+
`)return-1;if(s==="\\"){o++;continue}if(s==="[")i++;else if(s==="]"&&(i--,i===0))return o}return-1}function vh(e){return e.replace(/\\([\\[\]<>|{}])/g,"$1")}function kh(e,n){const i=e[n];if(i==="["&&e[n+1]==="["){const o=e.indexOf("]]",n+2);return o>=0&&e.slice(n+2,o).indexOf(`
|
|
679
|
+
`)<0?{node:{type:"qw",label:e.slice(n+2,o)},end:o+2}:null}if(i===":"&&e.startsWith(":zi[",n)){const o=rc(e,n+3);return o>n+4?{node:{type:"zi",label:vh(e.slice(n+4,o))},end:o+1}:null}if(i==="□"&&e[n+1]==="{"){const o=yh.exec(e.slice(n,n+64));if(o)return{node:{type:"qz",guess:o[1]},end:n+o[0].length}}return null}function oc(e,n,i,o,s){const a=[];let l="",d=!1;const c=()=>{if(!l)return;let p=l;o&&(p=l.replace(/\\?\|/g,h=>d?"|":(d=!0,""))),p&&a.push({type:"text",text:p}),l=""};for(;n<e.length;){const p=e[n];if(p==="\\"&&(e[n+1]==="<"||e[n+1]===">")){l+=e[n+1],n+=2;continue}if(i!==null){if(p===i)return c(),{nodes:a,end:n};if(p===`
|
|
680
|
+
`)return null}const h=kh(e,n);if(h){c(),a.push(h.node),n=h.end;continue}let u=null;if(p==="⟨"?u="⟩":p==="<"&&jh(e,n)&&(u=">"),u){const m=oc(e,n+1,u,!0,s);if(m&&!(p==="<"&&m.end-(n+1)>s)){c(),a.push({type:"jz",children:m.nodes}),n=m.end+1;continue}}l+=p,n++}return i!==null?null:(c(),{nodes:a,end:n})}function sc(e,n){return oc(e,0,null,!1,(n==null?void 0:n.jzMaxLength)??fh).nodes}function wh(e){return/[<⟨□]|\[\[|:zi\[/.test(e)}function ac(e){return e.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${ac(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const Sh=216,Qs="clamp(280px, 23vw, 360px)",_h=1440,Tr="(max-width: 719px)",$h=`${Tr}, (pointer: coarse)`,Ch=`
|
|
681
|
+
.bim-d-main.bim-d-main-grid { max-width: ${_h}px; padding: 16px 32px 0; }
|
|
682
682
|
.bim-d-grid {
|
|
683
683
|
display: grid;
|
|
684
|
-
grid-template-columns: ${
|
|
684
|
+
grid-template-columns: ${Sh}px minmax(0, 1fr) ${Qs};
|
|
685
685
|
grid-template-rows: auto 1fr;
|
|
686
686
|
grid-template-areas: "rail main card" "rail main side";
|
|
687
687
|
column-gap: 32px; row-gap: 28px; align-items: start;
|
|
@@ -1019,7 +1019,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1019
1019
|
.bim-d-side li .bim-d-meta { font-size: 12px; flex: none; }
|
|
1020
1020
|
|
|
1021
1021
|
/* 点击目标 ≥44px(Q5):触屏与窄屏 */
|
|
1022
|
-
@media ${
|
|
1022
|
+
@media ${$h} {
|
|
1023
1023
|
.bim-d-tab, .bim-d-check, .bim-d-more, .bim-d-rail-back,
|
|
1024
1024
|
.bim-d-card-foot summary, .bim-d-card-toggle, .bim-d-card details.bim-d-more-names summary,
|
|
1025
1025
|
.bim-d-tl summary, .bim-d-chap a { min-height: 44px; }
|
|
@@ -1057,7 +1057,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1057
1057
|
/* 中等宽度:左栏折到顶部一行 */
|
|
1058
1058
|
@media (max-width: 1100px) {
|
|
1059
1059
|
.bim-d-grid {
|
|
1060
|
-
grid-template-columns: minmax(0, 1fr) ${
|
|
1060
|
+
grid-template-columns: minmax(0, 1fr) ${Qs};
|
|
1061
1061
|
grid-template-rows: auto auto 1fr;
|
|
1062
1062
|
grid-template-areas: "rail rail" "main card" "main side";
|
|
1063
1063
|
}
|
|
@@ -1161,7 +1161,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1161
1161
|
:root[data-theme="ink"] :is(.bim-d-zt, .bim-d-side li, .bim-d-card-desc, .bim-d-desc, .bim-d-lf-card) a:hover {
|
|
1162
1162
|
text-decoration-color: currentColor; text-decoration-thickness: 2px;
|
|
1163
1163
|
}
|
|
1164
|
-
`;function On({railTop:e,back:n,up:i,nav:o,railLinks:s,main:a,card:l,side:d}){const{t:c,convert:p}=ne(),h=(o||[]).filter(Boolean);return t.jsxs("div",{className:"bim-d-grid",children:[t.jsxs("aside",{className:"bim-d-g-rail bim-d-ui",children:[e,n&&t.jsx("div",{style:{marginTop:e?12:0},children:n}),i,h.length>1&&t.jsxs("nav",{className:"bim-d-rail-navwrap","aria-label":c("detail.pageNav"),style:{marginTop:20},children:[t.jsx("p",{className:"bim-d-rail-cap",style:{marginTop:0},children:c("detail.thisPage")}),t.jsx("ul",{className:"bim-d-rail-nav",children:h.map(u=>t.jsx("li",{children:t.jsxs("a",{href:`#${u.id}`,children:[t.jsx("span",{children:p(u.label)}),u.count!=null&&t.jsx("span",{className:"bim-d-meta",children:u.count})]})},u.id))})]}),s&&s.length>0&&t.jsxs("nav",{className:"bim-d-rail-links","aria-label":c("detail.more"),children:[t.jsx("p",{className:"bim-d-rail-cap",children:c("detail.more")}),t.jsx("ul",{className:"bim-d-rail-nav",children:s.map(u=>t.jsx("li",{children:t.jsxs("a",{href:u.href??"#",onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),u.onClick())},children:[t.jsx("span",{children:p(u.label)}),t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:"→"})]})},u.key))})]})]}),t.jsx("div",{className:"bim-d-g-main",children:a}),t.jsx("div",{className:"bim-d-g-card",children:l}),t.jsx("div",{className:"bim-d-g-side",children:d})]})}function
|
|
1164
|
+
`;function On({railTop:e,back:n,up:i,nav:o,railLinks:s,main:a,card:l,side:d}){const{t:c,convert:p}=ne(),h=(o||[]).filter(Boolean);return t.jsxs("div",{className:"bim-d-grid",children:[t.jsxs("aside",{className:"bim-d-g-rail bim-d-ui",children:[e,n&&t.jsx("div",{style:{marginTop:e?12:0},children:n}),i,h.length>1&&t.jsxs("nav",{className:"bim-d-rail-navwrap","aria-label":c("detail.pageNav"),style:{marginTop:20},children:[t.jsx("p",{className:"bim-d-rail-cap",style:{marginTop:0},children:c("detail.thisPage")}),t.jsx("ul",{className:"bim-d-rail-nav",children:h.map(u=>t.jsx("li",{children:t.jsxs("a",{href:`#${u.id}`,children:[t.jsx("span",{children:p(u.label)}),u.count!=null&&t.jsx("span",{className:"bim-d-meta",children:u.count})]})},u.id))})]}),s&&s.length>0&&t.jsxs("nav",{className:"bim-d-rail-links","aria-label":c("detail.more"),children:[t.jsx("p",{className:"bim-d-rail-cap",children:c("detail.more")}),t.jsx("ul",{className:"bim-d-rail-nav",children:s.map(u=>t.jsx("li",{children:t.jsxs("a",{href:u.href??"#",onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),u.onClick())},children:[t.jsx("span",{children:p(u.label)}),t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:"→"})]})},u.key))})]})]}),t.jsx("div",{className:"bim-d-g-main",children:a}),t.jsx("div",{className:"bim-d-g-card",children:l}),t.jsx("div",{className:"bim-d-g-side",children:d})]})}function lc({caption:e,children:n}){const{convert:i}=ne();return t.jsxs("div",{className:"bim-d-up bim-d-ui",children:[t.jsx("span",{className:"bim-d-up-cap",children:i(e)}),n]})}function rt({id:e,title:n,meta:i,action:o,children:s}){const{convert:a}=ne();return t.jsxs("section",{id:e,className:"bim-d-sec",children:[t.jsxs("div",{className:"bim-d-sec-head bim-d-ui",children:[t.jsx("h2",{children:a(n)}),i!=null&&i!==""&&t.jsx("span",{className:"bim-d-meta",children:i}),o&&t.jsx("span",{className:"bim-d-sec-act",children:o})]}),t.jsx("div",{className:"bim-d-sec-body",children:s})]})}function it({items:e,className:n,style:i}){const o=e.filter(s=>s!=null&&s!==""&&s!==!1);return o.length?t.jsx("span",{className:`bim-d-meta${n?` ${n}`:""}`,style:i,children:o.map((s,a)=>t.jsxs(g.Fragment,{children:[a>0&&t.jsx("span",{className:"bim-d-dot"}),t.jsx("span",{children:s})]},a))}):null}function Ei({items:e,value:n,onChange:i}){const{convert:o}=ne();return t.jsx(t.Fragment,{children:e.map(s=>t.jsx("button",{type:"button",className:[...o(s.label)].length===1?"bim-d-tab bim-d-tab-1":"bim-d-tab","aria-pressed":s.key===n,onClick:()=>i(s.key),children:o(s.label)},s.key))})}function cc({label:e,checked:n,onChange:i}){const{convert:o}=ne();return t.jsxs("label",{className:"bim-d-check",children:[t.jsx("input",{type:"checkbox",checked:n,onChange:s=>i(s.target.checked)}),o(e)]})}const dc=6,Li=e=>e>dc+1;function mo({total:e,shown:n,unit:i,onClick:o}){const{t:s,convert:a}=ne(),l=e-n,d=Li(e)?e-Math.min(n,dc):l;return d<=0?null:t.jsxs("button",{type:"button",className:`bim-d-more bim-d-ui${l>0?"":" bim-d-more-ncap"}`,onClick:o,children:[l>0&&t.jsx("span",{className:"bim-d-more-w",children:s("detail.expandRest",{n:l,unit:a(i)})}),t.jsx("span",{className:"bim-d-more-n",children:s("detail.expandRest",{n:d,unit:a(i)})})]})}function ho({label:e,onClick:n}){const{convert:i}=ne();return t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:i(e)})}function Fn({kind:e,title:n,subtitle:i,byline:o,meta:s,description:a,clampDescription:l,facts:d,stats:c,readAction:p,secondaryAction:h,children:u,foot:m}){const{t:f,convert:x}=ne(),v=(d||[]).filter(j=>j.value!=null&&j.value!==""),y=(c||[]).filter(j=>j.value!=null&&j.value!==""&&j.value!==0),[S,b]=g.useState(!1),w=!!l&&!S;return t.jsxs("div",{className:"bim-d-card",children:[e&&t.jsx("div",{className:"bim-d-card-kind bim-d-ui",children:x(e)}),t.jsx("h1",{className:typeof n=="string"&&[...n].length>7?"bim-d-card-long":void 0,children:n}),i&&t.jsx("div",{className:"bim-d-card-sub",children:i}),o&&t.jsx("p",{className:"bim-d-card-byline",style:{marginBottom:0},children:o}),s&&t.jsx("div",{className:"bim-d-card-cls bim-d-ui",children:s}),a&&t.jsx("div",{className:w?"bim-d-card-desc bim-d-clamp":"bim-d-card-desc",style:w?{"--detail-clamp":l}:void 0,children:a}),a&&!!l&&t.jsx("button",{type:"button",className:"bim-d-card-toggle bim-d-ui","aria-expanded":S,onClick:()=>b(j=>!j),children:f(S?"action.collapse":"action.expand")}),y.length>0&&t.jsx("div",{className:"bim-d-stats bim-d-ui",children:y.map((j,k)=>t.jsxs("div",{children:[t.jsx("b",{children:j.value}),t.jsx("span",{children:x(j.label)})]},k))}),v.length>0&&t.jsx("dl",{className:"bim-d-ui",children:v.map((j,k)=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:x(j.label)}),t.jsx("dd",{title:j.title,children:j.value})]},k))}),u,p,h,m&&t.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:m})]})}function go(e){return!!e&&[...e.replace(/\s+/g,"")].length>110}function zr({href:e,onClick:n,label:i}){const{t:o,convert:s}=ne(),a=i??o("detail.read");return e?t.jsx("a",{className:"bim-d-btn",href:e,onClick:n?l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),n())}:void 0,children:s(a)}):t.jsx("button",{type:"button",className:"bim-d-btn",onClick:n,children:s(a)})}function en({id:e,title:n,meta:i,items:o,metas:s,currentIndex:a,cap:l=8,moreLabel:d,foot:c,sub:p,timeline:h}){const{t:u,convert:m}=ne(),[f,x]=g.useState(!1);if(!o.length)return null;const v=f?o:o.slice(0,l),y=o.length-v.length;return t.jsxs("div",{id:e,className:h?"bim-d-side bim-d-side-tl":"bim-d-side",style:{scrollMarginTop:16},children:[t.jsxs("h2",{className:"bim-d-ui bim-d-side-h",children:[m(n),i!=null&&i!==""&&t.jsx("span",{className:"bim-d-meta",children:i})]}),p&&t.jsx("p",{className:"bim-d-side-sub bim-d-ui",children:p}),t.jsx("ul",{children:v.map((S,b)=>t.jsxs("li",{className:b===a?"bim-d-side-cur":void 0,"aria-current":b===a?"page":void 0,children:[S,s!=null&&s[b]?t.jsx("span",{className:"bim-d-meta",style:{marginLeft:"auto"},children:s[b]}):null]},b))}),y>0&&t.jsx(ho,{label:d?d(y):u("detail.showMore",{n:y}),onClick:()=>x(!0)}),c&&t.jsx("p",{className:"bim-d-side-note bim-d-ui",children:c})]})}const Th=new Set(["reviewed","disputed","unreviewed","draft"]);function Hn({revision:e,revisedAt:n,review:i,todo:o}){const{t:s,convert:a}=ne(),l=i&&Th.has(i.status)?s(`detail.review.${i.status}`):void 0,d=i&&i.status!=="unreviewed"&&l?[l,i.by,i.date].filter(Boolean).join(" "):"",c=[e!=null&&e!==""?`${s("detail.dataVersion")} ${e}`:"",n??"",a(d)].filter(Boolean),p=(o||[]).filter(h=>h&&h.what);return!c.length&&!p.length?null:t.jsxs(t.Fragment,{children:[c.length>0&&t.jsx(it,{items:c,style:{fontSize:12}}),p.length>0&&t.jsxs("details",{children:[t.jsx("summary",{children:s("detail.todoCount",{n:p.length})}),t.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:18,lineHeight:1.7},children:p.map((h,u)=>t.jsxs("li",{children:[a(h.what),(h.by||h.date)&&t.jsxs("span",{style:{marginLeft:6},children:["(",[h.by&&a(h.by),h.date].filter(Boolean).join(" · "),")"]})]},u))})]})]})}const pi=1e3,ea=208,zh=1440,Nh="(max-width: 719px)",pc=`
|
|
1165
1165
|
.bim-d-page {
|
|
1166
1166
|
background: ${r("page-bg")};
|
|
1167
1167
|
color: ${r("ink")};
|
|
@@ -1181,7 +1181,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1181
1181
|
* PAGE_MAX_WIDTH,读者的行宽体验不变。
|
|
1182
1182
|
*/
|
|
1183
1183
|
.bim-d-main.bim-d-main-wide {
|
|
1184
|
-
max-width: ${
|
|
1184
|
+
max-width: ${zh}px;
|
|
1185
1185
|
}
|
|
1186
1186
|
.bim-d-ui { font-family: var(--bim-font-ui, system-ui, sans-serif); }
|
|
1187
1187
|
|
|
@@ -1213,9 +1213,9 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1213
1213
|
*/
|
|
1214
1214
|
.bim-d-reader {
|
|
1215
1215
|
display: grid;
|
|
1216
|
-
grid-template-columns: ${
|
|
1216
|
+
grid-template-columns: ${ea}px minmax(0, ${pi}px);
|
|
1217
1217
|
gap: 32px;
|
|
1218
|
-
max-width: ${
|
|
1218
|
+
max-width: ${ea+pi+32}px;
|
|
1219
1219
|
margin: 0 auto;
|
|
1220
1220
|
align-items: start;
|
|
1221
1221
|
}
|
|
@@ -1238,7 +1238,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1238
1238
|
align-items: start; margin-bottom: 48px; }
|
|
1239
1239
|
.bim-d-pair-wide { grid-template-columns: 1fr 1.2fr; }
|
|
1240
1240
|
|
|
1241
|
-
@media ${
|
|
1241
|
+
@media ${Nh} {
|
|
1242
1242
|
.bim-d-intro { grid-template-columns: 1fr; gap: 20px; margin-bottom: 32px; }
|
|
1243
1243
|
.bim-d-pair, .bim-d-pair-wide { grid-template-columns: 1fr; gap: 40px; }
|
|
1244
1244
|
/* 表格:meta 列折到第二行,表头隐藏 */
|
|
@@ -1256,20 +1256,20 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1256
1256
|
padding-right: 0; padding-bottom: 12px;
|
|
1257
1257
|
}
|
|
1258
1258
|
}
|
|
1259
|
-
${
|
|
1260
|
-
`)||(n.push({start:i,end:a+1,inner:l}),i=a)}return n}function
|
|
1259
|
+
${Ch}`;function In({children:e,style:n,wide:i,grid:o}){return t.jsxs("div",{className:"bim-d-page",style:n,children:[t.jsx("style",{children:pc}),t.jsx("div",{className:o?"bim-d-main bim-d-main-grid":i?"bim-d-main bim-d-main-wide":"bim-d-main",children:e})]})}function Nr({breadcrumb:e,actions:n}){return t.jsxs("div",{className:"bim-d-ui bim-d-top",style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:"8px 16px",marginBottom:24,fontSize:12,color:r("aux-fg")},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:e}),n&&t.jsx("div",{style:{display:"flex",alignItems:"center",gap:16},children:n})]})}function fo({char:e,tone:n="accent"}){return t.jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,flex:"none",fontSize:11,fontFamily:"var(--bim-font-ui, system-ui, sans-serif)",background:r(n==="accent"?"accent":"ink"),color:r("page-bg")},children:e})}function Ir({items:e}){const n=tt();return t.jsx(t.Fragment,{children:e.map((i,o)=>{const s=o===e.length-1,a=o>0&&t.jsx("span",{style:{color:r("hint-fg")},children:"/"},`s${o}`),l=i.id?n(i.id):i.href,d=s||!i.onClick&&!l?t.jsx("span",{style:{color:r("ink")},children:i.label},o):t.jsx("a",{href:l??"#",onClick:i.onClick?c=>{c.metaKey||c.ctrlKey||(c.preventDefault(),i.onClick())}:void 0,style:{color:r("meta-fg")},children:i.label},o);return t.jsxs(g.Fragment,{children:[a,d]},o)})})}function uc({title:e,subtitle:n,aside:i,secondLine:o}){return t.jsxs("header",{style:{borderBottom:`2px solid ${r("rule-strong")}`,paddingBottom:18},children:[t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"flex-end",justifyContent:"space-between",gap:"10px 24px"},children:[t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"6px 14px",minWidth:0},children:[t.jsx("h1",{className:"bim-d-h1",style:{margin:0,fontSize:42,fontWeight:700,letterSpacing:".06em",lineHeight:1.1,wordBreak:"break-word"},children:e}),n&&t.jsx("span",{style:{fontSize:15,color:r("meta-fg"),letterSpacing:".06em"},children:n})]}),i&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg"),letterSpacing:".06em"},children:i})]}),o&&t.jsx("div",{style:{marginTop:12,fontSize:13.5,color:r("quiet-fg")},children:o})]})}function Ih({children:e,facts:n}){return!e&&n?t.jsx("div",{style:{padding:"20px 0 26px",borderBottom:`1px solid ${r("rule")}`,marginBottom:40},children:n}):t.jsxs("div",{className:"bim-d-intro",children:[t.jsx("div",{style:{minWidth:0},children:e}),n]})}function Rh({items:e,horizontal:n}){const{convert:i}=Pe();return e.length?t.jsx("div",{style:{borderLeft:`2px solid ${r("accent")}`,paddingLeft:16,display:n?"grid":"flex",gridTemplateColumns:n?"repeat(auto-fit, minmax(150px, max-content))":void 0,flexDirection:n?void 0:"column",gap:n?"14px 40px":10,fontSize:13},children:e.map((o,s)=>t.jsxs("div",{title:o.title,style:n?{display:"flex",flexDirection:"column",gap:3}:{display:"flex",justifyContent:"space-between",gap:10},children:[t.jsx("span",{className:"bim-d-ui",style:{color:r("label-fg"),letterSpacing:".08em",flex:"none"},children:i(o.label)}),t.jsx("span",{style:{color:r("body-fg"),textAlign:n?"left":"right",minWidth:0},children:o.value})]},s))}):null}function Eh({glyph:e,tone:n,title:i,count:o,actions:s,id:a}){const{convert:l}=Pe();return t.jsxs("div",{id:a,style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",justifyContent:"space-between",gap:"10px 16px",marginBottom:14,scrollMarginTop:16},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx(fo,{char:e,tone:n}),t.jsx("h2",{style:{margin:0,fontSize:19,fontWeight:600,letterSpacing:".1em"},children:l(i)}),o!=null&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg")},children:o})]}),s&&t.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:14,fontSize:12},children:s})]})}function mc({label:e,active:n,onClick:i,dashed:o}){const{convert:s}=Pe();return t.jsx("button",{type:"button",onClick:i,"aria-pressed":n,className:"bim-d-ui",style:{padding:"5px 13px",border:`1px ${o&&!n?"dashed":"solid"} ${r(n?"accent":"rule")}`,background:n?r("accent"):"transparent",color:r(n?"page-bg":"meta-fg"),fontSize:12,cursor:"pointer",letterSpacing:".04em",lineHeight:1.4},children:s(e)})}function Lh({label:e,onClick:n}){const{convert:i}=Pe();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg"),borderBottom:`1px solid ${r("rule")}`},children:i(e)})}function Ah({label:e,onClick:n,inline:i}){const{convert:o}=Pe();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{marginTop:i?0:12,width:i?void 0:"100%",padding:i?"4px 12px":9,background:"none",border:`1px dashed ${r("rule-dashed")}`,cursor:"pointer",fontSize:12,color:r("meta-fg"),letterSpacing:i?void 0:".08em"},children:o(e)})}function hc({children:e,href:n,onClick:i,title:o}){const s={display:"inline-block",padding:"4px 10px",border:`1px solid ${r("rule")}`,fontSize:13,color:r("body-fg"),lineHeight:1.5};return n||i?t.jsx("a",{href:n??"#",title:o,onClick:i?a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i())}:void 0,style:s,children:e}):t.jsx("span",{title:o,style:s,children:e})}function Mh({children:e}){return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e})}function Ph({volumes:e,unit:n,max:i=60}){const{t:o}=ne(),s=n??o("unit.volume"),[a,l]=g.useState(!1);if(!e.length)return null;const d=a?e:e.slice(0,i);return t.jsxs("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,fontSize:11.5},children:[d.map(c=>t.jsx("span",{style:{minWidth:30,textAlign:"center",padding:"2px 5px",border:`1px solid ${r("rule")}`,color:r("meta-fg")},children:c},c)),!a&&e.length>i&&t.jsxs("button",{type:"button",onClick:()=>l(!0),style:{padding:"2px 8px",background:"none",cursor:"pointer",border:`1px dashed ${r("rule-dashed")}`,fontFamily:"inherit",fontSize:11.5,color:r("meta-fg")},children:["+",e.length-i]}),t.jsx("span",{style:{padding:"2px 6px",color:r("hint-fg")},children:s})]})}function Bh({children:e}){return t.jsx("div",{style:{borderTop:`1px solid ${r("rule-strong")}`},children:e})}function Wh({spec:e}){const{convert:n}=Pe();return t.jsxs("div",{className:"bim-d-thead bim-d-ui",style:{display:"grid",gridTemplateColumns:`${e.leadWidth}px 1fr ${e.metaWidth}px`,gap:12,padding:"7px 4px",borderBottom:`1px solid ${r("rule-strong")}`,fontSize:11,color:r("label-fg"),letterSpacing:".1em"},children:[t.jsx("span",{}),t.jsx("span",{children:n(e.mainLabel)}),t.jsx("span",{style:{display:"grid",gridTemplateColumns:e.columns.map(i=>i.width).join(" "),gap:12},children:e.columns.map(i=>t.jsx("span",{children:n(i.label)},i.label))})]})}function Oh({no:e,main:n,meta:i,spec:o}){return t.jsxs("div",{className:"bim-d-row",style:{gridTemplateColumns:`${o.leadWidth}px 1fr ${o.metaWidth}px`,gap:12},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:r("hint-fg"),textAlign:"right"},children:e}),t.jsx("span",{style:{minWidth:0},children:n}),t.jsx("span",{className:"bim-d-row-meta",style:{display:"grid",gridTemplateColumns:o.columns.map(s=>s.width).join(" "),gap:12,alignItems:"center",fontSize:12},children:i})]})}function Fh(e){return String(e+1).padStart(2,"0")}function Hh(){return t.jsx("span",{style:{color:r("hint-fg")},children:"—"})}function Dh({open:e,onToggle:n,main:i,action:o,children:s}){return t.jsxs("div",{style:{borderBottom:`1px solid ${r("rule")}`},children:[t.jsxs("div",{className:"bim-d-expand-head",style:{display:"grid",gridTemplateColumns:"26px 1fr auto",gap:12,alignItems:"baseline",padding:"9px 4px"},children:[t.jsx("button",{type:"button",onClick:n,"aria-expanded":e,className:"bim-d-ui",style:{width:18,height:18,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,cursor:"pointer",fontSize:12,lineHeight:1,border:`1px solid ${r(e?"accent":"rule-dashed")}`,background:e?r("accent"):"transparent",color:r(e?"page-bg":"accent")},children:e?"-":"+"}),t.jsx("span",{style:{fontSize:14,minWidth:0},children:i}),o]}),e&&s&&t.jsx("div",{style:{padding:"2px 4px 14px 38px",borderLeft:`2px solid ${r("rule-accent-soft")}`,marginLeft:12},children:s})]})}function gc(e){const n=[];for(let i=0;i<e.length;i++){const o=e[i];let s;if(o==="⟨")s="⟩";else if(o==="<"){const d=e[i+1];if(d===void 0||/[A-Za-z/!?>\s]/.test(d))continue;s=">"}else continue;const a=e.indexOf(s,i+1);if(a<0)continue;const l=e.slice(i+1,a);l.includes(`
|
|
1260
|
+
`)||(n.push({start:i,end:a+1,inner:l}),i=a)}return n}function fc(e,n){if(e.length<=n)return e;let i=n;for(const o of gc(e)){if(o.start>=i)break;if(o.end>i){i=o.start>0?o.start:o.end;break}}return e.slice(0,i)}const xc={fontSize:".78em",color:r("meta-fg"),lineHeight:1.55},Uh={display:"inline-block",fontSize:"1em",lineHeight:1.15,padding:"0 .12em",margin:"0 .05em",border:"1px solid color-mix(in srgb, currentColor 40%, transparent)",borderRadius:2,verticalAlign:"baseline",whiteSpace:"nowrap"};function bc(e,n,i,o){return e.map((s,a)=>{switch(s.type){case"text":return t.jsx(g.Fragment,{children:n(s.text)},a);case"jz":return t.jsx("span",{className:"bim-jiazhu",style:i===0?xc:void 0,children:bc(s.children,n,i+1,o)},a);case"qw":return t.jsx("span",{className:"bim-qw guji-qw",title:s.label?o("detail.lacunaWith",{label:s.label}):o("detail.lacuna"),children:"□"},a);case"qz":return t.jsx("span",{className:"bim-qz guji-qz","data-guji-guess":s.guess,children:"□"},a);case"zi":return t.jsx("span",{className:"bim-zi guji-zi",title:o("detail.composedChar",{label:s.label}),style:Uh,children:s.label},a)}})}function ft(e,n=o=>o,i){if(!e)return"";if(i!=null&&i.gujiMarkdown)return wh(e)?bc(sc(e,{jzMaxLength:i.jzMaxLength}),n,0,i.t??yn("zh-Hant")):n(e);if(e.indexOf("⟨")<0&&e.indexOf("<")<0)return n(e);const o=[];let s=0,a=0;for(const l of gc(e))l.start>s&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s,l.start))},a++)),o.push(t.jsx("span",{className:"bim-jiazhu",style:xc,children:n(l.inner)},a++)),s=l.end;return s<e.length&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s))},a++)),o}function Vh({label:e,children:n}){return t.jsxs("div",{style:{marginBottom:10},children:[e&&t.jsx("div",{className:"bim-d-ui",style:{fontSize:11,fontWeight:600,letterSpacing:".1em",color:r("label-fg"),marginBottom:4},children:e}),t.jsx("div",{style:{fontSize:13.5,lineHeight:2,color:r("quiet-fg"),textAlign:"justify"},children:n})]})}function Gh({title:e,tag:n,children:i}){const{convert:o}=Pe();return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,paddingBottom:7,borderBottom:`1px solid ${r("rule-strong")}`,marginBottom:2},children:[t.jsx("span",{style:{fontSize:14.5,letterSpacing:".08em"},children:o(e)}),n&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:r("accent"),letterSpacing:".06em"},children:o(n)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column"},children:i})]})}function yc({name:e,note:n,href:i,extra:o}){const s=t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{fontSize:14,minWidth:0},children:e}),t.jsx("span",{className:"bim-d-ui",style:{fontSize:11,color:r("hint-fg"),flex:"none"},children:i?"↗":""}),n&&t.jsx("span",{className:"bim-d-ui",style:{gridColumn:"1 / -1",fontSize:11.5,color:r("label-fg")},children:n})]}),a={display:"grid",gridTemplateColumns:"1fr auto",gap:"4px 12px",padding:"9px 4px",borderBottom:`1px solid ${r("rule")}`,color:r("body-fg"),alignItems:"baseline"};return t.jsxs(t.Fragment,{children:[i?t.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",style:a,children:s}):t.jsx("div",{style:a,children:s}),o]})}function Yh({item:e,siblings:n,showVolumes:i=!0,fallbackNote:o}){const{t:s,convert:a}=ne(),[l,d]=g.useState(!1),c=ki(e),p=i&&!!c&&c.expected>0,h=(e.url?fn(e.url):void 0)||a(e.name),u=n?Kl(e,n):"",m=u?`${h}(${u})`:h;return t.jsx(yc,{name:m,note:Ii(e,s)||o,href:xn(e),extra:p?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>d(f=>!f),className:"bim-d-ui",style:{alignSelf:"flex-start",padding:"2px 0",marginTop:4,background:"none",border:"none",cursor:"pointer",fontSize:11,color:r("meta-fg"),borderBottom:`1px solid ${r("rule")}`},children:l?s("detail.collapseVolumes"):s("detail.expandVolumes",{n:c.expected})}),l&&t.jsx(xo,{item:e})]}):void 0})}function xo({item:e}){return t.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,padding:"6px 0 10px",fontSize:11},children:(e.volumes||[]).map((n,i)=>{const o=n.status==="missing";return n.url&&!o?t.jsx("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{padding:"4px 8px",borderRadius:4,background:r("zebra-bg")},children:n.volume},i):t.jsx("span",{style:{padding:"1px 5px",color:r(o?"missing-fg":"hint-fg"),textDecoration:o?"line-through":void 0},children:n.volume},i)})})}function jc({label:e,items:n}){const{convert:i}=Pe();return n.length?t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg"),letterSpacing:".08em"},children:e}),n.map((o,s)=>t.jsx(hc,{children:i(o)},s))]}):null}function qh({rows:e}){const n=e.filter(i=>i.items.length>0);return n.length?t.jsx("div",{style:{marginTop:16,display:"flex",flexDirection:"column",gap:8},children:n.map(i=>t.jsx(jc,{label:i.label,items:i.items},i.label))}):null}function Rr(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function vc({left:e,right:n}){return t.jsxs("footer",{className:"bim-d-ui",style:{marginTop:52,paddingTop:14,borderTop:`1px solid ${r("rule")}`,display:"flex",flexWrap:"wrap",justifyContent:"space-between",gap:"8px 16px",fontSize:11.5,color:r("aux-fg")},children:[t.jsx("span",{children:e}),n&&t.jsx("span",{style:{display:"flex",gap:16},children:n})]})}function Kh({children:e,action:n}){return t.jsxs("div",{className:"bim-d-ui",style:{padding:"18px 4px",fontSize:12.5,color:r("aux-fg"),borderBottom:`1px solid ${r("rule")}`,display:"flex",flexWrap:"wrap",alignItems:"center",gap:12},children:[t.jsx("span",{children:e}),n]})}function et({id:e,label:n,onNavigate:i,renderLink:o,style:s,dense:a}){const l=tt();return o?t.jsx(t.Fragment,{children:o(e,typeof n=="string"?n:void 0,{dense:a})}):t.jsx("a",{href:l(e),onClick:i?d=>{d.metaKey||d.ctrlKey||(d.preventDefault(),i(e))}:void 0,style:s,children:n??e})}function Xh({href:e,children:n}){return t.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[n," ",t.jsx("span",{className:"bim-d-ui",style:{fontSize:11},children:"↗"})]})}const kc="guji-table-v1";function Zh(e){return!!e&&e.table_notation===kc}const Jh=/^:::table(?:\{[^}]*\})?[ \t]*$/,Qh=/^:::[ \t]*$/;function wc(e){const n=[];let i="";for(let o=0;o<e.length;o++){const s=e[o];if(s===":"&&e.startsWith(":zi[",o)){const l=rc(e,o+3);if(l>o+4){i+=e.slice(o,l+1),o=l;continue}}let a=null;if(s==="⟨")a="⟩";else if(s==="<"){const l=e[o+1];l!==void 0&&!/[A-Za-z/!?>\s]/.test(l)&&(a=">")}if(a){const l=e.indexOf(a,o+1);if(l>0){i+=e.slice(o,l+1),o=l;continue}}s==="|"?(n.push(i),i=""):i+=s}return n.push(i),n.map(o=>o.trim())}const eg=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function tg(e){if(e==="^")return{cont:!0};const n=eg.exec(e),i=n[1].trim(),o=n[2]?Math.max(1,parseInt(n[2],10)):1,s=n[3]?Math.max(1,parseInt(n[3],10)):1,a=i==="_";return{cont:!1,cell:{text:a?"":i,empty:a,colspan:o,rowspan:s}}}function Sc(e,n=1){const i=[],o=[],s=[];let a=[];e.forEach((d,c)=>{const p=c+n+1;let h=d.trim();if(!h)return;let u=!1;h.startsWith("!")&&(u=!0,h=h.slice(1));const m=wc(h).map(tg),f=a.map(S=>S>0),x=a.map(S=>S>0?S-1:0),v=[];let y=0;for(const S of m){if(S.cont){f[y]||i.push(`第 ${p} 行第 ${y+1} 列:续格 ^ 上方没有跨行格`),y+=1;continue}const{cell:b}=S;for(let w=y;w<y+b.colspan;w++)if(f[w]){i.push(`第 ${p} 行第 ${w+1} 列:此处被上方跨行格占住,应写 ^`);break}if(b.rowspan>1)for(let w=y;w<y+b.colspan;w++)x[w]=b.rowspan-1;v.push(b),y+=b.colspan}for(let S=y;S<f.length;S++)f[S]&&i.push(`第 ${p} 行第 ${S+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let S=0;S<x.length;S++)x[S]===void 0&&(x[S]=0);a=x,o.push({header:u,cells:v}),s.push({width:y,line:p})});const l=s.reduce((d,c)=>Math.max(d,c.width),0);for(const d of s)d.width!==l&&i.push(`第 ${d.line} 行:占 ${d.width} 列,与总列数 ${l} 不符`);return a.some(d=>d>0)&&i.push("表尾:有跨行格超出了表的最后一行"),o.length===0&&i.push("空表"),{rows:o,columns:l,warnings:i}}function bo(e){const n=e.split(`
|
|
1261
1261
|
`),i=[];let o=[];const s=()=>{if(o.length===0)return;const l=o.join(`
|
|
1262
|
-
`);o=[],i.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(
|
|
1263
|
-
`)}),a=l+1;continue}}o.push(n[a]),a++}return s(),i.map((l,d)=>{var p,h;if(l.type!=="text")return l;let c=l.text;return((p=i[d-1])==null?void 0:p.type)==="table"&&(c=c.replace(/^\n+/,"")),((h=i[d+1])==null?void 0:h.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(l=>l.type!=="text"||l.text!=="")}const
|
|
1264
|
-
`).map(n=>n.trim()).filter(n=>n&&!vo.test(n))}const
|
|
1265
|
-
`)){const s=o.trim();if(!s||vo.test(s)||jo(s))continue;const a=s.replace(/<[^<>\n]*>|\u27e8[^\u27e9\n]*\u27e9/g,"").replace(/\s/g,"").length;n+=a,a>
|
|
1262
|
+
`);o=[],i.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(Jh.test(n[a].trim())){let l=a+1;for(;l<n.length&&!Qh.test(n[l].trim());)l++;if(l<n.length){s();const d=n.slice(a+1,l);i.push({type:"table",table:Sc(d,a+1),source:n.slice(a,l+1).join(`
|
|
1263
|
+
`)}),a=l+1;continue}}o.push(n[a]),a++}return s(),i.map((l,d)=>{var p,h;if(l.type!=="text")return l;let c=l.text;return((p=i[d-1])==null?void 0:p.type)==="table"&&(c=c.replace(/^\n+/,"")),((h=i[d+1])==null?void 0:h.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(l=>l.type!=="text"||l.text!=="")}const ng={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},ig={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},rg=`1px solid ${r("table-border")}`,_c={border:rg,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},og={..._c,background:r("table-head-bg"),fontWeight:600};function yo({table:e,opts:n}){return t.jsx("div",{className:"bim-guji-table-wrap",style:ng,children:t.jsx("table",{className:"bim-guji-table",style:ig,children:t.jsx("tbody",{children:e.rows.map((i,o)=>t.jsx("tr",{children:i.cells.map((s,a)=>{const l=i.header?"th":"td";return t.jsx(l,{colSpan:s.colspan>1?s.colspan:void 0,rowSpan:s.rowspan>1?s.rowspan:void 0,style:i.header?og:_c,children:s.empty?null:ft(s.text,void 0,n)},a)})},o))})})})}function sg(e,n){return e.indexOf("**")<0?ft(e,void 0,n):e.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((o,s)=>s%2===1?t.jsx("strong",{children:ft(o.trim().slice(2,-2),void 0,n)},s):t.jsx(g.Fragment,{children:ft(o,void 0,n)},s))}function ag(e,n,i=!1){const o=i?{gujiMarkdown:!0}:void 0;return n?bo(e).map((s,a)=>s.type==="table"?t.jsx(yo,{table:s.table,opts:o},a):t.jsx(g.Fragment,{children:sg(s.text,o)},a)):ft(e,void 0,o)}const lg=/^(#{1,6})\s+(.*)$/,cg=/^\*\*([^*\n]+)\*\*\s*$/;function jo(e){const n=e.match(lg);if(n)return{level:n[1].length,text:n[2].trim()};const i=e.trim().match(cg);return i?{level:3,text:i[1].trim()}:null}const vo=/^<!--.*-->$/;function $c(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function Cc(e){return e.split(`
|
|
1264
|
+
`).map(n=>n.trim()).filter(n=>n&&!vo.test(n))}const dg=60;function Tc(e){let n=0,i=0;for(const o of e.split(`
|
|
1265
|
+
`)){const s=o.trim();if(!s||vo.test(s)||jo(s))continue;const a=s.replace(/<[^<>\n]*>|\u27e8[^\u27e9\n]*\u27e9/g,"").replace(/\s/g,"").length;n+=a,a>dg&&(i+=a)}return n>0&&i*2>=n}function pg(e){return e.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function Ai(e){if(e=pg(e),Tc(e))return"unknown";const n=$c(e);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const i=n.map(s=>Cc(s).length).filter(s=>s>0);if(i.length===0)return"unknown";const o=i.reduce((s,a)=>s+a,0)/i.length;return o<=4?"record":o>=8?"catalog":"unknown"}function ug(e){const n=e.split(`
|
|
1266
1266
|
`),i=[];let o=null,s=[];const a=()=>{i.push({heading:o,body:s.join(`
|
|
1267
|
-
`)}),s=[]};for(const l of n){const d=jo(l);if(d){a(),o={kind:"heading",level:d.level,text:d.text};continue}s.push(l)}return a(),i}function
|
|
1268
|
-
`)){const o=jo(i);if(o){n.push({kind:"heading",level:o.level,text:o.text});continue}const s=i.trim();!s||vo.test(s)||n.push({kind:"body",text:i})}return n}function
|
|
1269
|
-
`)?"":n)}function
|
|
1270
|
-
`);let c=0;return t.jsx(t.Fragment,{children:d.map((p,h)=>{const u=p.match(cr);if(u){const f=c++;if(a(u[1].length,u[2],f))return null;const{Tag:x,className:v}=l(u[1].length);return t.jsx(x,{className:v,children:i(u[2])},h)}if(!p.trim())return h>=2&&!!d[h-1].trim()&&!!d[h-2].trim()&&!cr.test(d[h-1])&&!cr.test(d[h-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},h):null;if(
|
|
1271
|
-
,。、;:?!「」『』()…—·`));function _o(e){return!kg.has(e)}function Lc(e,n,i=0){const o=[],s=Array.from(e);let a=0;for(const d of s)_o(d)&&o.push(a),a+=d.length;const l=[];for(const d of n){if(!dn(d))continue;const c=d.start-i,p=d.end-i;if(c<0||p>o.length||p<=c)continue;const h=o[p-1],u=e.codePointAt(h)>65535?2:1;l.push({...d,start:o[c],end:h+u})}return l}function wg(e,n){return n.text?Array.from(e.slice(n.start,n.end)).filter(_o).join("")===n.text:!0}function Sg(e,n,i){if(!n.text)return null;let o=-1,s=Math.max(0,n.start-i);const a=n.start+i;for(;s<=a;){const l=e.indexOf(n.text,s);if(l<0||l>a)break;(o<0||Math.abs(l-n.start)<Math.abs(o-n.start))&&(o=l),s=l+1}return o<0?null:{...n,start:o,end:o+n.text.length}}function Ac(e,n,i=16){const o=[];for(const l of n){if(!dn(l))continue;let d={...l,start:Math.max(0,l.start),end:Math.min(e.length,l.end)};(d.end<=d.start||!wg(e,d))&&(d=Sg(e,l,i)),d&&o.push(d)}o.sort((l,d)=>l.start-d.start||d.end-l.end);const s=[];let a=0;for(const l of o)l.start<a||(l.start>a&&s.push({type:"text",text:e.slice(a,l.start),start:a}),s.push({type:"entity",text:e.slice(l.start,l.end),start:l.start,span:l}),a=l.end);return a<e.length&&s.push({type:"text",text:e.slice(a),start:a}),s}const _g={off:[],lite:["people","place","dynasty"],full:["people","place","dynasty","office","reign","other"]};function $g(e,n,i){const o=(i==null?void 0:i.showWorks)!==!1,s=new Set(_g[n]);return e.filter(a=>a.kind==="work"?o:s.has(a.kind))}function Cg(e,n,i){const[o,s]=g.useState(null),[a,l]=g.useState(!1),d=g.useRef(0);return g.useEffect(()=>{const c=++d.current;if(!e||!n){s(null),l(!1);return}let p;try{p=e(n,i)}catch{s(null),l(!1);return}if(!p||typeof p.then!="function"){s(p??null),l(!1);return}l(!0),p.then(h=>{c===d.current&&s(h??null)}).catch(()=>{c===d.current&&s(null)}).finally(()=>{c===d.current&&l(!1)})},[e,n,i]),{images:o,loading:a}}function Tg(e){return typeof e!="string"?null:e==="published"?"source":Object.prototype.hasOwnProperty.call(Dp,e)?e:null}function zg(e){if(e==="none")return{color:r("quality-none"),fontWeight:400};if(e==="placeholder")return{color:r("quality-placeholder"),fontWeight:400}}const Ng={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释",tally:"小计"},Mc="\0";function Ig(e,n,i){const[o,s=""]=e.split(Mc);return t.jsxs(t.Fragment,{children:[o,t.jsx(El,{text:n,convert:i}),s]})}function bt(e){return typeof e!="string"?"":Ng[e]??e}const Rg=["〇","一","二","三","四","五","六","七","八","九"],oa=["","十","百","千"],Eg=["","萬","億"];function $o(e){if(e===0)return"〇";if(e<0)return`負${$o(-e)}`;const n=[];let i=e,o=0;for(;i>0;){const s=i%1e4;s>0?n.unshift(Lg(s,o>0)+Eg[o]):n.length>0&&n.unshift("〇"),i=Math.floor(i/1e4),o++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Lg(e,n){const i=[];let o=e;for(;o>0;)i.unshift(o%10),o=Math.floor(o/10);let s="";for(let a=0;a<i.length;a++){const l=i[a],d=i.length-1-a;l===0?s&&!s.endsWith("〇")&&(s+="〇"):l===1&&d===1&&a===0&&!n?s+=oa[d]:s+=Rg[l]+oa[d]}return s.replace(/〇$/,"")}let An=null,oi=null;const yi=new Set;function Ag(){return An?Promise.resolve():oi||(oi=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});An=i=>n(Se.normalizeVariants(i)),yi.forEach(i=>i())}).catch(()=>{An=e=>e,yi.forEach(e=>e())}),oi)}const Mg=e=>e;function rn(){const[,e]=g.useState(0);return g.useEffect(()=>{if(An)return;const n=()=>e(i=>i+1);return yi.add(n),Ag(),()=>{yi.delete(n)}},[]),An??Mg}function gn(e,n){return n(e).toLowerCase()}const Pg=r("highlight-bg");function Dn(e,n,i){if(!n)return e;const o=gn(n,i);if(!o)return e;const s=gn(e,i),a=Array.from(e),l=Array.from(s);if(l.length!==a.length)return e;const d=new Map;let c=0;l.forEach((x,v)=>{d.set(c,v),c+=x.length});const p=Array.from(o).length,h=[];let u=0,m=0,f=0;for(;u<a.length;){const x=s.indexOf(o,m),v=x===-1?void 0:d.get(x);if(x===-1){h.push(a.slice(u).join(""));break}if(v===void 0){m=x+1;continue}v>u&&h.push(a.slice(u,v).join("")),h.push(t.jsx("mark",{style:{background:Pg,padding:0,color:"inherit"},children:a.slice(v,v+p).join("")},f++)),u=v+p,m=x+o.length}return t.jsx(t.Fragment,{children:h})}function Co(e,n,i,o){if(!n)return!0;const s=gn(n,o);return(i?[e.title,e.header_line,e.content,e.comment]:[e.title,e.book_title,e.author,e.author_info,e.summary,e.content,e.comment,e.additional_comment]).some(l=>typeof l=="string"&&gn(l,o).includes(s))}function Bg(e,n,i){return n?gn(e,i).includes(gn(n,i)):!0}const To={类:r("section-lei"),书:r("section-shu"),序:r("section-xu"),结语:r("section-jieyu"),注释:r("section-zhushi")},Wg={考证:r("section-kaozhen")};function zo(e,n,i){return e.collated.sectionType[n]??i(n)}function Pc(e){var o;const n=e.files.length,i=((o=e.children)==null?void 0:o.reduce((s,a)=>s+Pc(a),0))||0;return n+i}function Og(e,n){const i=[],o=l=>{var d;i.push(...l.files),(d=l.children)==null||d.forEach(o)};if(o(e),i.length===0)return;const s=i.map(l=>n[l]);if(s.every(l=>l===void 0))return;if(s.some(l=>l==="loading"))return"loading";let a=0;for(const l of s)typeof l=="number"&&(a+=l);return a}const Fg={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function No({enabled:e,expanded:n,onClick:i,style:o,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:i,style:{...Fg,...o},children:s}):t.jsx("span",{style:o,children:s})}function Hg({type:e}){const{convert:n,messages:i}=ne(),o=bt(e),s=To[o]||r("desc-fg");return t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:s,border:`1px solid ${s}40`,borderRadius:"2px",background:`${s}08`,flexShrink:0},children:zo(i,o,n)})}function Dg({section:e,onNavigate:n,highlightQuery:i="",no:o,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=ne(),c=tt(),p=rn(),h=w=>w?ft(d(w),j=>i?Dn(j,i,p):j,{t:l}):"",[u,m]=g.useState(!1),f=!!e.summary,x=!!e.comment,v=!!e.additional_comment,y=!!(e.content&&e.content.length>60),S=f||x||v||y;g.useEffect(()=>{i&&m(!0)},[i]);const b=!u&&y?gc(e.content.replace(/\n/g," "),80)+"…":null;return t.jsxs("div",{className:"bim-rd-row",id:a,style:{borderBottom:`1px solid ${r("rule")}`,overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>S&&m(!u),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:S?"pointer":"default",userSelect:"none"},children:[o!=null&&t.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:r("label-fg")},children:o}),t.jsxs(No,{enabled:S,expanded:u,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[S&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),transition:"transform 0.15s",transform:u?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1,minWidth:0},children:[t.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg")},children:[e.book_title?t.jsxs(t.Fragment,{children:["《",h(e.book_title),"》"]}):h(e.title),e.n_juan!=null&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:l("collated.nJuan",{n:d($o(e.n_juan))})}),(e.author_info||e.author)&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"8px"},children:h(e.author_info||e.author)})]}),!u&&b&&t.jsx("span",{style:{display:"block",fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:h(b)})]})]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:h(e.edition)}),e.tag&&t.jsx("span",{style:{fontSize:"11px",color:r("section-tag-fg")},children:e.tag==="triangle"?"△":e.tag}),e.work_id&&n&&t.jsx("a",{href:c(e.work_id),onClick:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),w.stopPropagation(),n(e.work_id))},style:{fontSize:"11px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:l("collated.viewWork"),"aria-label":l("collated.viewWorkOf",{title:d(e.book_title||e.title)}),children:l("collated.workArrow")}),s&&!e.work_id&&t.jsx("span",{style:{fontSize:"11px",color:r("label-fg"),flexShrink:0},children:l("collated.unlinked")})]}),u&&S&&t.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${r("widget-border")}`,background:r("bg")},children:[e.author_info&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"8px"},children:h(e.author_info)}),e.summary&&t.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.summary")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:h(e.summary)})]}),e.comment&&t.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.comment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:h(e.comment)})]}),e.additional_comment&&t.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.additionalComment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:h(e.additional_comment)})]}),y&&!f&&!x&&!v&&t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:h(e.content)})]})]})}function Ug({section:e,highlightQuery:n=""}){const{t:i,convert:o}=ne(),s=rn(),a=p=>p?ft(o(p),h=>n?Dn(h,n,s):h,{t:i}):"",[l,d]=g.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(No,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(Hg,{type:e.type}),t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:r("fg")},children:a(e.title)}),c&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),transition:"transform 0.15s",transform:l?"rotate(90deg)":"none",display:"inline-block"},children:"▶"})]}),l&&c&&t.jsx("div",{style:{marginTop:"8px",padding:"10px 14px",borderLeft:`3px solid color-mix(in srgb, ${To[bt(e.type)]||r("desc-fg")} 25%, transparent)`,borderRadius:"0 4px 4px 0",background:r("bg")},children:t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:a(e.content)})})]})}const Vg=100;function Io(e){return bt(e.type)!=="page_header"?!1:(e.content||"").length>=Vg}function Gg({section:e,highlightQuery:n=""}){const{t:i,convert:o,messages:s}=ne(),a=rn();if(bt(e.type)==="page_header"&&!Io(e)||!e.content&&!e.title)return null;const l=o((e.content||e.title||"").replace(/\n{2,}/g,`
|
|
1272
|
-
`)),d=ft(l,u=>n?Dn(u,n,a):u,{t:i}),c=bt(e.type),p=To[c]||r("desc-fg"),h=c==="序"||c==="结语"||c==="注释";return t.jsxs("div",{style:{padding:h?"10px 12px":"6px 0",margin:h?"8px 0":void 0,fontSize:"13px",color:r("desc-fg"),lineHeight:1.8,whiteSpace:"pre-line",borderLeft:h?`3px solid ${p}40`:void 0,background:h?r("bg"):void 0,borderRadius:h?"0 4px 4px 0":void 0,position:"relative"},children:[h&&t.jsx("span",{style:{display:"inline-block",fontSize:"10px",fontWeight:500,color:p,marginRight:"8px",padding:"1px 5px",border:`1px solid ${p}40`,borderRadius:"2px",background:`${p}08`,verticalAlign:"middle"},children:zo(s,c,o)}),d]})}function Yg(e,n,i){const[o,s]=g.useState({});return g.useEffect(()=>{var p;if(!n||e.length===0)return;let a=!1;const l=e.filter(h=>{var u;return!((u=i==null?void 0:i.current)!=null&&u.has(h))}),d={};for(const h of e)(p=i==null?void 0:i.current)!=null&&p.has(h)&&(d[h]=i.current.get(h));if(Object.keys(d).length>0&&s(d),l.length===0)return;const c=async h=>{var u;try{if(n.getEntry){const y=await n.getEntry(h);if(y)return{title:y.title,author:y.author}}const m=await n.getItem(h);if(!m)return null;const f=m.title||h,x=m.authors,v=(u=x==null?void 0:x[0])==null?void 0:u.name;return{title:f,author:v}}catch{return null}};return Promise.all(l.map(async h=>{var m;const u=await c(h);return(m=i==null?void 0:i.current)==null||m.set(h,u),[h,u]})).then(h=>{a||s(u=>{const m={...u};for(const[f,x]of h)m[f]=x;return m})}),()=>{a=!0}},[e.join(","),n]),o}function qg({section:e,onNavigate:n,transport:i,workLabelCache:o,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=ne(),c=tt(),p=rn(),h=j=>j?ft(l(j),k=>s?Dn(k,s,p):k,{t:a}):"",[u,m]=g.useState(!1);g.useEffect(()=>{s&&m(!0)},[s]);const f=bt(e.type),x=Wg[f]||r("desc-fg"),v=!!e.content,y=e.work_ids||[],S=y.length>1,b=Yg(S?y:[],i,o),w=v&&!u&&e.content.length>80?gc(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${r("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>v&&m(!u),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:v?"pointer":"default",userSelect:"none"},children:[t.jsxs(No,{enabled:v,expanded:u,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[v&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:u?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg"),lineHeight:1.6},children:e.header_line?h(e.header_line):h(e.title)}),!u&&w&&t.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:r("desc-fg"),lineHeight:1.7},children:h(w)})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[y.length===1&&n&&t.jsx("a",{href:c(y[0]),onClick:j=>{j.metaKey||j.ctrlKey||(j.preventDefault(),j.stopPropagation(),n(y[0]))},style:{fontSize:"11px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:a("collated.viewWork"),children:a("collated.arrowWork")}),S&&t.jsx("span",{style:{fontSize:"11px",color:r("link-fg"),flexShrink:0},children:a("collated.nWorks",{n:y.length})}),t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:x,border:`1px solid ${x}40`,borderRadius:"2px",background:`${x}08`},children:zo(d,f,l)})]})]}),S&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:y.map(j=>{const k=b[j],$=k?`${l(k.title)}${k.author?`(${l(k.author)})`:""}`:j.slice(0,8)+"…";return t.jsxs("a",{href:c(j),onClick:C=>{C.metaKey||C.ctrlKey||(C.preventDefault(),C.stopPropagation(),n(j))},style:{fontSize:"12px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:j,children:["→",$]},j)})}),u&&v&&t.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${x}40`,borderRadius:"0 4px 4px 0",background:r("bg")},children:[t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:h(e.content)}),e.comment&&t.jsx("div",{style:{marginTop:"10px",paddingTop:"8px",borderTop:`1px solid ${r("widget-border")}`,fontSize:"12px",color:r("desc-fg"),lineHeight:1.8,fontStyle:"italic"},children:h(e.comment)})]})]})}function Kg({juan:e,searchQuery:n,onNavigate:i,transport:o,workLabelCache:s}){const{t:a}=ne(),l=rn(),d=n.trim(),c=g.useMemo(()=>d?e.sections.filter(p=>Co(p,d,!0,l)):e.sections,[e.sections,d,l]);return t.jsxs("div",{children:[t.jsx("div",{children:c.map((p,h)=>t.jsx(qg,{section:p,onNavigate:i,transport:o,workLabelCache:s,highlightQuery:d},h))}),c.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:a("collated.noMatch")})]})}function Xg(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function Zg({sections:e,onNavigate:n,inline:i,workLinks:o=!0}){const s=tt(),{t:a,convert:l}=ne(),d=Xg();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const h=bt(c.type);if(h==="page_header"&&!Io(c))return null;if(h==="类")return t.jsxs(g.Fragment,{children:[g.createElement(d("类"),null,i(l(c.title))),c.content&&t.jsx("p",{children:i(l(c.content))})]},p);if(h==="书"||h==="诗"||h==="考证"||h==="注释"){const u=c.book_title?`《${c.book_title}》${c.n_juan!=null?a("collated.nJuan",{n:$o(c.n_juan)}):""}`:c.title,m=i(l(u));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[g.createElement(d("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&o?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},title:a("collated.viewWork"),children:m}),t.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},"aria-label":a("collated.viewWorkOf",{title:l(u)}),children:a("collated.workArrow")})]}):m),c.author_info&&t.jsx("p",{className:"bim-rd-sub",children:i(l(c.author_info))}),c.content&&c.content.split(/\n+/).map((f,x)=>t.jsx("p",{children:i(l(f))},x)),c.summary&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.summary")}),i(l(c.summary))]}),c.comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.comment")}),i(l(c.comment))]}),c.additional_comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.additionalComment")}),i(l(c.additional_comment))]})]},p)}return h==="小计"&&c.title?t.jsx("p",{children:i(l(c.title))},p):c.content?t.jsx("p",{children:i(l(c.content))},p):null})})}function Bc(e){return e.some(n=>{const i=bt(n.type);return i==="书"||i==="诗"||i==="考证"||i==="注释"||i==="类"||(i==="序"||i==="结语")&&!!n.content||i==="page_header"&&Io(n)})}function Jg({juan:e,rawText:n,positionLabel:i,groupLabel:o,index:s,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c,prefs:p,view:h,onViewChange:u}){var he;const{t:m,convert:f,messages:x}=ne(),v=rn(),[y,S]=g.useState("text"),b=h??y,w=Z=>{S(Z),u==null||u(Z)},j=a.trim(),k=(s==null?void 0:s.type)==="kaozhen",$=g.useCallback(Z=>j?Dn(Z,j,v):Z,[j,v]),C=ko(p),_=Z=>wo(Z,{renderText:$,bookMarking:C,quoteStyle:p.quoteStyle,t:m}),E=g.useMemo(()=>j?e.sections.filter(Z=>Co(Z,j,k,v)):e.sections,[e.sections,j,k,v]),z=(Z,M)=>M.filter(_e=>bt(_e.type)===Z).length,T=z("书",e.sections),B=z("诗",e.sections),W=z("考证",e.sections);let N="";k?N=j?m("collated.countTiaoOf",{m:z("考证",E),n:W}):m("collated.countTiao",{n:W}):B>0?N=j?m("collated.countPoemsOf",{m:z("诗",E),n:B}):m("collated.countPoems",{n:B}):T>0&&(N=j?m("collated.countBooksOf",{m:z("书",E),n:T}):m("collated.countBooks",{n:T}));const A=s!=null&&s.text_quality?Tg(s.text_quality.grade):null,F=[];if(N&&F.push(N),k&&(s!=null&&s.target_source)&&F.push(t.jsx(t.Fragment,{children:m("collated.kaozhenTarget",{target:f(s.target_source)})})),A){const Z=t.jsx("span",{className:"bim-rd-grade",style:zg(A),children:x.collated.qualityLabel[A]});F.push(t.jsx("span",{title:x.collated.qualityCriteria[A],children:(he=s==null?void 0:s.text_quality)!=null&&he.source_note?t.jsxs(t.Fragment,{children:[Ig(m("collated.baseText",{note:Mc}),s.text_quality.source_note,f),Z]}):t.jsxs(t.Fragment,{children:[m("collated.textQuality"),Z]})}))}e.source_url&&F.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:m("collated.originalSource")}));const Y=!k&&Bc(e.sections),ee=!!n&&(!Y||p.readingMode==="paragraph"&&bi(n)),se=!k&&(Y||!!n),D=k||!se?"entries":b;let V=0;return t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[(i||o)&&t.jsxs("p",{className:"bim-rd-kicker",children:[i,i&&o&&t.jsx("span",{className:"bim-rd-dot"}),o&&f(o)]}),t.jsx("h1",{className:"bim-rd-h1",children:f(e.title)}),F.length>0&&t.jsx("p",{className:"bim-rd-meta",children:F.map((Z,M)=>t.jsxs(g.Fragment,{children:[M>0&&t.jsx("span",{className:"bim-rd-dot"}),Z]},M))}),se&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":m("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":D==="text",onClick:()=>w("text"),children:m("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":D==="entries",onClick:()=>w("entries"),children:m("collated.viewEntries")})]})]}),D==="text"&&t.jsx("article",{className:"bim-rd-prose",children:ee?t.jsx(So,{text:n,mode:p.readingMode,bookMarking:C,quoteStyle:p.quoteStyle,renderText:$,dropTitle:e.title}):t.jsx(Zg,{sections:e.sections,onNavigate:l,inline:_,workLinks:p.workLinks})}),D==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:k?t.jsx(Kg,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[E.some(Z=>["书","诗","考证"].includes(bt(Z.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:m("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:m("collated.rowHeadTitle")}),t.jsx("span",{children:m("collated.rowHeadWork")})]}),E.map((Z,M)=>{const _e=bt(Z.type);return _e==="书"||_e==="诗"||_e==="考证"?(V+=1,t.jsx(Dg,{domId:`rd-e-${e.sections.indexOf(Z)}`,section:Z,onNavigate:p.workLinks?l:void 0,highlightQuery:j,no:V,showUnlinked:p.workLinks&&!!l},M)):_e==="类"?t.jsx(Ug,{section:Z,highlightQuery:j},M):t.jsx(Gg,{section:Z,highlightQuery:j},M)}),E.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:m("collated.noMatch")})]})})]})}function Qg(e){const{resetKey:n,load:i,files:o,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=rn(),h=g.useRef(new Map),[u,m]=g.useState({}),[f,x]=g.useState({}),v=g.useCallback((S,b)=>{const w=b==null?void 0:b.title;w&&x(j=>j[S]===w?j:{...j,[S]:w})},[]);g.useEffect(()=>{s&&a&&(h.current.set(s,{juan:a,rawText:l}),v(s,a))},[s,a,l,v]),g.useEffect(()=>{h.current.clear(),m({}),x({})},[n]);const y=g.useCallback((S,b)=>{let w=0;if(S.juan)for(const j of S.juan.sections)Co(j,b,c,p)&&w++;return w===0&&S.rawText&&Bg(S.rawText,b,p)&&(w=1),w},[c,p]);return g.useEffect(()=>{const S=d.trim();if(!S){m({});return}if(!i||o.length===0)return;let b=!1;const w={},j=[];for(const E of o){const z=h.current.get(E);z?w[E]=y(z,S):(w[E]="loading",j.push(E))}m(w);const k=8;let $=0;const C=async()=>{for(;$<j.length;){if(b)return;const E=$++,z=j[E];try{const T=await i(z),B=T.juan;if(h.current.set(z,T),v(z,B),b)return;m(W=>({...W,[z]:y(T,S)}))}catch{if(b)return;m(T=>({...T,[z]:0}))}}},_=Array.from({length:Math.min(k,j.length)},()=>C());return Promise.all(_),()=>{b=!0}},[d,n,i,o.join(","),y,p,v]),{matchStates:u,titles:f}}function ef({juan:e,view:n,onView:i,textHasEntries:o}){const{t:s,convert:a}=ne(),l=e.sections.map((h,u)=>({s:h,i:u,t:bt(h.type)})).filter(h=>h.t==="书"||h.t==="诗");if(l.length===0)return null;const d=l.filter(h=>!!h.s.work_id).length,c=l.every(h=>h.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),p=h=>{const u=()=>{var m,f;return(f=(m=document.getElementById(`rd-e-${h}`))==null?void 0:m.scrollIntoView)==null?void 0:f.call(m,{block:"start",behavior:"smooth"})};n==="text"&&!o&&i("entries"),n==="text"&&!o?setTimeout(u,0):u()};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-rd-rail-card",children:[t.jsx("div",{className:"bim-rd-rail-cap",children:s("collated.railCap")}),t.jsxs("div",{className:"bim-rd-rail-n",children:[t.jsx("b",{children:l.length}),t.jsx("span",{children:c}),t.jsx("span",{className:"bim-rd-rail-linked",children:s("collated.linkedN",{n:d})})]}),t.jsx("div",{className:"bim-rd-rail-bar",role:"img","aria-label":s("collated.linkedOf",{n:d,total:l.length}),children:t.jsx("span",{style:{width:`${Math.round(d/l.length*100)}%`}})})]}),t.jsxs("nav",{"aria-label":s("collated.railEntriesNav"),children:[t.jsx("div",{className:"bim-rd-rail-cap",style:{margin:"20px 0 6px 12px"},children:s("collated.viewEntries")}),t.jsx("ul",{className:"bim-rd-rail-list",children:l.map(({s:h,i:u})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${u}`,onClick:m=>{m.preventDefault(),p(u)},children:[t.jsx("span",{className:`bim-rd-rail-dot${h.work_id?" on":""}`,"aria-hidden":"true"}),t.jsx("span",{children:a(h.book_title||h.title)})]})},u))})]})]})}const tf=`
|
|
1267
|
+
`)}),s=[]};for(const l of n){const d=jo(l);if(d){a(),o={kind:"heading",level:d.level,text:d.text};continue}s.push(l)}return a(),i}function ta(e){const n=[];for(const i of e.split(`
|
|
1268
|
+
`)){const o=jo(i);if(o){n.push({kind:"heading",level:o.level,text:o.text});continue}const s=i.trim();!s||vo.test(s)||n.push({kind:"body",text:i})}return n}function zc(e){if(!e)return[];const n=Ai(e);if(n==="unknown")return ta(e);const i=[];for(const{heading:o,body:s}of ug(e)){o&&i.push(o);const a=$c(s);if(a.length!==0){if(Tc(s)){i.push(...ta(s));continue}if(n==="record"){const l=a.join(" ");l&&i.push({kind:"body",text:l})}else for(const l of a){const d=Cc(l);d.length&&i.push({kind:"body",text:d.join(" ")})}}}return i}const mg={"「":"“","」":"”","『":"‘","』":"’"},hg={"“":"「","”":"」","‘":"『","’":"』"},gg=new Set(["《","》","〈","〉"]);function Nc(e,n){const i=n.quoteStyle==="modern"?mg:n.quoteStyle==="classic"?hg:null;let o="";for(const s of e)n.hideBookBrackets&&gg.has(s)||(o+=(i==null?void 0:i[s])??s);return o}const Ic=e=>e;function ko(e){return e.showWorks?e.bookTitleStyle==="bracket"?"bracket":Hm(e.properNameMode)?"wavy":"bracket":"none"}function Rc(e,n=Ic,i="wavy"){if(e.indexOf("《")<0)return n(e);const o=[],s=/《([^《》\n]+)》/g;let a=0,l=0,d;for(;d=s.exec(e);){d.index>a&&o.push(t.jsx(g.Fragment,{children:n(e.slice(a,d.index))},l++));const c=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-sr",children:"《"}),n(d[1]),t.jsx("span",{className:"bim-rd-sr",children:"》"})]});o.push(i==="wavy"?t.jsx("span",{className:"bim-rd-pn",children:c},l++):t.jsx(g.Fragment,{children:c},l++)),a=d.index+d[0].length}return a===0?n(e):(a<e.length&&o.push(t.jsx(g.Fragment,{children:n(e.slice(a))},l++)),o)}function wo(e,n={}){let i=n.renderText??Ic;const o=n.quoteStyle;if(o&&o!=="original"){const d=i;i=c=>d(Nc(c,{quoteStyle:o}))}const s=n.bookMarking??(n.properNames?"wavy":"bracket"),a=s==="bracket"?i:d=>Rc(d,i,s),l=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return ft(e,a,l)}function na(e,n,i){return e.indexOf("**")<0?n(e):e.split(/(\*\*[^*]+\*\*)/g).map((s,a)=>s.startsWith("**")&&s.endsWith("**")&&s.length>4?t.jsx("strong",{children:n(s.slice(2,-2))},`${i}-${a}`):t.jsx(g.Fragment,{children:n(s)},`${i}-${a}`))}const cr=/^(#{1,6})\s+(.*)$/,fg=/^\s*<!--.*-->\s*$/;function Ec(e){return e.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
|
|
1269
|
+
`)?"":n)}function xg(e){return e<=1?2:e===2?3:4}function bg(){let e=1;return n=>{const i=xg(n),o=Math.min(i,e+1);return e=o,{Tag:`h${o}`,className:`bim-rd-hl${i}`}}}function bi(e){return e?Ai(Ec(e))!=="unknown":!1}function yg(e){return/^\u3000{2}/.test(e)}const ia=e=>yg(e)?"bim-rd-noindent":void 0;function ra({text:e,mode:n,inline:i,dropTitle:o}){const s=Ec(e),a=(p,h,u)=>!!o&&u<=1&&p<=2&&h.trim()===o.trim(),l=bg();if(n==="paragraph"&&Ai(s)!=="unknown"){const p=zc(s);return t.jsx(t.Fragment,{children:p.map((h,u)=>{if(h.kind==="heading"){if(a(h.level??1,h.text,u))return null;const{Tag:m,className:f}=l(h.level??1);return t.jsx(m,{className:f,children:i(h.text)},u)}return t.jsx("p",{className:ia(h.text),children:na(h.text,i,u)},u)})})}const d=s.split(`
|
|
1270
|
+
`);let c=0;return t.jsx(t.Fragment,{children:d.map((p,h)=>{const u=p.match(cr);if(u){const f=c++;if(a(u[1].length,u[2],f))return null;const{Tag:x,className:v}=l(u[1].length);return t.jsx(x,{className:v,children:i(u[2])},h)}if(!p.trim())return h>=2&&!!d[h-1].trim()&&!!d[h-2].trim()&&!cr.test(d[h-1])&&!cr.test(d[h-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},h):null;if(fg.test(p))return null;if(c++,/^\*\*[^*]+\*\*\s*$/.test(p.trim())){const{Tag:f,className:x}=l(3);return t.jsx(f,{className:x,children:i(p.trim().slice(2,-2))},h)}return t.jsx("p",{className:ia(p),children:na(p,i,h)},h)})})}function jg(e){const{convert:n}=Pe();return g.useMemo(()=>e?n(e):"",[e,n])}function So({text:e,mode:n,tables:i=!1,gujiMarkdown:o=!1,properNames:s=!1,bookMarking:a,quoteStyle:l,renderText:d,dropTitle:c}){const p=jg(e),{t:h,convert:u}=ne(),m=v=>wo(v,{renderText:d,properNames:s,bookMarking:a,quoteStyle:l,gujiMarkdown:o,t:h}),f=o?{gujiMarkdown:!0,t:h}:void 0,x=c?u(c):void 0;return!i||p.indexOf(":::")<0?t.jsx(ra,{text:p,mode:n,inline:m,dropTitle:x}):t.jsx(t.Fragment,{children:bo(p).map((v,y)=>v.type==="table"?t.jsx(yo,{table:v.table,opts:f},y):t.jsx(ra,{text:v.text,mode:n,inline:m,dropTitle:y===0?x:void 0},y))})}const oa={work:"work",book:"work",people:"people",person:"people",place:"place",office:"office",dynasty:"dynasty",reign:"reign"};function vg(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(oa,e)&&oa[e]||"other"}function Er(e){if(!e)return null;const n=e.trim(),i=/^book-index:\/\/(?:[A-Za-z]+\/)*([0-9A-Za-z]+)\/?$/.exec(n);if(i)return i[1];const o=/^bid:\\{1,2}([0-9A-Za-z]+)$/.exec(n);return o?o[1]:/^[0-9A-Za-z]+$/.test(n)?n:null}function Dt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Qe(e){return typeof e=="string"&&e?e:void 0}function kg(e){const n=e&&typeof e=="object"?e.candidates:void 0;if(!Array.isArray(n))return;const i=[];for(const o of n){if(!o||typeof o!="object"||Array.isArray(o))continue;const s=o,a={};Qe(s.entity_id)!==void 0&&(a.entity_id=Qe(s.entity_id)),Qe(s.canonical_name)!==void 0&&(a.canonical_name=Qe(s.canonical_name)),Dt(s.confidence)!==void 0&&(a.confidence=Dt(s.confidence)),i.push(a)}return i}const dn=e=>e.start!==void 0&&e.end!==void 0;function Lc(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.entities)?e.entities:[],i=[];return n.forEach((o,s)=>{if(!o||typeof o!="object")return;const a=o,l=a.span??{},d=a.target??{},c=Dt(l.start_offset)??Dt(a.start_offset),p=Dt(l.end_offset)??Dt(a.end_offset),h=c!==void 0&&p!==void 0&&c>=0&&p>c,u=a.anchor??{},m=Qe(u.start),f=Qe(u.end);if(!h&&!!!(m&&f))return;const v=Qe(d.status),y=v===void 0||v==="matched"?Er(Qe(d.entity_id))??Er(Qe(d.href))??void 0:void 0,S=Dt(d.confidence),b=kg(a.ambiguous);i.push({...m&&f?{anchor:{start:m,end:f}}:{},key:Qe(a.id)??`e${s}`,kind:vg(a.type),...h?{start:c,end:p}:{},text:Qe(a.text),targetId:y,canonicalName:Qe(d.canonical_name),confidence:Dt(a.confidence)??S,...S!==void 0?{targetConfidence:S}:{},...Qe(d.level)!==void 0?{targetLevel:Qe(d.level)}:{},...Qe(d.note)!==void 0?{targetNote:Qe(d.note)}:{},...Qe(a.group)!==void 0?{group:Qe(a.group)}:{},...b!==void 0?{candidates:b}:{}})}),i.sort((o,s)=>!dn(o)||!dn(s)?+!dn(o)-+!dn(s):o.start-s.start||s.end-o.end)}const wg=new Set(Array.from(`《》/<>\r
|
|
1271
|
+
,。、;:?!「」『』()…—·`));function _o(e){return!wg.has(e)}function Ac(e,n,i=0){const o=[],s=Array.from(e);let a=0;for(const d of s)_o(d)&&o.push(a),a+=d.length;const l=[];for(const d of n){if(!dn(d))continue;const c=d.start-i,p=d.end-i;if(c<0||p>o.length||p<=c)continue;const h=o[p-1],u=e.codePointAt(h)>65535?2:1;l.push({...d,start:o[c],end:h+u})}return l}function Sg(e,n){return n.text?Array.from(e.slice(n.start,n.end)).filter(_o).join("")===n.text:!0}function _g(e,n,i){if(!n.text)return null;let o=-1,s=Math.max(0,n.start-i);const a=n.start+i;for(;s<=a;){const l=e.indexOf(n.text,s);if(l<0||l>a)break;(o<0||Math.abs(l-n.start)<Math.abs(o-n.start))&&(o=l),s=l+1}return o<0?null:{...n,start:o,end:o+n.text.length}}function Mc(e,n,i=16){const o=[];for(const l of n){if(!dn(l))continue;let d={...l,start:Math.max(0,l.start),end:Math.min(e.length,l.end)};(d.end<=d.start||!Sg(e,d))&&(d=_g(e,l,i)),d&&o.push(d)}o.sort((l,d)=>l.start-d.start||d.end-l.end);const s=[];let a=0;for(const l of o)l.start<a||(l.start>a&&s.push({type:"text",text:e.slice(a,l.start),start:a}),s.push({type:"entity",text:e.slice(l.start,l.end),start:l.start,span:l}),a=l.end);return a<e.length&&s.push({type:"text",text:e.slice(a),start:a}),s}const $g={off:[],lite:["people","place","dynasty"],full:["people","place","dynasty","office","reign","other"]};function Cg(e,n,i){const o=(i==null?void 0:i.showWorks)!==!1,s=new Set($g[n]);return e.filter(a=>a.kind==="work"?o:s.has(a.kind))}function Tg(e,n,i){const[o,s]=g.useState(null),[a,l]=g.useState(!1),d=g.useRef(0);return g.useEffect(()=>{const c=++d.current;if(!e||!n){s(null),l(!1);return}let p;try{p=e(n,i)}catch{s(null),l(!1);return}if(!p||typeof p.then!="function"){s(p??null),l(!1);return}l(!0),p.then(h=>{c===d.current&&s(h??null)}).catch(()=>{c===d.current&&s(null)}).finally(()=>{c===d.current&&l(!1)})},[e,n,i]),{images:o,loading:a}}function zg(e){return typeof e!="string"?null:e==="published"?"source":Object.prototype.hasOwnProperty.call(Up,e)?e:null}function Ng(e){if(e==="none")return{color:r("quality-none"),fontWeight:400};if(e==="placeholder")return{color:r("quality-placeholder"),fontWeight:400}}const Ig={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释",tally:"小计"},Pc="\0";function Rg(e,n,i){const[o,s=""]=e.split(Pc);return t.jsxs(t.Fragment,{children:[o,t.jsx(Ll,{text:n,convert:i}),s]})}function bt(e){return typeof e!="string"?"":Ig[e]??e}const Eg=["〇","一","二","三","四","五","六","七","八","九"],sa=["","十","百","千"],Lg=["","萬","億"];function $o(e){if(e===0)return"〇";if(e<0)return`負${$o(-e)}`;const n=[];let i=e,o=0;for(;i>0;){const s=i%1e4;s>0?n.unshift(Ag(s,o>0)+Lg[o]):n.length>0&&n.unshift("〇"),i=Math.floor(i/1e4),o++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Ag(e,n){const i=[];let o=e;for(;o>0;)i.unshift(o%10),o=Math.floor(o/10);let s="";for(let a=0;a<i.length;a++){const l=i[a],d=i.length-1-a;l===0?s&&!s.endsWith("〇")&&(s+="〇"):l===1&&d===1&&a===0&&!n?s+=sa[d]:s+=Eg[l]+sa[d]}return s.replace(/〇$/,"")}let An=null,oi=null;const yi=new Set;function Mg(){return An?Promise.resolve():oi||(oi=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});An=i=>n(Se.normalizeVariants(i)),yi.forEach(i=>i())}).catch(()=>{An=e=>e,yi.forEach(e=>e())}),oi)}const Pg=e=>e;function rn(){const[,e]=g.useState(0);return g.useEffect(()=>{if(An)return;const n=()=>e(i=>i+1);return yi.add(n),Mg(),()=>{yi.delete(n)}},[]),An??Pg}function gn(e,n){return n(e).toLowerCase()}const Bg=r("highlight-bg");function Dn(e,n,i){if(!n)return e;const o=gn(n,i);if(!o)return e;const s=gn(e,i),a=Array.from(e),l=Array.from(s);if(l.length!==a.length)return e;const d=new Map;let c=0;l.forEach((x,v)=>{d.set(c,v),c+=x.length});const p=Array.from(o).length,h=[];let u=0,m=0,f=0;for(;u<a.length;){const x=s.indexOf(o,m),v=x===-1?void 0:d.get(x);if(x===-1){h.push(a.slice(u).join(""));break}if(v===void 0){m=x+1;continue}v>u&&h.push(a.slice(u,v).join("")),h.push(t.jsx("mark",{style:{background:Bg,padding:0,color:"inherit"},children:a.slice(v,v+p).join("")},f++)),u=v+p,m=x+o.length}return t.jsx(t.Fragment,{children:h})}function Co(e,n,i,o){if(!n)return!0;const s=gn(n,o);return(i?[e.title,e.header_line,e.content,e.comment]:[e.title,e.book_title,e.author,e.author_info,e.summary,e.content,e.comment,e.additional_comment]).some(l=>typeof l=="string"&&gn(l,o).includes(s))}function Wg(e,n,i){return n?gn(e,i).includes(gn(n,i)):!0}const To={类:r("section-lei"),书:r("section-shu"),序:r("section-xu"),结语:r("section-jieyu"),注释:r("section-zhushi")},Og={考证:r("section-kaozhen")};function zo(e,n,i){return e.collated.sectionType[n]??i(n)}function Bc(e){var o;const n=e.files.length,i=((o=e.children)==null?void 0:o.reduce((s,a)=>s+Bc(a),0))||0;return n+i}function Fg(e,n){const i=[],o=l=>{var d;i.push(...l.files),(d=l.children)==null||d.forEach(o)};if(o(e),i.length===0)return;const s=i.map(l=>n[l]);if(s.every(l=>l===void 0))return;if(s.some(l=>l==="loading"))return"loading";let a=0;for(const l of s)typeof l=="number"&&(a+=l);return a}const Hg={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function No({enabled:e,expanded:n,onClick:i,style:o,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:i,style:{...Hg,...o},children:s}):t.jsx("span",{style:o,children:s})}function Dg({type:e}){const{convert:n,messages:i}=ne(),o=bt(e),s=To[o]||r("desc-fg");return t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:s,border:`1px solid ${s}40`,borderRadius:"2px",background:`${s}08`,flexShrink:0},children:zo(i,o,n)})}function Ug({section:e,onNavigate:n,highlightQuery:i="",no:o,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=ne(),c=tt(),p=rn(),h=w=>w?ft(d(w),j=>i?Dn(j,i,p):j,{t:l}):"",[u,m]=g.useState(!1),f=!!e.summary,x=!!e.comment,v=!!e.additional_comment,y=!!(e.content&&e.content.length>60),S=f||x||v||y;g.useEffect(()=>{i&&m(!0)},[i]);const b=!u&&y?fc(e.content.replace(/\n/g," "),80)+"…":null;return t.jsxs("div",{className:"bim-rd-row",id:a,style:{borderBottom:`1px solid ${r("rule")}`,overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>S&&m(!u),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:S?"pointer":"default",userSelect:"none"},children:[o!=null&&t.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:r("label-fg")},children:o}),t.jsxs(No,{enabled:S,expanded:u,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[S&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),transition:"transform 0.15s",transform:u?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1,minWidth:0},children:[t.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg")},children:[e.book_title?t.jsxs(t.Fragment,{children:["《",h(e.book_title),"》"]}):h(e.title),e.n_juan!=null&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:l("collated.nJuan",{n:d($o(e.n_juan))})}),(e.author_info||e.author)&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"8px"},children:h(e.author_info||e.author)})]}),!u&&b&&t.jsx("span",{style:{display:"block",fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:h(b)})]})]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:h(e.edition)}),e.tag&&t.jsx("span",{style:{fontSize:"11px",color:r("section-tag-fg")},children:e.tag==="triangle"?"△":e.tag}),e.work_id&&n&&t.jsx("a",{href:c(e.work_id),onClick:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),w.stopPropagation(),n(e.work_id))},style:{fontSize:"11px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:l("collated.viewWork"),"aria-label":l("collated.viewWorkOf",{title:d(e.book_title||e.title)}),children:l("collated.workArrow")}),s&&!e.work_id&&t.jsx("span",{style:{fontSize:"11px",color:r("label-fg"),flexShrink:0},children:l("collated.unlinked")})]}),u&&S&&t.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${r("widget-border")}`,background:r("bg")},children:[e.author_info&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"8px"},children:h(e.author_info)}),e.summary&&t.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.summary")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:h(e.summary)})]}),e.comment&&t.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.comment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:h(e.comment)})]}),e.additional_comment&&t.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.additionalComment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:h(e.additional_comment)})]}),y&&!f&&!x&&!v&&t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:h(e.content)})]})]})}function Vg({section:e,highlightQuery:n=""}){const{t:i,convert:o}=ne(),s=rn(),a=p=>p?ft(o(p),h=>n?Dn(h,n,s):h,{t:i}):"",[l,d]=g.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(No,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(Dg,{type:e.type}),t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:r("fg")},children:a(e.title)}),c&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),transition:"transform 0.15s",transform:l?"rotate(90deg)":"none",display:"inline-block"},children:"▶"})]}),l&&c&&t.jsx("div",{style:{marginTop:"8px",padding:"10px 14px",borderLeft:`3px solid color-mix(in srgb, ${To[bt(e.type)]||r("desc-fg")} 25%, transparent)`,borderRadius:"0 4px 4px 0",background:r("bg")},children:t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:a(e.content)})})]})}const Gg=100;function Io(e){return bt(e.type)!=="page_header"?!1:(e.content||"").length>=Gg}function Yg({section:e,highlightQuery:n=""}){const{t:i,convert:o,messages:s}=ne(),a=rn();if(bt(e.type)==="page_header"&&!Io(e)||!e.content&&!e.title)return null;const l=o((e.content||e.title||"").replace(/\n{2,}/g,`
|
|
1272
|
+
`)),d=ft(l,u=>n?Dn(u,n,a):u,{t:i}),c=bt(e.type),p=To[c]||r("desc-fg"),h=c==="序"||c==="结语"||c==="注释";return t.jsxs("div",{style:{padding:h?"10px 12px":"6px 0",margin:h?"8px 0":void 0,fontSize:"13px",color:r("desc-fg"),lineHeight:1.8,whiteSpace:"pre-line",borderLeft:h?`3px solid ${p}40`:void 0,background:h?r("bg"):void 0,borderRadius:h?"0 4px 4px 0":void 0,position:"relative"},children:[h&&t.jsx("span",{style:{display:"inline-block",fontSize:"10px",fontWeight:500,color:p,marginRight:"8px",padding:"1px 5px",border:`1px solid ${p}40`,borderRadius:"2px",background:`${p}08`,verticalAlign:"middle"},children:zo(s,c,o)}),d]})}function qg(e,n,i){const[o,s]=g.useState({});return g.useEffect(()=>{var p;if(!n||e.length===0)return;let a=!1;const l=e.filter(h=>{var u;return!((u=i==null?void 0:i.current)!=null&&u.has(h))}),d={};for(const h of e)(p=i==null?void 0:i.current)!=null&&p.has(h)&&(d[h]=i.current.get(h));if(Object.keys(d).length>0&&s(d),l.length===0)return;const c=async h=>{var u;try{if(n.getEntry){const y=await n.getEntry(h);if(y)return{title:y.title,author:y.author}}const m=await n.getItem(h);if(!m)return null;const f=m.title||h,x=m.authors,v=(u=x==null?void 0:x[0])==null?void 0:u.name;return{title:f,author:v}}catch{return null}};return Promise.all(l.map(async h=>{var m;const u=await c(h);return(m=i==null?void 0:i.current)==null||m.set(h,u),[h,u]})).then(h=>{a||s(u=>{const m={...u};for(const[f,x]of h)m[f]=x;return m})}),()=>{a=!0}},[e.join(","),n]),o}function Kg({section:e,onNavigate:n,transport:i,workLabelCache:o,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=ne(),c=tt(),p=rn(),h=j=>j?ft(l(j),k=>s?Dn(k,s,p):k,{t:a}):"",[u,m]=g.useState(!1);g.useEffect(()=>{s&&m(!0)},[s]);const f=bt(e.type),x=Og[f]||r("desc-fg"),v=!!e.content,y=e.work_ids||[],S=y.length>1,b=qg(S?y:[],i,o),w=v&&!u&&e.content.length>80?fc(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${r("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>v&&m(!u),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:v?"pointer":"default",userSelect:"none"},children:[t.jsxs(No,{enabled:v,expanded:u,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[v&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:u?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg"),lineHeight:1.6},children:e.header_line?h(e.header_line):h(e.title)}),!u&&w&&t.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:r("desc-fg"),lineHeight:1.7},children:h(w)})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[y.length===1&&n&&t.jsx("a",{href:c(y[0]),onClick:j=>{j.metaKey||j.ctrlKey||(j.preventDefault(),j.stopPropagation(),n(y[0]))},style:{fontSize:"11px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:a("collated.viewWork"),children:a("collated.arrowWork")}),S&&t.jsx("span",{style:{fontSize:"11px",color:r("link-fg"),flexShrink:0},children:a("collated.nWorks",{n:y.length})}),t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:x,border:`1px solid ${x}40`,borderRadius:"2px",background:`${x}08`},children:zo(d,f,l)})]})]}),S&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:y.map(j=>{const k=b[j],$=k?`${l(k.title)}${k.author?`(${l(k.author)})`:""}`:j.slice(0,8)+"…";return t.jsxs("a",{href:c(j),onClick:C=>{C.metaKey||C.ctrlKey||(C.preventDefault(),C.stopPropagation(),n(j))},style:{fontSize:"12px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:j,children:["→",$]},j)})}),u&&v&&t.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${x}40`,borderRadius:"0 4px 4px 0",background:r("bg")},children:[t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:h(e.content)}),e.comment&&t.jsx("div",{style:{marginTop:"10px",paddingTop:"8px",borderTop:`1px solid ${r("widget-border")}`,fontSize:"12px",color:r("desc-fg"),lineHeight:1.8,fontStyle:"italic"},children:h(e.comment)})]})]})}function Xg({juan:e,searchQuery:n,onNavigate:i,transport:o,workLabelCache:s}){const{t:a}=ne(),l=rn(),d=n.trim(),c=g.useMemo(()=>d?e.sections.filter(p=>Co(p,d,!0,l)):e.sections,[e.sections,d,l]);return t.jsxs("div",{children:[t.jsx("div",{children:c.map((p,h)=>t.jsx(Kg,{section:p,onNavigate:i,transport:o,workLabelCache:s,highlightQuery:d},h))}),c.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:a("collated.noMatch")})]})}function Zg(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function Jg({sections:e,onNavigate:n,inline:i,workLinks:o=!0}){const s=tt(),{t:a,convert:l}=ne(),d=Zg();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const h=bt(c.type);if(h==="page_header"&&!Io(c))return null;if(h==="类")return t.jsxs(g.Fragment,{children:[g.createElement(d("类"),null,i(l(c.title))),c.content&&t.jsx("p",{children:i(l(c.content))})]},p);if(h==="书"||h==="诗"||h==="考证"||h==="注释"){const u=c.book_title?`《${c.book_title}》${c.n_juan!=null?a("collated.nJuan",{n:$o(c.n_juan)}):""}`:c.title,m=i(l(u));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[g.createElement(d("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&o?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},title:a("collated.viewWork"),children:m}),t.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},"aria-label":a("collated.viewWorkOf",{title:l(u)}),children:a("collated.workArrow")})]}):m),c.author_info&&t.jsx("p",{className:"bim-rd-sub",children:i(l(c.author_info))}),c.content&&c.content.split(/\n+/).map((f,x)=>t.jsx("p",{children:i(l(f))},x)),c.summary&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.summary")}),i(l(c.summary))]}),c.comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.comment")}),i(l(c.comment))]}),c.additional_comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.additionalComment")}),i(l(c.additional_comment))]})]},p)}return h==="小计"&&c.title?t.jsx("p",{children:i(l(c.title))},p):c.content?t.jsx("p",{children:i(l(c.content))},p):null})})}function Wc(e){return e.some(n=>{const i=bt(n.type);return i==="书"||i==="诗"||i==="考证"||i==="注释"||i==="类"||(i==="序"||i==="结语")&&!!n.content||i==="page_header"&&Io(n)})}function Qg({juan:e,rawText:n,positionLabel:i,groupLabel:o,index:s,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c,prefs:p,view:h,onViewChange:u}){var he;const{t:m,convert:f,messages:x}=ne(),v=rn(),[y,S]=g.useState("text"),b=h??y,w=Z=>{S(Z),u==null||u(Z)},j=a.trim(),k=(s==null?void 0:s.type)==="kaozhen",$=g.useCallback(Z=>j?Dn(Z,j,v):Z,[j,v]),C=ko(p),_=Z=>wo(Z,{renderText:$,bookMarking:C,quoteStyle:p.quoteStyle,t:m}),E=g.useMemo(()=>j?e.sections.filter(Z=>Co(Z,j,k,v)):e.sections,[e.sections,j,k,v]),z=(Z,M)=>M.filter(_e=>bt(_e.type)===Z).length,T=z("书",e.sections),B=z("诗",e.sections),W=z("考证",e.sections);let N="";k?N=j?m("collated.countTiaoOf",{m:z("考证",E),n:W}):m("collated.countTiao",{n:W}):B>0?N=j?m("collated.countPoemsOf",{m:z("诗",E),n:B}):m("collated.countPoems",{n:B}):T>0&&(N=j?m("collated.countBooksOf",{m:z("书",E),n:T}):m("collated.countBooks",{n:T}));const A=s!=null&&s.text_quality?zg(s.text_quality.grade):null,F=[];if(N&&F.push(N),k&&(s!=null&&s.target_source)&&F.push(t.jsx(t.Fragment,{children:m("collated.kaozhenTarget",{target:f(s.target_source)})})),A){const Z=t.jsx("span",{className:"bim-rd-grade",style:Ng(A),children:x.collated.qualityLabel[A]});F.push(t.jsx("span",{title:x.collated.qualityCriteria[A],children:(he=s==null?void 0:s.text_quality)!=null&&he.source_note?t.jsxs(t.Fragment,{children:[Rg(m("collated.baseText",{note:Pc}),s.text_quality.source_note,f),Z]}):t.jsxs(t.Fragment,{children:[m("collated.textQuality"),Z]})}))}e.source_url&&F.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:m("collated.originalSource")}));const Y=!k&&Wc(e.sections),te=!!n&&(!Y||p.readingMode==="paragraph"&&bi(n)),se=!k&&(Y||!!n),D=k||!se?"entries":b;let V=0;return t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[(i||o)&&t.jsxs("p",{className:"bim-rd-kicker",children:[i,i&&o&&t.jsx("span",{className:"bim-rd-dot"}),o&&f(o)]}),t.jsx("h1",{className:"bim-rd-h1",children:f(e.title)}),F.length>0&&t.jsx("p",{className:"bim-rd-meta",children:F.map((Z,M)=>t.jsxs(g.Fragment,{children:[M>0&&t.jsx("span",{className:"bim-rd-dot"}),Z]},M))}),se&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":m("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":D==="text",onClick:()=>w("text"),children:m("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":D==="entries",onClick:()=>w("entries"),children:m("collated.viewEntries")})]})]}),D==="text"&&t.jsx("article",{className:"bim-rd-prose",children:te?t.jsx(So,{text:n,mode:p.readingMode,bookMarking:C,quoteStyle:p.quoteStyle,renderText:$,dropTitle:e.title}):t.jsx(Jg,{sections:e.sections,onNavigate:l,inline:_,workLinks:p.workLinks})}),D==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:k?t.jsx(Xg,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[E.some(Z=>["书","诗","考证"].includes(bt(Z.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:m("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:m("collated.rowHeadTitle")}),t.jsx("span",{children:m("collated.rowHeadWork")})]}),E.map((Z,M)=>{const _e=bt(Z.type);return _e==="书"||_e==="诗"||_e==="考证"?(V+=1,t.jsx(Ug,{domId:`rd-e-${e.sections.indexOf(Z)}`,section:Z,onNavigate:p.workLinks?l:void 0,highlightQuery:j,no:V,showUnlinked:p.workLinks&&!!l},M)):_e==="类"?t.jsx(Vg,{section:Z,highlightQuery:j},M):t.jsx(Yg,{section:Z,highlightQuery:j},M)}),E.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:m("collated.noMatch")})]})})]})}function ef(e){const{resetKey:n,load:i,files:o,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=rn(),h=g.useRef(new Map),[u,m]=g.useState({}),[f,x]=g.useState({}),v=g.useCallback((S,b)=>{const w=b==null?void 0:b.title;w&&x(j=>j[S]===w?j:{...j,[S]:w})},[]);g.useEffect(()=>{s&&a&&(h.current.set(s,{juan:a,rawText:l}),v(s,a))},[s,a,l,v]),g.useEffect(()=>{h.current.clear(),m({}),x({})},[n]);const y=g.useCallback((S,b)=>{let w=0;if(S.juan)for(const j of S.juan.sections)Co(j,b,c,p)&&w++;return w===0&&S.rawText&&Wg(S.rawText,b,p)&&(w=1),w},[c,p]);return g.useEffect(()=>{const S=d.trim();if(!S){m({});return}if(!i||o.length===0)return;let b=!1;const w={},j=[];for(const E of o){const z=h.current.get(E);z?w[E]=y(z,S):(w[E]="loading",j.push(E))}m(w);const k=8;let $=0;const C=async()=>{for(;$<j.length;){if(b)return;const E=$++,z=j[E];try{const T=await i(z),B=T.juan;if(h.current.set(z,T),v(z,B),b)return;m(W=>({...W,[z]:y(T,S)}))}catch{if(b)return;m(T=>({...T,[z]:0}))}}},_=Array.from({length:Math.min(k,j.length)},()=>C());return Promise.all(_),()=>{b=!0}},[d,n,i,o.join(","),y,p,v]),{matchStates:u,titles:f}}function tf({juan:e,view:n,onView:i,textHasEntries:o}){const{t:s,convert:a}=ne(),l=e.sections.map((h,u)=>({s:h,i:u,t:bt(h.type)})).filter(h=>h.t==="书"||h.t==="诗");if(l.length===0)return null;const d=l.filter(h=>!!h.s.work_id).length,c=l.every(h=>h.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),p=h=>{const u=()=>{var m,f;return(f=(m=document.getElementById(`rd-e-${h}`))==null?void 0:m.scrollIntoView)==null?void 0:f.call(m,{block:"start",behavior:"smooth"})};n==="text"&&!o&&i("entries"),n==="text"&&!o?setTimeout(u,0):u()};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-rd-rail-card",children:[t.jsx("div",{className:"bim-rd-rail-cap",children:s("collated.railCap")}),t.jsxs("div",{className:"bim-rd-rail-n",children:[t.jsx("b",{children:l.length}),t.jsx("span",{children:c}),t.jsx("span",{className:"bim-rd-rail-linked",children:s("collated.linkedN",{n:d})})]}),t.jsx("div",{className:"bim-rd-rail-bar",role:"img","aria-label":s("collated.linkedOf",{n:d,total:l.length}),children:t.jsx("span",{style:{width:`${Math.round(d/l.length*100)}%`}})})]}),t.jsxs("nav",{"aria-label":s("collated.railEntriesNav"),children:[t.jsx("div",{className:"bim-rd-rail-cap",style:{margin:"20px 0 6px 12px"},children:s("collated.viewEntries")}),t.jsx("ul",{className:"bim-rd-rail-list",children:l.map(({s:h,i:u})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${u}`,onClick:m=>{m.preventDefault(),p(u)},children:[t.jsx("span",{className:`bim-rd-rail-dot${h.work_id?" on":""}`,"aria-hidden":"true"}),t.jsx("span",{children:a(h.book_title||h.title)})]})},u))})]})]})}const nf=`
|
|
1273
1273
|
attribute vec2 a_position; // 目标画布像素坐标 [0, canvasWidth] x [0, canvasHeight]
|
|
1274
1274
|
attribute vec2 a_texCoord; // 原图像素坐标 [0, imgWidth] x [0, imgHeight]
|
|
1275
1275
|
|
|
@@ -1287,7 +1287,7 @@ ${$h}`;function In({children:e,style:n,wide:i,grid:o}){return t.jsxs("div",{clas
|
|
|
1287
1287
|
// 纹理坐标归一化 [0, 1]
|
|
1288
1288
|
v_texCoord = a_texCoord / u_imgResolution;
|
|
1289
1289
|
}
|
|
1290
|
-
`,
|
|
1290
|
+
`,rf=`
|
|
1291
1291
|
precision mediump float;
|
|
1292
1292
|
uniform sampler2D u_image;
|
|
1293
1293
|
uniform float u_alpha;
|
|
@@ -1297,7 +1297,7 @@ ${$h}`;function In({children:e,style:n,wide:i,grid:o}){return t.jsxs("div",{clas
|
|
|
1297
1297
|
vec4 tex = texture2D(u_image, v_texCoord);
|
|
1298
1298
|
gl_FragColor = vec4(tex.rgb, tex.a * u_alpha);
|
|
1299
1299
|
}
|
|
1300
|
-
`;function sa(e,n,i){const o=e.createShader(n);return o?(e.shaderSource(o,i),e.compileShader(o),e.getShaderParameter(o,e.COMPILE_STATUS)?o:(console.error("Shader compile error:",e.getShaderInfoLog(o)),e.deleteShader(o),null)):null}class Lr{constructor(n){const i=n.getContext("webgl",{alpha:!0,antialias:!0,preserveDrawingBuffer:!0,premultipliedAlpha:!1});if(!i)throw new Error("WebGL not supported");this.gl=i;const o=sa(i,i.VERTEX_SHADER,tf),s=sa(i,i.FRAGMENT_SHADER,nf);if(!o||!s)throw new Error("Failed to create shaders");const a=i.createProgram();if(!a)throw new Error("Failed to create program");if(i.attachShader(a,o),i.attachShader(a,s),i.linkProgram(a),!i.getProgramParameter(a,i.LINK_STATUS))throw new Error("Program link error: "+i.getProgramInfoLog(a));this.program=a,this.positionBuffer=i.createBuffer(),this.texCoordBuffer=i.createBuffer(),this.uResolutionLoc=i.getUniformLocation(a,"u_resolution"),this.uImgResolutionLoc=i.getUniformLocation(a,"u_imgResolution"),this.uAlphaLoc=i.getUniformLocation(a,"u_alpha"),this.aPositionLoc=i.getAttribLocation(a,"a_position"),this.aTexCoordLoc=i.getAttribLocation(a,"a_texCoord"),i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.clear(n.width,n.height)}clear(n,i){const o=this.gl;o.viewport(0,0,n,i),o.clearColor(.98,.97,.95,1),o.clear(o.COLOR_BUFFER_BIT)}createTexture(n){const i=this.gl,o=i.createTexture();return i.bindTexture(i.TEXTURE_2D,o),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,n),o}renderStripsWithTexture(n,i,o,s,a,l,d=1){if(l.length===0)return;const c=this.gl;c.viewport(0,0,i,o),c.useProgram(this.program),c.uniform2f(this.uResolutionLoc,i,o),c.uniform2f(this.uImgResolutionLoc,s,a),c.uniform1f(this.uAlphaLoc,d);const p=[],h=[],u=8;for(const m of l){const f=m.colOffsetX||0,x=m.colOffsetY||0,{srcQuad:v,dstRect:y}=m.strip,[S,b,w,j]=y,k=f+S,$=x+b,[C,_,E,z]=v;for(let T=0;T<u;T++){const B=T/u,W=(T+1)/u,N=$+j*B,A=$+j*W,F=[C[0]+(z[0]-C[0])*B,C[1]+(z[1]-C[1])*B],Y=[C[0]+(z[0]-C[0])*W,C[1]+(z[1]-C[1])*W],ee=[_[0]+(E[0]-_[0])*B,_[1]+(E[1]-_[1])*B],se=[_[0]+(E[0]-_[0])*W,_[1]+(E[1]-_[1])*W],D=[k,N],V=[k+w,N],he=[k,A],Z=[k+w,A];p.push(D[0],D[1],V[0],V[1],he[0],he[1]),h.push(F[0],F[1],ee[0],ee[1],Y[0],Y[1]),p.push(V[0],V[1],Z[0],Z[1],he[0],he[1]),h.push(ee[0],ee[1],se[0],se[1],Y[0],Y[1])}}c.bindBuffer(c.ARRAY_BUFFER,this.positionBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(p),c.STATIC_DRAW),c.enableVertexAttribArray(this.aPositionLoc),c.vertexAttribPointer(this.aPositionLoc,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,this.texCoordBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(h),c.STATIC_DRAW),c.enableVertexAttribArray(this.aTexCoordLoc),c.vertexAttribPointer(this.aTexCoordLoc,2,c.FLOAT,!1,0,0),c.bindTexture(c.TEXTURE_2D,n),c.drawArrays(c.TRIANGLES,0,p.length/2)}deleteTexture(n){n&&this.gl.deleteTexture(n)}destroy(){const n=this.gl;n.deleteProgram(this.program),n.deleteBuffer(this.positionBuffer),n.deleteBuffer(this.texCoordBuffer)}}function rf(e){const[n,i]=e.image_size||[0,0];if(!(n>0)||!(i>0)||e.columns.some(m=>{var f;return(((f=m.strips)==null?void 0:f.length)??0)>0}))return null;let o=1/0,s=1/0,a=-1/0,l=-1/0;for(const m of e.columns)for(const f of m.chars){const[x,v,y,S]=f.bbox_col;![x,v,y,S].every(Number.isFinite)||!(y>x)||!(S>v)||(o=Math.min(o,m.offset_x+x),s=Math.min(s,v),a=Math.max(a,m.offset_x+y),l=Math.max(l,S))}if(!(a>o)||!(l>s))return null;const d=Math.min(n,i)*.03,c=Math.min(n,Math.max(0,o-d)),p=Math.min(i,Math.max(0,s-d)),h=Math.min(n,Math.max(0,a+d))-c,u=Math.min(i,Math.max(0,l+d))-p;return!(h>0)||!(u>0)||h>=n*.98&&u>=i*.98?null:{x:c,y:p,w:h,h:u}}const Ft=new Map,of=24;function Ar(e){let n=Ft.get(e);if(n)return Ft.delete(e),Ft.set(e,n),n;for(n=new Promise(i=>{const o=new Image;o.crossOrigin="anonymous",o.onload=()=>{(o.decode?o.decode().catch(()=>{}):Promise.resolve()).then(()=>i(o))},o.onerror=()=>{Ft.delete(e),i(null)},o.src=e}),Ft.set(e,n);Ft.size>of;)Ft.delete(Ft.keys().next().value);return n}const Ro=({imageUrl:e,pageData:n,selectedCharIds:i,hoveredCharId:o,preserveMargins:s=!1,onCharClick:a,onCharHover:l})=>{const d=g.useRef(null),c=g.useRef(null),p=g.useRef(null),h=g.useRef(null),u=g.useRef(null),m=g.useRef(null),[f,x]=g.useState(0),[v,y]=g.useState(0),S=g.useRef(""),b=g.useMemo(()=>Math.max(...n.columns.map(N=>N.warped_h),2440),[n]),w=n.total_warped_w,j=n.banxin,k=g.useMemo(()=>{var D;if(!s)return{top:0,bottom:0,left:0,right:0};const[N,A]=n.image_size||[2386,3082];let F=1/0,Y=-1/0,ee=1/0,se=-1/0;for(const V of n.columns)for(const he of V.strips||[])for(const Z of he.srcQuad)Z[0]<F&&(F=Z[0]),Z[0]>Y&&(Y=Z[0]),Z[1]<ee&&(ee=Z[1]),Z[1]>se&&(se=Z[1]);if((D=n.banxin)!=null&&D.current_page_strips)for(const V of n.banxin.current_page_strips)for(const he of V.srcQuad)he[0]<F&&(F=he[0]),he[0]>Y&&(Y=he[0]),he[1]<ee&&(ee=he[1]),he[1]>se&&(se=he[1]);return isFinite(F)||(F=0),isFinite(Y)||(Y=N),isFinite(ee)||(ee=0),isFinite(se)||(se=A),{top:Math.max(0,Math.round(ee)),bottom:Math.max(0,Math.round(A-se)),left:Math.max(0,Math.round(F)),right:Math.max(0,Math.round(N-Y)),rawMinX:F,rawMaxX:Y,rawMinY:ee,rawMaxY:se,imgW:N,imgH:A}},[n,s]),$=g.useMemo(()=>s?null:rf(n),[n,s]),C=w+(j?j.total_w:0),_=$?$.w:C+k.left+k.right,E=$?$.h:b+k.top+k.bottom,z=g.useCallback(()=>{const N=c.current;if(!(!N||!d.current)&&!(e&&S.current!==e)){if(N.clear(_,E),s&&k.rawMinX!==void 0&&u.current&&p.current){const{rawMinX:A,rawMaxX:F,rawMinY:Y,rawMaxY:ee,imgW:se,imgH:D,top:V,bottom:he,left:Z,right:M}=k,_e=[];Z>0&&_e.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[A,0],[A,D],[0,D]],dstRect:[0,0,Z,E]}}),V>0&&_e.push({colOffsetX:Z,colOffsetY:0,strip:{srcQuad:[[A,0],[F,0],[F,Y],[A,Y]],dstRect:[0,0,C,V]}}),he>0&&_e.push({colOffsetX:Z,colOffsetY:V+b,strip:{srcQuad:[[A,ee],[F,ee],[F,D],[A,D]],dstRect:[0,0,C,he]}}),M>0&&_e.push({colOffsetX:Z+C,colOffsetY:0,strip:{srcQuad:[[F,0],[se,0],[se,D],[F,D]],dstRect:[0,0,M,E]}}),N.renderStripsWithTexture(u.current,_,E,n.image_size[0],n.image_size[1],_e,1)}if(u.current&&p.current){const A=n.columns.flatMap(F=>(F.strips||[]).map(Y=>({colOffsetX:k.left+F.offset_x,colOffsetY:k.top,strip:Y})));if(A.length>0?N.renderStripsWithTexture(u.current,_,E,n.image_size[0],n.image_size[1],A,1):N.renderStripsWithTexture(u.current,_,E,n.image_size[0],n.image_size[1],[{colOffsetX:0,colOffsetY:0,strip:{srcQuad:$?[[$.x,$.y],[$.x+$.w,$.y],[$.x+$.w,$.y+$.h],[$.x,$.y+$.h]]:[[0,0],[n.image_size[0],0],[n.image_size[0],n.image_size[1]],[0,n.image_size[1]]],dstRect:[0,0,_,E]}}],1),j&&j.current_page_strips.length>0){const F=j.current_page_strips.map(Y=>({colOffsetX:k.left+w,colOffsetY:k.top,strip:Y}));N.renderStripsWithTexture(u.current,_,E,n.image_size[0],n.image_size[1],F,1)}}if(j&&m.current&&h.current&&j.mate_page_strips.length>0){const A=j.mate_page_strips.map(F=>({colOffsetX:k.left+w+j.half_w,colOffsetY:k.top,strip:F}));N.renderStripsWithTexture(m.current,_,E,j.mate_img_size[0],j.mate_img_size[1],A,.65)}}},[e,n,j,_,E,w,b,C,k,s,$]),T=g.useRef(z);T.current=z,g.useEffect(()=>{const N=d.current;if(!N)return;const A=ee=>{u.current=p.current?ee.createTexture(p.current):null,m.current=h.current?ee.createTexture(h.current):null,T.current()};try{const ee=new Lr(N);c.current=ee,A(ee)}catch(ee){console.error("Failed to init WebGL renderer:",ee)}const F=ee=>{ee.preventDefault(),console.warn("WebGL context lost")},Y=()=>{console.info("WebGL context restored, re-initializing..."),d.current&&(c.current=new Lr(d.current),A(c.current))};return N.addEventListener("webglcontextlost",F,!1),N.addEventListener("webglcontextrestored",Y,!1),()=>{N.removeEventListener("webglcontextlost",F),N.removeEventListener("webglcontextrestored",Y),c.current&&(c.current.deleteTexture(u.current),c.current.deleteTexture(m.current),c.current.destroy(),c.current=null)}},[]),g.useEffect(()=>{if(!e)return;let N=!0;return Ar(e).then(A=>{if(!N||!A)return;p.current=A,S.current=e;const F=c.current;F&&(F.deleteTexture(u.current),u.current=F.createTexture(A)),x(Y=>Y+1)}),()=>{N=!1}},[e]);const B=j==null?void 0:j.mate_image_url;g.useEffect(()=>{if(!B)return;let N=!0;return Ar(B).then(A=>{if(!N||!A)return;h.current=A;const F=c.current;F&&(F.deleteTexture(m.current),m.current=F.createTexture(A)),y(Y=>Y+1)}),()=>{N=!1}},[B]),g.useEffect(()=>{z()},[z,f,v]);const W=g.useMemo(()=>{const N=[];for(const A of n.columns)for(const F of A.chars){const[Y,ee,se,D]=F.bbox_col;N.push({id:F.id,char:F.char,x:k.left+A.offset_x+Y-(($==null?void 0:$.x)??0),y:k.top+ee-(($==null?void 0:$.y)??0),w:Math.max(se-Y,1),h:Math.max(D-ee,1)})}return N},[n,k,$]);return t.jsxs("div",{className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${_} / ${E}`,backgroundColor:r("warp-bg"),boxShadow:r("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("canvas",{ref:d,width:_,height:E,style:{width:"100%",height:"100%",display:"block",backgroundColor:r("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${_} ${E}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[W.map(N=>{const A=i.has(N.id),F=o===N.id;return t.jsx("rect",{"data-selected":A?"true":void 0,x:N.x,y:N.y,width:N.w,height:N.h,fill:A?r("warp-sel-bg"):F?r("warp-hover-bg"):"transparent",stroke:A?r("warp-sel-stroke"):F?r("warp-hover-stroke"):"transparent",strokeWidth:A?3.5:F?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>a==null?void 0:a(N.id),onMouseEnter:()=>l==null?void 0:l(N.id),onMouseLeave:()=>l==null?void 0:l(null),children:t.jsx("title",{children:N.char})},N.id)}),j&&t.jsxs("g",{children:[t.jsx("line",{x1:k.left+w,y1:k.top,x2:k.left+w,y2:k.top+b,stroke:r("warp-banxin-border"),strokeWidth:1.5}),t.jsx("line",{x1:k.left+w+j.half_w,y1:k.top,x2:k.left+w+j.half_w,y2:k.top+b,stroke:r("warp-banxin-fold"),strokeWidth:1.5,strokeDasharray:"8 6"}),t.jsx("line",{x1:k.left+C,y1:k.top,x2:k.left+C,y2:k.top+b,stroke:r("warp-banxin-outer"),strokeWidth:1})]})]})]})},Eo=`
|
|
1300
|
+
`;function aa(e,n,i){const o=e.createShader(n);return o?(e.shaderSource(o,i),e.compileShader(o),e.getShaderParameter(o,e.COMPILE_STATUS)?o:(console.error("Shader compile error:",e.getShaderInfoLog(o)),e.deleteShader(o),null)):null}class Lr{constructor(n){const i=n.getContext("webgl",{alpha:!0,antialias:!0,preserveDrawingBuffer:!0,premultipliedAlpha:!1});if(!i)throw new Error("WebGL not supported");this.gl=i;const o=aa(i,i.VERTEX_SHADER,nf),s=aa(i,i.FRAGMENT_SHADER,rf);if(!o||!s)throw new Error("Failed to create shaders");const a=i.createProgram();if(!a)throw new Error("Failed to create program");if(i.attachShader(a,o),i.attachShader(a,s),i.linkProgram(a),!i.getProgramParameter(a,i.LINK_STATUS))throw new Error("Program link error: "+i.getProgramInfoLog(a));this.program=a,this.positionBuffer=i.createBuffer(),this.texCoordBuffer=i.createBuffer(),this.uResolutionLoc=i.getUniformLocation(a,"u_resolution"),this.uImgResolutionLoc=i.getUniformLocation(a,"u_imgResolution"),this.uAlphaLoc=i.getUniformLocation(a,"u_alpha"),this.aPositionLoc=i.getAttribLocation(a,"a_position"),this.aTexCoordLoc=i.getAttribLocation(a,"a_texCoord"),i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.clear(n.width,n.height)}clear(n,i){const o=this.gl;o.viewport(0,0,n,i),o.clearColor(.98,.97,.95,1),o.clear(o.COLOR_BUFFER_BIT)}createTexture(n){const i=this.gl,o=i.createTexture();return i.bindTexture(i.TEXTURE_2D,o),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,n),o}renderStripsWithTexture(n,i,o,s,a,l,d=1){if(l.length===0)return;const c=this.gl;c.viewport(0,0,i,o),c.useProgram(this.program),c.uniform2f(this.uResolutionLoc,i,o),c.uniform2f(this.uImgResolutionLoc,s,a),c.uniform1f(this.uAlphaLoc,d);const p=[],h=[],u=8;for(const m of l){const f=m.colOffsetX||0,x=m.colOffsetY||0,{srcQuad:v,dstRect:y}=m.strip,[S,b,w,j]=y,k=f+S,$=x+b,[C,_,E,z]=v;for(let T=0;T<u;T++){const B=T/u,W=(T+1)/u,N=$+j*B,A=$+j*W,F=[C[0]+(z[0]-C[0])*B,C[1]+(z[1]-C[1])*B],Y=[C[0]+(z[0]-C[0])*W,C[1]+(z[1]-C[1])*W],te=[_[0]+(E[0]-_[0])*B,_[1]+(E[1]-_[1])*B],se=[_[0]+(E[0]-_[0])*W,_[1]+(E[1]-_[1])*W],D=[k,N],V=[k+w,N],he=[k,A],Z=[k+w,A];p.push(D[0],D[1],V[0],V[1],he[0],he[1]),h.push(F[0],F[1],te[0],te[1],Y[0],Y[1]),p.push(V[0],V[1],Z[0],Z[1],he[0],he[1]),h.push(te[0],te[1],se[0],se[1],Y[0],Y[1])}}c.bindBuffer(c.ARRAY_BUFFER,this.positionBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(p),c.STATIC_DRAW),c.enableVertexAttribArray(this.aPositionLoc),c.vertexAttribPointer(this.aPositionLoc,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,this.texCoordBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(h),c.STATIC_DRAW),c.enableVertexAttribArray(this.aTexCoordLoc),c.vertexAttribPointer(this.aTexCoordLoc,2,c.FLOAT,!1,0,0),c.bindTexture(c.TEXTURE_2D,n),c.drawArrays(c.TRIANGLES,0,p.length/2)}deleteTexture(n){n&&this.gl.deleteTexture(n)}destroy(){const n=this.gl;n.deleteProgram(this.program),n.deleteBuffer(this.positionBuffer),n.deleteBuffer(this.texCoordBuffer)}}function of(e){const[n,i]=e.image_size||[0,0];if(!(n>0)||!(i>0)||e.columns.some(m=>{var f;return(((f=m.strips)==null?void 0:f.length)??0)>0}))return null;let o=1/0,s=1/0,a=-1/0,l=-1/0;for(const m of e.columns)for(const f of m.chars){const[x,v,y,S]=f.bbox_col;![x,v,y,S].every(Number.isFinite)||!(y>x)||!(S>v)||(o=Math.min(o,m.offset_x+x),s=Math.min(s,v),a=Math.max(a,m.offset_x+y),l=Math.max(l,S))}if(!(a>o)||!(l>s))return null;const d=Math.min(n,i)*.03,c=Math.min(n,Math.max(0,o-d)),p=Math.min(i,Math.max(0,s-d)),h=Math.min(n,Math.max(0,a+d))-c,u=Math.min(i,Math.max(0,l+d))-p;return!(h>0)||!(u>0)||h>=n*.98&&u>=i*.98?null:{x:c,y:p,w:h,h:u}}const Ft=new Map,sf=24;function Ar(e){let n=Ft.get(e);if(n)return Ft.delete(e),Ft.set(e,n),n;for(n=new Promise(i=>{const o=new Image;o.crossOrigin="anonymous",o.onload=()=>{(o.decode?o.decode().catch(()=>{}):Promise.resolve()).then(()=>i(o))},o.onerror=()=>{Ft.delete(e),i(null)},o.src=e}),Ft.set(e,n);Ft.size>sf;)Ft.delete(Ft.keys().next().value);return n}const Ro=({imageUrl:e,pageData:n,selectedCharIds:i,hoveredCharId:o,preserveMargins:s=!1,onCharClick:a,onCharHover:l})=>{const d=g.useRef(null),c=g.useRef(null),p=g.useRef(null),h=g.useRef(null),u=g.useRef(null),m=g.useRef(null),[f,x]=g.useState(0),[v,y]=g.useState(0),S=g.useRef(""),b=g.useMemo(()=>Math.max(...n.columns.map(N=>N.warped_h),2440),[n]),w=n.total_warped_w,j=n.banxin,k=g.useMemo(()=>{var D;if(!s)return{top:0,bottom:0,left:0,right:0};const[N,A]=n.image_size||[2386,3082];let F=1/0,Y=-1/0,te=1/0,se=-1/0;for(const V of n.columns)for(const he of V.strips||[])for(const Z of he.srcQuad)Z[0]<F&&(F=Z[0]),Z[0]>Y&&(Y=Z[0]),Z[1]<te&&(te=Z[1]),Z[1]>se&&(se=Z[1]);if((D=n.banxin)!=null&&D.current_page_strips)for(const V of n.banxin.current_page_strips)for(const he of V.srcQuad)he[0]<F&&(F=he[0]),he[0]>Y&&(Y=he[0]),he[1]<te&&(te=he[1]),he[1]>se&&(se=he[1]);return isFinite(F)||(F=0),isFinite(Y)||(Y=N),isFinite(te)||(te=0),isFinite(se)||(se=A),{top:Math.max(0,Math.round(te)),bottom:Math.max(0,Math.round(A-se)),left:Math.max(0,Math.round(F)),right:Math.max(0,Math.round(N-Y)),rawMinX:F,rawMaxX:Y,rawMinY:te,rawMaxY:se,imgW:N,imgH:A}},[n,s]),$=g.useMemo(()=>s?null:of(n),[n,s]),C=w+(j?j.total_w:0),_=$?$.w:C+k.left+k.right,E=$?$.h:b+k.top+k.bottom,z=g.useCallback(()=>{const N=c.current;if(!(!N||!d.current)&&!(e&&S.current!==e)){if(N.clear(_,E),s&&k.rawMinX!==void 0&&u.current&&p.current){const{rawMinX:A,rawMaxX:F,rawMinY:Y,rawMaxY:te,imgW:se,imgH:D,top:V,bottom:he,left:Z,right:M}=k,_e=[];Z>0&&_e.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[A,0],[A,D],[0,D]],dstRect:[0,0,Z,E]}}),V>0&&_e.push({colOffsetX:Z,colOffsetY:0,strip:{srcQuad:[[A,0],[F,0],[F,Y],[A,Y]],dstRect:[0,0,C,V]}}),he>0&&_e.push({colOffsetX:Z,colOffsetY:V+b,strip:{srcQuad:[[A,te],[F,te],[F,D],[A,D]],dstRect:[0,0,C,he]}}),M>0&&_e.push({colOffsetX:Z+C,colOffsetY:0,strip:{srcQuad:[[F,0],[se,0],[se,D],[F,D]],dstRect:[0,0,M,E]}}),N.renderStripsWithTexture(u.current,_,E,n.image_size[0],n.image_size[1],_e,1)}if(u.current&&p.current){const A=n.columns.flatMap(F=>(F.strips||[]).map(Y=>({colOffsetX:k.left+F.offset_x,colOffsetY:k.top,strip:Y})));if(A.length>0?N.renderStripsWithTexture(u.current,_,E,n.image_size[0],n.image_size[1],A,1):N.renderStripsWithTexture(u.current,_,E,n.image_size[0],n.image_size[1],[{colOffsetX:0,colOffsetY:0,strip:{srcQuad:$?[[$.x,$.y],[$.x+$.w,$.y],[$.x+$.w,$.y+$.h],[$.x,$.y+$.h]]:[[0,0],[n.image_size[0],0],[n.image_size[0],n.image_size[1]],[0,n.image_size[1]]],dstRect:[0,0,_,E]}}],1),j&&j.current_page_strips.length>0){const F=j.current_page_strips.map(Y=>({colOffsetX:k.left+w,colOffsetY:k.top,strip:Y}));N.renderStripsWithTexture(u.current,_,E,n.image_size[0],n.image_size[1],F,1)}}if(j&&m.current&&h.current&&j.mate_page_strips.length>0){const A=j.mate_page_strips.map(F=>({colOffsetX:k.left+w+j.half_w,colOffsetY:k.top,strip:F}));N.renderStripsWithTexture(m.current,_,E,j.mate_img_size[0],j.mate_img_size[1],A,.65)}}},[e,n,j,_,E,w,b,C,k,s,$]),T=g.useRef(z);T.current=z,g.useEffect(()=>{const N=d.current;if(!N)return;const A=te=>{u.current=p.current?te.createTexture(p.current):null,m.current=h.current?te.createTexture(h.current):null,T.current()};try{const te=new Lr(N);c.current=te,A(te)}catch(te){console.error("Failed to init WebGL renderer:",te)}const F=te=>{te.preventDefault(),console.warn("WebGL context lost")},Y=()=>{console.info("WebGL context restored, re-initializing..."),d.current&&(c.current=new Lr(d.current),A(c.current))};return N.addEventListener("webglcontextlost",F,!1),N.addEventListener("webglcontextrestored",Y,!1),()=>{N.removeEventListener("webglcontextlost",F),N.removeEventListener("webglcontextrestored",Y),c.current&&(c.current.deleteTexture(u.current),c.current.deleteTexture(m.current),c.current.destroy(),c.current=null)}},[]),g.useEffect(()=>{if(!e)return;let N=!0;return Ar(e).then(A=>{if(!N||!A)return;p.current=A,S.current=e;const F=c.current;F&&(F.deleteTexture(u.current),u.current=F.createTexture(A)),x(Y=>Y+1)}),()=>{N=!1}},[e]);const B=j==null?void 0:j.mate_image_url;g.useEffect(()=>{if(!B)return;let N=!0;return Ar(B).then(A=>{if(!N||!A)return;h.current=A;const F=c.current;F&&(F.deleteTexture(m.current),m.current=F.createTexture(A)),y(Y=>Y+1)}),()=>{N=!1}},[B]),g.useEffect(()=>{z()},[z,f,v]);const W=g.useMemo(()=>{const N=[];for(const A of n.columns)for(const F of A.chars){const[Y,te,se,D]=F.bbox_col;N.push({id:F.id,char:F.char,x:k.left+A.offset_x+Y-(($==null?void 0:$.x)??0),y:k.top+te-(($==null?void 0:$.y)??0),w:Math.max(se-Y,1),h:Math.max(D-te,1)})}return N},[n,k,$]);return t.jsxs("div",{className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${_} / ${E}`,backgroundColor:r("warp-bg"),boxShadow:r("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("canvas",{ref:d,width:_,height:E,style:{width:"100%",height:"100%",display:"block",backgroundColor:r("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${_} ${E}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[W.map(N=>{const A=i.has(N.id),F=o===N.id;return t.jsx("rect",{"data-selected":A?"true":void 0,x:N.x,y:N.y,width:N.w,height:N.h,fill:A?r("warp-sel-bg"):F?r("warp-hover-bg"):"transparent",stroke:A?r("warp-sel-stroke"):F?r("warp-hover-stroke"):"transparent",strokeWidth:A?3.5:F?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>a==null?void 0:a(N.id),onMouseEnter:()=>l==null?void 0:l(N.id),onMouseLeave:()=>l==null?void 0:l(null),children:t.jsx("title",{children:N.char})},N.id)}),j&&t.jsxs("g",{children:[t.jsx("line",{x1:k.left+w,y1:k.top,x2:k.left+w,y2:k.top+b,stroke:r("warp-banxin-border"),strokeWidth:1.5}),t.jsx("line",{x1:k.left+w+j.half_w,y1:k.top,x2:k.left+w+j.half_w,y2:k.top+b,stroke:r("warp-banxin-fold"),strokeWidth:1.5,strokeDasharray:"8 6"}),t.jsx("line",{x1:k.left+C,y1:k.top,x2:k.left+C,y2:k.top+b,stroke:r("warp-banxin-outer"),strokeWidth:1})]})]})]})},Eo=`
|
|
1301
1301
|
.bim-et-w { position: relative; display: inline; }
|
|
1302
1302
|
.bim-et {
|
|
1303
1303
|
color: inherit; text-decoration-line: underline;
|
|
@@ -1340,17 +1340,17 @@ a.bim-et:focus-visible { outline: 2px solid ${r("accent")}; outline-offset: 2px;
|
|
|
1340
1340
|
.bim-et-card { animation: bim-et-in 120ms ease-out; }
|
|
1341
1341
|
@keyframes bim-et-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
|
|
1342
1342
|
}
|
|
1343
|
-
`,sf=120;function mt(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function af(e,n=sf){if(!e)return;const i=e.replace(/\s+/g," ").trim(),o=Array.from(i);return o.length>n?o.slice(0,n).join("")+"…":i}function lf(e){const n=typeof e.birth_year=="number"?e.birth_year:void 0,i=typeof e.death_year=="number"?e.death_year:void 0;if(!(n===void 0&&i===void 0))return`${n??"?"}–${i??"?"}`}function cf(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(i=>{if(!i||typeof i!="object")return"";const o=i,s=mt(o.name);return s?[mt(o.dynasty)&&`〔${mt(o.dynasty)}〕`,s,mt(o.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function Wc(e,n){const i=mt(n.type),o=mt(n.primary_name)??mt(n.title)??e,s=i==="entity"?[mt(n.dynasty),lf(n),mt(n.native_place)].filter(Boolean).join(" · "):[cf(n),mt(n.edition),mt(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?mt(n.description.text):mt(n.description);return{id:e,type:i,title:o,meta:s||void 0,description:af(a)}}function Oc(e){const n=[e.dynasty,e.author,e.edition].filter(Boolean).join(" · ");return{id:e.id,type:e.type,title:e.title,meta:n||void 0}}function Fc(e){return async n=>{const i=await e.getItem(n);if(i)return Wc(n,i);if(e.getEntry){const o=await e.getEntry(n);if(o)return Oc(o)}return null}}const aa=new WeakMap;function df(e,n,i){let o=aa.get(e);o||(o=new Map,aa.set(e,o));const s=o.get(i);if(s)return s;const a=n(i);return o.set(i,a),a.catch(()=>o.delete(i)),a}const Hc=e=>`/item/${encodeURIComponent(e)}`,la={work:"書名",people:"人名",place:"地名",office:"官職",dynasty:"朝代",reign:"年號",other:"專名"},pf=typeof window>"u"?g.useEffect:g.useLayoutEffect;function Lo(e,n){return g.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:Fc(e)}:null,[n,e])}const uf=e=>e,mf=({text:e,entities:n,offsets:i="text",plainBase:o=0,transport:s,loadSummary:a,buildHref:l=Hc,onNavigate:d,renderText:c=uf,hoverDelayMs:p=250,closeDelayMs:h,injectStyles:u=!0,className:m})=>{const f=g.useMemo(()=>{const v=i==="plain"?Lc(e,n,o):n;return Ac(e,v)},[e,n,i,o]),x=Lo(s,a);return t.jsxs("span",{className:m?`bim-et-root ${m}`:"bim-et-root",children:[u&&t.jsx("style",{children:Eo}),f.map(v=>v.type==="text"?t.jsx(g.Fragment,{children:c(v.text)},`t${v.start}`):t.jsx(Ao,{span:v.span,label:v.text,hasBrackets:e[v.start-1]==="《"&&e[v.start+v.text.length]==="》",loader:x,buildHref:l,onNavigate:d,renderText:c,hoverDelayMs:p,closeDelayMs:h},`${v.span.key}@${v.start}`))]})};let Ht=null;const Ao=({span:e,label:n,hasBrackets:i,plain:o,loader:s,buildHref:a,onNavigate:l,renderText:d,hoverDelayMs:c,closeDelayMs:p=280})=>{const h=g.useId(),[u,m]=g.useState(!1),[f,x]=g.useState(!1),v=g.useRef(null),y=g.useRef(null),S=`bim-et bim-et-${e.kind}${o?" bim-et-nu":""}`,b=e.kind==="work"&&!i,w=t.jsxs(t.Fragment,{children:[b&&t.jsx("span",{className:"bim-et-sr",children:"《"}),d(n),b&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),j=()=>{v.current&&(clearTimeout(v.current),v.current=null)},k=()=>{y.current&&(clearTimeout(y.current),y.current=null)},$=g.useCallback(()=>{j(),k(),m(!1),x(!1),Ht===$&&(Ht=null)},[]);g.useEffect(()=>()=>{j(),k(),Ht===$&&(Ht=null)},[$]);const C=g.useCallback(()=>{Ht&&Ht!==$&&Ht(),Ht=$,m(!0)},[$]),_=g.useCallback(W=>{k(),x(!0),!u&&(j(),W<=0?C():v.current=setTimeout(C,W))},[u,C]),E=g.useCallback(()=>{j(),k(),y.current=setTimeout($,p)},[$,p]),z=!!e.targetId,T=e.targetId,B={className:"bim-et-w","data-active":f?"":void 0,onMouseEnter:()=>_(c),onMouseLeave:E,onBlur:W=>{W.currentTarget.contains(W.relatedTarget)||$()},onKeyDown:W=>{W.key==="Escape"&&u&&(W.stopPropagation(),$())}};return!z||!T?t.jsxs("span",{...B,children:[t.jsx("span",{className:S,children:w}),u&&t.jsx(ca,{id:h,entityId:null,span:e,loader:null,buildHref:a,onNavigate:l})]}):t.jsxs("span",{...B,children:[t.jsx("a",{className:S,href:a(T),"data-entity-id":T,"aria-describedby":u?h:void 0,onFocus:()=>_(0),onClick:l?W=>l(T,W):void 0,children:w}),u&&t.jsx(ca,{id:h,entityId:T,span:e,loader:s,buildHref:a,onNavigate:l})]})},ca=({id:e,entityId:n,span:i,loader:o,buildHref:s,onNavigate:a})=>{const{convert:l,t:d}=ne(),c=g.useRef(null),[p,h]=g.useState("start"),[u,m]=g.useState(o&&n?{status:"loading"}:{status:"ready",summary:null});g.useEffect(()=>{if(!o||!n)return;let v=!1;return m({status:"loading"}),df(o.owner,o.load,n).then(y=>{v||m({status:"ready",summary:y})}).catch(()=>{v||m({status:"error"})}),()=>{v=!0}},[o,n]),pf(()=>{const v=c.current;if(!v||typeof window>"u")return;const y=v.getBoundingClientRect(),S=document.documentElement.clientWidth||window.innerWidth;y.right>S-8&&p==="start"&&h("end")},[u,p]);const f=u.status==="ready"?u.summary:null,x=(f==null?void 0:f.title)??i.canonicalName??i.text;return n?t.jsxs("span",{ref:c,id:e,role:"tooltip",className:"bim-et-card","data-align":p,children:[t.jsx("span",{className:"bim-et-card-k",children:l(la[i.kind])}),x&&t.jsx("span",{className:"bim-et-card-t",children:l(x)}),(f==null?void 0:f.meta)&&t.jsx("span",{className:"bim-et-card-m",children:l(f.meta)}),(f==null?void 0:f.description)&&t.jsx("span",{className:"bim-et-card-d",children:l(f.description)}),u.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:l("載入中…")}),u.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:l("摘要載入失敗")}),t.jsx("a",{className:"bim-et-card-a",href:s(n),onClick:a?v=>a(n,v):void 0,children:d("reader.entityDetail")})]}):t.jsx("span",{ref:c,id:e,role:"tooltip",className:"bim-et-card","data-align":p,children:t.jsx("span",{className:"bim-et-card-k",children:l(la[i.kind])})})},hf=e=>`/item/${encodeURIComponent(e)}`;function gf(e){const n=e.filter(i=>i.kind!=="break");return{before:n.filter(i=>i.pos==="before"),after:n.filter(i=>i.pos!=="before")}}function ff(e,n){const i=[];for(const o of e){const s=n.get(o.charData.id)??null,a=i[i.length-1];a&&a.entity===s?a.chars.push(o):i.push({entity:s,chars:[o]})}return i}const Mo=({pageData:e,pages:n,punctuations:i=bf,selectedCharIds:o,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:h,convert:u,scrollToPage:m,entities:f,entityTransport:x,loadEntitySummary:v,buildEntityHref:y,onEntityNavigate:S,pageBreaks:b=!0,pageIndicatorY:w,onPageIndicatorYChange:j,quoteStyle:k,bookTitleStyle:$,showWorks:C})=>{const _=g.useRef(null),E=g.useRef(0),z=g.useMemo(()=>{const te=new Map;return p&&i.forEach((H,G)=>{const xe=H.id?H:{...H,id:`${H.anchor}#${G}`},K=te.get(xe.anchor)||[];K.push(xe),te.set(xe.anchor,K)}),te},[i,p]),T=g.useMemo(()=>k===void 0&&$===void 0&&C===void 0?null:{quoteStyle:k??"original",hideBookBrackets:$==="wavy"||C===!1},[k,$,C]),B=$==="bracket",W=g.useMemo(()=>{var xe;const H=(n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}]).filter(K=>K.columns.some(L=>L.chars.length>0)).map(K=>{const L=[...K.columns].sort((re,Ce)=>re.col-Ce.col),q=[];let ae=[],be=0;for(const re of L){if(re.chars.length===0){re.kind==="blank"&&be++;continue}const Ce=re.raised||re.lead_blank||be?{raised:re.raised,leadBlank:re.lead_blank,blankBefore:be}:void 0;be=0;let We=!0;for(const O of re.chars){const{before:ie,after:je}=gf(z.get(O.id)||[]),ke=(z.get(O.id)||[]).some(P=>P.kind==="break");ae.push({charData:O,col:re.col,beforePuncts:ie,afterPuncts:je,...We&&Ce?{start:Ce}:{}}),We=!1,ke&&(q.push({id:`para-p${K.page}-${q.length}`,chars:ae}),ae=[])}}const X=ae.length>0;return X&&q.push({id:`para-p${K.page}-${q.length}`,chars:ae}),{page:K.page,paragraphs:q,endsOpen:X,...K.label?{label:K.label}:{},...be>0?{trailingBlank:be}:{}}}),G=new Map;if(!b){let K=null;for(const L of H){const q=L.paragraphs[0],ae=(xe=q==null?void 0:q.chars[0])==null?void 0:xe.start,be=!!ae&&!!(ae.raised||ae.leadBlank||ae.blankBefore),X=L.paragraphs.length===1&&!!L.trailingBlank;if(K&&q&&!be&&!X){for(const re of q.chars)G.set(re.charData.id,K.owner);K.para.chars=K.para.chars.concat(q.chars),L.leadFirstId=q.chars[0].charData.id,L.paragraphs=L.paragraphs.slice(1)}if(L.endsOpen&&!L.trailingBlank){const re=L.paragraphs[L.paragraphs.length-1];re&&(K={para:re,owner:L.page})}else K=null}}return{pages:H,mergedOwner:G}},[n,e,z,b]),N=W.pages,A=g.useMemo(()=>{const te=[];for(const H of N)for(const G of H.paragraphs)for(const xe of G.chars)te.push(xe.charData.id);return te},[N]),F=g.useMemo(()=>{const te=new Map;if(!f||f.length===0)return te;const H=new Map(A.map((G,xe)=>[G,xe]));for(const G of f){if(!G.anchor)continue;const xe=H.get(G.anchor.start),K=H.get(G.anchor.end);if(!(xe===void 0||K===void 0||K<xe))for(let L=xe;L<=K;L++)te.has(A[L])||te.set(A[L],G)}return te},[f,A]),Y=Lo(x,v),ee=F.size>0,se=g.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:S});se.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:S};const D=g.useMemo(()=>({click:te=>{var H,G;E.current=Date.now()+1200,(G=(H=se.current).onCharClick)==null||G.call(H,te)},enter:te=>{var H,G;return(G=(H=se.current).onCharHover)==null?void 0:G.call(H,te)},leave:()=>{var te,H;return(H=(te=se.current).onCharHover)==null?void 0:H.call(te,null)},navigate:(te,H)=>{var xe,K;if(!(H.detail===0||H.ctrlKey||H.metaKey||H.shiftKey)){H.preventDefault();return}(K=(xe=se.current).onEntityNavigate)==null||K.call(xe,te,H)}}),[]),V=yf(o,W.mergedOwner),he=g.useRef(null);g.useEffect(()=>{var H,G;if((H=he.current)==null||H.classList.remove("is-hovered"),he.current=null,!s)return;const te=(G=_.current)==null?void 0:G.querySelector(`span[data-char-id="${s}"]`);te&&(te.classList.add("is-hovered"),he.current=te)},[s]),g.useEffect(()=>{let te=null;const H=()=>{var je,ke;te=null;const xe=window.getSelection(),K=_.current;if(!xe||xe.isCollapsed||xe.rangeCount===0||!K)return;const L=xe.getRangeAt(0),q=L.commonAncestorContainer,ae=q.nodeType===3?q.parentElement:q;if(!ae||!K.contains(ae))return;const be=K.querySelectorAll("span[data-char-id]"),X=P=>P.firstChild??P;let re=0,Ce=be.length;for(;re<Ce;){const P=re+Ce>>1;L.comparePoint(X(be[P]),0)<0?re=P+1:Ce=P}const We=re;for(Ce=be.length;re<Ce;){const P=re+Ce>>1;L.comparePoint(X(be[P]),0)<=0?re=P+1:Ce=P}let O=re-1;if(O>=We&&L.endOffset===0&&L.endContainer===X(be[O])&&O--,O<We)return;const ie=[];for(let P=We;P<=O;P++)ie.push(be[P].getAttribute("data-char-id"));ie.length>0&&(E.current=Date.now()+1200,(ke=(je=se.current).onSelectionChange)==null||ke.call(je,ie))},G=()=>{te&&clearTimeout(te),te=setTimeout(H,120)};return document.addEventListener("selectionchange",G),()=>{document.removeEventListener("selectionchange",G),te&&clearTimeout(te)}},[]),g.useEffect(()=>{var te;if(o.size===1){const H=Array.from(o)[0],G=(te=_.current)==null?void 0:te.querySelector(`span[data-char-id="${H}"]`);G&&G.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[o]);const Z=te=>{var xe;const H=_.current;if(!H)return null;const G=(xe=N.find(K=>K.page===te))==null?void 0:xe.leadFirstId;return G?H.querySelector(`span[data-char-id="${G}"]`):H.querySelector(`[data-page-section="${te}"]`)},M=m==null?void 0:m.nonce;g.useEffect(()=>{if(!m)return;const te=Z(m.page);te&&(E.current=Date.now()+800,te.scrollIntoView({behavior:"auto",block:"start"}))},[M]);const _e=!!h,ce=_e&&typeof w=="number",[ge,le]=g.useState(null),Be=Mr(ge??w??0),ze=g.useRef(null);ze.current=ce?Be:null;const Fe=g.useRef(()=>{});return g.useEffect(()=>{if(!_e)return;const te=[],H=[];for(const L of N){const q=Z(L.page);q&&(te.push(q),H.push(L.page))}if(te.length===0)return;let G=0;const xe=()=>{var be,X;if(G=0,Date.now()<E.current)return;const L=ze.current===null?120:ze.current*window.innerHeight;let q=0,ae=te.length-1;for(;q<ae;){const re=q+ae+1>>1;te[re].getBoundingClientRect().top<=L?q=re:ae=re-1}(X=(be=se.current).onVisiblePageChange)==null||X.call(be,H[q])},K=()=>{G||(G=requestAnimationFrame(xe))};return Fe.current=()=>{G||(G=requestAnimationFrame(xe))},window.addEventListener("scroll",K,{passive:!0}),xe(),()=>{window.removeEventListener("scroll",K),G&&cancelAnimationFrame(G),Fe.current=()=>{}}},[_e,N]),g.useEffect(()=>{ce&&Fe.current()},[ce,Be]),t.jsxs("div",{ref:_,className:"guji-text-pane-content",children:[ee&&t.jsx("style",{children:Eo}),ce&&t.jsx(wf,{y:Be,containerRef:_,onDrag:le,onCommit:te=>{le(null),j==null||j(te)}}),t.jsx("div",{className:"guji-text-reflow-view",children:N.map((te,H)=>t.jsx(vf,{pGroup:te,first:H===0,pageBreaks:b,markOpts:T,plainBooks:B,selected:V.get(te.page)??xf,entityOfChar:F,entityLoader:Y,convert:u,buildHref:y??hf,handlers:D},`page-sec-${te.page}`))})]})},xf=new Set,bf=[];function yf(e,n){const i=g.useRef(new Map);return g.useMemo(()=>{const o=new Map;e.forEach(a=>{const l=n.get(a)??parseInt(a.split(":")[0],10);let d=o.get(l);d||o.set(l,d=new Set),d.add(a)});const s=new Map;return o.forEach((a,l)=>{const d=i.current.get(l),c=d&&d.size===a.size&&Array.from(a).every(p=>d.has(p));s.set(l,c?d:a)}),i.current=s,s},[e,n])}function da({n:e}){return t.jsx(t.Fragment,{children:Array.from({length:e},(n,i)=>t.jsx("span",{className:"guji-text-blank-col","aria-hidden":"true","data-blank-col":""},i))})}function jf(e,n){const i=Array.from(n(e.join("")));return i.length===e.length&&e.every(o=>Array.from(o).length===1)?i:e.map(o=>n(o))}const vf=g.memo(function({pGroup:n,first:i,pageBreaks:o,markOpts:s,plainBooks:a,selected:l,entityOfChar:d,entityLoader:c,convert:p,buildHref:h,handlers:u}){const m=g.useMemo(()=>{const y=new Map;if(!p)return y;for(const S of n.paragraphs){const b=jf(S.chars.map(w=>w.charData.char),p);S.chars.forEach((w,j)=>y.set(w.charData.id,b[j]))}return y},[n,p]),f=y=>m.get(y.id)??y.char,{t:x}=ne(),v=y=>{const S=s?zc(y.mark,s):y.mark;return S?t.jsx("span",{className:"guji-text-punct","data-punct-id":y.id,children:S},y.id):null};return t.jsxs("section",{"data-page-section":n.page,className:"guji-page-section",style:{position:"relative",scrollMarginTop:96},children:[!i&&o&&t.jsxs("div",{className:"guji-page-divider",style:{display:"flex",alignItems:"center",margin:"2rem 0 1.2rem",color:r("meta-fg"),fontSize:"0.82rem",letterSpacing:"0.08em",userSelect:"none"},children:[t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}}),t.jsxs("span",{style:{padding:"0 12px",fontWeight:500},"data-page-label":n.label,title:n.label?`${n.page}`:void 0,children:["第 ",n.label??n.page," 葉"]}),t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}})]}),n.paragraphs.map((y,S)=>t.jsxs("p",{className:"guji-reflow-paragraph",children:[ff(y.chars,d).map((b,w)=>{const j=b.chars.map(({charData:C,beforePuncts:_,afterPuncts:E,start:z},T)=>{const B=!!b.entity&&T===0,W=!!b.entity&&T===b.chars.length-1,N=B?[]:_,A=W?[]:E;return t.jsxs(g.Fragment,{children:[z&&z.blankBefore>0&&t.jsx(da,{n:z.blankBefore}),N.map(v),t.jsx("span",{"data-char-id":C.id,onClick:()=>u.click(C.id),onMouseEnter:()=>u.enter(C.id),onMouseLeave:u.leave,className:`guji-text-char${l.has(C.id)?" is-selected":""}${C.sub?" is-sub":""}${C.lane==="solo"?" is-solo":""}${C.lacuna?" is-lacuna":""}${C.guess?" is-guess":""}${C.zi?" is-zi":""}${z!=null&&z.raised?" is-raised":""}`,"data-raised":(z==null?void 0:z.raised)||void 0,title:C.lacuna?x("detail.lacuna"):C.zi?x("detail.composedChar",{label:C.zi}):C.guess?x("reader.charGuess"):void 0,children:f(C)}),A.map(v)]},C.id)});if(!b.entity)return t.jsx(g.Fragment,{children:j},`r${w}`);const k=b.chars[0].beforePuncts.map(v),$=b.chars[b.chars.length-1].afterPuncts.map(v);return t.jsxs(g.Fragment,{children:[k,t.jsx(Ao,{span:b.entity,label:b.chars.map(C=>f(C.charData)).join(""),hasBrackets:!0,plain:a&&b.entity.kind==="work",loader:c,buildHref:h,onNavigate:u.navigate,renderText:()=>j,hoverDelayMs:250}),$]},`${b.entity.key}@${w}`)}),S===n.paragraphs.length-1&&n.trailingBlank?t.jsx(da,{n:n.trailingBlank}):null]},y.id))]})});function Mr(e){const[n,i]=Pn,o=Number.isFinite(e)?e:.33;return Math.round(Math.min(i,Math.max(n,o))*1e3)/1e3}const kf=.02,si=16;function wf({y:e,containerRef:n,onDrag:i,onCommit:o}){const{t:s}=ne(),[a,l]=g.useState(0),d=g.useRef(!1),c=g.useRef(e);c.current=e;const p=g.useCallback(()=>{var f,x;const m=(x=((f=n.current)==null?void 0:f.querySelector(".guji-text-reflow-view"))??n.current)==null?void 0:x.getBoundingClientRect();l(Math.max(0,((m==null?void 0:m.left)??0)-si-2))},[n]);g.useLayoutEffect(()=>(p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)),[p]);const h=u=>Mr(u/Math.max(1,window.innerHeight));return t.jsx("div",{role:"slider",tabIndex:0,className:"guji-page-indicator","aria-label":s("reader.pageIndicator"),"aria-orientation":"vertical","aria-valuemin":Math.round(Pn[0]*100),"aria-valuemax":Math.round(Pn[1]*100),"aria-valuenow":Math.round(e*100),"data-indicator-y":e,style:{position:"fixed",left:a,top:`calc(${e*100}vh - ${si/2}px)`,width:si,height:si,zIndex:20,cursor:"ns-resize",touchAction:"none",background:r("accent"),clipPath:"polygon(0 0, 100% 50%, 0 100%)",outline:"none"},onPointerDown:u=>{d.current=!0;try{u.currentTarget.setPointerCapture(u.pointerId)}catch{}u.preventDefault()},onPointerMove:u=>{if(!d.current)return;const m=h(u.clientY);c.current=m,i(m)},onPointerUp:u=>{if(d.current){d.current=!1;try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}o(h(u.clientY))}},onPointerCancel:()=>{d.current&&(d.current=!1,o(c.current))},onKeyDown:u=>{const m=u.key==="ArrowUp"?-1:u.key==="ArrowDown"?1:0;m&&(u.preventDefault(),o(Mr(e+m*(u.shiftKey?5:1)*kf)))}})}const Dc=1,Uc=6,ai={s:1,x:0,y:0},ui=(e,n,i)=>Math.min(i,Math.max(n,e));function Po(e,n,i){const o=ui(e.s,Dc,Uc);return{s:o,x:ui(e.x,n*(1-o),0),y:ui(e.y,i*(1-o),0)}}function dr(e,n,i,o,s,a){const l=ui(e.s*o,Dc,Uc),d=l/e.s;return Po({s:l,x:n-(n-e.x)*d,y:i-(i-e.y)*d},s,a)}function Sf(e,n,i,o,s){return Po({s:e.s,x:e.x+n,y:e.y+i},o,s)}function _f(e,n,i){const o=n===1?e*16:n===2?e*400:e;return Math.exp(-o*(i?.01:.0015))}const pa=4,$f=g.forwardRef(function({children:n,onScaleChange:i,resetKey:o,style:s},a){const l=g.useRef(null),[d,c]=g.useState(ai),p=g.useRef(d),h=g.useRef(i);h.current=i;const u=b=>{var j;const w=p.current;p.current=b,c(b),b.s!==w.s&&((j=h.current)==null||j.call(h,b.s))},m=()=>{var w;const b=(w=l.current)==null?void 0:w.getBoundingClientRect();return{w:(b==null?void 0:b.width)??0,h:(b==null?void 0:b.height)??0,left:(b==null?void 0:b.left)??0,top:(b==null?void 0:b.top)??0}};g.useImperativeHandle(a,()=>({zoomBy(b){const{w,h:j}=m();u(dr(p.current,w/2,j/2,b,w,j))},reset(){u(ai)}})),g.useEffect(()=>{u(ai)},[o]),g.useEffect(()=>{const b=l.current;if(!b||typeof ResizeObserver>"u")return;const w=new ResizeObserver(()=>{const{w:j,h:k}=m(),$=Po(p.current,j,k);($.x!==p.current.x||$.y!==p.current.y)&&u($)});return w.observe(b),()=>w.disconnect()},[]),g.useEffect(()=>{const b=l.current;if(!b)return;const w=j=>{const k=_f(j.deltaY,j.deltaMode,j.ctrlKey);if(p.current.s<=1&&k<1)return;j.preventDefault();const{w:$,h:C,left:_,top:E}=m();u(dr(p.current,j.clientX-_,j.clientY-E,k,$,C))};return b.addEventListener("wheel",w,{passive:!1}),()=>b.removeEventListener("wheel",w)},[]);const f=g.useRef(new Map),x=g.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),v=b=>{if(b.pointerType==="mouse"&&b.button!==0)return;f.current.set(b.pointerId,{x:b.clientX,y:b.clientY});const w=x.current;if(w.swallowClick=!1,f.current.size===1&&(w.moved=0,w.dragging=!1),f.current.size===2){const[j,k]=[...f.current.values()];w.pinchDist=Math.hypot(j.x-k.x,j.y-k.y),w.moved=pa+1}},y=b=>{var B;const w=f.current.get(b.pointerId);if(!w)return;const j={x:b.clientX,y:b.clientY};f.current.set(b.pointerId,j);const k=x.current,{w:$,h:C,left:_,top:E}=m();if(f.current.size>=2){const[W,N]=[...f.current.values()],A=Math.hypot(W.x-N.x,W.y-N.y);if(k.pinchDist>0&&A>0){const F=(W.x+N.x)/2-_,Y=(W.y+N.y)/2-E;u(dr(p.current,F,Y,A/k.pinchDist,$,C))}k.pinchDist=A,k.swallowClick=!0;return}const z=j.x-w.x,T=j.y-w.y;if(k.moved+=Math.abs(z)+Math.abs(T),!(k.moved<=pa)){if(!k.dragging){k.dragging=!0;try{(B=l.current)==null||B.setPointerCapture(b.pointerId)}catch{}}k.swallowClick=!0,p.current.s>1&&u(Sf(p.current,z,T,$,C))}},S=b=>{f.current.delete(b.pointerId);const w=x.current;w.pinchDist=0,f.current.size===0&&(w.dragging=!1)};return t.jsx("div",{ref:l,className:"bim-zp","data-zoom":d.s.toFixed(2),onPointerDown:v,onPointerMove:y,onPointerUp:S,onPointerCancel:S,onClickCapture:b=>{x.current.swallowClick&&(x.current.swallowClick=!1,b.stopPropagation(),b.preventDefault())},onDoubleClick:()=>u(ai),style:{position:"relative",overflow:"hidden",touchAction:"none",cursor:d.s>1?"grab":void 0,...s},children:t.jsx("div",{className:"bim-zp-inner",style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transformOrigin:"0 0",transform:`translate(${d.x}px, ${d.y}px) scale(${d.s})`,willChange:d.s>1?"transform":void 0},children:n})})});function Vc(e,n,i,o){const[s,a]=g.useState(n??null),[l,d]=g.useState(!1),c=g.useRef(0);return g.useEffect(()=>{if(n!==void 0){a(n);return}const p=++c.current;if(!i){a(null),d(!1);return}if(e){let h;try{h=e(i,o)}catch{a(null),d(!1);return}if(!h||typeof h.then!="function"){a(h??null),d(!1);return}d(!0),h.then(u=>{p===c.current&&a(u??null)}).catch(()=>{p===c.current&&a(null)}).finally(()=>{p===c.current&&d(!1)});return}a(null),d(!1)},[e,n,i,o]),{warpData:s,loading:l}}function Cf(e,n,i){const[o,s]=g.useState([]),a=g.useRef(0);return g.useEffect(()=>{const l=++a.current;if(!e||!n){s([]);return}let d;try{d=e(n,i)}catch{s([]);return}Promise.resolve(d).then(c=>{l===a.current&&s(c?Ec(c):[])}).catch(()=>{l===a.current&&s([])})},[e,n,i]),o}const ua={padding:24,color:r("desc-fg"),fontSize:14};function ma({title:e,label:n,className:i,style:o}){const s=(a,l=14,d=14)=>({width:a,height:l,marginTop:d,borderRadius:3,background:r("rule")});return t.jsxs("div",{className:i,style:{...o,padding:"20px 24px",maxWidth:760,margin:"0 auto"},"aria-busy":"true",children:[e&&t.jsx("div",{style:{fontSize:15,color:r("ink"),fontFamily:r("font-ui")},children:e}),t.jsx("div",{style:s("42%",24,28)}),t.jsx("div",{style:s("30%",12,10)}),["96%","100%","92%","98%","64%"].map((a,l)=>t.jsx("div",{style:s(a,16,l===0?30:14)},l)),t.jsx("p",{role:"status",style:{marginTop:24,color:r("desc-fg"),fontSize:14,fontFamily:r("font-ui")},children:n})]})}const ha=/^https?:\/\//i;function Tf(e){if(!e||typeof e!="object")return null;const n=a=>typeof a=="string"&&a.trim()?a.trim():void 0,i=n(e.url),o=n(e.license_url),s={name:n(e.name),url:i&&ha.test(i)?i:void 0,license:n(e.license),license_url:o&&ha.test(o)?o:void 0,note:n(e.note)};return s.name||s.license||s.note?s:null}function zf(e,n){return{work_id:n.work_id??e,title:n.title,type:n.type,juan_files:n.chapters.map(i=>i.file),juan_metadata:n.juan_metadata,juan_groups:n.juan_groups,references:n.references,target_source:n.target_source,target_source_id:n.target_source_id,text_source:n.text_source,text_quality:n.text_quality}}function Nf(e,n){return(n==null?void 0:n.type)==="kaozhen"?"章":n!=null&&n.juan_metadata&&Object.values(n.juan_metadata).some(i=>i.vol_label)?"冊":Se.isCollatedKind(e==null?void 0:e.kind)?"卷":"章"}function Gc(e,n,i,o=!1){const s=i(`${n}${e.n}`);if(!e.title)return s;const a=i(e.title);return o&&!/^[卷冊册章篇回第]/.test(e.title)?`${s} ${a}`:a}function If(e,n,i,o,s){var p;const a=new Map(e.chapters.map(h=>[h.file,h])),l=h=>h==="loading"?"…":typeof h=="number"&&h>0?h:void 0,d=(h,u)=>{const m=a.get(h);return{key:h,label:u??(m?Gc(m,i,o,s):h),hint:l(n[h]),disabled:n[h]===0}},c=(p=e.juan_groups)==null?void 0:p.filter(h=>{var u;return h.files.some(m=>a.has(m))||((u=h.children)==null?void 0:u.length)});if(c&&c.length>0){const h=(u,m)=>{var x;if(u.files.length===1&&!((x=u.children)!=null&&x.length))return d(u.files[0],o(u.label));const f=Og(u,n);return{key:`group:${m}`,label:o(u.label),hint:f==="loading"?"…":typeof f=="number"&&f>0?`${f}`:Pc(u),defaultExpanded:typeof f=="number"&&f>0,children:[...u.files.filter(v=>a.has(v)).map(v=>d(v)),...(u.children??[]).map((v,y)=>h(v,`${m}.${y}`))]}};return c.map((u,m)=>h(u,`${m}`))}return e.chapters.map(h=>d(h.file))}const Bo=e=>{const n=Hl();return t.jsx(bu,{mode:n[0].scriptMode,children:t.jsx(Rf,{...e,prefsState:n})})},Rf=({prefsState:e,id:n,transport:i,versionKey:o,chapter:s,onLocationChange:a,onNavigate:l,title:d,subtitle:c,resolveImages:p,renderImageOverlay:h,imagePanel:u,allowVertical:m,onReportError:f,revisedAt:x,backHref:v,backLabel:y,resolveWarpData:S,warpData:b,resolveEntities:w,onEntityNavigate:j,className:k,style:$})=>{var ls,cs,ds;const{t:C,convert:_}=ne(),E=g.useMemo(()=>Rl(i),[i]),[z,T]=e,B=tt(),W=g.useRef(a);W.current=a;const[N,A]=g.useState(null),[F,Y]=g.useState("loading");g.useEffect(()=>{let R=!1;return A(null),Y("loading"),E.getManifest(n).then(de=>{R||(de?(A(de),Y("ready")):Y("missing"))}).catch(()=>{R||Y("missing")}),()=>{R=!0}},[E,n]);const ee=o!==void 0,se=s!==void 0,[D,V]=g.useState(null),[he,Z]=g.useState(null);g.useEffect(()=>{V(null),Z(null)},[n]);const M=Se.pickTextVersion(N,ee?o:D),_e=((ls=N==null?void 0:N.versions.find(R=>R.key==="default"))==null?void 0:ls.key)??((cs=N==null?void 0:N.versions[0])==null?void 0:cs.key)??"default",ce=(M==null?void 0:M.key)??null,ge=se?s:he,le=g.useCallback((R,de,Ne)=>{var Ue;(Ue=W.current)==null||Ue.call(W,{key:R,chapter:de,isDefault:R===_e},Ne)},[_e]);g.useEffect(()=>{!N||!ee||o==null||N.versions.some(R=>R.key===o)||le(_e,null,"auto")},[N,ee,o,_e,le]);const Be=g.useRef(new Map);g.useEffect(()=>{Be.current.clear()},[E,n]);const ze=g.useCallback(async R=>{const de=`${n}
|
|
1344
|
-
${R}`;if(Be.current.has(de))return Be.current.get(de)??null;const Ne=await E.getIndex(n,R).catch(()=>null);return Ne&&Be.current.set(de,Ne),Ne},[E,n]),[Fe,
|
|
1343
|
+
`,af=120;function mt(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function lf(e,n=af){if(!e)return;const i=e.replace(/\s+/g," ").trim(),o=Array.from(i);return o.length>n?o.slice(0,n).join("")+"…":i}function cf(e){const n=typeof e.birth_year=="number"?e.birth_year:void 0,i=typeof e.death_year=="number"?e.death_year:void 0;if(!(n===void 0&&i===void 0))return`${n??"?"}–${i??"?"}`}function df(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(i=>{if(!i||typeof i!="object")return"";const o=i,s=mt(o.name);return s?[mt(o.dynasty)&&`〔${mt(o.dynasty)}〕`,s,mt(o.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function Oc(e,n){const i=mt(n.type),o=mt(n.primary_name)??mt(n.title)??e,s=i==="entity"?[mt(n.dynasty),cf(n),mt(n.native_place)].filter(Boolean).join(" · "):[df(n),mt(n.edition),mt(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?mt(n.description.text):mt(n.description);return{id:e,type:i,title:o,meta:s||void 0,description:lf(a)}}function Fc(e){const n=[e.dynasty,e.author,e.edition].filter(Boolean).join(" · ");return{id:e.id,type:e.type,title:e.title,meta:n||void 0}}function Hc(e){return async n=>{const i=await e.getItem(n);if(i)return Oc(n,i);if(e.getEntry){const o=await e.getEntry(n);if(o)return Fc(o)}return null}}const la=new WeakMap;function pf(e,n,i){let o=la.get(e);o||(o=new Map,la.set(e,o));const s=o.get(i);if(s)return s;const a=n(i);return o.set(i,a),a.catch(()=>o.delete(i)),a}const Dc=e=>`/item/${encodeURIComponent(e)}`,ca={work:"書名",people:"人名",place:"地名",office:"官職",dynasty:"朝代",reign:"年號",other:"專名"},uf=typeof window>"u"?g.useEffect:g.useLayoutEffect;function Lo(e,n){return g.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:Hc(e)}:null,[n,e])}const mf=e=>e,hf=({text:e,entities:n,offsets:i="text",plainBase:o=0,transport:s,loadSummary:a,buildHref:l=Dc,onNavigate:d,renderText:c=mf,hoverDelayMs:p=250,closeDelayMs:h,injectStyles:u=!0,className:m})=>{const f=g.useMemo(()=>{const v=i==="plain"?Ac(e,n,o):n;return Mc(e,v)},[e,n,i,o]),x=Lo(s,a);return t.jsxs("span",{className:m?`bim-et-root ${m}`:"bim-et-root",children:[u&&t.jsx("style",{children:Eo}),f.map(v=>v.type==="text"?t.jsx(g.Fragment,{children:c(v.text)},`t${v.start}`):t.jsx(Ao,{span:v.span,label:v.text,hasBrackets:e[v.start-1]==="《"&&e[v.start+v.text.length]==="》",loader:x,buildHref:l,onNavigate:d,renderText:c,hoverDelayMs:p,closeDelayMs:h},`${v.span.key}@${v.start}`))]})};let Ht=null;const Ao=({span:e,label:n,hasBrackets:i,plain:o,loader:s,buildHref:a,onNavigate:l,renderText:d,hoverDelayMs:c,closeDelayMs:p=280})=>{const h=g.useId(),[u,m]=g.useState(!1),[f,x]=g.useState(!1),v=g.useRef(null),y=g.useRef(null),S=`bim-et bim-et-${e.kind}${o?" bim-et-nu":""}`,b=e.kind==="work"&&!i,w=t.jsxs(t.Fragment,{children:[b&&t.jsx("span",{className:"bim-et-sr",children:"《"}),d(n),b&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),j=()=>{v.current&&(clearTimeout(v.current),v.current=null)},k=()=>{y.current&&(clearTimeout(y.current),y.current=null)},$=g.useCallback(()=>{j(),k(),m(!1),x(!1),Ht===$&&(Ht=null)},[]);g.useEffect(()=>()=>{j(),k(),Ht===$&&(Ht=null)},[$]);const C=g.useCallback(()=>{Ht&&Ht!==$&&Ht(),Ht=$,m(!0)},[$]),_=g.useCallback(W=>{k(),x(!0),!u&&(j(),W<=0?C():v.current=setTimeout(C,W))},[u,C]),E=g.useCallback(()=>{j(),k(),y.current=setTimeout($,p)},[$,p]),z=!!e.targetId,T=e.targetId,B={className:"bim-et-w","data-active":f?"":void 0,onMouseEnter:()=>_(c),onMouseLeave:E,onBlur:W=>{W.currentTarget.contains(W.relatedTarget)||$()},onKeyDown:W=>{W.key==="Escape"&&u&&(W.stopPropagation(),$())}};return!z||!T?t.jsxs("span",{...B,children:[t.jsx("span",{className:S,children:w}),u&&t.jsx(da,{id:h,entityId:null,span:e,loader:null,buildHref:a,onNavigate:l})]}):t.jsxs("span",{...B,children:[t.jsx("a",{className:S,href:a(T),"data-entity-id":T,"aria-describedby":u?h:void 0,onFocus:()=>_(0),onClick:l?W=>l(T,W):void 0,children:w}),u&&t.jsx(da,{id:h,entityId:T,span:e,loader:s,buildHref:a,onNavigate:l})]})},da=({id:e,entityId:n,span:i,loader:o,buildHref:s,onNavigate:a})=>{const{convert:l,t:d}=ne(),c=g.useRef(null),[p,h]=g.useState("start"),[u,m]=g.useState(o&&n?{status:"loading"}:{status:"ready",summary:null});g.useEffect(()=>{if(!o||!n)return;let v=!1;return m({status:"loading"}),pf(o.owner,o.load,n).then(y=>{v||m({status:"ready",summary:y})}).catch(()=>{v||m({status:"error"})}),()=>{v=!0}},[o,n]),uf(()=>{const v=c.current;if(!v||typeof window>"u")return;const y=v.getBoundingClientRect(),S=document.documentElement.clientWidth||window.innerWidth;y.right>S-8&&p==="start"&&h("end")},[u,p]);const f=u.status==="ready"?u.summary:null,x=(f==null?void 0:f.title)??i.canonicalName??i.text;return n?t.jsxs("span",{ref:c,id:e,role:"tooltip",className:"bim-et-card","data-align":p,children:[t.jsx("span",{className:"bim-et-card-k",children:l(ca[i.kind])}),x&&t.jsx("span",{className:"bim-et-card-t",children:l(x)}),(f==null?void 0:f.meta)&&t.jsx("span",{className:"bim-et-card-m",children:l(f.meta)}),(f==null?void 0:f.description)&&t.jsx("span",{className:"bim-et-card-d",children:l(f.description)}),u.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:l("載入中…")}),u.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:l("摘要載入失敗")}),t.jsx("a",{className:"bim-et-card-a",href:s(n),onClick:a?v=>a(n,v):void 0,children:d("reader.entityDetail")})]}):t.jsx("span",{ref:c,id:e,role:"tooltip",className:"bim-et-card","data-align":p,children:t.jsx("span",{className:"bim-et-card-k",children:l(ca[i.kind])})})},gf=e=>`/item/${encodeURIComponent(e)}`;function ff(e){const n=e.filter(i=>i.kind!=="break");return{before:n.filter(i=>i.pos==="before"),after:n.filter(i=>i.pos!=="before")}}function xf(e,n){const i=[];for(const o of e){const s=n.get(o.charData.id)??null,a=i[i.length-1];a&&a.entity===s?a.chars.push(o):i.push({entity:s,chars:[o]})}return i}const Mo=({pageData:e,pages:n,punctuations:i=yf,selectedCharIds:o,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:h,convert:u,scrollToPage:m,entities:f,entityTransport:x,loadEntitySummary:v,buildEntityHref:y,onEntityNavigate:S,pageBreaks:b=!0,pageIndicatorY:w,onPageIndicatorYChange:j,quoteStyle:k,bookTitleStyle:$,showWorks:C})=>{const _=g.useRef(null),E=g.useRef(0),z=g.useMemo(()=>{const Q=new Map;return p&&i.forEach((H,G)=>{const xe=H.id?H:{...H,id:`${H.anchor}#${G}`},K=Q.get(xe.anchor)||[];K.push(xe),Q.set(xe.anchor,K)}),Q},[i,p]),T=g.useMemo(()=>k===void 0&&$===void 0&&C===void 0?null:{quoteStyle:k??"original",hideBookBrackets:$==="wavy"||C===!1},[k,$,C]),B=$==="bracket",W=g.useMemo(()=>{var xe;const H=(n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}]).filter(K=>K.columns.some(L=>L.chars.length>0)).map(K=>{const L=[...K.columns].sort((re,Ce)=>re.col-Ce.col),q=[];let ae=[],be=0;for(const re of L){if(re.chars.length===0){re.kind==="blank"&&be++;continue}const Ce=re.raised||re.lead_blank||be?{raised:re.raised,leadBlank:re.lead_blank,blankBefore:be}:void 0;be=0;let We=!0;for(const O of re.chars){const{before:ie,after:je}=ff(z.get(O.id)||[]),ke=(z.get(O.id)||[]).some(P=>P.kind==="break");ae.push({charData:O,col:re.col,beforePuncts:ie,afterPuncts:je,...We&&Ce?{start:Ce}:{}}),We=!1,ke&&(q.push({id:`para-p${K.page}-${q.length}`,chars:ae}),ae=[])}}const X=ae.length>0;return X&&q.push({id:`para-p${K.page}-${q.length}`,chars:ae}),{page:K.page,paragraphs:q,endsOpen:X,...K.label?{label:K.label}:{},...be>0?{trailingBlank:be}:{}}}),G=new Map;if(!b){let K=null;for(const L of H){const q=L.paragraphs[0],ae=(xe=q==null?void 0:q.chars[0])==null?void 0:xe.start,be=!!ae&&!!(ae.raised||ae.leadBlank||ae.blankBefore),X=L.paragraphs.length===1&&!!L.trailingBlank;if(K&&q&&!be&&!X){for(const re of q.chars)G.set(re.charData.id,K.owner);K.para.chars=K.para.chars.concat(q.chars),L.leadFirstId=q.chars[0].charData.id,L.paragraphs=L.paragraphs.slice(1)}if(L.endsOpen&&!L.trailingBlank){const re=L.paragraphs[L.paragraphs.length-1];re&&(K={para:re,owner:L.page})}else K=null}}return{pages:H,mergedOwner:G}},[n,e,z,b]),N=W.pages,A=g.useMemo(()=>{const Q=[];for(const H of N)for(const G of H.paragraphs)for(const xe of G.chars)Q.push(xe.charData.id);return Q},[N]),F=g.useMemo(()=>{const Q=new Map;if(!f||f.length===0)return Q;const H=new Map(A.map((G,xe)=>[G,xe]));for(const G of f){if(!G.anchor)continue;const xe=H.get(G.anchor.start),K=H.get(G.anchor.end);if(!(xe===void 0||K===void 0||K<xe))for(let L=xe;L<=K;L++)Q.has(A[L])||Q.set(A[L],G)}return Q},[f,A]),Y=Lo(x,v),te=F.size>0,se=g.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:S});se.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:S};const D=g.useMemo(()=>({click:Q=>{var H,G;E.current=Date.now()+1200,(G=(H=se.current).onCharClick)==null||G.call(H,Q)},enter:Q=>{var H,G;return(G=(H=se.current).onCharHover)==null?void 0:G.call(H,Q)},leave:()=>{var Q,H;return(H=(Q=se.current).onCharHover)==null?void 0:H.call(Q,null)},navigate:(Q,H)=>{var xe,K;if(!(H.detail===0||H.ctrlKey||H.metaKey||H.shiftKey)){H.preventDefault();return}(K=(xe=se.current).onEntityNavigate)==null||K.call(xe,Q,H)}}),[]),V=jf(o,W.mergedOwner),he=g.useRef(null);g.useEffect(()=>{var H,G;if((H=he.current)==null||H.classList.remove("is-hovered"),he.current=null,!s)return;const Q=(G=_.current)==null?void 0:G.querySelector(`span[data-char-id="${s}"]`);Q&&(Q.classList.add("is-hovered"),he.current=Q)},[s]),g.useEffect(()=>{let Q=null;const H=()=>{var je,ke;Q=null;const xe=window.getSelection(),K=_.current;if(!xe||xe.isCollapsed||xe.rangeCount===0||!K)return;const L=xe.getRangeAt(0),q=L.commonAncestorContainer,ae=q.nodeType===3?q.parentElement:q;if(!ae||!K.contains(ae))return;const be=K.querySelectorAll("span[data-char-id]"),X=P=>P.firstChild??P;let re=0,Ce=be.length;for(;re<Ce;){const P=re+Ce>>1;L.comparePoint(X(be[P]),0)<0?re=P+1:Ce=P}const We=re;for(Ce=be.length;re<Ce;){const P=re+Ce>>1;L.comparePoint(X(be[P]),0)<=0?re=P+1:Ce=P}let O=re-1;if(O>=We&&L.endOffset===0&&L.endContainer===X(be[O])&&O--,O<We)return;const ie=[];for(let P=We;P<=O;P++)ie.push(be[P].getAttribute("data-char-id"));ie.length>0&&(E.current=Date.now()+1200,(ke=(je=se.current).onSelectionChange)==null||ke.call(je,ie))},G=()=>{Q&&clearTimeout(Q),Q=setTimeout(H,120)};return document.addEventListener("selectionchange",G),()=>{document.removeEventListener("selectionchange",G),Q&&clearTimeout(Q)}},[]),g.useEffect(()=>{var Q;if(o.size===1){const H=Array.from(o)[0],G=(Q=_.current)==null?void 0:Q.querySelector(`span[data-char-id="${H}"]`);G&&G.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[o]);const Z=Q=>{var xe;const H=_.current;if(!H)return null;const G=(xe=N.find(K=>K.page===Q))==null?void 0:xe.leadFirstId;return G?H.querySelector(`span[data-char-id="${G}"]`):H.querySelector(`[data-page-section="${Q}"]`)},M=m==null?void 0:m.nonce;g.useEffect(()=>{if(!m)return;const Q=Z(m.page);Q&&(E.current=Date.now()+800,Q.scrollIntoView({behavior:"auto",block:"start"}))},[M]);const _e=!!h,ce=_e&&typeof w=="number",[ge,le]=g.useState(null),Be=Mr(ge??w??0),ze=g.useRef(null);ze.current=ce?Be:null;const Fe=g.useRef(()=>{});return g.useEffect(()=>{if(!_e)return;const Q=[],H=[];for(const L of N){const q=Z(L.page);q&&(Q.push(q),H.push(L.page))}if(Q.length===0)return;let G=0;const xe=()=>{var be,X;if(G=0,Date.now()<E.current||Q.length>1&&Q[0].getBoundingClientRect().top===Q[Q.length-1].getBoundingClientRect().top)return;const L=ze.current===null?120:ze.current*window.innerHeight;let q=0,ae=Q.length-1;for(;q<ae;){const re=q+ae+1>>1;Q[re].getBoundingClientRect().top<=L?q=re:ae=re-1}(X=(be=se.current).onVisiblePageChange)==null||X.call(be,H[q])},K=()=>{G||(G=requestAnimationFrame(xe))};return Fe.current=()=>{G||(G=requestAnimationFrame(xe))},window.addEventListener("scroll",K,{passive:!0}),xe(),()=>{window.removeEventListener("scroll",K),G&&cancelAnimationFrame(G),Fe.current=()=>{}}},[_e,N]),g.useEffect(()=>{ce&&Fe.current()},[ce,Be]),t.jsxs("div",{ref:_,className:"guji-text-pane-content",children:[te&&t.jsx("style",{children:Eo}),ce&&t.jsx(Sf,{y:Be,containerRef:_,onDrag:le,onCommit:Q=>{le(null),j==null||j(Q)}}),t.jsx("div",{className:"guji-text-reflow-view",children:N.map((Q,H)=>t.jsx(kf,{pGroup:Q,first:H===0,pageBreaks:b,markOpts:T,plainBooks:B,selected:V.get(Q.page)??bf,entityOfChar:F,entityLoader:Y,convert:u,buildHref:y??gf,handlers:D},`page-sec-${Q.page}`))})]})},bf=new Set,yf=[];function jf(e,n){const i=g.useRef(new Map);return g.useMemo(()=>{const o=new Map;e.forEach(a=>{const l=n.get(a)??parseInt(a.split(":")[0],10);let d=o.get(l);d||o.set(l,d=new Set),d.add(a)});const s=new Map;return o.forEach((a,l)=>{const d=i.current.get(l),c=d&&d.size===a.size&&Array.from(a).every(p=>d.has(p));s.set(l,c?d:a)}),i.current=s,s},[e,n])}function pa({n:e}){return t.jsx(t.Fragment,{children:Array.from({length:e},(n,i)=>t.jsx("span",{className:"guji-text-blank-col","aria-hidden":"true","data-blank-col":""},i))})}function vf(e,n){const i=Array.from(n(e.join("")));return i.length===e.length&&e.every(o=>Array.from(o).length===1)?i:e.map(o=>n(o))}const kf=g.memo(function({pGroup:n,first:i,pageBreaks:o,markOpts:s,plainBooks:a,selected:l,entityOfChar:d,entityLoader:c,convert:p,buildHref:h,handlers:u}){const m=g.useMemo(()=>{const y=new Map;if(!p)return y;for(const S of n.paragraphs){const b=vf(S.chars.map(w=>w.charData.char),p);S.chars.forEach((w,j)=>y.set(w.charData.id,b[j]))}return y},[n,p]),f=y=>m.get(y.id)??y.char,{t:x}=ne(),v=y=>{const S=s?Nc(y.mark,s):y.mark;return S?t.jsx("span",{className:"guji-text-punct","data-punct-id":y.id,children:S},y.id):null};return t.jsxs("section",{"data-page-section":n.page,className:"guji-page-section",style:{position:"relative",scrollMarginTop:96},children:[!i&&o&&t.jsxs("div",{className:"guji-page-divider",style:{display:"flex",alignItems:"center",margin:"2rem 0 1.2rem",color:r("meta-fg"),fontSize:"0.82rem",letterSpacing:"0.08em",userSelect:"none"},children:[t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}}),t.jsxs("span",{style:{padding:"0 12px",fontWeight:500},"data-page-label":n.label,title:n.label?`${n.page}`:void 0,children:["第 ",n.label??n.page," 葉"]}),t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}})]}),n.paragraphs.map((y,S)=>t.jsxs("p",{className:"guji-reflow-paragraph",children:[xf(y.chars,d).map((b,w)=>{const j=b.chars.map(({charData:C,beforePuncts:_,afterPuncts:E,start:z},T)=>{const B=!!b.entity&&T===0,W=!!b.entity&&T===b.chars.length-1,N=B?[]:_,A=W?[]:E;return t.jsxs(g.Fragment,{children:[z&&z.blankBefore>0&&t.jsx(pa,{n:z.blankBefore}),N.map(v),t.jsx("span",{"data-char-id":C.id,onClick:()=>u.click(C.id),onMouseEnter:()=>u.enter(C.id),onMouseLeave:u.leave,className:`guji-text-char${l.has(C.id)?" is-selected":""}${C.sub?" is-sub":""}${C.lane==="solo"?" is-solo":""}${C.lacuna?" is-lacuna":""}${C.guess?" is-guess":""}${C.zi?" is-zi":""}${z!=null&&z.raised?" is-raised":""}`,"data-raised":(z==null?void 0:z.raised)||void 0,title:C.lacuna?x("detail.lacuna"):C.zi?x("detail.composedChar",{label:C.zi}):C.guess?x("reader.charGuess"):void 0,children:f(C)}),A.map(v)]},C.id)});if(!b.entity)return t.jsx(g.Fragment,{children:j},`r${w}`);const k=b.chars[0].beforePuncts.map(v),$=b.chars[b.chars.length-1].afterPuncts.map(v);return t.jsxs(g.Fragment,{children:[k,t.jsx(Ao,{span:b.entity,label:b.chars.map(C=>f(C.charData)).join(""),hasBrackets:!0,plain:a&&b.entity.kind==="work",loader:c,buildHref:h,onNavigate:u.navigate,renderText:()=>j,hoverDelayMs:250}),$]},`${b.entity.key}@${w}`)}),S===n.paragraphs.length-1&&n.trailingBlank?t.jsx(pa,{n:n.trailingBlank}):null]},y.id))]})});function Mr(e){const[n,i]=Pn,o=Number.isFinite(e)?e:.33;return Math.round(Math.min(i,Math.max(n,o))*1e3)/1e3}const wf=.02,si=16;function Sf({y:e,containerRef:n,onDrag:i,onCommit:o}){const{t:s}=ne(),[a,l]=g.useState(0),d=g.useRef(!1),c=g.useRef(e);c.current=e;const p=g.useCallback(()=>{var f,x;const m=(x=((f=n.current)==null?void 0:f.querySelector(".guji-text-reflow-view"))??n.current)==null?void 0:x.getBoundingClientRect();l(Math.max(0,((m==null?void 0:m.left)??0)-si-2))},[n]);g.useLayoutEffect(()=>(p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)),[p]);const h=u=>Mr(u/Math.max(1,window.innerHeight));return t.jsx("div",{role:"slider",tabIndex:0,className:"guji-page-indicator","aria-label":s("reader.pageIndicator"),"aria-orientation":"vertical","aria-valuemin":Math.round(Pn[0]*100),"aria-valuemax":Math.round(Pn[1]*100),"aria-valuenow":Math.round(e*100),"data-indicator-y":e,style:{position:"fixed",left:a,top:`calc(${e*100}vh - ${si/2}px)`,width:si,height:si,zIndex:20,cursor:"ns-resize",touchAction:"none",background:r("accent"),clipPath:"polygon(0 0, 100% 50%, 0 100%)",outline:"none"},onPointerDown:u=>{d.current=!0;try{u.currentTarget.setPointerCapture(u.pointerId)}catch{}u.preventDefault()},onPointerMove:u=>{if(!d.current)return;const m=h(u.clientY);c.current=m,i(m)},onPointerUp:u=>{if(d.current){d.current=!1;try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}o(h(u.clientY))}},onPointerCancel:()=>{d.current&&(d.current=!1,o(c.current))},onKeyDown:u=>{const m=u.key==="ArrowUp"?-1:u.key==="ArrowDown"?1:0;m&&(u.preventDefault(),o(Mr(e+m*(u.shiftKey?5:1)*wf)))}})}const Uc=1,Vc=6,ai={s:1,x:0,y:0},ui=(e,n,i)=>Math.min(i,Math.max(n,e));function Po(e,n,i){const o=ui(e.s,Uc,Vc);return{s:o,x:ui(e.x,n*(1-o),0),y:ui(e.y,i*(1-o),0)}}function dr(e,n,i,o,s,a){const l=ui(e.s*o,Uc,Vc),d=l/e.s;return Po({s:l,x:n-(n-e.x)*d,y:i-(i-e.y)*d},s,a)}function _f(e,n,i,o,s){return Po({s:e.s,x:e.x+n,y:e.y+i},o,s)}function $f(e,n,i){const o=n===1?e*16:n===2?e*400:e;return Math.exp(-o*(i?.01:.0015))}const ua=4,Cf=g.forwardRef(function({children:n,onScaleChange:i,resetKey:o,style:s},a){const l=g.useRef(null),[d,c]=g.useState(ai),p=g.useRef(d),h=g.useRef(i);h.current=i;const u=b=>{var j;const w=p.current;p.current=b,c(b),b.s!==w.s&&((j=h.current)==null||j.call(h,b.s))},m=()=>{var w;const b=(w=l.current)==null?void 0:w.getBoundingClientRect();return{w:(b==null?void 0:b.width)??0,h:(b==null?void 0:b.height)??0,left:(b==null?void 0:b.left)??0,top:(b==null?void 0:b.top)??0}};g.useImperativeHandle(a,()=>({zoomBy(b){const{w,h:j}=m();u(dr(p.current,w/2,j/2,b,w,j))},reset(){u(ai)}})),g.useEffect(()=>{u(ai)},[o]),g.useEffect(()=>{const b=l.current;if(!b||typeof ResizeObserver>"u")return;const w=new ResizeObserver(()=>{const{w:j,h:k}=m(),$=Po(p.current,j,k);($.x!==p.current.x||$.y!==p.current.y)&&u($)});return w.observe(b),()=>w.disconnect()},[]),g.useEffect(()=>{const b=l.current;if(!b)return;const w=j=>{const k=$f(j.deltaY,j.deltaMode,j.ctrlKey);if(p.current.s<=1&&k<1)return;j.preventDefault();const{w:$,h:C,left:_,top:E}=m();u(dr(p.current,j.clientX-_,j.clientY-E,k,$,C))};return b.addEventListener("wheel",w,{passive:!1}),()=>b.removeEventListener("wheel",w)},[]);const f=g.useRef(new Map),x=g.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),v=b=>{if(b.pointerType==="mouse"&&b.button!==0)return;f.current.set(b.pointerId,{x:b.clientX,y:b.clientY});const w=x.current;if(w.swallowClick=!1,f.current.size===1&&(w.moved=0,w.dragging=!1),f.current.size===2){const[j,k]=[...f.current.values()];w.pinchDist=Math.hypot(j.x-k.x,j.y-k.y),w.moved=ua+1}},y=b=>{var B;const w=f.current.get(b.pointerId);if(!w)return;const j={x:b.clientX,y:b.clientY};f.current.set(b.pointerId,j);const k=x.current,{w:$,h:C,left:_,top:E}=m();if(f.current.size>=2){const[W,N]=[...f.current.values()],A=Math.hypot(W.x-N.x,W.y-N.y);if(k.pinchDist>0&&A>0){const F=(W.x+N.x)/2-_,Y=(W.y+N.y)/2-E;u(dr(p.current,F,Y,A/k.pinchDist,$,C))}k.pinchDist=A,k.swallowClick=!0;return}const z=j.x-w.x,T=j.y-w.y;if(k.moved+=Math.abs(z)+Math.abs(T),!(k.moved<=ua)){if(!k.dragging){k.dragging=!0;try{(B=l.current)==null||B.setPointerCapture(b.pointerId)}catch{}}k.swallowClick=!0,p.current.s>1&&u(_f(p.current,z,T,$,C))}},S=b=>{f.current.delete(b.pointerId);const w=x.current;w.pinchDist=0,f.current.size===0&&(w.dragging=!1)};return t.jsx("div",{ref:l,className:"bim-zp","data-zoom":d.s.toFixed(2),onPointerDown:v,onPointerMove:y,onPointerUp:S,onPointerCancel:S,onClickCapture:b=>{x.current.swallowClick&&(x.current.swallowClick=!1,b.stopPropagation(),b.preventDefault())},onDoubleClick:()=>u(ai),style:{position:"relative",overflow:"hidden",touchAction:"none",cursor:d.s>1?"grab":void 0,...s},children:t.jsx("div",{className:"bim-zp-inner",style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transformOrigin:"0 0",transform:`translate(${d.x}px, ${d.y}px) scale(${d.s})`,willChange:d.s>1?"transform":void 0},children:n})})});function Gc(e,n,i,o){const[s,a]=g.useState(n??null),[l,d]=g.useState(!1),c=g.useRef(0);return g.useEffect(()=>{if(n!==void 0){a(n);return}const p=++c.current;if(!i){a(null),d(!1);return}if(e){let h;try{h=e(i,o)}catch{a(null),d(!1);return}if(!h||typeof h.then!="function"){a(h??null),d(!1);return}d(!0),h.then(u=>{p===c.current&&a(u??null)}).catch(()=>{p===c.current&&a(null)}).finally(()=>{p===c.current&&d(!1)});return}a(null),d(!1)},[e,n,i,o]),{warpData:s,loading:l}}function Tf(e,n,i){const[o,s]=g.useState([]),a=g.useRef(0);return g.useEffect(()=>{const l=++a.current;if(!e||!n){s([]);return}let d;try{d=e(n,i)}catch{s([]);return}Promise.resolve(d).then(c=>{l===a.current&&s(c?Lc(c):[])}).catch(()=>{l===a.current&&s([])})},[e,n,i]),o}const ma={padding:24,color:r("desc-fg"),fontSize:14};function ha({title:e,label:n,className:i,style:o}){const s=(a,l=14,d=14)=>({width:a,height:l,marginTop:d,borderRadius:3,background:r("rule")});return t.jsxs("div",{className:i,style:{...o,padding:"20px 24px",maxWidth:760,margin:"0 auto"},"aria-busy":"true",children:[e&&t.jsx("div",{style:{fontSize:15,color:r("ink"),fontFamily:r("font-ui")},children:e}),t.jsx("div",{style:s("42%",24,28)}),t.jsx("div",{style:s("30%",12,10)}),["96%","100%","92%","98%","64%"].map((a,l)=>t.jsx("div",{style:s(a,16,l===0?30:14)},l)),t.jsx("p",{role:"status",style:{marginTop:24,color:r("desc-fg"),fontSize:14,fontFamily:r("font-ui")},children:n})]})}const ga=/^https?:\/\//i,zf=[];function Nf(e){if(!e||typeof e!="object")return null;const n=a=>typeof a=="string"&&a.trim()?a.trim():void 0,i=n(e.url),o=n(e.license_url),s={name:n(e.name),url:i&&ga.test(i)?i:void 0,license:n(e.license),license_url:o&&ga.test(o)?o:void 0,note:n(e.note)};return s.name||s.license||s.note?s:null}function If(e,n){return{work_id:n.work_id??e,title:n.title,type:n.type,juan_files:n.chapters.map(i=>i.file),juan_metadata:n.juan_metadata,juan_groups:n.juan_groups,references:n.references,target_source:n.target_source,target_source_id:n.target_source_id,text_source:n.text_source,text_quality:n.text_quality}}function Rf(e,n){return(n==null?void 0:n.type)==="kaozhen"?"章":n!=null&&n.juan_metadata&&Object.values(n.juan_metadata).some(i=>i.vol_label)?"冊":Se.isCollatedKind(e==null?void 0:e.kind)?"卷":"章"}function Yc(e,n,i,o=!1){const s=i(`${n}${e.n}`);if(!e.title)return s;const a=i(e.title);return o&&!/^[卷冊册章篇回第]/.test(e.title)?`${s} ${a}`:a}function Ef(e,n,i,o,s){var p;const a=new Map(e.chapters.map(h=>[h.file,h])),l=h=>h==="loading"?"…":typeof h=="number"&&h>0?h:void 0,d=(h,u)=>{const m=a.get(h);return{key:h,label:u??(m?Yc(m,i,o,s):h),hint:l(n[h]),disabled:n[h]===0}},c=(p=e.juan_groups)==null?void 0:p.filter(h=>{var u;return h.files.some(m=>a.has(m))||((u=h.children)==null?void 0:u.length)});if(c&&c.length>0){const h=(u,m)=>{var x;if(u.files.length===1&&!((x=u.children)!=null&&x.length))return d(u.files[0],o(u.label));const f=Fg(u,n);return{key:`group:${m}`,label:o(u.label),hint:f==="loading"?"…":typeof f=="number"&&f>0?`${f}`:Bc(u),defaultExpanded:typeof f=="number"&&f>0,children:[...u.files.filter(v=>a.has(v)).map(v=>d(v)),...(u.children??[]).map((v,y)=>h(v,`${m}.${y}`))]}};return c.map((u,m)=>h(u,`${m}`))}return e.chapters.map(h=>d(h.file))}const Bo=e=>{const n=Dl();return t.jsx(yu,{mode:n[0].scriptMode,children:t.jsx(Lf,{...e,prefsState:n})})},Lf=({prefsState:e,id:n,transport:i,versionKey:o,chapter:s,onLocationChange:a,onNavigate:l,title:d,subtitle:c,resolveImages:p,renderImageOverlay:h,imagePanel:u,allowVertical:m,onReportError:f,revisedAt:x,backHref:v,backLabel:y,resolveWarpData:S,warpData:b,resolveEntities:w,onEntityNavigate:j,className:k,style:$})=>{var cs,ds,ps;const{t:C,convert:_}=ne(),E=g.useMemo(()=>El(i),[i]),[z,T]=e,B=tt(),W=g.useRef(a);W.current=a;const[N,A]=g.useState(null),[F,Y]=g.useState("loading");g.useEffect(()=>{let R=!1;return A(null),Y("loading"),E.getManifest(n).then(de=>{R||(de?(A(de),Y("ready")):Y("missing"))}).catch(()=>{R||Y("missing")}),()=>{R=!0}},[E,n]);const te=o!==void 0,se=s!==void 0,[D,V]=g.useState(null),[he,Z]=g.useState(null);g.useEffect(()=>{V(null),Z(null)},[n]);const M=Se.pickTextVersion(N,te?o:D),_e=((cs=N==null?void 0:N.versions.find(R=>R.key==="default"))==null?void 0:cs.key)??((ds=N==null?void 0:N.versions[0])==null?void 0:ds.key)??"default",ce=(M==null?void 0:M.key)??null,ge=se?s:he,le=g.useCallback((R,de,Ne)=>{var Ue;(Ue=W.current)==null||Ue.call(W,{key:R,chapter:de,isDefault:R===_e},Ne)},[_e]);g.useEffect(()=>{!N||!te||o==null||N.versions.some(R=>R.key===o)||le(_e,null,"auto")},[N,te,o,_e,le]);const Be=g.useRef(new Map);g.useEffect(()=>{Be.current.clear()},[E,n]);const ze=g.useCallback(async R=>{const de=`${n}
|
|
1344
|
+
${R}`;if(Be.current.has(de))return Be.current.get(de)??null;const Ne=await E.getIndex(n,R).catch(()=>null);return Ne&&Be.current.set(de,Ne),Ne},[E,n]),[Fe,Q]=g.useState(null),[H,G]=g.useState("loading"),xe=ce?`${n}
|
|
1345
1345
|
${ce}`:null,K=Fe&&Fe.owner===xe?Fe.idx:null;g.useEffect(()=>{if(!ce)return;let R=!1;const de=`${n}
|
|
1346
|
-
${ce}`;return
|
|
1346
|
+
${ce}`;return Q(null),G("loading"),ze(ce).then(Ne=>{R||(Ne&&Ne.chapters.length>0?(Q({owner:de,idx:Ne}),G("ready")):G("failed"))}),()=>{R=!0}},[n,ce,ze]),g.useEffect(()=>{if(!K||!ce||ge!=null&&K.chapters.some(Ne=>Ne.file===ge))return;const de=K.chapters[0].file;se||Z(de),le(ce,de,"auto")},[K,ce,ge,se,le]);const L=K?ge!=null&&K.chapters.some(R=>R.file===ge)?ge:K.chapters[0].file:ge,q=g.useMemo(()=>K&&L?K.chapters.find(R=>R.file===L)??null:null,[K,L]),ae=g.useRef(0),be=g.useCallback(async R=>{if(!N||R===ce||!N.versions.some(vt=>vt.key===R))return;const de=++ae.current,Ne=await ze(R);if(de!==ae.current)return;const Ue=q??(L?{file:L}:null),Je=Se.matchChapterAcrossVersions(Ue,Ne);te||V(R),se||Z(Je),le(R,Je,"version")},[N,ce,ze,q,L,te,se,le]),X=g.useCallback(R=>{ce&&(se||Z(R),le(ce,R,"chapter"))},[ce,se,le]),[re,Ce]=g.useState(null),We=ce&&q?`${n}
|
|
1347
1347
|
${ce}
|
|
1348
1348
|
${q.file}`:null,[O,ie]=g.useState(null),je=We!==null&&O!==We,ke=g.useRef(0);g.useEffect(()=>{if(!ce||!q)return;const R=++ke.current,de=`${n}
|
|
1349
1349
|
${ce}
|
|
1350
|
-
${q.file}`;Ce(null),E.getChapter(n,ce,q.file,{json:!!q.has_json}).then(Ne=>{R===ke.current&&Ce(Ne)}).catch(()=>{R===ke.current&&Ce(null)}).finally(()=>{R===ke.current&&ie(de)})},[E,n,ce,q]);const P=Se.isCollatedKind(M==null?void 0:M.kind),[fe,oe]=g.useState("");g.useEffect(()=>{oe("")},[n,ce]);const we=g.useMemo(()=>ce&&P?async R=>{const de=await E.getChapter(n,ce,R,{json:!0});return{juan:(de==null?void 0:de.json)??null,rawText:(de==null?void 0:de.md)??null}}:null,[E,n,ce,P]),Le=(K==null?void 0:K.type)==="kaozhen",He=g.useMemo(()=>(K==null?void 0:K.chapters.map(R=>R.file))??[],[K]),{matchStates:Ge}=
|
|
1351
|
-
${ce??""}`,load:we,files:He,activeFile:L??null,activeJuan:(re==null?void 0:re.json)??null,activeRawText:(re==null?void 0:re.md)??null,query:fe,isKaozhen:Le}),Ye=g.useRef(new Map);g.useEffect(()=>{Ye.current.clear()},[n]);const Xe=g.useMemo(()=>({versionKey:ce,chapter:q??null}),[ce,q]),I=
|
|
1350
|
+
${q.file}`;Ce(null),E.getChapter(n,ce,q.file,{json:!!q.has_json}).then(Ne=>{R===ke.current&&Ce(Ne)}).catch(()=>{R===ke.current&&Ce(null)}).finally(()=>{R===ke.current&&ie(de)})},[E,n,ce,q]);const P=Se.isCollatedKind(M==null?void 0:M.kind),[fe,oe]=g.useState("");g.useEffect(()=>{oe("")},[n,ce]);const we=g.useMemo(()=>ce&&P?async R=>{const de=await E.getChapter(n,ce,R,{json:!0});return{juan:(de==null?void 0:de.json)??null,rawText:(de==null?void 0:de.md)??null}}:null,[E,n,ce,P]),Le=(K==null?void 0:K.type)==="kaozhen",He=g.useMemo(()=>(K==null?void 0:K.chapters.map(R=>R.file))??[],[K]),{matchStates:Ge}=ef({resetKey:`${n}
|
|
1351
|
+
${ce??""}`,load:we,files:He,activeFile:L??null,activeJuan:(re==null?void 0:re.json)??null,activeRawText:(re==null?void 0:re.md)??null,query:fe,isKaozhen:Le}),Ye=g.useRef(new Map);g.useEffect(()=>{Ye.current.clear()},[n]);const Xe=g.useMemo(()=>({versionKey:ce,chapter:q??null}),[ce,q]),I=Tg(p,L??null,Xe),{warpData:U,loading:pe}=Gc(S,b,L??null,Xe),$e=Tf(w,L??null,Xe),ye=z.properNameMode??($e.length>0?"full":"off"),ue=g.useMemo(()=>({...z,properNameMode:ye}),[z,ye]),Ve=g.useMemo(()=>Cg($e,ye,{showWorks:ue.showWorks}),[$e,ye,ue.showWorks]),[ee,ve]=g.useState(new Set),[Ae,Oe]=g.useState(null),[Ie,me]=g.useState(!0),Te=z.preserveMargins;g.useCallback(R=>T({preserveMargins:R}),[T]);const De=g.useRef(null),[Me,yt]=g.useState(1),[jt,on]=g.useState(null),Wt=R=>{var Ne;const de=parseInt(((Ne=R==null?void 0:R.page_id)==null?void 0:Ne.split(":")[1])??"",10);return isNaN(de)?null:de},J=R=>{var Ne,Ue;const de=(R==null?void 0:R.pages)??[];return Wt(R)??((Ne=de.find(Je=>Je.columns.some(vt=>vt.chars.length>0)))==null?void 0:Ne.page)??((Ue=de[0])==null?void 0:Ue.page)??1},[Re,qe]=g.useState(()=>J(U)),ot=`${n}
|
|
1352
1352
|
${ce}
|
|
1353
|
-
${L??""}`,[Vi,Qo]=g.useState({key:ot,data:U,started:!!U});if(Vi.key!==ot)Qo({key:ot,data:U,started:!1});else if(U!==Vi.data&&(Qo({key:ot,data:U,started:!!U}),U)){const R=U.pages??[];(!Vi.started||!R.some(de=>de.page===Re))&&qe(J(U))}g.useEffect(()=>{ve(new Set),Oe(null)},[L,ce]);const fp=g.useCallback(R=>{if(ve(new Set(R)),R.length>0){const de=R[0],Ne=parseInt(de.split(":")[0],10);isNaN(Ne)||qe(Ne)}},[]),zt=g.useMemo(()=>{const R=new Map;for(const de of(U==null?void 0:U.pages)??[])R.set(de.page,de);return R},[U]),vn=Wt(U),Gn=g.useCallback(R=>{var Ue;const de=I.images;if(!de||de.length===0)return;const Ne=(Ue=zt.get(R))==null?void 0:Ue.seq;return(Ne?de.find(Je=>Je.seq===Ne):void 0)??de.find(Je=>Je.pageNo===R)??de[R-1]},[I.images,zt]),es=Me>1.5,Yn=g.useCallback((R,de=!1)=>{const Ne=Gn(R);return Ne?R===vn||de?Ne.hiresUrl??Ne.url:Ne.url:R===vn?(U==null?void 0:U.imageUrl)??"":""},[Gn,U,vn]),xp=g.useMemo(()=>Yn(Re,es),[Yn,Re,es]),Nt=g.useMemo(()=>[...zt.keys()].sort((R,de)=>R-de),[zt]),qn=g.useRef(Re);qn.current=Re;const Kn=g.useCallback(R=>{var de;qn.current===R||!zt.has(R)||(qn.current=R,qe(R),(de=zt.get(R))!=null&&de.columns.some(Ne=>Ne.chars.length>0)&&on(Ne=>({page:R,nonce:((Ne==null?void 0:Ne.nonce)??0)+1})))},[zt]),kn=g.useCallback(R=>{const de=qn.current,Ne=Nt.indexOf(de),Ue=Nt[Ne<0?0:Ne+R];Ue===void 0||Ue===de||Kn(Ue)},[Nt,Kn]),ts=g.useCallback(R=>{if(!R.trim().match(/^\d+$/)||Nt.length===0)return null;const Ne=parseInt(R.trim(),10),Ue=Number.isFinite(Ne)?Ne:Number.MAX_SAFE_INTEGER;return Nt.reduce((Je,vt)=>Math.abs(vt-Ue)<Math.abs(Je-Ue)?vt:Je,Nt[0])},[Nt]),[Gi,Yi]=g.useState(null),Xn=g.useRef(null),bp=g.useCallback(R=>{Xn.current=R,Yi(R)},[]),ns=g.useCallback(()=>{const R=Xn.current;if(Xn.current=null,Yi(null),R===null)return;const de=ts(R);de!==null&&Kn(de)},[ts,Kn]),qi=Nt.indexOf(Re),yp=g.useCallback(R=>{if(R.altKey||R.ctrlKey||R.metaKey)return;const de=R.target.tagName;de==="INPUT"||de==="TEXTAREA"||de==="SELECT"||(R.key==="ArrowLeft"||R.key==="PageUp"?(R.preventDefault(),kn(-1)):(R.key==="ArrowRight"||R.key==="PageDown")&&(R.preventDefault(),kn(1)))},[kn]);g.useEffect(()=>{if(U)for(const R of[1,-1,2,3]){const de=Yn(Re+R);de&&Ar(de)}},[U,Re,Yn]);const is=g.useMemo(()=>{var hs;if(!U)return null;if(Re===vn)return U;const R=zt.get(Re);if(R&&R.width>0&&R.height>0)return{page_id:`p:${Re}`,title:`第${Re}葉`,image_size:[R.width,R.height],total_warped_w:R.width,columns:[{col:1,warped_w:R.width,warped_h:R.height,offset_x:0,strips:[],chars:R.columns.flatMap(Ze=>Ze.chars).map(Ze=>({id:Ze.id,char:Ze.char,slot:Ze.slot,pos:Ze.pos,sub:Ze.sub,bbox_col:Ze.bbox??[0,0,0,0]}))}]};const de=(hs=U.pages)==null?void 0:hs.find(Ze=>Ze.page===Re),[Ne,Ue]=U.image_size||[2386,3082],Je=Gn(Re),vt=(Je==null?void 0:Je.width)??Ne,Qi=(Je==null?void 0:Je.height)??Ue,ps=vt/Ne,us=Qi/Ue,ms=new Map;for(const Ze of U.columns){const ut=(Ze.strips||[]).flatMap(ti=>ti.srcQuad.map(ni=>ni[0]));if(ut.length===0)continue;const It=Ze.top_y??0,er=Ze.bottom_y??It+Ze.warped_h;ms.set(Ze.col,{x0:Math.min(...ut),x1:Math.max(...ut),top:It,slotH:(er-It)/21})}return{page_id:`p:${Re}`,title:`第${Re}葉`,image_size:[vt,Qi],total_warped_w:vt,columns:de?de.columns.map(Ze=>{const ut=ms.get(Ze.col)??{x0:0,x1:0,top:0,slotH:118};return{col:Ze.col,warped_w:vt,warped_h:Qi,offset_x:0,strips:[],chars:Ze.chars.map(It=>{const er=It.slot??It.pos??0,ti=(ut.top+(er-1)*ut.slotH)*us,ni=(ut.x0+ut.x1)/2,[Cp,Tp]=It.sub==="a"?[ni,ut.x1]:It.sub==="b"?[ut.x0,ni]:[ut.x0,ut.x1];return{...It,bbox_col:[Cp*ps,ti,Tp*ps,ti+ut.slotH*us]}})}}):[]}},[U,Re,vn,zt,Gn]),{entryTitle:Zn,authors:rs}=Af(n,i,d===void 0),[os,Ki]=g.useState("text");if(g.useEffect(()=>{Ki("text")},[L,ce]),F==="loading")return t.jsx(ma,{className:k,style:$,title:d??Zn,label:C("reader.loading")});if(F==="missing"||!N||!M)return t.jsx("div",{className:k,style:{...$,...ua},children:C("reader.noText")});if(H==="failed")return t.jsx("div",{className:k,style:{...$,...ua},children:C("reader.tocFailed")});if(!K)return t.jsx(ma,{className:k,style:$,title:d??Zn,label:C("reader.tocLoading")});const Yt=Nf(M,K),jp=If(K,Ge,Yt,_,P),Xi=N.versions.map(R=>({key:R.key,label:Se.textVersionLabel(R),optionLabel:_(Se.textVersionLabel(R)),sourceName:ga(R)?C("reader.originalSource"):R.source_name?_(R.source_name):void 0,license:R.license??void 0,sourceUrl:R.source_url??void 0,primary:R.key===_e})),pt=Tf((ds=K.source)==null?void 0:ds.upstream),Jn=(typeof d=="string"?_(d):d)??(K.title?_(K.title):Zn?_(Zn):void 0),ss=M.edition_label?_(M.edition_label):void 0,Zi=Jn?t.jsx("a",{href:B(n),title:C("reader.viewEntry"),onClick:l?R=>{R.metaKey||R.ctrlKey||(R.preventDefault(),l(n))}:void 0,children:Jn}):void 0,vp=Zi&&ss?t.jsxs(t.Fragment,{children:[Zi,t.jsxs("span",{className:"bim-rd-ed",children:["·",ss]})]}):Zi,kp=rs.length>0?_(rs.slice(0,2).map(R=>`${R.dynasty?`〔${R.dynasty}〕`:""}${R.name}${` ${R.role||C("reader.defaultRole")}`}`).join("、")):void 0,Ji=q?Gc(q,Yt,_,P):void 0,qt=P&&!!(re!=null&&re.json),Kt=(re==null?void 0:re.json)??null,sn=(re==null?void 0:re.md)??null,as=qt&&!Le&&Bc(Kt.sections),wp=as&&!(sn&&ue.readingMode==="paragraph"&&bi(sn)),Sp=qt&&as?t.jsx(ef,{juan:Kt,view:os,onView:Ki,textHasEntries:wp}):void 0,_p=!0,Qn=sn?sn.replace(/^##\s+[^\n]+\n+/,""):null,ei=ga(M),Ot=ei?C("reader.originalSource"):M.source_name?_(M.source_name):void 0,$p=(typeof c=="string"?_(c):c)??(ei?void 0:Ot??_(Se.textVersionLabel(M)));return t.jsxs(Vl,{className:k,style:$,title:vp,subtitle:$p,byline:kp,current:Ji,pagerUnit:Yt,rail:Sp,revisedAt:x,backHref:v,backLabel:y,onReportError:f?R=>f({...R,bookTitle:typeof Jn=="string"?Jn:void 0,entryId:n}):void 0,workLinkToggle:qt&&!Le&&!!l&&!!(Kt!=null&&Kt.sections.some(R=>R.work_id)),toc:jp,tocCaption:C("reader.tocCaption",{n:K.chapters.length,unit:_(Yt)}),tocHeader:P&&K.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:Le?C("reader.searchChaptersPlaceholder"):C("reader.searchUnitPlaceholder",{unit:_(Yt)}),"aria-label":Le?C("reader.searchChapters"):C("reader.searchUnit",{unit:_(Yt)}),value:fe,onChange:R=>oe(R.target.value)}):void 0,activeKey:L??null,onSelect:X,images:I.images,imagesLoading:I.loading||pe,renderImageOverlay:h,imagePanel:U?"open":u,isWarpMode:!!U,customImagePanel:U&&is?t.jsxs("div",{className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:yp,style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",outline:"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 4px 6px",fontSize:12,color:r("meta-fg"),gap:8,flexWrap:"wrap"},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:4},children:t.jsx("span",{style:{fontWeight:600,marginRight:4},children:"底本书影"})}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[Q.size>0&&t.jsxs("button",{type:"button",onClick:()=>ve(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${r("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",Q.size,")"]}),t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:2},"data-testid":"facsimile-zoom-tools",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"缩小",title:"缩小",disabled:Me<=1,onClick:()=>{var R;return(R=De.current)==null?void 0:R.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(Me*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:Me>=6,onClick:()=>{var R;return(R=De.current)==null?void 0:R.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:Me===1,onClick:()=>{var R;return(R=De.current)==null?void 0:R.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx($f,{ref:De,resetKey:Re,onScaleChange:yt,style:{flex:1,minHeight:0},children:t.jsx(Ro,{imageUrl:xp,pageData:is,selectedCharIds:Q,hoveredCharId:Ae,preserveMargins:Te,onCharClick:R=>{ve(Ne=>{const Ue=new Set(Ne);return Ue.has(R)?Ue.delete(R):(Ue.clear(),Ue.add(R)),Ue});const de=document.querySelector(`[data-char-id="${R}"]`);de&&de.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:Oe})}),t.jsxs("div",{"data-testid":"facsimile-pager",role:"group","aria-label":C("reader.facsimilePager"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,padding:"6px 4px 0",fontSize:13,color:r("meta-fg")},children:[t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-prev","aria-label":"上一葉",style:{minWidth:40,minHeight:40,fontSize:20,lineHeight:1},disabled:qi<=0,onClick:()=>kn(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":Re,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"1px 8px",background:r("rule"),borderRadius:10},children:["第",t.jsx("input",{type:"text",inputMode:"numeric","data-testid":"facsimile-page-input","aria-label":C("reader.facsimilePageInput"),size:Math.max(2,String(Gi??Re).length),value:Gi??String(Re),onFocus:R=>R.currentTarget.select(),onChange:R=>bp(R.target.value),onKeyDown:R=>{R.key==="Enter"?(R.preventDefault(),ns()):R.key==="Escape"&&(Xn.current=null,Yi(null)),R.stopPropagation()},onBlur:ns,style:{width:`${Math.max(2,String(Gi??Re).length)+1}ch`,minHeight:28,textAlign:"center",font:"inherit",border:`1px solid ${r("rule")}`,borderRadius:4,background:"transparent",color:"inherit"}}),"葉"]}),t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-next","aria-label":"下一葉",style:{minWidth:40,minHeight:40,fontSize:20,lineHeight:1},disabled:qi<0||qi>=Nt.length-1,onClick:()=>kn(1),children:"›"})]})]}):void 0,settingsAnnotate:U?t.jsx("button",{type:"button",className:`bim-rd-t bim-rd-sp-tg ${Ie?"bim-rd-on":""}`,"aria-pressed":Ie,title:"切换外挂现代断句标点",onClick:()=>me(R=>!R),children:Ie?"标点":"无标点"}):void 0,prefs:ue,onPrefsChange:T,versions:Xi.length>1?Xi:void 0,currentVersionKey:Xi.length>1?M.key:void 0,onVersionChange:be,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:bi(sn),allowVertical:m,children:[(je||pe&&!U&&!qt&&Qn==null)&&t.jsx(nn,{}),!je&&U&&t.jsxs("article",{className:"bim-rd-prose",style:{marginTop:0},children:[t.jsxs("header",{style:{marginBottom:16},children:[t.jsx("h1",{className:"bim-rd-h1",children:q!=null&&q.title?_(q.title):Ji}),(Ot||M.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[Ot,M.license&&t.jsxs(t.Fragment,{children:[Ot&&t.jsx("span",{className:"bim-rd-dot"}),M.license]})]})]}),t.jsx(Mo,{pageData:U,pages:U.pages,punctuations:U.punctuations||[],selectedCharIds:Q,hoveredCharId:Ae,onSelectionChange:fp,onCharClick:R=>{ve(Ne=>{const Ue=new Set(Ne);return Ue.has(R)?Ue.delete(R):(Ue.clear(),Ue.add(R)),Ue});const de=parseInt(R.split(":")[0],10);isNaN(de)||qe(de)},onCharHover:Oe,mode:"horizontal",showPunctuation:Ie,entities:Ve,entityTransport:i,onEntityNavigate:j,onVisiblePageChange:R=>qe(R),convert:_,scrollToPage:jt,pageBreaks:ue.pageBreaks,pageIndicatorY:ue.pageIndicatorY,onPageIndicatorYChange:R=>T({pageIndicatorY:R}),quoteStyle:ue.quoteStyle,bookTitleStyle:ue.bookTitleStyle,showWorks:ue.showWorks})]}),!je&&!U&&qt&&Kt&&t.jsx(Jg,{juan:Kt,rawText:sn,positionLabel:Ef(q,K,Yt,_),groupLabel:Lf(K,L??null),index:zf(n,K),searchQuery:fe,onNavigate:l,transport:i,workLabelCache:Ye,prefs:ue,view:os,onViewChange:Ki},`${ce}/${L}`),!je&&!U&&!qt&&Qn!=null&&q&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:q.title?_(q.title):Ji}),(Ot||M.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[ei&&Ot&&t.jsx(t.Fragment,{children:Ot}),!ei&&M.source_name&&t.jsxs(t.Fragment,{children:[C("reader.textSource")," ",M.source_url?t.jsx("a",{className:"bim-rd-link",href:M.source_url,target:"_blank",rel:"noreferrer",children:_(M.source_name)}):_(M.source_name)]}),Ot&&M.license&&t.jsx("span",{className:"bim-rd-dot"}),M.license]}),pt&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[C("reader.upstream")," ",pt.url?t.jsx("a",{className:"bim-rd-link",href:pt.url,target:"_blank",rel:"noreferrer",children:_(pt.name??pt.url)}):_(pt.name??""),pt.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),pt.license_url?t.jsx("a",{className:"bim-rd-link",href:pt.license_url,target:"_blank",rel:"noreferrer",children:pt.license}):pt.license]}),pt.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(El,{text:pt.note,convert:_})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(So,{text:Qn,mode:ue.readingMode,tables:_p,gujiMarkdown:!0,bookMarking:ko(ue),quoteStyle:ue.quoteStyle})})]}),!je&&!pe&&!U&&!qt&&Qn==null&&q&&t.jsx("div",{className:"bim-rd-state",children:C("reader.chapterFailed")}),K.references&&K.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:C("reader.references")}),t.jsx("ol",{children:K.references.map((R,de)=>t.jsxs("li",{children:[R.url?t.jsx("a",{className:"bim-rd-link",href:R.url,target:"_blank",rel:"noopener noreferrer",children:_(R.title)}):t.jsx("span",{children:_(R.title)}),R.author&&t.jsxs("span",{children:[",",_(R.author)]}),R.note&&t.jsxs("span",{children:["。",_(R.note)]})]},de))})]})]})};function ga(e){return e.is_original===!0||e.source==="original"}function Ef(e,n,i,o){var a,l;if(!e)return;const s=(l=(a=n.juan_metadata)==null?void 0:a[e.file])==null?void 0:l.vol_label;return o(s?`${s}冊`:`${i}${e.n}`)}function Lf(e,n){if(!n)return;const i=o=>{var s;for(const a of o??[]){const l=i(a.children);if(l)return l;if((s=a.files)!=null&&s.includes(n))return a.label}};return i(e.juan_groups)}function Af(e,n,i){const[o,s]=g.useState({entryTitle:void 0,authors:[]});return g.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let a=!1;return Promise.resolve(n.getItem(e)).then(l=>{if(a||!l)return;const d=(l.authors??[]).filter(c=>c&&c.name);s({entryTitle:i&&typeof l.title=="string"?l.title:void 0,authors:d})}).catch(()=>{}),()=>{a=!0}},[e,n,i]),o}const Yc={bug:{key:"bug",color:r("danger")},resource:{key:"resource",color:r("primary")},suggestion:{key:"suggestion",color:r("primary")},other:{key:"other",color:r("desc-fg")}},Mf=Yc.other,qc={pending:{key:"pending",color:r("warning")},in_progress:{key:"in_progress",color:r("primary")},resolved:{key:"resolved",color:r("success")},wontfix:{key:"wontfix",color:r("desc-fg")},duplicate:{key:"duplicate",color:r("desc-fg")}},Pf=qc.pending;function Bf(e){try{const n=new Date(e),i=o=>String(o).padStart(2,"0");return`${n.getFullYear()}-${i(n.getMonth()+1)}-${i(n.getDate())} ${i(n.getHours())}:${i(n.getMinutes())}`}catch{return e}}function Wf(e,n){if(!e)return!1;try{const i=new URL(e,n);if(i.protocol!=="http:"&&i.protocol!=="https:")return!1;const o=new URL(n);return i.hostname===o.hostname}catch{return!1}}const Wo=({items:e,loading:n})=>{const i=tt(),{t:o,convert:s}=ne();return n?t.jsx(nn,{}):e.length===0?t.jsx("div",{style:Of,children:o("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=Yc[a.type]||Mf,d=qc[a.status]||Pf,c=typeof window<"u"&&Wf(a.pageUrl,window.location.href);return t.jsxs("div",{style:Ff,children:[t.jsxs("div",{style:Hf,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...fa,background:l.color},children:o(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...fa,background:d.color},children:o(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:Df,children:Bf(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:Uf,children:[a.resourceId&&t.jsx("a",{href:i(a.resourceId),style:pr,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:pr,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:pr,children:a.pageUrl}))]}),t.jsx("div",{style:Vf,children:s(a.content)}),a.reply&&t.jsxs("div",{style:Gf,children:[t.jsx("div",{style:Yf,children:o("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},Of={textAlign:"center",padding:"40px 0",color:r("desc-fg"),fontSize:"14px"},Ff={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"16px"},Hf={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},fa={fontSize:"12px",color:r("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},Df={fontSize:"12px",color:r("desc-fg")},Uf={fontSize:"12px",marginBottom:"6px"},pr={color:r("primary"),textDecoration:"none",borderBottom:`1px dashed ${r("primary")}`},Vf={fontSize:"14px",lineHeight:"1.6",color:r("fg"),whiteSpace:"pre-wrap"},Gf={marginTop:"12px",padding:"10px 12px",background:r("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:r("fg")},Yf={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:r("primary")},Pr=({transport:e,onNavigate:n,recommendedIds:i,activeTab:o,onTabChange:s,feedbackApiUrl:a})=>{const l=Ee(),[d,c]=g.useState(null),[p,h]=g.useState([]),[u,m]=g.useState("recommend"),[f,x]=g.useState([]),[v,y]=g.useState(!1),S=o??u,b=A=>{m(A),s==null||s(A)},[w,j]=g.useState(!0),[k,$]=g.useState(null),[C,_]=g.useState(null),[E,z]=g.useState(null);g.useEffect(()=>{let A=!1;if(e.getCounts)return e.getCounts().then(F=>{A||c({works:F.works,books:F.books,collections:F.collections})}).catch(()=>{}),()=>{A=!0}},[e]),g.useEffect(()=>{let A=!1;return(async()=>{if(i)return i;if(e.getRecommended)try{const Y=await e.getRecommended();if(Y!=null&&Y.groups)return Y.groups.flatMap(ee=>ee.items.map(se=>({...se,group:ee.name})))}catch{}return[]})().then(async Y=>{if(A)return;const ee=Y.filter(D=>D.id);if(ee.length===0){j(!1);return}const se=await Promise.all(ee.map(async D=>{if(D.type)return{id:D.id,title:D.title,type:D.type,author:D.author,dynasty:D.dynasty,role:D.role,edition:D.edition,has_text:D.has_text,has_image:D.has_image,has_collated:D.has_collated,subtype:D.subtype,primary_name:D.primary_name,group:D.group,fallbackDescription:D.description};try{let V=null;if(e.getEntry)V=await e.getEntry(D.id);else{const he=await e.getItem(D.id);he&&(V={id:D.id,title:he.title||D.id,type:he.type||"work"})}if(V)return{...V,group:D.group,fallbackDescription:D.description}}catch{}return{id:D.id,title:D.title,type:Se.extractType(D.id),group:D.group,fallbackDescription:D.description}}));A||(h(se.filter(D=>D!==null)),j(!1))}),()=>{A=!0}},[e,i]);const T=g.useRef(!1),B=g.useRef(!1),W=g.useRef(!1);g.useEffect(()=>{if(S!=="catalog"||T.current)return;const A=e.getCatalogProgress??e.getResourceProgress;if(!A)return;T.current=!0;let F=!1;return A.call(e).then(Y=>{F||$(Y)}).catch(()=>{T.current=!1}),()=>{F=!0}},[e,S]),g.useEffect(()=>{if(S!=="collection"||B.current||!e.getCollectionProgress)return;B.current=!0;let A=!1;return e.getCollectionProgress().then(F=>{A||_(F)}).catch(()=>{B.current=!1}),()=>{A=!0}},[e,S]),g.useEffect(()=>{if(S!=="site"||W.current||!e.getSiteProgress)return;W.current=!0;let A=!1;return e.getSiteProgress().then(F=>{A||z(F)}).catch(()=>{W.current=!1}),()=>{A=!0}},[e,S]),g.useEffect(()=>{if(!a||S!=="feedback")return;let A=!1;return y(!0),fetch(a).then(F=>F.json()).then(F=>{!A&&F.success&&x(F.items||[])}).catch(()=>{}).finally(()=>{A||y(!1)}),()=>{A=!0}},[a,S]);const N=A=>t.jsx(jn,{type:A,size:12});return t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:r("fg")},children:t.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[t.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${r("widget-border")}`,marginBottom:"16px"},children:[t.jsx(Cn,{label:l.home.recommendTab,active:S==="recommend",onClick:()=>b("recommend")}),t.jsx(Cn,{label:l.home.catalogTab,active:S==="catalog",onClick:()=>b("catalog")}),t.jsx(Cn,{label:l.home.collectionTab,active:S==="collection",onClick:()=>b("collection")}),t.jsx(Cn,{label:l.home.siteTab,active:S==="site",onClick:()=>b("site")}),a&&t.jsx(Cn,{label:l.home.feedbackTab,active:S==="feedback",onClick:()=>b("feedback")})]}),S==="recommend"&&t.jsx(qf,{recommended:p,loading:w,onNavigate:n,getIcon:N,t:l}),S==="catalog"&&t.jsx(xa,{progress:k,t:l,onNavigate:n}),S==="collection"&&t.jsx(xa,{progress:C,t:l,onNavigate:n}),S==="site"&&t.jsx(Xf,{progress:E,t:l,totalWorks:(d==null?void 0:d.works)??0}),S==="feedback"&&a&&t.jsx(Wo,{items:f,loading:v})]})})},Cn=({label:e,active:n,onClick:i})=>t.jsx("button",{onClick:i,style:{padding:"8px 16px",fontSize:"14px",fontWeight:n?600:400,color:r(n?"primary":"desc-fg"),background:"none",border:"none",borderBottom:n?`2px solid ${r("primary")}`:"2px solid transparent",cursor:"pointer",marginBottom:"-1px"},children:e}),qf=({recommended:e,loading:n,onNavigate:i,getIcon:o,t:s})=>{const a=tt();if(n)return t.jsx(nn,{});if(e.length===0)return null;const l=new Map;for(const d of e){const c=d.group||s.home.recommendedBrowse;l.has(c)||l.set(c,[]),l.get(c).push(d)}return t.jsx(t.Fragment,{children:Array.from(l.entries()).map(([d,c])=>t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:d}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"8px"},children:c.map(p=>{const h=p.dynasty||p.author?`${p.dynasty?`〔${p.dynasty}〕`:""}${p.author||""}`:p.fallbackDescription;return t.jsxs("a",{href:a(p.id),onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),i==null||i(p.id))},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,cursor:"pointer",background:r("input-bg"),textDecoration:"none",color:"inherit"},children:[t.jsx("span",{style:{fontSize:"20px"},children:o(p.type)}),t.jsxs("div",{style:{minWidth:0},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[p.title,p.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:r("desc-fg"),marginLeft:"4px"},children:p.edition})]}),h&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h})]})]},p.id)})})]},d))})},xa=({progress:e,t:n,onNavigate:i})=>{if(!e)return t.jsx(nn,{});const o=[...e.resources].sort((d,c)=>d.priority-c.priority),s=["in_progress","done","todo"],a={in_progress:n.home.statusInProgress,done:n.home.statusDone,todo:n.home.statusTodo},l={in_progress:r("progress-active"),done:r("progress-done"),todo:r("progress-todo")};return t.jsx("div",{children:s.map(d=>{const c=o.filter(p=>p.status===d);return c.length===0?null:t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:l[d]}}),a[d]," (",c.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c.map(p=>t.jsx(Kf,{item:p,t:n,statusColor:l[d],onNavigate:i},p.id))})]},d)})})},Kf=({item:e,t:n,statusColor:i,onNavigate:o})=>{const s=tt(),a=e.total>0?Math.round(e.imported/e.total*100):0,l=e.type==="catalog"?n.home.typeCatalog:n.home.typeCollection;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(()=>{const d=e.edition?`${e.name}·${e.edition}`:e.name,c=e.collection_id||e.work_id;return c&&o?t.jsx("a",{href:s(c),onClick:p=>{p.metaKey||p.ctrlKey||(p.preventDefault(),o(c))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`},onMouseEnter:p=>p.currentTarget.style.borderBottomStyle="solid",onMouseLeave:p=>p.currentTarget.style.borderBottomStyle="dashed",children:d}):e.url?t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:d}):d})()}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"4px",background:r("widget-border"),color:r("desc-fg"),whiteSpace:"nowrap"},children:e.collection_id?n.indexType.collection:e.work_id?n.indexType.work:l})]}),t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.total>0?gt(n.home.progressFormat,{imported:String(e.imported),total:String(e.total)}):n.home.totalPending})]}),e.total>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:r("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${a}%`,borderRadius:"2px",background:i,transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"4px"},children:e.description})]})},Xf=({progress:e,t:n,totalWorks:i})=>{if(!e)return t.jsx(nn,{});const o=[...e.resources].sort((c,p)=>c.priority-p.priority),s=o.filter(c=>c.imported>0),a=o.filter(c=>c.imported===0),l=s.reduce((c,p)=>Math.max(c,p.imported),0),d=i>0?Math.round(l/i*100):0;return t.jsxs("div",{children:[i>0&&t.jsxs("div",{style:{padding:"12px 16px",marginBottom:"16px",borderRadius:"8px",background:`color-mix(in srgb, ${r("primary")} 6%, transparent)`,fontSize:"13px",color:r("fg")},children:[n.home.siteCoverage,": ",t.jsx("strong",{children:l.toLocaleString()})," / ",i.toLocaleString()," ",n.indexType.work," (",d,"%)"]}),s.length>0&&t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:r("progress-done")}}),n.home.statusInProgress," (",s.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(c=>t.jsx(ba,{item:c,t:n,totalWorks:i},c.id))})]}),a.length>0&&t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:r("progress-todo")}}),n.home.statusTodo," (",a.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:a.map(c=>t.jsx(ba,{item:c,t:n,totalWorks:i},c.id))})]})]})},ba=({item:e,t:n,totalWorks:i})=>{const o=i>0?Math.round(e.imported/i*100):0;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:t.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:e.url?t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:e.name}):e.name})}),t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.imported>0?`${e.imported.toLocaleString()} ${n.indexType.work} (${o}%)`:n.home.statusTodo})]}),e.imported>0&&i>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:r("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${o}%`,borderRadius:"2px",background:r("progress-done"),transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"4px"},children:e.description})]})},ya="(max-width: 768px)";function Zf(){const[e,n]=g.useState(()=>typeof window>"u"?!1:window.matchMedia(ya).matches);return g.useEffect(()=>{const i=window.matchMedia(ya),o=s=>n(s.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),e}const Jf=({transport:e,hideModeIndicator:n=!0,onEntryClick:i,recommendedIds:o,headerRight:s})=>{var B;const a=Ee(),{convert:l}=Pe(),d=Zf(),[c,p]=g.useState(null),[h,u]=g.useState(null),[m,f]=g.useState(!1),[x,v]=g.useState("detail"),[y,S]=g.useState([]),[b,w]=g.useState(!1),j=g.useCallback(async W=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){S([]);return}w(!0);try{if(e.getCollectionCatalogs){const N=await e.getCollectionCatalogs(W);S(N||[])}else if(e.getCollectionCatalog){const N=await e.getCollectionCatalog(W);S(N?[{resource_id:"",data:N}]:[])}}catch{S([])}finally{w(!1)}},[e]),k=g.useCallback(async W=>{if(i){i(W);return}p(W),u(null),S([]),v("detail"),f(!0);try{const N=await e.getItem(W.id);N&&(u(N),N.type==="collection"&&j(W.id))}catch(N){console.error("加载详情失败:",N)}finally{f(!1)}},[e,i,j]),$=g.useCallback(async W=>{u(null),S([]),v("detail"),f(!0);try{const N=await e.getItem(W);N&&(u(N),p({id:W,title:N.title||W,type:N.type||"book"}),N.type==="collection"&&j(W))}catch(N){console.error("导航失败:",N)}finally{f(!1)}},[e,j]),C=typeof(h==null?void 0:h.text_count)=="number"&&h.text_count>0,_=(h==null?void 0:h.type)==="collection"&&(y.length>0||b)||(h==null?void 0:h.type)==="work"&&C,E=d&&(m||h),z=g.useCallback(()=>{p(null),u(null),S([]),v("detail")},[]),T=t.jsx(t.Fragment,{children:m?t.jsx(nn,{}):h?t.jsxs(t.Fragment,{children:[(_||s)&&t.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${r("widget-border")}`,padding:d?"0 12px":"0 48px",background:r("input-bg"),flexShrink:0,overflowX:d?"auto":void 0},children:[_&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>v("detail"),style:li(x==="detail"),children:a.detailTab.basicInfo}),h.type==="collection"&&b&&y.length===0&&t.jsxs("button",{onClick:()=>{},style:li(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),h.type==="collection"&&y.map(W=>t.jsx("button",{onClick:()=>v(`catalog:${W.resource_id}`),style:li(x===`catalog:${W.resource_id}`),children:W.short_name?`${l(W.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},W.resource_id)),h.type==="work"&&C&&t.jsx("button",{onClick:()=>v("collated"),style:li(x==="collated"),children:a.detailTab.collatedEdition})]}),s&&t.jsx("div",{style:{marginLeft:"auto",flexShrink:0,padding:"4px 0"},children:s})]}),t.jsx("div",{style:{padding:d?"16px 12px":"32px 48px",maxWidth:"900px",flex:1,overflow:"auto"},children:x==="detail"?t.jsx(to,{data:h,transport:e,onNavigate:$}):x.startsWith("catalog:")?t.jsx(no,{data:(B=y.find(W=>`catalog:${W.resource_id}`===x))==null?void 0:B.data,onNavigate:$}):x==="collated"?t.jsx(Bo,{id:h.id,transport:e,onNavigate:$}):null})]}):t.jsx(Pr,{transport:e,onNavigate:$,recommendedIds:o})});return d?t.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:r("bg"),color:r("fg")},children:E?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${r("widget-border")}`,background:r("input-bg"),flexShrink:0},children:t.jsxs("button",{onClick:z,style:{padding:"4px 12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px"},children:["← ",a.detailTab.basicInfo]})}),t.jsx("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:T})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(kr,{transport:e,onEntryClick:k,hideModeIndicator:n}),!h&&t.jsx(Pr,{transport:e,onNavigate:$,recommendedIds:o})]})}):t.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:r("bg"),color:r("fg")},children:[t.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:`1px solid ${r("widget-border")}`,display:"flex",flexDirection:"column",background:r("input-bg"),overflow:"hidden"},children:t.jsx("div",{style:{flex:1,overflow:"auto"},children:t.jsx(kr,{transport:e,onEntryClick:k,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:r("bg"),display:"flex",flexDirection:"column"},children:T})]})};function li(e){return{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${r("primary")}`:"2px solid transparent",background:"transparent",color:r(e?"primary":"desc-fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}const Qf=({pageData:e,rawImageUrl:n="",punctuations:i=[],title:o,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=g.useState(new Set),[h,u]=g.useState(null),[m,f]=g.useState("horizontal"),[x,v]=g.useState(!0),y=g.useRef(null),S=g.useCallback(k=>{p(new Set(k))},[]),b=g.useCallback(k=>{if(p($=>{const C=new Set($);return C.has(k)?C.delete(k):(C.clear(),C.add(k)),C}),y.current){const $=y.current.querySelector(`[data-char-id="${k}"]`);$&&$.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),w=()=>{var k;p(new Set),window.getSelection&&((k=window.getSelection())==null||k.removeAllRanges())},j=i.length>0?i:e.punctuations||[];return t.jsxs("div",{className:`guji-reader-container ${l}`,style:d,children:[t.jsxs("header",{className:"guji-reader-header",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a&&t.jsx("button",{type:"button",onClick:a,className:"guji-reader-btn",style:{marginRight:6},children:"‹ 返回"}),t.jsx("span",{className:"guji-reader-title",children:o||e.title}),s&&t.jsx("span",{style:{fontSize:"0.85rem",color:r("meta-fg")},children:s}),t.jsx("span",{className:"guji-reader-tag",children:"WebGL 客户端透视矫正对读"})]}),t.jsxs("div",{className:"guji-reader-actions",children:[t.jsxs("span",{style:{fontSize:"0.85rem",color:r("body-fg")},children:["已选字数: ",t.jsx("strong",{style:{color:r("accent")},children:c.size})]}),c.size>0&&t.jsx("button",{type:"button",onClick:w,className:"guji-reader-btn",children:"清除选中"}),t.jsx("button",{type:"button",onClick:()=>v(k=>!k),className:`guji-reader-btn ${x?"active":""}`,title:"独立外挂标点 (guji-punct v0.1)",children:x?"✓ 标点":"底本文本"}),t.jsx("button",{type:"button",onClick:()=>f(k=>k==="horizontal"?"vertical":"horizontal"),className:"guji-reader-btn primary",children:m==="horizontal"?"切换竖排":"切换横排"})]})]}),t.jsxs("div",{className:"guji-reader-body",children:[t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%",position:"sticky",top:0},children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:"底本书影 (WebGL 分带透视矫正 + 完整版心)"}),t.jsx("span",{className:"guji-pane-hint",children:"点击字框可联动文本定位"})]}),t.jsx("div",{className:"guji-pane-content",children:t.jsx(Ro,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:h,onCharClick:b,onCharHover:u})})]}),t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%"},ref:y,children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:m==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(Mo,{pageData:e,punctuations:j,selectedCharIds:c,hoveredCharId:h,onSelectionChange:S,onCharClick:b,onCharHover:u,mode:m,showPunctuation:x})]})]})]})},ex=e=>typeof e=="string"&&Array.from(e).length===1;function tx(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.punctuations)?e.punctuations:[],i=[];for(const o of n){if(!o||typeof o!="object")continue;const s=o;typeof s.anchor!="string"||typeof s.mark!="string"||s.pre_char!=null&&!ex(s.pre_char)||i.push({id:typeof s.id=="string"?s.id:void 0,anchor:s.anchor,mark:s.mark,kind:s.kind,pos:s.pos,pre_char:s.pre_char??void 0})}return i}function nx(e){var i;const n=e&&typeof e=="object"?e.pages:void 0;if(!Array.isArray(n))return null;for(const o of n){const s=/\/iiif\/([^/]+)\/canvas\/([^/]+)\//.exec(String(((i=o==null?void 0:o.canvas)==null?void 0:i.id)??""));if(s)return{bookId:s[1],vol:s[2]}}return null}const ix=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function st(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}const rx=new Set(["main","solo","jz_r","jz_l"]),ox=new Set(["body","banxin","blank"]);function sx(e){const n={};return typeof e.lane=="string"&&rx.has(e.lane)&&e.lane!=="main"&&(n.lane=e.lane),e.lacuna===!0&&(n.lacuna=!0),e.guess===!0&&(n.guess=!0),typeof e.zi=="string"&&e.zi&&(n.zi=e.zi),n}function ax(e){const n={};typeof e.kind=="string"&&ox.has(e.kind)&&e.kind!=="body"&&(n.kind=e.kind);const i=st(e.raised);i!==void 0&&Number.isInteger(i)&&i>0&&(n.raised=i);const o=st(e.lead_blank);return o!==void 0&&Number.isInteger(o)&&o>0&&(n.lead_blank=o),n}function ur(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(i=>!!i&&typeof i=="object"):[]}function lx(e,n){var c,p,h,u,m,f,x,v,y,S;const i=new Map,o=new Map;for(const b of ur(n)){const w=st(b.page);if(w!==void 0){i.set(w,b);for(const j of Array.isArray(b.cells)?b.cells:[]){const k=j==null?void 0:j.box;typeof(j==null?void 0:j.a)=="string"&&Array.isArray(k)&&k.length===4&&k.every($=>st($)!==void 0)&&o.set(j.a,[k[0],k[1],k[0]+k[2],k[1]+k[3]])}}}const s=[],a=new Map,l=new Map;for(const b of ur(e)){const w=st(b.page);w!==void 0&&typeof b.label=="string"&&b.label&&a.set(w,b.label)}for(const b of ur(e)){const w=st(b.page);if(w===void 0)continue;const j=[];for(const $ of Array.isArray(b.columns)?b.columns:[]){const C=st($==null?void 0:$.col);if(C===void 0)continue;const _=[];for(const z of Array.isArray($.cells)?$.cells:[]){const T=ix.exec(String((z==null?void 0:z.a)??""));if(!T||typeof z.c!="string")continue;const B=parseInt(T[3],10);_.push({id:z.a,char:z.c,slot:B,pos:B,sub:T[4]||null,bbox:o.get(z.a)??null,...sx(z)})}const E=ax($);(_.length>0||E.kind==="blank")&&j.push({col:C,chars:_,...E})}if(!j.some($=>$.chars.length>0)){j.length>0&&l.set(w,j);continue}j.sort(($,C)=>$.col-C.col);const k=i.get(w);s.push({page:w,seq:String(((c=k==null?void 0:k.canvas)==null?void 0:c.seq)??""),width:st((p=k==null?void 0:k.canvas)==null?void 0:p.width)??st((h=k==null?void 0:k.image)==null?void 0:h.width)??0,height:st((u=k==null?void 0:k.canvas)==null?void 0:u.height)??st((m=k==null?void 0:k.image)==null?void 0:m.height)??0,...typeof b.label=="string"&&b.label?{label:b.label}:{},columns:j})}const d=new Set(s.map(b=>b.page));for(const[b,w]of i){const j=(f=w==null?void 0:w.canvas)==null?void 0:f.seq;d.has(b)||typeof j!="string"&&typeof j!="number"||String(j)===""||s.push({page:b,seq:String(j),width:st((x=w.canvas)==null?void 0:x.width)??st((v=w.image)==null?void 0:v.width)??0,height:st((y=w.canvas)==null?void 0:y.height)??st((S=w.image)==null?void 0:S.height)??0,...a.has(b)?{label:a.get(b)}:{},columns:l.get(b)??[]})}return s.sort((b,w)=>b.page-w.page)}const cx=({data:e,onNavigate:n,className:i,style:o})=>{var h;const{t:s,convert:a}=ne(),[l,d]=g.useState(((h=e.divisions[0])==null?void 0:h.name)??null),[c,p]=g.useState(null);return t.jsxs("div",{className:i,style:o,children:[t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:r("fg"),margin:"0 0 8px"},children:a(e.title)}),e.stats&&t.jsxs("div",{style:{fontSize:"13px",color:r("desc-fg"),display:"flex",gap:"16px"},children:[e.total_volumes!=null&&t.jsxs("span",{children:[s("catalog.totalVolumes")," ",t.jsx("strong",{children:e.total_volumes})," ",s("unit.juan")]}),e.stats.zhulu!=null&&t.jsxs("span",{children:[s("catalogPage.zhulu")," ",t.jsx("strong",{children:e.stats.zhulu})," ",s("unit.bu")]}),e.stats.cunmu!=null&&t.jsxs("span",{children:[s("catalogPage.cunmu")," ",t.jsx("strong",{children:e.stats.cunmu})," ",s("unit.bu")]}),e.stats.categories!=null&&t.jsx("span",{children:s("catalogPage.categoriesN",{n:e.stats.categories})})]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.divisions.map(u=>t.jsx(dx,{division:u,expanded:l===u.name,onToggle:()=>d(l===u.name?null:u.name),expandedCat:c,onCatToggle:m=>p(c===m?null:m),onNavigate:n},u.name))})]})},dx=({division:e,expanded:n,onToggle:i,expandedCat:o,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=ne(),c=e.categories.reduce((p,h)=>{const u=h.stats||{zhulu:0,cunmu:0};return p+(u.zhulu||0)+(u.cunmu||0)},0);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:"none",background:n?`color-mix(in srgb, ${r("primary")} 6%, transparent)`:r("bg"),cursor:"pointer",fontSize:"15px",fontWeight:600,color:r("fg"),textAlign:"left"},children:[t.jsx("span",{children:d(e.name)}),t.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg")},children:[l("catalogPage.divisionStat",{cats:e.categories.length,books:c}),t.jsx("span",{style:{marginLeft:"8px"},children:n?"▲":"▼"})]})]}),n&&t.jsx("div",{style:{padding:"4px 0"},children:e.categories.map(p=>{const h=`${e.name}/${p.name}`;return t.jsx(px,{category:p,expanded:o===h,onToggle:()=>s(h),onNavigate:a},p.name)})})]})},px=({category:e,expanded:n,onToggle:i,onNavigate:o})=>{var p,h,u,m;const{t:s,convert:a}=ne(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((h=e.books)==null?void 0:h.cunmu)||[],c=(((u=e.stats)==null?void 0:u.zhulu)||l.length)+(((m=e.stats)==null?void 0:m.cunmu)||d.length);return t.jsxs("div",{children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px 6px 28px",border:"none",background:n?r("input-bg"):"transparent",cursor:"pointer",fontSize:"13px",color:r("fg"),textAlign:"left"},children:[t.jsxs("span",{style:{fontWeight:500},children:[a(e.name),e.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:a(e.volumes)})})]}),t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[s("catalogPage.booksN",{n:c})," ",n?"▲":"▼"]})]}),n&&(l.length>0||d.length>0)&&t.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[l.length>0&&t.jsx(ja,{label:s("catalogPage.zhulu"),books:l,onNavigate:o}),d.length>0&&t.jsx(ja,{label:s("catalogPage.cunmu"),books:d,onNavigate:o})]})]})},ja=({label:e,books:n,onNavigate:i})=>{const{t:o,convert:s}=ne(),a=tt(),[l,d]=g.useState(n.length<=20),c=l?n:n.slice(0,10);return t.jsxs("div",{style:{marginBottom:"8px"},children:[t.jsxs("div",{style:{fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},children:[e," (",n.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((p,h)=>t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[t.jsx("span",{style:{fontWeight:500,color:r("fg")},children:p.work_id&&i?t.jsx("a",{href:a(p.work_id),onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),i(p.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`},children:s(p.title)}):s(p.title)}),p.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:s(p.volumes)}),p.author&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:s(p.author).slice(0,20)})]},h))}),!l&&t.jsx("button",{onClick:()=>d(!0),style:{marginTop:"4px",padding:"2px 12px",fontSize:"11px",color:r("primary"),background:"transparent",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:o("catalogPage.expandAllN",{n:n.length})})]})},kt=({title:e,onSave:n,onAskAI:i,extraButtons:o,children:s})=>{const a=Ee();return t.jsxs("div",{style:{background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",paddingBottom:"8px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:r("fg")},children:e}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[o,i&&t.jsx("button",{onClick:i,style:mx,children:"AI"}),n&&t.jsx("button",{onClick:n,style:ux,children:a.action.save})]})]}),s]})},ux={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},mx={padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},ht=({label:e,value:n,onChange:i,placeholder:o,disabled:s})=>t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:{display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},children:e}),t.jsx("input",{type:"text",value:n,onChange:a=>i(a.target.value),placeholder:o,disabled:s,style:{width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]}),tn=({value:e,onChange:n,placeholder:i})=>{const o=g.useRef(null);return g.useEffect(()=>{o.current&&(o.current.style.height="auto",o.current.style.height=`${o.current.scrollHeight}px`)},[e]),t.jsx("textarea",{ref:o,value:e||"",onChange:s=>n(s.target.value),placeholder:i,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},ji=({children:e,color:n,style:i})=>t.jsx("span",{style:{display:"inline-block",padding:"2px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",background:n||r("primary-soft"),color:r(n?"on-color-fg":"fg"),...i},children:e});function hx(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const mi=({value:e,onChange:n,label:i})=>{const[o,s]=g.useState(!1),a=g.useRef(null),l=hx(e||"");return g.useEffect(()=>{o&&a.current&&a.current.focus()},[o]),!o&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:va,children:i}),t.jsxs("div",{onClick:()=>s(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:`1px solid ${r("input-border")}`,borderRadius:"2px",background:r("input-bg"),cursor:"pointer",minHeight:"30px"},children:[t.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:r("fg")},children:l.name}),t.jsx(ji,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:va,children:i}),t.jsx("input",{ref:a,type:"text",value:e||"",onChange:d=>n(d.target.value),onBlur:()=>s(!1),style:{width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},va={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500};function gx(e){switch(e){case"url":return r("source-url");case"bookID":return r("source-bookid");default:return r("desc-fg")}}function fx(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const Kc=({items:e,onChange:n,onOpenEntityPicker:i})=>{const o=Ee(),[s,a]=g.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=u=>{n(e.filter((m,f)=>f!==u)),s===u&&a(null)},c=(u,m,f)=>{const x=[...e];x[u]={...x[u],[m]:f},n(x)},p=(u,m)=>{const f=[...e];f[u]={...f[u],type:m,id:"",name:""},n(f),m==="bookID"&&i&&i(x=>{const v=[...e];v[u]={...v[u],id:x.id,name:x.title,type:"bookID"},n(v)})},h=u=>{i&&i(m=>{const f=[...e];f[u]={...f[u],id:m.id,name:m.title,type:"bookID"},n(f)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((u,m)=>t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>a(s===m?null:m),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===m?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:r("fg")},children:u.name||`${o.editor.sourcePlaceholder} ${m+1}`}),u.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:gx(u.type),color:r("on-color-fg"),borderRadius:"3px",fontWeight:500},children:fx(u.type)}),t.jsx("button",{onClick:f=>{f.stopPropagation(),d(m)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:o.editor.deleteThisSource,children:"✕"})]}),s===m&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!u.type&&t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:o.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(m,"bookID"),style:{...ka,borderColor:r("source-bookid"),color:r("source-bookid")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"📚"}),t.jsx("span",{children:"Book ID"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.fromExistingBook})]}),t.jsxs("button",{onClick:()=>p(m,"url"),style:{...ka,borderColor:r("source-url"),color:r("source-url")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),t.jsx("span",{children:"URL"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.enterUrl})]})]})]}),u.type==="bookID"&&t.jsx(t.Fragment,{children:t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:Rt,children:o.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const f=[...e];f[m]={...f[m],type:"",id:"",name:""},n(f)},style:wa,children:o.action.changeType})]}),u.id&&u.name?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:r("bg"),border:`1px solid ${r("source-bookid")}`,borderRadius:"6px"},children:[t.jsx("span",{style:{color:r("source-bookid"),fontSize:"16px"},children:"✓"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:u.name}),t.jsx("code",{style:{fontSize:"11px",background:r("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:u.id})]}),t.jsx("button",{onClick:()=>h(m),style:{background:"transparent",border:`1px solid ${r("widget-border")}`,color:r("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:o.action.reselect})]}):t.jsxs("button",{onClick:()=>h(m),style:{width:"100%",padding:"14px",border:`2px dashed ${r("widget-border")}`,borderRadius:"6px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[t.jsx("span",{children:"🔍"}),t.jsx("span",{children:o.action.clickToSelectBookOrWork})]})]})}),u.type==="url"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:Rt,children:o.label.sourceName}),t.jsx("button",{onClick:()=>{const f=[...e];f[m]={...f[m],type:"",id:"",name:""},n(f)},style:wa,children:o.action.changeType})]}),t.jsx("input",{type:"text",value:u.name,onChange:f=>c(m,"name",f.target.value),placeholder:o.editor.sourceNamePlaceholder,style:ln})]}),t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:o.label.urlAddress}),t.jsx("input",{type:"text",value:u.id,onChange:f=>c(m,"id",f.target.value),placeholder:"https://...",style:ln})]})]}),u.type&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{borderTop:`1px dashed ${r("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:t.jsx("label",{style:{...Rt,opacity:.7},children:o.label.optionalInfo})}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:o.label.detailsOptional}),t.jsx("input",{type:"text",value:u.details,onChange:f=>c(m,"details",f.target.value),placeholder:o.editor.detailsPlaceholder,style:ln})]}),t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:o.label.positionOptional}),t.jsx("input",{type:"text",value:u.position,onChange:f=>c(m,"position",f.target.value),placeholder:"如: 卷三, p.52",style:ln})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:o.label.dataVersionOptional}),t.jsx("input",{type:"text",value:u.version,onChange:f=>c(m,"version",f.target.value),placeholder:"如: v1.0, 2024-01",style:ln})]}),t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:o.label.processorVersionOptional}),t.jsx("input",{type:"text",value:u.processor_version,onChange:f=>c(m,"processor_version",f.target.value),placeholder:"如: v0.1",style:ln})]})]})]})]})})]},m)),t.jsxs("button",{onClick:l,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:o.action.addSource})]})]})},Rt={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},ln={width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},ka={flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",padding:"16px 12px",background:r("bg"),border:"2px solid",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:500,transition:"all 0.2s"},wa={background:"transparent",border:"none",color:r("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function Xc(e){if(!e||!e.trim())return[];try{const n=JSON.parse(e);if(Array.isArray(n))return n.map(i=>({id:i.id||"",name:i.name||"",type:i.type||"",details:i.details||"",position:i.position||"",version:i.version||"",processor_version:i.processor_version||""}))}catch{}return[]}function Zc(e){return!e||e.length===0?"":JSON.stringify(e)}const Jc=({entityType:e,entityId:n,entityTitle:i,parentWork:o,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:h,onLinkEntity:u,onUnlinkEntity:m,onViewEntity:f,onCreateAndLink:x,onSaveRelations:v})=>{const y=Ee();return t.jsxs("div",{style:{background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:"🔗"}),t.jsx("span",{children:y.section.relations})]}),v&&t.jsx("button",{onClick:v,style:xx,children:y.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(Tn,{direction:"up",title:y.relation.belongsToWork,entity:a,onView:f,onUnlink:()=>m("workId"),onLink:()=>u("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(Tn,{direction:"up",title:y.relation.containedInCollection,entity:l,onView:f,onUnlink:()=>m("collectionId"),onLink:()=>u("collectionId","collection"),onCreate:()=>x("collectionId","collection",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),a&&h&&h.length>0&&t.jsx(cn,{direction:"horizontal",title:`${y.relation.siblingVersions} (${h.length})`,entities:h,onView:f,onAdd:()=>x("siblingBook","book",{workId:a.id}),addLabel:y.relation.addVersionForWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="work"&&t.jsxs(t.Fragment,{children:[t.jsx(Tn,{direction:"up",title:y.relation.parentWork,entity:o,onView:f,onUnlink:()=>m("parentWorkId"),onLink:()=>u("parentWorkId","work"),onCreate:()=>x("parentWorkId","work"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),d&&d.length>0&&t.jsx(cn,{direction:"down",title:`${y.relation.childWorks} (${d.length})`,entities:d,onView:f,onAdd:()=>x("childWork","work",{parentWorkId:n}),addLabel:y.action.addSubWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),c&&c.length>0&&t.jsx(cn,{direction:"down",title:`${y.relation.collectionImpl} (${c.length})`,entities:c,onView:f,onAdd:()=>x("childCollection","collection",{workId:n}),addLabel:y.action.addCollectionImpl,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(cn,{direction:"down",title:`${y.relation.allVersions} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{workId:n}),addLabel:y.action.addVersion,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="collection"&&t.jsxs(t.Fragment,{children:[t.jsx(Tn,{direction:"up",title:y.relation.correspondingWork,entity:a,onView:f,onUnlink:()=>m("workId"),onLink:()=>u("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(Tn,{direction:"up",title:y.relation.parentCollection,entity:s,onView:f,onUnlink:()=>m("parentCollectionId"),onLink:()=>u("parentCollectionId","collection"),onCreate:()=>x("parentCollectionId","collection"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(cn,{direction:"down",title:`${y.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:f,onAdd:()=>x("childCollection","collection",{parentCollectionId:n}),addLabel:y.action.addSubCollection,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(cn,{direction:"down",title:`${y.relation.containedBooks} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{collectionId:n}),addLabel:y.action.addBook,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]})]})]})},Tn=({direction:e,title:n,entity:i,onView:o,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:h,unlinkLabel:u})=>{const m=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),f=e==="up"?"⬆️":e==="down"?"⬇️":"↔️";return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:m,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:f}),t.jsx("span",{children:n})]}),i?t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:r("bg"),borderRadius:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Qc(i.type)}),t.jsx("span",{style:{fontWeight:500},children:i.title}),t.jsx("span",{style:{fontSize:"11px",opacity:.6},children:i.id})]}),t.jsxs("div",{style:{display:"flex",gap:"4px"},children:[t.jsx(Sa,{onClick:()=>o(i),title:h,children:"👁️"}),t.jsx(Sa,{onClick:s,title:u,danger:!0,children:"✕"})]})]}):t.jsx("div",{style:{padding:"8px",background:r("bg"),borderRadius:"4px",color:r("desc-fg"),fontSize:"12px",textAlign:"center"},children:p}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsx(Br,{onClick:a,children:d}),t.jsx(Br,{onClick:l,primary:!0,children:c})]})]})},cn=({direction:e,title:n,entities:i,onView:o,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=g.useState(!1),h=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),u=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",m=c?i:i.slice(0,5);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:h,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:u}),t.jsx("span",{children:n})]}),i.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[m.map(f=>t.jsxs("div",{onClick:()=>o(f),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:r("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[t.jsx("span",{children:Qc(f.type)}),t.jsx("span",{children:f.title})]},f.id)),i.length>5&&!c&&t.jsxs("div",{onClick:()=>p(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:r("link-fg"),cursor:"pointer"},children:[d," (",i.length-5,")"]})]}):t.jsx("div",{style:{padding:"8px",background:r("bg"),borderRadius:"4px",color:r("desc-fg"),fontSize:"12px",textAlign:"center"},children:l}),t.jsx("div",{style:{marginTop:"8px"},children:t.jsxs(Br,{onClick:s,primary:!0,children:["+ ",a]})})]})},Sa=({onClick:e,title:n,danger:i,children:o})=>t.jsx("button",{onClick:s=>{s.stopPropagation(),e()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:i?r("danger"):"inherit",opacity:.7},children:o}),Br=({onClick:e,primary:n,children:i})=>t.jsx("button",{onClick:e,style:{padding:"4px 10px",fontSize:"11px",border:n?"none":`1px solid ${r("widget-border")}`,borderRadius:"4px",background:n?r("primary"):"transparent",color:n?r("primary-fg"):"inherit",cursor:"pointer"},children:i});function Qc(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const xx={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},ed=({isOpen:e,entityType:n,title:i,onSelect:o,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[h,u]=g.useState(""),m=p?l.filter(y=>y.id!==p):l;g.useEffect(()=>{e&&(u(""),d(""))},[e]);const f=y=>{u(y),d(y)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",v=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:bx,children:t.jsxs("div",{style:yx,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:i}),t.jsx("button",{onClick:s,style:jx,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:h,onChange:y=>f(y.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:vx})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:mr,children:"搜索中..."}):m.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:m.map(y=>t.jsxs("div",{onClick:()=>o(y),style:kx,children:[t.jsx("span",{style:{fontSize:"16px"},children:v}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[y.title,y.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:y.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[y.id,y.author&&` · ${y.author}`,y.dynasty&&` · ${y.dynasty}`]})]})]},y.id))}):h?t.jsxs("div",{style:mr,children:["未找到匹配的",x]}):t.jsxs("div",{style:mr,children:["输入关键词搜索",x]})}),t.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsxs("button",{onClick:a,style:wx,children:["创建新",x,"并关联"]})]})]})})},bx={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},yx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",width:"500px",maxWidth:"calc(100vw - 32px)",maxHeight:"70vh",display:"flex",flexDirection:"column",boxShadow:r("shadow-dialog")},jx={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},vx={width:"100%",padding:"10px 12px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"},kx={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:r("primary-soft")},mr={padding:"20px",textAlign:"center",color:r("desc-fg")},wx={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},_a={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},Sx={work:"📜",book:"📖",collection:"📚",entity:"👤"},td=({isOpen:e,entityType:n,relationField:i,inheritData:o,onConfirm:s,onCancel:a})=>{const[l,d]=g.useState(""),c=g.useRef(null);g.useEffect(()=>{e&&(d((o==null?void 0:o.title)||""),setTimeout(()=>{var m,f;(m=c.current)==null||m.focus(),(f=c.current)==null||f.select()},100))},[e,o==null?void 0:o.title]);const p=m=>{m.key==="Enter"&&l.trim()?h():m.key==="Escape"&&a()},h=()=>{l.trim()&&s(l.trim(),{...o,title:l.trim()})};if(!e)return null;const u=()=>{switch(i){case"parentWorkId":return"创建父作品";case"workId":return"创建所属作品";case"collectionId":return"创建所属丛编";case"parentCollectionId":return"创建父丛编";case"childWork":return"创建子作品";case"childBook":case"siblingBook":return"创建书籍";case"childCollection":return"创建子丛编";default:return`创建新${_a[n]}`}};return t.jsx("div",{style:_x,onClick:m=>{m.target===m.currentTarget&&a()},children:t.jsxs("div",{style:$x,onClick:m=>m.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Sx[n]}),t.jsx("span",{children:u()})]}),t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:r("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",t.jsx("span",{style:{color:r("danger"),marginLeft:"4px"},children:"*"})]}),t.jsx("input",{ref:c,type:"text",value:l,onChange:m=>d(m.target.value),onKeyDown:p,placeholder:`请输入${_a[n]}名称...`,style:Cx})]}),((o==null?void 0:o.author)||(o==null?void 0:o.dynasty))&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),background:r("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[t.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(o==null?void 0:o.author)&&t.jsxs("div",{children:["作者: ",o.author]}),(o==null?void 0:o.dynasty)&&t.jsxs("div",{children:["朝代/年份: ",o.dynasty]})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[t.jsx("button",{onClick:a,style:Tx,children:"取消"}),t.jsx("button",{onClick:h,disabled:!l.trim(),style:{...zx,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},_x={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},$x={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:r("shadow-dialog")},Cx={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box"},Tx={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},zx={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg")};function Nx(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function nd(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Ix(e){switch(e){case"work":return r("editor-type-work");case"collection":return r("editor-type-collection");case"book":return r("editor-type-book");default:return r("desc-fg")}}const id=({isOpen:e,title:n,filterType:i="all",recentEntities:o=[],excludeId:s,showCreateButton:a=!1,createButtonText:l,onSelect:d,onCancel:c,onCreate:p,onSearch:h})=>{const[u,m]=g.useState(""),[f,x]=g.useState([]),[v,y]=g.useState(!1),[S,b]=g.useState("recent");g.useEffect(()=>{e&&(m(""),x([]),b(o.length>0?"recent":"search"))},[e,o.length]),g.useEffect(()=>{if(!u.trim()){x([]);return}const _=setTimeout(async()=>{y(!0);try{x(await h(u,i))}catch{x([])}finally{y(!1)}},300);return()=>clearTimeout(_)},[u,i,h]);const w=g.useCallback(_=>{m(_.target.value),_.target.value.trim()&&b("search")},[]),j=g.useCallback(_=>s?_.filter(E=>E.id!==s):_,[s]);if(!e)return null;const k=n||(i==="all"?"选择实体":`选择${nd(i)}`),$=j(o),C=j(f);return t.jsx("div",{style:Ex,children:t.jsxs("div",{style:Lx,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:k}),t.jsx("button",{onClick:c,style:Ax,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:u,onChange:w,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Mx}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),v&&t.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),$.length>0&&t.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs($a,{active:S==="recent",onClick:()=>b("recent"),children:["最近使用 (",$.length,")"]}),t.jsxs($a,{active:S==="search",onClick:()=>b("search"),children:["搜索结果 ",C.length>0&&`(${C.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:S==="recent"&&$.length>0?t.jsx(Ca,{entities:$,onSelect:d}):u.trim()?v?t.jsx(hr,{message:"搜索中..."}):C.length>0?t.jsx(Ca,{entities:C,onSelect:d}):t.jsx(hr,{message:"未找到匹配的结果"}):t.jsx(hr,{message:"输入关键词开始搜索"})}),a&&p&&t.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsx("button",{onClick:p,style:Px,children:l||"创建新实体"})]})]})})},$a=({active:e,onClick:n,children:i})=>t.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${r("primary")}`:"2px solid transparent",background:"transparent",color:r(e?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:e?600:400,marginBottom:"-1px"},children:i}),Ca=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(i=>t.jsx(Rx,{entity:i,onClick:()=>n(i)},i.id))}),Rx=({entity:e,onClick:n})=>{const[i,o]=g.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:r("primary-soft"),transition:"background 0.1s"},children:[t.jsx("span",{style:{fontSize:"18px"},children:Nx(e.type)}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{fontWeight:500,fontSize:"13px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[e.title,e.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:r("desc-fg"),marginLeft:"4px"},children:e.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7,display:"flex",alignItems:"center",gap:"6px",marginTop:"2px"},children:[t.jsx("code",{style:{fontSize:"10px",background:r("primary-soft"),padding:"1px 4px",borderRadius:"2px"},children:e.id}),e.author&&t.jsx("span",{children:e.author}),e.dynasty&&t.jsx("span",{children:e.dynasty})]})]}),t.jsx("span",{style:{fontSize:"10px",padding:"3px 8px",background:Ix(e.type),color:r("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:nd(e.type)})]})},hr=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:e}),Ex={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Lx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",width:"550px",maxWidth:"calc(100vw - 32px)",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:r("shadow-dialog")},Ax={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Mx={width:"100%",padding:"12px 16px",paddingLeft:"40px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"},Px={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Bx={work:r("editor-type-work"),collection:r("editor-type-collection"),book:r("editor-type-book"),entity:r("editor-type-entity")},Wx={work:"📜",collection:"📚",book:"📖",entity:"👤"},rd=({data:e,onChange:n,onSave:i,transport:o,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:h,relations:u,onRelationsChange:m})=>{var be;const f=Ee(),[x,v]=g.useState(!1),[y,S]=g.useState("work"),[b,w]=g.useState(""),[j,k]=g.useState(""),[$,C]=g.useState([]),[_,E]=g.useState(!1),[z,T]=g.useState(!1),[B,W]=g.useState("work"),[N,A]=g.useState(""),[F,Y]=g.useState(),[ee,se]=g.useState(!1),[D,V]=g.useState(null),[he,Z]=g.useState([]);g.useRef(null);const M=e.type,_e=M==="work",ce=M==="collection",ge=M==="book",le=g.useCallback((X,re)=>{n({...e,[X]:re})},[e,n]),Be=g.useCallback((X,re)=>{w(X),S(re),k(f.editor.selectToLink+f.indexType[re]),C([]),v(!0)},[f]),ze=g.useCallback(X=>{o!=null&&o.unlinkEntity&&o.unlinkEntity(e.id,X)},[o,e.id]),Fe=g.useCallback(X=>{s==null||s(X.id,X.type)},[s]),te=g.useCallback((X,re,Ce)=>{const We={...Ce,author:(Ce==null?void 0:Ce.author)||e.author,dynasty:Ce==null?void 0:Ce.dynasty};W(re),A(X),Y(We),T(!0)},[e.author]),H=g.useCallback((X,re)=>{o!=null&&o.createAndLink&&o.createAndLink(e.id,N,{type:B,title:X,inheritData:re}),T(!1)},[o,e.id,N,B]),G=g.useCallback(X=>{if(!X.trim()){C([]);return}E(!0),o!=null&&o.searchEntities&&o.searchEntities(X,y).then(re=>{C(re),E(!1)}).catch(()=>{C([]),E(!1)})},[o,y]),xe=g.useCallback(X=>{o!=null&&o.linkEntity&&o.linkEntity(e.id,b,X.id),v(!1)},[o,e.id,b]),K=g.useCallback(()=>{i()},[i]),L=g.useCallback(X=>{V(()=>X),se(!0),o!=null&&o.getRecentEntities&&o.getRecentEntities().then(Z).catch(()=>{})},[o]),q=g.useCallback((X,re)=>o!=null&&o.searchEntities?o.searchEntities(X,re==="all"?void 0:re):Promise.resolve([]),[o]),ae=g.useCallback(X=>{o!=null&&o.addRecentEntity&&o.addRecentEntity(X),Z(re=>[X,...re.filter(Ce=>Ce.id!==X.id)].slice(0,10)),D==null||D(X),se(!1),V(null)},[o,D]);return t.jsxs("div",{style:{padding:"16px",maxWidth:"900px",margin:"0 auto"},children:[t.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:`1px solid ${r("widget-border")}`,paddingBottom:"16px"},children:t.jsxs("h1",{style:{fontSize:"20px",fontWeight:600,margin:0,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Wx[M]}),t.jsx("span",{children:e.title||f.editor.untitled}),t.jsx(ji,{children:e.id}),t.jsx(ji,{color:Bx[M],children:f.indexType[M]})]})}),t.jsx(kt,{title:f.section.basicInfo,onSave:i,onAskAI:d?()=>d("基本信息"):void 0,extraButtons:c==null?void 0:c("基本信息"),children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[t.jsx(mi,{label:_e?f.editor.workTitle:ce?f.editor.collectionTitle:f.editor.bookTitle,value:e.title,onChange:X=>le("title",X)}),ge&&t.jsx(mi,{label:f.editor.belongsToWork,value:e.workName||"",onChange:X=>le("workName",X)}),t.jsx(ht,{label:f.editor.authorLabel,value:e.author||"",onChange:X=>le("author",X)}),t.jsx(ht,{label:f.editor.publicationYearLabel,value:e.publicationYear||"",onChange:X=>le("publicationYear",X)}),(ge||ce)&&t.jsx(mi,{label:f.editor.containedIn,value:e.collection||"",onChange:X=>le("collection",X)}),(ge||ce)&&t.jsx(ht,{label:f.editor.holderLabel,value:e.holder||"",onChange:X=>le("holder",X)}),(ge||ce)&&t.jsx(ht,{label:ge?f.editor.pageLabel:f.editor.volumeLabel,value:e.pages||"",onChange:X=>le("pages",X)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(ht,{label:f.editor.firstImageLabel,value:e.firstImage||"",onChange:X=>le("firstImage",X)})})]})}),t.jsx(kt,{title:f.section.description,onSave:i,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(tn,{value:e.description||"",onChange:X=>le("description",X),placeholder:f.editor.descriptionPlaceholder})}),(((be=e.additional_works)==null?void 0:be.length)||0)>0&&t.jsx(kt,{title:f.section.additionalWorks,onSave:i,children:t.jsx(Ox,{items:e.additional_works||[],onChange:X=>le("additional_works",X)})}),t.jsx(kt,{title:f.section.indexedBy,onSave:i,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(Fx,{items:e.indexed_by||[],onChange:X=>le("indexed_by",X)})}),t.jsx(kt,{title:f.section.emendatedBy,onSave:i,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(Hx,{items:e.emendated_by||[],onChange:X=>le("emendated_by",X)})}),t.jsx(kt,{title:f.section.textResources,onSave:i,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(jr,{items:e.resources||[],onChange:X=>le("resources",X),onDownload:p,downloadStatuses:h,filterType:"text"})}),t.jsx(kt,{title:f.section.imageResources,onSave:i,children:t.jsx(jr,{items:e.resources||[],onChange:X=>le("resources",X),onDownload:p,downloadStatuses:h,filterType:"image"})}),t.jsx(kt,{title:f.section.sources,onSave:i,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(Kc,{items:Xc(e.sources||""),onChange:X=>le("sources",Zc(X)),onOpenEntityPicker:L})}),(ge||ce)&&t.jsx(kt,{title:f.section.provenance,onSave:i,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(tn,{value:e.provenance||"",onChange:X=>le("provenance",X),placeholder:f.editor.provenancePlaceholder})}),ge&&t.jsx(kt,{title:f.section.otherEditions,onSave:i,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(tn,{value:e.otherEditions||"",onChange:X=>le("otherEditions",X),placeholder:f.editor.otherEditionsPlaceholder})}),t.jsx(Jc,{entityType:M,entityId:e.id,entityTitle:e.title,parentWork:u==null?void 0:u.parentWork,parentCollection:u==null?void 0:u.parentCollection,belongsToWork:u==null?void 0:u.belongsToWork,belongsToCollection:u==null?void 0:u.belongsToCollection,childWorks:u==null?void 0:u.childWorks,childCollections:u==null?void 0:u.childCollections,containedBooks:u==null?void 0:u.containedBooks,siblingBooks:u==null?void 0:u.siblingBooks,onLinkEntity:Be,onUnlinkEntity:ze,onViewEntity:Fe,onCreateAndLink:te,onSaveRelations:K}),a&&l&&t.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${r("danger-soft-border")}`,background:r("danger-soft-bg"),borderRadius:"4px"},children:[t.jsx("div",{style:{color:r("danger"),fontWeight:600,marginBottom:"8px"},children:f.section.dangerZone}),t.jsx("p",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"12px"},children:f.editor.dangerZoneDesc}),t.jsx("button",{onClick:l,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("danger")}`,borderRadius:"4px",background:"transparent",color:r("danger"),cursor:"pointer"},children:f.editor.deleteEntity})]}),t.jsx(ed,{isOpen:x,entityType:y,title:j,onSelect:xe,onCancel:()=>v(!1),onCreate:()=>{v(!1),te(b,y)},searchResults:$,onSearch:G,isLoading:_,excludeId:e.id}),t.jsx(td,{isOpen:z,entityType:B,relationField:N,inheritData:F,onConfirm:H,onCancel:()=>T(!1)}),t.jsx(id,{isOpen:ee,title:f.action.selectBookOrWork,filterType:"all",recentEntities:he,excludeId:e.id,onSelect:ae,onCancel:()=>{se(!1),V(null)},onSearch:q})]})};function Ox({items:e,onChange:n}){const i=Ee(),o=(l,d,c)=>{const p=e.map((h,u)=>u===l?{...h,[d]:c}:h);n(p)},s=l=>n(e.filter((d,c)=>c!==l)),a=()=>n([...e,{book_title:""}]);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((l,d)=>t.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[t.jsx(ht,{label:i.editor.bookNameLabel,value:l.book_title,onChange:c=>o(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(ht,{label:i.label.juanCount,value:l.n_juan!=null?String(l.n_juan):"",onChange:c=>o(d,"n_juan",c&&parseInt(c,10)||void 0)})}),t.jsx("button",{onClick:()=>s(d),style:{padding:"4px 8px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("muted"),marginTop:"18px"},children:"✕"})]},d)),t.jsx("button",{onClick:a,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${r("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("desc-fg"),alignSelf:"flex-start"},children:i.action.addAdditionalWork})]})}function od({items:e,onChange:n,showMeta:i,addLabel:o}){const s=Ee(),[a,l]=g.useState(null),d=(h,u,m)=>{const f=e.map((x,v)=>v===h?{...x,[u]:m||void 0}:x);n(f)},c=h=>{n(e.filter((u,m)=>m!==h)),a===h&&l(null)},p=()=>{n([...e,{source:""}]),l(e.length)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((h,u)=>{const m=a===u;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:m?`color-mix(in srgb, ${r("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(m?null:u),children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.2s",transform:m?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:h.source||s.editor.unnamedSource}),h.source_bid&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:h.source_bid}),t.jsx("button",{onClick:f=>{f.stopPropagation(),c(u)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${r("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:r("muted")},children:"✕"})]}),!m&&i&&(h.title_info||h.author_info)&&t.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:r("desc-fg")},children:[h.title_info,h.title_info&&h.author_info&&" — ",h.author_info]}),m&&t.jsxs("div",{style:{padding:"8px 12px 12px",display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(ht,{label:s.label.sourceName,value:h.source,onChange:f=>d(u,"source",f)}),t.jsx(ht,{label:s.label.sourceBid,value:h.source_bid||"",onChange:f=>d(u,"source_bid",f)})]}),i&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(ht,{label:s.label.titleInfo,value:h.title_info||"",onChange:f=>d(u,"title_info",f)}),t.jsx(ht,{label:s.label.authorInfo,value:h.author_info||"",onChange:f=>d(u,"author_info",f)})]}),t.jsx(ht,{label:s.label.edition,value:h.edition||"",onChange:f=>d(u,"edition",f)})]}),t.jsx(tn,{value:h.summary||"",onChange:f=>d(u,"summary",f),placeholder:s.editor.summaryPlaceholder}),t.jsx(tn,{value:h.comment||"",onChange:f=>d(u,"comment",f),placeholder:s.editor.commentPlaceholder}),t.jsx(tn,{value:h.additional_comment||"",onChange:f=>d(u,"additional_comment",f),placeholder:s.editor.additionalCommentPlaceholder})]})]},u)}),t.jsx("button",{onClick:p,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${r("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("desc-fg"),alignSelf:"flex-start"},children:o})]})}function Fx({items:e,onChange:n}){const i=Ee();return t.jsx(od,{items:e,onChange:n,showMeta:!0,addLabel:i.action.addIndexedBy})}function Hx({items:e,onChange:n}){const i=Ee();return t.jsx(od,{items:e,onChange:n,addLabel:i.action.addEmendatedBy})}function sd(e){var d,c,p,h,u,m,f;const n=((c=(d=e.authors)==null?void 0:d[0])==null?void 0:c.name)||"",i=((p=e.publication_info)==null?void 0:p.year)||"",o=((h=e.current_location)==null?void 0:h.name)||"",s=(u=e.page_count)!=null&&u.number?String(e.page_count.number):((m=e.page_count)==null?void 0:m.description)||"",a=typeof e.description=="object"&&e.description!==null&&e.description.text||"",l={id:e.id,title:e.title,type:e.type,author:n,publicationYear:i,holder:o,pages:s,description:a,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};if(e.type==="work"){const x=e;if(Array.isArray(x.related_works)){const v=x.related_works.find(y=>y.relation==="part_of");v&&(l.parentWorkId=v.id,l.parentWorkName=v.title)}}if(e.type==="book"){const x=e;l.workId=x.work_id,Array.isArray(x.contained_in)&&x.contained_in.length>0&&(l.collectionId=(f=x.contained_in[0])==null?void 0:f.id)}return l}function Dx(e){const n={id:e.id,title:e.title,type:e.type,description:e.description?{text:e.description}:void 0,authors:e.author?[{name:e.author}]:void 0,publication_info:e.publicationYear?{year:e.publicationYear}:void 0,current_location:e.holder?{name:e.holder}:void 0,page_count:e.pages?{number:parseInt(e.pages)||0,description:e.pages}:void 0,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};return e.type==="work"&&e.parentWorkId&&(n.related_works=[{id:e.parentWorkId,title:e.parentWorkName||"",relation:"part_of"}]),e.type==="book"&&(n.work_id=e.workId,e.collectionId&&(n.contained_in=[{id:e.collectionId}])),n}const Ux=e=>{const{data:n,id:i,transport:o,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:h,onAskAI:u,renderSectionActions:m,onDownloadResource:f,downloadStatuses:x,relations:v,onRelationsChange:y,headerExtra:S,className:b,style:w}=e,j=Ee(),[k,$]=g.useState(s),C=a?s:k;g.useEffect(()=>{s!==k&&$(s)},[s]);const _=g.useCallback(()=>{const A=C==="view"?"edit":"view";a?a(A):$(A)},[C,a]),[E,z]=g.useState(null);g.useEffect(()=>{i&&o&&o.getItem(i).then(A=>{A&&z(A)})},[i,o]);const T=n||E,B=g.useMemo(()=>T?sd(T):null,[T]),W=a||!n?t.jsx("button",{onClick:_,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:C==="edit"?r("accent-bg"):"transparent",color:r(C==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:C==="view"?j.common.switchToEdit:j.common.switchToView,children:C==="view"?j.common.modeEdit:j.common.modeView}):null,N=t.jsxs(t.Fragment,{children:[W,S]});return!T&&!B?t.jsx(nn,{}):C==="view"?t.jsx(to,{data:T,transport:o,onNavigate:p?A=>p(A):void 0,renderLink:h,headerExtra:N,className:b,style:w}):B?t.jsxs("div",{className:b,style:w,children:[N&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:N}),t.jsx(rd,{data:B,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:o,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:u,renderSectionActions:m,onDownloadResource:f,downloadStatuses:x,relations:v,onRelationsChange:y})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:r("muted")},children:j.common.noData})},Vx=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],ad=({isOpen:e,onClose:n,onSubmit:i,feedbackListUrl:o})=>{const{t:s}=ne(),[a,l]=g.useState(null),[d,c]=g.useState(""),[p,h]=g.useState(""),[u,m]=g.useState("idle"),[f,x]=g.useState(""),v=g.useRef(null);g.useEffect(()=>{e&&(l(null),c(""),h(""),m("idle"),x(""))},[e]),g.useEffect(()=>{a&&setTimeout(()=>{var b;return(b=v.current)==null?void 0:b.focus()},100)},[a]),g.useEffect(()=>{if(u==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[u,n]),g.useEffect(()=>{if(!e)return;const b=w=>{w.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,n]);const y=async()=>{if(!(!a||!d.trim())){m("submitting"),x("");try{await i({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),m("success")}catch(b){m("error"),x(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const S=a&&d.trim()&&u!=="submitting";return t.jsx("div",{style:Gx,onClick:b=>{b.target===b.currentTarget&&n()},children:t.jsxs("div",{style:Yx,onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{style:qx,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:Kx,"aria-label":s("feedback.close"),children:"✕"})]}),u==="success"?t.jsxs("div",{style:eb,children:[t.jsx("span",{style:{fontSize:"32px"},children:"✓"}),t.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:s("feedback.thanks")}),o&&t.jsx("a",{href:o,style:{fontSize:"13px",color:r("primary"),marginTop:"8px"},children:s("feedback.viewList")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"16px"},children:Vx.map(b=>t.jsxs("button",{onClick:()=>l(b.value),style:{...Xx,...a===b.value?Zx:{}},children:[t.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),t.jsx("textarea",{ref:v,value:d,onChange:b=>c(b.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||u==="submitting",style:{...Jx,opacity:a?1:.6}}),t.jsx("input",{type:"text",value:p,onChange:b=>h(b.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!a||u==="submitting","aria-label":s("feedback.contactLabel"),style:nb}),t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),u==="error"&&t.jsx("div",{style:tb,children:f}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:y,disabled:!S,style:{...Qx,opacity:S?1:.6,cursor:S?"pointer":"not-allowed"},children:s(u==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},Gx={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Yx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:r("shadow-dialog")},qx={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},Kx={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:r("desc-fg"),padding:"4px 8px",borderRadius:"4px"},Xx={flex:"1 1 calc(50% - 4px)",padding:"10px 12px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},Zx={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},Jx={width:"100%",minHeight:"120px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},Qx={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},eb={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:r("success")},tb={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginBottom:"12px"},nb={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"},Wr="--bim-feedback-fab-offset",Or=48,ib=16,rb=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:i,hidden:o=!1,zIndex:s})=>{const{t:a}=ne(),[l,d]=g.useState(!1),c=n.bottom??24;return g.useEffect(()=>{if(o||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(Wr,`calc(${c+Or+ib}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(Wr)}},[o,c]),t.jsxs(t.Fragment,{children:[!o&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...ob,zIndex:s??r("feedback-fab-z"),bottom:`calc(${c}px + env(safe-area-inset-bottom, 0px))`,right:n.right},"aria-label":a("feedback.title"),title:a("feedback.title"),children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),t.jsx(ad,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:i})]})},ob={position:"fixed",width:`${Or}px`,height:`${Or}px`,borderRadius:"50%",border:"none",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:r("shadow-fab"),transition:"transform 0.2s, box-shadow 0.2s"},sb=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],ld=({onSubmit:e})=>{const{t:n}=ne(),[i,o]=g.useState("bug"),[s,a]=g.useState(""),[l,d]=g.useState(""),[c,p]=g.useState("idle"),[h,u]=g.useState(""),m=g.useRef(null);g.useEffect(()=>{i&&setTimeout(()=>{var v;return(v=m.current)==null?void 0:v.focus()},100)},[i]);const f=async()=>{if(!(!i||!s.trim())){p("submitting"),u("");try{await e({type:i,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),o("bug")}catch(v){p("error"),u(v instanceof Error?v.message:n("feedback.submitFailedRetry"))}}},x=i&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:Ta,children:t.jsxs("div",{style:pb,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:ub,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:Ta,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:sb.map(v=>t.jsxs("button",{onClick:()=>o(v.value),style:{...ab,...i===v.value?lb:{}},children:[t.jsx("span",{children:v.icon})," ",n(`feedback.submitType.${v.value}`)]},v.value))}),t.jsx("textarea",{ref:m,value:s,onChange:v=>a(v.target.value),placeholder:n(i?`feedback.placeholder.${i}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...cb}}),t.jsx("input",{type:"text",value:l,onChange:v=>d(v.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:hb}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg")},children:[s.length," / 2000"]}),t.jsx("button",{onClick:f,disabled:!x,style:{...db,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:mb,children:h})]})},Ta={padding:"16px",border:`1px solid ${r("widget-border")}`,borderRadius:"8px",background:r("input-bg")},ab={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:"transparent",color:r("fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},lb={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},cb={width:"100%",minHeight:"100px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},db={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},pb={display:"flex",alignItems:"center",gap:"12px",color:r("success"),fontSize:"14px"},ub={background:"none",border:"none",color:r("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},mb={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginTop:"8px"},hb={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"};function za(e){return typeof e=="function"?e():e??"/api/feedback"}const cd=({resourceId:e,apiUrl:n})=>{const{t:i}=ne(),[o,s]=g.useState([]),[a,l]=g.useState(!0),d=g.useCallback(async()=>{const p=za(n);l(!0);try{const u=await(await fetch(`${p}?resourceId=${encodeURIComponent(e)}`)).json();u.success&&s(u.items)}catch{}finally{l(!1)}},[e,n]);g.useEffect(()=>{d()},[d]);const c=async p=>{const h=za(n),u=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!u.ok){const m=await u.json().catch(()=>null);throw new Error((m==null?void 0:m.error)||i("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(Wo,{items:o,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(ld,{onSubmit:c})})]})},Mi=8;async function Pi(e,n,i,o){const s=Number.isFinite(n)?Math.max(1,Math.floor(n)):1,a=new Array(e.length);let l=0;const d=Array.from({length:Math.min(s,Math.max(1,e.length))},async()=>{for(;l<e.length&&!(o!=null&&o());){const c=l++;a[c]=await i(e[c],c)}});return await Promise.all(d),a}const gb=wi["zh-Hant"].relation,fb=wi["zh-Hant"].lossStatus,xb=wi["zh-Hant"].resourceKind,Bi=yn("zh-Hant"),Oo=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function Na(e,n=Bi){return e?Oo(gb,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function bb(e,n=Bi){return Oo(fb,e)?n(`detail.lossStatus.${e}`):e}function yb(e,n=Bi){return Oo(xb,e)?n(`detail.resourceKind.${e}`):""}function Fo({authors:e,onNavigate:n,renderLink:i}){const{convert:o}=ne(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=co(a.role);return t.jsxs(g.Fragment,{children:[l>0&&" ",a.dynasty&&t.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",o(a.dynasty),"〕"]}),a.entity_id?t.jsx(et,{id:a.entity_id,label:o(a.name),onNavigate:n,renderLink:i,dense:!0}):o(a.name),d&&t.jsx("span",{style:{marginLeft:4},children:o(d)})]},l)})}):null}function dd(e,n,i=Bi){var c,p;const o=ao(e,n),s=o.mirrors.map(h=>({key:h.key,label:h.label,description:h.description,rows:h.items.filter(u=>u.group_role!=="mirror"),mirrors:h.items.filter(u=>u.group_role==="mirror")})),a=o.buckets.filter(h=>h.key==="image"||h.key==="textImage").flatMap(h=>h.items);a.length&&s.push({key:"_images",label:s.length?i("detail.otherImages"):void 0,rows:a,mirrors:[]});const l=((c=o.buckets.find(h=>h.key==="physical"))==null?void 0:c.items)??[];return l.length&&s.push({key:"_physical",label:i("detail.resourceKind.physical"),rows:l,mirrors:[]}),{text:((p=o.buckets.find(h=>h.key==="text"))==null?void 0:p.items)??[],groups:s}}function pd(e,n){const i=(e.url?fn(e.url):void 0)||e.name,o=ql(e,n);return o?`${i}(${o})`:i}function Ho({item:e,siblings:n,listedVolumeCounts:i}){const{t:o,convert:s}=ne(),[a,l]=g.useState(!1),d=ki(e),c=!!d&&d.expected>0&&!(i!=null&&i.has(d.expected)),p=s(pd(e,n)),h=xn(e),u=Ii(e,o)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var f,x;const m=(f=e.metadata)!=null&&f.fragment||e.color_mode?t.jsxs("span",{className:"bim-d-tags bim-d-ui",style:{display:"inline-flex",margin:"0 0 0 8px",verticalAlign:"middle"},children:[((x=e.metadata)==null?void 0:x.fragment)&&t.jsx("span",{className:"bim-d-tag",children:o("detail.fragmentTag")}),e.color_mode&&t.jsx("span",{className:"bim-d-tag",children:e.color_mode==="color"?o("colorMode.color"):o("colorMode.bw")})]}):null;return h?t.jsxs("a",{href:h,target:"_blank",rel:"noopener noreferrer",children:[p," ",t.jsx("span",{"aria-hidden":"true",children:"↗"}),m]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,m]})})(),u&&t.jsx("span",{className:"bim-d-meta",children:s(u)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(xo,{item:e})})]}),t.jsx("td",{className:c?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:c&&t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":a,onClick:()=>l(m=>!m),children:a?o("detail.collapseVolumes"):o("detail.expandVolumes",{n:d.expected})})})]})}function ud({groups:e,listedVolumeCounts:n}){const{t:i,convert:o}=ne();return t.jsx(t.Fragment,{children:e.map(s=>t.jsxs("div",{className:"bim-d-rg",children:[s.label&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:o(s.label)}),s.description&&t.jsx("p",{className:"bim-d-rg-d",children:o(s.description)}),s.rows.length>0&&t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:s.rows.map((a,l)=>t.jsx(Ho,{item:a,siblings:s.rows,listedVolumeCounts:n},`${a.id||a.url||a.name}-${l}`))})}),s.mirrors.length>0&&t.jsxs("div",{className:"bim-d-rg-mir bim-d-ui",children:[s.rows.length>0&&t.jsx("span",{className:"bim-d-meta",style:{marginRight:10},children:i("detail.mirror")}),s.mirrors.map((a,l)=>{const d=xn(a),c=o(pd(a,s.mirrors));return d?t.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",title:a.details?o(a.details):void 0,children:[c," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]},l):t.jsx("span",{style:{marginRight:14},children:c},l)})]})]},s.key))})}const Mn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function Fr(e){var i;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(i=Mn.find(o=>n.startsWith(o.key[0])))==null?void 0:i.key}const Ia=12,jb=60,md=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,railTop:a,back:l,railLinks:d})=>{var G,xe,K;const{t:c,convert:p,messages:h}=ne(),u=g.useMemo(()=>po({_books:e._books}),[e._books]),[m,f]=g.useState(new Map),[x,v]=g.useState(!1),[y,S]=g.useState(""),[b,w]=g.useState(!1),j=u.length<=jb,k=j||x||!!y||b,$=g.useMemo(()=>k?u:u.slice(0,Ia),[u,k]);g.useEffect(()=>{if(!n||$.length===0)return;const L=$.filter(ae=>!m.has(ae));if(L.length===0)return;let q=!1;return Pi(L,Mi,ae=>n.getItem(ae).then(be=>{const X=be??{};return[ae,{id:ae,title:X.title,edition:X.edition,resources:X.resources,publication_info:X.publication_info,current_location:X.current_location,lineage:X.lineage,measure_info:X.measure_info}]}).catch(()=>[ae,{id:ae}]),()=>q).then(ae=>{q||f(be=>{const X=new Map(be);for(const[re,Ce]of ae)X.set(re,Ce);return X})}),()=>{q=!0}},[n,$,m]);const C=g.useMemo(()=>u.map(L=>m.get(L)??{id:L}),[u,m]),_=u.length>0&&u.every(L=>m.has(L)),E=!!n&&$.some(L=>!m.has(L)),z=j||k,T=g.useMemo(()=>Xl(C,e.version_graph,{era:y,scanOnly:b,sort:z?"year":"default"}),[C,e.version_graph,y,b,z]),B=x?T.rows:T.rows.slice(0,Ia),W=T.allRows.filter(L=>L.hasImage).length,N=g.useMemo(()=>(e._related||[]).map(L=>({...L,title:L.title??""})),[e._related]),A=N.filter(L=>L.relation==="collected_in"),F=g.useMemo(()=>{const L=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],q=ae=>{const be=L.indexOf(ae??"");return be<0?L.length:be};return N.filter(ae=>ae.relation!=="collected_in").map((ae,be)=>({r:ae,i:be})).sort((ae,be)=>q(ae.r.relation)-q(be.r.relation)||ae.i-be.i).map(ae=>ae.r)},[N]),Y=g.useMemo(()=>{const L=ao(e.resources,e.resource_groups);return[...L.mirrors.flatMap(q=>q.items.map(ae=>({r:ae,kind:p(q.label)}))),...L.buckets.flatMap(q=>q.items.map(ae=>({r:ae,kind:p(yb(q.key,c))})))]},[e.resources,e.resource_groups,p,c]),ee=e.indexed_by||[],se=e.emendated_by||[],D=g.useMemo(()=>{var O,ie,je;const L=[],q=(ie=(O=e.authors)==null?void 0:O[0])==null?void 0:ie.dynasty;q&&L.push({label:c("workPage.fact.written"),value:p(q)});const ae=Bt(e,h.unit.juan);if(ae){const ke=(je=e.juan_count)==null?void 0:je.description;L.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(ae),ke&&ke!==ae?t.jsxs("span",{className:"bim-d-meta",children:["(",p(ke),")"]}):null]})})}e.loss_status&&L.push({label:c("workPage.fact.loss"),value:p(bb(e.loss_status,c))});const be=T.allRows.filter(ke=>ke.sortYear!=null),X=be.length>0?be.reduce((ke,P)=>ke.sortYear<=P.sortYear?ke:P):null;X!=null&&X.era.era?L.push({label:c("workPage.fact.earliest"),value:p([X.era.era,X.era.reign].filter(Boolean).join(" ")),title:X.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):E&&L.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),se.length&&L.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:se.length})});const re=Ra(e.additional_titles);re.length&&L.push({label:c("workPage.fact.alias"),value:re.map(p).join("、")});const Ce=Ra(e.attached_texts);Ce.length&&L.push({label:c("workPage.fact.attached"),value:Ce.map(p).join("、")});const We=(e.additional_works||[]).map(ke=>p(ke.book_title)+(ke.n_juan!=null?` ${ke.n_juan}${h.unit.juan}`:""));return We.length&&L.push({label:c("workPage.fact.appendix"),value:We.join("、")}),L},[e,p,c,h,E,T.allRows,se.length]),he=[{value:e._edition_count??u.length,label:c("workPage.stat.editions")},{value:_?W:0,label:c("workPage.stat.hasImage")},{value:ee.length,label:c("workPage.stat.catalogs")}],Z=uo(e),M=Z?[Z.l1,Z.l2,Z.l3,Z.l4].filter(Boolean).map(L=>p(L)):[],_e=e.subtype?h.workSubtype[e.subtype]??p(e.subtype):"",ce=t.jsx(Fn,{title:p(e.title),byline:t.jsx(Fo,{authors:e.authors,onNavigate:i,renderLink:o}),meta:t.jsx(it,{items:[...M,Z!=null&&Z.source?c("workPage.classifiedBy",{source:p(Z.source.split("/")[0])}):"",_e]}),description:(G=e.description)!=null&&G.text?t.jsxs(t.Fragment,{children:[t.jsx(Pt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(xe=e.description.sources)!=null&&xe.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(L=>({text:p(mh(L)),href:hh(L)})).filter(L=>L.text).map((L,q)=>t.jsxs(g.Fragment,{children:[q>0?" · ":null,L.href?t.jsx("a",{href:L.href,target:"_blank",rel:"noopener noreferrer",children:L.text}):L.text]},q))}):null]}):void 0,stats:he,facts:D,readAction:s,foot:t.jsx(Hn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(K=e.appendix)==null?void 0:K.map((L,q)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(L.title)}),t.jsx(Pt,{text:L.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},q))}),ge=T.eras.length>=2?[{key:"",label:c("catalog.all")},...T.eras.map(L=>({key:L,label:`${L} ${T.allRows.filter(q=>q.era.era===L).length}`}))]:[],le=[];u.length&&le.push({id:"versions",label:c("workPage.sec.versions"),count:u.length}),ee.length&&le.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:ee.length}),A.length&&le.push({id:"collected",label:c("workPage.sec.collected"),count:A.length}),F.length&&le.push({id:"related",label:c("workPage.sec.related"),count:F.length}),Y.length&&le.push({id:"resources",label:c("workPage.sec.resources"),count:Y.length});const Be=u.length===0&&ee.length===0,ze=t.jsxs(t.Fragment,{children:[u.length>0&&t.jsxs(rt,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(it,{items:[c("workPage.versionsTotal",{n:u.length}),_&&W?c("workPage.versionsWithImage",{n:W}):"",T.rows.length!==T.allRows.length?c("workPage.versionsCurrent",{n:T.rows.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":E&&ge.length===0&&u.length>1?"":void 0,children:[ge.length>0&&t.jsx(Ei,{items:ge,value:y,onChange:L=>{S(L),v(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(lc,{label:c("workPage.scanOnly"),checked:b,onChange:L=>{w(L),v(!1)}}),t.jsx("span",{className:"bim-d-meta",children:c(z?"workPage.sortByYear":"workPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&Li(T.rows.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:c("workPage.col.edition")}),t.jsx("th",{children:c("workPage.col.era")}),t.jsx("th",{children:c("workPage.col.holder")}),t.jsx("th",{children:t.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:c("workPage.col.image")})})]})}),t.jsx("tbody",{children:B.map(L=>{var q;return t.jsx(vb,{row:L,measure:(q=m.get(L.id))==null?void 0:q.measure_info,loaded:m.has(L.id),onNavigate:i,renderLink:o},`${L.id}:${m.has(L.id)?"r":"p"}`)})})]}),B.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c(y||b?"workPage.noVersionsFiltered":"workPage.noVersions")}),!x&&t.jsx(mo,{total:T.rows.length,shown:B.length,unit:c("workPage.moreUnit"),onClick:()=>v(!0)}),T.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),ee.length>0&&t.jsx(kb,{items:ee,transport:n,onNavigate:i,renderLink:o}),Be&&t.jsx(rt,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),Fe=(L,q)=>t.jsx(et,{id:L,label:p(q),onNavigate:i,renderLink:o,dense:!0}),te=g.useMemo(()=>{const L=new Map;for(const q of F){const ae=Na(q.relation,c);L.set(ae,(L.get(ae)??0)+1)}return L.size>1?[...L.entries()].sort((q,ae)=>ae[1]-q[1]).slice(0,4).map(([q,ae])=>`${p(q)} ${ae}`).join(" · "):void 0},[F,p,c]),H=t.jsxs(t.Fragment,{children:[t.jsx(en,{id:"collected",title:c("workPage.sec.collected"),items:A.map(L=>Fe(L.id,L.title))}),t.jsx(en,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:F.length}),sub:te,items:F.map(L=>t.jsxs(t.Fragment,{children:[Fe(L.id,L.title),t.jsx("span",{className:"bim-d-meta",title:L.note?p(L.note):void 0,children:p(Na(L.relation,c))})]}))}),t.jsx(en,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:Y.map(({r:L,kind:q})=>{const ae=p((L.url?fn(L.url):void 0)||L.name),be=xn(L);return t.jsxs(t.Fragment,{children:[be?t.jsxs("a",{href:be,target:"_blank",rel:"noopener noreferrer",children:[ae," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:ae}),q&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:q})]})})})]});return t.jsx(On,{railTop:a,back:l,nav:le,railLinks:d,main:ze,card:ce,side:H})};function Ra(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Ea(e,n){return n((e.url?fn(e.url):void 0)||e.name)}function vb({row:e,measure:n,loaded:i,onNavigate:o,renderLink:s}){const{t:a,convert:l}=ne(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],h=p?Ea(p,l):e.locationName?l(e.locationName):"",u=e.images[0],m=u?xn(u):void 0,f=e.images.map(x=>Ea(x,l)).join("、");return t.jsxs("tr",{"data-loading":i?void 0:"",children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(et,{id:e.id,label:l(e.name),onNavigate:o,renderLink:s,dense:!0}),n?t.jsx("span",{className:"bim-d-meta",children:l(n)}):t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${d?"":" bim-d-zt-blank"}`,title:c?a("workPage.inferredFromEdition"):void 0,children:d?l(d):i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),t.jsxs("td",{className:`bim-d-zt-sub${h?"":" bim-d-zt-blank"}`,children:[h||(i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),e.holders.length>1&&t.jsxs("span",{className:"bim-d-meta",children:[" +",e.holders.length-1]})]}),t.jsx("td",{className:e.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:e.hasImage&&(m?t.jsx("a",{className:"bim-d-flag",href:m,target:"_blank",rel:"noopener noreferrer",title:f,children:a("workPage.hasImage")}):t.jsx("span",{className:"bim-d-flag",title:f,children:a("workPage.hasImage")}))})]})}function kb({items:e,transport:n,onNavigate:i,renderLink:o}){const{t:s,convert:a}=ne(),[l,d]=g.useState(0),c=Math.min(l,e.length-1),p=e[c],[h,u]=g.useState(new Map);return g.useEffect(()=>{if(!n)return;const m=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(m.length===0)return;let f=!1;return Promise.all(m.map(x=>n.getItem(x).then(v=>{var y,S;return[x,((S=(y=v==null?void 0:v.authors)==null?void 0:y[0])==null?void 0:S.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{f||u(new Map(x.filter(([,v])=>v)))}),()=>{f=!0}},[n,e]),t.jsx(rt,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(it,{items:[s("workPage.catalog.meta",{n:e.length}),s("workPage.sortByCatalog")]}),children:t.jsxs("div",{className:"bim-d-lu",children:[t.jsx("ul",{className:"bim-d-tl2 bim-d-ui",role:"tablist","aria-label":s("workPage.catalog.tablist"),children:e.map((m,f)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":f===c,"aria-label":a(m.source),onClick:()=>d(f),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:h.get(m.source_bid??"")?a(h.get(m.source_bid??"")):" "}),t.jsx("i",{className:"bim-d-tl2-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-d-tl2-name","aria-hidden":"true",children:[...a(m.source)].slice(0,9).map((x,v)=>t.jsx("span",{children:x},v))})]})},f))}),t.jsxs("div",{className:"bim-d-lu-body",role:"tabpanel",children:[p.title_info&&t.jsx("div",{className:"bim-d-lu-title",children:a(p.title_info)}),t.jsx(it,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(et,{id:p.source_bid,label:a(p.source),onNavigate:i,renderLink:o,dense:!0}):a(p.source),p.section?a(p.section):"",p.author_info?`${s("label.authorInfo")} ${a(p.author_info)}`:"",p.edition?`${s("label.edition")} ${a(p.edition)}`:"",p.page??""]}),p.summary&&t.jsx("p",{className:"bim-d-quote",children:ft(a(p.summary),void 0,{t:s})}),p.comment&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.comment")}),t.jsx("p",{className:"bim-d-quote",children:ft(a(p.comment),void 0,{t:s})})]}),p.additional_comment&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.additionalComment")}),t.jsx("p",{className:"bim-d-quote",children:ft(a(p.additional_comment),void 0,{t:s})})]}),!p.summary&&!p.comment&&!p.additional_comment&&!p.title_info&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{marginTop:12},children:s("workPage.catalog.titleOnly")}),e.length>1&&t.jsxs("div",{className:"bim-d-lu-pager bim-d-ui",children:[c>0?t.jsx("button",{type:"button","aria-label":s("workPage.catalog.prev",{name:a(e[c-1].source)}),onClick:()=>d(c-1),children:t.jsxs("span",{"aria-hidden":"true",children:["← ",a(e[c-1].source)]})}):t.jsx("span",{"aria-hidden":"true"}),t.jsxs("span",{className:"bim-d-meta",children:[c+1," / ",e.length]}),c<e.length-1?t.jsx("button",{type:"button","aria-label":s("workPage.catalog.next",{name:a(e[c+1].source)}),onClick:()=>d(c+1),children:t.jsxs("span",{"aria-hidden":"true",children:[a(e[c+1].source)," →"]})}):t.jsx("span",{"aria-hidden":"true"})]})]})]})})}function wb(e){var n;return{id:e.id,kind:"hypothetical",label:e.label,year:e.year??((n=e.year_range)==null?void 0:n[0]),year_range:e.year_range,year_uncertain:e.year_uncertain,group:e.group,note:e.note,description:e.description}}function Sb(e,n){if(!e.lineage)return null;const i=e.lineage;return{id:e.id,kind:"book",label:e.title,year:i.year,year_text:i.year_text,year_uncertain:i.year_uncertain,category:i.category,status:i.status,extant_juan:i.extant_juan,group:n[e.id],note:i.note}}function La(e,n,i){return{id:`derive:${n.ref}->${e}:${i}`,source:n.ref,target:e,kind:"derive",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function _b(e,n,i){const[o,s]=[e,n.book_id].sort();return{id:`sibling:${o}-${s}:${i}`,source:o,target:s,kind:"sibling",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function $b(e,n){var p;if(n==="all")return null;const i=(p=e.collections)==null?void 0:p[n],o=Array.isArray(i==null?void 0:i.groups)&&i.groups.length>0,s=Array.isArray(i==null?void 0:i.book_ids)&&i.book_ids.length>0,a=o||s||!!(i!=null&&i.hypothetical_ids);if(!a&&n==="core"&&Array.isArray(e.core_books)&&e.core_books.length>0)return{books:new Set(e.core_books),hypos:e.core_hypotheticals?new Set(e.core_hypotheticals):null};if(!i||!a)return null;const l=o?new Set(i.groups):null,d=new Set(i.book_ids??[]);if(l&&e.node_groups)for(const[h,u]of Object.entries(e.node_groups))l.has(u)&&d.add(h);let c=null;if(i.hypothetical_ids&&(c=new Set(i.hypothetical_ids)),l){c||(c=new Set);for(const h of e.hypothetical_nodes??[])h.group&&l.has(h.group)&&c.add(h.id)}return{books:d,hypos:c}}function hi(e,n,i){const o=e.version_graph,s={nodes:[],edges:[],groups:[],layout:"LR",excluded:[]};if(!o||!o.enabled)return s;const a=new Set(o.excluded_books??[]),l=o.node_groups??{},d=$b(o,i??o.default_collection??"all"),c=d!==null,p=(d==null?void 0:d.books)??null,h=(d==null?void 0:d.hypos)??null,u=new Set,m=new Set;if(c){const j=new Map(n.map(z=>[z.id,z])),k=new Map((o.hypothetical_nodes??[]).map(z=>[z.id,z])),$=z=>{const T=j.get(z);if(T&&T.lineage)return(T.lineage.derived_from??[]).map(W=>W.ref);const B=k.get(z);return B?(B.derived_from??[]).map(W=>W.ref):[]},C=z=>k.has(z)?!h||h.has(z):!p||p.has(z),_=new Set,E=z=>{if(!_.has(z)){_.add(z);for(const T of $(z))a.has(T)||(C(T)||(k.has(T)?m.add(T):j.has(T)&&u.add(T)),E(T))}};for(const z of n)p&&p.has(z.id)&&!a.has(z.id)&&E(z.id);for(const z of o.hypothetical_nodes??[])h&&h.has(z.id)&&E(z.id)}const f=n.filter(j=>!a.has(j.id)).filter(j=>!p||p.has(j.id)||u.has(j.id)).map(j=>{const k=Sb(j,l);return k&&u.has(j.id)&&(k.bridge=!0),k}).filter(j=>j!==null),x=(o.hypothetical_nodes??[]).filter(j=>!h||h.has(j.id)||m.has(j.id)).map(j=>{const k=wb(j);return m.has(j.id)&&(k.bridge=!0),k}),v=[...f,...x],y=new Set(v.map(j=>j.id)),S=new Set,b=[],w=j=>{S.has(j.id)||!y.has(j.source)||!y.has(j.target)||(S.add(j.id),b.push(j))};for(const j of n)a.has(j.id)||!j.lineage||p&&!p.has(j.id)&&!u.has(j.id)||((j.lineage.derived_from??[]).forEach((k,$)=>{w(La(j.id,k,$))}),(j.lineage.related_to??[]).forEach((k,$)=>{w(_b(j.id,k,$))}));for(const j of o.hypothetical_nodes??[])h&&!h.has(j.id)&&!m.has(j.id)||(j.derived_from??[]).forEach((k,$)=>{w(La(j.id,k,$))});return{nodes:v,edges:b,groups:o.groups??[],title:o.title,description:o.description,layout:o.layout??"LR",excluded:Array.from(a)}}function hd(e,n,i){const o=(e??(n!=null?String(n):"")).trim();return o?!i||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(o)?o:`约 ${o}`:""}function Cb(e,n){const i=[],o=e.version_graph;if(!o)return i;const s=new Set(n.map(c=>c.id)),a=new Set((o.hypothetical_nodes??[]).map(c=>c.id)),l=new Set([...s,...a]),d=(c,p)=>{l.has(p.ref)||i.push(`${c}: derived_from.ref "${p.ref}" 未在 books 或 hypothetical_nodes 中找到`),p.ref_type==="book"&&!s.has(p.ref)&&i.push(`${c}: derived_from.ref "${p.ref}" 标记为 book 但不在 books 列表中`),p.ref_type==="hypothetical"&&!a.has(p.ref)&&i.push(`${c}: derived_from.ref "${p.ref}" 标记为 hypothetical 但不在 hypothetical_nodes 中`)};for(const c of n){if(!c.lineage)continue;const p=`Book ${c.id} (${c.title})`;(c.lineage.derived_from??[]).forEach(h=>d(p,h)),(c.lineage.related_to??[]).forEach(h=>{s.has(h.book_id)||i.push(`${p}: related_to.book_id "${h.book_id}" 不在 books 列表中`)})}for(const c of o.hypothetical_nodes??[]){const p=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(h=>d(p,h))}return i}const gd=({graph:e,renderLink:n,className:i,style:o})=>{const{t:s,convert:a}=ne();if(!e.nodes.length)return t.jsx("div",{style:{...Fb,...o},className:i,children:s("lineage.emptyGraph")});const l=new Map,d=new Map;for(const f of e.edges)if(f.kind==="derive"){const x=l.get(f.target)??[];x.push(f),l.set(f.target,x)}else for(const x of[f.source,f.target]){const v=d.get(x)??[];v.push(f),d.set(x,v)}const c=new Map(e.nodes.map(f=>[f.id,f])),p=new Map,h=[];for(const f of e.nodes)if(f.group){const x=p.get(f.group)??[];x.push(f),p.set(f.group,x)}else h.push(f);const u=(f,x)=>(f.year??9999)-(x.year??9999);p.forEach(f=>f.sort(u)),h.sort(u);const m=e.groups.filter(f=>p.has(f.id));return t.jsxs("div",{className:i,style:{...zb,...o},children:[e.title&&t.jsx("div",{style:Nb,children:a(e.title)}),e.description&&t.jsx("div",{style:Ib,children:a(e.description)}),m.map(f=>t.jsx(Aa,{label:f.label,color:f.color,nodes:p.get(f.id),incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n},f.id)),h.length>0&&t.jsx(Aa,{label:s("lineage.otherGroup"),nodes:h,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},Aa=({label:e,color:n,nodes:i,incomingMap:o,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=ne();return t.jsxs("div",{style:Rb,children:[t.jsx("div",{style:{...Eb,borderLeftColor:n??r("widget-border")},children:d(e)}),i.map(c=>t.jsx(Tb,{node:c,incoming:o.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},Tb=({node:e,incoming:n,siblings:i,nodeMap:o,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=ne();return t.jsxs("div",{style:{...Lb,borderStyle:a||l?"dashed":"solid",opacity:l?.55:e.status==="lost"?.7:1,background:l?r("bg-subtle"):void 0},title:l?d("lineage.bridgeTitle"):void 0,children:[t.jsxs("div",{style:Ab,children:[t.jsx("span",{style:Mb,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:Pb,children:hd(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:Bb,children:[e.category&&t.jsx(zn,{children:c(e.category)}),e.status==="lost"&&t.jsx(zn,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(zn,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(zn,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(zn,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:Wb,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:Ob,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:Pa,children:[t.jsx("div",{style:Ba,children:d("lineage.sources")}),n.map(p=>{const h=o.get(p.source);return t.jsxs("div",{style:Wa(p.confidence),children:[t.jsx("span",{style:Oa,children:c(p.relation)}),t.jsx("span",{children:(h==null?void 0:h.kind)==="book"&&s?s(h.id,c(h.label)):c((h==null?void 0:h.label)??p.source)}),p.confidence!=="consensus"&&p.confidence!=="certain"&&t.jsx(Ma,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Fa,children:["· ",c(p.evidence)]})]},p.id)})]}),i.length>0&&t.jsxs("div",{style:Pa,children:[t.jsx("div",{style:Ba,children:d("lineage.related")}),i.map(p=>{const h=p.source===e.id?p.target:p.source,u=o.get(h);return t.jsxs("div",{style:Wa(p.confidence),children:[t.jsx("span",{style:Oa,children:c(p.relation)}),t.jsx("span",{children:(u==null?void 0:u.kind)==="book"&&s?s(u.id,c(u.label)):c((u==null?void 0:u.label)??h)}),t.jsx(Ma,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Fa,children:["· ",c(p.evidence)]})]},p.id)})]})]})},zn=({children:e,tone:n="default"})=>{const o={default:{bg:r("tag-bg"),fg:r("fg")},warn:{bg:r("warn-bg"),fg:r("warn-fg")},info:{bg:r("info-bg"),fg:r("info-fg")}}[n];return t.jsx("span",{style:{display:"inline-block",padding:"1px 8px",fontSize:"11px",borderRadius:"10px",background:o.bg,color:o.fg,marginRight:"4px"},children:e})},Ma=({level:e})=>{const{t:n}=ne(),o={certain:{key:"certain",color:r("confidence-certain")},consensus:{key:"consensus",color:r("confidence-consensus")},probable:{key:"probable",color:r("confidence-probable")},disputed:{key:"disputed",color:r("confidence-disputed")}}[e];return o?t.jsx("span",{style:{display:"inline-block",padding:"0 6px",fontSize:"10px",border:`1px solid ${o.color}`,color:o.color,borderRadius:"8px",marginLeft:"4px"},children:n(`lineage.confidence.${o.key}`)}):null},zb={fontSize:"14px",color:r("fg")},Nb={fontSize:"16px",fontWeight:600,marginBottom:"8px"},Ib={fontSize:"13px",color:r("muted"),marginBottom:"16px",lineHeight:1.6},Rb={marginBottom:"16px"},Eb={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:r("fg")},Lb={border:`1px solid ${r("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:r("bg")},Ab={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Mb={fontSize:"15px",fontWeight:600},Pb={fontSize:"12px",color:r("muted")},Bb={marginBottom:"6px"},Wb={fontSize:"12px",color:r("muted"),margin:"2px 0"},Ob={fontSize:"12px",color:r("muted"),fontStyle:"italic",margin:"4px 0"},Pa={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${r("widget-border")}`},Ba={fontSize:"11px",color:r("muted"),marginBottom:"2px"},Wa=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),Oa={display:"inline-block",padding:"0 6px",fontSize:"11px",background:r("tag-bg"),color:r("fg"),borderRadius:"3px",marginRight:"6px"},Fa={fontSize:"11px",color:r("muted")},Fb={padding:"20px",textAlign:"center",color:r("muted"),fontSize:"13px"},fd=({selectedNodeId:e,...n})=>{const{t:i}=ne(),[o,s]=g.useState("loading"),[a,l]=g.useState(null);return g.useEffect(()=>{let d=!1;return Hb().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),o==="loading"?t.jsx("div",{style:Da,children:i("lineage.graphLoading")}):o==="missing"||!a?t.jsxs("div",{style:Da,children:[t.jsx("div",{children:Ha(i("lineage.graphMissing"),{xyflow:t.jsx("code",{children:"@xyflow/react"}),dagre:t.jsx("code",{children:"@dagrejs/dagre"})})}),t.jsx("div",{style:{fontSize:"12px",marginTop:"4px"},children:Ha(i("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(Db,{modules:a,selectedNodeId:e,...n})};function Ha(e,n){return e.split(/(\{\w+\})/).map((i,o)=>{const s=/^\{(\w+)\}$/.exec(i);return t.jsx(g.Fragment,{children:s&&s[1]in n?n[s[1]]:i},o)})}async function Hb(){try{const[e,n]=await Promise.all([import("@xyflow/react"),import("@dagrejs/dagre")]);let i=!1;try{await import("@xyflow/react/dist/style.css"),i=!0}catch{i=!1}return{ReactFlow:e.ReactFlow,Background:e.Background,Controls:e.Controls,Handle:e.Handle,Position:e.Position,BaseEdge:e.BaseEdge,EdgeLabelRenderer:e.EdgeLabelRenderer,getSmoothStepPath:e.getSmoothStepPath,dagre:n,cssLoaded:i}}catch{return null}}const Db=({graph:e,renderLink:n,height:i=600,className:o,style:s,selectedNodeId:a,modules:l})=>{const{ReactFlow:d,Background:c,Controls:p,Handle:h,Position:u,BaseEdge:m,EdgeLabelRenderer:f,getSmoothStepPath:x,dagre:v}=l,y=g.useMemo(()=>({lineage:$=>{var F,Y,ee,se;const C=((F=$.data)==null?void 0:F.stepPosition)??.85,[_,E,z]=x({sourceX:$.sourceX,sourceY:$.sourceY,sourcePosition:$.sourcePosition,targetX:$.targetX,targetY:$.targetY,targetPosition:$.targetPosition,stepPosition:C,borderRadius:5}),T=!!((Y=$.data)!=null&&Y.isSibling),B=T?E:$.targetX-18,W=T?z:$.targetY-12,N=(ee=$.data)==null?void 0:ee.labelStyle,A=(se=$.data)==null?void 0:se.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(m,{id:$.id,path:_,style:$.style,markerStart:$.markerStart,markerEnd:$.markerEnd}),$.label&&t.jsx(f,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${B}px,${W}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:r("bg"),border:`0.5px solid ${r("widget-border")}`,...A,...N},children:$.label})})]})}}),[m,f,x]),S=g.useMemo(()=>({version:$=>{const{t:C}=ne(),_=$.data,E=_.kind==="hypothetical",z=_.status==="lost",T=_.isSelected,B=_.bridge,W=_.borderColor??r("muted"),N=B||E?"dashed":"solid",A=B?.5:z?.6:1;return t.jsxs("div",{style:{background:r(B?"bg-subtle":"bg"),border:`2px ${N} ${T?r("primary"):W}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:A,boxShadow:T?r("shadow-node-selected"):E||B?"none":r("shadow-node")},title:B?C("lineage.bridgeTitle"):void 0,children:[t.jsx(h,{type:"target",position:u.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:E||!_.renderLink?_.label:_.renderLink(_.bookId,_.label)}),_.description&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.25,marginTop:1},children:_.description}),_.yearText&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.2},children:hd(_.yearText,void 0,_.uncertain)}),z&&t.jsx("div",{style:{fontSize:9,color:r("lost-fg"),marginTop:1},children:C("lineage.lost")}),t.jsx(h,{type:"source",position:u.Right,style:{visibility:"hidden"}})]})}}),[h,u]),{convert:b}=ne(),{rfNodes:w,rfEdges:j}=g.useMemo(()=>Ub(e,v,n,a,b),[e,v,n,a,b]);return t.jsx("div",{style:{width:"100%",height:i,...s},className:o,children:t.jsxs(d,{nodes:w,edges:j,nodeTypes:S,edgeTypes:y,fitView:!0,fitViewOptions:{padding:.15},proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,minZoom:.2,maxZoom:1.8,children:[t.jsx(c,{gap:16}),t.jsx(p,{showInteractive:!1})]})})};function Ub(e,n,i,o,s=a=>a??""){const d=e.layout==="LR"||!e.layout,c=new n.graphlib.Graph;c.setGraph({rankdir:d?"LR":"TB",ranksep:160,nodesep:40,edgesep:16,marginx:20,marginy:20}),c.setDefaultEdgeLabel(()=>({}));const p=new Map(e.groups.map(S=>[S.id,S.color??r("muted")]));for(const S of e.nodes)c.setNode(S.id,{width:160,height:90});const h=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const S of e.edges)S.kind==="derive"&&(h.has(S.relation)||c.setEdge(S.source,S.target));n.layout(c);const u=e.nodes.map(S=>{const b=c.node(S.id),w=o?S.id===o:void 0,j={kind:S.kind,label:s(S.label),bookId:S.kind==="book"?S.id:void 0,yearText:s(S.year_text??Gb(S)),uncertain:S.year_uncertain,category:S.category,status:S.status,borderColor:S.group?p.get(S.group):void 0,renderLink:i,isSelected:w,description:s(S.description),bridge:S.bridge};return{id:S.id,type:"version",position:{x:b.x-160/2,y:b.y-90/2},data:j,draggable:!1,selected:w}}),m=.78,f=.06,x=new Map;for(const S of e.edges)S.kind==="derive"&&(x.has(S.source)||x.set(S.source,[]),x.get(S.source).push(S));const v=new Map;for(const[S,b]of x){if(b.length<=1)continue;const w=[...b].sort((k,$)=>{var E,z;const C=((E=c.node(k.target))==null?void 0:E.y)??0,_=((z=c.node($.target))==null?void 0:z.y)??0;return C-_}),j=w.length;w.forEach((k,$)=>{const C=($-(j-1)/2)*f;v.set(k.id,m+C)})}const y=e.edges.map(S=>Vb(S,v.get(S.id),s));return{rfNodes:u,rfEdges:y}}function Vb(e,n,i=o=>o??""){const o=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=Yb(e.confidence),l={type:"arrowclosed",color:a,width:14,height:14};return{id:e.id,source:e.source,target:e.target,type:"lineage",label:i(e.relation),data:{labelStyle:{color:r("fg")},isSibling:s,stepPosition:n},style:{stroke:a,strokeWidth:s?1:1.5,strokeDasharray:s?"4 3":o?"6 4":void 0,opacity:o?.75:1},animated:!1,markerEnd:l,markerStart:s?l:void 0,zIndex:1e3}}function Gb(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function Yb(e){switch(e){case"certain":return r("confidence-certain");case"consensus":return r("lineage-edge-consensus");case"probable":return r("confidence-probable");case"disputed":return r("confidence-disputed");default:return r("muted")}}const Da={padding:"40px 20px",textAlign:"center",color:r("muted"),fontSize:"13px",border:`1px dashed ${r("widget-border")}`,borderRadius:8,background:r("bg")},Do=({graph:e,defaultMode:n="list",renderLink:i,graphHeight:o=600,selectedNodeId:s,onModeChange:a,collection:l,onCollectionChange:d,collectionsAvailable:c,collectionCounts:p,className:h,style:u})=>{var j;const{t:m,convert:f}=ne(),[x,v]=g.useState(n),y=k=>{v(k),a==null||a(k)},S=(()=>{if(!c)return[];const k=Object.entries(c);return k.length===0||c.all?k:[...k,["all",{label:m("lineage.collectionAll"),description:m("lineage.collectionAllDesc")}]]})(),b=!!(d&&S.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:r("muted"),textAlign:"center"},children:m("lineage.empty")});const w=l?(j=c==null?void 0:c[l])==null?void 0:j.description:void 0;return t.jsxs("div",{className:h,style:u,children:[t.jsxs("div",{style:qb,children:[t.jsx("button",{onClick:()=>y("list"),style:gr(x==="list"),children:m("lineage.modeList")}),t.jsx("button",{onClick:()=>y("graph"),style:gr(x==="graph"),children:m("lineage.modeGraph")}),b&&t.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:12,color:r("muted"),marginRight:4},children:m("lineage.collectionLabel")}),S.map(([k,$])=>{const C=p==null?void 0:p[k];return t.jsxs("button",{onClick:()=>d==null?void 0:d(k),style:gr(l===k),title:$.description?f($.description):void 0,children:[f($.label),C!=null?` ${C}`:""]},k)})]})]}),b&&w&&t.jsx("div",{style:{fontSize:12,color:r("muted"),marginBottom:8,padding:"4px 8px",background:r("bg-subtle"),borderRadius:4},children:f(w)}),x==="list"?t.jsx(gd,{graph:e,renderLink:i}):t.jsx(fd,{graph:e,renderLink:i,height:o,selectedNodeId:s})]})},qb={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},gr=e=>({padding:"4px 12px",fontSize:12,border:`1px solid ${r("widget-border")}`,borderRadius:4,background:e?r("primary"):"transparent",color:r(e?"primary-fg":"fg"),cursor:"pointer"}),Ua=40,Va=2,Kb=9,Xb=new Set(["certain","consensus","probable","disputed"]);function fr(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const xd=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:h})=>{var je,ke,P,fe,oe,we,Le,He,Ge,Ye,Xe;const u=Ee(),{t:m,convert:f}=ne(),[x,v]=g.useState(null),[y,S]=g.useState(new Map),[b,w]=g.useState([]),[j,k]=g.useState(new Map),[$,C]=g.useState(!1),[_,E]=g.useState("flow"),[z,T]=g.useState(null);g.useEffect(()=>{if(!n||!e.work_id){v(null);return}let I=!1;return n.getItem(e.work_id).then(U=>{!I&&U&&U.type==="work"&&v(U)}).catch(()=>{}),()=>{I=!0}},[n,e.work_id]),g.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){T(null);return}let I=!1;return n.getLineageGraph(e.work_id).then(U=>{I||T(U&&U.nodes.length>1?U:null)}).catch(()=>{I||T(null)}),()=>{I=!0}},[n,e.work_id]),g.useEffect(()=>{const I=e._collections||[];if(!n||I.length===0){S(new Map);return}let U=!1;return Promise.all(I.map(pe=>{const $e=pe.id;return n.getItem($e).then(ye=>[$e,ye]).catch(()=>[$e,null])})).then(pe=>{if(U)return;const $e=new Map;for(const[ye,ue]of pe)ue&&$e.set(ye,ue);S($e)}),()=>{U=!0}},[n,e._collections]);const B=g.useMemo(()=>{const I=new Set([...x?po(x):[],...e.related_books||[]]);return I.add(e.id),[...I]},[x,e.related_books,e.id]),W=B.length-1;g.useEffect(()=>{if(!n||W<=0){w([]);return}const I=B.length<=Ua,U=I?B:B.slice(0,8);let pe=!1;return Promise.all(U.map($e=>$e===e.id?Promise.resolve({id:$e,title:e.title,edition:e.edition,year:xi(e)}):n.getItem($e).then(ye=>{const ue=ye??{};return{id:$e,title:ue.title,edition:ue.edition,year:ye?xi(ue):void 0}}).catch(()=>({id:$e})))).then($e=>{if(pe)return;const ye=$e.filter(ue=>ue.id===e.id||ue.title||ue.edition);I&&ye.sort((ue,Ve)=>(ue.year??1/0)-(Ve.year??1/0)),w(ye)}),()=>{pe=!0}},[n,B,W,e]);const N=e.lineage,A=g.useMemo(()=>[...((N==null?void 0:N.derived_from)||[]).filter(I=>I.ref_type==="book").map(I=>I.ref),...((N==null?void 0:N.related_to)||[]).map(I=>I.book_id)].filter(Boolean),[N]);g.useEffect(()=>{if(!n||A.length===0){k(new Map);return}let I=!1;return Promise.all(A.map(U=>n.getItem(U).then(pe=>[U,{id:U,title:pe==null?void 0:pe.title,edition:pe==null?void 0:pe.edition}]).catch(()=>[U,{id:U}]))).then(U=>{I||k(new Map(U))}),()=>{I=!0}},[n,A]);const F=g.useMemo(()=>dd(e.resources,e.resource_groups,m),[e.resources,e.resource_groups,m]),Y=F.groups.reduce((I,U)=>I+U.rows.length+U.mirrors.length,0),ee=F.groups.length>0&&F.groups.every(I=>I.key==="_physical"),se=Wn(e),D=nc(e),V=Bt(e,u.unit.juan),he=new Set((e._collections||[]).map(I=>Ln(I.vol).length).filter(I=>I>0)),Z=I=>{var $e;const U=($e=e.base_edition)==null?void 0:$e.find(ye=>ye.book_id===I&&ye.name);if(U!=null&&U.name)return U.name;const pe=j.get(I);return(pe==null?void 0:pe.edition)||(pe==null?void 0:pe.title)||""},M=g.useMemo(()=>{var ve,Ae,Oe,Ie,me;const I=[];D&&I.push({label:m("bookPage.fact.editionType"),value:f(D),title:e.edition_type||(ve=e.lineage)!=null&&ve.category?void 0:m("bookPage.inferredFromEdition")}),(Ae=e.publication_info)!=null&&Ae.details?I.push({label:m("bookPage.fact.publication"),value:f(e.publication_info.details)}):(se.era||se.reign)&&I.push({label:m("bookPage.fact.era"),value:f([se.era,se.reign].filter(Boolean).join(" ")),title:se.source==="edition"?m("bookPage.inferredFromEdition"):void 0}),V&&I.push({label:m("bookPage.fact.measure"),value:f(V)});const U=(e._collections||[]).flatMap(Te=>Ln(Te.vol));U.length&&I.push({label:m("bookPage.fact.volumes"),value:m("bookPage.volumesValue",{range:Ri(U,u.unit.volume),unit:u.unit.volume,n:U.length})});const pe=(((Oe=e.lineage)==null?void 0:Oe.derived_from)||[]).find(Te=>Te.relation==="底本"&&Te.ref_type==="book");pe&&Z(pe.ref)&&I.push({label:m("bookPage.fact.baseEdition"),value:t.jsx(et,{id:pe.ref,label:f(Z(pe.ref)),onNavigate:i,renderLink:o,dense:!0})});const $e=(e.base_edition||[]).filter(Te=>Te&&Te.name);for(const Te of["底本","配補","參校"]){if(Te==="底本"&&pe&&Z(pe.ref))continue;const De=$e.filter(Me=>Me.role===Te);De.length&&I.push({label:f(Te),value:De.map((Me,yt)=>t.jsxs(g.Fragment,{children:[yt>0&&"、",Me.book_id?t.jsx(et,{id:Me.book_id,label:f(Me.name),onNavigate:i,renderLink:o,dense:!0}):f(Me.name)]},yt))})}const ye=(e.provenance||[]).filter(Te=>Te&&Te.institution),ue=(e.resources||[]).filter(Te=>Mt(Te).includes("physical"));if(ye.length){I.push({label:m("bookPage.fact.holdings"),value:ye.slice(0,2).map(Me=>f(Me.institution)).join("、")+(ye.length>2?m("bookPage.andMorePlaces",{n:ye.length}):"")});const Te=ye.filter(Me=>Me.call_number).slice(0,2).map(Me=>`${f(Me.institution)} ${Me.call_number}`);Te.length&&I.push({label:m("bookPage.fact.callNumber"),value:Te.join(";")+(ye.filter(Me=>Me.call_number).length>2?"…":"")});const De=ye.flatMap(Me=>Me.seals||[]).filter(Boolean);De.length&&I.push({label:m("bookPage.fact.seals"),value:f(De.join("、"))})}else ue.length?I.push({label:m("bookPage.fact.holdings"),value:ue.slice(0,2).map(Te=>f(Te.name)).join("、")+(ue.length>2?m("bookPage.andMorePlaces",{n:ue.length}):"")}):(Ie=e.current_location)!=null&&Ie.name&&I.push({label:m("bookPage.fact.holdings"),value:f(e.current_location.name)});const Ve=e.physical_description;if(Ve){const Te=[[m("bookPage.fact.leafStyle"),Ve.leaf_style],[m("bookPage.fact.binding"),Ve.binding],[m("bookPage.fact.dimensions"),Ve.dimensions],[m("bookPage.fact.condition"),Ve.condition]];for(const[De,Me]of Te)Me&&Me.trim()&&I.push({label:De,value:f(Me)})}(me=e.page_count)!=null&&me.description&&I.push({label:u.label.pageCount,value:f(e.page_count.description)});const Q=[...Rr(e.additional_titles),...Rr(e.attached_texts)];return Q.length&&I.push({label:m("bookPage.fact.aliases"),value:Q.map(f).join("、")}),I},[e,f,u,m,se,D,V,j,i,o]),_e=f(e.title),ce=e.edition?f(e.edition):void 0,ge=((je=e.lineage)==null?void 0:je.year_text)||"",le=t.jsx(Fn,{kind:m("bookPage.kind"),title:_e,subtitle:ce,byline:t.jsx(Fo,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:i,renderLink:o}),meta:(()=>{const I=[D?f(D):"",se.era?f([se.era,se.reign].filter(Boolean).join("")):"",V?f(V):""].filter(Boolean);return I.length?t.jsx("span",{className:"bim-d-tags",children:I.map((U,pe)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(pe,2)}`,children:U},pe))}):null})(),description:(ke=e.description)!=null&&ke.text?t.jsx(Pt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:go((P=e.description)==null?void 0:P.text)?6:void 0,facts:M,readAction:s,secondaryAction:s&&Y>0&&!ee?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:m("bookPage.viewImages")}):void 0,foot:t.jsx(Hn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),Be=e._collections||[],ze=(a==null?void 0:a.chapters)||[],Fe=f(ze[0]&&fr(ze[0].title)[0].slice(-1)||"")||m("bookPage.chapterUnit"),te=m("bookPage.chapterCount",{n:ze.length,unit:Fe}),H=!!((fe=N==null?void 0:N.derived_from)!=null&&fe.length||(oe=N==null?void 0:N.related_to)!=null&&oe.length||(we=e.appendix)!=null&&we.length),G=[],xe=m(ee?"bookPage.sec.physical":"bookPage.sec.images");(ze.length||F.text.length||l)&&G.push({id:"fulltext",label:m("bookPage.sec.fulltext"),count:ze.length?te:void 0}),F.groups.length&&G.push({id:"images",label:xe,count:Y}),H&&G.push({id:"lineage",label:m("bookPage.sec.lineage")}),Be.length&&G.push({id:"collections",label:m("section.containedIn"),count:Be.length}),(Le=e.location_history)!=null&&Le.length&&G.push({id:"provenance",label:m("section.locationHistory")});const K=I=>(d==null?void 0:d(I))??null,L=ze[0],q=L?K(L.file):null,ae=$?ze:ze.slice(0,Kb),be=(I,U,pe)=>I?t.jsx("a",{className:pe,href:I.href??"#",onClick:I.onClick?$e=>{$e.metaKey||$e.ctrlKey||($e.preventDefault(),I.onClick())}:void 0,children:U}):t.jsx("span",{className:pe,children:U}),X=t.jsxs(t.Fragment,{children:[(ze.length>0||F.text.length>0||l)&&t.jsxs(rt,{id:"fulltext",title:m("bookPage.sec.fulltext"),meta:ze.length>0?t.jsx(it,{items:[te,(He=a==null?void 0:a.source)!=null&&He.name?m("bookPage.sourceBy",{src:f(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!L&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-d-ft","aria-busy":"true",children:[t.jsx("span",{className:"bim-d-ft-h",children:" "}),t.jsx("span",{className:"bim-d-meta",children:" "})]}),t.jsx("div",{className:"bim-d-chap-pending","aria-hidden":"true"})]}),L&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:m("bookPage.readFrom",{ch:f(fr(L.title)[0])||m("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:f((L.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),be(q,t.jsxs(t.Fragment,{children:[m("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),ze.length>1&&t.jsx("ul",{className:"bim-d-chap",children:ae.map(I=>{const[U,pe]=fr(I.title);return t.jsx("li",{children:be(K(I.file),t.jsxs(t.Fragment,{children:[U&&t.jsx("b",{children:f(U)}),f(pe||I.file)]}))},I.file)})}),ze.length>ae.length&&t.jsx(ho,{label:m("detail.expandRest",{n:ze.length-ae.length,unit:Fe}),onClick:()=>C(!0)}),F.text.length>0&&t.jsxs(t.Fragment,{children:[(ze.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:m("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:F.text.map((I,U)=>t.jsx(Ho,{item:I,siblings:F.text,listedVolumeCounts:he},`${I.id||I.url||I.name}-${U}`))})})]})]}),F.groups.length>0&&t.jsx(rt,{id:"images",title:xe,meta:t.jsx(it,{items:[F.groups.length>1?m("bookPage.groupCount",{n:F.groups.length}):"",m("bookPage.placeCount",{n:Y})]}),children:t.jsx(ud,{groups:F.groups,listedVolumeCounts:he})}),H&&t.jsx(rt,{id:"lineage",title:m("bookPage.sec.lineage"),meta:(Ge=N==null?void 0:N.derived_from)!=null&&Ge.length?m("bookPage.lineageMeta"):void 0,action:z?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":m("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":_==="flow",onClick:()=>E("flow"),children:m("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":_==="graph",onClick:()=>E("graph"),children:m("bookPage.viewGraph")})]}):void 0,children:_==="graph"&&z?t.jsx(Do,{graph:z,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(I,U)=>t.jsx(et,{id:I,label:f(U),onNavigate:i,renderLink:o,dense:!0})}):t.jsx(Jb,{data:e,heading:ce||_e,yearText:ge,refName:Z,onNavigate:i,renderLink:o})}),Be.length>0&&t.jsx(rt,{id:"collections",title:m("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:Be.map((I,U)=>{const pe=I.id,$e=Ln(I.vol),ye=y.get(pe),ue=ph(ye);return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(et,{id:pe,label:ye?f(ye.title):pe,onNavigate:i,renderLink:o,dense:!0}),$e.length>0&&t.jsx(Zb,{volumes:$e,unit:u.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${ue?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:ue>0&&m("bookPage.totalOf",{n:ue,unit:u.unit.bu})})]},`${pe}-${U}`)})})})}),(Ye=e.location_history)!=null&&Ye.length?t.jsx(rt,{id:"provenance",title:m("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((I,U)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:f(I.name)}),([I.start_date,I.end_date].filter(Boolean).join("—")||I.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(it,{items:[[I.start_date,I.end_date].filter(Boolean).join("—"),I.description?f(I.description):""]})})]},U))})}):null,G.length===0&&t.jsx(rt,{title:m("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:m("bookPage.emptyText")})})]}),re=b.findIndex(I=>I.id===e.id),Ce=B.length<=Ua,We=Ce&&re>=0?b.slice(Math.max(0,re-Va),re+Va+1):b.filter(I=>I.id!==e.id),O=t.jsxs(t.Fragment,{children:[x&&t.jsxs("div",{id:"work",className:"bim-d-side",style:{scrollMarginTop:16},children:[t.jsx("h2",{className:"bim-d-ui bim-d-side-h",children:f(u.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(et,{id:x.id,label:f(x.title),onNavigate:i,renderLink:o})}),t.jsx(it,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(I=>`${I.dynasty?`〔${f(I.dynasty)}〕`:""}${f(I.name)}`),f(Bt(x,u.unit.juan)),x._edition_count?m("bookPage.editionCount",{n:x._edition_count}):""]}),((Xe=x.description)==null?void 0:Xe.text)&&t.jsx("p",{style:{fontSize:14,lineHeight:1.8,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},className:"bim-d-card-desc bim-d-side-desc",children:f(x.description.text.replace(/[#*_>`[\]]/g,""))})]}),W>0&&We.length>0&&t.jsxs("div",{children:[t.jsx(en,{id:"siblings",timeline:!0,title:Ce?m("bookPage.siblings"):u.relation.siblingVersions,meta:Ce?m("bookPage.byEra"):m("bookPage.kindCount",{n:W}),cap:We.length,items:We.map(I=>I.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:f(I.edition||I.title||I.id)}):t.jsx(et,{id:I.id,label:f(I.edition||I.title||I.id),onNavigate:i,renderLink:o,dense:!0})),metas:We.map(I=>[I.year!=null?I.year<0?m("detail.bce",{n:-I.year}):String(I.year):"",I.id===e.id?m("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:We.findIndex(I=>I.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(et,{id:x.id,label:m("bookPage.viewAllInWork",{n:B.length}),onNavigate:i,renderLink:o,dense:!0})})]})]}),ie=e.work_id?t.jsx(ac,{caption:u.section.belongsToWork,children:t.jsx(et,{id:e.work_id,label:x?f(x.title):" ",onNavigate:i,renderLink:o,dense:!0})}):void 0;return t.jsx(On,{railTop:c,back:p,up:ie,nav:G,railLinks:h,main:X,card:le,side:O})};function Zb({volumes:e,unit:n}){const{t:i}=ne();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[i("bookPage.volumeRange",{range:Ri(e,n),unit:n}),e.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-d-dot"}),i("bookPage.volumeCount",{n:e.length,unit:n})]})]})}function Jb({data:e,heading:n,yearText:i,refName:o,onNavigate:s,renderLink:a}){var S;const{t:l,convert:d}=ne(),c=e.lineage,p=(c==null?void 0:c.derived_from)||[],h=p.filter(b=>b.ref_type!=="book"),u=p.filter(b=>b.ref_type==="book"&&b.relation==="底本"),m=p.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),f=(c==null?void 0:c.related_to)||[],x=p.length>0||f.length>0,v=b=>b&&Xb.has(b)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${b}`)}):"",y=(b,w)=>t.jsx(et,{id:b,label:d(w||b),onNavigate:s,renderLink:a,dense:!0});return t.jsxs("div",{className:"bim-d-lf",children:[x&&t.jsxs("ol",{className:"bim-d-lf-list",children:[h.map((b,w)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:b.relation?d(b.relation):l("bookPage.lineage.ancestor")}),t.jsx("span",{className:"bim-d-lf-name",children:l("bookPage.lineage.reconstructed")}),b.evidence&&t.jsxs("span",{className:"bim-d-meta",children:[d(b.evidence),v(b.confidence)]})]})},`a-${w}`)),u.map((b,w)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-card",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,o(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),v(b.confidence)]})]})},`b-${w}`)),t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-cur",children:[t.jsxs("div",{className:"bim-d-lf-here",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:l("bookPage.lineage.thisEdition")}),t.jsx("span",{className:"bim-d-lf-name",children:n}),i&&t.jsx("span",{className:"bim-d-lf-yr",children:d(i)})]}),m.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:m.map((b,w)=>t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,o(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),v(b.confidence)]})]},w))})]}),f.length>0&&t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-out",children:[t.jsx("span",{className:"bim-d-lf-out-h bim-d-ui",children:l("bookPage.lineage.derivatives")}),t.jsx("span",{className:"bim-d-lf-chips",children:f.map((b,w)=>t.jsxs("span",{className:"bim-d-lf-chip",title:b.evidence?d(b.evidence):void 0,children:[y(b.book_id,o(b.book_id)),t.jsx("span",{className:"bim-d-meta",children:d(b.relation)})]},w))})]})]}),(S=e.appendix)==null?void 0:S.map((b,w)=>t.jsxs("details",{className:"bim-d-lf-app",children:[t.jsxs("summary",{className:"bim-d-ui",children:[t.jsx("span",{className:"bim-d-meta",children:l("bookPage.lineage.appendix")})," ",d(b.title)]}),t.jsx(Pt,{text:b.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${w}`)),(c==null?void 0:c.note)&&t.jsx("p",{className:"bim-d-meta",style:{margin:"12px 0 0",maxWidth:"46em"},children:d(c.note)})]})}const Nn=16,Qb=200,ey=16,bd=({data:e,catalog:n,transport:i,onNavigate:o,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var re,Ce,We,O,ie,je,ke;const{t:p,convert:h,messages:u}=ne(),[m,f]=g.useState(""),[x,v]=g.useState(!1),[y,S]=g.useState(null),[b,w]=g.useState(""),[j,k]=g.useState(!1),$=g.useMemo(()=>ec(e,n),[e,n]),C=g.useMemo(()=>Ql(e),[e]),[_,E]=g.useState(new Map),z=!!i&&$.rows.length>0&&$.rows.length<=Qb,T=z&&($.rows.length<=Nn||j),B=T&&$.rows.every(P=>!P.id||_.has(P.id)),W=P=>{var fe;return Fr(P?(fe=_.get(P))==null?void 0:fe.l1:void 0)},N=g.useMemo(()=>{const P=m.trim(),fe=P?h(P):"";return $.rows.filter(oe=>{var Le,He;if(b&&Fr(oe.id?(Le=_.get(oe.id))==null?void 0:Le.l1:void 0)!==b)return!1;if(!fe)return!0;const we=oe.id&&((He=_.get(oe.id))==null?void 0:He.title)||oe.title;return h(we).includes(fe)||(oe.subItems||[]).some(Ge=>h(Ge).includes(fe))})},[$.rows,m,b,_,h]),A=x?N:N.slice(0,Nn),F=g.useMemo(()=>(T?$.rows:A).filter(P=>P.id&&!_.has(P.id)).map(P=>P.id),[T,$.rows,A,_]);g.useEffect(()=>{if(!i||F.length===0)return;let P=!1;const fe=F.slice(0,ey);return Pi(fe,Mi,oe=>i.getItem(oe).then(we=>{var Ge,Ye;const Le=we??{},He={title:Le.title,edition:Le.edition,authors:Le.authors,measure:we?Bt(we,u.unit.juan):void 0,versionCount:Le._edition_count??((Ge=Le._books)==null?void 0:Ge.length),l1:((Ye=uo(Le))==null?void 0:Ye.l1)||void 0};return[oe,He]}).catch(()=>[oe,{}]),()=>P).then(oe=>{P||E(we=>{const Le=new Map(we);for(const[He,Ge]of oe)Le.set(He,Ge);return Le})}),()=>{P=!0}},[i,F,u.unit.juan]);const Y=(re=(e.contained_in||[])[0])==null?void 0:re.id;g.useEffect(()=>{if(!Y){S(null);return}if(S({id:Y}),!i)return;let P=!1;return i.getItem(Y).then(fe=>{P||S({id:Y,title:fe==null?void 0:fe.title})}).catch(()=>{}),()=>{P=!0}},[i,Y]);const ee=g.useMemo(()=>dd(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),se=ee.text.length+ee.groups.reduce((P,fe)=>P+fe.rows.length+fe.mirrors.length,0),D=C.works,V=new Set($.rows.map(P=>P.id).filter(Boolean)),he=D.length>0&&!D.every(P=>V.has(P.id)),Z=(()=>{const P=$.rows.map(fe=>fe.edition).filter(Boolean);return P.length>1&&new Set(P).size===1})(),M=$.rows.some(P=>P.volumes.length>0||P.expected!=null),_e=C.total,ce=C.truncated?_e:$.rows.length,ge=Bt(e,u.unit.juan),le=e.count,Be=P=>typeof P=="number"&&Number.isFinite(P)?P:null,ze=Be(le==null?void 0:le.juan)??Be((Ce=e.juan_count)==null?void 0:Ce.number),Fe=Be(le==null?void 0:le.ce)??($.totalVolumes||null),te=[{value:ce,label:p("collectionPage.stat.titles")},{value:ze??0,label:u.unit.juan},{value:Fe??0,label:u.unit.volume}],H=g.useMemo(()=>{var oe,we;const P=[];if((oe=e.publication_info)!=null&&oe.details&&P.push({label:p("collectionPage.fact.publication"),value:h(e.publication_info.details)}),_e&&(_e!==$.rows.length||C.truncated)){const Le=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");P.push({label:Le,value:`${_e} ${u.unit.bu}`,title:p("collectionPage.memberNote")})}const fe=[Be(le==null?void 0:le.zhong)!=null?p("collectionPage.nZhong",{n:le.zhong}):"",Be(le==null?void 0:le.han)!=null?p("collectionPage.nHan",{n:le.han}):""].filter(Boolean);return fe.length&&P.push({label:p("collectionPage.fact.expected"),value:fe.join(" ")}),ze==null&&ge&&P.push({label:p("collectionPage.fact.measure"),value:h(ge),title:(we=e.juan_count)!=null&&we.description?h(e.juan_count.description):void 0}),P},[e,_e,C.truncated,$.rows.length,ze,ge,le,h,p,u]),G=g.useMemo(()=>{if(!B)return[];const P=new Map;for(const oe of $.rows){const we=W(oe.id);we&&P.set(we,(P.get(we)??0)+1)}const fe=Mn.filter(oe=>(P.get(oe.key)??0)>0);return fe.length<2?[]:[{key:"",label:`${u.catalog.all} ${ce}`},...fe.map(oe=>({key:oe.key,label:`${oe.label} ${P.get(oe.key)}`}))]},[B,$.rows,_,u]),xe=g.useMemo(()=>{if(!B||!$.rows.some(we=>we.volumes.length>0))return null;const P=[],fe=$.rows.filter(we=>we.volumes.length>0).map(we=>({k:W(we.id)??"",from:Math.min(...we.volumes),to:Math.max(...we.volumes)})).sort((we,Le)=>we.from-Le.from);for(const we of fe){const Le=we.to-we.from+1,He=P[P.length-1];He&&He.key===we.k?(He.to=Math.max(He.to,we.to),He.n+=Le):P.push({key:we.k,from:we.from,to:we.to,n:Le})}const oe=fe.reduce((we,Le)=>Math.max(we,Le.to),0);return P.length>1&&P.some(we=>we.key)?{segs:P,last:oe}:null},[B,$.rows,_]),K=(We=e.description)==null?void 0:We.text,L=t.jsx(Fn,{kind:p("collectionPage.kind"),title:h(e.title),byline:t.jsx(Fo,{authors:e.authors,onNavigate:o,renderLink:s}),meta:t.jsx(it,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(O=e.publication_info)!=null&&O.year?h(e.publication_info.year):""]}),description:K||(ie=e.history)!=null&&ie.length?t.jsxs(t.Fragment,{children:[K&&t.jsx(Pt,{text:K,style:{fontSize:15,lineHeight:1.85}}),(je=e.history)!=null&&je.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((P,fe)=>t.jsx("li",{children:h(P)},fe))}):null]}):void 0,clampDescription:go(K)||(((ke=e.history)==null?void 0:ke.length)??0)>2?6:void 0,stats:te,facts:H,foot:t.jsx(Hn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:xe&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:p("collectionPage.dist.head")})}),t.jsx("div",{className:"bim-d-dist-bar",role:"group","aria-label":p("collectionPage.dist.head"),children:xe.segs.map((P,fe)=>{const oe=Mn.find(we=>we.key===P.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!oe,title:oe?p("collectionPage.dist.segTitle",{section:h(oe.label),from:P.from,to:P.to}):void 0,"aria-label":oe?p("collectionPage.dist.only",{section:h(oe.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!oe&&b===P.key,style:{flexGrow:P.n,background:r(oe?oe.token:"rule")},onClick:()=>{oe&&(w(b===P.key?"":P.key),v(!1))}},fe)})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:p("catalog.volume",{n:1})}),t.jsx("span",{children:p("collectionPage.dist.hint")}),t.jsx("span",{children:p("catalog.volume",{n:xe.last})})]})]})}),q=[];$.rows.length&&q.push({id:"titles",label:p("collectionPage.sec.titles"),count:ce}),se&&q.push({id:"resources",label:p("collectionPage.sec.resources"),count:se}),he&&q.push({id:"works",label:u.section.containedWorks,count:D.length});const ae=t.jsxs(t.Fragment,{children:[$.rows.length>0&&t.jsxs(rt,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(it,{items:[`${ce} ${u.unit.items}`,$.totalVolumes?p("collectionPage.totalVolumes",{n:$.totalVolumes,unit:u.unit.volume}):"",N.length!==ce?p("collectionPage.currentN",{n:N.length,unit:u.unit.items}):""]}),action:a,children:[($.rows.length>Nn||G.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[G.length>0&&t.jsx(Ei,{items:G,value:b,onChange:P=>{w(P),v(!1)}}),z&&$.rows.length>Nn&&!B&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:j,onClick:()=>k(!0),title:p("collectionPage.loadAllTitle",{n:$.rows.length,unit:u.unit.items}),children:p(j?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),$.rows.length>Nn&&t.jsx("input",{type:"search",className:"bim-d-find",value:m,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:P=>{f(P.target.value),v(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Li(N.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[M&&t.jsx("th",{style:{width:"8.5em"},children:p("collectionPage.col.volumes")}),t.jsx("th",{children:p("collectionPage.col.title")}),t.jsx("th",{style:{textAlign:"right"},children:p("collectionPage.col.versions")})]})}),t.jsx("tbody",{children:A.map((P,fe)=>{var Xe;const oe=P.id?_.get(P.id):void 0,we=oe!=null&&oe.title&&P.title===P.id?oe.title:P.title,Le=((oe==null?void 0:oe.authors)||[]).find(I=>I&&I.name),He=[Le?`${Le.dynasty?`〔${h(Le.dynasty)}〕`:""}${h(Le.name)}${Le.role?` ${h(Le.role)}`:""}`:"",oe!=null&&oe.measure?h(oe.measure):"",(Xe=P.subItems)!=null&&Xe.length?P.subItems.map(I=>h(I)).join("、"):"",(oe!=null&&oe.edition||P.edition)&&!Z?h((oe==null?void 0:oe.edition)||P.edition||""):""].filter(Boolean),Ge=Mn.find(I=>I.key===W(P.id)),Ye=P.volumes.length>0?p("collectionPage.volumeRange",{range:Ri(P.volumes,u.unit.volume),unit:u.unit.volume}):P.expected!=null?`${P.found??0}/${P.expected} ${u.unit.volume}`:"";return t.jsxs("tr",{children:[M&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Ye?"":" bim-d-zt-blank"}`,children:[Ge&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:r(Ge.token)}}),Ye||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[P.id?t.jsx(et,{id:P.id,label:h(we),onNavigate:o,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:h(we)}),He.length>0?t.jsx(it,{items:He}):P.id&&!oe&&i?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${oe!=null&&oe.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:oe!=null&&oe.versionCount?p("collectionPage.nZhong",{n:oe.versionCount}):""})]},`${P.id??P.title}-${fe}`)})})]}),A.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!x&&t.jsx(mo,{total:N.length,shown:A.length,unit:u.unit.items,onClick:()=>v(!0)})]}),se>0&&t.jsxs(rt,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:se}),children:[ee.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[ee.groups.length>0&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:p("collectionPage.text")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:ee.text.map((P,fe)=>t.jsx(Ho,{item:P,siblings:ee.text},`${P.id||P.url||P.name}-${fe}`))})})]}),t.jsx(ud,{groups:ee.groups})]}),$.rows.length===0&&se===0&&t.jsx(rt,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),be=he?t.jsx(en,{id:"works",title:u.section.containedWorks,meta:p("collectionPage.nZhong",{n:D.length}),cap:12,items:D.map(P=>t.jsx(et,{id:P.id,label:h(P.title),onNavigate:o,renderLink:s,dense:!0}))}):null,X=y?t.jsx(ac,{caption:p("collectionPage.parent"),children:t.jsx(et,{id:y.id,label:h(y.title||y.id),onNavigate:o,renderLink:s,dense:!0})}):void 0;return t.jsx(On,{railTop:l,back:d,up:X,nav:q,railLinks:c,main:ae,card:L,side:be})},ty=16,xr=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function Ga(e){if(!e)return xr.length;const n=xr.indexOf(e);return n===-1?xr.length:n}function ny(e,n,i){if(n)return e[n]??i(n)}function iy(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const ry={秦:[-221,-207],西漢:[-202,8],西汉:[-202,8],東漢:[25,220],东汉:[25,220],漢:[-202,220],汉:[-202,220],三國:[220,280],三国:[220,280],西晉:[265,316],西晋:[265,316],東晉:[317,420],东晋:[317,420],隋:[581,618],唐:[618,907],五代:[907,960],北宋:[960,1127],南宋:[1127,1279],宋:[960,1279],遼:[916,1125],辽:[916,1125],金:[1115,1234],元:[1271,1368],明:[1368,1644],清:[1636,1912]},yd=({data:e,transport:n,onNavigate:i,renderLink:o,railTop:s,back:a,railLinks:l})=>{var be,X,re,Ce,We;const{t:d,convert:c,messages:p}=ne(),h=O=>iy(O,d),[u,m]=g.useState("全部"),[f,x]=g.useState(!1),[v,y]=g.useState("default"),[S,b]=g.useState(new Map),w=g.useMemo(()=>e._works||[],[e._works]),j=g.useMemo(()=>w.map(O=>{const ie=S.get(O.work_id);return{id:O.work_id,title:(ie==null?void 0:ie.title)??O.title??O.work_id,role:O.role||"",cls:lo(O.role),versionCount:ie==null?void 0:ie.versionCount,section:ie==null?void 0:ie.cls,l1:ie==null?void 0:ie.l1,measure:ie==null?void 0:ie.measure,hasImage:ie==null?void 0:ie.hasImage,loaded:!!(ie!=null&&ie.loaded)}}),[w,S]),k=g.useMemo(()=>Jl(w.map(O=>O.role),d("detail.roleAll")),[w,d]),$=g.useMemo(()=>{const O=u==="全部"?j:j.filter(ie=>ie.cls===u);return v==="versions"?[...O].sort((ie,je)=>(je.versionCount??-1)-(ie.versionCount??-1)):O},[j,u,v]),C=f?$:$.slice(0,ty),_=g.useMemo(()=>C.filter(O=>!S.has(O.id)).map(O=>O.id),[C,S]);g.useEffect(()=>{if(!n||_.length===0)return;let O=!1;return Pi(_,Mi,ie=>n.getItem(ie).then(je=>{var we;const ke=je??{},P=ke._edition_count??((we=ke._books)==null?void 0:we.length)??0,fe=uo(ke),oe=[fe==null?void 0:fe.l1,fe==null?void 0:fe.l2].filter(Boolean).join(" ");return[ie,{id:ie,title:ke.title,versionCount:P,loaded:!0,cls:oe||void 0,l1:(fe==null?void 0:fe.l1)||void 0,measure:je&&Bt(je,p.unit.juan)||void 0,hasImage:!!ke._has_image}]}).catch(()=>[ie,{id:ie,loaded:!0}]),()=>O).then(ie=>{O||b(je=>{const ke=new Map(je);for(const[P,fe]of ie)ke.set(P,fe);return ke})}),()=>{O=!0}},[n,_,p.unit.juan]);const E=g.useMemo(()=>{const O=new Map;for(const ie of e.alt_names||[]){const je=ie.type||p.section.aliases;O.has(je)||O.set(je,[]),O.get(je).push(ie.name)}return[...O.entries()].sort((ie,je)=>Ga(ie[0])-Ga(je[0])).map(([ie,je])=>({label:ie,names:je}))},[e.alt_names,p]),z=e.birth_year??((be=e.dates)==null?void 0:be.birth)??void 0,T=e.death_year??((X=e.dates)==null?void 0:X.death)??void 0,B=(re=e.dates)==null?void 0:re.floruit,W=z!=null||T!=null?`${h(z)||"?"}—${h(T)||"?"}`:Array.isArray(B)&&B.length===2&&B.every(O=>Number.isFinite(O))?d("entityPage.floruit",{from:h(B[0]),to:h(B[1])}):"",N=new Set(["本名","字","號","号"]),A=E.filter(O=>N.has(O.label)),F=E.filter(O=>!N.has(O.label)),Y=F.reduce((O,ie)=>O+ie.names.length,0),ee=g.useMemo(()=>{const O=[];for(const je of A)O.push({label:je.label,value:je.names.map(ke=>c(ke)).join("、")});const ie=w.length;return ie&&O.push({label:d("entityPage.fact.works"),value:d("entityPage.nZhong",{n:ie})}),O},[w,A,c,d]),se=O=>{var ie;return(ie=E.find(je=>O.includes(je.label)))==null?void 0:ie.names[0]},D=se(["字"]),V=se(["號","号"]),he=[D?d("entityPage.zi",{name:c(D)}):"",V?d("entityPage.hao",{name:c(V)}):""].filter(Boolean).join(","),Z=e.native_place,M=e.dynasty?ry[e.dynasty]:void 0,_e=(()=>{if(!M||z==null||T==null||T<z)return null;const[O,ie]=M,je=Math.max(z,O),ke=Math.min(T,ie);if(ke<=je)return null;const P=ie-O;return t.jsxs("div",{className:"bim-d-life bim-d-ui",children:[t.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":d("entityPage.lifeAria",{birth:h(z),death:h(T),years:T-z+1}),children:t.jsx("i",{style:{left:`${(je-O)/P*100}%`,width:`${(ke-je)/P*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${h(O)} ${c(e.dynasty)}`}),t.jsx("span",{children:d("entityPage.lifeYears",{years:T-z+1})}),t.jsx("span",{children:h(ie)})]})]})})(),ce=g.useMemo(()=>{if(!n||j.length===0||j.some(je=>!je.loaded))return null;const O=new Map;for(const je of j){const ke=Fr(je.l1);ke&&O.set(ke,(O.get(ke)??0)+1)}const ie=Mn.map(je=>({...je,n:O.get(je.key)??0})).filter(je=>je.n>0);return ie.length?ie:null},[j,n]),ge=t.jsxs(Fn,{kind:ny(p.entityPage.subtype,e.subtype,c),title:c(e.primary_name||e.title),subtitle:he||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(it,{items:[e.dynasty?c(e.dynasty):"",W,Z?d("entityPage.nativePlace",{place:c(Z)}):""]}),_e]}),description:(Ce=e.description)!=null&&Ce.text?t.jsx(Pt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:go((We=e.description)==null?void 0:We.text)?6:void 0,facts:ee,foot:t.jsx(Hn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[Y>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:d("entityPage.moreNames",{n:Y})}),t.jsx("dl",{children:F.map(O=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:c(O.label)}),t.jsx("dd",{children:O.names.map(ie=>c(ie)).join("、")})]},O.label))})]}),ce&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:d("entityPage.dist")})}),t.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:ce.map(O=>t.jsx("i",{style:{flexGrow:O.n,background:r(O.token)}},O.key))}),t.jsx("div",{className:"bim-d-dist-key",children:ce.map(O=>t.jsxs("span",{children:[t.jsx("i",{style:{background:r(O.token)}}),c(O.label)," ",O.n]},O.key))})]})]}),le=g.useMemo(()=>j.filter(O=>O.loaded&&(O.versionCount??0)>0).sort((O,ie)=>(ie.versionCount??0)-(O.versionCount??0)).slice(0,3),[j]),Be=!!n&&j.length>=3&&C.some(O=>!O.loaded),ze=u==="全部"&&(Be||le.length>=2),Fe=e.external_ids||{},te=[];Fe.cbdb_id!=null&&te.push({label:"CBDB",id:String(Fe.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${Fe.cbdb_id}`,note:Fe.cbdb_match==="auto"?d("entityPage.autoMatch"):void 0});const H=Fe.wikidata_id;H&&te.push({label:"Wikidata",id:H,href:`https://www.wikidata.org/wiki/${H}`});const G=Fe.viaf_id;G&&te.push({label:"VIAF",id:G,href:`https://viaf.org/viaf/${G}`});const xe=k.map(O=>({key:O.cls,label:`${O.label} ${O.count}`})),K=[...ze&&!Be?[{id:"featured",label:d("entityPage.sec.featured"),count:le.length}]:[],...j.length?[{id:"works",label:d("entityPage.sec.allWorks"),count:j.length}]:[],...te.length?[{id:"external",label:d("entityPage.sec.external"),count:te.length}]:[]],L=ze?t.jsxs(rt,{id:"featured",title:d("entityPage.sec.featured"),children:[t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:d("entityPage.featuredSub")}),t.jsxs("div",{className:"bim-d-picks","aria-busy":Be||void 0,children:[Be&&[0,1,2].map(O=>t.jsxs("div",{className:"bim-d-pick","aria-hidden":"true",children:[t.jsx("span",{className:"bim-d-pick-t",children:" "}),t.jsx("span",{className:"bim-d-meta",children:" "}),t.jsx("div",{className:"bim-d-pick-n",children:" "})]},O)),!Be&&le.map(O=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(et,{id:O.id,label:c(O.title),onNavigate:i,renderLink:o,dense:!0})}),t.jsx(it,{items:[O.section?c(O.section):"",O.measure?c(O.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:O.versionCount}),t.jsx("span",{children:d("entityPage.versionsUnit")}),O.hasImage&&t.jsx("span",{className:"bim-d-flag",children:d("entityPage.hasImage")})]})]},O.id))]})]}):null,q=j.length===0?t.jsx(rt,{title:d("entityPage.sec.works"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:d("entityPage.empty")})}):t.jsxs(t.Fragment,{children:[L,t.jsxs(rt,{id:"works",title:d("entityPage.sec.works"),meta:t.jsx(it,{items:[d("entityPage.total",{n:j.length}),$.length!==j.length?d("entityPage.current",{n:$.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[xe.length>1&&t.jsx(Ei,{items:xe,value:u,onChange:O=>{m(O),x(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":v==="versions",onClick:()=>{v==="default"&&x(!0),y(O=>O==="default"?"versions":"default")},children:d(v==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!f&&Li($.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:d("entityPage.col.work")}),t.jsx("th",{children:d("entityPage.col.section")}),t.jsx("th",{children:d("entityPage.col.role")}),t.jsx("th",{children:d("entityPage.col.versions")}),t.jsx("th",{"aria-label":d("entityPage.col.image")})]})}),t.jsx("tbody",{children:C.map(O=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(et,{id:O.id,label:c(O.title),onNavigate:i,renderLink:o,dense:!0}),O.measure?t.jsx(it,{items:[c(O.measure)]}):!O.loaded&&n?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${O.section||O.loaded?"":" bim-d-zt-blank"}`,children:O.section?c(O.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${O.role?"":" bim-d-zt-blank"}`,children:O.role?c(O.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${O.loaded?"":" bim-d-zt-blank"}`,children:O.loaded?O.versionCount?d("entityPage.nZhong",{n:O.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:d("entityPage.notRecorded")}):""}),t.jsx("td",{className:O.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:O.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:d("entityPage.hasImage")})})]},O.id))})]}),C.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:d("entityPage.emptyRole")}),!f&&t.jsx(mo,{total:$.length,shown:C.length,unit:d("entityPage.moreUnit"),onClick:()=>x(!0)})]})]}),ae=te.length>0?t.jsx(en,{id:"external",title:d("entityPage.sec.external"),items:te.map(O=>t.jsxs("a",{href:O.href,target:"_blank",rel:"noopener noreferrer",children:[O.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:te.map(O=>O.id),foot:Fe.cbdb_id!=null&&Fe.cbdb_match==="auto"?d("entityPage.cbdbAuto"):void 0}):null;return t.jsx(On,{railTop:s,back:a,nav:K,railLinks:l,main:q,card:ge,side:ae})},Uo="(max-width: 719px)",oy=`${Uo}, (pointer: coarse)`,jd=`
|
|
1353
|
+
${L??""}`,[Vi,Qo]=g.useState({key:ot,data:U,started:!!U});if(Vi.key!==ot)Qo({key:ot,data:U,started:!1});else if(U!==Vi.data&&(Qo({key:ot,data:U,started:!!U}),U)){const R=U.pages??[];(!Vi.started||!R.some(de=>de.page===Re))&&qe(J(U))}g.useEffect(()=>{ve(new Set),Oe(null)},[L,ce]);const xp=g.useCallback(R=>{if(ve(new Set(R)),R.length>0){const de=R[0],Ne=parseInt(de.split(":")[0],10);isNaN(Ne)||qe(Ne)}},[]),zt=g.useMemo(()=>{const R=new Map;for(const de of(U==null?void 0:U.pages)??[])R.set(de.page,de);return R},[U]),vn=Wt(U),Gn=g.useCallback(R=>{var Ue;const de=I.images;if(!de||de.length===0)return;const Ne=(Ue=zt.get(R))==null?void 0:Ue.seq;return(Ne?de.find(Je=>Je.seq===Ne):void 0)??de.find(Je=>Je.pageNo===R)??de[R-1]},[I.images,zt]),es=Me>1.5,Yn=g.useCallback((R,de=!1)=>{const Ne=Gn(R);return Ne?R===vn||de?Ne.hiresUrl??Ne.url:Ne.url:R===vn?(U==null?void 0:U.imageUrl)??"":""},[Gn,U,vn]),bp=g.useMemo(()=>Yn(Re,es),[Yn,Re,es]),Nt=g.useMemo(()=>[...zt.keys()].sort((R,de)=>R-de),[zt]),qn=g.useRef(Re);qn.current=Re;const ts=g.useRef(0),Kn=g.useCallback(R=>{var de;qn.current===R||!zt.has(R)||(ts.current=Date.now()+1e3,qn.current=R,qe(R),(de=zt.get(R))!=null&&de.columns.some(Ne=>Ne.chars.length>0)&&on(Ne=>({page:R,nonce:((Ne==null?void 0:Ne.nonce)??0)+1})))},[zt]),kn=g.useCallback(R=>{const de=qn.current,Ne=Nt.indexOf(de),Ue=Nt[Ne<0?0:Ne+R];Ue===void 0||Ue===de||Kn(Ue)},[Nt,Kn]),ns=g.useCallback(R=>{if(!R.trim().match(/^\d+$/)||Nt.length===0)return null;const Ne=parseInt(R.trim(),10),Ue=Number.isFinite(Ne)?Ne:Number.MAX_SAFE_INTEGER;return Nt.reduce((Je,vt)=>Math.abs(vt-Ue)<Math.abs(Je-Ue)?vt:Je,Nt[0])},[Nt]),[Gi,Yi]=g.useState(null),Xn=g.useRef(null),yp=g.useCallback(R=>{Xn.current=R,Yi(R)},[]),is=g.useCallback(()=>{const R=Xn.current;if(Xn.current=null,Yi(null),R===null)return;const de=ns(R);de!==null&&Kn(de)},[ns,Kn]),qi=Nt.indexOf(Re),jp=g.useCallback(R=>{if(R.altKey||R.ctrlKey||R.metaKey)return;const de=R.target.tagName;de==="INPUT"||de==="TEXTAREA"||de==="SELECT"||(R.key==="ArrowLeft"||R.key==="PageUp"?(R.preventDefault(),kn(-1)):(R.key==="ArrowRight"||R.key==="PageDown")&&(R.preventDefault(),kn(1)))},[kn]);g.useEffect(()=>{if(U)for(const R of[1,-1,2,3]){const de=Yn(Re+R);de&&Ar(de)}},[U,Re,Yn]);const rs=g.useMemo(()=>{var gs;if(!U)return null;if(Re===vn)return U;const R=zt.get(Re);if(R&&R.width>0&&R.height>0)return{page_id:`p:${Re}`,title:`第${Re}葉`,image_size:[R.width,R.height],total_warped_w:R.width,columns:[{col:1,warped_w:R.width,warped_h:R.height,offset_x:0,strips:[],chars:R.columns.flatMap(Ze=>Ze.chars).map(Ze=>({id:Ze.id,char:Ze.char,slot:Ze.slot,pos:Ze.pos,sub:Ze.sub,bbox_col:Ze.bbox??[0,0,0,0]}))}]};const de=(gs=U.pages)==null?void 0:gs.find(Ze=>Ze.page===Re),[Ne,Ue]=U.image_size||[2386,3082],Je=Gn(Re),vt=(Je==null?void 0:Je.width)??Ne,Qi=(Je==null?void 0:Je.height)??Ue,us=vt/Ne,ms=Qi/Ue,hs=new Map;for(const Ze of U.columns){const ut=(Ze.strips||[]).flatMap(ti=>ti.srcQuad.map(ni=>ni[0]));if(ut.length===0)continue;const It=Ze.top_y??0,er=Ze.bottom_y??It+Ze.warped_h;hs.set(Ze.col,{x0:Math.min(...ut),x1:Math.max(...ut),top:It,slotH:(er-It)/21})}return{page_id:`p:${Re}`,title:`第${Re}葉`,image_size:[vt,Qi],total_warped_w:vt,columns:de?de.columns.map(Ze=>{const ut=hs.get(Ze.col)??{x0:0,x1:0,top:0,slotH:118};return{col:Ze.col,warped_w:vt,warped_h:Qi,offset_x:0,strips:[],chars:Ze.chars.map(It=>{const er=It.slot??It.pos??0,ti=(ut.top+(er-1)*ut.slotH)*ms,ni=(ut.x0+ut.x1)/2,[Tp,zp]=It.sub==="a"?[ni,ut.x1]:It.sub==="b"?[ut.x0,ni]:[ut.x0,ut.x1];return{...It,bbox_col:[Tp*us,ti,zp*us,ti+ut.slotH*ms]}})}}):[]}},[U,Re,vn,zt,Gn]),{entryTitle:Zn,authors:os}=Pf(n,i,d===void 0),[ss,Ki]=g.useState("text");if(g.useEffect(()=>{Ki("text")},[L,ce]),F==="loading")return t.jsx(ha,{className:k,style:$,title:d??Zn,label:C("reader.loading")});if(F==="missing"||!N||!M)return t.jsx("div",{className:k,style:{...$,...ma},children:C("reader.noText")});if(H==="failed")return t.jsx("div",{className:k,style:{...$,...ma},children:C("reader.tocFailed")});if(!K)return t.jsx(ha,{className:k,style:$,title:d??Zn,label:C("reader.tocLoading")});const Yt=Rf(M,K),vp=Ef(K,Ge,Yt,_,P),Xi=N.versions.map(R=>({key:R.key,label:Se.textVersionLabel(R),optionLabel:_(Se.textVersionLabel(R)),sourceName:fa(R)?C("reader.originalSource"):R.source_name?_(R.source_name):void 0,license:R.license??void 0,sourceUrl:R.source_url??void 0,primary:R.key===_e})),pt=Nf((ps=K.source)==null?void 0:ps.upstream),Jn=(typeof d=="string"?_(d):d)??(K.title?_(K.title):Zn?_(Zn):void 0),as=M.edition_label?_(M.edition_label):void 0,Zi=Jn?t.jsx("a",{href:B(n),title:C("reader.viewEntry"),onClick:l?R=>{R.metaKey||R.ctrlKey||(R.preventDefault(),l(n))}:void 0,children:Jn}):void 0,kp=Zi&&as?t.jsxs(t.Fragment,{children:[Zi,t.jsxs("span",{className:"bim-rd-ed",children:["·",as]})]}):Zi,wp=os.length>0?_(os.slice(0,2).map(R=>`${R.dynasty?`〔${R.dynasty}〕`:""}${R.name}${` ${R.role||C("reader.defaultRole")}`}`).join("、")):void 0,Ji=q?Yc(q,Yt,_,P):void 0,qt=P&&!!(re!=null&&re.json),Kt=(re==null?void 0:re.json)??null,sn=(re==null?void 0:re.md)??null,ls=qt&&!Le&&Wc(Kt.sections),Sp=ls&&!(sn&&ue.readingMode==="paragraph"&&bi(sn)),_p=qt&&ls?t.jsx(tf,{juan:Kt,view:ss,onView:Ki,textHasEntries:Sp}):void 0,$p=!0,Qn=sn?sn.replace(/^##\s+[^\n]+\n+/,""):null,ei=fa(M),Ot=ei?C("reader.originalSource"):M.source_name?_(M.source_name):void 0,Cp=(typeof c=="string"?_(c):c)??(ei?void 0:Ot??_(Se.textVersionLabel(M)));return t.jsxs(Gl,{className:k,style:$,title:kp,subtitle:Cp,byline:wp,current:Ji,pagerUnit:Yt,rail:_p,revisedAt:x,backHref:v,backLabel:y,onReportError:f?R=>f({...R,bookTitle:typeof Jn=="string"?Jn:void 0,entryId:n}):void 0,workLinkToggle:qt&&!Le&&!!l&&!!(Kt!=null&&Kt.sections.some(R=>R.work_id)),toc:vp,tocCaption:C("reader.tocCaption",{n:K.chapters.length,unit:_(Yt)}),tocHeader:P&&K.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:Le?C("reader.searchChaptersPlaceholder"):C("reader.searchUnitPlaceholder",{unit:_(Yt)}),"aria-label":Le?C("reader.searchChapters"):C("reader.searchUnit",{unit:_(Yt)}),value:fe,onChange:R=>oe(R.target.value)}):void 0,activeKey:L??null,onSelect:X,images:I.images,imagesLoading:I.loading||pe,renderImageOverlay:h,imagePanel:U?"open":u,isWarpMode:!!U,customImagePanel:U&&rs?t.jsxs("div",{className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:jp,style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",outline:"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 4px 6px",fontSize:12,color:r("meta-fg"),gap:8,flexWrap:"wrap"},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:4},children:t.jsx("span",{style:{fontWeight:600,marginRight:4},children:"底本书影"})}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[ee.size>0&&t.jsxs("button",{type:"button",onClick:()=>ve(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${r("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",ee.size,")"]}),t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:2},"data-testid":"facsimile-zoom-tools",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"缩小",title:"缩小",disabled:Me<=1,onClick:()=>{var R;return(R=De.current)==null?void 0:R.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(Me*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:Me>=6,onClick:()=>{var R;return(R=De.current)==null?void 0:R.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:Me===1,onClick:()=>{var R;return(R=De.current)==null?void 0:R.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(Cf,{ref:De,resetKey:Re,onScaleChange:yt,style:{flex:1,minHeight:0},children:t.jsx(Ro,{imageUrl:bp,pageData:rs,selectedCharIds:ee,hoveredCharId:Ae,preserveMargins:Te,onCharClick:R=>{ve(Ne=>{const Ue=new Set(Ne);return Ue.has(R)?Ue.delete(R):(Ue.clear(),Ue.add(R)),Ue});const de=document.querySelector(`[data-char-id="${R}"]`);de&&de.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:Oe})}),t.jsxs("div",{"data-testid":"facsimile-pager",role:"group","aria-label":C("reader.facsimilePager"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,padding:"6px 4px 0",fontSize:13,color:r("meta-fg")},children:[t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-prev","aria-label":"上一葉",style:{minWidth:40,minHeight:40,fontSize:20,lineHeight:1},disabled:qi<=0,onClick:()=>kn(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":Re,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"1px 8px",background:r("rule"),borderRadius:10},children:["第",t.jsx("input",{type:"text",inputMode:"numeric","data-testid":"facsimile-page-input","aria-label":C("reader.facsimilePageInput"),size:Math.max(2,String(Gi??Re).length),value:Gi??String(Re),onFocus:R=>R.currentTarget.select(),onChange:R=>yp(R.target.value),onKeyDown:R=>{R.key==="Enter"?(R.preventDefault(),is()):R.key==="Escape"&&(Xn.current=null,Yi(null)),R.stopPropagation()},onBlur:is,style:{width:`${Math.max(2,String(Gi??Re).length)+1}ch`,minHeight:28,textAlign:"center",font:"inherit",border:`1px solid ${r("rule")}`,borderRadius:4,background:"transparent",color:"inherit"}}),"葉"]}),t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-next","aria-label":"下一葉",style:{minWidth:40,minHeight:40,fontSize:20,lineHeight:1},disabled:qi<0||qi>=Nt.length-1,onClick:()=>kn(1),children:"›"})]})]}):void 0,settingsAnnotate:U?t.jsx("button",{type:"button",className:`bim-rd-t bim-rd-sp-tg ${Ie?"bim-rd-on":""}`,"aria-pressed":Ie,title:"切换外挂现代断句标点",onClick:()=>me(R=>!R),children:Ie?"标点":"无标点"}):void 0,prefs:ue,onPrefsChange:T,versions:Xi.length>1?Xi:void 0,currentVersionKey:Xi.length>1?M.key:void 0,onVersionChange:be,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:bi(sn),allowVertical:m,children:[(je||pe&&!U&&!qt&&Qn==null)&&t.jsx(nn,{}),!je&&U&&t.jsxs("article",{className:"bim-rd-prose",style:{marginTop:0},children:[t.jsxs("header",{style:{marginBottom:16},children:[t.jsx("h1",{className:"bim-rd-h1",children:q!=null&&q.title?_(q.title):Ji}),(Ot||M.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[Ot,M.license&&t.jsxs(t.Fragment,{children:[Ot&&t.jsx("span",{className:"bim-rd-dot"}),M.license]})]})]}),t.jsx(Mo,{pageData:U,pages:U.pages,punctuations:U.punctuations||zf,selectedCharIds:ee,hoveredCharId:Ae,onSelectionChange:xp,onCharClick:R=>{ve(Ne=>{const Ue=new Set(Ne);return Ue.has(R)?Ue.delete(R):(Ue.clear(),Ue.add(R)),Ue});const de=parseInt(R.split(":")[0],10);isNaN(de)||qe(de)},onCharHover:Oe,mode:"horizontal",showPunctuation:Ie,entities:Ve,entityTransport:i,onEntityNavigate:j,onVisiblePageChange:R=>{Date.now()>=ts.current&&qe(R)},convert:_,scrollToPage:jt,pageBreaks:ue.pageBreaks,pageIndicatorY:ue.pageIndicatorY,onPageIndicatorYChange:R=>T({pageIndicatorY:R}),quoteStyle:ue.quoteStyle,bookTitleStyle:ue.bookTitleStyle,showWorks:ue.showWorks})]}),!je&&!U&&qt&&Kt&&t.jsx(Qg,{juan:Kt,rawText:sn,positionLabel:Af(q,K,Yt,_),groupLabel:Mf(K,L??null),index:If(n,K),searchQuery:fe,onNavigate:l,transport:i,workLabelCache:Ye,prefs:ue,view:ss,onViewChange:Ki},`${ce}/${L}`),!je&&!U&&!qt&&Qn!=null&&q&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:q.title?_(q.title):Ji}),(Ot||M.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[ei&&Ot&&t.jsx(t.Fragment,{children:Ot}),!ei&&M.source_name&&t.jsxs(t.Fragment,{children:[C("reader.textSource")," ",M.source_url?t.jsx("a",{className:"bim-rd-link",href:M.source_url,target:"_blank",rel:"noreferrer",children:_(M.source_name)}):_(M.source_name)]}),Ot&&M.license&&t.jsx("span",{className:"bim-rd-dot"}),M.license]}),pt&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[C("reader.upstream")," ",pt.url?t.jsx("a",{className:"bim-rd-link",href:pt.url,target:"_blank",rel:"noreferrer",children:_(pt.name??pt.url)}):_(pt.name??""),pt.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),pt.license_url?t.jsx("a",{className:"bim-rd-link",href:pt.license_url,target:"_blank",rel:"noreferrer",children:pt.license}):pt.license]}),pt.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(Ll,{text:pt.note,convert:_})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(So,{text:Qn,mode:ue.readingMode,tables:$p,gujiMarkdown:!0,bookMarking:ko(ue),quoteStyle:ue.quoteStyle})})]}),!je&&!pe&&!U&&!qt&&Qn==null&&q&&t.jsx("div",{className:"bim-rd-state",children:C("reader.chapterFailed")}),K.references&&K.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:C("reader.references")}),t.jsx("ol",{children:K.references.map((R,de)=>t.jsxs("li",{children:[R.url?t.jsx("a",{className:"bim-rd-link",href:R.url,target:"_blank",rel:"noopener noreferrer",children:_(R.title)}):t.jsx("span",{children:_(R.title)}),R.author&&t.jsxs("span",{children:[",",_(R.author)]}),R.note&&t.jsxs("span",{children:["。",_(R.note)]})]},de))})]})]})};function fa(e){return e.is_original===!0||e.source==="original"}function Af(e,n,i,o){var a,l;if(!e)return;const s=(l=(a=n.juan_metadata)==null?void 0:a[e.file])==null?void 0:l.vol_label;return o(s?`${s}冊`:`${i}${e.n}`)}function Mf(e,n){if(!n)return;const i=o=>{var s;for(const a of o??[]){const l=i(a.children);if(l)return l;if((s=a.files)!=null&&s.includes(n))return a.label}};return i(e.juan_groups)}function Pf(e,n,i){const[o,s]=g.useState({entryTitle:void 0,authors:[]});return g.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let a=!1;return Promise.resolve(n.getItem(e)).then(l=>{if(a||!l)return;const d=(l.authors??[]).filter(c=>c&&c.name);s({entryTitle:i&&typeof l.title=="string"?l.title:void 0,authors:d})}).catch(()=>{}),()=>{a=!0}},[e,n,i]),o}const qc={bug:{key:"bug",color:r("danger")},resource:{key:"resource",color:r("primary")},suggestion:{key:"suggestion",color:r("primary")},other:{key:"other",color:r("desc-fg")}},Bf=qc.other,Kc={pending:{key:"pending",color:r("warning")},in_progress:{key:"in_progress",color:r("primary")},resolved:{key:"resolved",color:r("success")},wontfix:{key:"wontfix",color:r("desc-fg")},duplicate:{key:"duplicate",color:r("desc-fg")}},Wf=Kc.pending;function Of(e){try{const n=new Date(e),i=o=>String(o).padStart(2,"0");return`${n.getFullYear()}-${i(n.getMonth()+1)}-${i(n.getDate())} ${i(n.getHours())}:${i(n.getMinutes())}`}catch{return e}}function Ff(e,n){if(!e)return!1;try{const i=new URL(e,n);if(i.protocol!=="http:"&&i.protocol!=="https:")return!1;const o=new URL(n);return i.hostname===o.hostname}catch{return!1}}const Wo=({items:e,loading:n})=>{const i=tt(),{t:o,convert:s}=ne();return n?t.jsx(nn,{}):e.length===0?t.jsx("div",{style:Hf,children:o("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=qc[a.type]||Bf,d=Kc[a.status]||Wf,c=typeof window<"u"&&Ff(a.pageUrl,window.location.href);return t.jsxs("div",{style:Df,children:[t.jsxs("div",{style:Uf,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...xa,background:l.color},children:o(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...xa,background:d.color},children:o(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:Vf,children:Of(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:Gf,children:[a.resourceId&&t.jsx("a",{href:i(a.resourceId),style:pr,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:pr,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:pr,children:a.pageUrl}))]}),t.jsx("div",{style:Yf,children:s(a.content)}),a.reply&&t.jsxs("div",{style:qf,children:[t.jsx("div",{style:Kf,children:o("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},Hf={textAlign:"center",padding:"40px 0",color:r("desc-fg"),fontSize:"14px"},Df={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"16px"},Uf={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},xa={fontSize:"12px",color:r("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},Vf={fontSize:"12px",color:r("desc-fg")},Gf={fontSize:"12px",marginBottom:"6px"},pr={color:r("primary"),textDecoration:"none",borderBottom:`1px dashed ${r("primary")}`},Yf={fontSize:"14px",lineHeight:"1.6",color:r("fg"),whiteSpace:"pre-wrap"},qf={marginTop:"12px",padding:"10px 12px",background:r("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:r("fg")},Kf={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:r("primary")},Pr=({transport:e,onNavigate:n,recommendedIds:i,activeTab:o,onTabChange:s,feedbackApiUrl:a})=>{const l=Ee(),[d,c]=g.useState(null),[p,h]=g.useState([]),[u,m]=g.useState("recommend"),[f,x]=g.useState([]),[v,y]=g.useState(!1),S=o??u,b=A=>{m(A),s==null||s(A)},[w,j]=g.useState(!0),[k,$]=g.useState(null),[C,_]=g.useState(null),[E,z]=g.useState(null);g.useEffect(()=>{let A=!1;if(e.getCounts)return e.getCounts().then(F=>{A||c({works:F.works,books:F.books,collections:F.collections})}).catch(()=>{}),()=>{A=!0}},[e]),g.useEffect(()=>{let A=!1;return(async()=>{if(i)return i;if(e.getRecommended)try{const Y=await e.getRecommended();if(Y!=null&&Y.groups)return Y.groups.flatMap(te=>te.items.map(se=>({...se,group:te.name})))}catch{}return[]})().then(async Y=>{if(A)return;const te=Y.filter(D=>D.id);if(te.length===0){j(!1);return}const se=await Promise.all(te.map(async D=>{if(D.type)return{id:D.id,title:D.title,type:D.type,author:D.author,dynasty:D.dynasty,role:D.role,edition:D.edition,has_text:D.has_text,has_image:D.has_image,has_collated:D.has_collated,subtype:D.subtype,primary_name:D.primary_name,group:D.group,fallbackDescription:D.description};try{let V=null;if(e.getEntry)V=await e.getEntry(D.id);else{const he=await e.getItem(D.id);he&&(V={id:D.id,title:he.title||D.id,type:he.type||"work"})}if(V)return{...V,group:D.group,fallbackDescription:D.description}}catch{}return{id:D.id,title:D.title,type:Se.extractType(D.id),group:D.group,fallbackDescription:D.description}}));A||(h(se.filter(D=>D!==null)),j(!1))}),()=>{A=!0}},[e,i]);const T=g.useRef(!1),B=g.useRef(!1),W=g.useRef(!1);g.useEffect(()=>{if(S!=="catalog"||T.current)return;const A=e.getCatalogProgress??e.getResourceProgress;if(!A)return;T.current=!0;let F=!1;return A.call(e).then(Y=>{F||$(Y)}).catch(()=>{T.current=!1}),()=>{F=!0}},[e,S]),g.useEffect(()=>{if(S!=="collection"||B.current||!e.getCollectionProgress)return;B.current=!0;let A=!1;return e.getCollectionProgress().then(F=>{A||_(F)}).catch(()=>{B.current=!1}),()=>{A=!0}},[e,S]),g.useEffect(()=>{if(S!=="site"||W.current||!e.getSiteProgress)return;W.current=!0;let A=!1;return e.getSiteProgress().then(F=>{A||z(F)}).catch(()=>{W.current=!1}),()=>{A=!0}},[e,S]),g.useEffect(()=>{if(!a||S!=="feedback")return;let A=!1;return y(!0),fetch(a).then(F=>F.json()).then(F=>{!A&&F.success&&x(F.items||[])}).catch(()=>{}).finally(()=>{A||y(!1)}),()=>{A=!0}},[a,S]);const N=A=>t.jsx(jn,{type:A,size:12});return t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:r("fg")},children:t.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[t.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${r("widget-border")}`,marginBottom:"16px"},children:[t.jsx(Cn,{label:l.home.recommendTab,active:S==="recommend",onClick:()=>b("recommend")}),t.jsx(Cn,{label:l.home.catalogTab,active:S==="catalog",onClick:()=>b("catalog")}),t.jsx(Cn,{label:l.home.collectionTab,active:S==="collection",onClick:()=>b("collection")}),t.jsx(Cn,{label:l.home.siteTab,active:S==="site",onClick:()=>b("site")}),a&&t.jsx(Cn,{label:l.home.feedbackTab,active:S==="feedback",onClick:()=>b("feedback")})]}),S==="recommend"&&t.jsx(Xf,{recommended:p,loading:w,onNavigate:n,getIcon:N,t:l}),S==="catalog"&&t.jsx(ba,{progress:k,t:l,onNavigate:n}),S==="collection"&&t.jsx(ba,{progress:C,t:l,onNavigate:n}),S==="site"&&t.jsx(Jf,{progress:E,t:l,totalWorks:(d==null?void 0:d.works)??0}),S==="feedback"&&a&&t.jsx(Wo,{items:f,loading:v})]})})},Cn=({label:e,active:n,onClick:i})=>t.jsx("button",{onClick:i,style:{padding:"8px 16px",fontSize:"14px",fontWeight:n?600:400,color:r(n?"primary":"desc-fg"),background:"none",border:"none",borderBottom:n?`2px solid ${r("primary")}`:"2px solid transparent",cursor:"pointer",marginBottom:"-1px"},children:e}),Xf=({recommended:e,loading:n,onNavigate:i,getIcon:o,t:s})=>{const a=tt();if(n)return t.jsx(nn,{});if(e.length===0)return null;const l=new Map;for(const d of e){const c=d.group||s.home.recommendedBrowse;l.has(c)||l.set(c,[]),l.get(c).push(d)}return t.jsx(t.Fragment,{children:Array.from(l.entries()).map(([d,c])=>t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:d}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"8px"},children:c.map(p=>{const h=p.dynasty||p.author?`${p.dynasty?`〔${p.dynasty}〕`:""}${p.author||""}`:p.fallbackDescription;return t.jsxs("a",{href:a(p.id),onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),i==null||i(p.id))},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,cursor:"pointer",background:r("input-bg"),textDecoration:"none",color:"inherit"},children:[t.jsx("span",{style:{fontSize:"20px"},children:o(p.type)}),t.jsxs("div",{style:{minWidth:0},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[p.title,p.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:r("desc-fg"),marginLeft:"4px"},children:p.edition})]}),h&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h})]})]},p.id)})})]},d))})},ba=({progress:e,t:n,onNavigate:i})=>{if(!e)return t.jsx(nn,{});const o=[...e.resources].sort((d,c)=>d.priority-c.priority),s=["in_progress","done","todo"],a={in_progress:n.home.statusInProgress,done:n.home.statusDone,todo:n.home.statusTodo},l={in_progress:r("progress-active"),done:r("progress-done"),todo:r("progress-todo")};return t.jsx("div",{children:s.map(d=>{const c=o.filter(p=>p.status===d);return c.length===0?null:t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:l[d]}}),a[d]," (",c.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c.map(p=>t.jsx(Zf,{item:p,t:n,statusColor:l[d],onNavigate:i},p.id))})]},d)})})},Zf=({item:e,t:n,statusColor:i,onNavigate:o})=>{const s=tt(),a=e.total>0?Math.round(e.imported/e.total*100):0,l=e.type==="catalog"?n.home.typeCatalog:n.home.typeCollection;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(()=>{const d=e.edition?`${e.name}·${e.edition}`:e.name,c=e.collection_id||e.work_id;return c&&o?t.jsx("a",{href:s(c),onClick:p=>{p.metaKey||p.ctrlKey||(p.preventDefault(),o(c))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`},onMouseEnter:p=>p.currentTarget.style.borderBottomStyle="solid",onMouseLeave:p=>p.currentTarget.style.borderBottomStyle="dashed",children:d}):e.url?t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:d}):d})()}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"4px",background:r("widget-border"),color:r("desc-fg"),whiteSpace:"nowrap"},children:e.collection_id?n.indexType.collection:e.work_id?n.indexType.work:l})]}),t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.total>0?gt(n.home.progressFormat,{imported:String(e.imported),total:String(e.total)}):n.home.totalPending})]}),e.total>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:r("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${a}%`,borderRadius:"2px",background:i,transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"4px"},children:e.description})]})},Jf=({progress:e,t:n,totalWorks:i})=>{if(!e)return t.jsx(nn,{});const o=[...e.resources].sort((c,p)=>c.priority-p.priority),s=o.filter(c=>c.imported>0),a=o.filter(c=>c.imported===0),l=s.reduce((c,p)=>Math.max(c,p.imported),0),d=i>0?Math.round(l/i*100):0;return t.jsxs("div",{children:[i>0&&t.jsxs("div",{style:{padding:"12px 16px",marginBottom:"16px",borderRadius:"8px",background:`color-mix(in srgb, ${r("primary")} 6%, transparent)`,fontSize:"13px",color:r("fg")},children:[n.home.siteCoverage,": ",t.jsx("strong",{children:l.toLocaleString()})," / ",i.toLocaleString()," ",n.indexType.work," (",d,"%)"]}),s.length>0&&t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:r("progress-done")}}),n.home.statusInProgress," (",s.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(c=>t.jsx(ya,{item:c,t:n,totalWorks:i},c.id))})]}),a.length>0&&t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:r("progress-todo")}}),n.home.statusTodo," (",a.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:a.map(c=>t.jsx(ya,{item:c,t:n,totalWorks:i},c.id))})]})]})},ya=({item:e,t:n,totalWorks:i})=>{const o=i>0?Math.round(e.imported/i*100):0;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:t.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:e.url?t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:e.name}):e.name})}),t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.imported>0?`${e.imported.toLocaleString()} ${n.indexType.work} (${o}%)`:n.home.statusTodo})]}),e.imported>0&&i>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:r("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${o}%`,borderRadius:"2px",background:r("progress-done"),transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"4px"},children:e.description})]})},ja="(max-width: 768px)";function Qf(){const[e,n]=g.useState(()=>typeof window>"u"?!1:window.matchMedia(ja).matches);return g.useEffect(()=>{const i=window.matchMedia(ja),o=s=>n(s.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),e}const ex=({transport:e,hideModeIndicator:n=!0,onEntryClick:i,recommendedIds:o,headerRight:s})=>{var B;const a=Ee(),{convert:l}=Pe(),d=Qf(),[c,p]=g.useState(null),[h,u]=g.useState(null),[m,f]=g.useState(!1),[x,v]=g.useState("detail"),[y,S]=g.useState([]),[b,w]=g.useState(!1),j=g.useCallback(async W=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){S([]);return}w(!0);try{if(e.getCollectionCatalogs){const N=await e.getCollectionCatalogs(W);S(N||[])}else if(e.getCollectionCatalog){const N=await e.getCollectionCatalog(W);S(N?[{resource_id:"",data:N}]:[])}}catch{S([])}finally{w(!1)}},[e]),k=g.useCallback(async W=>{if(i){i(W);return}p(W),u(null),S([]),v("detail"),f(!0);try{const N=await e.getItem(W.id);N&&(u(N),N.type==="collection"&&j(W.id))}catch(N){console.error("加载详情失败:",N)}finally{f(!1)}},[e,i,j]),$=g.useCallback(async W=>{u(null),S([]),v("detail"),f(!0);try{const N=await e.getItem(W);N&&(u(N),p({id:W,title:N.title||W,type:N.type||"book"}),N.type==="collection"&&j(W))}catch(N){console.error("导航失败:",N)}finally{f(!1)}},[e,j]),C=typeof(h==null?void 0:h.text_count)=="number"&&h.text_count>0,_=(h==null?void 0:h.type)==="collection"&&(y.length>0||b)||(h==null?void 0:h.type)==="work"&&C,E=d&&(m||h),z=g.useCallback(()=>{p(null),u(null),S([]),v("detail")},[]),T=t.jsx(t.Fragment,{children:m?t.jsx(nn,{}):h?t.jsxs(t.Fragment,{children:[(_||s)&&t.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${r("widget-border")}`,padding:d?"0 12px":"0 48px",background:r("input-bg"),flexShrink:0,overflowX:d?"auto":void 0},children:[_&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>v("detail"),style:li(x==="detail"),children:a.detailTab.basicInfo}),h.type==="collection"&&b&&y.length===0&&t.jsxs("button",{onClick:()=>{},style:li(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),h.type==="collection"&&y.map(W=>t.jsx("button",{onClick:()=>v(`catalog:${W.resource_id}`),style:li(x===`catalog:${W.resource_id}`),children:W.short_name?`${l(W.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},W.resource_id)),h.type==="work"&&C&&t.jsx("button",{onClick:()=>v("collated"),style:li(x==="collated"),children:a.detailTab.collatedEdition})]}),s&&t.jsx("div",{style:{marginLeft:"auto",flexShrink:0,padding:"4px 0"},children:s})]}),t.jsx("div",{style:{padding:d?"16px 12px":"32px 48px",maxWidth:"900px",flex:1,overflow:"auto"},children:x==="detail"?t.jsx(to,{data:h,transport:e,onNavigate:$}):x.startsWith("catalog:")?t.jsx(no,{data:(B=y.find(W=>`catalog:${W.resource_id}`===x))==null?void 0:B.data,onNavigate:$}):x==="collated"?t.jsx(Bo,{id:h.id,transport:e,onNavigate:$}):null})]}):t.jsx(Pr,{transport:e,onNavigate:$,recommendedIds:o})});return d?t.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:r("bg"),color:r("fg")},children:E?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${r("widget-border")}`,background:r("input-bg"),flexShrink:0},children:t.jsxs("button",{onClick:z,style:{padding:"4px 12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px"},children:["← ",a.detailTab.basicInfo]})}),t.jsx("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:T})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(kr,{transport:e,onEntryClick:k,hideModeIndicator:n}),!h&&t.jsx(Pr,{transport:e,onNavigate:$,recommendedIds:o})]})}):t.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:r("bg"),color:r("fg")},children:[t.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:`1px solid ${r("widget-border")}`,display:"flex",flexDirection:"column",background:r("input-bg"),overflow:"hidden"},children:t.jsx("div",{style:{flex:1,overflow:"auto"},children:t.jsx(kr,{transport:e,onEntryClick:k,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:r("bg"),display:"flex",flexDirection:"column"},children:T})]})};function li(e){return{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${r("primary")}`:"2px solid transparent",background:"transparent",color:r(e?"primary":"desc-fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}const tx=({pageData:e,rawImageUrl:n="",punctuations:i=[],title:o,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=g.useState(new Set),[h,u]=g.useState(null),[m,f]=g.useState("horizontal"),[x,v]=g.useState(!0),y=g.useRef(null),S=g.useCallback(k=>{p(new Set(k))},[]),b=g.useCallback(k=>{if(p($=>{const C=new Set($);return C.has(k)?C.delete(k):(C.clear(),C.add(k)),C}),y.current){const $=y.current.querySelector(`[data-char-id="${k}"]`);$&&$.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),w=()=>{var k;p(new Set),window.getSelection&&((k=window.getSelection())==null||k.removeAllRanges())},j=i.length>0?i:e.punctuations||[];return t.jsxs("div",{className:`guji-reader-container ${l}`,style:d,children:[t.jsxs("header",{className:"guji-reader-header",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a&&t.jsx("button",{type:"button",onClick:a,className:"guji-reader-btn",style:{marginRight:6},children:"‹ 返回"}),t.jsx("span",{className:"guji-reader-title",children:o||e.title}),s&&t.jsx("span",{style:{fontSize:"0.85rem",color:r("meta-fg")},children:s}),t.jsx("span",{className:"guji-reader-tag",children:"WebGL 客户端透视矫正对读"})]}),t.jsxs("div",{className:"guji-reader-actions",children:[t.jsxs("span",{style:{fontSize:"0.85rem",color:r("body-fg")},children:["已选字数: ",t.jsx("strong",{style:{color:r("accent")},children:c.size})]}),c.size>0&&t.jsx("button",{type:"button",onClick:w,className:"guji-reader-btn",children:"清除选中"}),t.jsx("button",{type:"button",onClick:()=>v(k=>!k),className:`guji-reader-btn ${x?"active":""}`,title:"独立外挂标点 (guji-punct v0.1)",children:x?"✓ 标点":"底本文本"}),t.jsx("button",{type:"button",onClick:()=>f(k=>k==="horizontal"?"vertical":"horizontal"),className:"guji-reader-btn primary",children:m==="horizontal"?"切换竖排":"切换横排"})]})]}),t.jsxs("div",{className:"guji-reader-body",children:[t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%",position:"sticky",top:0},children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:"底本书影 (WebGL 分带透视矫正 + 完整版心)"}),t.jsx("span",{className:"guji-pane-hint",children:"点击字框可联动文本定位"})]}),t.jsx("div",{className:"guji-pane-content",children:t.jsx(Ro,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:h,onCharClick:b,onCharHover:u})})]}),t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%"},ref:y,children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:m==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(Mo,{pageData:e,punctuations:j,selectedCharIds:c,hoveredCharId:h,onSelectionChange:S,onCharClick:b,onCharHover:u,mode:m,showPunctuation:x})]})]})]})},nx=e=>typeof e=="string"&&Array.from(e).length===1;function ix(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.punctuations)?e.punctuations:[],i=[];for(const o of n){if(!o||typeof o!="object")continue;const s=o;typeof s.anchor!="string"||typeof s.mark!="string"||s.pre_char!=null&&!nx(s.pre_char)||i.push({id:typeof s.id=="string"?s.id:void 0,anchor:s.anchor,mark:s.mark,kind:s.kind,pos:s.pos,pre_char:s.pre_char??void 0})}return i}function rx(e){var i;const n=e&&typeof e=="object"?e.pages:void 0;if(!Array.isArray(n))return null;for(const o of n){const s=/\/iiif\/([^/]+)\/canvas\/([^/]+)\//.exec(String(((i=o==null?void 0:o.canvas)==null?void 0:i.id)??""));if(s)return{bookId:s[1],vol:s[2]}}return null}const ox=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function st(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}const sx=new Set(["main","solo","jz_r","jz_l"]),ax=new Set(["body","banxin","blank"]);function lx(e){const n={};return typeof e.lane=="string"&&sx.has(e.lane)&&e.lane!=="main"&&(n.lane=e.lane),e.lacuna===!0&&(n.lacuna=!0),e.guess===!0&&(n.guess=!0),typeof e.zi=="string"&&e.zi&&(n.zi=e.zi),n}function cx(e){const n={};typeof e.kind=="string"&&ax.has(e.kind)&&e.kind!=="body"&&(n.kind=e.kind);const i=st(e.raised);i!==void 0&&Number.isInteger(i)&&i>0&&(n.raised=i);const o=st(e.lead_blank);return o!==void 0&&Number.isInteger(o)&&o>0&&(n.lead_blank=o),n}function ur(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(i=>!!i&&typeof i=="object"):[]}function dx(e,n){var c,p,h,u,m,f,x,v,y,S;const i=new Map,o=new Map;for(const b of ur(n)){const w=st(b.page);if(w!==void 0){i.set(w,b);for(const j of Array.isArray(b.cells)?b.cells:[]){const k=j==null?void 0:j.box;typeof(j==null?void 0:j.a)=="string"&&Array.isArray(k)&&k.length===4&&k.every($=>st($)!==void 0)&&o.set(j.a,[k[0],k[1],k[0]+k[2],k[1]+k[3]])}}}const s=[],a=new Map,l=new Map;for(const b of ur(e)){const w=st(b.page);w!==void 0&&typeof b.label=="string"&&b.label&&a.set(w,b.label)}for(const b of ur(e)){const w=st(b.page);if(w===void 0)continue;const j=[];for(const $ of Array.isArray(b.columns)?b.columns:[]){const C=st($==null?void 0:$.col);if(C===void 0)continue;const _=[];for(const z of Array.isArray($.cells)?$.cells:[]){const T=ox.exec(String((z==null?void 0:z.a)??""));if(!T||typeof z.c!="string")continue;const B=parseInt(T[3],10);_.push({id:z.a,char:z.c,slot:B,pos:B,sub:T[4]||null,bbox:o.get(z.a)??null,...lx(z)})}const E=cx($);(_.length>0||E.kind==="blank")&&j.push({col:C,chars:_,...E})}if(!j.some($=>$.chars.length>0)){j.length>0&&l.set(w,j);continue}j.sort(($,C)=>$.col-C.col);const k=i.get(w);s.push({page:w,seq:String(((c=k==null?void 0:k.canvas)==null?void 0:c.seq)??""),width:st((p=k==null?void 0:k.canvas)==null?void 0:p.width)??st((h=k==null?void 0:k.image)==null?void 0:h.width)??0,height:st((u=k==null?void 0:k.canvas)==null?void 0:u.height)??st((m=k==null?void 0:k.image)==null?void 0:m.height)??0,...typeof b.label=="string"&&b.label?{label:b.label}:{},columns:j})}const d=new Set(s.map(b=>b.page));for(const[b,w]of i){const j=(f=w==null?void 0:w.canvas)==null?void 0:f.seq;d.has(b)||typeof j!="string"&&typeof j!="number"||String(j)===""||s.push({page:b,seq:String(j),width:st((x=w.canvas)==null?void 0:x.width)??st((v=w.image)==null?void 0:v.width)??0,height:st((y=w.canvas)==null?void 0:y.height)??st((S=w.image)==null?void 0:S.height)??0,...a.has(b)?{label:a.get(b)}:{},columns:l.get(b)??[]})}return s.sort((b,w)=>b.page-w.page)}const px=({data:e,onNavigate:n,className:i,style:o})=>{var h;const{t:s,convert:a}=ne(),[l,d]=g.useState(((h=e.divisions[0])==null?void 0:h.name)??null),[c,p]=g.useState(null);return t.jsxs("div",{className:i,style:o,children:[t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:r("fg"),margin:"0 0 8px"},children:a(e.title)}),e.stats&&t.jsxs("div",{style:{fontSize:"13px",color:r("desc-fg"),display:"flex",gap:"16px"},children:[e.total_volumes!=null&&t.jsxs("span",{children:[s("catalog.totalVolumes")," ",t.jsx("strong",{children:e.total_volumes})," ",s("unit.juan")]}),e.stats.zhulu!=null&&t.jsxs("span",{children:[s("catalogPage.zhulu")," ",t.jsx("strong",{children:e.stats.zhulu})," ",s("unit.bu")]}),e.stats.cunmu!=null&&t.jsxs("span",{children:[s("catalogPage.cunmu")," ",t.jsx("strong",{children:e.stats.cunmu})," ",s("unit.bu")]}),e.stats.categories!=null&&t.jsx("span",{children:s("catalogPage.categoriesN",{n:e.stats.categories})})]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.divisions.map(u=>t.jsx(ux,{division:u,expanded:l===u.name,onToggle:()=>d(l===u.name?null:u.name),expandedCat:c,onCatToggle:m=>p(c===m?null:m),onNavigate:n},u.name))})]})},ux=({division:e,expanded:n,onToggle:i,expandedCat:o,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=ne(),c=e.categories.reduce((p,h)=>{const u=h.stats||{zhulu:0,cunmu:0};return p+(u.zhulu||0)+(u.cunmu||0)},0);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:"none",background:n?`color-mix(in srgb, ${r("primary")} 6%, transparent)`:r("bg"),cursor:"pointer",fontSize:"15px",fontWeight:600,color:r("fg"),textAlign:"left"},children:[t.jsx("span",{children:d(e.name)}),t.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg")},children:[l("catalogPage.divisionStat",{cats:e.categories.length,books:c}),t.jsx("span",{style:{marginLeft:"8px"},children:n?"▲":"▼"})]})]}),n&&t.jsx("div",{style:{padding:"4px 0"},children:e.categories.map(p=>{const h=`${e.name}/${p.name}`;return t.jsx(mx,{category:p,expanded:o===h,onToggle:()=>s(h),onNavigate:a},p.name)})})]})},mx=({category:e,expanded:n,onToggle:i,onNavigate:o})=>{var p,h,u,m;const{t:s,convert:a}=ne(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((h=e.books)==null?void 0:h.cunmu)||[],c=(((u=e.stats)==null?void 0:u.zhulu)||l.length)+(((m=e.stats)==null?void 0:m.cunmu)||d.length);return t.jsxs("div",{children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px 6px 28px",border:"none",background:n?r("input-bg"):"transparent",cursor:"pointer",fontSize:"13px",color:r("fg"),textAlign:"left"},children:[t.jsxs("span",{style:{fontWeight:500},children:[a(e.name),e.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:a(e.volumes)})})]}),t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[s("catalogPage.booksN",{n:c})," ",n?"▲":"▼"]})]}),n&&(l.length>0||d.length>0)&&t.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[l.length>0&&t.jsx(va,{label:s("catalogPage.zhulu"),books:l,onNavigate:o}),d.length>0&&t.jsx(va,{label:s("catalogPage.cunmu"),books:d,onNavigate:o})]})]})},va=({label:e,books:n,onNavigate:i})=>{const{t:o,convert:s}=ne(),a=tt(),[l,d]=g.useState(n.length<=20),c=l?n:n.slice(0,10);return t.jsxs("div",{style:{marginBottom:"8px"},children:[t.jsxs("div",{style:{fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},children:[e," (",n.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((p,h)=>t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[t.jsx("span",{style:{fontWeight:500,color:r("fg")},children:p.work_id&&i?t.jsx("a",{href:a(p.work_id),onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),i(p.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`},children:s(p.title)}):s(p.title)}),p.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:s(p.volumes)}),p.author&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:s(p.author).slice(0,20)})]},h))}),!l&&t.jsx("button",{onClick:()=>d(!0),style:{marginTop:"4px",padding:"2px 12px",fontSize:"11px",color:r("primary"),background:"transparent",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:o("catalogPage.expandAllN",{n:n.length})})]})},kt=({title:e,onSave:n,onAskAI:i,extraButtons:o,children:s})=>{const a=Ee();return t.jsxs("div",{style:{background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",paddingBottom:"8px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:r("fg")},children:e}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[o,i&&t.jsx("button",{onClick:i,style:gx,children:"AI"}),n&&t.jsx("button",{onClick:n,style:hx,children:a.action.save})]})]}),s]})},hx={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},gx={padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},ht=({label:e,value:n,onChange:i,placeholder:o,disabled:s})=>t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:{display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},children:e}),t.jsx("input",{type:"text",value:n,onChange:a=>i(a.target.value),placeholder:o,disabled:s,style:{width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]}),tn=({value:e,onChange:n,placeholder:i})=>{const o=g.useRef(null);return g.useEffect(()=>{o.current&&(o.current.style.height="auto",o.current.style.height=`${o.current.scrollHeight}px`)},[e]),t.jsx("textarea",{ref:o,value:e||"",onChange:s=>n(s.target.value),placeholder:i,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},ji=({children:e,color:n,style:i})=>t.jsx("span",{style:{display:"inline-block",padding:"2px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",background:n||r("primary-soft"),color:r(n?"on-color-fg":"fg"),...i},children:e});function fx(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const mi=({value:e,onChange:n,label:i})=>{const[o,s]=g.useState(!1),a=g.useRef(null),l=fx(e||"");return g.useEffect(()=>{o&&a.current&&a.current.focus()},[o]),!o&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:ka,children:i}),t.jsxs("div",{onClick:()=>s(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:`1px solid ${r("input-border")}`,borderRadius:"2px",background:r("input-bg"),cursor:"pointer",minHeight:"30px"},children:[t.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:r("fg")},children:l.name}),t.jsx(ji,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:ka,children:i}),t.jsx("input",{ref:a,type:"text",value:e||"",onChange:d=>n(d.target.value),onBlur:()=>s(!1),style:{width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},ka={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500};function xx(e){switch(e){case"url":return r("source-url");case"bookID":return r("source-bookid");default:return r("desc-fg")}}function bx(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const Xc=({items:e,onChange:n,onOpenEntityPicker:i})=>{const o=Ee(),[s,a]=g.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=u=>{n(e.filter((m,f)=>f!==u)),s===u&&a(null)},c=(u,m,f)=>{const x=[...e];x[u]={...x[u],[m]:f},n(x)},p=(u,m)=>{const f=[...e];f[u]={...f[u],type:m,id:"",name:""},n(f),m==="bookID"&&i&&i(x=>{const v=[...e];v[u]={...v[u],id:x.id,name:x.title,type:"bookID"},n(v)})},h=u=>{i&&i(m=>{const f=[...e];f[u]={...f[u],id:m.id,name:m.title,type:"bookID"},n(f)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((u,m)=>t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>a(s===m?null:m),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===m?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:r("fg")},children:u.name||`${o.editor.sourcePlaceholder} ${m+1}`}),u.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:xx(u.type),color:r("on-color-fg"),borderRadius:"3px",fontWeight:500},children:bx(u.type)}),t.jsx("button",{onClick:f=>{f.stopPropagation(),d(m)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:o.editor.deleteThisSource,children:"✕"})]}),s===m&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!u.type&&t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:o.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(m,"bookID"),style:{...wa,borderColor:r("source-bookid"),color:r("source-bookid")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"📚"}),t.jsx("span",{children:"Book ID"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.fromExistingBook})]}),t.jsxs("button",{onClick:()=>p(m,"url"),style:{...wa,borderColor:r("source-url"),color:r("source-url")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),t.jsx("span",{children:"URL"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.enterUrl})]})]})]}),u.type==="bookID"&&t.jsx(t.Fragment,{children:t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:Rt,children:o.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const f=[...e];f[m]={...f[m],type:"",id:"",name:""},n(f)},style:Sa,children:o.action.changeType})]}),u.id&&u.name?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:r("bg"),border:`1px solid ${r("source-bookid")}`,borderRadius:"6px"},children:[t.jsx("span",{style:{color:r("source-bookid"),fontSize:"16px"},children:"✓"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:u.name}),t.jsx("code",{style:{fontSize:"11px",background:r("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:u.id})]}),t.jsx("button",{onClick:()=>h(m),style:{background:"transparent",border:`1px solid ${r("widget-border")}`,color:r("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:o.action.reselect})]}):t.jsxs("button",{onClick:()=>h(m),style:{width:"100%",padding:"14px",border:`2px dashed ${r("widget-border")}`,borderRadius:"6px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[t.jsx("span",{children:"🔍"}),t.jsx("span",{children:o.action.clickToSelectBookOrWork})]})]})}),u.type==="url"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:Rt,children:o.label.sourceName}),t.jsx("button",{onClick:()=>{const f=[...e];f[m]={...f[m],type:"",id:"",name:""},n(f)},style:Sa,children:o.action.changeType})]}),t.jsx("input",{type:"text",value:u.name,onChange:f=>c(m,"name",f.target.value),placeholder:o.editor.sourceNamePlaceholder,style:ln})]}),t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:o.label.urlAddress}),t.jsx("input",{type:"text",value:u.id,onChange:f=>c(m,"id",f.target.value),placeholder:"https://...",style:ln})]})]}),u.type&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{borderTop:`1px dashed ${r("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:t.jsx("label",{style:{...Rt,opacity:.7},children:o.label.optionalInfo})}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:o.label.detailsOptional}),t.jsx("input",{type:"text",value:u.details,onChange:f=>c(m,"details",f.target.value),placeholder:o.editor.detailsPlaceholder,style:ln})]}),t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:o.label.positionOptional}),t.jsx("input",{type:"text",value:u.position,onChange:f=>c(m,"position",f.target.value),placeholder:"如: 卷三, p.52",style:ln})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:o.label.dataVersionOptional}),t.jsx("input",{type:"text",value:u.version,onChange:f=>c(m,"version",f.target.value),placeholder:"如: v1.0, 2024-01",style:ln})]}),t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:o.label.processorVersionOptional}),t.jsx("input",{type:"text",value:u.processor_version,onChange:f=>c(m,"processor_version",f.target.value),placeholder:"如: v0.1",style:ln})]})]})]})]})})]},m)),t.jsxs("button",{onClick:l,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:o.action.addSource})]})]})},Rt={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},ln={width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},wa={flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",padding:"16px 12px",background:r("bg"),border:"2px solid",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:500,transition:"all 0.2s"},Sa={background:"transparent",border:"none",color:r("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function Zc(e){if(!e||!e.trim())return[];try{const n=JSON.parse(e);if(Array.isArray(n))return n.map(i=>({id:i.id||"",name:i.name||"",type:i.type||"",details:i.details||"",position:i.position||"",version:i.version||"",processor_version:i.processor_version||""}))}catch{}return[]}function Jc(e){return!e||e.length===0?"":JSON.stringify(e)}const Qc=({entityType:e,entityId:n,entityTitle:i,parentWork:o,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:h,onLinkEntity:u,onUnlinkEntity:m,onViewEntity:f,onCreateAndLink:x,onSaveRelations:v})=>{const y=Ee();return t.jsxs("div",{style:{background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:"🔗"}),t.jsx("span",{children:y.section.relations})]}),v&&t.jsx("button",{onClick:v,style:yx,children:y.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(Tn,{direction:"up",title:y.relation.belongsToWork,entity:a,onView:f,onUnlink:()=>m("workId"),onLink:()=>u("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(Tn,{direction:"up",title:y.relation.containedInCollection,entity:l,onView:f,onUnlink:()=>m("collectionId"),onLink:()=>u("collectionId","collection"),onCreate:()=>x("collectionId","collection",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),a&&h&&h.length>0&&t.jsx(cn,{direction:"horizontal",title:`${y.relation.siblingVersions} (${h.length})`,entities:h,onView:f,onAdd:()=>x("siblingBook","book",{workId:a.id}),addLabel:y.relation.addVersionForWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="work"&&t.jsxs(t.Fragment,{children:[t.jsx(Tn,{direction:"up",title:y.relation.parentWork,entity:o,onView:f,onUnlink:()=>m("parentWorkId"),onLink:()=>u("parentWorkId","work"),onCreate:()=>x("parentWorkId","work"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),d&&d.length>0&&t.jsx(cn,{direction:"down",title:`${y.relation.childWorks} (${d.length})`,entities:d,onView:f,onAdd:()=>x("childWork","work",{parentWorkId:n}),addLabel:y.action.addSubWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),c&&c.length>0&&t.jsx(cn,{direction:"down",title:`${y.relation.collectionImpl} (${c.length})`,entities:c,onView:f,onAdd:()=>x("childCollection","collection",{workId:n}),addLabel:y.action.addCollectionImpl,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(cn,{direction:"down",title:`${y.relation.allVersions} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{workId:n}),addLabel:y.action.addVersion,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="collection"&&t.jsxs(t.Fragment,{children:[t.jsx(Tn,{direction:"up",title:y.relation.correspondingWork,entity:a,onView:f,onUnlink:()=>m("workId"),onLink:()=>u("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(Tn,{direction:"up",title:y.relation.parentCollection,entity:s,onView:f,onUnlink:()=>m("parentCollectionId"),onLink:()=>u("parentCollectionId","collection"),onCreate:()=>x("parentCollectionId","collection"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(cn,{direction:"down",title:`${y.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:f,onAdd:()=>x("childCollection","collection",{parentCollectionId:n}),addLabel:y.action.addSubCollection,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(cn,{direction:"down",title:`${y.relation.containedBooks} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{collectionId:n}),addLabel:y.action.addBook,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]})]})]})},Tn=({direction:e,title:n,entity:i,onView:o,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:h,unlinkLabel:u})=>{const m=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),f=e==="up"?"⬆️":e==="down"?"⬇️":"↔️";return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:m,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:f}),t.jsx("span",{children:n})]}),i?t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:r("bg"),borderRadius:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:ed(i.type)}),t.jsx("span",{style:{fontWeight:500},children:i.title}),t.jsx("span",{style:{fontSize:"11px",opacity:.6},children:i.id})]}),t.jsxs("div",{style:{display:"flex",gap:"4px"},children:[t.jsx(_a,{onClick:()=>o(i),title:h,children:"👁️"}),t.jsx(_a,{onClick:s,title:u,danger:!0,children:"✕"})]})]}):t.jsx("div",{style:{padding:"8px",background:r("bg"),borderRadius:"4px",color:r("desc-fg"),fontSize:"12px",textAlign:"center"},children:p}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsx(Br,{onClick:a,children:d}),t.jsx(Br,{onClick:l,primary:!0,children:c})]})]})},cn=({direction:e,title:n,entities:i,onView:o,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=g.useState(!1),h=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),u=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",m=c?i:i.slice(0,5);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:h,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:u}),t.jsx("span",{children:n})]}),i.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[m.map(f=>t.jsxs("div",{onClick:()=>o(f),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:r("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[t.jsx("span",{children:ed(f.type)}),t.jsx("span",{children:f.title})]},f.id)),i.length>5&&!c&&t.jsxs("div",{onClick:()=>p(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:r("link-fg"),cursor:"pointer"},children:[d," (",i.length-5,")"]})]}):t.jsx("div",{style:{padding:"8px",background:r("bg"),borderRadius:"4px",color:r("desc-fg"),fontSize:"12px",textAlign:"center"},children:l}),t.jsx("div",{style:{marginTop:"8px"},children:t.jsxs(Br,{onClick:s,primary:!0,children:["+ ",a]})})]})},_a=({onClick:e,title:n,danger:i,children:o})=>t.jsx("button",{onClick:s=>{s.stopPropagation(),e()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:i?r("danger"):"inherit",opacity:.7},children:o}),Br=({onClick:e,primary:n,children:i})=>t.jsx("button",{onClick:e,style:{padding:"4px 10px",fontSize:"11px",border:n?"none":`1px solid ${r("widget-border")}`,borderRadius:"4px",background:n?r("primary"):"transparent",color:n?r("primary-fg"):"inherit",cursor:"pointer"},children:i});function ed(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const yx={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},td=({isOpen:e,entityType:n,title:i,onSelect:o,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[h,u]=g.useState(""),m=p?l.filter(y=>y.id!==p):l;g.useEffect(()=>{e&&(u(""),d(""))},[e]);const f=y=>{u(y),d(y)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",v=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:jx,children:t.jsxs("div",{style:vx,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:i}),t.jsx("button",{onClick:s,style:kx,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:h,onChange:y=>f(y.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:wx})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:mr,children:"搜索中..."}):m.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:m.map(y=>t.jsxs("div",{onClick:()=>o(y),style:Sx,children:[t.jsx("span",{style:{fontSize:"16px"},children:v}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[y.title,y.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:y.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[y.id,y.author&&` · ${y.author}`,y.dynasty&&` · ${y.dynasty}`]})]})]},y.id))}):h?t.jsxs("div",{style:mr,children:["未找到匹配的",x]}):t.jsxs("div",{style:mr,children:["输入关键词搜索",x]})}),t.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsxs("button",{onClick:a,style:_x,children:["创建新",x,"并关联"]})]})]})})},jx={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},vx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",width:"500px",maxWidth:"calc(100vw - 32px)",maxHeight:"70vh",display:"flex",flexDirection:"column",boxShadow:r("shadow-dialog")},kx={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},wx={width:"100%",padding:"10px 12px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"},Sx={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:r("primary-soft")},mr={padding:"20px",textAlign:"center",color:r("desc-fg")},_x={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},$a={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},$x={work:"📜",book:"📖",collection:"📚",entity:"👤"},nd=({isOpen:e,entityType:n,relationField:i,inheritData:o,onConfirm:s,onCancel:a})=>{const[l,d]=g.useState(""),c=g.useRef(null);g.useEffect(()=>{e&&(d((o==null?void 0:o.title)||""),setTimeout(()=>{var m,f;(m=c.current)==null||m.focus(),(f=c.current)==null||f.select()},100))},[e,o==null?void 0:o.title]);const p=m=>{m.key==="Enter"&&l.trim()?h():m.key==="Escape"&&a()},h=()=>{l.trim()&&s(l.trim(),{...o,title:l.trim()})};if(!e)return null;const u=()=>{switch(i){case"parentWorkId":return"创建父作品";case"workId":return"创建所属作品";case"collectionId":return"创建所属丛编";case"parentCollectionId":return"创建父丛编";case"childWork":return"创建子作品";case"childBook":case"siblingBook":return"创建书籍";case"childCollection":return"创建子丛编";default:return`创建新${$a[n]}`}};return t.jsx("div",{style:Cx,onClick:m=>{m.target===m.currentTarget&&a()},children:t.jsxs("div",{style:Tx,onClick:m=>m.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:$x[n]}),t.jsx("span",{children:u()})]}),t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:r("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",t.jsx("span",{style:{color:r("danger"),marginLeft:"4px"},children:"*"})]}),t.jsx("input",{ref:c,type:"text",value:l,onChange:m=>d(m.target.value),onKeyDown:p,placeholder:`请输入${$a[n]}名称...`,style:zx})]}),((o==null?void 0:o.author)||(o==null?void 0:o.dynasty))&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),background:r("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[t.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(o==null?void 0:o.author)&&t.jsxs("div",{children:["作者: ",o.author]}),(o==null?void 0:o.dynasty)&&t.jsxs("div",{children:["朝代/年份: ",o.dynasty]})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[t.jsx("button",{onClick:a,style:Nx,children:"取消"}),t.jsx("button",{onClick:h,disabled:!l.trim(),style:{...Ix,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},Cx={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Tx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:r("shadow-dialog")},zx={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box"},Nx={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},Ix={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg")};function Rx(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function id(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Ex(e){switch(e){case"work":return r("editor-type-work");case"collection":return r("editor-type-collection");case"book":return r("editor-type-book");default:return r("desc-fg")}}const rd=({isOpen:e,title:n,filterType:i="all",recentEntities:o=[],excludeId:s,showCreateButton:a=!1,createButtonText:l,onSelect:d,onCancel:c,onCreate:p,onSearch:h})=>{const[u,m]=g.useState(""),[f,x]=g.useState([]),[v,y]=g.useState(!1),[S,b]=g.useState("recent");g.useEffect(()=>{e&&(m(""),x([]),b(o.length>0?"recent":"search"))},[e,o.length]),g.useEffect(()=>{if(!u.trim()){x([]);return}const _=setTimeout(async()=>{y(!0);try{x(await h(u,i))}catch{x([])}finally{y(!1)}},300);return()=>clearTimeout(_)},[u,i,h]);const w=g.useCallback(_=>{m(_.target.value),_.target.value.trim()&&b("search")},[]),j=g.useCallback(_=>s?_.filter(E=>E.id!==s):_,[s]);if(!e)return null;const k=n||(i==="all"?"选择实体":`选择${id(i)}`),$=j(o),C=j(f);return t.jsx("div",{style:Ax,children:t.jsxs("div",{style:Mx,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:k}),t.jsx("button",{onClick:c,style:Px,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:u,onChange:w,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Bx}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),v&&t.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),$.length>0&&t.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs(Ca,{active:S==="recent",onClick:()=>b("recent"),children:["最近使用 (",$.length,")"]}),t.jsxs(Ca,{active:S==="search",onClick:()=>b("search"),children:["搜索结果 ",C.length>0&&`(${C.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:S==="recent"&&$.length>0?t.jsx(Ta,{entities:$,onSelect:d}):u.trim()?v?t.jsx(hr,{message:"搜索中..."}):C.length>0?t.jsx(Ta,{entities:C,onSelect:d}):t.jsx(hr,{message:"未找到匹配的结果"}):t.jsx(hr,{message:"输入关键词开始搜索"})}),a&&p&&t.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsx("button",{onClick:p,style:Wx,children:l||"创建新实体"})]})]})})},Ca=({active:e,onClick:n,children:i})=>t.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${r("primary")}`:"2px solid transparent",background:"transparent",color:r(e?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:e?600:400,marginBottom:"-1px"},children:i}),Ta=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(i=>t.jsx(Lx,{entity:i,onClick:()=>n(i)},i.id))}),Lx=({entity:e,onClick:n})=>{const[i,o]=g.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:r("primary-soft"),transition:"background 0.1s"},children:[t.jsx("span",{style:{fontSize:"18px"},children:Rx(e.type)}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{fontWeight:500,fontSize:"13px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[e.title,e.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:r("desc-fg"),marginLeft:"4px"},children:e.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7,display:"flex",alignItems:"center",gap:"6px",marginTop:"2px"},children:[t.jsx("code",{style:{fontSize:"10px",background:r("primary-soft"),padding:"1px 4px",borderRadius:"2px"},children:e.id}),e.author&&t.jsx("span",{children:e.author}),e.dynasty&&t.jsx("span",{children:e.dynasty})]})]}),t.jsx("span",{style:{fontSize:"10px",padding:"3px 8px",background:Ex(e.type),color:r("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:id(e.type)})]})},hr=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:e}),Ax={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Mx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",width:"550px",maxWidth:"calc(100vw - 32px)",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:r("shadow-dialog")},Px={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Bx={width:"100%",padding:"12px 16px",paddingLeft:"40px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"},Wx={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Ox={work:r("editor-type-work"),collection:r("editor-type-collection"),book:r("editor-type-book"),entity:r("editor-type-entity")},Fx={work:"📜",collection:"📚",book:"📖",entity:"👤"},od=({data:e,onChange:n,onSave:i,transport:o,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:h,relations:u,onRelationsChange:m})=>{var be;const f=Ee(),[x,v]=g.useState(!1),[y,S]=g.useState("work"),[b,w]=g.useState(""),[j,k]=g.useState(""),[$,C]=g.useState([]),[_,E]=g.useState(!1),[z,T]=g.useState(!1),[B,W]=g.useState("work"),[N,A]=g.useState(""),[F,Y]=g.useState(),[te,se]=g.useState(!1),[D,V]=g.useState(null),[he,Z]=g.useState([]);g.useRef(null);const M=e.type,_e=M==="work",ce=M==="collection",ge=M==="book",le=g.useCallback((X,re)=>{n({...e,[X]:re})},[e,n]),Be=g.useCallback((X,re)=>{w(X),S(re),k(f.editor.selectToLink+f.indexType[re]),C([]),v(!0)},[f]),ze=g.useCallback(X=>{o!=null&&o.unlinkEntity&&o.unlinkEntity(e.id,X)},[o,e.id]),Fe=g.useCallback(X=>{s==null||s(X.id,X.type)},[s]),Q=g.useCallback((X,re,Ce)=>{const We={...Ce,author:(Ce==null?void 0:Ce.author)||e.author,dynasty:Ce==null?void 0:Ce.dynasty};W(re),A(X),Y(We),T(!0)},[e.author]),H=g.useCallback((X,re)=>{o!=null&&o.createAndLink&&o.createAndLink(e.id,N,{type:B,title:X,inheritData:re}),T(!1)},[o,e.id,N,B]),G=g.useCallback(X=>{if(!X.trim()){C([]);return}E(!0),o!=null&&o.searchEntities&&o.searchEntities(X,y).then(re=>{C(re),E(!1)}).catch(()=>{C([]),E(!1)})},[o,y]),xe=g.useCallback(X=>{o!=null&&o.linkEntity&&o.linkEntity(e.id,b,X.id),v(!1)},[o,e.id,b]),K=g.useCallback(()=>{i()},[i]),L=g.useCallback(X=>{V(()=>X),se(!0),o!=null&&o.getRecentEntities&&o.getRecentEntities().then(Z).catch(()=>{})},[o]),q=g.useCallback((X,re)=>o!=null&&o.searchEntities?o.searchEntities(X,re==="all"?void 0:re):Promise.resolve([]),[o]),ae=g.useCallback(X=>{o!=null&&o.addRecentEntity&&o.addRecentEntity(X),Z(re=>[X,...re.filter(Ce=>Ce.id!==X.id)].slice(0,10)),D==null||D(X),se(!1),V(null)},[o,D]);return t.jsxs("div",{style:{padding:"16px",maxWidth:"900px",margin:"0 auto"},children:[t.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:`1px solid ${r("widget-border")}`,paddingBottom:"16px"},children:t.jsxs("h1",{style:{fontSize:"20px",fontWeight:600,margin:0,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Fx[M]}),t.jsx("span",{children:e.title||f.editor.untitled}),t.jsx(ji,{children:e.id}),t.jsx(ji,{color:Ox[M],children:f.indexType[M]})]})}),t.jsx(kt,{title:f.section.basicInfo,onSave:i,onAskAI:d?()=>d("基本信息"):void 0,extraButtons:c==null?void 0:c("基本信息"),children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[t.jsx(mi,{label:_e?f.editor.workTitle:ce?f.editor.collectionTitle:f.editor.bookTitle,value:e.title,onChange:X=>le("title",X)}),ge&&t.jsx(mi,{label:f.editor.belongsToWork,value:e.workName||"",onChange:X=>le("workName",X)}),t.jsx(ht,{label:f.editor.authorLabel,value:e.author||"",onChange:X=>le("author",X)}),t.jsx(ht,{label:f.editor.publicationYearLabel,value:e.publicationYear||"",onChange:X=>le("publicationYear",X)}),(ge||ce)&&t.jsx(mi,{label:f.editor.containedIn,value:e.collection||"",onChange:X=>le("collection",X)}),(ge||ce)&&t.jsx(ht,{label:f.editor.holderLabel,value:e.holder||"",onChange:X=>le("holder",X)}),(ge||ce)&&t.jsx(ht,{label:ge?f.editor.pageLabel:f.editor.volumeLabel,value:e.pages||"",onChange:X=>le("pages",X)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(ht,{label:f.editor.firstImageLabel,value:e.firstImage||"",onChange:X=>le("firstImage",X)})})]})}),t.jsx(kt,{title:f.section.description,onSave:i,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(tn,{value:e.description||"",onChange:X=>le("description",X),placeholder:f.editor.descriptionPlaceholder})}),(((be=e.additional_works)==null?void 0:be.length)||0)>0&&t.jsx(kt,{title:f.section.additionalWorks,onSave:i,children:t.jsx(Hx,{items:e.additional_works||[],onChange:X=>le("additional_works",X)})}),t.jsx(kt,{title:f.section.indexedBy,onSave:i,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(Dx,{items:e.indexed_by||[],onChange:X=>le("indexed_by",X)})}),t.jsx(kt,{title:f.section.emendatedBy,onSave:i,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(Ux,{items:e.emendated_by||[],onChange:X=>le("emendated_by",X)})}),t.jsx(kt,{title:f.section.textResources,onSave:i,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(jr,{items:e.resources||[],onChange:X=>le("resources",X),onDownload:p,downloadStatuses:h,filterType:"text"})}),t.jsx(kt,{title:f.section.imageResources,onSave:i,children:t.jsx(jr,{items:e.resources||[],onChange:X=>le("resources",X),onDownload:p,downloadStatuses:h,filterType:"image"})}),t.jsx(kt,{title:f.section.sources,onSave:i,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(Xc,{items:Zc(e.sources||""),onChange:X=>le("sources",Jc(X)),onOpenEntityPicker:L})}),(ge||ce)&&t.jsx(kt,{title:f.section.provenance,onSave:i,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(tn,{value:e.provenance||"",onChange:X=>le("provenance",X),placeholder:f.editor.provenancePlaceholder})}),ge&&t.jsx(kt,{title:f.section.otherEditions,onSave:i,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(tn,{value:e.otherEditions||"",onChange:X=>le("otherEditions",X),placeholder:f.editor.otherEditionsPlaceholder})}),t.jsx(Qc,{entityType:M,entityId:e.id,entityTitle:e.title,parentWork:u==null?void 0:u.parentWork,parentCollection:u==null?void 0:u.parentCollection,belongsToWork:u==null?void 0:u.belongsToWork,belongsToCollection:u==null?void 0:u.belongsToCollection,childWorks:u==null?void 0:u.childWorks,childCollections:u==null?void 0:u.childCollections,containedBooks:u==null?void 0:u.containedBooks,siblingBooks:u==null?void 0:u.siblingBooks,onLinkEntity:Be,onUnlinkEntity:ze,onViewEntity:Fe,onCreateAndLink:Q,onSaveRelations:K}),a&&l&&t.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${r("danger-soft-border")}`,background:r("danger-soft-bg"),borderRadius:"4px"},children:[t.jsx("div",{style:{color:r("danger"),fontWeight:600,marginBottom:"8px"},children:f.section.dangerZone}),t.jsx("p",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"12px"},children:f.editor.dangerZoneDesc}),t.jsx("button",{onClick:l,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("danger")}`,borderRadius:"4px",background:"transparent",color:r("danger"),cursor:"pointer"},children:f.editor.deleteEntity})]}),t.jsx(td,{isOpen:x,entityType:y,title:j,onSelect:xe,onCancel:()=>v(!1),onCreate:()=>{v(!1),Q(b,y)},searchResults:$,onSearch:G,isLoading:_,excludeId:e.id}),t.jsx(nd,{isOpen:z,entityType:B,relationField:N,inheritData:F,onConfirm:H,onCancel:()=>T(!1)}),t.jsx(rd,{isOpen:te,title:f.action.selectBookOrWork,filterType:"all",recentEntities:he,excludeId:e.id,onSelect:ae,onCancel:()=>{se(!1),V(null)},onSearch:q})]})};function Hx({items:e,onChange:n}){const i=Ee(),o=(l,d,c)=>{const p=e.map((h,u)=>u===l?{...h,[d]:c}:h);n(p)},s=l=>n(e.filter((d,c)=>c!==l)),a=()=>n([...e,{book_title:""}]);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((l,d)=>t.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[t.jsx(ht,{label:i.editor.bookNameLabel,value:l.book_title,onChange:c=>o(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(ht,{label:i.label.juanCount,value:l.n_juan!=null?String(l.n_juan):"",onChange:c=>o(d,"n_juan",c&&parseInt(c,10)||void 0)})}),t.jsx("button",{onClick:()=>s(d),style:{padding:"4px 8px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("muted"),marginTop:"18px"},children:"✕"})]},d)),t.jsx("button",{onClick:a,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${r("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("desc-fg"),alignSelf:"flex-start"},children:i.action.addAdditionalWork})]})}function sd({items:e,onChange:n,showMeta:i,addLabel:o}){const s=Ee(),[a,l]=g.useState(null),d=(h,u,m)=>{const f=e.map((x,v)=>v===h?{...x,[u]:m||void 0}:x);n(f)},c=h=>{n(e.filter((u,m)=>m!==h)),a===h&&l(null)},p=()=>{n([...e,{source:""}]),l(e.length)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((h,u)=>{const m=a===u;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:m?`color-mix(in srgb, ${r("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(m?null:u),children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.2s",transform:m?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:h.source||s.editor.unnamedSource}),h.source_bid&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:h.source_bid}),t.jsx("button",{onClick:f=>{f.stopPropagation(),c(u)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${r("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:r("muted")},children:"✕"})]}),!m&&i&&(h.title_info||h.author_info)&&t.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:r("desc-fg")},children:[h.title_info,h.title_info&&h.author_info&&" — ",h.author_info]}),m&&t.jsxs("div",{style:{padding:"8px 12px 12px",display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(ht,{label:s.label.sourceName,value:h.source,onChange:f=>d(u,"source",f)}),t.jsx(ht,{label:s.label.sourceBid,value:h.source_bid||"",onChange:f=>d(u,"source_bid",f)})]}),i&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(ht,{label:s.label.titleInfo,value:h.title_info||"",onChange:f=>d(u,"title_info",f)}),t.jsx(ht,{label:s.label.authorInfo,value:h.author_info||"",onChange:f=>d(u,"author_info",f)})]}),t.jsx(ht,{label:s.label.edition,value:h.edition||"",onChange:f=>d(u,"edition",f)})]}),t.jsx(tn,{value:h.summary||"",onChange:f=>d(u,"summary",f),placeholder:s.editor.summaryPlaceholder}),t.jsx(tn,{value:h.comment||"",onChange:f=>d(u,"comment",f),placeholder:s.editor.commentPlaceholder}),t.jsx(tn,{value:h.additional_comment||"",onChange:f=>d(u,"additional_comment",f),placeholder:s.editor.additionalCommentPlaceholder})]})]},u)}),t.jsx("button",{onClick:p,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${r("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("desc-fg"),alignSelf:"flex-start"},children:o})]})}function Dx({items:e,onChange:n}){const i=Ee();return t.jsx(sd,{items:e,onChange:n,showMeta:!0,addLabel:i.action.addIndexedBy})}function Ux({items:e,onChange:n}){const i=Ee();return t.jsx(sd,{items:e,onChange:n,addLabel:i.action.addEmendatedBy})}function ad(e){var d,c,p,h,u,m,f;const n=((c=(d=e.authors)==null?void 0:d[0])==null?void 0:c.name)||"",i=((p=e.publication_info)==null?void 0:p.year)||"",o=((h=e.current_location)==null?void 0:h.name)||"",s=(u=e.page_count)!=null&&u.number?String(e.page_count.number):((m=e.page_count)==null?void 0:m.description)||"",a=typeof e.description=="object"&&e.description!==null&&e.description.text||"",l={id:e.id,title:e.title,type:e.type,author:n,publicationYear:i,holder:o,pages:s,description:a,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};if(e.type==="work"){const x=e;if(Array.isArray(x.related_works)){const v=x.related_works.find(y=>y.relation==="part_of");v&&(l.parentWorkId=v.id,l.parentWorkName=v.title)}}if(e.type==="book"){const x=e;l.workId=x.work_id,Array.isArray(x.contained_in)&&x.contained_in.length>0&&(l.collectionId=(f=x.contained_in[0])==null?void 0:f.id)}return l}function Vx(e){const n={id:e.id,title:e.title,type:e.type,description:e.description?{text:e.description}:void 0,authors:e.author?[{name:e.author}]:void 0,publication_info:e.publicationYear?{year:e.publicationYear}:void 0,current_location:e.holder?{name:e.holder}:void 0,page_count:e.pages?{number:parseInt(e.pages)||0,description:e.pages}:void 0,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};return e.type==="work"&&e.parentWorkId&&(n.related_works=[{id:e.parentWorkId,title:e.parentWorkName||"",relation:"part_of"}]),e.type==="book"&&(n.work_id=e.workId,e.collectionId&&(n.contained_in=[{id:e.collectionId}])),n}const Gx=e=>{const{data:n,id:i,transport:o,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:h,onAskAI:u,renderSectionActions:m,onDownloadResource:f,downloadStatuses:x,relations:v,onRelationsChange:y,headerExtra:S,className:b,style:w}=e,j=Ee(),[k,$]=g.useState(s),C=a?s:k;g.useEffect(()=>{s!==k&&$(s)},[s]);const _=g.useCallback(()=>{const A=C==="view"?"edit":"view";a?a(A):$(A)},[C,a]),[E,z]=g.useState(null);g.useEffect(()=>{i&&o&&o.getItem(i).then(A=>{A&&z(A)})},[i,o]);const T=n||E,B=g.useMemo(()=>T?ad(T):null,[T]),W=a||!n?t.jsx("button",{onClick:_,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:C==="edit"?r("accent-bg"):"transparent",color:r(C==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:C==="view"?j.common.switchToEdit:j.common.switchToView,children:C==="view"?j.common.modeEdit:j.common.modeView}):null,N=t.jsxs(t.Fragment,{children:[W,S]});return!T&&!B?t.jsx(nn,{}):C==="view"?t.jsx(to,{data:T,transport:o,onNavigate:p?A=>p(A):void 0,renderLink:h,headerExtra:N,className:b,style:w}):B?t.jsxs("div",{className:b,style:w,children:[N&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:N}),t.jsx(od,{data:B,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:o,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:u,renderSectionActions:m,onDownloadResource:f,downloadStatuses:x,relations:v,onRelationsChange:y})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:r("muted")},children:j.common.noData})},Yx=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],ld=({isOpen:e,onClose:n,onSubmit:i,feedbackListUrl:o})=>{const{t:s}=ne(),[a,l]=g.useState(null),[d,c]=g.useState(""),[p,h]=g.useState(""),[u,m]=g.useState("idle"),[f,x]=g.useState(""),v=g.useRef(null);g.useEffect(()=>{e&&(l(null),c(""),h(""),m("idle"),x(""))},[e]),g.useEffect(()=>{a&&setTimeout(()=>{var b;return(b=v.current)==null?void 0:b.focus()},100)},[a]),g.useEffect(()=>{if(u==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[u,n]),g.useEffect(()=>{if(!e)return;const b=w=>{w.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,n]);const y=async()=>{if(!(!a||!d.trim())){m("submitting"),x("");try{await i({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),m("success")}catch(b){m("error"),x(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const S=a&&d.trim()&&u!=="submitting";return t.jsx("div",{style:qx,onClick:b=>{b.target===b.currentTarget&&n()},children:t.jsxs("div",{style:Kx,onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{style:Xx,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:Zx,"aria-label":s("feedback.close"),children:"✕"})]}),u==="success"?t.jsxs("div",{style:nb,children:[t.jsx("span",{style:{fontSize:"32px"},children:"✓"}),t.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:s("feedback.thanks")}),o&&t.jsx("a",{href:o,style:{fontSize:"13px",color:r("primary"),marginTop:"8px"},children:s("feedback.viewList")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"16px"},children:Yx.map(b=>t.jsxs("button",{onClick:()=>l(b.value),style:{...Jx,...a===b.value?Qx:{}},children:[t.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),t.jsx("textarea",{ref:v,value:d,onChange:b=>c(b.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||u==="submitting",style:{...eb,opacity:a?1:.6}}),t.jsx("input",{type:"text",value:p,onChange:b=>h(b.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!a||u==="submitting","aria-label":s("feedback.contactLabel"),style:rb}),t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),u==="error"&&t.jsx("div",{style:ib,children:f}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:y,disabled:!S,style:{...tb,opacity:S?1:.6,cursor:S?"pointer":"not-allowed"},children:s(u==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},qx={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Kx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:r("shadow-dialog")},Xx={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},Zx={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:r("desc-fg"),padding:"4px 8px",borderRadius:"4px"},Jx={flex:"1 1 calc(50% - 4px)",padding:"10px 12px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},Qx={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},eb={width:"100%",minHeight:"120px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},tb={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},nb={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:r("success")},ib={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginBottom:"12px"},rb={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"},Wr="--bim-feedback-fab-offset",Or=48,ob=16,sb=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:i,hidden:o=!1,zIndex:s})=>{const{t:a}=ne(),[l,d]=g.useState(!1),c=n.bottom??24;return g.useEffect(()=>{if(o||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(Wr,`calc(${c+Or+ob}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(Wr)}},[o,c]),t.jsxs(t.Fragment,{children:[!o&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...ab,zIndex:s??r("feedback-fab-z"),bottom:`calc(${c}px + env(safe-area-inset-bottom, 0px))`,right:n.right},"aria-label":a("feedback.title"),title:a("feedback.title"),children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),t.jsx(ld,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:i})]})},ab={position:"fixed",width:`${Or}px`,height:`${Or}px`,borderRadius:"50%",border:"none",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:r("shadow-fab"),transition:"transform 0.2s, box-shadow 0.2s"},lb=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],cd=({onSubmit:e})=>{const{t:n}=ne(),[i,o]=g.useState("bug"),[s,a]=g.useState(""),[l,d]=g.useState(""),[c,p]=g.useState("idle"),[h,u]=g.useState(""),m=g.useRef(null);g.useEffect(()=>{i&&setTimeout(()=>{var v;return(v=m.current)==null?void 0:v.focus()},100)},[i]);const f=async()=>{if(!(!i||!s.trim())){p("submitting"),u("");try{await e({type:i,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),o("bug")}catch(v){p("error"),u(v instanceof Error?v.message:n("feedback.submitFailedRetry"))}}},x=i&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:za,children:t.jsxs("div",{style:mb,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:hb,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:za,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:lb.map(v=>t.jsxs("button",{onClick:()=>o(v.value),style:{...cb,...i===v.value?db:{}},children:[t.jsx("span",{children:v.icon})," ",n(`feedback.submitType.${v.value}`)]},v.value))}),t.jsx("textarea",{ref:m,value:s,onChange:v=>a(v.target.value),placeholder:n(i?`feedback.placeholder.${i}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...pb}}),t.jsx("input",{type:"text",value:l,onChange:v=>d(v.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:fb}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg")},children:[s.length," / 2000"]}),t.jsx("button",{onClick:f,disabled:!x,style:{...ub,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:gb,children:h})]})},za={padding:"16px",border:`1px solid ${r("widget-border")}`,borderRadius:"8px",background:r("input-bg")},cb={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:"transparent",color:r("fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},db={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},pb={width:"100%",minHeight:"100px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},ub={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},mb={display:"flex",alignItems:"center",gap:"12px",color:r("success"),fontSize:"14px"},hb={background:"none",border:"none",color:r("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},gb={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginTop:"8px"},fb={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"};function Na(e){return typeof e=="function"?e():e??"/api/feedback"}const dd=({resourceId:e,apiUrl:n})=>{const{t:i}=ne(),[o,s]=g.useState([]),[a,l]=g.useState(!0),d=g.useCallback(async()=>{const p=Na(n);l(!0);try{const u=await(await fetch(`${p}?resourceId=${encodeURIComponent(e)}`)).json();u.success&&s(u.items)}catch{}finally{l(!1)}},[e,n]);g.useEffect(()=>{d()},[d]);const c=async p=>{const h=Na(n),u=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!u.ok){const m=await u.json().catch(()=>null);throw new Error((m==null?void 0:m.error)||i("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(Wo,{items:o,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(cd,{onSubmit:c})})]})},Mi=8;async function Pi(e,n,i,o){const s=Number.isFinite(n)?Math.max(1,Math.floor(n)):1,a=new Array(e.length);let l=0;const d=Array.from({length:Math.min(s,Math.max(1,e.length))},async()=>{for(;l<e.length&&!(o!=null&&o());){const c=l++;a[c]=await i(e[c],c)}});return await Promise.all(d),a}const xb=wi["zh-Hant"].relation,bb=wi["zh-Hant"].lossStatus,yb=wi["zh-Hant"].resourceKind,Bi=yn("zh-Hant"),Oo=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function Ia(e,n=Bi){return e?Oo(xb,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function jb(e,n=Bi){return Oo(bb,e)?n(`detail.lossStatus.${e}`):e}function vb(e,n=Bi){return Oo(yb,e)?n(`detail.resourceKind.${e}`):""}function Fo({authors:e,onNavigate:n,renderLink:i}){const{convert:o}=ne(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=co(a.role);return t.jsxs(g.Fragment,{children:[l>0&&" ",a.dynasty&&t.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",o(a.dynasty),"〕"]}),a.entity_id?t.jsx(et,{id:a.entity_id,label:o(a.name),onNavigate:n,renderLink:i,dense:!0}):o(a.name),d&&t.jsx("span",{style:{marginLeft:4},children:o(d)})]},l)})}):null}function pd(e,n,i=Bi){var c,p;const o=ao(e,n),s=o.mirrors.map(h=>({key:h.key,label:h.label,description:h.description,rows:h.items.filter(u=>u.group_role!=="mirror"),mirrors:h.items.filter(u=>u.group_role==="mirror")})),a=o.buckets.filter(h=>h.key==="image"||h.key==="textImage").flatMap(h=>h.items);a.length&&s.push({key:"_images",label:s.length?i("detail.otherImages"):void 0,rows:a,mirrors:[]});const l=((c=o.buckets.find(h=>h.key==="physical"))==null?void 0:c.items)??[];return l.length&&s.push({key:"_physical",label:i("detail.resourceKind.physical"),rows:l,mirrors:[]}),{text:((p=o.buckets.find(h=>h.key==="text"))==null?void 0:p.items)??[],groups:s}}function ud(e,n){const i=(e.url?fn(e.url):void 0)||e.name,o=Kl(e,n);return o?`${i}(${o})`:i}function Ho({item:e,siblings:n,listedVolumeCounts:i}){const{t:o,convert:s}=ne(),[a,l]=g.useState(!1),d=ki(e),c=!!d&&d.expected>0&&!(i!=null&&i.has(d.expected)),p=s(ud(e,n)),h=xn(e),u=Ii(e,o)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var f,x;const m=(f=e.metadata)!=null&&f.fragment||e.color_mode?t.jsxs("span",{className:"bim-d-tags bim-d-ui",style:{display:"inline-flex",margin:"0 0 0 8px",verticalAlign:"middle"},children:[((x=e.metadata)==null?void 0:x.fragment)&&t.jsx("span",{className:"bim-d-tag",children:o("detail.fragmentTag")}),e.color_mode&&t.jsx("span",{className:"bim-d-tag",children:e.color_mode==="color"?o("colorMode.color"):o("colorMode.bw")})]}):null;return h?t.jsxs("a",{href:h,target:"_blank",rel:"noopener noreferrer",children:[p," ",t.jsx("span",{"aria-hidden":"true",children:"↗"}),m]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,m]})})(),u&&t.jsx("span",{className:"bim-d-meta",children:s(u)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(xo,{item:e})})]}),t.jsx("td",{className:c?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:c&&t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":a,onClick:()=>l(m=>!m),children:a?o("detail.collapseVolumes"):o("detail.expandVolumes",{n:d.expected})})})]})}function md({groups:e,listedVolumeCounts:n}){const{t:i,convert:o}=ne();return t.jsx(t.Fragment,{children:e.map(s=>t.jsxs("div",{className:"bim-d-rg",children:[s.label&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:o(s.label)}),s.description&&t.jsx("p",{className:"bim-d-rg-d",children:o(s.description)}),s.rows.length>0&&t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:s.rows.map((a,l)=>t.jsx(Ho,{item:a,siblings:s.rows,listedVolumeCounts:n},`${a.id||a.url||a.name}-${l}`))})}),s.mirrors.length>0&&t.jsxs("div",{className:"bim-d-rg-mir bim-d-ui",children:[s.rows.length>0&&t.jsx("span",{className:"bim-d-meta",style:{marginRight:10},children:i("detail.mirror")}),s.mirrors.map((a,l)=>{const d=xn(a),c=o(ud(a,s.mirrors));return d?t.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",title:a.details?o(a.details):void 0,children:[c," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]},l):t.jsx("span",{style:{marginRight:14},children:c},l)})]})]},s.key))})}const Mn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function Fr(e){var i;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(i=Mn.find(o=>n.startsWith(o.key[0])))==null?void 0:i.key}const Ra=12,kb=60,hd=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,railTop:a,back:l,railLinks:d})=>{var G,xe,K;const{t:c,convert:p,messages:h}=ne(),u=g.useMemo(()=>po({_books:e._books}),[e._books]),[m,f]=g.useState(new Map),[x,v]=g.useState(!1),[y,S]=g.useState(""),[b,w]=g.useState(!1),j=u.length<=kb,k=j||x||!!y||b,$=g.useMemo(()=>k?u:u.slice(0,Ra),[u,k]);g.useEffect(()=>{if(!n||$.length===0)return;const L=$.filter(ae=>!m.has(ae));if(L.length===0)return;let q=!1;return Pi(L,Mi,ae=>n.getItem(ae).then(be=>{const X=be??{};return[ae,{id:ae,title:X.title,edition:X.edition,resources:X.resources,publication_info:X.publication_info,current_location:X.current_location,lineage:X.lineage,measure_info:X.measure_info}]}).catch(()=>[ae,{id:ae}]),()=>q).then(ae=>{q||f(be=>{const X=new Map(be);for(const[re,Ce]of ae)X.set(re,Ce);return X})}),()=>{q=!0}},[n,$,m]);const C=g.useMemo(()=>u.map(L=>m.get(L)??{id:L}),[u,m]),_=u.length>0&&u.every(L=>m.has(L)),E=!!n&&$.some(L=>!m.has(L)),z=j||k,T=g.useMemo(()=>Zl(C,e.version_graph,{era:y,scanOnly:b,sort:z?"year":"default"}),[C,e.version_graph,y,b,z]),B=x?T.rows:T.rows.slice(0,Ra),W=T.allRows.filter(L=>L.hasImage).length,N=g.useMemo(()=>(e._related||[]).map(L=>({...L,title:L.title??""})),[e._related]),A=N.filter(L=>L.relation==="collected_in"),F=g.useMemo(()=>{const L=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],q=ae=>{const be=L.indexOf(ae??"");return be<0?L.length:be};return N.filter(ae=>ae.relation!=="collected_in").map((ae,be)=>({r:ae,i:be})).sort((ae,be)=>q(ae.r.relation)-q(be.r.relation)||ae.i-be.i).map(ae=>ae.r)},[N]),Y=g.useMemo(()=>{const L=ao(e.resources,e.resource_groups);return[...L.mirrors.flatMap(q=>q.items.map(ae=>({r:ae,kind:p(q.label)}))),...L.buckets.flatMap(q=>q.items.map(ae=>({r:ae,kind:p(vb(q.key,c))})))]},[e.resources,e.resource_groups,p,c]),te=e.indexed_by||[],se=e.emendated_by||[],D=g.useMemo(()=>{var O,ie,je;const L=[],q=(ie=(O=e.authors)==null?void 0:O[0])==null?void 0:ie.dynasty;q&&L.push({label:c("workPage.fact.written"),value:p(q)});const ae=Bt(e,h.unit.juan);if(ae){const ke=(je=e.juan_count)==null?void 0:je.description;L.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(ae),ke&&ke!==ae?t.jsxs("span",{className:"bim-d-meta",children:["(",p(ke),")"]}):null]})})}e.loss_status&&L.push({label:c("workPage.fact.loss"),value:p(jb(e.loss_status,c))});const be=T.allRows.filter(ke=>ke.sortYear!=null),X=be.length>0?be.reduce((ke,P)=>ke.sortYear<=P.sortYear?ke:P):null;X!=null&&X.era.era?L.push({label:c("workPage.fact.earliest"),value:p([X.era.era,X.era.reign].filter(Boolean).join(" ")),title:X.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):E&&L.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),se.length&&L.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:se.length})});const re=Ea(e.additional_titles);re.length&&L.push({label:c("workPage.fact.alias"),value:re.map(p).join("、")});const Ce=Ea(e.attached_texts);Ce.length&&L.push({label:c("workPage.fact.attached"),value:Ce.map(p).join("、")});const We=(e.additional_works||[]).map(ke=>p(ke.book_title)+(ke.n_juan!=null?` ${ke.n_juan}${h.unit.juan}`:""));return We.length&&L.push({label:c("workPage.fact.appendix"),value:We.join("、")}),L},[e,p,c,h,E,T.allRows,se.length]),he=[{value:e._edition_count??u.length,label:c("workPage.stat.editions")},{value:_?W:0,label:c("workPage.stat.hasImage")},{value:te.length,label:c("workPage.stat.catalogs")}],Z=uo(e),M=Z?[Z.l1,Z.l2,Z.l3,Z.l4].filter(Boolean).map(L=>p(L)):[],_e=e.subtype?h.workSubtype[e.subtype]??p(e.subtype):"",ce=t.jsx(Fn,{title:p(e.title),byline:t.jsx(Fo,{authors:e.authors,onNavigate:i,renderLink:o}),meta:t.jsx(it,{items:[...M,Z!=null&&Z.source?c("workPage.classifiedBy",{source:p(Z.source.split("/")[0])}):"",_e]}),description:(G=e.description)!=null&&G.text?t.jsxs(t.Fragment,{children:[t.jsx(Pt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(xe=e.description.sources)!=null&&xe.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(L=>({text:p(hh(L)),href:gh(L)})).filter(L=>L.text).map((L,q)=>t.jsxs(g.Fragment,{children:[q>0?" · ":null,L.href?t.jsx("a",{href:L.href,target:"_blank",rel:"noopener noreferrer",children:L.text}):L.text]},q))}):null]}):void 0,stats:he,facts:D,readAction:s,foot:t.jsx(Hn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(K=e.appendix)==null?void 0:K.map((L,q)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(L.title)}),t.jsx(Pt,{text:L.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},q))}),ge=T.eras.length>=2?[{key:"",label:c("catalog.all")},...T.eras.map(L=>({key:L,label:`${L} ${T.allRows.filter(q=>q.era.era===L).length}`}))]:[],le=[];u.length&&le.push({id:"versions",label:c("workPage.sec.versions"),count:u.length}),te.length&&le.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:te.length}),A.length&&le.push({id:"collected",label:c("workPage.sec.collected"),count:A.length}),F.length&&le.push({id:"related",label:c("workPage.sec.related"),count:F.length}),Y.length&&le.push({id:"resources",label:c("workPage.sec.resources"),count:Y.length});const Be=u.length===0&&te.length===0,ze=t.jsxs(t.Fragment,{children:[u.length>0&&t.jsxs(rt,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(it,{items:[c("workPage.versionsTotal",{n:u.length}),_&&W?c("workPage.versionsWithImage",{n:W}):"",T.rows.length!==T.allRows.length?c("workPage.versionsCurrent",{n:T.rows.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":E&&ge.length===0&&u.length>1?"":void 0,children:[ge.length>0&&t.jsx(Ei,{items:ge,value:y,onChange:L=>{S(L),v(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(cc,{label:c("workPage.scanOnly"),checked:b,onChange:L=>{w(L),v(!1)}}),t.jsx("span",{className:"bim-d-meta",children:c(z?"workPage.sortByYear":"workPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&Li(T.rows.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:c("workPage.col.edition")}),t.jsx("th",{children:c("workPage.col.era")}),t.jsx("th",{children:c("workPage.col.holder")}),t.jsx("th",{children:t.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:c("workPage.col.image")})})]})}),t.jsx("tbody",{children:B.map(L=>{var q;return t.jsx(wb,{row:L,measure:(q=m.get(L.id))==null?void 0:q.measure_info,loaded:m.has(L.id),onNavigate:i,renderLink:o},`${L.id}:${m.has(L.id)?"r":"p"}`)})})]}),B.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c(y||b?"workPage.noVersionsFiltered":"workPage.noVersions")}),!x&&t.jsx(mo,{total:T.rows.length,shown:B.length,unit:c("workPage.moreUnit"),onClick:()=>v(!0)}),T.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),te.length>0&&t.jsx(Sb,{items:te,transport:n,onNavigate:i,renderLink:o}),Be&&t.jsx(rt,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),Fe=(L,q)=>t.jsx(et,{id:L,label:p(q),onNavigate:i,renderLink:o,dense:!0}),Q=g.useMemo(()=>{const L=new Map;for(const q of F){const ae=Ia(q.relation,c);L.set(ae,(L.get(ae)??0)+1)}return L.size>1?[...L.entries()].sort((q,ae)=>ae[1]-q[1]).slice(0,4).map(([q,ae])=>`${p(q)} ${ae}`).join(" · "):void 0},[F,p,c]),H=t.jsxs(t.Fragment,{children:[t.jsx(en,{id:"collected",title:c("workPage.sec.collected"),items:A.map(L=>Fe(L.id,L.title))}),t.jsx(en,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:F.length}),sub:Q,items:F.map(L=>t.jsxs(t.Fragment,{children:[Fe(L.id,L.title),t.jsx("span",{className:"bim-d-meta",title:L.note?p(L.note):void 0,children:p(Ia(L.relation,c))})]}))}),t.jsx(en,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:Y.map(({r:L,kind:q})=>{const ae=p((L.url?fn(L.url):void 0)||L.name),be=xn(L);return t.jsxs(t.Fragment,{children:[be?t.jsxs("a",{href:be,target:"_blank",rel:"noopener noreferrer",children:[ae," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:ae}),q&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:q})]})})})]});return t.jsx(On,{railTop:a,back:l,nav:le,railLinks:d,main:ze,card:ce,side:H})};function Ea(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function La(e,n){return n((e.url?fn(e.url):void 0)||e.name)}function wb({row:e,measure:n,loaded:i,onNavigate:o,renderLink:s}){const{t:a,convert:l}=ne(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],h=p?La(p,l):e.locationName?l(e.locationName):"",u=e.images[0],m=u?xn(u):void 0,f=e.images.map(x=>La(x,l)).join("、");return t.jsxs("tr",{"data-loading":i?void 0:"",children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(et,{id:e.id,label:l(e.name),onNavigate:o,renderLink:s,dense:!0}),n?t.jsx("span",{className:"bim-d-meta",children:l(n)}):t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${d?"":" bim-d-zt-blank"}`,title:c?a("workPage.inferredFromEdition"):void 0,children:d?l(d):i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),t.jsxs("td",{className:`bim-d-zt-sub${h?"":" bim-d-zt-blank"}`,children:[h||(i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),e.holders.length>1&&t.jsxs("span",{className:"bim-d-meta",children:[" +",e.holders.length-1]})]}),t.jsx("td",{className:e.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:e.hasImage&&(m?t.jsx("a",{className:"bim-d-flag",href:m,target:"_blank",rel:"noopener noreferrer",title:f,children:a("workPage.hasImage")}):t.jsx("span",{className:"bim-d-flag",title:f,children:a("workPage.hasImage")}))})]})}function Sb({items:e,transport:n,onNavigate:i,renderLink:o}){const{t:s,convert:a}=ne(),[l,d]=g.useState(0),c=Math.min(l,e.length-1),p=e[c],[h,u]=g.useState(new Map);return g.useEffect(()=>{if(!n)return;const m=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(m.length===0)return;let f=!1;return Promise.all(m.map(x=>n.getItem(x).then(v=>{var y,S;return[x,((S=(y=v==null?void 0:v.authors)==null?void 0:y[0])==null?void 0:S.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{f||u(new Map(x.filter(([,v])=>v)))}),()=>{f=!0}},[n,e]),t.jsx(rt,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(it,{items:[s("workPage.catalog.meta",{n:e.length}),s("workPage.sortByCatalog")]}),children:t.jsxs("div",{className:"bim-d-lu",children:[t.jsx("ul",{className:"bim-d-tl2 bim-d-ui",role:"tablist","aria-label":s("workPage.catalog.tablist"),children:e.map((m,f)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":f===c,"aria-label":a(m.source),onClick:()=>d(f),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:h.get(m.source_bid??"")?a(h.get(m.source_bid??"")):" "}),t.jsx("i",{className:"bim-d-tl2-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-d-tl2-name","aria-hidden":"true",children:[...a(m.source)].slice(0,9).map((x,v)=>t.jsx("span",{children:x},v))})]})},f))}),t.jsxs("div",{className:"bim-d-lu-body",role:"tabpanel",children:[p.title_info&&t.jsx("div",{className:"bim-d-lu-title",children:a(p.title_info)}),t.jsx(it,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(et,{id:p.source_bid,label:a(p.source),onNavigate:i,renderLink:o,dense:!0}):a(p.source),p.section?a(p.section):"",p.author_info?`${s("label.authorInfo")} ${a(p.author_info)}`:"",p.edition?`${s("label.edition")} ${a(p.edition)}`:"",p.page??""]}),p.summary&&t.jsx("p",{className:"bim-d-quote",children:ft(a(p.summary),void 0,{t:s})}),p.comment&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.comment")}),t.jsx("p",{className:"bim-d-quote",children:ft(a(p.comment),void 0,{t:s})})]}),p.additional_comment&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.additionalComment")}),t.jsx("p",{className:"bim-d-quote",children:ft(a(p.additional_comment),void 0,{t:s})})]}),!p.summary&&!p.comment&&!p.additional_comment&&!p.title_info&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{marginTop:12},children:s("workPage.catalog.titleOnly")}),e.length>1&&t.jsxs("div",{className:"bim-d-lu-pager bim-d-ui",children:[c>0?t.jsx("button",{type:"button","aria-label":s("workPage.catalog.prev",{name:a(e[c-1].source)}),onClick:()=>d(c-1),children:t.jsxs("span",{"aria-hidden":"true",children:["← ",a(e[c-1].source)]})}):t.jsx("span",{"aria-hidden":"true"}),t.jsxs("span",{className:"bim-d-meta",children:[c+1," / ",e.length]}),c<e.length-1?t.jsx("button",{type:"button","aria-label":s("workPage.catalog.next",{name:a(e[c+1].source)}),onClick:()=>d(c+1),children:t.jsxs("span",{"aria-hidden":"true",children:[a(e[c+1].source)," →"]})}):t.jsx("span",{"aria-hidden":"true"})]})]})]})})}function _b(e){var n;return{id:e.id,kind:"hypothetical",label:e.label,year:e.year??((n=e.year_range)==null?void 0:n[0]),year_range:e.year_range,year_uncertain:e.year_uncertain,group:e.group,note:e.note,description:e.description}}function $b(e,n){if(!e.lineage)return null;const i=e.lineage;return{id:e.id,kind:"book",label:e.title,year:i.year,year_text:i.year_text,year_uncertain:i.year_uncertain,category:i.category,status:i.status,extant_juan:i.extant_juan,group:n[e.id],note:i.note}}function Aa(e,n,i){return{id:`derive:${n.ref}->${e}:${i}`,source:n.ref,target:e,kind:"derive",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function Cb(e,n,i){const[o,s]=[e,n.book_id].sort();return{id:`sibling:${o}-${s}:${i}`,source:o,target:s,kind:"sibling",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function Tb(e,n){var p;if(n==="all")return null;const i=(p=e.collections)==null?void 0:p[n],o=Array.isArray(i==null?void 0:i.groups)&&i.groups.length>0,s=Array.isArray(i==null?void 0:i.book_ids)&&i.book_ids.length>0,a=o||s||!!(i!=null&&i.hypothetical_ids);if(!a&&n==="core"&&Array.isArray(e.core_books)&&e.core_books.length>0)return{books:new Set(e.core_books),hypos:e.core_hypotheticals?new Set(e.core_hypotheticals):null};if(!i||!a)return null;const l=o?new Set(i.groups):null,d=new Set(i.book_ids??[]);if(l&&e.node_groups)for(const[h,u]of Object.entries(e.node_groups))l.has(u)&&d.add(h);let c=null;if(i.hypothetical_ids&&(c=new Set(i.hypothetical_ids)),l){c||(c=new Set);for(const h of e.hypothetical_nodes??[])h.group&&l.has(h.group)&&c.add(h.id)}return{books:d,hypos:c}}function hi(e,n,i){const o=e.version_graph,s={nodes:[],edges:[],groups:[],layout:"LR",excluded:[]};if(!o||!o.enabled)return s;const a=new Set(o.excluded_books??[]),l=o.node_groups??{},d=Tb(o,i??o.default_collection??"all"),c=d!==null,p=(d==null?void 0:d.books)??null,h=(d==null?void 0:d.hypos)??null,u=new Set,m=new Set;if(c){const j=new Map(n.map(z=>[z.id,z])),k=new Map((o.hypothetical_nodes??[]).map(z=>[z.id,z])),$=z=>{const T=j.get(z);if(T&&T.lineage)return(T.lineage.derived_from??[]).map(W=>W.ref);const B=k.get(z);return B?(B.derived_from??[]).map(W=>W.ref):[]},C=z=>k.has(z)?!h||h.has(z):!p||p.has(z),_=new Set,E=z=>{if(!_.has(z)){_.add(z);for(const T of $(z))a.has(T)||(C(T)||(k.has(T)?m.add(T):j.has(T)&&u.add(T)),E(T))}};for(const z of n)p&&p.has(z.id)&&!a.has(z.id)&&E(z.id);for(const z of o.hypothetical_nodes??[])h&&h.has(z.id)&&E(z.id)}const f=n.filter(j=>!a.has(j.id)).filter(j=>!p||p.has(j.id)||u.has(j.id)).map(j=>{const k=$b(j,l);return k&&u.has(j.id)&&(k.bridge=!0),k}).filter(j=>j!==null),x=(o.hypothetical_nodes??[]).filter(j=>!h||h.has(j.id)||m.has(j.id)).map(j=>{const k=_b(j);return m.has(j.id)&&(k.bridge=!0),k}),v=[...f,...x],y=new Set(v.map(j=>j.id)),S=new Set,b=[],w=j=>{S.has(j.id)||!y.has(j.source)||!y.has(j.target)||(S.add(j.id),b.push(j))};for(const j of n)a.has(j.id)||!j.lineage||p&&!p.has(j.id)&&!u.has(j.id)||((j.lineage.derived_from??[]).forEach((k,$)=>{w(Aa(j.id,k,$))}),(j.lineage.related_to??[]).forEach((k,$)=>{w(Cb(j.id,k,$))}));for(const j of o.hypothetical_nodes??[])h&&!h.has(j.id)&&!m.has(j.id)||(j.derived_from??[]).forEach((k,$)=>{w(Aa(j.id,k,$))});return{nodes:v,edges:b,groups:o.groups??[],title:o.title,description:o.description,layout:o.layout??"LR",excluded:Array.from(a)}}function gd(e,n,i){const o=(e??(n!=null?String(n):"")).trim();return o?!i||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(o)?o:`约 ${o}`:""}function zb(e,n){const i=[],o=e.version_graph;if(!o)return i;const s=new Set(n.map(c=>c.id)),a=new Set((o.hypothetical_nodes??[]).map(c=>c.id)),l=new Set([...s,...a]),d=(c,p)=>{l.has(p.ref)||i.push(`${c}: derived_from.ref "${p.ref}" 未在 books 或 hypothetical_nodes 中找到`),p.ref_type==="book"&&!s.has(p.ref)&&i.push(`${c}: derived_from.ref "${p.ref}" 标记为 book 但不在 books 列表中`),p.ref_type==="hypothetical"&&!a.has(p.ref)&&i.push(`${c}: derived_from.ref "${p.ref}" 标记为 hypothetical 但不在 hypothetical_nodes 中`)};for(const c of n){if(!c.lineage)continue;const p=`Book ${c.id} (${c.title})`;(c.lineage.derived_from??[]).forEach(h=>d(p,h)),(c.lineage.related_to??[]).forEach(h=>{s.has(h.book_id)||i.push(`${p}: related_to.book_id "${h.book_id}" 不在 books 列表中`)})}for(const c of o.hypothetical_nodes??[]){const p=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(h=>d(p,h))}return i}const fd=({graph:e,renderLink:n,className:i,style:o})=>{const{t:s,convert:a}=ne();if(!e.nodes.length)return t.jsx("div",{style:{...Db,...o},className:i,children:s("lineage.emptyGraph")});const l=new Map,d=new Map;for(const f of e.edges)if(f.kind==="derive"){const x=l.get(f.target)??[];x.push(f),l.set(f.target,x)}else for(const x of[f.source,f.target]){const v=d.get(x)??[];v.push(f),d.set(x,v)}const c=new Map(e.nodes.map(f=>[f.id,f])),p=new Map,h=[];for(const f of e.nodes)if(f.group){const x=p.get(f.group)??[];x.push(f),p.set(f.group,x)}else h.push(f);const u=(f,x)=>(f.year??9999)-(x.year??9999);p.forEach(f=>f.sort(u)),h.sort(u);const m=e.groups.filter(f=>p.has(f.id));return t.jsxs("div",{className:i,style:{...Ib,...o},children:[e.title&&t.jsx("div",{style:Rb,children:a(e.title)}),e.description&&t.jsx("div",{style:Eb,children:a(e.description)}),m.map(f=>t.jsx(Ma,{label:f.label,color:f.color,nodes:p.get(f.id),incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n},f.id)),h.length>0&&t.jsx(Ma,{label:s("lineage.otherGroup"),nodes:h,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},Ma=({label:e,color:n,nodes:i,incomingMap:o,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=ne();return t.jsxs("div",{style:Lb,children:[t.jsx("div",{style:{...Ab,borderLeftColor:n??r("widget-border")},children:d(e)}),i.map(c=>t.jsx(Nb,{node:c,incoming:o.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},Nb=({node:e,incoming:n,siblings:i,nodeMap:o,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=ne();return t.jsxs("div",{style:{...Mb,borderStyle:a||l?"dashed":"solid",opacity:l?.55:e.status==="lost"?.7:1,background:l?r("bg-subtle"):void 0},title:l?d("lineage.bridgeTitle"):void 0,children:[t.jsxs("div",{style:Pb,children:[t.jsx("span",{style:Bb,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:Wb,children:gd(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:Ob,children:[e.category&&t.jsx(zn,{children:c(e.category)}),e.status==="lost"&&t.jsx(zn,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(zn,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(zn,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(zn,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:Fb,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:Hb,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:Ba,children:[t.jsx("div",{style:Wa,children:d("lineage.sources")}),n.map(p=>{const h=o.get(p.source);return t.jsxs("div",{style:Oa(p.confidence),children:[t.jsx("span",{style:Fa,children:c(p.relation)}),t.jsx("span",{children:(h==null?void 0:h.kind)==="book"&&s?s(h.id,c(h.label)):c((h==null?void 0:h.label)??p.source)}),p.confidence!=="consensus"&&p.confidence!=="certain"&&t.jsx(Pa,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Ha,children:["· ",c(p.evidence)]})]},p.id)})]}),i.length>0&&t.jsxs("div",{style:Ba,children:[t.jsx("div",{style:Wa,children:d("lineage.related")}),i.map(p=>{const h=p.source===e.id?p.target:p.source,u=o.get(h);return t.jsxs("div",{style:Oa(p.confidence),children:[t.jsx("span",{style:Fa,children:c(p.relation)}),t.jsx("span",{children:(u==null?void 0:u.kind)==="book"&&s?s(u.id,c(u.label)):c((u==null?void 0:u.label)??h)}),t.jsx(Pa,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Ha,children:["· ",c(p.evidence)]})]},p.id)})]})]})},zn=({children:e,tone:n="default"})=>{const o={default:{bg:r("tag-bg"),fg:r("fg")},warn:{bg:r("warn-bg"),fg:r("warn-fg")},info:{bg:r("info-bg"),fg:r("info-fg")}}[n];return t.jsx("span",{style:{display:"inline-block",padding:"1px 8px",fontSize:"11px",borderRadius:"10px",background:o.bg,color:o.fg,marginRight:"4px"},children:e})},Pa=({level:e})=>{const{t:n}=ne(),o={certain:{key:"certain",color:r("confidence-certain")},consensus:{key:"consensus",color:r("confidence-consensus")},probable:{key:"probable",color:r("confidence-probable")},disputed:{key:"disputed",color:r("confidence-disputed")}}[e];return o?t.jsx("span",{style:{display:"inline-block",padding:"0 6px",fontSize:"10px",border:`1px solid ${o.color}`,color:o.color,borderRadius:"8px",marginLeft:"4px"},children:n(`lineage.confidence.${o.key}`)}):null},Ib={fontSize:"14px",color:r("fg")},Rb={fontSize:"16px",fontWeight:600,marginBottom:"8px"},Eb={fontSize:"13px",color:r("muted"),marginBottom:"16px",lineHeight:1.6},Lb={marginBottom:"16px"},Ab={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:r("fg")},Mb={border:`1px solid ${r("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:r("bg")},Pb={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Bb={fontSize:"15px",fontWeight:600},Wb={fontSize:"12px",color:r("muted")},Ob={marginBottom:"6px"},Fb={fontSize:"12px",color:r("muted"),margin:"2px 0"},Hb={fontSize:"12px",color:r("muted"),fontStyle:"italic",margin:"4px 0"},Ba={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${r("widget-border")}`},Wa={fontSize:"11px",color:r("muted"),marginBottom:"2px"},Oa=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),Fa={display:"inline-block",padding:"0 6px",fontSize:"11px",background:r("tag-bg"),color:r("fg"),borderRadius:"3px",marginRight:"6px"},Ha={fontSize:"11px",color:r("muted")},Db={padding:"20px",textAlign:"center",color:r("muted"),fontSize:"13px"},xd=({selectedNodeId:e,...n})=>{const{t:i}=ne(),[o,s]=g.useState("loading"),[a,l]=g.useState(null);return g.useEffect(()=>{let d=!1;return Ub().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),o==="loading"?t.jsx("div",{style:Ua,children:i("lineage.graphLoading")}):o==="missing"||!a?t.jsxs("div",{style:Ua,children:[t.jsx("div",{children:Da(i("lineage.graphMissing"),{xyflow:t.jsx("code",{children:"@xyflow/react"}),dagre:t.jsx("code",{children:"@dagrejs/dagre"})})}),t.jsx("div",{style:{fontSize:"12px",marginTop:"4px"},children:Da(i("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(Vb,{modules:a,selectedNodeId:e,...n})};function Da(e,n){return e.split(/(\{\w+\})/).map((i,o)=>{const s=/^\{(\w+)\}$/.exec(i);return t.jsx(g.Fragment,{children:s&&s[1]in n?n[s[1]]:i},o)})}async function Ub(){try{const[e,n]=await Promise.all([import("@xyflow/react"),import("@dagrejs/dagre")]);let i=!1;try{await import("@xyflow/react/dist/style.css"),i=!0}catch{i=!1}return{ReactFlow:e.ReactFlow,Background:e.Background,Controls:e.Controls,Handle:e.Handle,Position:e.Position,BaseEdge:e.BaseEdge,EdgeLabelRenderer:e.EdgeLabelRenderer,getSmoothStepPath:e.getSmoothStepPath,dagre:n,cssLoaded:i}}catch{return null}}const Vb=({graph:e,renderLink:n,height:i=600,className:o,style:s,selectedNodeId:a,modules:l})=>{const{ReactFlow:d,Background:c,Controls:p,Handle:h,Position:u,BaseEdge:m,EdgeLabelRenderer:f,getSmoothStepPath:x,dagre:v}=l,y=g.useMemo(()=>({lineage:$=>{var F,Y,te,se;const C=((F=$.data)==null?void 0:F.stepPosition)??.85,[_,E,z]=x({sourceX:$.sourceX,sourceY:$.sourceY,sourcePosition:$.sourcePosition,targetX:$.targetX,targetY:$.targetY,targetPosition:$.targetPosition,stepPosition:C,borderRadius:5}),T=!!((Y=$.data)!=null&&Y.isSibling),B=T?E:$.targetX-18,W=T?z:$.targetY-12,N=(te=$.data)==null?void 0:te.labelStyle,A=(se=$.data)==null?void 0:se.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(m,{id:$.id,path:_,style:$.style,markerStart:$.markerStart,markerEnd:$.markerEnd}),$.label&&t.jsx(f,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${B}px,${W}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:r("bg"),border:`0.5px solid ${r("widget-border")}`,...A,...N},children:$.label})})]})}}),[m,f,x]),S=g.useMemo(()=>({version:$=>{const{t:C}=ne(),_=$.data,E=_.kind==="hypothetical",z=_.status==="lost",T=_.isSelected,B=_.bridge,W=_.borderColor??r("muted"),N=B||E?"dashed":"solid",A=B?.5:z?.6:1;return t.jsxs("div",{style:{background:r(B?"bg-subtle":"bg"),border:`2px ${N} ${T?r("primary"):W}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:A,boxShadow:T?r("shadow-node-selected"):E||B?"none":r("shadow-node")},title:B?C("lineage.bridgeTitle"):void 0,children:[t.jsx(h,{type:"target",position:u.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:E||!_.renderLink?_.label:_.renderLink(_.bookId,_.label)}),_.description&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.25,marginTop:1},children:_.description}),_.yearText&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.2},children:gd(_.yearText,void 0,_.uncertain)}),z&&t.jsx("div",{style:{fontSize:9,color:r("lost-fg"),marginTop:1},children:C("lineage.lost")}),t.jsx(h,{type:"source",position:u.Right,style:{visibility:"hidden"}})]})}}),[h,u]),{convert:b}=ne(),{rfNodes:w,rfEdges:j}=g.useMemo(()=>Gb(e,v,n,a,b),[e,v,n,a,b]);return t.jsx("div",{style:{width:"100%",height:i,...s},className:o,children:t.jsxs(d,{nodes:w,edges:j,nodeTypes:S,edgeTypes:y,fitView:!0,fitViewOptions:{padding:.15},proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,minZoom:.2,maxZoom:1.8,children:[t.jsx(c,{gap:16}),t.jsx(p,{showInteractive:!1})]})})};function Gb(e,n,i,o,s=a=>a??""){const d=e.layout==="LR"||!e.layout,c=new n.graphlib.Graph;c.setGraph({rankdir:d?"LR":"TB",ranksep:160,nodesep:40,edgesep:16,marginx:20,marginy:20}),c.setDefaultEdgeLabel(()=>({}));const p=new Map(e.groups.map(S=>[S.id,S.color??r("muted")]));for(const S of e.nodes)c.setNode(S.id,{width:160,height:90});const h=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const S of e.edges)S.kind==="derive"&&(h.has(S.relation)||c.setEdge(S.source,S.target));n.layout(c);const u=e.nodes.map(S=>{const b=c.node(S.id),w=o?S.id===o:void 0,j={kind:S.kind,label:s(S.label),bookId:S.kind==="book"?S.id:void 0,yearText:s(S.year_text??qb(S)),uncertain:S.year_uncertain,category:S.category,status:S.status,borderColor:S.group?p.get(S.group):void 0,renderLink:i,isSelected:w,description:s(S.description),bridge:S.bridge};return{id:S.id,type:"version",position:{x:b.x-160/2,y:b.y-90/2},data:j,draggable:!1,selected:w}}),m=.78,f=.06,x=new Map;for(const S of e.edges)S.kind==="derive"&&(x.has(S.source)||x.set(S.source,[]),x.get(S.source).push(S));const v=new Map;for(const[S,b]of x){if(b.length<=1)continue;const w=[...b].sort((k,$)=>{var E,z;const C=((E=c.node(k.target))==null?void 0:E.y)??0,_=((z=c.node($.target))==null?void 0:z.y)??0;return C-_}),j=w.length;w.forEach((k,$)=>{const C=($-(j-1)/2)*f;v.set(k.id,m+C)})}const y=e.edges.map(S=>Yb(S,v.get(S.id),s));return{rfNodes:u,rfEdges:y}}function Yb(e,n,i=o=>o??""){const o=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=Kb(e.confidence),l={type:"arrowclosed",color:a,width:14,height:14};return{id:e.id,source:e.source,target:e.target,type:"lineage",label:i(e.relation),data:{labelStyle:{color:r("fg")},isSibling:s,stepPosition:n},style:{stroke:a,strokeWidth:s?1:1.5,strokeDasharray:s?"4 3":o?"6 4":void 0,opacity:o?.75:1},animated:!1,markerEnd:l,markerStart:s?l:void 0,zIndex:1e3}}function qb(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function Kb(e){switch(e){case"certain":return r("confidence-certain");case"consensus":return r("lineage-edge-consensus");case"probable":return r("confidence-probable");case"disputed":return r("confidence-disputed");default:return r("muted")}}const Ua={padding:"40px 20px",textAlign:"center",color:r("muted"),fontSize:"13px",border:`1px dashed ${r("widget-border")}`,borderRadius:8,background:r("bg")},Do=({graph:e,defaultMode:n="list",renderLink:i,graphHeight:o=600,selectedNodeId:s,onModeChange:a,collection:l,onCollectionChange:d,collectionsAvailable:c,collectionCounts:p,className:h,style:u})=>{var j;const{t:m,convert:f}=ne(),[x,v]=g.useState(n),y=k=>{v(k),a==null||a(k)},S=(()=>{if(!c)return[];const k=Object.entries(c);return k.length===0||c.all?k:[...k,["all",{label:m("lineage.collectionAll"),description:m("lineage.collectionAllDesc")}]]})(),b=!!(d&&S.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:r("muted"),textAlign:"center"},children:m("lineage.empty")});const w=l?(j=c==null?void 0:c[l])==null?void 0:j.description:void 0;return t.jsxs("div",{className:h,style:u,children:[t.jsxs("div",{style:Xb,children:[t.jsx("button",{onClick:()=>y("list"),style:gr(x==="list"),children:m("lineage.modeList")}),t.jsx("button",{onClick:()=>y("graph"),style:gr(x==="graph"),children:m("lineage.modeGraph")}),b&&t.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:12,color:r("muted"),marginRight:4},children:m("lineage.collectionLabel")}),S.map(([k,$])=>{const C=p==null?void 0:p[k];return t.jsxs("button",{onClick:()=>d==null?void 0:d(k),style:gr(l===k),title:$.description?f($.description):void 0,children:[f($.label),C!=null?` ${C}`:""]},k)})]})]}),b&&w&&t.jsx("div",{style:{fontSize:12,color:r("muted"),marginBottom:8,padding:"4px 8px",background:r("bg-subtle"),borderRadius:4},children:f(w)}),x==="list"?t.jsx(fd,{graph:e,renderLink:i}):t.jsx(xd,{graph:e,renderLink:i,height:o,selectedNodeId:s})]})},Xb={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},gr=e=>({padding:"4px 12px",fontSize:12,border:`1px solid ${r("widget-border")}`,borderRadius:4,background:e?r("primary"):"transparent",color:r(e?"primary-fg":"fg"),cursor:"pointer"}),Va=40,Ga=2,Zb=9,Jb=new Set(["certain","consensus","probable","disputed"]);function fr(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const bd=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:h})=>{var je,ke,P,fe,oe,we,Le,He,Ge,Ye,Xe;const u=Ee(),{t:m,convert:f}=ne(),[x,v]=g.useState(null),[y,S]=g.useState(new Map),[b,w]=g.useState([]),[j,k]=g.useState(new Map),[$,C]=g.useState(!1),[_,E]=g.useState("flow"),[z,T]=g.useState(null);g.useEffect(()=>{if(!n||!e.work_id){v(null);return}let I=!1;return n.getItem(e.work_id).then(U=>{!I&&U&&U.type==="work"&&v(U)}).catch(()=>{}),()=>{I=!0}},[n,e.work_id]),g.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){T(null);return}let I=!1;return n.getLineageGraph(e.work_id).then(U=>{I||T(U&&U.nodes.length>1?U:null)}).catch(()=>{I||T(null)}),()=>{I=!0}},[n,e.work_id]),g.useEffect(()=>{const I=e._collections||[];if(!n||I.length===0){S(new Map);return}let U=!1;return Promise.all(I.map(pe=>{const $e=pe.id;return n.getItem($e).then(ye=>[$e,ye]).catch(()=>[$e,null])})).then(pe=>{if(U)return;const $e=new Map;for(const[ye,ue]of pe)ue&&$e.set(ye,ue);S($e)}),()=>{U=!0}},[n,e._collections]);const B=g.useMemo(()=>{const I=new Set([...x?po(x):[],...e.related_books||[]]);return I.add(e.id),[...I]},[x,e.related_books,e.id]),W=B.length-1;g.useEffect(()=>{if(!n||W<=0){w([]);return}const I=B.length<=Va,U=I?B:B.slice(0,8);let pe=!1;return Promise.all(U.map($e=>$e===e.id?Promise.resolve({id:$e,title:e.title,edition:e.edition,year:xi(e)}):n.getItem($e).then(ye=>{const ue=ye??{};return{id:$e,title:ue.title,edition:ue.edition,year:ye?xi(ue):void 0}}).catch(()=>({id:$e})))).then($e=>{if(pe)return;const ye=$e.filter(ue=>ue.id===e.id||ue.title||ue.edition);I&&ye.sort((ue,Ve)=>(ue.year??1/0)-(Ve.year??1/0)),w(ye)}),()=>{pe=!0}},[n,B,W,e]);const N=e.lineage,A=g.useMemo(()=>[...((N==null?void 0:N.derived_from)||[]).filter(I=>I.ref_type==="book").map(I=>I.ref),...((N==null?void 0:N.related_to)||[]).map(I=>I.book_id)].filter(Boolean),[N]);g.useEffect(()=>{if(!n||A.length===0){k(new Map);return}let I=!1;return Promise.all(A.map(U=>n.getItem(U).then(pe=>[U,{id:U,title:pe==null?void 0:pe.title,edition:pe==null?void 0:pe.edition}]).catch(()=>[U,{id:U}]))).then(U=>{I||k(new Map(U))}),()=>{I=!0}},[n,A]);const F=g.useMemo(()=>pd(e.resources,e.resource_groups,m),[e.resources,e.resource_groups,m]),Y=F.groups.reduce((I,U)=>I+U.rows.length+U.mirrors.length,0),te=F.groups.length>0&&F.groups.every(I=>I.key==="_physical"),se=Wn(e),D=ic(e),V=Bt(e,u.unit.juan),he=new Set((e._collections||[]).map(I=>Ln(I.vol).length).filter(I=>I>0)),Z=I=>{var $e;const U=($e=e.base_edition)==null?void 0:$e.find(ye=>ye.book_id===I&&ye.name);if(U!=null&&U.name)return U.name;const pe=j.get(I);return(pe==null?void 0:pe.edition)||(pe==null?void 0:pe.title)||""},M=g.useMemo(()=>{var ve,Ae,Oe,Ie,me;const I=[];D&&I.push({label:m("bookPage.fact.editionType"),value:f(D),title:e.edition_type||(ve=e.lineage)!=null&&ve.category?void 0:m("bookPage.inferredFromEdition")}),(Ae=e.publication_info)!=null&&Ae.details?I.push({label:m("bookPage.fact.publication"),value:f(e.publication_info.details)}):(se.era||se.reign)&&I.push({label:m("bookPage.fact.era"),value:f([se.era,se.reign].filter(Boolean).join(" ")),title:se.source==="edition"?m("bookPage.inferredFromEdition"):void 0}),V&&I.push({label:m("bookPage.fact.measure"),value:f(V)});const U=(e._collections||[]).flatMap(Te=>Ln(Te.vol));U.length&&I.push({label:m("bookPage.fact.volumes"),value:m("bookPage.volumesValue",{range:Ri(U,u.unit.volume),unit:u.unit.volume,n:U.length})});const pe=(((Oe=e.lineage)==null?void 0:Oe.derived_from)||[]).find(Te=>Te.relation==="底本"&&Te.ref_type==="book");pe&&Z(pe.ref)&&I.push({label:m("bookPage.fact.baseEdition"),value:t.jsx(et,{id:pe.ref,label:f(Z(pe.ref)),onNavigate:i,renderLink:o,dense:!0})});const $e=(e.base_edition||[]).filter(Te=>Te&&Te.name);for(const Te of["底本","配補","參校"]){if(Te==="底本"&&pe&&Z(pe.ref))continue;const De=$e.filter(Me=>Me.role===Te);De.length&&I.push({label:f(Te),value:De.map((Me,yt)=>t.jsxs(g.Fragment,{children:[yt>0&&"、",Me.book_id?t.jsx(et,{id:Me.book_id,label:f(Me.name),onNavigate:i,renderLink:o,dense:!0}):f(Me.name)]},yt))})}const ye=(e.provenance||[]).filter(Te=>Te&&Te.institution),ue=(e.resources||[]).filter(Te=>Mt(Te).includes("physical"));if(ye.length){I.push({label:m("bookPage.fact.holdings"),value:ye.slice(0,2).map(Me=>f(Me.institution)).join("、")+(ye.length>2?m("bookPage.andMorePlaces",{n:ye.length}):"")});const Te=ye.filter(Me=>Me.call_number).slice(0,2).map(Me=>`${f(Me.institution)} ${Me.call_number}`);Te.length&&I.push({label:m("bookPage.fact.callNumber"),value:Te.join(";")+(ye.filter(Me=>Me.call_number).length>2?"…":"")});const De=ye.flatMap(Me=>Me.seals||[]).filter(Boolean);De.length&&I.push({label:m("bookPage.fact.seals"),value:f(De.join("、"))})}else ue.length?I.push({label:m("bookPage.fact.holdings"),value:ue.slice(0,2).map(Te=>f(Te.name)).join("、")+(ue.length>2?m("bookPage.andMorePlaces",{n:ue.length}):"")}):(Ie=e.current_location)!=null&&Ie.name&&I.push({label:m("bookPage.fact.holdings"),value:f(e.current_location.name)});const Ve=e.physical_description;if(Ve){const Te=[[m("bookPage.fact.leafStyle"),Ve.leaf_style],[m("bookPage.fact.binding"),Ve.binding],[m("bookPage.fact.dimensions"),Ve.dimensions],[m("bookPage.fact.condition"),Ve.condition]];for(const[De,Me]of Te)Me&&Me.trim()&&I.push({label:De,value:f(Me)})}(me=e.page_count)!=null&&me.description&&I.push({label:u.label.pageCount,value:f(e.page_count.description)});const ee=[...Rr(e.additional_titles),...Rr(e.attached_texts)];return ee.length&&I.push({label:m("bookPage.fact.aliases"),value:ee.map(f).join("、")}),I},[e,f,u,m,se,D,V,j,i,o]),_e=f(e.title),ce=e.edition?f(e.edition):void 0,ge=((je=e.lineage)==null?void 0:je.year_text)||"",le=t.jsx(Fn,{kind:m("bookPage.kind"),title:_e,subtitle:ce,byline:t.jsx(Fo,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:i,renderLink:o}),meta:(()=>{const I=[D?f(D):"",se.era?f([se.era,se.reign].filter(Boolean).join("")):"",V?f(V):""].filter(Boolean);return I.length?t.jsx("span",{className:"bim-d-tags",children:I.map((U,pe)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(pe,2)}`,children:U},pe))}):null})(),description:(ke=e.description)!=null&&ke.text?t.jsx(Pt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:go((P=e.description)==null?void 0:P.text)?6:void 0,facts:M,readAction:s,secondaryAction:s&&Y>0&&!te?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:m("bookPage.viewImages")}):void 0,foot:t.jsx(Hn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),Be=e._collections||[],ze=(a==null?void 0:a.chapters)||[],Fe=f(ze[0]&&fr(ze[0].title)[0].slice(-1)||"")||m("bookPage.chapterUnit"),Q=m("bookPage.chapterCount",{n:ze.length,unit:Fe}),H=!!((fe=N==null?void 0:N.derived_from)!=null&&fe.length||(oe=N==null?void 0:N.related_to)!=null&&oe.length||(we=e.appendix)!=null&&we.length),G=[],xe=m(te?"bookPage.sec.physical":"bookPage.sec.images");(ze.length||F.text.length||l)&&G.push({id:"fulltext",label:m("bookPage.sec.fulltext"),count:ze.length?Q:void 0}),F.groups.length&&G.push({id:"images",label:xe,count:Y}),H&&G.push({id:"lineage",label:m("bookPage.sec.lineage")}),Be.length&&G.push({id:"collections",label:m("section.containedIn"),count:Be.length}),(Le=e.location_history)!=null&&Le.length&&G.push({id:"provenance",label:m("section.locationHistory")});const K=I=>(d==null?void 0:d(I))??null,L=ze[0],q=L?K(L.file):null,ae=$?ze:ze.slice(0,Zb),be=(I,U,pe)=>I?t.jsx("a",{className:pe,href:I.href??"#",onClick:I.onClick?$e=>{$e.metaKey||$e.ctrlKey||($e.preventDefault(),I.onClick())}:void 0,children:U}):t.jsx("span",{className:pe,children:U}),X=t.jsxs(t.Fragment,{children:[(ze.length>0||F.text.length>0||l)&&t.jsxs(rt,{id:"fulltext",title:m("bookPage.sec.fulltext"),meta:ze.length>0?t.jsx(it,{items:[Q,(He=a==null?void 0:a.source)!=null&&He.name?m("bookPage.sourceBy",{src:f(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!L&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-d-ft","aria-busy":"true",children:[t.jsx("span",{className:"bim-d-ft-h",children:" "}),t.jsx("span",{className:"bim-d-meta",children:" "})]}),t.jsx("div",{className:"bim-d-chap-pending","aria-hidden":"true"})]}),L&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:m("bookPage.readFrom",{ch:f(fr(L.title)[0])||m("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:f((L.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),be(q,t.jsxs(t.Fragment,{children:[m("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),ze.length>1&&t.jsx("ul",{className:"bim-d-chap",children:ae.map(I=>{const[U,pe]=fr(I.title);return t.jsx("li",{children:be(K(I.file),t.jsxs(t.Fragment,{children:[U&&t.jsx("b",{children:f(U)}),f(pe||I.file)]}))},I.file)})}),ze.length>ae.length&&t.jsx(ho,{label:m("detail.expandRest",{n:ze.length-ae.length,unit:Fe}),onClick:()=>C(!0)}),F.text.length>0&&t.jsxs(t.Fragment,{children:[(ze.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:m("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:F.text.map((I,U)=>t.jsx(Ho,{item:I,siblings:F.text,listedVolumeCounts:he},`${I.id||I.url||I.name}-${U}`))})})]})]}),F.groups.length>0&&t.jsx(rt,{id:"images",title:xe,meta:t.jsx(it,{items:[F.groups.length>1?m("bookPage.groupCount",{n:F.groups.length}):"",m("bookPage.placeCount",{n:Y})]}),children:t.jsx(md,{groups:F.groups,listedVolumeCounts:he})}),H&&t.jsx(rt,{id:"lineage",title:m("bookPage.sec.lineage"),meta:(Ge=N==null?void 0:N.derived_from)!=null&&Ge.length?m("bookPage.lineageMeta"):void 0,action:z?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":m("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":_==="flow",onClick:()=>E("flow"),children:m("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":_==="graph",onClick:()=>E("graph"),children:m("bookPage.viewGraph")})]}):void 0,children:_==="graph"&&z?t.jsx(Do,{graph:z,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(I,U)=>t.jsx(et,{id:I,label:f(U),onNavigate:i,renderLink:o,dense:!0})}):t.jsx(ey,{data:e,heading:ce||_e,yearText:ge,refName:Z,onNavigate:i,renderLink:o})}),Be.length>0&&t.jsx(rt,{id:"collections",title:m("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:Be.map((I,U)=>{const pe=I.id,$e=Ln(I.vol),ye=y.get(pe),ue=uh(ye);return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(et,{id:pe,label:ye?f(ye.title):pe,onNavigate:i,renderLink:o,dense:!0}),$e.length>0&&t.jsx(Qb,{volumes:$e,unit:u.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${ue?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:ue>0&&m("bookPage.totalOf",{n:ue,unit:u.unit.bu})})]},`${pe}-${U}`)})})})}),(Ye=e.location_history)!=null&&Ye.length?t.jsx(rt,{id:"provenance",title:m("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((I,U)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:f(I.name)}),([I.start_date,I.end_date].filter(Boolean).join("—")||I.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(it,{items:[[I.start_date,I.end_date].filter(Boolean).join("—"),I.description?f(I.description):""]})})]},U))})}):null,G.length===0&&t.jsx(rt,{title:m("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:m("bookPage.emptyText")})})]}),re=b.findIndex(I=>I.id===e.id),Ce=B.length<=Va,We=Ce&&re>=0?b.slice(Math.max(0,re-Ga),re+Ga+1):b.filter(I=>I.id!==e.id),O=t.jsxs(t.Fragment,{children:[x&&t.jsxs("div",{id:"work",className:"bim-d-side",style:{scrollMarginTop:16},children:[t.jsx("h2",{className:"bim-d-ui bim-d-side-h",children:f(u.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(et,{id:x.id,label:f(x.title),onNavigate:i,renderLink:o})}),t.jsx(it,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(I=>`${I.dynasty?`〔${f(I.dynasty)}〕`:""}${f(I.name)}`),f(Bt(x,u.unit.juan)),x._edition_count?m("bookPage.editionCount",{n:x._edition_count}):""]}),((Xe=x.description)==null?void 0:Xe.text)&&t.jsx("p",{style:{fontSize:14,lineHeight:1.8,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},className:"bim-d-card-desc bim-d-side-desc",children:f(x.description.text.replace(/[#*_>`[\]]/g,""))})]}),W>0&&We.length>0&&t.jsxs("div",{children:[t.jsx(en,{id:"siblings",timeline:!0,title:Ce?m("bookPage.siblings"):u.relation.siblingVersions,meta:Ce?m("bookPage.byEra"):m("bookPage.kindCount",{n:W}),cap:We.length,items:We.map(I=>I.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:f(I.edition||I.title||I.id)}):t.jsx(et,{id:I.id,label:f(I.edition||I.title||I.id),onNavigate:i,renderLink:o,dense:!0})),metas:We.map(I=>[I.year!=null?I.year<0?m("detail.bce",{n:-I.year}):String(I.year):"",I.id===e.id?m("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:We.findIndex(I=>I.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(et,{id:x.id,label:m("bookPage.viewAllInWork",{n:B.length}),onNavigate:i,renderLink:o,dense:!0})})]})]}),ie=e.work_id?t.jsx(lc,{caption:u.section.belongsToWork,children:t.jsx(et,{id:e.work_id,label:x?f(x.title):" ",onNavigate:i,renderLink:o,dense:!0})}):void 0;return t.jsx(On,{railTop:c,back:p,up:ie,nav:G,railLinks:h,main:X,card:le,side:O})};function Qb({volumes:e,unit:n}){const{t:i}=ne();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[i("bookPage.volumeRange",{range:Ri(e,n),unit:n}),e.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-d-dot"}),i("bookPage.volumeCount",{n:e.length,unit:n})]})]})}function ey({data:e,heading:n,yearText:i,refName:o,onNavigate:s,renderLink:a}){var S;const{t:l,convert:d}=ne(),c=e.lineage,p=(c==null?void 0:c.derived_from)||[],h=p.filter(b=>b.ref_type!=="book"),u=p.filter(b=>b.ref_type==="book"&&b.relation==="底本"),m=p.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),f=(c==null?void 0:c.related_to)||[],x=p.length>0||f.length>0,v=b=>b&&Jb.has(b)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${b}`)}):"",y=(b,w)=>t.jsx(et,{id:b,label:d(w||b),onNavigate:s,renderLink:a,dense:!0});return t.jsxs("div",{className:"bim-d-lf",children:[x&&t.jsxs("ol",{className:"bim-d-lf-list",children:[h.map((b,w)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:b.relation?d(b.relation):l("bookPage.lineage.ancestor")}),t.jsx("span",{className:"bim-d-lf-name",children:l("bookPage.lineage.reconstructed")}),b.evidence&&t.jsxs("span",{className:"bim-d-meta",children:[d(b.evidence),v(b.confidence)]})]})},`a-${w}`)),u.map((b,w)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-card",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,o(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),v(b.confidence)]})]})},`b-${w}`)),t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-cur",children:[t.jsxs("div",{className:"bim-d-lf-here",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:l("bookPage.lineage.thisEdition")}),t.jsx("span",{className:"bim-d-lf-name",children:n}),i&&t.jsx("span",{className:"bim-d-lf-yr",children:d(i)})]}),m.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:m.map((b,w)=>t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,o(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),v(b.confidence)]})]},w))})]}),f.length>0&&t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-out",children:[t.jsx("span",{className:"bim-d-lf-out-h bim-d-ui",children:l("bookPage.lineage.derivatives")}),t.jsx("span",{className:"bim-d-lf-chips",children:f.map((b,w)=>t.jsxs("span",{className:"bim-d-lf-chip",title:b.evidence?d(b.evidence):void 0,children:[y(b.book_id,o(b.book_id)),t.jsx("span",{className:"bim-d-meta",children:d(b.relation)})]},w))})]})]}),(S=e.appendix)==null?void 0:S.map((b,w)=>t.jsxs("details",{className:"bim-d-lf-app",children:[t.jsxs("summary",{className:"bim-d-ui",children:[t.jsx("span",{className:"bim-d-meta",children:l("bookPage.lineage.appendix")})," ",d(b.title)]}),t.jsx(Pt,{text:b.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${w}`)),(c==null?void 0:c.note)&&t.jsx("p",{className:"bim-d-meta",style:{margin:"12px 0 0",maxWidth:"46em"},children:d(c.note)})]})}const Nn=16,ty=200,ny=16,yd=({data:e,catalog:n,transport:i,onNavigate:o,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var re,Ce,We,O,ie,je,ke;const{t:p,convert:h,messages:u}=ne(),[m,f]=g.useState(""),[x,v]=g.useState(!1),[y,S]=g.useState(null),[b,w]=g.useState(""),[j,k]=g.useState(!1),$=g.useMemo(()=>tc(e,n),[e,n]),C=g.useMemo(()=>ec(e),[e]),[_,E]=g.useState(new Map),z=!!i&&$.rows.length>0&&$.rows.length<=ty,T=z&&($.rows.length<=Nn||j),B=T&&$.rows.every(P=>!P.id||_.has(P.id)),W=P=>{var fe;return Fr(P?(fe=_.get(P))==null?void 0:fe.l1:void 0)},N=g.useMemo(()=>{const P=m.trim(),fe=P?h(P):"";return $.rows.filter(oe=>{var Le,He;if(b&&Fr(oe.id?(Le=_.get(oe.id))==null?void 0:Le.l1:void 0)!==b)return!1;if(!fe)return!0;const we=oe.id&&((He=_.get(oe.id))==null?void 0:He.title)||oe.title;return h(we).includes(fe)||(oe.subItems||[]).some(Ge=>h(Ge).includes(fe))})},[$.rows,m,b,_,h]),A=x?N:N.slice(0,Nn),F=g.useMemo(()=>(T?$.rows:A).filter(P=>P.id&&!_.has(P.id)).map(P=>P.id),[T,$.rows,A,_]);g.useEffect(()=>{if(!i||F.length===0)return;let P=!1;const fe=F.slice(0,ny);return Pi(fe,Mi,oe=>i.getItem(oe).then(we=>{var Ge,Ye;const Le=we??{},He={title:Le.title,edition:Le.edition,authors:Le.authors,measure:we?Bt(we,u.unit.juan):void 0,versionCount:Le._edition_count??((Ge=Le._books)==null?void 0:Ge.length),l1:((Ye=uo(Le))==null?void 0:Ye.l1)||void 0};return[oe,He]}).catch(()=>[oe,{}]),()=>P).then(oe=>{P||E(we=>{const Le=new Map(we);for(const[He,Ge]of oe)Le.set(He,Ge);return Le})}),()=>{P=!0}},[i,F,u.unit.juan]);const Y=(re=(e.contained_in||[])[0])==null?void 0:re.id;g.useEffect(()=>{if(!Y){S(null);return}if(S({id:Y}),!i)return;let P=!1;return i.getItem(Y).then(fe=>{P||S({id:Y,title:fe==null?void 0:fe.title})}).catch(()=>{}),()=>{P=!0}},[i,Y]);const te=g.useMemo(()=>pd(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),se=te.text.length+te.groups.reduce((P,fe)=>P+fe.rows.length+fe.mirrors.length,0),D=C.works,V=new Set($.rows.map(P=>P.id).filter(Boolean)),he=D.length>0&&!D.every(P=>V.has(P.id)),Z=(()=>{const P=$.rows.map(fe=>fe.edition).filter(Boolean);return P.length>1&&new Set(P).size===1})(),M=$.rows.some(P=>P.volumes.length>0||P.expected!=null),_e=C.total,ce=C.truncated?_e:$.rows.length,ge=Bt(e,u.unit.juan),le=e.count,Be=P=>typeof P=="number"&&Number.isFinite(P)?P:null,ze=Be(le==null?void 0:le.juan)??Be((Ce=e.juan_count)==null?void 0:Ce.number),Fe=Be(le==null?void 0:le.ce)??($.totalVolumes||null),Q=[{value:ce,label:p("collectionPage.stat.titles")},{value:ze??0,label:u.unit.juan},{value:Fe??0,label:u.unit.volume}],H=g.useMemo(()=>{var oe,we;const P=[];if((oe=e.publication_info)!=null&&oe.details&&P.push({label:p("collectionPage.fact.publication"),value:h(e.publication_info.details)}),_e&&(_e!==$.rows.length||C.truncated)){const Le=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");P.push({label:Le,value:`${_e} ${u.unit.bu}`,title:p("collectionPage.memberNote")})}const fe=[Be(le==null?void 0:le.zhong)!=null?p("collectionPage.nZhong",{n:le.zhong}):"",Be(le==null?void 0:le.han)!=null?p("collectionPage.nHan",{n:le.han}):""].filter(Boolean);return fe.length&&P.push({label:p("collectionPage.fact.expected"),value:fe.join(" ")}),ze==null&&ge&&P.push({label:p("collectionPage.fact.measure"),value:h(ge),title:(we=e.juan_count)!=null&&we.description?h(e.juan_count.description):void 0}),P},[e,_e,C.truncated,$.rows.length,ze,ge,le,h,p,u]),G=g.useMemo(()=>{if(!B)return[];const P=new Map;for(const oe of $.rows){const we=W(oe.id);we&&P.set(we,(P.get(we)??0)+1)}const fe=Mn.filter(oe=>(P.get(oe.key)??0)>0);return fe.length<2?[]:[{key:"",label:`${u.catalog.all} ${ce}`},...fe.map(oe=>({key:oe.key,label:`${oe.label} ${P.get(oe.key)}`}))]},[B,$.rows,_,u]),xe=g.useMemo(()=>{if(!B||!$.rows.some(we=>we.volumes.length>0))return null;const P=[],fe=$.rows.filter(we=>we.volumes.length>0).map(we=>({k:W(we.id)??"",from:Math.min(...we.volumes),to:Math.max(...we.volumes)})).sort((we,Le)=>we.from-Le.from);for(const we of fe){const Le=we.to-we.from+1,He=P[P.length-1];He&&He.key===we.k?(He.to=Math.max(He.to,we.to),He.n+=Le):P.push({key:we.k,from:we.from,to:we.to,n:Le})}const oe=fe.reduce((we,Le)=>Math.max(we,Le.to),0);return P.length>1&&P.some(we=>we.key)?{segs:P,last:oe}:null},[B,$.rows,_]),K=(We=e.description)==null?void 0:We.text,L=t.jsx(Fn,{kind:p("collectionPage.kind"),title:h(e.title),byline:t.jsx(Fo,{authors:e.authors,onNavigate:o,renderLink:s}),meta:t.jsx(it,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(O=e.publication_info)!=null&&O.year?h(e.publication_info.year):""]}),description:K||(ie=e.history)!=null&&ie.length?t.jsxs(t.Fragment,{children:[K&&t.jsx(Pt,{text:K,style:{fontSize:15,lineHeight:1.85}}),(je=e.history)!=null&&je.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((P,fe)=>t.jsx("li",{children:h(P)},fe))}):null]}):void 0,clampDescription:go(K)||(((ke=e.history)==null?void 0:ke.length)??0)>2?6:void 0,stats:Q,facts:H,foot:t.jsx(Hn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:xe&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:p("collectionPage.dist.head")})}),t.jsx("div",{className:"bim-d-dist-bar",role:"group","aria-label":p("collectionPage.dist.head"),children:xe.segs.map((P,fe)=>{const oe=Mn.find(we=>we.key===P.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!oe,title:oe?p("collectionPage.dist.segTitle",{section:h(oe.label),from:P.from,to:P.to}):void 0,"aria-label":oe?p("collectionPage.dist.only",{section:h(oe.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!oe&&b===P.key,style:{flexGrow:P.n,background:r(oe?oe.token:"rule")},onClick:()=>{oe&&(w(b===P.key?"":P.key),v(!1))}},fe)})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:p("catalog.volume",{n:1})}),t.jsx("span",{children:p("collectionPage.dist.hint")}),t.jsx("span",{children:p("catalog.volume",{n:xe.last})})]})]})}),q=[];$.rows.length&&q.push({id:"titles",label:p("collectionPage.sec.titles"),count:ce}),se&&q.push({id:"resources",label:p("collectionPage.sec.resources"),count:se}),he&&q.push({id:"works",label:u.section.containedWorks,count:D.length});const ae=t.jsxs(t.Fragment,{children:[$.rows.length>0&&t.jsxs(rt,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(it,{items:[`${ce} ${u.unit.items}`,$.totalVolumes?p("collectionPage.totalVolumes",{n:$.totalVolumes,unit:u.unit.volume}):"",N.length!==ce?p("collectionPage.currentN",{n:N.length,unit:u.unit.items}):""]}),action:a,children:[($.rows.length>Nn||G.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[G.length>0&&t.jsx(Ei,{items:G,value:b,onChange:P=>{w(P),v(!1)}}),z&&$.rows.length>Nn&&!B&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:j,onClick:()=>k(!0),title:p("collectionPage.loadAllTitle",{n:$.rows.length,unit:u.unit.items}),children:p(j?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),$.rows.length>Nn&&t.jsx("input",{type:"search",className:"bim-d-find",value:m,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:P=>{f(P.target.value),v(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Li(N.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[M&&t.jsx("th",{style:{width:"8.5em"},children:p("collectionPage.col.volumes")}),t.jsx("th",{children:p("collectionPage.col.title")}),t.jsx("th",{style:{textAlign:"right"},children:p("collectionPage.col.versions")})]})}),t.jsx("tbody",{children:A.map((P,fe)=>{var Xe;const oe=P.id?_.get(P.id):void 0,we=oe!=null&&oe.title&&P.title===P.id?oe.title:P.title,Le=((oe==null?void 0:oe.authors)||[]).find(I=>I&&I.name),He=[Le?`${Le.dynasty?`〔${h(Le.dynasty)}〕`:""}${h(Le.name)}${Le.role?` ${h(Le.role)}`:""}`:"",oe!=null&&oe.measure?h(oe.measure):"",(Xe=P.subItems)!=null&&Xe.length?P.subItems.map(I=>h(I)).join("、"):"",(oe!=null&&oe.edition||P.edition)&&!Z?h((oe==null?void 0:oe.edition)||P.edition||""):""].filter(Boolean),Ge=Mn.find(I=>I.key===W(P.id)),Ye=P.volumes.length>0?p("collectionPage.volumeRange",{range:Ri(P.volumes,u.unit.volume),unit:u.unit.volume}):P.expected!=null?`${P.found??0}/${P.expected} ${u.unit.volume}`:"";return t.jsxs("tr",{children:[M&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Ye?"":" bim-d-zt-blank"}`,children:[Ge&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:r(Ge.token)}}),Ye||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[P.id?t.jsx(et,{id:P.id,label:h(we),onNavigate:o,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:h(we)}),He.length>0?t.jsx(it,{items:He}):P.id&&!oe&&i?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${oe!=null&&oe.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:oe!=null&&oe.versionCount?p("collectionPage.nZhong",{n:oe.versionCount}):""})]},`${P.id??P.title}-${fe}`)})})]}),A.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!x&&t.jsx(mo,{total:N.length,shown:A.length,unit:u.unit.items,onClick:()=>v(!0)})]}),se>0&&t.jsxs(rt,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:se}),children:[te.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[te.groups.length>0&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:p("collectionPage.text")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:te.text.map((P,fe)=>t.jsx(Ho,{item:P,siblings:te.text},`${P.id||P.url||P.name}-${fe}`))})})]}),t.jsx(md,{groups:te.groups})]}),$.rows.length===0&&se===0&&t.jsx(rt,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),be=he?t.jsx(en,{id:"works",title:u.section.containedWorks,meta:p("collectionPage.nZhong",{n:D.length}),cap:12,items:D.map(P=>t.jsx(et,{id:P.id,label:h(P.title),onNavigate:o,renderLink:s,dense:!0}))}):null,X=y?t.jsx(lc,{caption:p("collectionPage.parent"),children:t.jsx(et,{id:y.id,label:h(y.title||y.id),onNavigate:o,renderLink:s,dense:!0})}):void 0;return t.jsx(On,{railTop:l,back:d,up:X,nav:q,railLinks:c,main:ae,card:L,side:be})},iy=16,xr=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function Ya(e){if(!e)return xr.length;const n=xr.indexOf(e);return n===-1?xr.length:n}function ry(e,n,i){if(n)return e[n]??i(n)}function oy(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const sy={秦:[-221,-207],西漢:[-202,8],西汉:[-202,8],東漢:[25,220],东汉:[25,220],漢:[-202,220],汉:[-202,220],三國:[220,280],三国:[220,280],西晉:[265,316],西晋:[265,316],東晉:[317,420],东晋:[317,420],隋:[581,618],唐:[618,907],五代:[907,960],北宋:[960,1127],南宋:[1127,1279],宋:[960,1279],遼:[916,1125],辽:[916,1125],金:[1115,1234],元:[1271,1368],明:[1368,1644],清:[1636,1912]},jd=({data:e,transport:n,onNavigate:i,renderLink:o,railTop:s,back:a,railLinks:l})=>{var be,X,re,Ce,We;const{t:d,convert:c,messages:p}=ne(),h=O=>oy(O,d),[u,m]=g.useState("全部"),[f,x]=g.useState(!1),[v,y]=g.useState("default"),[S,b]=g.useState(new Map),w=g.useMemo(()=>e._works||[],[e._works]),j=g.useMemo(()=>w.map(O=>{const ie=S.get(O.work_id);return{id:O.work_id,title:(ie==null?void 0:ie.title)??O.title??O.work_id,role:O.role||"",cls:lo(O.role),versionCount:ie==null?void 0:ie.versionCount,section:ie==null?void 0:ie.cls,l1:ie==null?void 0:ie.l1,measure:ie==null?void 0:ie.measure,hasImage:ie==null?void 0:ie.hasImage,loaded:!!(ie!=null&&ie.loaded)}}),[w,S]),k=g.useMemo(()=>Ql(w.map(O=>O.role),d("detail.roleAll")),[w,d]),$=g.useMemo(()=>{const O=u==="全部"?j:j.filter(ie=>ie.cls===u);return v==="versions"?[...O].sort((ie,je)=>(je.versionCount??-1)-(ie.versionCount??-1)):O},[j,u,v]),C=f?$:$.slice(0,iy),_=g.useMemo(()=>C.filter(O=>!S.has(O.id)).map(O=>O.id),[C,S]);g.useEffect(()=>{if(!n||_.length===0)return;let O=!1;return Pi(_,Mi,ie=>n.getItem(ie).then(je=>{var we;const ke=je??{},P=ke._edition_count??((we=ke._books)==null?void 0:we.length)??0,fe=uo(ke),oe=[fe==null?void 0:fe.l1,fe==null?void 0:fe.l2].filter(Boolean).join(" ");return[ie,{id:ie,title:ke.title,versionCount:P,loaded:!0,cls:oe||void 0,l1:(fe==null?void 0:fe.l1)||void 0,measure:je&&Bt(je,p.unit.juan)||void 0,hasImage:!!ke._has_image}]}).catch(()=>[ie,{id:ie,loaded:!0}]),()=>O).then(ie=>{O||b(je=>{const ke=new Map(je);for(const[P,fe]of ie)ke.set(P,fe);return ke})}),()=>{O=!0}},[n,_,p.unit.juan]);const E=g.useMemo(()=>{const O=new Map;for(const ie of e.alt_names||[]){const je=ie.type||p.section.aliases;O.has(je)||O.set(je,[]),O.get(je).push(ie.name)}return[...O.entries()].sort((ie,je)=>Ya(ie[0])-Ya(je[0])).map(([ie,je])=>({label:ie,names:je}))},[e.alt_names,p]),z=e.birth_year??((be=e.dates)==null?void 0:be.birth)??void 0,T=e.death_year??((X=e.dates)==null?void 0:X.death)??void 0,B=(re=e.dates)==null?void 0:re.floruit,W=z!=null||T!=null?`${h(z)||"?"}—${h(T)||"?"}`:Array.isArray(B)&&B.length===2&&B.every(O=>Number.isFinite(O))?d("entityPage.floruit",{from:h(B[0]),to:h(B[1])}):"",N=new Set(["本名","字","號","号"]),A=E.filter(O=>N.has(O.label)),F=E.filter(O=>!N.has(O.label)),Y=F.reduce((O,ie)=>O+ie.names.length,0),te=g.useMemo(()=>{const O=[];for(const je of A)O.push({label:je.label,value:je.names.map(ke=>c(ke)).join("、")});const ie=w.length;return ie&&O.push({label:d("entityPage.fact.works"),value:d("entityPage.nZhong",{n:ie})}),O},[w,A,c,d]),se=O=>{var ie;return(ie=E.find(je=>O.includes(je.label)))==null?void 0:ie.names[0]},D=se(["字"]),V=se(["號","号"]),he=[D?d("entityPage.zi",{name:c(D)}):"",V?d("entityPage.hao",{name:c(V)}):""].filter(Boolean).join(","),Z=e.native_place,M=e.dynasty?sy[e.dynasty]:void 0,_e=(()=>{if(!M||z==null||T==null||T<z)return null;const[O,ie]=M,je=Math.max(z,O),ke=Math.min(T,ie);if(ke<=je)return null;const P=ie-O;return t.jsxs("div",{className:"bim-d-life bim-d-ui",children:[t.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":d("entityPage.lifeAria",{birth:h(z),death:h(T),years:T-z+1}),children:t.jsx("i",{style:{left:`${(je-O)/P*100}%`,width:`${(ke-je)/P*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${h(O)} ${c(e.dynasty)}`}),t.jsx("span",{children:d("entityPage.lifeYears",{years:T-z+1})}),t.jsx("span",{children:h(ie)})]})]})})(),ce=g.useMemo(()=>{if(!n||j.length===0||j.some(je=>!je.loaded))return null;const O=new Map;for(const je of j){const ke=Fr(je.l1);ke&&O.set(ke,(O.get(ke)??0)+1)}const ie=Mn.map(je=>({...je,n:O.get(je.key)??0})).filter(je=>je.n>0);return ie.length?ie:null},[j,n]),ge=t.jsxs(Fn,{kind:ry(p.entityPage.subtype,e.subtype,c),title:c(e.primary_name||e.title),subtitle:he||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(it,{items:[e.dynasty?c(e.dynasty):"",W,Z?d("entityPage.nativePlace",{place:c(Z)}):""]}),_e]}),description:(Ce=e.description)!=null&&Ce.text?t.jsx(Pt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:go((We=e.description)==null?void 0:We.text)?6:void 0,facts:te,foot:t.jsx(Hn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[Y>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:d("entityPage.moreNames",{n:Y})}),t.jsx("dl",{children:F.map(O=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:c(O.label)}),t.jsx("dd",{children:O.names.map(ie=>c(ie)).join("、")})]},O.label))})]}),ce&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:d("entityPage.dist")})}),t.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:ce.map(O=>t.jsx("i",{style:{flexGrow:O.n,background:r(O.token)}},O.key))}),t.jsx("div",{className:"bim-d-dist-key",children:ce.map(O=>t.jsxs("span",{children:[t.jsx("i",{style:{background:r(O.token)}}),c(O.label)," ",O.n]},O.key))})]})]}),le=g.useMemo(()=>j.filter(O=>O.loaded&&(O.versionCount??0)>0).sort((O,ie)=>(ie.versionCount??0)-(O.versionCount??0)).slice(0,3),[j]),Be=!!n&&j.length>=3&&C.some(O=>!O.loaded),ze=u==="全部"&&(Be||le.length>=2),Fe=e.external_ids||{},Q=[];Fe.cbdb_id!=null&&Q.push({label:"CBDB",id:String(Fe.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${Fe.cbdb_id}`,note:Fe.cbdb_match==="auto"?d("entityPage.autoMatch"):void 0});const H=Fe.wikidata_id;H&&Q.push({label:"Wikidata",id:H,href:`https://www.wikidata.org/wiki/${H}`});const G=Fe.viaf_id;G&&Q.push({label:"VIAF",id:G,href:`https://viaf.org/viaf/${G}`});const xe=k.map(O=>({key:O.cls,label:`${O.label} ${O.count}`})),K=[...ze&&!Be?[{id:"featured",label:d("entityPage.sec.featured"),count:le.length}]:[],...j.length?[{id:"works",label:d("entityPage.sec.allWorks"),count:j.length}]:[],...Q.length?[{id:"external",label:d("entityPage.sec.external"),count:Q.length}]:[]],L=ze?t.jsxs(rt,{id:"featured",title:d("entityPage.sec.featured"),children:[t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:d("entityPage.featuredSub")}),t.jsxs("div",{className:"bim-d-picks","aria-busy":Be||void 0,children:[Be&&[0,1,2].map(O=>t.jsxs("div",{className:"bim-d-pick","aria-hidden":"true",children:[t.jsx("span",{className:"bim-d-pick-t",children:" "}),t.jsx("span",{className:"bim-d-meta",children:" "}),t.jsx("div",{className:"bim-d-pick-n",children:" "})]},O)),!Be&&le.map(O=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(et,{id:O.id,label:c(O.title),onNavigate:i,renderLink:o,dense:!0})}),t.jsx(it,{items:[O.section?c(O.section):"",O.measure?c(O.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:O.versionCount}),t.jsx("span",{children:d("entityPage.versionsUnit")}),O.hasImage&&t.jsx("span",{className:"bim-d-flag",children:d("entityPage.hasImage")})]})]},O.id))]})]}):null,q=j.length===0?t.jsx(rt,{title:d("entityPage.sec.works"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:d("entityPage.empty")})}):t.jsxs(t.Fragment,{children:[L,t.jsxs(rt,{id:"works",title:d("entityPage.sec.works"),meta:t.jsx(it,{items:[d("entityPage.total",{n:j.length}),$.length!==j.length?d("entityPage.current",{n:$.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[xe.length>1&&t.jsx(Ei,{items:xe,value:u,onChange:O=>{m(O),x(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":v==="versions",onClick:()=>{v==="default"&&x(!0),y(O=>O==="default"?"versions":"default")},children:d(v==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!f&&Li($.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:d("entityPage.col.work")}),t.jsx("th",{children:d("entityPage.col.section")}),t.jsx("th",{children:d("entityPage.col.role")}),t.jsx("th",{children:d("entityPage.col.versions")}),t.jsx("th",{"aria-label":d("entityPage.col.image")})]})}),t.jsx("tbody",{children:C.map(O=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(et,{id:O.id,label:c(O.title),onNavigate:i,renderLink:o,dense:!0}),O.measure?t.jsx(it,{items:[c(O.measure)]}):!O.loaded&&n?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${O.section||O.loaded?"":" bim-d-zt-blank"}`,children:O.section?c(O.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${O.role?"":" bim-d-zt-blank"}`,children:O.role?c(O.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${O.loaded?"":" bim-d-zt-blank"}`,children:O.loaded?O.versionCount?d("entityPage.nZhong",{n:O.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:d("entityPage.notRecorded")}):""}),t.jsx("td",{className:O.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:O.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:d("entityPage.hasImage")})})]},O.id))})]}),C.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:d("entityPage.emptyRole")}),!f&&t.jsx(mo,{total:$.length,shown:C.length,unit:d("entityPage.moreUnit"),onClick:()=>x(!0)})]})]}),ae=Q.length>0?t.jsx(en,{id:"external",title:d("entityPage.sec.external"),items:Q.map(O=>t.jsxs("a",{href:O.href,target:"_blank",rel:"noopener noreferrer",children:[O.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:Q.map(O=>O.id),foot:Fe.cbdb_id!=null&&Fe.cbdb_match==="auto"?d("entityPage.cbdbAuto"):void 0}):null;return t.jsx(On,{railTop:s,back:a,nav:K,railLinks:l,main:q,card:ge,side:ae})},Uo="(max-width: 719px)",ay=`${Uo}, (pointer: coarse)`,vd=`
|
|
1354
1354
|
.bim-ct {
|
|
1355
1355
|
display: grid; grid-template-columns: 248px minmax(0, 1fr); column-gap: 32px; align-items: start;
|
|
1356
1356
|
max-width: 1440px; margin: 0 auto; padding: 20px 32px 48px; box-sizing: border-box;
|
|
@@ -1483,7 +1483,7 @@ ${L??""}`,[Vi,Qo]=g.useState({key:ot,data:U,started:!!U});if(Vi.key!==ot)Qo({key
|
|
|
1483
1483
|
}
|
|
1484
1484
|
|
|
1485
1485
|
/* 点击目标 ≥44px(Q5):触屏与窄屏 */
|
|
1486
|
-
@media ${
|
|
1486
|
+
@media ${ay} {
|
|
1487
1487
|
.bim-ct-row { min-height: 44px; }
|
|
1488
1488
|
.bim-ct-tw { width: 44px; }
|
|
1489
1489
|
.bim-ct-pg { min-width: 44px; height: 44px; }
|
|
@@ -1509,7 +1509,7 @@ ${L??""}`,[Vi,Qo]=g.useState({key:ot,data:U,started:!!U});if(Vi.key!==ot)Qo({key
|
|
|
1509
1509
|
/* 窄屏分类抽屉:界栏下按钮和面板都有框 */
|
|
1510
1510
|
:root[data-layout="boxed"] .bim-ct-drawer-btn { border: ${r("fr-bd")}; background: ${r("fr-bg")}; }
|
|
1511
1511
|
:root[data-layout="boxed"] .bim-ct-drawer { border: ${r("fr-bd")}; }
|
|
1512
|
-
`,Qt="未分類",Lt="all",Vo=20;function Un(e){if(!e)return[];const n=[];for(const i of[e.l1,e.l2,e.l3,e.l4]){const o=(i??"").trim();if(!o)break;n.push(o)}return n}function sy(e){const n=Un(e);return n.length?n.join("/"):Qt}function ay(e){const n=Un(e);return n.length?n.map((i,o)=>n.slice(0,o+1).join("/")):[Qt]}function ly(e,n=[]){const i=new Map;n.forEach((d,c)=>{const p=[d.cata_l1,d.cata_l2,d.cata_l3,d.cata_l4].filter(h=>!!h);p.forEach((h,u)=>{const m=p.slice(0,u+1).join("/");i.has(m)||i.set(m,c)})});const o=new Map;let s=0;for(const d of e){const c=Un(d.classification);if(!c.length){s++;continue}let p=o;c.forEach((h,u)=>{const m=c.slice(0,u+1).join("/");let f=p.get(h);f||(f={id:m,label:h,count:0,children:new Map},p.set(h,f)),f.count++,p=f.children})}const a=d=>[...d.values()].sort((c,p)=>{const h=c.label===Qt?1:0,u=p.label===Qt?1:0;if(h!==u)return h-u;const m=i.get(c.id)??1/0,f=i.get(p.id)??1/0;return m!==f?m-f:c.label.localeCompare(p.label,"zh")}).map(c=>{const p={id:c.id,label:c.label,count:c.count};return c.children.size&&(p.children=a(c.children)),p}),l=a(o);return s>0&&l.push({id:Qt,label:Qt,count:s}),l}function pn(e,n){if(!n)return[];for(const i of e){if(i.id===n)return[i];if(i.children){const o=pn(i.children,n);if(o.length)return[i,...o]}}return[]}function Go(e){return e.reduce((n,i)=>n+i.count,0)}function cy(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function dy(e){var d;const n={id:e.id,title:e.title||e.id},i=e.juan_count,o=typeof i=="number"?i:i==null?void 0:i.number;typeof o=="number"&&o>0?n.juan=o:e.measure_info&&(n.juan=e.measure_info);const s=(e.authors??[]).filter(c=>c==null?void 0:c.name).map(c=>{const p=c.dynasty||(e.authors.length===1?e.dynasty:void 0);return p?{name:c.name,dynasty:p}:{name:c.name}});s.length&&(n.authors=s);const a=cy(typeof e.description=="string"?e.description:(d=e.description)==null?void 0:d.text);a&&(n.summary=a);const l=Un(e.classification);return l.length&&(n.classification=l),n}function py(e,n){const i=e.summary?0:1,o=n.summary?0:1;return i!==o?i-o:e.title.localeCompare(n.title,"zh")}function uy(e,n=Vo){return Math.max(1,Math.ceil(e/n))}function vd(e,n,i=2){if(n<=1)return[1];const o=new Set([1,n]);for(let l=e-i;l<=e+i;l++)l>=1&&l<=n&&o.add(l);const s=[...o].sort((l,d)=>l-d),a=[];return s.forEach((l,d)=>{if(d>0){const c=l-s[d-1];c===2?a.push(l-1):c>2&&a.push(null)}a.push(l)}),a}const my=()=>t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:t.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function hy(e,n,i){const o=[];i&&o.push({id:Lt,parentId:null,hasChildren:!1,firstChildId:null});const s=(a,l)=>{var d;for(const c of a){const p=(d=c.children)!=null&&d.length?c.children:null;o.push({id:c.id,parentId:l,hasChildren:!!p,firstChildId:p?p[0].id:null}),p&&n.has(c.id)&&s(p,c.id)}};return s(e,null),o}function kd({tree:e,selectedId:n,onSelect:i,allLabel:o,label:s}){const{t:a,convert:l}=ne(),d=o===void 0?a("catalogPage.all"):o,c=s??a("catalogPage.classification"),p=g.useRef(null),h=n&&n!==Lt?n:null,u=d!==null,[m,f]=g.useState(()=>{const _=new Set;for(const E of pn(e,h))_.add(E.id);return _});g.useEffect(()=>{const _=pn(e,h);_.length&&f(E=>{if(_.every(T=>E.has(T.id)))return E;const z=new Set(E);for(const T of _)z.add(T.id);return z})},[e,h]);const x=g.useMemo(()=>hy(e,m,u),[e,m,u]),[v,y]=g.useState(null);g.useEffect(()=>{y(null)},[n]);const S=h??(u?Lt:null),b=g.useMemo(()=>{var z;const _=new Set(x.map(T=>T.id));if(v&&_.has(v))return v;if(S&&_.has(S))return S;const E=pn(e,h).map(T=>T.id).filter(T=>_.has(T));return E.length?E[E.length-1]:((z=x[0])==null?void 0:z.id)??null},[x,v,S,e,h]),w=g.useCallback((_,E)=>{f(z=>{const T=z.has(_),B=E??!T;if(B===T)return z;const W=new Set(z);return B?W.add(_):W.delete(_),W})},[]),j=g.useCallback(_=>{y(_),requestAnimationFrame(()=>{var z;const E=Array.from(((z=p.current)==null?void 0:z.querySelectorAll("[data-ct-id]"))??[]).find(T=>T.dataset.ctId===_);E==null||E.focus()})},[]),k=g.useCallback((_,E)=>{E&&w(_,!0),i(_)},[i,w]),$=g.useCallback(_=>{const E=_.target.closest("[data-ct-id]");if(!E)return;const z=E.dataset.ctId,T=x.findIndex(N=>N.id===z);if(T<0)return;const B=x[T];let W=null;switch(_.key){case"ArrowDown":W=x[Math.min(x.length-1,T+1)].id;break;case"ArrowUp":W=x[Math.max(0,T-1)].id;break;case"Home":W=x[0].id;break;case"End":W=x[x.length-1].id;break;case"ArrowRight":if(!B.hasChildren)break;m.has(z)?W=B.firstChildId:w(z,!0);break;case"ArrowLeft":B.hasChildren&&m.has(z)?w(z,!1):W=B.parentId;break;case"Enter":case" ":_.preventDefault(),k(z,B.hasChildren);return;default:return}_.preventDefault(),W&&W!==z&&j(W)},[x,m,w,j,k]),C=(_,E)=>_.map((z,T)=>{var F;const B=(F=z.children)!=null&&F.length?z.children:null,W=!!B&&m.has(z.id),N=z.id===h,A=E===1&&_.length>1&&T===_.length-1;return t.jsxs("li",{role:"treeitem","aria-level":E,"aria-expanded":B?W:void 0,"aria-selected":N,tabIndex:b===z.id?0:-1,"data-ct-id":z.id,className:A?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":E-1},onClick:()=>{y(z.id),k(z.id,!!B)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:B?Y=>{Y.stopPropagation(),y(z.id),w(z.id)}:void 0,children:B?t.jsx(my,{}):null}),t.jsx("span",{className:"bim-ct-lb",children:l(z.label)}),t.jsx("span",{className:"bim-ct-n",children:z.count.toLocaleString("en-US")})]}),W&&t.jsx("ul",{role:"group",children:C(B,E+1)})]},z.id)});return t.jsxs("ul",{ref:p,role:"tree","aria-label":l(c),className:"bim-ct-tree",onKeyDown:$,children:[u&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!h,tabIndex:b===Lt?0:-1,"data-ct-id":Lt,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(Lt),i(Lt)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true"}),t.jsx("span",{className:"bim-ct-lb",children:l(d)}),t.jsx("span",{className:"bim-ct-n",children:Go(e).toLocaleString("en-US")})]})}),C(e,1)]})}const wd=e=>`/item/${encodeURIComponent(e)}`;function gy(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function Sd(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function _d({work:e,href:n}){var d,c;const{t:i,convert:o}=ne(),s=Sd(e.juan,i),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-card",children:t.jsxs("a",{href:n,children:[t.jsxs("div",{className:"bim-ct-ch",children:[t.jsx("h2",{className:"bim-ct-ct",children:o(e.title)}),s&&t.jsx("span",{className:"bim-ct-juan",children:o(s)})]}),a.length>0&&t.jsx("span",{className:"bim-ct-by",children:a.map((p,h)=>t.jsxs(g.Fragment,{children:[h>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},h))}),e.summary&&t.jsx("p",{className:"bim-ct-sum",children:o(e.summary)}),l.length>0&&t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function $d({work:e,href:n}){var d,c;const{t:i,convert:o}=ne(),s=Sd(e.juan,i),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-lrow",children:t.jsxs("a",{href:n,children:[t.jsxs("span",{className:"bim-ct-lt",children:[o(e.title),s&&t.jsx("span",{className:"bim-ct-juan",children:o(s)})]}),t.jsx("span",{className:"bim-ct-by",children:a.map((p,h)=>t.jsxs(g.Fragment,{children:[h>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},h))}),t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function Cd({page:e,pageCount:n,onPage:i,pageHref:o,label:s}){const{t:a,convert:l}=ne();if(n<=1)return null;const d=p=>h=>{i&&(o&&!gy(h)||(h.preventDefault(),i(p)))},c=(p,h,u)=>{if(u.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:h});const m={className:"bim-ct-pg","aria-current":u.current?"page":void 0,"aria-label":u.aria};return o?t.jsx("a",{...m,href:o(p),onClick:d(p),children:h}):t.jsx("button",{type:"button",...m,onClick:u.current?void 0:d(p),children:h})};return t.jsxs("nav",{className:"bim-ct-pager","aria-label":s?l(s):a("catalogPage.pagerLabel"),children:[c(e-1,a("catalogPage.prevPage"),{disabled:e<=1}),t.jsx("ol",{children:vd(e,n).map((p,h)=>t.jsx("li",{style:{display:"contents"},children:p===null?t.jsx("span",{className:"bim-ct-gap","aria-hidden":"true",children:"…"}):c(p,p,{current:p===e,aria:a("catalogPage.pageN",{n:p})})},p??`gap${h}`))}),t.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[e," / ",n]}),c(e+1,a("catalogPage.nextPage"),{disabled:e>=n})]})}function Td({works:e,workLink:n=wd,emptyText:i,view:o="card",...s}){const{t:a,convert:l}=ne();return t.jsxs("div",{className:"bim-ct-works",children:[e.length===0?t.jsx("p",{className:"bim-ct-empty",children:i===void 0?a("catalogPage.emptyWorks"):typeof i=="string"?l(i):i}):o==="list"?t.jsx("ul",{className:"bim-ct-list",children:e.map(d=>t.jsx($d,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(_d,{work:d,href:n(d.id)},d.id))}),t.jsx(Cd,{...s})]})}const fy=()=>t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:t.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function xy({tree:e,selectedId:n,page:i,pageCount:o,works:s,onSelect:a,onPage:l,searchSlot:d,workLink:c,pageHref:p,allLabel:h,allTitle:u,pageSize:m=Vo,className:f,view:x,onViewChange:v}){const{t:y,convert:S}=ne(),b=h===void 0?y("catalogPage.all"):h,w=u??y("catalogPage.allTitle"),k=`bim-ct-drawer-${g.useId().replace(/:/g,"")}`,[$,C]=g.useState(!1),[_,E]=g.useState("card"),z=x??_,T=Y=>{E(Y),v==null||v(Y)},B=pn(e,n&&n!==Lt?n:null),W=B.length?B[B.length-1]:null,N=W?W.label:w,A=W?W.count:Go(e),F=g.useCallback(Y=>{C(!1),a(Y)},[a]);return t.jsxs("div",{className:f?`bim-ct ${f}`:"bim-ct","data-drawer":$?"open":"closed",children:[t.jsx("style",{children:jd}),t.jsxs("aside",{className:"bim-ct-side","aria-label":y("catalogPage.sideNav"),children:[t.jsxs("button",{type:"button",className:"bim-ct-drawer-btn","aria-expanded":$,"aria-controls":k,onClick:()=>C(Y=>!Y),children:[t.jsx("span",{children:y("catalogPage.drawerLabel",{path:S(B.length?B.map(Y=>Y.label).join(" › "):b??w)})}),t.jsx(fy,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:k,children:[t.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),t.jsx(kd,{tree:e,selectedId:n,onSelect:F,allLabel:b})]})]}),t.jsxs("div",{className:"bim-ct-main",children:[t.jsxs("header",{className:"bim-ct-head",children:[t.jsx("h1",{className:"bim-ct-title",children:S(N)}),B.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:S(B.slice(0,-1).map(Y=>Y.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:A.toLocaleString("en-US"),size:m}),o>1&&y("catalogPage.statPage",{page:i,pages:o})]}),t.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":y("catalogPage.viewLabel"),children:[t.jsx("button",{type:"button","aria-pressed":z==="card",onClick:()=>T("card"),children:y("catalogPage.viewCard")}),t.jsx("button",{type:"button","aria-pressed":z==="list",onClick:()=>T("list"),children:y("catalogPage.viewList")})]})]}),d&&t.jsx("div",{className:"bim-ct-search",children:d}),t.jsx(Td,{works:s,view:z,workLink:c,page:i,pageCount:o,onPage:l,pageHref:p})]})]})}const Vn="(max-width: 719px)",by="(max-width: 1079px)",yy=`${Vn}, (pointer: coarse)`,jy=[8,18,30,42,88],Yo=`
|
|
1512
|
+
`,Qt="未分類",Lt="all",Vo=20;function Un(e){if(!e)return[];const n=[];for(const i of[e.l1,e.l2,e.l3,e.l4]){const o=(i??"").trim();if(!o)break;n.push(o)}return n}function ly(e){const n=Un(e);return n.length?n.join("/"):Qt}function cy(e){const n=Un(e);return n.length?n.map((i,o)=>n.slice(0,o+1).join("/")):[Qt]}function dy(e,n=[]){const i=new Map;n.forEach((d,c)=>{const p=[d.cata_l1,d.cata_l2,d.cata_l3,d.cata_l4].filter(h=>!!h);p.forEach((h,u)=>{const m=p.slice(0,u+1).join("/");i.has(m)||i.set(m,c)})});const o=new Map;let s=0;for(const d of e){const c=Un(d.classification);if(!c.length){s++;continue}let p=o;c.forEach((h,u)=>{const m=c.slice(0,u+1).join("/");let f=p.get(h);f||(f={id:m,label:h,count:0,children:new Map},p.set(h,f)),f.count++,p=f.children})}const a=d=>[...d.values()].sort((c,p)=>{const h=c.label===Qt?1:0,u=p.label===Qt?1:0;if(h!==u)return h-u;const m=i.get(c.id)??1/0,f=i.get(p.id)??1/0;return m!==f?m-f:c.label.localeCompare(p.label,"zh")}).map(c=>{const p={id:c.id,label:c.label,count:c.count};return c.children.size&&(p.children=a(c.children)),p}),l=a(o);return s>0&&l.push({id:Qt,label:Qt,count:s}),l}function pn(e,n){if(!n)return[];for(const i of e){if(i.id===n)return[i];if(i.children){const o=pn(i.children,n);if(o.length)return[i,...o]}}return[]}function Go(e){return e.reduce((n,i)=>n+i.count,0)}function py(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function uy(e){var d;const n={id:e.id,title:e.title||e.id},i=e.juan_count,o=typeof i=="number"?i:i==null?void 0:i.number;typeof o=="number"&&o>0?n.juan=o:e.measure_info&&(n.juan=e.measure_info);const s=(e.authors??[]).filter(c=>c==null?void 0:c.name).map(c=>{const p=c.dynasty||(e.authors.length===1?e.dynasty:void 0);return p?{name:c.name,dynasty:p}:{name:c.name}});s.length&&(n.authors=s);const a=py(typeof e.description=="string"?e.description:(d=e.description)==null?void 0:d.text);a&&(n.summary=a);const l=Un(e.classification);return l.length&&(n.classification=l),n}function my(e,n){const i=e.summary?0:1,o=n.summary?0:1;return i!==o?i-o:e.title.localeCompare(n.title,"zh")}function hy(e,n=Vo){return Math.max(1,Math.ceil(e/n))}function kd(e,n,i=2){if(n<=1)return[1];const o=new Set([1,n]);for(let l=e-i;l<=e+i;l++)l>=1&&l<=n&&o.add(l);const s=[...o].sort((l,d)=>l-d),a=[];return s.forEach((l,d)=>{if(d>0){const c=l-s[d-1];c===2?a.push(l-1):c>2&&a.push(null)}a.push(l)}),a}const gy=()=>t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:t.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function fy(e,n,i){const o=[];i&&o.push({id:Lt,parentId:null,hasChildren:!1,firstChildId:null});const s=(a,l)=>{var d;for(const c of a){const p=(d=c.children)!=null&&d.length?c.children:null;o.push({id:c.id,parentId:l,hasChildren:!!p,firstChildId:p?p[0].id:null}),p&&n.has(c.id)&&s(p,c.id)}};return s(e,null),o}function wd({tree:e,selectedId:n,onSelect:i,allLabel:o,label:s}){const{t:a,convert:l}=ne(),d=o===void 0?a("catalogPage.all"):o,c=s??a("catalogPage.classification"),p=g.useRef(null),h=n&&n!==Lt?n:null,u=d!==null,[m,f]=g.useState(()=>{const _=new Set;for(const E of pn(e,h))_.add(E.id);return _});g.useEffect(()=>{const _=pn(e,h);_.length&&f(E=>{if(_.every(T=>E.has(T.id)))return E;const z=new Set(E);for(const T of _)z.add(T.id);return z})},[e,h]);const x=g.useMemo(()=>fy(e,m,u),[e,m,u]),[v,y]=g.useState(null);g.useEffect(()=>{y(null)},[n]);const S=h??(u?Lt:null),b=g.useMemo(()=>{var z;const _=new Set(x.map(T=>T.id));if(v&&_.has(v))return v;if(S&&_.has(S))return S;const E=pn(e,h).map(T=>T.id).filter(T=>_.has(T));return E.length?E[E.length-1]:((z=x[0])==null?void 0:z.id)??null},[x,v,S,e,h]),w=g.useCallback((_,E)=>{f(z=>{const T=z.has(_),B=E??!T;if(B===T)return z;const W=new Set(z);return B?W.add(_):W.delete(_),W})},[]),j=g.useCallback(_=>{y(_),requestAnimationFrame(()=>{var z;const E=Array.from(((z=p.current)==null?void 0:z.querySelectorAll("[data-ct-id]"))??[]).find(T=>T.dataset.ctId===_);E==null||E.focus()})},[]),k=g.useCallback((_,E)=>{E&&w(_,!0),i(_)},[i,w]),$=g.useCallback(_=>{const E=_.target.closest("[data-ct-id]");if(!E)return;const z=E.dataset.ctId,T=x.findIndex(N=>N.id===z);if(T<0)return;const B=x[T];let W=null;switch(_.key){case"ArrowDown":W=x[Math.min(x.length-1,T+1)].id;break;case"ArrowUp":W=x[Math.max(0,T-1)].id;break;case"Home":W=x[0].id;break;case"End":W=x[x.length-1].id;break;case"ArrowRight":if(!B.hasChildren)break;m.has(z)?W=B.firstChildId:w(z,!0);break;case"ArrowLeft":B.hasChildren&&m.has(z)?w(z,!1):W=B.parentId;break;case"Enter":case" ":_.preventDefault(),k(z,B.hasChildren);return;default:return}_.preventDefault(),W&&W!==z&&j(W)},[x,m,w,j,k]),C=(_,E)=>_.map((z,T)=>{var F;const B=(F=z.children)!=null&&F.length?z.children:null,W=!!B&&m.has(z.id),N=z.id===h,A=E===1&&_.length>1&&T===_.length-1;return t.jsxs("li",{role:"treeitem","aria-level":E,"aria-expanded":B?W:void 0,"aria-selected":N,tabIndex:b===z.id?0:-1,"data-ct-id":z.id,className:A?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":E-1},onClick:()=>{y(z.id),k(z.id,!!B)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:B?Y=>{Y.stopPropagation(),y(z.id),w(z.id)}:void 0,children:B?t.jsx(gy,{}):null}),t.jsx("span",{className:"bim-ct-lb",children:l(z.label)}),t.jsx("span",{className:"bim-ct-n",children:z.count.toLocaleString("en-US")})]}),W&&t.jsx("ul",{role:"group",children:C(B,E+1)})]},z.id)});return t.jsxs("ul",{ref:p,role:"tree","aria-label":l(c),className:"bim-ct-tree",onKeyDown:$,children:[u&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!h,tabIndex:b===Lt?0:-1,"data-ct-id":Lt,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(Lt),i(Lt)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true"}),t.jsx("span",{className:"bim-ct-lb",children:l(d)}),t.jsx("span",{className:"bim-ct-n",children:Go(e).toLocaleString("en-US")})]})}),C(e,1)]})}const Sd=e=>`/item/${encodeURIComponent(e)}`;function xy(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function _d(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function $d({work:e,href:n}){var d,c;const{t:i,convert:o}=ne(),s=_d(e.juan,i),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-card",children:t.jsxs("a",{href:n,children:[t.jsxs("div",{className:"bim-ct-ch",children:[t.jsx("h2",{className:"bim-ct-ct",children:o(e.title)}),s&&t.jsx("span",{className:"bim-ct-juan",children:o(s)})]}),a.length>0&&t.jsx("span",{className:"bim-ct-by",children:a.map((p,h)=>t.jsxs(g.Fragment,{children:[h>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},h))}),e.summary&&t.jsx("p",{className:"bim-ct-sum",children:o(e.summary)}),l.length>0&&t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function Cd({work:e,href:n}){var d,c;const{t:i,convert:o}=ne(),s=_d(e.juan,i),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-lrow",children:t.jsxs("a",{href:n,children:[t.jsxs("span",{className:"bim-ct-lt",children:[o(e.title),s&&t.jsx("span",{className:"bim-ct-juan",children:o(s)})]}),t.jsx("span",{className:"bim-ct-by",children:a.map((p,h)=>t.jsxs(g.Fragment,{children:[h>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},h))}),t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function Td({page:e,pageCount:n,onPage:i,pageHref:o,label:s}){const{t:a,convert:l}=ne();if(n<=1)return null;const d=p=>h=>{i&&(o&&!xy(h)||(h.preventDefault(),i(p)))},c=(p,h,u)=>{if(u.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:h});const m={className:"bim-ct-pg","aria-current":u.current?"page":void 0,"aria-label":u.aria};return o?t.jsx("a",{...m,href:o(p),onClick:d(p),children:h}):t.jsx("button",{type:"button",...m,onClick:u.current?void 0:d(p),children:h})};return t.jsxs("nav",{className:"bim-ct-pager","aria-label":s?l(s):a("catalogPage.pagerLabel"),children:[c(e-1,a("catalogPage.prevPage"),{disabled:e<=1}),t.jsx("ol",{children:kd(e,n).map((p,h)=>t.jsx("li",{style:{display:"contents"},children:p===null?t.jsx("span",{className:"bim-ct-gap","aria-hidden":"true",children:"…"}):c(p,p,{current:p===e,aria:a("catalogPage.pageN",{n:p})})},p??`gap${h}`))}),t.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[e," / ",n]}),c(e+1,a("catalogPage.nextPage"),{disabled:e>=n})]})}function zd({works:e,workLink:n=Sd,emptyText:i,view:o="card",...s}){const{t:a,convert:l}=ne();return t.jsxs("div",{className:"bim-ct-works",children:[e.length===0?t.jsx("p",{className:"bim-ct-empty",children:i===void 0?a("catalogPage.emptyWorks"):typeof i=="string"?l(i):i}):o==="list"?t.jsx("ul",{className:"bim-ct-list",children:e.map(d=>t.jsx(Cd,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx($d,{work:d,href:n(d.id)},d.id))}),t.jsx(Td,{...s})]})}const by=()=>t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:t.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function yy({tree:e,selectedId:n,page:i,pageCount:o,works:s,onSelect:a,onPage:l,searchSlot:d,workLink:c,pageHref:p,allLabel:h,allTitle:u,pageSize:m=Vo,className:f,view:x,onViewChange:v}){const{t:y,convert:S}=ne(),b=h===void 0?y("catalogPage.all"):h,w=u??y("catalogPage.allTitle"),k=`bim-ct-drawer-${g.useId().replace(/:/g,"")}`,[$,C]=g.useState(!1),[_,E]=g.useState("card"),z=x??_,T=Y=>{E(Y),v==null||v(Y)},B=pn(e,n&&n!==Lt?n:null),W=B.length?B[B.length-1]:null,N=W?W.label:w,A=W?W.count:Go(e),F=g.useCallback(Y=>{C(!1),a(Y)},[a]);return t.jsxs("div",{className:f?`bim-ct ${f}`:"bim-ct","data-drawer":$?"open":"closed",children:[t.jsx("style",{children:vd}),t.jsxs("aside",{className:"bim-ct-side","aria-label":y("catalogPage.sideNav"),children:[t.jsxs("button",{type:"button",className:"bim-ct-drawer-btn","aria-expanded":$,"aria-controls":k,onClick:()=>C(Y=>!Y),children:[t.jsx("span",{children:y("catalogPage.drawerLabel",{path:S(B.length?B.map(Y=>Y.label).join(" › "):b??w)})}),t.jsx(by,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:k,children:[t.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),t.jsx(wd,{tree:e,selectedId:n,onSelect:F,allLabel:b})]})]}),t.jsxs("div",{className:"bim-ct-main",children:[t.jsxs("header",{className:"bim-ct-head",children:[t.jsx("h1",{className:"bim-ct-title",children:S(N)}),B.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:S(B.slice(0,-1).map(Y=>Y.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:A.toLocaleString("en-US"),size:m}),o>1&&y("catalogPage.statPage",{page:i,pages:o})]}),t.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":y("catalogPage.viewLabel"),children:[t.jsx("button",{type:"button","aria-pressed":z==="card",onClick:()=>T("card"),children:y("catalogPage.viewCard")}),t.jsx("button",{type:"button","aria-pressed":z==="list",onClick:()=>T("list"),children:y("catalogPage.viewList")})]})]}),d&&t.jsx("div",{className:"bim-ct-search",children:d}),t.jsx(zd,{works:s,view:z,workLink:c,page:i,pageCount:o,onPage:l,pageHref:p})]})]})}const Vn="(max-width: 719px)",jy="(max-width: 1079px)",vy=`${Vn}, (pointer: coarse)`,ky=[8,18,30,42,88],Yo=`
|
|
1513
1513
|
.bim-rh { color: ${r("ink")}; font-family: ${r("font-ui")}; font-size: 14px; line-height: 1.6; }
|
|
1514
1514
|
.bim-rh *, .bim-rh *::before, .bim-rh *::after { box-sizing: border-box; }
|
|
1515
1515
|
.bim-rh a { color: ${r("accent")}; text-decoration: none; }
|
|
@@ -1657,7 +1657,7 @@ ${L??""}`,[Vi,Qo]=g.useState({key:ot,data:U,started:!!U});if(Vi.key!==ot)Qo({key
|
|
|
1657
1657
|
flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 8px; overflow: hidden;
|
|
1658
1658
|
color: ${r("ink")} !important; font-size: 13px;
|
|
1659
1659
|
}
|
|
1660
|
-
${
|
|
1660
|
+
${ky.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb, ${r("accent")} ${e}%, ${r("card-bg")}); }`).join(`
|
|
1661
1661
|
`)}
|
|
1662
1662
|
.bim-rh-band a[data-k="4"] { color: ${r("page-bg")} !important; }
|
|
1663
1663
|
.bim-rh-band a:hover { outline: 2px solid ${r("ink")}; outline-offset: -2px; }
|
|
@@ -1685,7 +1685,7 @@ ${jy.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1685
1685
|
}
|
|
1686
1686
|
|
|
1687
1687
|
/* ── 中屏 ── */
|
|
1688
|
-
@media ${
|
|
1688
|
+
@media ${jy} {
|
|
1689
1689
|
.bim-rh-picks, .bim-rh-works, .bim-rh-groups, .bim-rh-bu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1690
1690
|
.bim-rh-authors { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
1691
1691
|
}
|
|
@@ -1728,7 +1728,7 @@ ${jy.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1728
1728
|
}
|
|
1729
1729
|
|
|
1730
1730
|
/* 触屏或窄屏:点击目标放大到 44px */
|
|
1731
|
-
@media ${
|
|
1731
|
+
@media ${vy} {
|
|
1732
1732
|
.bim-rh-rows a, .bim-rh-bu-l a, .bim-rh-au li a, .bim-rh-chip, .bim-rh-secnav a, .bim-rh-expand { min-height: 44px; display: flex; align-items: center; }
|
|
1733
1733
|
.bim-rh-chip { display: inline-flex; }
|
|
1734
1734
|
}
|
|
@@ -1739,7 +1739,7 @@ ${jy.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1739
1739
|
}
|
|
1740
1740
|
|
|
1741
1741
|
@media (prefers-reduced-motion: reduce) { .bim-rh * { scroll-behavior: auto !important; transition: none !important; } }
|
|
1742
|
-
`,vy=Xr["zh-Hant"].period,zd={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function Vt(e){return{...zd,...e??{}}}function qo(e){var i;const n=(i=e.authors)==null?void 0:i.find(o=>o==null?void 0:o.name);return n?n.dynasty?`${n.dynasty} ${n.name}`:n.name:""}function Wi(e){return(e.authors??[]).filter(i=>i==null?void 0:i.name).map(i=>i.dynasty?`〔${i.dynasty}〕${i.name}`:i.name).join(" ")}function Nd(e,n=Xr["zh-Hant"].shelfOther){var s;const i=[],o=new Map;for(const a of e){const l=((s=a.period_of)==null?void 0:s.trim())||n;let d=o.get(l);d||(d={label:l,items:[]},o.set(l,d),i.push(d)),d.items.push(a)}return i}function Id(e){return Math.max(150,Array.from(e).length*18+44)}function Rd(e,n){if(n<=0||e<=0)return 0;const i=e/n;return i<.15?0:i<.35?1:i<.6?2:i<.85?3:4}const Ed=.04;function Ke(e){return e.toLocaleString("en-US")}function Ld({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,i)=>t.jsx("span",{children:n},i))})}function ct({id:e,title:n,sub:i,more:o,children:s}){const{convert:a}=ne(),l=`${e}-h`;return t.jsxs("section",{className:"bim-rh-sec",id:e,"aria-labelledby":l,children:[t.jsxs("div",{className:"bim-rh-hd",children:[t.jsx("h2",{id:l,children:a(n)}),i&&t.jsx("span",{className:"bim-rh-sub",children:i}),o]}),t.jsx("div",{className:"bim-rh-bd",children:s})]})}function Ad({counts:e}){const{t:n}=ne();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:Ke(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:Ke(e.pieces)}),n("readHome.pieces")]})]})}function Md({picks:e,links:n}){const{t:i,convert:o}=ne(),s=Vt(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=Wi(a),d=[a.type_label,a.edition].filter(Boolean).join(" · ");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-pk",href:s.read(a.id),children:[t.jsx("span",{className:"bim-rh-slip","aria-hidden":"true",children:t.jsx(Ld,{text:o(a.slip||a.title)})}),t.jsxs("span",{className:"bim-rh-pk-body",children:[d&&t.jsx("span",{className:"bim-rh-badge",children:o(d)}),t.jsx("h3",{children:o(a.title)}),l&&t.jsx("span",{className:"bim-rh-by",children:o(l)}),a.blurb&&t.jsx("p",{children:o(a.blurb)}),t.jsx("span",{className:"bim-rh-go","aria-hidden":"true",children:i("readHome.startReading")})]})]})},a.id)})}):null}function Pd(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function Ko({topic:e,links:n,hint:i,legendCount:o,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=ne(),c=Vt(n);if(!e.items.length)return null;const p=o===void 0?l("readHome.shelfLegendCount"):o,h=Nd(e.items,l("readHome.shelfOther")),u=m=>{const f=m.records?Ke(m.records):Pd(m.text_count,l),x=qo(m),v=[d(m.title),m.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",m.records?l("readHome.spineRecords",{n:f}):f?l("readHome.spineOnSite",{n:f}):""].filter(Boolean).join(",");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-spine",href:c.read(m.id),"data-orig":m.orig?"":void 0,"aria-label":v,title:v,style:{height:Id(m.title)},children:[t.jsx(Ld,{text:d(m.title)}),f&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":m.records?"":void 0,children:f})]})},m.id)};return t.jsxs("div",{className:"bim-rh-shelf-box",children:[s&&t.jsxs("h3",{className:"bim-rh-gt",children:[d(e.label),t.jsx("small",{children:i?d(i):l("readHome.shelfHint")})]}),t.jsx("div",{className:"bim-rh-shelf-wrap",tabIndex:0,role:"region","aria-label":l("readHome.shelfRegion",{label:d(e.label)}),children:t.jsx("ul",{className:"bim-rh-shelf",children:h.map(m=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(m.label),children:m.items.map(u)}),t.jsx("span",{"aria-hidden":"true",children:d(m.label)})]},m.label))})}),t.jsxs("p",{className:"bim-rh-legend",children:[t.jsxs("span",{children:[t.jsx("i",{"data-orig":"","aria-hidden":"true"}),l("readHome.origZhi")]}),t.jsxs("span",{children:[t.jsx("i",{"aria-hidden":"true"}),l("readHome.laterZhi")]}),p&&t.jsx("span",{children:d(p)}),a==null?void 0:a.map(m=>t.jsx("span",{children:d(m)},m))]})]})}const ky=4,Bn=e=>e>ky+1;function Bd({topic:e,links:n}){const{t:i,convert:o}=ne(),s=Vt(n),[a,l]=g.useState(!1);if(!e.items.length)return null;const d=`bim-rh-g-${e.key}`;return t.jsxs("div",{className:"bim-rh-grp","data-cap":Bn(e.items.length)?"":void 0,"data-open":a?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",id:d,children:[o(e.label),t.jsx("small",{className:"bim-rh-num",children:i("readHome.nWorks",{n:Ke(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=Pd(c.text_count,i),h=qo(c);return t.jsx("li",{children:t.jsxs("a",{href:s.read(c.id),children:[t.jsx("span",{className:"bim-rh-t",children:o(c.title)}),p&&t.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:p}),h&&t.jsx("small",{children:o(h)})]})},c.id)})}),Bn(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":a,onClick:()=>l(c=>!c),children:a?i("action.collapse"):i("readHome.allNWorks",{n:e.items.length})})]})}function Wd({topics:e,links:n}){const i=e.filter(s=>s.shelf&&s.items.length),o=e.filter(s=>!s.shelf&&s.items.length);return!i.length&&!o.length?null:t.jsxs(t.Fragment,{children:[i.map(s=>t.jsx(Ko,{topic:s,links:n},s.key)),o.length>0&&t.jsx("div",{className:"bim-rh-groups",children:o.map(s=>t.jsx(Bd,{topic:s,links:n},s.key))})]})}function Od({famous:e,links:n}){const{t:i,convert:o}=ne(),s=Vt(n);return e.length?t.jsx("ul",{className:"bim-rh-works",children:e.map(a=>t.jsx("li",{children:t.jsxs("article",{className:"bim-rh-wk",children:[t.jsxs("div",{className:"bim-rh-wk-h",children:[t.jsx("h3",{children:o(a.title)}),a.authors&&t.jsx("span",{className:"bim-rh-by",children:o(a.authors)}),t.jsx("span",{className:"bim-rh-c bim-rh-num",children:i("readHome.nCopiesCard",{n:a.text_count})})]}),a.systems.map((l,d)=>t.jsxs("div",{className:"bim-rh-lin",role:"group","aria-label":l.label?o(l.label):void 0,children:[l.label&&t.jsx("small",{"aria-hidden":"true",children:o(l.label)}),l.items.map(c=>t.jsx("a",{className:"bim-rh-chip",href:s.read(c.id),title:o([c.title,c.edition].filter(Boolean).join(" · ")),children:o(c.short)},c.id))]},d)),a.work_id&&t.jsx("div",{className:"bim-rh-wk-f",children:t.jsx("a",{href:s.work(a.work_id),children:i("readHome.workPageLink",{title:o(a.title)})})})]})},a.work_id??a.title))}):null}function Xo({bu:e,unclassified:n,links:i,unclassifiedNote:o}){const{t:s,convert:a}=ne(),l=Vt(i);return!e.length&&!n?null:t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-bu",children:e.map(d=>{var p;const c=((p=d.top[0])==null?void 0:p.count)||1;return t.jsxs("li",{className:"bim-rh-bu-c",children:[t.jsxs("a",{className:"bim-rh-bu-h",href:l.node(d.id),children:[t.jsx("b",{children:a(d.label)}),t.jsx("span",{className:"bim-rh-num",children:s("readHome.nWorks",{n:Ke(d.count)})})]}),d.top.length>0&&t.jsx("ul",{className:"bim-rh-bu-l","aria-label":s("readHome.subClasses",{label:a(d.label)}),children:d.top.map(h=>t.jsx("li",{children:t.jsxs("a",{href:l.node(h.id),children:[t.jsx("span",{children:a(h.label)}),t.jsx("small",{className:"bim-rh-num",children:Ke(h.count)}),t.jsx("span",{className:"bim-rh-bar","aria-hidden":"true",style:{"--bimrh-w":`${Math.round(h.count/c*100)}%`}})]})},h.id))}),d.children_total>d.top.length&&t.jsx("a",{className:"bim-rh-bu-more",href:l.node(d.id),children:s("readHome.allNClasses",{label:a(d.label),n:d.children_total})})]},d.id)})}),!!n&&t.jsxs("p",{className:"bim-rh-uncl bim-rh-num",children:[t.jsx("b",{children:s("readHome.unclassified")}),t.jsx("span",{children:s("readHome.nWorks",{n:Ke(n)})}),t.jsx("span",{children:o?a(o):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function Fd({periods:e,unknown:n,links:i}){const{t:o,convert:s,messages:a}=ne(),l=a.readHome.period,d=Vt(i),c=e.filter(u=>u.count>0);if(!c.length)return null;const p=c.reduce((u,m)=>u+m.count,0),h=Math.max(...c.map(u=>u.count));return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-band",children:c.map(u=>{const m=u.label?s(u.label):l[u.key]??s(u.key),f=u.count/p,x=o("readHome.periodItem",{label:m,n:Ke(u.count)});return t.jsx("li",{style:{flex:`0 0 ${(f*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(u.key),"data-k":Rd(u.count,h),"data-narrow":f<Ed?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:m}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(m)[0]}),t.jsx("small",{className:"bim-rh-num",children:Ke(u.count)})]})},u.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:o("readHome.periodUnknown",{n:Ke(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:o("readHome.hoverHint")})]})]})}function Hd({authors:e,links:n}){const{t:i,convert:o}=ne(),s=Vt(n);return e.length?t.jsx("ul",{className:"bim-rh-authors",children:e.map(a=>t.jsxs("li",{className:"bim-rh-au",children:[t.jsxs("h3",{className:"bim-rh-au-h",children:[o(a.name),a.dynasty&&t.jsx("span",{children:o(a.dynasty)}),t.jsx("small",{className:"bim-rh-num",children:i("readHome.nPieces",{n:Ke(a.count)})})]}),t.jsx("ul",{children:a.items.map(l=>t.jsx("li",{children:t.jsx("a",{href:s.read(l.id),children:o(l.title)})},l.id))}),s.author&&t.jsx("a",{className:"bim-rh-more",href:s.author(a.name),children:i("readHome.authorAll",{name:o(a.name),n:a.count})})]},a.name))}):null}const Dd={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function wy({sections:e,links:n,head:i,piecesMoreHref:o,className:s}){const{t:a}=ne(),l=e,d=Dd,c=l.topics.filter(m=>!m.shelf),p={picks:l.picks.length>0,topics:c.some(m=>m.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(m=>m.count>0),pieces:l.pieces.authors.length>0},h=Object.keys(d).filter(m=>p[m]),u=m=>a(`readHome.nav.${m}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:Yo}),t.jsxs("div",{className:"bim-rh-head",children:[i,t.jsx(Ad,{counts:l.counts})]}),h.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":a("readHome.navLabel"),children:t.jsx("ul",{children:h.map(m=>t.jsx("li",{children:t.jsx("a",{href:`#${d[m]}`,children:u(m)})},m))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(ct,{id:d.picks,title:u("picks"),sub:a("readHome.picksSub"),children:t.jsx(Md,{picks:l.picks,links:n})}),p.topics&&t.jsx(ct,{id:d.topics,title:u("topics"),sub:a("readHome.topicsSub"),children:t.jsx(Wd,{topics:c,links:n})}),p.famous&&t.jsx(ct,{id:d.famous,title:u("famous"),sub:a("readHome.famousSub"),children:t.jsx(Od,{famous:l.famous,links:n})}),p.sibu&&t.jsx(ct,{id:d.sibu,title:u("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(Xo,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(ct,{id:d.period,title:u("period"),sub:a("readHome.periodSub"),children:t.jsx(Fd,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(ct,{id:d.pieces,title:u("pieces"),sub:a("readHome.piecesSub"),more:o?t.jsx("a",{className:"bim-rh-more",href:o,children:a("readHome.piecesMore")}):void 0,children:t.jsx(Hd,{authors:l.pieces.authors,links:n})})]})]})}const Sy="(max-width: 1079px)",_y=`${Vn}, (pointer: coarse)`,Ud=`
|
|
1742
|
+
`,wy=Xr["zh-Hant"].period,Nd={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function Vt(e){return{...Nd,...e??{}}}function qo(e){var i;const n=(i=e.authors)==null?void 0:i.find(o=>o==null?void 0:o.name);return n?n.dynasty?`${n.dynasty} ${n.name}`:n.name:""}function Wi(e){return(e.authors??[]).filter(i=>i==null?void 0:i.name).map(i=>i.dynasty?`〔${i.dynasty}〕${i.name}`:i.name).join(" ")}function Id(e,n=Xr["zh-Hant"].shelfOther){var s;const i=[],o=new Map;for(const a of e){const l=((s=a.period_of)==null?void 0:s.trim())||n;let d=o.get(l);d||(d={label:l,items:[]},o.set(l,d),i.push(d)),d.items.push(a)}return i}function Rd(e){return Math.max(150,Array.from(e).length*18+44)}function Ed(e,n){if(n<=0||e<=0)return 0;const i=e/n;return i<.15?0:i<.35?1:i<.6?2:i<.85?3:4}const Ld=.04;function Ke(e){return e.toLocaleString("en-US")}function Ad({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,i)=>t.jsx("span",{children:n},i))})}function ct({id:e,title:n,sub:i,more:o,children:s}){const{convert:a}=ne(),l=`${e}-h`;return t.jsxs("section",{className:"bim-rh-sec",id:e,"aria-labelledby":l,children:[t.jsxs("div",{className:"bim-rh-hd",children:[t.jsx("h2",{id:l,children:a(n)}),i&&t.jsx("span",{className:"bim-rh-sub",children:i}),o]}),t.jsx("div",{className:"bim-rh-bd",children:s})]})}function Md({counts:e}){const{t:n}=ne();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:Ke(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:Ke(e.pieces)}),n("readHome.pieces")]})]})}function Pd({picks:e,links:n}){const{t:i,convert:o}=ne(),s=Vt(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=Wi(a),d=[a.type_label,a.edition].filter(Boolean).join(" · ");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-pk",href:s.read(a.id),children:[t.jsx("span",{className:"bim-rh-slip","aria-hidden":"true",children:t.jsx(Ad,{text:o(a.slip||a.title)})}),t.jsxs("span",{className:"bim-rh-pk-body",children:[d&&t.jsx("span",{className:"bim-rh-badge",children:o(d)}),t.jsx("h3",{children:o(a.title)}),l&&t.jsx("span",{className:"bim-rh-by",children:o(l)}),a.blurb&&t.jsx("p",{children:o(a.blurb)}),t.jsx("span",{className:"bim-rh-go","aria-hidden":"true",children:i("readHome.startReading")})]})]})},a.id)})}):null}function Bd(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function Ko({topic:e,links:n,hint:i,legendCount:o,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=ne(),c=Vt(n);if(!e.items.length)return null;const p=o===void 0?l("readHome.shelfLegendCount"):o,h=Id(e.items,l("readHome.shelfOther")),u=m=>{const f=m.records?Ke(m.records):Bd(m.text_count,l),x=qo(m),v=[d(m.title),m.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",m.records?l("readHome.spineRecords",{n:f}):f?l("readHome.spineOnSite",{n:f}):""].filter(Boolean).join(",");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-spine",href:c.read(m.id),"data-orig":m.orig?"":void 0,"aria-label":v,title:v,style:{height:Rd(m.title)},children:[t.jsx(Ad,{text:d(m.title)}),f&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":m.records?"":void 0,children:f})]})},m.id)};return t.jsxs("div",{className:"bim-rh-shelf-box",children:[s&&t.jsxs("h3",{className:"bim-rh-gt",children:[d(e.label),t.jsx("small",{children:i?d(i):l("readHome.shelfHint")})]}),t.jsx("div",{className:"bim-rh-shelf-wrap",tabIndex:0,role:"region","aria-label":l("readHome.shelfRegion",{label:d(e.label)}),children:t.jsx("ul",{className:"bim-rh-shelf",children:h.map(m=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(m.label),children:m.items.map(u)}),t.jsx("span",{"aria-hidden":"true",children:d(m.label)})]},m.label))})}),t.jsxs("p",{className:"bim-rh-legend",children:[t.jsxs("span",{children:[t.jsx("i",{"data-orig":"","aria-hidden":"true"}),l("readHome.origZhi")]}),t.jsxs("span",{children:[t.jsx("i",{"aria-hidden":"true"}),l("readHome.laterZhi")]}),p&&t.jsx("span",{children:d(p)}),a==null?void 0:a.map(m=>t.jsx("span",{children:d(m)},m))]})]})}const Sy=4,Bn=e=>e>Sy+1;function Wd({topic:e,links:n}){const{t:i,convert:o}=ne(),s=Vt(n),[a,l]=g.useState(!1);if(!e.items.length)return null;const d=`bim-rh-g-${e.key}`;return t.jsxs("div",{className:"bim-rh-grp","data-cap":Bn(e.items.length)?"":void 0,"data-open":a?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",id:d,children:[o(e.label),t.jsx("small",{className:"bim-rh-num",children:i("readHome.nWorks",{n:Ke(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=Bd(c.text_count,i),h=qo(c);return t.jsx("li",{children:t.jsxs("a",{href:s.read(c.id),children:[t.jsx("span",{className:"bim-rh-t",children:o(c.title)}),p&&t.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:p}),h&&t.jsx("small",{children:o(h)})]})},c.id)})}),Bn(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":a,onClick:()=>l(c=>!c),children:a?i("action.collapse"):i("readHome.allNWorks",{n:e.items.length})})]})}function Od({topics:e,links:n}){const i=e.filter(s=>s.shelf&&s.items.length),o=e.filter(s=>!s.shelf&&s.items.length);return!i.length&&!o.length?null:t.jsxs(t.Fragment,{children:[i.map(s=>t.jsx(Ko,{topic:s,links:n},s.key)),o.length>0&&t.jsx("div",{className:"bim-rh-groups",children:o.map(s=>t.jsx(Wd,{topic:s,links:n},s.key))})]})}function Fd({famous:e,links:n}){const{t:i,convert:o}=ne(),s=Vt(n);return e.length?t.jsx("ul",{className:"bim-rh-works",children:e.map(a=>t.jsx("li",{children:t.jsxs("article",{className:"bim-rh-wk",children:[t.jsxs("div",{className:"bim-rh-wk-h",children:[t.jsx("h3",{children:o(a.title)}),a.authors&&t.jsx("span",{className:"bim-rh-by",children:o(a.authors)}),t.jsx("span",{className:"bim-rh-c bim-rh-num",children:i("readHome.nCopiesCard",{n:a.text_count})})]}),a.systems.map((l,d)=>t.jsxs("div",{className:"bim-rh-lin",role:"group","aria-label":l.label?o(l.label):void 0,children:[l.label&&t.jsx("small",{"aria-hidden":"true",children:o(l.label)}),l.items.map(c=>t.jsx("a",{className:"bim-rh-chip",href:s.read(c.id),title:o([c.title,c.edition].filter(Boolean).join(" · ")),children:o(c.short)},c.id))]},d)),a.work_id&&t.jsx("div",{className:"bim-rh-wk-f",children:t.jsx("a",{href:s.work(a.work_id),children:i("readHome.workPageLink",{title:o(a.title)})})})]})},a.work_id??a.title))}):null}function Xo({bu:e,unclassified:n,links:i,unclassifiedNote:o}){const{t:s,convert:a}=ne(),l=Vt(i);return!e.length&&!n?null:t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-bu",children:e.map(d=>{var p;const c=((p=d.top[0])==null?void 0:p.count)||1;return t.jsxs("li",{className:"bim-rh-bu-c",children:[t.jsxs("a",{className:"bim-rh-bu-h",href:l.node(d.id),children:[t.jsx("b",{children:a(d.label)}),t.jsx("span",{className:"bim-rh-num",children:s("readHome.nWorks",{n:Ke(d.count)})})]}),d.top.length>0&&t.jsx("ul",{className:"bim-rh-bu-l","aria-label":s("readHome.subClasses",{label:a(d.label)}),children:d.top.map(h=>t.jsx("li",{children:t.jsxs("a",{href:l.node(h.id),children:[t.jsx("span",{children:a(h.label)}),t.jsx("small",{className:"bim-rh-num",children:Ke(h.count)}),t.jsx("span",{className:"bim-rh-bar","aria-hidden":"true",style:{"--bimrh-w":`${Math.round(h.count/c*100)}%`}})]})},h.id))}),d.children_total>d.top.length&&t.jsx("a",{className:"bim-rh-bu-more",href:l.node(d.id),children:s("readHome.allNClasses",{label:a(d.label),n:d.children_total})})]},d.id)})}),!!n&&t.jsxs("p",{className:"bim-rh-uncl bim-rh-num",children:[t.jsx("b",{children:s("readHome.unclassified")}),t.jsx("span",{children:s("readHome.nWorks",{n:Ke(n)})}),t.jsx("span",{children:o?a(o):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function Hd({periods:e,unknown:n,links:i}){const{t:o,convert:s,messages:a}=ne(),l=a.readHome.period,d=Vt(i),c=e.filter(u=>u.count>0);if(!c.length)return null;const p=c.reduce((u,m)=>u+m.count,0),h=Math.max(...c.map(u=>u.count));return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-band",children:c.map(u=>{const m=u.label?s(u.label):l[u.key]??s(u.key),f=u.count/p,x=o("readHome.periodItem",{label:m,n:Ke(u.count)});return t.jsx("li",{style:{flex:`0 0 ${(f*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(u.key),"data-k":Ed(u.count,h),"data-narrow":f<Ld?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:m}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(m)[0]}),t.jsx("small",{className:"bim-rh-num",children:Ke(u.count)})]})},u.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:o("readHome.periodUnknown",{n:Ke(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:o("readHome.hoverHint")})]})]})}function Dd({authors:e,links:n}){const{t:i,convert:o}=ne(),s=Vt(n);return e.length?t.jsx("ul",{className:"bim-rh-authors",children:e.map(a=>t.jsxs("li",{className:"bim-rh-au",children:[t.jsxs("h3",{className:"bim-rh-au-h",children:[o(a.name),a.dynasty&&t.jsx("span",{children:o(a.dynasty)}),t.jsx("small",{className:"bim-rh-num",children:i("readHome.nPieces",{n:Ke(a.count)})})]}),t.jsx("ul",{children:a.items.map(l=>t.jsx("li",{children:t.jsx("a",{href:s.read(l.id),children:o(l.title)})},l.id))}),s.author&&t.jsx("a",{className:"bim-rh-more",href:s.author(a.name),children:i("readHome.authorAll",{name:o(a.name),n:a.count})})]},a.name))}):null}const Ud={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function _y({sections:e,links:n,head:i,piecesMoreHref:o,className:s}){const{t:a}=ne(),l=e,d=Ud,c=l.topics.filter(m=>!m.shelf),p={picks:l.picks.length>0,topics:c.some(m=>m.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(m=>m.count>0),pieces:l.pieces.authors.length>0},h=Object.keys(d).filter(m=>p[m]),u=m=>a(`readHome.nav.${m}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:Yo}),t.jsxs("div",{className:"bim-rh-head",children:[i,t.jsx(Md,{counts:l.counts})]}),h.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":a("readHome.navLabel"),children:t.jsx("ul",{children:h.map(m=>t.jsx("li",{children:t.jsx("a",{href:`#${d[m]}`,children:u(m)})},m))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(ct,{id:d.picks,title:u("picks"),sub:a("readHome.picksSub"),children:t.jsx(Pd,{picks:l.picks,links:n})}),p.topics&&t.jsx(ct,{id:d.topics,title:u("topics"),sub:a("readHome.topicsSub"),children:t.jsx(Od,{topics:c,links:n})}),p.famous&&t.jsx(ct,{id:d.famous,title:u("famous"),sub:a("readHome.famousSub"),children:t.jsx(Fd,{famous:l.famous,links:n})}),p.sibu&&t.jsx(ct,{id:d.sibu,title:u("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(Xo,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(ct,{id:d.period,title:u("period"),sub:a("readHome.periodSub"),children:t.jsx(Hd,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(ct,{id:d.pieces,title:u("pieces"),sub:a("readHome.piecesSub"),more:o?t.jsx("a",{className:"bim-rh-more",href:o,children:a("readHome.piecesMore")}):void 0,children:t.jsx(Dd,{authors:l.pieces.authors,links:n})})]})]})}const $y="(max-width: 1079px)",Cy=`${Vn}, (pointer: coarse)`,Vd=`
|
|
1743
1743
|
/* ── 页首:检索(宿主插槽)+类型签|最近浏览 ── */
|
|
1744
1744
|
.bim-mh-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 16px 48px; align-items: start; padding-top: 8px; }
|
|
1745
1745
|
.bim-mh-q { min-width: 0; }
|
|
@@ -1879,7 +1879,7 @@ ${jy.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1879
1879
|
.bim-mh-cc0 { display: inline-block; margin-right: 8px; padding: 1px 7px; font-size: 11.5px; letter-spacing: 0.08em; background: ${r("check-fine-bg")}; color: ${r("check-fine-fg")}; }
|
|
1880
1880
|
|
|
1881
1881
|
/* ── 中屏 ── */
|
|
1882
|
-
@media ${
|
|
1882
|
+
@media ${$y} {
|
|
1883
1883
|
.bim-mh-head, .bim-mh-zhi { grid-template-columns: minmax(0, 1fr); }
|
|
1884
1884
|
.bim-mh-cg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1885
1885
|
.bim-mh-lin { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
@@ -1906,8 +1906,8 @@ ${jy.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1906
1906
|
.bim-mh-tbl tr > :nth-child(2), .bim-mh-tbl tr > :nth-child(3) { display: none; }
|
|
1907
1907
|
}
|
|
1908
1908
|
|
|
1909
|
-
@media ${
|
|
1909
|
+
@media ${Cy} {
|
|
1910
1910
|
.bim-mh-recent li a, .bim-mh-types a, .bim-mh-tl-list a { min-height: 44px; align-items: center; }
|
|
1911
1911
|
.bim-mh-recent-h button { min-height: 44px; }
|
|
1912
1912
|
}
|
|
1913
|
-
`,Vd={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function Gt(e){return{...Vd,...e??{}}}function Gd(e,n){if(e.lineage)return e.lineage(n);const i=e.item(n),o=i.indexOf("#"),[s,a]=o<0?[i,""]:[i.slice(0,o),i.slice(o)];return`${s}${s.includes("?")?"&":"?"}tab=lineage${a}`}function Zo(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function Yd(e){const n=e.filter(p=>Number.isFinite(p.birth_year)||Number.isFinite(p.death_year)),i=e.filter(p=>!n.includes(p));if(!n.length)return{min:0,max:0,placed:[],missing:i};const o=p=>{const h=Number.isFinite(p.birth_year)?p.birth_year:p.death_year-50,u=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(h,u),Math.max(h,u)]},s=n.map(o),a=Math.min(...s.map(p=>p[0])),l=Math.max(...s.map(p=>p[1])),d=Math.max(1,l-a),c=n.map((p,h)=>({p,from:s[h][0],to:s[h][1]})).sort((p,h)=>p.from-h.from).map(p=>({...p,left:(p.from-a)/d*100,width:Math.max(.8,(p.to-p.from)/d*100)}));return{min:a,max:l,placed:c,missing:i}}function vi(e,n=yn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function $y(e){return{read:e.item,work:e.item,node:e.node}}function qd({counts:e,links:n}){const{t:i}=ne(),o=n==null?void 0:n.type;if(!o)return null;const s=[["all",i("metaHome.typeAll"),null],["work",i("metaHome.typeLabel.work"),e.works],["book",i("metaHome.typeLabel.book"),e.books],["collection",i("metaHome.typeLabel.collection"),e.collections],["entity",i("metaHome.typeLabel.entity"),e.entities]];return t.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":i("metaHome.typeChipsLabel"),children:s.map(([a,l,d])=>t.jsx("li",{children:t.jsxs("a",{href:o(a),children:[t.jsx("b",{children:l}),d!=null&&d>0&&t.jsx("small",{children:Ke(d)})]})},a))})}function Kd(e,n=5){const[i,o]=g.useState(null);g.useEffect(()=>{let a=!1;const l=Ut().slice(0,n);if(!l.length||!e){o([]);return}return Promise.all(l.map(d=>eo(e,d))).then(d=>{a||o(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=g.useCallback(()=>{Qr(),o([])},[]);return{entries:i,clear:s}}function Cy(e,n,i){const o=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return o?i(o):Xd(e.type,n)}function Xd(e,n){return n(`metaHome.typeLabel.${e}`)}function Zd({entries:e,onClear:n,links:i}){const{t:o,convert:s}=ne(),a=Gt(i);return t.jsxs("aside",{className:"bim-mh-recent","aria-labelledby":"bim-mh-recent-h",children:[t.jsxs("div",{className:"bim-mh-recent-h",children:[t.jsx("h2",{id:"bim-mh-recent-h",children:o("metaHome.recentTitle")}),e&&e.length>0&&n&&t.jsx("button",{type:"button",onClick:n,children:o("metaHome.recentClear")})]}),e&&e.length>0&&t.jsx("ol",{children:e.map(l=>t.jsx("li",{children:t.jsxs("a",{href:a.item(l.id),"aria-label":o("metaHome.recentItemLabel",{type:l.type?Xd(l.type,o):"",title:s(l.title)}),children:[t.jsx("i",{className:"bim-mh-ty","aria-hidden":"true",children:l.type?o(`metaHome.typeShort.${l.type}`):""}),t.jsx("span",{children:s(l.title)}),t.jsx("small",{"aria-hidden":"true",children:Cy(l,o,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:o("metaHome.recentEmpty")})]})}function Jd(e,n,i,o=!1){return o&&(e==="done"||e==="in_progress")?n(`metaHome.siteStatus.${e}`):e==="done"||e==="in_progress"||e==="todo"?n(`metaHome.status.${e}`):i(e)}function Qd({rows:e,links:n}){const{t:i,convert:o}=ne(),s=Gt(n);return e.length?t.jsx("div",{className:"bim-mh-tbl-wrap",tabIndex:0,role:"region","aria-label":i("metaHome.catalogTitle"),children:t.jsxs("table",{className:"bim-mh-tbl",children:[t.jsxs("caption",{children:[i("metaHome.catalogTitle"),t.jsx("small",{children:i("metaHome.catalogNote")})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:i("metaHome.colCatalog")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:i("metaHome.colRecords")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:i("metaHome.colMatched")}),t.jsx("th",{scope:"col",children:i("metaHome.colProgress")}),t.jsx("th",{scope:"col",children:i("metaHome.colStatus")})]})}),t.jsx("tbody",{children:e.map(a=>{const l=Zo(a.imported,a.total),d=a.work_id??a.collection_id,c=o(a.edition?`${a.name}·${a.edition}`:a.name);return t.jsxs("tr",{children:[t.jsx("th",{scope:"row",children:d?t.jsx("a",{href:s.item(d),children:c}):c}),t.jsx("td",{className:"bim-mh-r",children:Ke(a.total)}),t.jsx("td",{className:"bim-mh-r",children:Ke(a.imported)}),t.jsx("td",{children:t.jsxs("span",{className:"bim-mh-meter",children:[t.jsx("i",{"aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[l,"%"]})]})}),t.jsx("td",{children:a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:Jd(a.status,i,o)})})]},a.id||a.name)})})]})}):null}function ep({items:e,links:n,label:i}){const{convert:o}=ne();return t.jsx("ul",{className:"bim-rh-rows","aria-label":i?o(i):void 0,children:e.map(s=>t.jsx("li",{children:t.jsxs("a",{href:n.item(s.id),children:[t.jsx("span",{className:"bim-rh-t",children:o(s.title)}),s.sub&&t.jsx("small",{children:o(s.sub)})]})},s.id))})}function tp({works:e,links:n}){const{t:i}=ne(),[o,s]=g.useState(!1);if(!e.length)return null;const a=Bn(e.length);return t.jsxs("div",{className:"bim-rh-grp","data-cap":a?"":void 0,"data-open":o?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[i("metaHome.relatedTitle"),t.jsx("small",{children:i("metaHome.relatedNote")})]}),t.jsx(ep,{items:e.map(l=>({id:l.id,title:l.title,sub:Wi(l)||void 0})),links:Gt(n)}),a&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":o,onClick:()=>s(l=>!l),children:o?i("action.collapse"):i("metaHome.allNWorks",{n:e.length})})]})}const np="siku_qige";function Ty({group:e,links:n}){const{t:i,convert:o}=ne(),[s,a]=g.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":Bn(e.items.length)?"":void 0,"data-open":s?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[o(e.label),t.jsx("small",{className:"bim-rh-num",children:i("metaHome.nKinds",{n:e.items.length})})]}),t.jsx(ep,{items:e.items,links:n,label:e.label}),Bn(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":s,onClick:()=>a(l=>!l),children:s?i("action.collapse"):i("metaHome.allNKinds",{n:e.items.length})})]})}function ip({groups:e,links:n}){const{t:i,convert:o}=ne(),s=Gt(n);if(!e.length)return null;const a=e.find(c=>c.key===np),l=e.filter(c=>c!==a),d=c=>{var p;return((p=c.match(/(文[^\s·・閣阁]+)[閣阁]/))==null?void 0:p[1])??c};return t.jsxs(t.Fragment,{children:[a&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:"bim-rh-gt",children:[o(a.label),t.jsx("small",{children:o(a.items.map(c=>d(c.title)).join("、"))})]}),t.jsx("ul",{className:"bim-mh-ge","aria-label":o(a.label),children:a.items.map(c=>t.jsx("li",{children:t.jsxs("a",{href:s.item(c.id),"aria-label":o(c.title),title:o(c.title),children:[t.jsx("span",{"aria-hidden":"true",children:o(d(c.title))}),d(c.title)!==c.title&&t.jsx("small",{"aria-hidden":"true",children:i("metaHome.pavilion")})]})},c.id))})]}),l.length>0&&t.jsx("div",{className:"bim-mh-cg",style:a?void 0:{marginTop:0},children:l.map(c=>t.jsx(Ty,{group:c,links:s},c.key))})]})}const Ya=34,qa=13;function Ka(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?vi(e.birth_year,n):"?"}–${e.death_year!=null?vi(e.death_year,n):"?"}`}function zy(e,n){const i=n-e,o=i>1200?300:i>400?100:50,s=[];for(let a=Math.ceil(e/o)*o;a<=n;a+=o)s.push(a);return s}function rp({people:e,links:n}){const{t:i,convert:o}=ne(),s=Gt(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=Yd(e),p=[],h=d.map(m=>{const f=m.left>70,x=f?Math.min(m.left,m.left+m.width-qa):m.left;let v=0;for(;p[v]!=null&&p[v]>x;)v++;return p[v]=f?m.left+m.width:m.left+Math.max(m.width,qa),{...m,lane:v,end:f}}),u=Math.max(1,l-a);return t.jsxs(t.Fragment,{children:[h.length>0&&t.jsxs("div",{className:"bim-mh-tl",children:[t.jsx("ul",{className:"bim-mh-tl-rows",style:{height:p.length*Ya+10},children:h.map(m=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":m.end?"":void 0,style:{left:`${m.left}%`,top:m.lane*Ya+4,width:`${Math.max(m.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(m.p.id),children:[o(m.p.name),t.jsx("small",{className:"bim-rh-num",children:Ka(m.p,i)})]})]},m.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:zy(a,l).map(m=>t.jsx("span",{style:{left:`${(m-a)/u*100}%`},children:vi(m,i)},m))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":h.length?void 0:"",children:(h.length?e:c).map(m=>t.jsx("li",{children:t.jsxs("a",{href:s.item(m.id),children:[t.jsx("span",{children:o(m.name)}),t.jsx("small",{className:"bim-rh-num",children:[m.dynasty?o(m.dynasty):"",Ka(m,i)].filter(Boolean).join(" ")})]})},m.id))}),c.length>0&&h.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:i("metaHome.missingLife",{names:o(c.map(m=>m.name).join("、"))})})]})}const Ny=t.jsxs("svg",{width:"54",height:"34",viewBox:"0 0 54 34",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:[t.jsx("circle",{cx:"27",cy:"5",r:"3.5"}),t.jsx("circle",{cx:"10",cy:"29",r:"3.5"}),t.jsx("circle",{cx:"27",cy:"29",r:"3.5"}),t.jsx("circle",{cx:"44",cy:"29",r:"3.5"}),t.jsx("path",{d:"M27 8.5v17M27 15H10v10.5M27 15h17v10.5"})]});function op({works:e,links:n}){const{t:i,convert:o}=ne(),s=Gt(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=Wi(a);return t.jsx("li",{children:t.jsxs("a",{href:Gd(s,a.id),children:[Ny,t.jsx("b",{children:o(a.title)}),l&&t.jsx("small",{children:o(l)}),t.jsx("span",{children:i("metaHome.viewLineage")})]})},a.id)})}):null}function sp({sites:e}){const{t:n,convert:i}=ne(),o=e.filter(a=>a.status!=="todo"&&a.total>0),s=e.filter(a=>!o.includes(a));return e.length?t.jsxs(t.Fragment,{children:[o.length>0&&t.jsx("ul",{className:"bim-mh-cov",children:o.map(a=>{const l=Zo(a.imported,a.total);return t.jsxs("li",{children:[a.url?t.jsx("a",{href:a.url,rel:"noopener noreferrer",target:"_blank",children:i(a.name)}):t.jsx("span",{children:i(a.name)}),t.jsx("span",{className:"bim-mh-bar","aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[`${Ke(a.imported)} / ${Ke(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:Jd(a.status,n,i,!0)})]})]},a.id||a.name)})}),s.length>0&&t.jsx("p",{className:"bim-mh-todo",children:n("metaHome.plannedSites",{names:i(s.map(a=>a.name).join("、"))})})]}):null}const Xa=["extant","partially_extant","lost","unknown"];function ap({stats:e,links:n,version:i,repoUrl:o,downloadHref:s}){const{t:a}=ne(),l=["works","books","collections","entities","has_image","has_text","article","poem"].map(p=>[e[p],a(`metaHome.stat.${p}`)]).filter(([p])=>p>0),d=n==null?void 0:n.loss,c=Xa.some(p=>{var h;return(((h=e.loss)==null?void 0:h[p])??0)>0});return t.jsxs("div",{className:"bim-mh-data",children:[l.length>0&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.dataScale")}),t.jsx("ul",{className:"bim-mh-nums",children:l.map(([p,h])=>t.jsxs("li",{children:[t.jsx("b",{className:"bim-rh-num",children:Ke(p)}),t.jsx("span",{children:h})]},h))})]}),d&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.byLoss")}),t.jsx("ul",{className:"bim-mh-loss",children:Xa.map(p=>{var m;const h=((m=e.loss)==null?void 0:m[p])??0,u=a(`metaHome.lossNote.${p}`);return t.jsx("li",{children:t.jsxs("a",{href:d(p),children:[a(`metaHome.loss.${p}`),t.jsx("small",{className:"bim-rh-num",children:c&&h>0?a("metaHome.lossCount",{n:Ke(h),note:u}):u})]})},p)})})]}),t.jsxs("div",{className:"bim-mh-lic",children:[t.jsxs("p",{children:[t.jsx("span",{className:"bim-mh-cc0",children:"CC0"}),a("metaHome.license")]}),t.jsxs("p",{children:[a("metaHome.repo"),o?t.jsx("a",{href:o,children:t.jsx("code",{children:"book-index"})}):t.jsx("code",{children:"book-index"}),a("metaHome.repoNote")]}),i&&t.jsxs("p",{children:[a("metaHome.version"),t.jsx("code",{children:i})]}),s&&t.jsx("p",{children:t.jsx("a",{href:s,children:a("metaHome.download")})})]})]})}const lp={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function Iy({sections:e,links:n,head:i,transport:o,catalogHref:s,collectionsHref:a,entitiesHref:l,version:d,repoUrl:c,downloadHref:p,className:h}){var k,$;const{t:u}=ne(),m=e,f=Gt(n),x=$y(f),v=lp,y=Kd(o),S={zhi:!!((k=m.shelf)!=null&&k.items.length)||m.catalog_progress.length>0||m.related_catalogs.length>0,sibu:m.bu.length>0||m.unclassified>0,cong:m.collection_groups.length>0,people:m.bibliographers.length>0,lineage:m.lineage.length>0,sites:m.sites.length>0,data:!0},b=Object.keys(v).filter(C=>S[C]),w=C=>u(`metaHome.nav.${C}`),j=(C,_)=>C?t.jsx("a",{className:"bim-rh-more",href:C,children:_}):void 0;return t.jsxs("div",{className:h?`bim-rh bim-mh ${h}`:"bim-rh bim-mh",children:[t.jsx("style",{children:Yo+Ud}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[i,t.jsx(qd,{counts:m.counts,links:n})]}),o&&t.jsx(Zd,{entries:y.entries,onClear:y.clear,links:n})]}),b.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":u("metaHome.navLabel"),children:t.jsx("ul",{children:b.map(C=>t.jsx("li",{children:t.jsx("a",{href:`#${v[C]}`,children:w(C)})},C))})}),t.jsxs("div",{className:"bim-rh-main",children:[S.zhi&&t.jsxs(ct,{id:v.zhi,title:w("zhi"),sub:u("metaHome.zhiSub"),children:[m.shelf&&m.shelf.items.length>0&&t.jsx(Ko,{topic:{key:"shelf",label:m.shelf.label,shelf:!0,items:m.shelf.items},links:x,showTitle:!1,legendCount:m.shelf.items.some(C=>C.records)?u("metaHome.shelfLegendCount"):null,legendExtra:[u("metaHome.shelfLegendClick")]}),(m.catalog_progress.length>0||m.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:($=m.shelf)!=null&&$.items.length?void 0:{marginTop:0},children:[t.jsx(Qd,{rows:m.catalog_progress,links:n}),t.jsx(tp,{works:m.related_catalogs,links:n})]})]}),S.sibu&&t.jsx(ct,{id:v.sibu,title:w("sibu"),sub:u("metaHome.sibuSub"),more:j(s,u("metaHome.toCatalog")),children:t.jsx(Xo,{bu:m.bu,unclassified:m.unclassified,links:x,unclassifiedNote:u("metaHome.unclassifiedNote")})}),S.cong&&t.jsx(ct,{id:v.cong,title:w("cong"),sub:u("metaHome.congSub"),more:j(a,u("metaHome.allNKindsMore",{n:Ke(m.counts.collections)})),children:t.jsx(ip,{groups:m.collection_groups,links:n})}),S.people&&t.jsx(ct,{id:v.people,title:w("people"),sub:u("metaHome.peopleSub"),more:j(l,u("metaHome.allNPeopleMore",{n:Ke(m.counts.entities)})),children:t.jsx(rp,{people:m.bibliographers,links:n})}),S.lineage&&t.jsx(ct,{id:v.lineage,title:w("lineage"),sub:u("metaHome.lineageSub"),children:t.jsx(op,{works:m.lineage,links:n})}),S.sites&&t.jsx(ct,{id:v.sites,title:w("sites"),sub:u("metaHome.sitesSub"),children:t.jsx(sp,{sites:m.sites})}),t.jsx(ct,{id:v.data,title:w("data"),sub:u("metaHome.dataSub"),children:t.jsx(ap,{stats:m.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const cp=["_related","_catalogs","_collections","_members","_children"],Ry=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Hr=e=>Ry(e)&&!!e.h;function Ey(e){return e?cp.some(n=>{const i=e[n];return Array.isArray(i)&&i.some(Hr)}):!1}function Ly(e,n){const i={...e};if(!n)return i;for(const o of cp){const s=e[o];!Array.isArray(s)||!s.some(Hr)||(i[o]=s.map(a=>{var c;if(!Hr(a)||typeof a.title=="string"&&a.title)return a;const l=a.id??a.bid,d=l?(c=n[l])==null?void 0:c.title:void 0;return d?{...a,title:d}:a}))}return i}function Ay(e){let n=null;const i=()=>e.getHubs?(n??(n=e.getHubs().catch(()=>null)),n):Promise.resolve(null);return new Proxy(e,{get(o,s){if(s==="getItem")return async l=>{const d=await o.getItem(l);return d&&Ly(d,Ey(d)?await i():null)};const a=Reflect.get(o,s,o);return typeof a=="function"?a.bind(o):a}})}const Dr=({style:e})=>{const n=g.useContext(Tt),{t:i}=ne();if(!n)return null;const{locale:o,setLocale:s}=n,a=o==="zh-Hant",l=()=>s(a?"zh-Hans":"zh-Hant");return t.jsxs("button",{type:"button",onClick:l,title:i(a?"common.toHans":"common.toHant"),style:{display:"inline-flex",alignItems:"center",gap:"2px",padding:"4px 10px",fontSize:"13px",fontWeight:500,lineHeight:1,border:`1px solid ${r("border")}`,borderRadius:"4px",background:r("bg"),color:r("fg"),cursor:"pointer",userSelect:"none",...e},children:[t.jsx("span",{style:{color:a?r("primary"):void 0,fontWeight:a?700:400},children:i("common.localeShortHant")}),t.jsx("span",{style:{opacity:.3},children:"/"}),t.jsx("span",{style:{color:a?void 0:r("primary"),fontWeight:a?400:700},children:i("common.localeShortHans")})]})},Ur=({href:e,label:n,size:i=16,className:o,style:s})=>{const{t:a}=ne(),l=n??a("common.repoSourceLink");return t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:l,"aria-label":l,className:o,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:i+8,height:i+8,borderRadius:4,color:r("desc-fg"),textDecoration:"none",transition:"color 120ms, background 120ms",...s},onMouseEnter:d=>{d.currentTarget.style.color=r("fg")},onMouseLeave:d=>{d.currentTarget.style.color=r("desc-fg")},children:t.jsx("svg",{width:i,height:i,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8a8 8 0 0 0 5.47 7.59c.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})})};function br(e){const n=e.text_count;return typeof n=="number"&&n>0}function yr(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function My(e,n){if(!n)return!1;const i=n.id;return i===void 0||i===e}const Py=({id:e,transport:n,initialDetail:i,initialEntry:o,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:h,onLineageCollectionChange:u,initialPage:m=1,selectedLineageNodeId:f,onNavigate:x,onBack:v,backLabel:y,renderLink:S,enrichDetail:b,getSourceLink:w,readLink:j,railTop:k,extraTabs:$=[],showFeedbackTab:C=!0,feedbackApiUrl:_,height:E,footerExtra:z,hideHeaderControls:T=!1,className:B,style:W})=>{const N=g.useMemo(()=>Ay(n),[n]),A=Ee(),{t:F,convert:Y}=ne(),[ee]=g.useState(()=>{if(!My(e,i))return null;const Q={...i},ve=o??yr(e,Q);return b&&b(ve,Q),{id:e,entry:ve,detail:Q}}),[se,D]=g.useState((ee==null?void 0:ee.entry)??null),[V,he]=g.useState((ee==null?void 0:ee.detail)??null),[Z,M]=g.useState(!ee),[_e,ce]=g.useState(!1),[ge,le]=g.useState([]),[Be,ze]=g.useState(!1),[Fe,te]=g.useState(null),[H,G]=g.useState(null),[xe,K]=g.useState(null),[L,q]=g.useState(!1),ae=g.useRef(null),be=g.useRef(0),[X,re]=g.useState(null),Ce=l!==void 0?l:X,We=g.useCallback(Q=>{d?d(Q):re(Q)},[d]),O=g.useCallback(async Q=>{if(!N.getCollectionCatalogs&&!N.getCollectionCatalog){le([]);return}ze(!0);try{if(N.getCollectionCatalogs)le(await N.getCollectionCatalogs(Q)||[]);else if(N.getCollectionCatalog){const ve=await N.getCollectionCatalog(Q);le(ve?[{resource_id:"",data:ve}]:[])}}catch{le([])}finally{ze(!1)}},[N]),ie=g.useCallback(async Q=>{var ve,Ae;if(!N.getTextManifest||!N.getTextIndex){te(null),G(Q);return}try{const Oe=Se.pickTextVersion(await N.getTextManifest(Q)),Ie=Oe?await N.getTextIndex(Q,Oe.key):null;te(Ie&&Ie.chapters.length>0?{chapters:Ie.chapters.map(me=>({n:me.n,title:me.title,file:me.file})),source:{name:((ve=Ie.source)==null?void 0:ve.name)??(Oe==null?void 0:Oe.source_name),license:((Ae=Ie.source)==null?void 0:Ae.license)??(Oe==null?void 0:Oe.license)??void 0}}:null)}catch{te(null)}finally{G(Q)}},[N]),je=g.useCallback(async(Q,ve)=>{const Ae=++be.current,Oe=()=>Ae!==be.current;q(!0);try{if(N.getLineageGraph){const jt=await N.getLineageGraph(Q);if(Oe())return;jt&&K(jt)}const Ie=ve.version_graph;if(!Ie||!Ie.enabled){xe||K(null),ae.current=null;return}const me=po(ve),De=(await Pi(me,Mi,async jt=>{try{return await N.getItem(jt)}catch{return null}},Oe)).filter(Boolean);if(Oe())return;ae.current={work:ve,books:De};const Me=h??Ie.default_collection??(Ie.core_books&&Ie.core_books.length>0?"core":"all"),yt=Me==="core"&&Array.isArray(Ie.core_books)&&Ie.core_books.length>0?"core":Me??"all";K(hi(ve,De,yt))}catch{if(Oe())return;K(null),ae.current=null}finally{Oe()||q(!1)}},[N]),ke=g.useRef({initialDetail:i,initialEntry:o});ke.current={initialDetail:i,initialEntry:o},g.useEffect(()=>{let Q=!1;be.current++,q(!1);const ve=me=>{me.type==="collection"?O(e):me.type==="work"?(me.version_graph||N.getLineageGraph)&&je(e,me):me.type==="book"&&br(me)&&ie(e)},Ae=ke.current;let Oe=null;if(ee&&ee.id===e)Oe=ee;else if(Ae.initialDetail&&Ae.initialDetail.id===e){const me={...Ae.initialDetail},Te=Ae.initialEntry??yr(e,me);b&&b(Te,me),Oe={entry:Te,detail:me}}return Oe?(ce(!1),le(me=>me.length?[]:me),te(null),K(null),ae.current=null,D(Oe.entry),he(Oe.detail),M(!1),ve(Oe.detail),()=>{Q=!0}):((async()=>{M(!0),ce(!1),D(null),he(null),le([]),te(null),K(null),ae.current=null;try{const me=await N.getItem(e);if(Q)return;if(!me){ce(!0);return}const Te=me;let De=null;if(N.getEntry&&(De=await N.getEntry(e),Q))return;De||(De=yr(e,Te)),b&&b(De,Te),D(De),he(Te),ve(Te)}catch{Q||ce(!0)}finally{Q||M(!1)}})(),()=>{Q=!0})},[e,N,ee,b,O,je,ie]),g.useEffect(()=>{const Q=ae.current;!Q||!h||K(hi(Q.work,Q.books,h))},[h]);const P=[];if(V){if(P.push({key:"basic",label:A.detailTab.basicInfo}),V.type==="collection"){Be&&ge.length===0&&P.push({key:"catalog:loading",label:`${A.detailTab.catalog}…`});for(const Q of ge)P.push({key:`catalog:${Q.resource_id}`,label:Q.short_name?`${Y(Q.short_name)}${A.detailTab.catalogSuffix}`:A.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&P.push({key:s,label:A.detailTab.fullText}),V.type==="work"&&(xe||L)&&P.push({key:"lineage",label:L?`${A.detailTab.lineage}…`:A.detailTab.lineage});for(const Q of $)(Q.position??"before-feedback")==="before-feedback"&&Q.shouldShow(V)&&P.push({key:Q.key,label:Q.label});C&&s==="feedback"&&P.push({key:"feedback",label:A.detailTab.feedback});for(const Q of $)Q.position==="after-feedback"&&Q.shouldShow(V)&&P.push({key:Q.key,label:Q.label})}g.useEffect(()=>{if(s!=="emendated"||!V)return;a("basic");const Q=setTimeout(()=>{var ve;(ve=document.getElementById("studies"))==null||ve.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(Q)},[s,V,a]);const fe=se&&V&&w?w({activeTab:s,activeJuan:Ce,entry:se,detail:V}):null,oe=g.useMemo(()=>{var Ie;if(!V)return null;const ve=(V.authors??[]).map(me=>{const Te=co(me.role);return`${me.dynasty?`〔${Y(me.dynasty)}〕`:""}${Y(me.name)}${Te?` ${Y(Te)}`:""}`}).join(" · ");let Ae=!1;try{Ae=Se.extractStatus(V.id)==="draft"}catch{}if(V.type==="book"){const me=V;return{title:Y(me.title),subtitle:me.edition?Y(me.edition):ve||void 0,aside:[Ae?A.status.draft:"",ve&&me.edition?ve:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(V.type==="collection"){const me=V;return{title:Y(me.title),subtitle:Y(Bt(me,A.unit.juan))||void 0,aside:[(Ie=me.publication_info)==null?void 0:Ie.year,Ae?A.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:ve||void 0}}if(V.type==="entity"){const me=V,Te=Me=>Me==null?"":Me<0?F("detail.bce",{n:-Me}):String(Me),De=me.birth_year!=null||me.death_year!=null?`${Te(me.birth_year)||"?"}—${Te(me.death_year)||"?"}`:"";return{title:Y(me.primary_name||me.title),subtitle:[me.dynasty?`〔${Y(me.dynasty)}〕`:"",De].filter(Boolean).join(" ")||void 0,aside:Ae?A.status.draft:void 0,secondLine:void 0}}const Oe=Y(Bt(V,A.unit.juan));return{title:Y(V.title),subtitle:[Oe,ve].filter(Boolean).join(" · ")||void 0,aside:[Wy(A,V.subtype),Ae?A.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[V,Y,A,F]),we=V&&br(V)?"text":null,Le=()=>{We(null),a("fulltext")};let He=null;if(V&&j){const Q=j({detail:V,kind:we});Q&&(He=t.jsx(zr,{href:Q}))}else we&&(He=t.jsx(zr,{onClick:Le}));const Ge=Q=>{if(!V)return null;const ve=Q.replace(/\.[^.]+$/,"");if(j){const Ae=j({detail:V,kind:we,juan:ve});return Ae?{href:Ae}:null}return{onClick:()=>{We(ve),a("fulltext")}}},Ye=new Set($.map(Q=>Q.key)),Xe=P.filter(Q=>Q.key.startsWith("catalog:")&&Q.key!=="catalog:loading"||Q.key==="lineage"&&!!xe&&!L||Ye.has(Q.key)).map(Q=>({key:Q.key,label:Q.label,onClick:()=>a(Q.key)})),I=()=>{var Q;return V?V.type==="work"?t.jsx(md,{data:V,transport:N,onNavigate:x,renderLink:S,readAction:He,railTop:k,railLinks:Xe}):V.type==="book"?t.jsx(xd,{data:V,transport:N,onNavigate:x,renderLink:S,readAction:He,fullText:Fe,fullTextPending:br(V)&&!!N.getTextManifest&&H!==V.id,chapterLink:Ge,railTop:k,railLinks:Xe}):V.type==="collection"?t.jsx(bd,{data:V,catalog:(Q=ge[0])==null?void 0:Q.data,transport:N,onNavigate:x,renderLink:S,readAction:He,railTop:k,railLinks:Xe,catalogAction:ge.length>0?t.jsxs("a",{href:"#catalog",onClick:ve=>{ve.preventDefault(),a(`catalog:${ge[0].resource_id}`)},children:[Y(A.detailTab.collectionCatalog)," →"]}):null}):t.jsx(yd,{data:V,transport:N,onNavigate:x,renderLink:S,railTop:k,railLinks:Xe}):null},U=()=>{var ve,Ae,Oe;if(!se||!V)return null;if(s==="basic"||s==="emendated")return I();if(typeof s=="string"&&s.startsWith("catalog:")){const Ie=(ve=ge.find(me=>`catalog:${me.resource_id}`===s))==null?void 0:ve.data;return t.jsx(no,{data:Ie,onNavigate:x,renderLink:S})}if(s==="collated"||s==="fulltext")return t.jsx(Bo,{id:e,transport:N,chapter:Ce,onLocationChange:Ie=>We(Ie.chapter),onNavigate:x});if(s==="lineage"){if(!xe)return t.jsx("div",{style:{color:r("label-fg"),padding:"24px 0"},children:F(L?"detail.loading":"detail.noLineageGraph")});const Ie=V.type==="work"?V:null;return t.jsx(Do,{graph:xe,renderLink:S,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:f,collection:h??((Ae=Ie==null?void 0:Ie.version_graph)==null?void 0:Ae.default_collection),onCollectionChange:u,collectionsAvailable:(Oe=Ie==null?void 0:Ie.version_graph)==null?void 0:Oe.collections,collectionCounts:(()=>{var Me,yt,jt,on,Wt,J,Re;if(!Ie)return;const me={},Te=((Me=ae.current)==null?void 0:Me.books)??[];me.all=(((yt=Ie._books)==null?void 0:yt.length)??0)-(((on=(jt=Ie.version_graph)==null?void 0:jt.excluded_books)==null?void 0:on.length)??0);const De=(Wt=Ie.version_graph)==null?void 0:Wt.collections;if(De)for(const qe of Object.keys(De))me[qe]=hi(Ie,Te,qe).nodes.filter(ot=>ot.kind==="book"&&!ot.bridge).length;return me.core==null&&((Re=(J=Ie.version_graph)==null?void 0:J.core_books)!=null&&Re.length)&&(me.core=Ie.version_graph.core_books.length),me})()})}if(s==="feedback"&&C)return t.jsx(cd,{resourceId:e,apiUrl:_});const Q=$.find(Ie=>Ie.key===s);return Q?Q.render({detail:V,entry:se,transport:N,onNavigate:x}):null};if(Z)return t.jsx(In,{style:{minHeight:E,...W},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((Q,ve)=>t.jsx("div",{style:{height:ve===1?40:16,width:Q,opacity:.35,background:r("rule")}},ve))})});if(_e||!V||!se||!oe)return t.jsx(In,{style:{minHeight:E,...W},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:r("label-fg"),fontSize:14},children:F("detail.notFound")})});const pe=s==="basic"||s==="emendated",$e=[{label:y??A.detailTab.backToIndex,onClick:v}];if(V.type==="book"&&V.work_id){const Q=V.work_id;$e.push({label:A.indexType.work,id:Q,onClick:()=>x==null?void 0:x(Q)})}$e.push({label:A.indexType[V.type]});const ye=s==="collated"||s==="fulltext",ue=typeof z=="string"?A.status[z.trim()]??z:z,Ve=t.jsx(jc,{left:t.jsxs(t.Fragment,{children:[ue,ue?" · ":"",t.jsx(By,{id:V.id,label:A.label.id,copied:A.action.copied,copyLabel:A.action.copy})]}),right:t.jsxs(t.Fragment,{children:[C&&!pe&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg")},children:A.detailTab.submitVersion}),fe&&t.jsx("a",{href:fe.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:r("meta-fg")},children:A.detailTab.dataLicense})]})});return pe?t.jsx("div",{className:B,children:t.jsxs(In,{grid:!0,style:{minHeight:E,...W},children:[t.jsx(Nr,{breadcrumb:t.jsx(Ir,{items:$e}),actions:t.jsxs(t.Fragment,{children:[!T&&t.jsx(Dr,{style:{border:"none",background:"transparent"}}),!T&&fe&&t.jsx(Ur,{...fe})]})}),I(),Ve]})}):t.jsx("div",{className:B,children:t.jsxs(In,{wide:ye,style:{minHeight:E,...W},children:[t.jsx(Nr,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(fo,{char:"籍"}),t.jsx(Ir,{items:$e})]}),actions:t.jsxs(t.Fragment,{children:[!T&&t.jsx(Dr,{}),C&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),className:"bim-d-ui",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg")},children:A.detailTab.feedback}),!T&&fe&&t.jsx(Ur,{...fe})]})}),t.jsx(pc,{...oe,aside:ye?t.jsxs("button",{type:"button",onClick:()=>a("basic"),className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("accent"),borderBottom:`1px solid ${r("rule")}`},children:[F("detail.workInfo")," →"]}):oe.aside}),!ye&&P.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:P.map(Q=>t.jsx(uc,{label:Q.label,active:Q.key===s||pe&&Q.key==="basic",onClick:()=>a(Q.key)},Q.key))}),t.jsx("div",{style:{marginTop:!ye&&P.length>1?8:0},children:U()}),Ve]})})};function By({id:e,label:n,copied:i,copyLabel:o}){const[s,a]=g.useState(!1);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[t.jsxs("span",{children:[n," ",e]}),t.jsx("button",{type:"button",onClick:()=>{var l;(l=navigator.clipboard)==null||l.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},title:s?i:o,"aria-label":s?i:o,className:"bim-d-hit",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:14,minWidth:32,minHeight:32,display:"inline-flex",alignItems:"center",justifyContent:"center",color:r("aux-fg")},children:s?"✓":"⧉"})]})}function Wy(e,n){return n?e.workSubtype[n]??n:""}const dp=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],Oi="zhusha",Fi="bim-theme";function pp(e){return e==="zhusha"||e==="indigo"||e==="ink"}function Hi(e){return pp(e)?e:Oi}function Oy(){try{return Hi(window.localStorage.getItem(Fi))}catch{return Oi}}function up(e){try{window.localStorage.setItem(Fi,e)}catch{}}function mp(e){const n=Hi(e);return document.documentElement.setAttribute("data-theme",n),n}function hp(){return Hi(document.documentElement.getAttribute("data-theme"))}const Fy=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Jo="airy",Di="bim-layout";function gp(e){return e==="airy"||e==="boxed"}function Ui(e){return gp(e)?e:Jo}function Hy(){try{return Ui(window.localStorage.getItem(Di))}catch{return Jo}}function Dy(e){try{window.localStorage.setItem(Di,e)}catch{}}function Uy(e){const n=Ui(e);return document.documentElement.setAttribute("data-layout",n),n}function Vy(){return Ui(document.documentElement.getAttribute("data-layout"))}const Gy=`try{var t=localStorage.getItem(${JSON.stringify(Fi)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Di)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,Yy={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},qy=({onChange:e,style:n})=>{const{t:i}=ne(),[o,s]=g.useState(Oi);g.useEffect(()=>{s(hp())},[]);const a=l=>{s(mp(l)),up(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":i("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:dp.map(l=>{const d=o===l.name;return t.jsx("button",{type:"button",role:"radio","aria-checked":d,"aria-label":i(`common.theme.${l.name}`),title:i(`common.theme.${l.name}`),onClick:()=>a(l.name),style:{width:28,height:44,padding:0,border:0,background:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:t.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:"50%",boxSizing:"border-box",background:r(Yy[l.name]),boxShadow:d?`0 0 0 2px ${r("page-bg")}, 0 0 0 3.5px ${r("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=Se.BidLink;exports.BookIndexError=Se.BookIndexError;exports.BookIndexManager=Se.BookIndexManager;exports.BookIndexStorage=Se.BookIndexStorage;exports.BundleStorage=Se.BundleStorage;exports.ConfigError=Se.ConfigError;exports.GithubStorage=Se.GithubStorage;exports.IdGenerationError=Se.IdGenerationError;exports.IdGenerator=Se.IdGenerator;exports.LocalStorage=Se.LocalStorage;exports.MigrationError=Se.MigrationError;exports.StorageError=Se.StorageError;exports.VARIANT_CHARS=Se.VARIANT_CHARS;exports.base36Decode=Se.base36Decode;exports.base36Encode=Se.base36Encode;exports.base58Decode=Se.base58Decode;exports.buildId=Se.buildId;exports.buildPromotionMap=Se.buildPromotionMap;exports.cleanName=Se.cleanName;exports.decodeId=Se.decodeId;exports.decodeIdString=Se.decodeIdString;exports.encodeId=Se.encodeId;exports.extractIdFromUrl=Se.extractIdFromUrl;exports.extractStatus=Se.extractStatus;exports.extractType=Se.extractType;exports.isChapterSegment=Se.isChapterSegment;exports.isTextKey=Se.isTextKey;exports.matchChapterAcrossVersions=Se.matchChapterAcrossVersions;exports.normalizeCatalog=Se.normalizeCatalog;exports.normalizeVariants=Se.normalizeVariants;exports.parseId=Se.parseId;exports.pickTextVersion=Se.pickTextVersion;exports.shardOf=Se.shardOf;exports.smartDecode=Se.smartDecode;exports.textVersionLabel=Se.textVersionLabel;exports.validateResource=Se.validateResource;exports.VARIANT_SUPPLEMENT=Za.VARIANT_SUPPLEMENT;exports.Badge=ji;exports.BidUrlProvider=Wp;exports.BookDetailLayout=Py;exports.BookPage=xd;exports.Breadcrumb=Ir;exports.CATALOG_ALL_ID=Lt;exports.CATALOG_CSS=jd;exports.CATALOG_NARROW_QUERY=Uo;exports.CATALOG_PAGE_SIZE=Vo;exports.CATALOG_UNCLASSIFIED_ID=Qt;exports.CLASSIFICATIONS=Ci;exports.COMMON_TRADITIONAL_CHARS=ll;exports.CardFoot=Hn;exports.CatalogPage=xy;exports.CatalogPager=Cd;exports.CatalogTree=kd;exports.CheckFilter=lc;exports.Chip=mc;exports.ChipWall=Ah;exports.CollectionCatalog=no;exports.CollectionPage=bd;exports.CreateEntityDialog=td;exports.DEFAULT_LAYOUT=Jo;exports.DEFAULT_META_HOME_LINKS=Vd;exports.DEFAULT_READER_PREFS=ro;exports.DEFAULT_READ_HOME_LINKS=zd;exports.DEFAULT_THEME=Oi;exports.DETAIL_CSS=dc;exports.DYNASTY_GROUPS=$i;exports.Dash=Fh;exports.DataTable=Ph;exports.DetailFooter=jc;exports.DetailGrid=On;exports.DetailHeader=pc;exports.EMPTY_FILTERS=_i;exports.ENTITY_TEXT_CSS=Eo;exports.EmendatedBySection=Nl;exports.EmptyNote=qh;exports.EntityDetail=Sl;exports.EntityMark=Ao;exports.EntityPage=yd;exports.EntityPickerDialog=id;exports.EntitySelector=ed;exports.EntityText=mf;exports.ExpandRow=Hh;exports.ExtLink=Kh;exports.FEEDBACK_FAB_OFFSET_VAR=Wr;exports.FILTER_SUPPORT=gl;exports.FONT_SIZE_STEPS=Et;exports.FactList=Ih;exports.FeedbackButton=rb;exports.FeedbackDialog=ad;exports.FeedbackForm=ld;exports.FeedbackList=Wo;exports.FeedbackTab=cd;exports.FilterChip=uc;exports.FormInput=ht;exports.FormTextArea=tn;exports.GUJI_MARKDOWN_FIELD=fh;exports.GUJI_TABLE_NOTATION=vc;exports.GlyphBadge=fo;exports.GujiInteractiveReader=Qf;exports.GujiTable=yo;exports.GujiTextViewer=Mo;exports.GujiWarpCanvas=Ro;exports.HomePage=Pr;exports.ImagePanel=wr;exports.IndexApp=Jf;exports.IndexBrowser=kr;exports.IndexDetail=to;exports.IndexEditor=rd;exports.IndexView=Ux;exports.IntroGrid=Nh;exports.LAYOUTS=Fy;exports.LAYOUT_STORAGE_KEY=Di;exports.LOSS_OPTIONS=hl;exports.LocaleContext=Tt;exports.LocaleProvider=mu;exports.LocaleToggle=Dr;exports.META_HOME_CSS=Ud;exports.META_HOME_SECTION_IDS=lp;exports.MetaCatalogTable=Qd;exports.MetaCollectionGroups=ip;exports.MetaDataLicense=ap;exports.MetaHomeView=Iy;exports.MetaLine=it;exports.MetaLineageCards=op;exports.MetaOnlineSites=sp;exports.MetaPeopleTimeline=rp;exports.MetaRecentPanel=Zd;exports.MetaRelatedCatalogs=tp;exports.MetaTypeChips=qd;exports.ModeIndicator=dl;exports.MoreButton=Lh;exports.MoreLink=ho;exports.PAGE_MAX_WIDTH=pi;exports.PERIOD_NARROW_SHARE=Ed;exports.PageFrame=In;exports.Quote=Uh;exports.READER_CSS=Pl;exports.READ_HOME_CSS=Yo;exports.READ_HOME_NARROW_QUERY=Vn;exports.READ_HOME_SECTION_IDS=Dd;exports.READ_PERIOD_LABELS=vy;exports.RECENT_IDS_STORAGE_KEY=un;exports.ROLE_CLASS_ORDER=Zl;exports.ReadButton=zr;exports.ReadFamousWorks=Od;exports.ReadHomeView=wy;exports.ReadPeriodBand=Fd;exports.ReadPicks=Md;exports.ReadPieces=Hd;exports.ReadSection=ct;exports.ReadShelf=Ko;exports.ReadSibu=Xo;exports.ReadStats=Ad;exports.ReadTopicGroup=Bd;exports.ReadTopics=Wd;exports.ReaderMdText=So;exports.ReaderShell=Vl;exports.ReaderToc=Wl;exports.RelationPanel=Jc;exports.RepoSourceLink=Ur;exports.ResourceEditor=jr;exports.ResourceGroup=Vh;exports.ResourceLine=Gh;exports.ResourceList=Zr;exports.ResourceRow=bc;exports.SEARCH_VIEW_STORAGE_KEY=Jr;exports.SEVEN_PAVILIONS_KEY=np;exports.SNIPPET_MARK_END=el;exports.SNIPPET_MARK_START=Qa;exports.SORTABLE_TYPES=ml;exports.SearchInput=ul;exports.SearchResults=vl;exports.Sec=rt;exports.Section=kt;exports.SectionHead=Rh;exports.SideList=en;exports.SmartBidInput=mi;exports.SourceEditor=Kc;exports.StripWarpRenderer=Lr;exports.SummaryCard=Fn;exports.THEMES=dp;exports.THEME_INIT_SCRIPT=Gy;exports.THEME_STORAGE_KEY=Fi;exports.TRADITIONAL_ALLOWLIST=cl;exports.TabFilter=Ei;exports.TableHead=Bh;exports.TableRow=Wh;exports.TagRow=yc;exports.TagRows=Yh;exports.TextButton=Eh;exports.TextReader=Bo;exports.ThemeToggle=qy;exports.TopStrip=Nr;exports.VersionLineageGraph=fd;exports.VersionLineageList=gd;exports.VersionLineageView=Do;exports.VolumeChips=Mh;exports.VolumeLinks=xo;exports.WorkCard=_d;exports.WorkCardGrid=Td;exports.WorkCatalog=cx;exports.WorkPage=md;exports.WorkRow=$d;exports.adaptCharCord=lx;exports.adaptEntityJson=Ec;exports.adaptPunctJson=tx;exports.applyLayout=Uy;exports.applyTheme=mp;exports.authorsLine=Wi;exports.bookIndexUriToId=Er;exports.bookMarkingOf=ko;exports.bucketResources=ao;exports.buildCatalogTree=ly;exports.buildCollectionTable=ec;exports.buildLineageGraph=hi;exports.buildMeiliFilter=Iu;exports.buildPageUrl=Kr;exports.buildParagraphBlocks=Tc;exports.buildVersionRow=Kl;exports.buildVersionTable=Xl;exports.canParagraphize=bi;exports.catalogNodeIdOf=sy;exports.catalogNodeIdsOf=ay;exports.catalogPageCount=uy;exports.catalogTotal=Go;exports.classificationPath=Un;exports.clearAllRecentIds=Qr;exports.compareCatalogCards=py;exports.computeVersionPartition=ch;exports.countActiveFilters=Ti;exports.createTextApi=Rl;exports.currentLayout=Vy;exports.currentTheme=hp;exports.defaultEntityHref=Hc;exports.defaultWorkLink=wd;exports.deriveDating=sh;exports.deriveEditionType=nc;exports.deriveEra=Wn;exports.deriveYear=Ni;exports.deriveYearRange=so;exports.detailToEditor=sd;exports.detectGenre=Ai;exports.displayAuthorRole=co;exports.editorToDetail=Dx;exports.eraRank=Cr;exports.filtersFromParams=Ru;exports.filtersToParams=gi;exports.findCatalogPath=pn;exports.findTraditionalChars=fu;exports.firstAuthorText=qo;exports.flattenTitles=Rr;exports.flattenToc=Ul;exports.fmtCount=Ke;exports.formatHitCount=ci;exports.formatTemplate=gt;exports.formatVolumeRange=Ri;exports.getDisplayNameFromUrl=fn;exports.getMessages=bn;exports.getStartPage=qr;exports.getT=yn;exports.getTypeGroupKey=Gr;exports.groupRelatedWorks=ah;exports.gujiInlineToPlain=sc;exports.hasActiveFilters=fl;exports.hasGujiMarkdownV02=xh;exports.hasGujiTableNotation=Xh;exports.hasSearchOptions=Tu;exports.iiifVolumeOf=nx;exports.isCountedChar=_o;exports.isLayoutName=gp;exports.isThemeName=pp;exports.lineageHref=Gd;exports.loadRecentIds=Ut;exports.measureText=Bt;exports.mergeVolumeResources=Yr;exports.normalizeEra=nt;exports.normalizeLayout=Ui;exports.normalizeRole=lo;exports.normalizeTheme=Hi;exports.normalizeVolumeIndex=Ln;exports.normalizeVolumes=il;exports.numberToChinese=tc;exports.paginationItems=vd;exports.parseChineseNumber=fi;exports.parseGujiInline=oc;exports.parseGujiTable=wc;exports.parseSourceString=Xc;exports.pct=Zo;exports.periodLevel=Rd;exports.pickReaderVersion=Dl;exports.readStoredLayout=Hy;exports.readStoredTheme=Oy;exports.readerVersionOptionLabel=_r;exports.remapPlainOffsets=Lc;exports.removeRecentId=kl;exports.renderFullTextBody=sg;exports.renderProperNames=Ic;exports.renderReaderInline=wo;exports.resolveRecentEntry=eo;exports.resourceHref=xn;exports.resourceNote=Ii;exports.resultTabFromParam=Hu;exports.resultTabToParam=Du;exports.roleFacets=Jl;exports.rowNo=Oh;exports.sameFilters=Eu;exports.saveRecentId=vr;exports.segmentEntities=Ac;exports.shelfColumns=Nd;exports.sortFor=zu;exports.sortYear=xi;exports.spineHeight=Id;exports.splitFullTextTables=bo;exports.splitHighlightSnippet=Vr;exports.splitTableRow=kc;exports.storeLayout=Dy;exports.storeTheme=up;exports.stringifySources=Zc;exports.summaryFromEntry=Oc;exports.summaryFromItem=Wc;exports.timelineLayout=Yd;exports.toCatalogWorkCard=dy;exports.transportSummaryLoader=Fc;exports.typeSupportsFilters=xl;exports.useBidUrl=tt;exports.useChapterWarpData=Vc;exports.useConvert=Pe;exports.useEntitySummaryLoader=Lo;exports.useI18n=ne;exports.useReaderPrefs=Hl;exports.useRecentEntries=Kd;exports.useT=Ee;exports.validateLineageGraph=Cb;exports.volumeStats=ki;exports.withDefaultLinks=Vt;exports.withMetaLinks=Gt;exports.yearText=vi;
|
|
1913
|
+
`,Gd={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function Gt(e){return{...Gd,...e??{}}}function Yd(e,n){if(e.lineage)return e.lineage(n);const i=e.item(n),o=i.indexOf("#"),[s,a]=o<0?[i,""]:[i.slice(0,o),i.slice(o)];return`${s}${s.includes("?")?"&":"?"}tab=lineage${a}`}function Zo(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function qd(e){const n=e.filter(p=>Number.isFinite(p.birth_year)||Number.isFinite(p.death_year)),i=e.filter(p=>!n.includes(p));if(!n.length)return{min:0,max:0,placed:[],missing:i};const o=p=>{const h=Number.isFinite(p.birth_year)?p.birth_year:p.death_year-50,u=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(h,u),Math.max(h,u)]},s=n.map(o),a=Math.min(...s.map(p=>p[0])),l=Math.max(...s.map(p=>p[1])),d=Math.max(1,l-a),c=n.map((p,h)=>({p,from:s[h][0],to:s[h][1]})).sort((p,h)=>p.from-h.from).map(p=>({...p,left:(p.from-a)/d*100,width:Math.max(.8,(p.to-p.from)/d*100)}));return{min:a,max:l,placed:c,missing:i}}function vi(e,n=yn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function Ty(e){return{read:e.item,work:e.item,node:e.node}}function Kd({counts:e,links:n}){const{t:i}=ne(),o=n==null?void 0:n.type;if(!o)return null;const s=[["all",i("metaHome.typeAll"),null],["work",i("metaHome.typeLabel.work"),e.works],["book",i("metaHome.typeLabel.book"),e.books],["collection",i("metaHome.typeLabel.collection"),e.collections],["entity",i("metaHome.typeLabel.entity"),e.entities]];return t.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":i("metaHome.typeChipsLabel"),children:s.map(([a,l,d])=>t.jsx("li",{children:t.jsxs("a",{href:o(a),children:[t.jsx("b",{children:l}),d!=null&&d>0&&t.jsx("small",{children:Ke(d)})]})},a))})}function Xd(e,n=5){const[i,o]=g.useState(null);g.useEffect(()=>{let a=!1;const l=Ut().slice(0,n);if(!l.length||!e){o([]);return}return Promise.all(l.map(d=>eo(e,d))).then(d=>{a||o(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=g.useCallback(()=>{Qr(),o([])},[]);return{entries:i,clear:s}}function zy(e,n,i){const o=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return o?i(o):Zd(e.type,n)}function Zd(e,n){return n(`metaHome.typeLabel.${e}`)}function Jd({entries:e,onClear:n,links:i}){const{t:o,convert:s}=ne(),a=Gt(i);return t.jsxs("aside",{className:"bim-mh-recent","aria-labelledby":"bim-mh-recent-h",children:[t.jsxs("div",{className:"bim-mh-recent-h",children:[t.jsx("h2",{id:"bim-mh-recent-h",children:o("metaHome.recentTitle")}),e&&e.length>0&&n&&t.jsx("button",{type:"button",onClick:n,children:o("metaHome.recentClear")})]}),e&&e.length>0&&t.jsx("ol",{children:e.map(l=>t.jsx("li",{children:t.jsxs("a",{href:a.item(l.id),"aria-label":o("metaHome.recentItemLabel",{type:l.type?Zd(l.type,o):"",title:s(l.title)}),children:[t.jsx("i",{className:"bim-mh-ty","aria-hidden":"true",children:l.type?o(`metaHome.typeShort.${l.type}`):""}),t.jsx("span",{children:s(l.title)}),t.jsx("small",{"aria-hidden":"true",children:zy(l,o,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:o("metaHome.recentEmpty")})]})}function Qd(e,n,i,o=!1){return o&&(e==="done"||e==="in_progress")?n(`metaHome.siteStatus.${e}`):e==="done"||e==="in_progress"||e==="todo"?n(`metaHome.status.${e}`):i(e)}function ep({rows:e,links:n}){const{t:i,convert:o}=ne(),s=Gt(n);return e.length?t.jsx("div",{className:"bim-mh-tbl-wrap",tabIndex:0,role:"region","aria-label":i("metaHome.catalogTitle"),children:t.jsxs("table",{className:"bim-mh-tbl",children:[t.jsxs("caption",{children:[i("metaHome.catalogTitle"),t.jsx("small",{children:i("metaHome.catalogNote")})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:i("metaHome.colCatalog")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:i("metaHome.colRecords")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:i("metaHome.colMatched")}),t.jsx("th",{scope:"col",children:i("metaHome.colProgress")}),t.jsx("th",{scope:"col",children:i("metaHome.colStatus")})]})}),t.jsx("tbody",{children:e.map(a=>{const l=Zo(a.imported,a.total),d=a.work_id??a.collection_id,c=o(a.edition?`${a.name}·${a.edition}`:a.name);return t.jsxs("tr",{children:[t.jsx("th",{scope:"row",children:d?t.jsx("a",{href:s.item(d),children:c}):c}),t.jsx("td",{className:"bim-mh-r",children:Ke(a.total)}),t.jsx("td",{className:"bim-mh-r",children:Ke(a.imported)}),t.jsx("td",{children:t.jsxs("span",{className:"bim-mh-meter",children:[t.jsx("i",{"aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[l,"%"]})]})}),t.jsx("td",{children:a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:Qd(a.status,i,o)})})]},a.id||a.name)})})]})}):null}function tp({items:e,links:n,label:i}){const{convert:o}=ne();return t.jsx("ul",{className:"bim-rh-rows","aria-label":i?o(i):void 0,children:e.map(s=>t.jsx("li",{children:t.jsxs("a",{href:n.item(s.id),children:[t.jsx("span",{className:"bim-rh-t",children:o(s.title)}),s.sub&&t.jsx("small",{children:o(s.sub)})]})},s.id))})}function np({works:e,links:n}){const{t:i}=ne(),[o,s]=g.useState(!1);if(!e.length)return null;const a=Bn(e.length);return t.jsxs("div",{className:"bim-rh-grp","data-cap":a?"":void 0,"data-open":o?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[i("metaHome.relatedTitle"),t.jsx("small",{children:i("metaHome.relatedNote")})]}),t.jsx(tp,{items:e.map(l=>({id:l.id,title:l.title,sub:Wi(l)||void 0})),links:Gt(n)}),a&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":o,onClick:()=>s(l=>!l),children:o?i("action.collapse"):i("metaHome.allNWorks",{n:e.length})})]})}const ip="siku_qige";function Ny({group:e,links:n}){const{t:i,convert:o}=ne(),[s,a]=g.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":Bn(e.items.length)?"":void 0,"data-open":s?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[o(e.label),t.jsx("small",{className:"bim-rh-num",children:i("metaHome.nKinds",{n:e.items.length})})]}),t.jsx(tp,{items:e.items,links:n,label:e.label}),Bn(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":s,onClick:()=>a(l=>!l),children:s?i("action.collapse"):i("metaHome.allNKinds",{n:e.items.length})})]})}function rp({groups:e,links:n}){const{t:i,convert:o}=ne(),s=Gt(n);if(!e.length)return null;const a=e.find(c=>c.key===ip),l=e.filter(c=>c!==a),d=c=>{var p;return((p=c.match(/(文[^\s·・閣阁]+)[閣阁]/))==null?void 0:p[1])??c};return t.jsxs(t.Fragment,{children:[a&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:"bim-rh-gt",children:[o(a.label),t.jsx("small",{children:o(a.items.map(c=>d(c.title)).join("、"))})]}),t.jsx("ul",{className:"bim-mh-ge","aria-label":o(a.label),children:a.items.map(c=>t.jsx("li",{children:t.jsxs("a",{href:s.item(c.id),"aria-label":o(c.title),title:o(c.title),children:[t.jsx("span",{"aria-hidden":"true",children:o(d(c.title))}),d(c.title)!==c.title&&t.jsx("small",{"aria-hidden":"true",children:i("metaHome.pavilion")})]})},c.id))})]}),l.length>0&&t.jsx("div",{className:"bim-mh-cg",style:a?void 0:{marginTop:0},children:l.map(c=>t.jsx(Ny,{group:c,links:s},c.key))})]})}const qa=34,Ka=13;function Xa(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?vi(e.birth_year,n):"?"}–${e.death_year!=null?vi(e.death_year,n):"?"}`}function Iy(e,n){const i=n-e,o=i>1200?300:i>400?100:50,s=[];for(let a=Math.ceil(e/o)*o;a<=n;a+=o)s.push(a);return s}function op({people:e,links:n}){const{t:i,convert:o}=ne(),s=Gt(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=qd(e),p=[],h=d.map(m=>{const f=m.left>70,x=f?Math.min(m.left,m.left+m.width-Ka):m.left;let v=0;for(;p[v]!=null&&p[v]>x;)v++;return p[v]=f?m.left+m.width:m.left+Math.max(m.width,Ka),{...m,lane:v,end:f}}),u=Math.max(1,l-a);return t.jsxs(t.Fragment,{children:[h.length>0&&t.jsxs("div",{className:"bim-mh-tl",children:[t.jsx("ul",{className:"bim-mh-tl-rows",style:{height:p.length*qa+10},children:h.map(m=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":m.end?"":void 0,style:{left:`${m.left}%`,top:m.lane*qa+4,width:`${Math.max(m.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(m.p.id),children:[o(m.p.name),t.jsx("small",{className:"bim-rh-num",children:Xa(m.p,i)})]})]},m.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:Iy(a,l).map(m=>t.jsx("span",{style:{left:`${(m-a)/u*100}%`},children:vi(m,i)},m))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":h.length?void 0:"",children:(h.length?e:c).map(m=>t.jsx("li",{children:t.jsxs("a",{href:s.item(m.id),children:[t.jsx("span",{children:o(m.name)}),t.jsx("small",{className:"bim-rh-num",children:[m.dynasty?o(m.dynasty):"",Xa(m,i)].filter(Boolean).join(" ")})]})},m.id))}),c.length>0&&h.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:i("metaHome.missingLife",{names:o(c.map(m=>m.name).join("、"))})})]})}const Ry=t.jsxs("svg",{width:"54",height:"34",viewBox:"0 0 54 34",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:[t.jsx("circle",{cx:"27",cy:"5",r:"3.5"}),t.jsx("circle",{cx:"10",cy:"29",r:"3.5"}),t.jsx("circle",{cx:"27",cy:"29",r:"3.5"}),t.jsx("circle",{cx:"44",cy:"29",r:"3.5"}),t.jsx("path",{d:"M27 8.5v17M27 15H10v10.5M27 15h17v10.5"})]});function sp({works:e,links:n}){const{t:i,convert:o}=ne(),s=Gt(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=Wi(a);return t.jsx("li",{children:t.jsxs("a",{href:Yd(s,a.id),children:[Ry,t.jsx("b",{children:o(a.title)}),l&&t.jsx("small",{children:o(l)}),t.jsx("span",{children:i("metaHome.viewLineage")})]})},a.id)})}):null}function ap({sites:e}){const{t:n,convert:i}=ne(),o=e.filter(a=>a.status!=="todo"&&a.total>0),s=e.filter(a=>!o.includes(a));return e.length?t.jsxs(t.Fragment,{children:[o.length>0&&t.jsx("ul",{className:"bim-mh-cov",children:o.map(a=>{const l=Zo(a.imported,a.total);return t.jsxs("li",{children:[a.url?t.jsx("a",{href:a.url,rel:"noopener noreferrer",target:"_blank",children:i(a.name)}):t.jsx("span",{children:i(a.name)}),t.jsx("span",{className:"bim-mh-bar","aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[`${Ke(a.imported)} / ${Ke(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:Qd(a.status,n,i,!0)})]})]},a.id||a.name)})}),s.length>0&&t.jsx("p",{className:"bim-mh-todo",children:n("metaHome.plannedSites",{names:i(s.map(a=>a.name).join("、"))})})]}):null}const Za=["extant","partially_extant","lost","unknown"];function lp({stats:e,links:n,version:i,repoUrl:o,downloadHref:s}){const{t:a}=ne(),l=["works","books","collections","entities","has_image","has_text","article","poem"].map(p=>[e[p],a(`metaHome.stat.${p}`)]).filter(([p])=>p>0),d=n==null?void 0:n.loss,c=Za.some(p=>{var h;return(((h=e.loss)==null?void 0:h[p])??0)>0});return t.jsxs("div",{className:"bim-mh-data",children:[l.length>0&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.dataScale")}),t.jsx("ul",{className:"bim-mh-nums",children:l.map(([p,h])=>t.jsxs("li",{children:[t.jsx("b",{className:"bim-rh-num",children:Ke(p)}),t.jsx("span",{children:h})]},h))})]}),d&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.byLoss")}),t.jsx("ul",{className:"bim-mh-loss",children:Za.map(p=>{var m;const h=((m=e.loss)==null?void 0:m[p])??0,u=a(`metaHome.lossNote.${p}`);return t.jsx("li",{children:t.jsxs("a",{href:d(p),children:[a(`metaHome.loss.${p}`),t.jsx("small",{className:"bim-rh-num",children:c&&h>0?a("metaHome.lossCount",{n:Ke(h),note:u}):u})]})},p)})})]}),t.jsxs("div",{className:"bim-mh-lic",children:[t.jsxs("p",{children:[t.jsx("span",{className:"bim-mh-cc0",children:"CC0"}),a("metaHome.license")]}),t.jsxs("p",{children:[a("metaHome.repo"),o?t.jsx("a",{href:o,children:t.jsx("code",{children:"book-index"})}):t.jsx("code",{children:"book-index"}),a("metaHome.repoNote")]}),i&&t.jsxs("p",{children:[a("metaHome.version"),t.jsx("code",{children:i})]}),s&&t.jsx("p",{children:t.jsx("a",{href:s,children:a("metaHome.download")})})]})]})}const cp={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function Ey({sections:e,links:n,head:i,transport:o,catalogHref:s,collectionsHref:a,entitiesHref:l,version:d,repoUrl:c,downloadHref:p,className:h}){var k,$;const{t:u}=ne(),m=e,f=Gt(n),x=Ty(f),v=cp,y=Xd(o),S={zhi:!!((k=m.shelf)!=null&&k.items.length)||m.catalog_progress.length>0||m.related_catalogs.length>0,sibu:m.bu.length>0||m.unclassified>0,cong:m.collection_groups.length>0,people:m.bibliographers.length>0,lineage:m.lineage.length>0,sites:m.sites.length>0,data:!0},b=Object.keys(v).filter(C=>S[C]),w=C=>u(`metaHome.nav.${C}`),j=(C,_)=>C?t.jsx("a",{className:"bim-rh-more",href:C,children:_}):void 0;return t.jsxs("div",{className:h?`bim-rh bim-mh ${h}`:"bim-rh bim-mh",children:[t.jsx("style",{children:Yo+Vd}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[i,t.jsx(Kd,{counts:m.counts,links:n})]}),o&&t.jsx(Jd,{entries:y.entries,onClear:y.clear,links:n})]}),b.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":u("metaHome.navLabel"),children:t.jsx("ul",{children:b.map(C=>t.jsx("li",{children:t.jsx("a",{href:`#${v[C]}`,children:w(C)})},C))})}),t.jsxs("div",{className:"bim-rh-main",children:[S.zhi&&t.jsxs(ct,{id:v.zhi,title:w("zhi"),sub:u("metaHome.zhiSub"),children:[m.shelf&&m.shelf.items.length>0&&t.jsx(Ko,{topic:{key:"shelf",label:m.shelf.label,shelf:!0,items:m.shelf.items},links:x,showTitle:!1,legendCount:m.shelf.items.some(C=>C.records)?u("metaHome.shelfLegendCount"):null,legendExtra:[u("metaHome.shelfLegendClick")]}),(m.catalog_progress.length>0||m.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:($=m.shelf)!=null&&$.items.length?void 0:{marginTop:0},children:[t.jsx(ep,{rows:m.catalog_progress,links:n}),t.jsx(np,{works:m.related_catalogs,links:n})]})]}),S.sibu&&t.jsx(ct,{id:v.sibu,title:w("sibu"),sub:u("metaHome.sibuSub"),more:j(s,u("metaHome.toCatalog")),children:t.jsx(Xo,{bu:m.bu,unclassified:m.unclassified,links:x,unclassifiedNote:u("metaHome.unclassifiedNote")})}),S.cong&&t.jsx(ct,{id:v.cong,title:w("cong"),sub:u("metaHome.congSub"),more:j(a,u("metaHome.allNKindsMore",{n:Ke(m.counts.collections)})),children:t.jsx(rp,{groups:m.collection_groups,links:n})}),S.people&&t.jsx(ct,{id:v.people,title:w("people"),sub:u("metaHome.peopleSub"),more:j(l,u("metaHome.allNPeopleMore",{n:Ke(m.counts.entities)})),children:t.jsx(op,{people:m.bibliographers,links:n})}),S.lineage&&t.jsx(ct,{id:v.lineage,title:w("lineage"),sub:u("metaHome.lineageSub"),children:t.jsx(sp,{works:m.lineage,links:n})}),S.sites&&t.jsx(ct,{id:v.sites,title:w("sites"),sub:u("metaHome.sitesSub"),children:t.jsx(ap,{sites:m.sites})}),t.jsx(ct,{id:v.data,title:w("data"),sub:u("metaHome.dataSub"),children:t.jsx(lp,{stats:m.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const dp=["_related","_catalogs","_collections","_members","_children"],Ly=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Hr=e=>Ly(e)&&!!e.h;function Ay(e){return e?dp.some(n=>{const i=e[n];return Array.isArray(i)&&i.some(Hr)}):!1}function My(e,n){const i={...e};if(!n)return i;for(const o of dp){const s=e[o];!Array.isArray(s)||!s.some(Hr)||(i[o]=s.map(a=>{var c;if(!Hr(a)||typeof a.title=="string"&&a.title)return a;const l=a.id??a.bid,d=l?(c=n[l])==null?void 0:c.title:void 0;return d?{...a,title:d}:a}))}return i}function Py(e){let n=null;const i=()=>e.getHubs?(n??(n=e.getHubs().catch(()=>null)),n):Promise.resolve(null);return new Proxy(e,{get(o,s){if(s==="getItem")return async l=>{const d=await o.getItem(l);return d&&My(d,Ay(d)?await i():null)};const a=Reflect.get(o,s,o);return typeof a=="function"?a.bind(o):a}})}const Dr=({style:e})=>{const n=g.useContext(Tt),{t:i}=ne();if(!n)return null;const{locale:o,setLocale:s}=n,a=o==="zh-Hant",l=()=>s(a?"zh-Hans":"zh-Hant");return t.jsxs("button",{type:"button",onClick:l,title:i(a?"common.toHans":"common.toHant"),style:{display:"inline-flex",alignItems:"center",gap:"2px",padding:"4px 10px",fontSize:"13px",fontWeight:500,lineHeight:1,border:`1px solid ${r("border")}`,borderRadius:"4px",background:r("bg"),color:r("fg"),cursor:"pointer",userSelect:"none",...e},children:[t.jsx("span",{style:{color:a?r("primary"):void 0,fontWeight:a?700:400},children:i("common.localeShortHant")}),t.jsx("span",{style:{opacity:.3},children:"/"}),t.jsx("span",{style:{color:a?void 0:r("primary"),fontWeight:a?400:700},children:i("common.localeShortHans")})]})},Ur=({href:e,label:n,size:i=16,className:o,style:s})=>{const{t:a}=ne(),l=n??a("common.repoSourceLink");return t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:l,"aria-label":l,className:o,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:i+8,height:i+8,borderRadius:4,color:r("desc-fg"),textDecoration:"none",transition:"color 120ms, background 120ms",...s},onMouseEnter:d=>{d.currentTarget.style.color=r("fg")},onMouseLeave:d=>{d.currentTarget.style.color=r("desc-fg")},children:t.jsx("svg",{width:i,height:i,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8a8 8 0 0 0 5.47 7.59c.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})})};function br(e){const n=e.text_count;return typeof n=="number"&&n>0}function yr(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function By(e,n){if(!n)return!1;const i=n.id;return i===void 0||i===e}const Wy=({id:e,transport:n,initialDetail:i,initialEntry:o,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:h,onLineageCollectionChange:u,initialPage:m=1,selectedLineageNodeId:f,onNavigate:x,onBack:v,backLabel:y,renderLink:S,enrichDetail:b,getSourceLink:w,readLink:j,railTop:k,extraTabs:$=[],showFeedbackTab:C=!0,feedbackApiUrl:_,height:E,footerExtra:z,hideHeaderControls:T=!1,className:B,style:W})=>{const N=g.useMemo(()=>Py(n),[n]),A=Ee(),{t:F,convert:Y}=ne(),[te]=g.useState(()=>{if(!By(e,i))return null;const ee={...i},ve=o??yr(e,ee);return b&&b(ve,ee),{id:e,entry:ve,detail:ee}}),[se,D]=g.useState((te==null?void 0:te.entry)??null),[V,he]=g.useState((te==null?void 0:te.detail)??null),[Z,M]=g.useState(!te),[_e,ce]=g.useState(!1),[ge,le]=g.useState([]),[Be,ze]=g.useState(!1),[Fe,Q]=g.useState(null),[H,G]=g.useState(null),[xe,K]=g.useState(null),[L,q]=g.useState(!1),ae=g.useRef(null),be=g.useRef(0),[X,re]=g.useState(null),Ce=l!==void 0?l:X,We=g.useCallback(ee=>{d?d(ee):re(ee)},[d]),O=g.useCallback(async ee=>{if(!N.getCollectionCatalogs&&!N.getCollectionCatalog){le([]);return}ze(!0);try{if(N.getCollectionCatalogs)le(await N.getCollectionCatalogs(ee)||[]);else if(N.getCollectionCatalog){const ve=await N.getCollectionCatalog(ee);le(ve?[{resource_id:"",data:ve}]:[])}}catch{le([])}finally{ze(!1)}},[N]),ie=g.useCallback(async ee=>{var ve,Ae;if(!N.getTextManifest||!N.getTextIndex){Q(null),G(ee);return}try{const Oe=Se.pickTextVersion(await N.getTextManifest(ee)),Ie=Oe?await N.getTextIndex(ee,Oe.key):null;Q(Ie&&Ie.chapters.length>0?{chapters:Ie.chapters.map(me=>({n:me.n,title:me.title,file:me.file})),source:{name:((ve=Ie.source)==null?void 0:ve.name)??(Oe==null?void 0:Oe.source_name),license:((Ae=Ie.source)==null?void 0:Ae.license)??(Oe==null?void 0:Oe.license)??void 0}}:null)}catch{Q(null)}finally{G(ee)}},[N]),je=g.useCallback(async(ee,ve)=>{const Ae=++be.current,Oe=()=>Ae!==be.current;q(!0);try{if(N.getLineageGraph){const jt=await N.getLineageGraph(ee);if(Oe())return;jt&&K(jt)}const Ie=ve.version_graph;if(!Ie||!Ie.enabled){xe||K(null),ae.current=null;return}const me=po(ve),De=(await Pi(me,Mi,async jt=>{try{return await N.getItem(jt)}catch{return null}},Oe)).filter(Boolean);if(Oe())return;ae.current={work:ve,books:De};const Me=h??Ie.default_collection??(Ie.core_books&&Ie.core_books.length>0?"core":"all"),yt=Me==="core"&&Array.isArray(Ie.core_books)&&Ie.core_books.length>0?"core":Me??"all";K(hi(ve,De,yt))}catch{if(Oe())return;K(null),ae.current=null}finally{Oe()||q(!1)}},[N]),ke=g.useRef({initialDetail:i,initialEntry:o});ke.current={initialDetail:i,initialEntry:o},g.useEffect(()=>{let ee=!1;be.current++,q(!1);const ve=me=>{me.type==="collection"?O(e):me.type==="work"?(me.version_graph||N.getLineageGraph)&&je(e,me):me.type==="book"&&br(me)&&ie(e)},Ae=ke.current;let Oe=null;if(te&&te.id===e)Oe=te;else if(Ae.initialDetail&&Ae.initialDetail.id===e){const me={...Ae.initialDetail},Te=Ae.initialEntry??yr(e,me);b&&b(Te,me),Oe={entry:Te,detail:me}}return Oe?(ce(!1),le(me=>me.length?[]:me),Q(null),K(null),ae.current=null,D(Oe.entry),he(Oe.detail),M(!1),ve(Oe.detail),()=>{ee=!0}):((async()=>{M(!0),ce(!1),D(null),he(null),le([]),Q(null),K(null),ae.current=null;try{const me=await N.getItem(e);if(ee)return;if(!me){ce(!0);return}const Te=me;let De=null;if(N.getEntry&&(De=await N.getEntry(e),ee))return;De||(De=yr(e,Te)),b&&b(De,Te),D(De),he(Te),ve(Te)}catch{ee||ce(!0)}finally{ee||M(!1)}})(),()=>{ee=!0})},[e,N,te,b,O,je,ie]),g.useEffect(()=>{const ee=ae.current;!ee||!h||K(hi(ee.work,ee.books,h))},[h]);const P=[];if(V){if(P.push({key:"basic",label:A.detailTab.basicInfo}),V.type==="collection"){Be&&ge.length===0&&P.push({key:"catalog:loading",label:`${A.detailTab.catalog}…`});for(const ee of ge)P.push({key:`catalog:${ee.resource_id}`,label:ee.short_name?`${Y(ee.short_name)}${A.detailTab.catalogSuffix}`:A.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&P.push({key:s,label:A.detailTab.fullText}),V.type==="work"&&(xe||L)&&P.push({key:"lineage",label:L?`${A.detailTab.lineage}…`:A.detailTab.lineage});for(const ee of $)(ee.position??"before-feedback")==="before-feedback"&&ee.shouldShow(V)&&P.push({key:ee.key,label:ee.label});C&&s==="feedback"&&P.push({key:"feedback",label:A.detailTab.feedback});for(const ee of $)ee.position==="after-feedback"&&ee.shouldShow(V)&&P.push({key:ee.key,label:ee.label})}g.useEffect(()=>{if(s!=="emendated"||!V)return;a("basic");const ee=setTimeout(()=>{var ve;(ve=document.getElementById("studies"))==null||ve.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(ee)},[s,V,a]);const fe=se&&V&&w?w({activeTab:s,activeJuan:Ce,entry:se,detail:V}):null,oe=g.useMemo(()=>{var Ie;if(!V)return null;const ve=(V.authors??[]).map(me=>{const Te=co(me.role);return`${me.dynasty?`〔${Y(me.dynasty)}〕`:""}${Y(me.name)}${Te?` ${Y(Te)}`:""}`}).join(" · ");let Ae=!1;try{Ae=Se.extractStatus(V.id)==="draft"}catch{}if(V.type==="book"){const me=V;return{title:Y(me.title),subtitle:me.edition?Y(me.edition):ve||void 0,aside:[Ae?A.status.draft:"",ve&&me.edition?ve:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(V.type==="collection"){const me=V;return{title:Y(me.title),subtitle:Y(Bt(me,A.unit.juan))||void 0,aside:[(Ie=me.publication_info)==null?void 0:Ie.year,Ae?A.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:ve||void 0}}if(V.type==="entity"){const me=V,Te=Me=>Me==null?"":Me<0?F("detail.bce",{n:-Me}):String(Me),De=me.birth_year!=null||me.death_year!=null?`${Te(me.birth_year)||"?"}—${Te(me.death_year)||"?"}`:"";return{title:Y(me.primary_name||me.title),subtitle:[me.dynasty?`〔${Y(me.dynasty)}〕`:"",De].filter(Boolean).join(" ")||void 0,aside:Ae?A.status.draft:void 0,secondLine:void 0}}const Oe=Y(Bt(V,A.unit.juan));return{title:Y(V.title),subtitle:[Oe,ve].filter(Boolean).join(" · ")||void 0,aside:[Fy(A,V.subtype),Ae?A.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[V,Y,A,F]),we=V&&br(V)?"text":null,Le=()=>{We(null),a("fulltext")};let He=null;if(V&&j){const ee=j({detail:V,kind:we});ee&&(He=t.jsx(zr,{href:ee}))}else we&&(He=t.jsx(zr,{onClick:Le}));const Ge=ee=>{if(!V)return null;const ve=ee.replace(/\.[^.]+$/,"");if(j){const Ae=j({detail:V,kind:we,juan:ve});return Ae?{href:Ae}:null}return{onClick:()=>{We(ve),a("fulltext")}}},Ye=new Set($.map(ee=>ee.key)),Xe=P.filter(ee=>ee.key.startsWith("catalog:")&&ee.key!=="catalog:loading"||ee.key==="lineage"&&!!xe&&!L||Ye.has(ee.key)).map(ee=>({key:ee.key,label:ee.label,onClick:()=>a(ee.key)})),I=()=>{var ee;return V?V.type==="work"?t.jsx(hd,{data:V,transport:N,onNavigate:x,renderLink:S,readAction:He,railTop:k,railLinks:Xe}):V.type==="book"?t.jsx(bd,{data:V,transport:N,onNavigate:x,renderLink:S,readAction:He,fullText:Fe,fullTextPending:br(V)&&!!N.getTextManifest&&H!==V.id,chapterLink:Ge,railTop:k,railLinks:Xe}):V.type==="collection"?t.jsx(yd,{data:V,catalog:(ee=ge[0])==null?void 0:ee.data,transport:N,onNavigate:x,renderLink:S,readAction:He,railTop:k,railLinks:Xe,catalogAction:ge.length>0?t.jsxs("a",{href:"#catalog",onClick:ve=>{ve.preventDefault(),a(`catalog:${ge[0].resource_id}`)},children:[Y(A.detailTab.collectionCatalog)," →"]}):null}):t.jsx(jd,{data:V,transport:N,onNavigate:x,renderLink:S,railTop:k,railLinks:Xe}):null},U=()=>{var ve,Ae,Oe;if(!se||!V)return null;if(s==="basic"||s==="emendated")return I();if(typeof s=="string"&&s.startsWith("catalog:")){const Ie=(ve=ge.find(me=>`catalog:${me.resource_id}`===s))==null?void 0:ve.data;return t.jsx(no,{data:Ie,onNavigate:x,renderLink:S})}if(s==="collated"||s==="fulltext")return t.jsx(Bo,{id:e,transport:N,chapter:Ce,onLocationChange:Ie=>We(Ie.chapter),onNavigate:x});if(s==="lineage"){if(!xe)return t.jsx("div",{style:{color:r("label-fg"),padding:"24px 0"},children:F(L?"detail.loading":"detail.noLineageGraph")});const Ie=V.type==="work"?V:null;return t.jsx(Do,{graph:xe,renderLink:S,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:f,collection:h??((Ae=Ie==null?void 0:Ie.version_graph)==null?void 0:Ae.default_collection),onCollectionChange:u,collectionsAvailable:(Oe=Ie==null?void 0:Ie.version_graph)==null?void 0:Oe.collections,collectionCounts:(()=>{var Me,yt,jt,on,Wt,J,Re;if(!Ie)return;const me={},Te=((Me=ae.current)==null?void 0:Me.books)??[];me.all=(((yt=Ie._books)==null?void 0:yt.length)??0)-(((on=(jt=Ie.version_graph)==null?void 0:jt.excluded_books)==null?void 0:on.length)??0);const De=(Wt=Ie.version_graph)==null?void 0:Wt.collections;if(De)for(const qe of Object.keys(De))me[qe]=hi(Ie,Te,qe).nodes.filter(ot=>ot.kind==="book"&&!ot.bridge).length;return me.core==null&&((Re=(J=Ie.version_graph)==null?void 0:J.core_books)!=null&&Re.length)&&(me.core=Ie.version_graph.core_books.length),me})()})}if(s==="feedback"&&C)return t.jsx(dd,{resourceId:e,apiUrl:_});const ee=$.find(Ie=>Ie.key===s);return ee?ee.render({detail:V,entry:se,transport:N,onNavigate:x}):null};if(Z)return t.jsx(In,{style:{minHeight:E,...W},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((ee,ve)=>t.jsx("div",{style:{height:ve===1?40:16,width:ee,opacity:.35,background:r("rule")}},ve))})});if(_e||!V||!se||!oe)return t.jsx(In,{style:{minHeight:E,...W},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:r("label-fg"),fontSize:14},children:F("detail.notFound")})});const pe=s==="basic"||s==="emendated",$e=[{label:y??A.detailTab.backToIndex,onClick:v}];if(V.type==="book"&&V.work_id){const ee=V.work_id;$e.push({label:A.indexType.work,id:ee,onClick:()=>x==null?void 0:x(ee)})}$e.push({label:A.indexType[V.type]});const ye=s==="collated"||s==="fulltext",ue=typeof z=="string"?A.status[z.trim()]??z:z,Ve=t.jsx(vc,{left:t.jsxs(t.Fragment,{children:[ue,ue?" · ":"",t.jsx(Oy,{id:V.id,label:A.label.id,copied:A.action.copied,copyLabel:A.action.copy})]}),right:t.jsxs(t.Fragment,{children:[C&&!pe&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg")},children:A.detailTab.submitVersion}),fe&&t.jsx("a",{href:fe.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:r("meta-fg")},children:A.detailTab.dataLicense})]})});return pe?t.jsx("div",{className:B,children:t.jsxs(In,{grid:!0,style:{minHeight:E,...W},children:[t.jsx(Nr,{breadcrumb:t.jsx(Ir,{items:$e}),actions:t.jsxs(t.Fragment,{children:[!T&&t.jsx(Dr,{style:{border:"none",background:"transparent"}}),!T&&fe&&t.jsx(Ur,{...fe})]})}),I(),Ve]})}):t.jsx("div",{className:B,children:t.jsxs(In,{wide:ye,style:{minHeight:E,...W},children:[t.jsx(Nr,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(fo,{char:"籍"}),t.jsx(Ir,{items:$e})]}),actions:t.jsxs(t.Fragment,{children:[!T&&t.jsx(Dr,{}),C&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),className:"bim-d-ui",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg")},children:A.detailTab.feedback}),!T&&fe&&t.jsx(Ur,{...fe})]})}),t.jsx(uc,{...oe,aside:ye?t.jsxs("button",{type:"button",onClick:()=>a("basic"),className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("accent"),borderBottom:`1px solid ${r("rule")}`},children:[F("detail.workInfo")," →"]}):oe.aside}),!ye&&P.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:P.map(ee=>t.jsx(mc,{label:ee.label,active:ee.key===s||pe&&ee.key==="basic",onClick:()=>a(ee.key)},ee.key))}),t.jsx("div",{style:{marginTop:!ye&&P.length>1?8:0},children:U()}),Ve]})})};function Oy({id:e,label:n,copied:i,copyLabel:o}){const[s,a]=g.useState(!1);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[t.jsxs("span",{children:[n," ",e]}),t.jsx("button",{type:"button",onClick:()=>{var l;(l=navigator.clipboard)==null||l.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},title:s?i:o,"aria-label":s?i:o,className:"bim-d-hit",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:14,minWidth:32,minHeight:32,display:"inline-flex",alignItems:"center",justifyContent:"center",color:r("aux-fg")},children:s?"✓":"⧉"})]})}function Fy(e,n){return n?e.workSubtype[n]??n:""}const pp=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],Oi="zhusha",Fi="bim-theme";function up(e){return e==="zhusha"||e==="indigo"||e==="ink"}function Hi(e){return up(e)?e:Oi}function Hy(){try{return Hi(window.localStorage.getItem(Fi))}catch{return Oi}}function mp(e){try{window.localStorage.setItem(Fi,e)}catch{}}function hp(e){const n=Hi(e);return document.documentElement.setAttribute("data-theme",n),n}function gp(){return Hi(document.documentElement.getAttribute("data-theme"))}const Dy=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Jo="airy",Di="bim-layout";function fp(e){return e==="airy"||e==="boxed"}function Ui(e){return fp(e)?e:Jo}function Uy(){try{return Ui(window.localStorage.getItem(Di))}catch{return Jo}}function Vy(e){try{window.localStorage.setItem(Di,e)}catch{}}function Gy(e){const n=Ui(e);return document.documentElement.setAttribute("data-layout",n),n}function Yy(){return Ui(document.documentElement.getAttribute("data-layout"))}const qy=`try{var t=localStorage.getItem(${JSON.stringify(Fi)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Di)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,Ky={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},Xy=({onChange:e,style:n})=>{const{t:i}=ne(),[o,s]=g.useState(Oi);g.useEffect(()=>{s(gp())},[]);const a=l=>{s(hp(l)),mp(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":i("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:pp.map(l=>{const d=o===l.name;return t.jsx("button",{type:"button",role:"radio","aria-checked":d,"aria-label":i(`common.theme.${l.name}`),title:i(`common.theme.${l.name}`),onClick:()=>a(l.name),style:{width:28,height:44,padding:0,border:0,background:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:t.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:"50%",boxSizing:"border-box",background:r(Ky[l.name]),boxShadow:d?`0 0 0 2px ${r("page-bg")}, 0 0 0 3.5px ${r("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=Se.BidLink;exports.BookIndexError=Se.BookIndexError;exports.BookIndexManager=Se.BookIndexManager;exports.BookIndexStorage=Se.BookIndexStorage;exports.BundleStorage=Se.BundleStorage;exports.ConfigError=Se.ConfigError;exports.GithubStorage=Se.GithubStorage;exports.IdGenerationError=Se.IdGenerationError;exports.IdGenerator=Se.IdGenerator;exports.LocalStorage=Se.LocalStorage;exports.MigrationError=Se.MigrationError;exports.StorageError=Se.StorageError;exports.VARIANT_CHARS=Se.VARIANT_CHARS;exports.base36Decode=Se.base36Decode;exports.base36Encode=Se.base36Encode;exports.base58Decode=Se.base58Decode;exports.buildId=Se.buildId;exports.buildPromotionMap=Se.buildPromotionMap;exports.cleanName=Se.cleanName;exports.decodeId=Se.decodeId;exports.decodeIdString=Se.decodeIdString;exports.encodeId=Se.encodeId;exports.extractIdFromUrl=Se.extractIdFromUrl;exports.extractStatus=Se.extractStatus;exports.extractType=Se.extractType;exports.isChapterSegment=Se.isChapterSegment;exports.isTextKey=Se.isTextKey;exports.matchChapterAcrossVersions=Se.matchChapterAcrossVersions;exports.normalizeCatalog=Se.normalizeCatalog;exports.normalizeVariants=Se.normalizeVariants;exports.parseId=Se.parseId;exports.pickTextVersion=Se.pickTextVersion;exports.shardOf=Se.shardOf;exports.smartDecode=Se.smartDecode;exports.textVersionLabel=Se.textVersionLabel;exports.validateResource=Se.validateResource;exports.VARIANT_SUPPLEMENT=Ja.VARIANT_SUPPLEMENT;exports.Badge=ji;exports.BidUrlProvider=Op;exports.BookDetailLayout=Wy;exports.BookPage=bd;exports.Breadcrumb=Ir;exports.CATALOG_ALL_ID=Lt;exports.CATALOG_CSS=vd;exports.CATALOG_NARROW_QUERY=Uo;exports.CATALOG_PAGE_SIZE=Vo;exports.CATALOG_UNCLASSIFIED_ID=Qt;exports.CLASSIFICATIONS=Ci;exports.COMMON_TRADITIONAL_CHARS=cl;exports.CardFoot=Hn;exports.CatalogPage=yy;exports.CatalogPager=Td;exports.CatalogTree=wd;exports.CheckFilter=cc;exports.Chip=hc;exports.ChipWall=Mh;exports.CollectionCatalog=no;exports.CollectionPage=yd;exports.CreateEntityDialog=nd;exports.DEFAULT_LAYOUT=Jo;exports.DEFAULT_META_HOME_LINKS=Gd;exports.DEFAULT_READER_PREFS=ro;exports.DEFAULT_READ_HOME_LINKS=Nd;exports.DEFAULT_THEME=Oi;exports.DETAIL_CSS=pc;exports.DYNASTY_GROUPS=$i;exports.Dash=Hh;exports.DataTable=Bh;exports.DetailFooter=vc;exports.DetailGrid=On;exports.DetailHeader=uc;exports.EMPTY_FILTERS=_i;exports.ENTITY_TEXT_CSS=Eo;exports.EmendatedBySection=Il;exports.EmptyNote=Kh;exports.EntityDetail=_l;exports.EntityMark=Ao;exports.EntityPage=jd;exports.EntityPickerDialog=rd;exports.EntitySelector=td;exports.EntityText=hf;exports.ExpandRow=Dh;exports.ExtLink=Xh;exports.FEEDBACK_FAB_OFFSET_VAR=Wr;exports.FILTER_SUPPORT=fl;exports.FONT_SIZE_STEPS=Et;exports.FactList=Rh;exports.FeedbackButton=sb;exports.FeedbackDialog=ld;exports.FeedbackForm=cd;exports.FeedbackList=Wo;exports.FeedbackTab=dd;exports.FilterChip=mc;exports.FormInput=ht;exports.FormTextArea=tn;exports.GUJI_MARKDOWN_FIELD=xh;exports.GUJI_TABLE_NOTATION=kc;exports.GlyphBadge=fo;exports.GujiInteractiveReader=tx;exports.GujiTable=yo;exports.GujiTextViewer=Mo;exports.GujiWarpCanvas=Ro;exports.HomePage=Pr;exports.ImagePanel=wr;exports.IndexApp=ex;exports.IndexBrowser=kr;exports.IndexDetail=to;exports.IndexEditor=od;exports.IndexView=Gx;exports.IntroGrid=Ih;exports.LAYOUTS=Dy;exports.LAYOUT_STORAGE_KEY=Di;exports.LOSS_OPTIONS=gl;exports.LocaleContext=Tt;exports.LocaleProvider=hu;exports.LocaleToggle=Dr;exports.META_HOME_CSS=Vd;exports.META_HOME_SECTION_IDS=cp;exports.MetaCatalogTable=ep;exports.MetaCollectionGroups=rp;exports.MetaDataLicense=lp;exports.MetaHomeView=Ey;exports.MetaLine=it;exports.MetaLineageCards=sp;exports.MetaOnlineSites=ap;exports.MetaPeopleTimeline=op;exports.MetaRecentPanel=Jd;exports.MetaRelatedCatalogs=np;exports.MetaTypeChips=Kd;exports.ModeIndicator=pl;exports.MoreButton=Ah;exports.MoreLink=ho;exports.PAGE_MAX_WIDTH=pi;exports.PERIOD_NARROW_SHARE=Ld;exports.PageFrame=In;exports.Quote=Vh;exports.READER_CSS=Bl;exports.READ_HOME_CSS=Yo;exports.READ_HOME_NARROW_QUERY=Vn;exports.READ_HOME_SECTION_IDS=Ud;exports.READ_PERIOD_LABELS=wy;exports.RECENT_IDS_STORAGE_KEY=un;exports.ROLE_CLASS_ORDER=Jl;exports.ReadButton=zr;exports.ReadFamousWorks=Fd;exports.ReadHomeView=_y;exports.ReadPeriodBand=Hd;exports.ReadPicks=Pd;exports.ReadPieces=Dd;exports.ReadSection=ct;exports.ReadShelf=Ko;exports.ReadSibu=Xo;exports.ReadStats=Md;exports.ReadTopicGroup=Wd;exports.ReadTopics=Od;exports.ReaderMdText=So;exports.ReaderShell=Gl;exports.ReaderToc=Ol;exports.RelationPanel=Qc;exports.RepoSourceLink=Ur;exports.ResourceEditor=jr;exports.ResourceGroup=Gh;exports.ResourceLine=Yh;exports.ResourceList=Zr;exports.ResourceRow=yc;exports.SEARCH_VIEW_STORAGE_KEY=Jr;exports.SEVEN_PAVILIONS_KEY=ip;exports.SNIPPET_MARK_END=tl;exports.SNIPPET_MARK_START=el;exports.SORTABLE_TYPES=hl;exports.SearchInput=ml;exports.SearchResults=kl;exports.Sec=rt;exports.Section=kt;exports.SectionHead=Eh;exports.SideList=en;exports.SmartBidInput=mi;exports.SourceEditor=Xc;exports.StripWarpRenderer=Lr;exports.SummaryCard=Fn;exports.THEMES=pp;exports.THEME_INIT_SCRIPT=qy;exports.THEME_STORAGE_KEY=Fi;exports.TRADITIONAL_ALLOWLIST=dl;exports.TabFilter=Ei;exports.TableHead=Wh;exports.TableRow=Oh;exports.TagRow=jc;exports.TagRows=qh;exports.TextButton=Lh;exports.TextReader=Bo;exports.ThemeToggle=Xy;exports.TopStrip=Nr;exports.VersionLineageGraph=xd;exports.VersionLineageList=fd;exports.VersionLineageView=Do;exports.VolumeChips=Ph;exports.VolumeLinks=xo;exports.WorkCard=$d;exports.WorkCardGrid=zd;exports.WorkCatalog=px;exports.WorkPage=hd;exports.WorkRow=Cd;exports.adaptCharCord=dx;exports.adaptEntityJson=Lc;exports.adaptPunctJson=ix;exports.applyLayout=Gy;exports.applyTheme=hp;exports.authorsLine=Wi;exports.bookIndexUriToId=Er;exports.bookMarkingOf=ko;exports.bucketResources=ao;exports.buildCatalogTree=dy;exports.buildCollectionTable=tc;exports.buildLineageGraph=hi;exports.buildMeiliFilter=Ru;exports.buildPageUrl=Kr;exports.buildParagraphBlocks=zc;exports.buildVersionRow=Xl;exports.buildVersionTable=Zl;exports.canParagraphize=bi;exports.catalogNodeIdOf=ly;exports.catalogNodeIdsOf=cy;exports.catalogPageCount=hy;exports.catalogTotal=Go;exports.classificationPath=Un;exports.clearAllRecentIds=Qr;exports.compareCatalogCards=my;exports.computeVersionPartition=dh;exports.countActiveFilters=Ti;exports.createTextApi=El;exports.currentLayout=Yy;exports.currentTheme=gp;exports.defaultEntityHref=Dc;exports.defaultWorkLink=Sd;exports.deriveDating=ah;exports.deriveEditionType=ic;exports.deriveEra=Wn;exports.deriveYear=Ni;exports.deriveYearRange=so;exports.detailToEditor=ad;exports.detectGenre=Ai;exports.displayAuthorRole=co;exports.editorToDetail=Vx;exports.eraRank=Cr;exports.filtersFromParams=Eu;exports.filtersToParams=gi;exports.findCatalogPath=pn;exports.findTraditionalChars=xu;exports.firstAuthorText=qo;exports.flattenTitles=Rr;exports.flattenToc=Vl;exports.fmtCount=Ke;exports.formatHitCount=ci;exports.formatTemplate=gt;exports.formatVolumeRange=Ri;exports.getDisplayNameFromUrl=fn;exports.getMessages=bn;exports.getStartPage=qr;exports.getT=yn;exports.getTypeGroupKey=Gr;exports.groupRelatedWorks=lh;exports.gujiInlineToPlain=ac;exports.hasActiveFilters=xl;exports.hasGujiMarkdownV02=bh;exports.hasGujiTableNotation=Zh;exports.hasSearchOptions=zu;exports.iiifVolumeOf=rx;exports.isCountedChar=_o;exports.isLayoutName=fp;exports.isThemeName=up;exports.lineageHref=Yd;exports.loadRecentIds=Ut;exports.measureText=Bt;exports.mergeVolumeResources=Yr;exports.normalizeEra=nt;exports.normalizeLayout=Ui;exports.normalizeRole=lo;exports.normalizeTheme=Hi;exports.normalizeVolumeIndex=Ln;exports.normalizeVolumes=rl;exports.numberToChinese=nc;exports.paginationItems=kd;exports.parseChineseNumber=fi;exports.parseGujiInline=sc;exports.parseGujiTable=Sc;exports.parseSourceString=Zc;exports.pct=Zo;exports.periodLevel=Ed;exports.pickReaderVersion=Ul;exports.readStoredLayout=Uy;exports.readStoredTheme=Hy;exports.readerVersionOptionLabel=_r;exports.remapPlainOffsets=Ac;exports.removeRecentId=wl;exports.renderFullTextBody=ag;exports.renderProperNames=Rc;exports.renderReaderInline=wo;exports.resolveRecentEntry=eo;exports.resourceHref=xn;exports.resourceNote=Ii;exports.resultTabFromParam=Du;exports.resultTabToParam=Uu;exports.roleFacets=Ql;exports.rowNo=Fh;exports.sameFilters=Lu;exports.saveRecentId=vr;exports.segmentEntities=Mc;exports.shelfColumns=Id;exports.sortFor=Nu;exports.sortYear=xi;exports.spineHeight=Rd;exports.splitFullTextTables=bo;exports.splitHighlightSnippet=Vr;exports.splitTableRow=wc;exports.storeLayout=Vy;exports.storeTheme=mp;exports.stringifySources=Jc;exports.summaryFromEntry=Fc;exports.summaryFromItem=Oc;exports.timelineLayout=qd;exports.toCatalogWorkCard=uy;exports.transportSummaryLoader=Hc;exports.typeSupportsFilters=bl;exports.useBidUrl=tt;exports.useChapterWarpData=Gc;exports.useConvert=Pe;exports.useEntitySummaryLoader=Lo;exports.useI18n=ne;exports.useReaderPrefs=Dl;exports.useRecentEntries=Xd;exports.useT=Ee;exports.validateLineageGraph=zb;exports.volumeStats=ki;exports.withDefaultLinks=Vt;exports.withMetaLinks=Gt;exports.yearText=vi;
|