book-index-ui 0.65.2 → 0.66.0-rc.1
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 +75 -75
- package/dist/index.d.ts +134 -2
- package/dist/index.js +6846 -7033
- package/dist/storage-entry-Bw_cAsLM.cjs +2 -0
- package/dist/{storage-entry-DuObqdka.js → storage-entry-D9rs8i1m.js} +965 -630
- package/dist/storage.cjs +1 -1
- package/dist/storage.d.ts +236 -0
- package/dist/storage.js +17 -11
- package/package.json +1 -1
- package/dist/storage-entry-h5vhXs0r.cjs +0 -2
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Gu=Object.create;var ra=Object.defineProperty;var Yu=Object.getOwnPropertyDescriptor;var Ku=Object.getOwnPropertyNames;var qu=Object.getPrototypeOf,Xu=Object.prototype.hasOwnProperty;var Zu=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Ku(n))!Xu.call(e,s)&&s!==i&&ra(e,s,{get:()=>n[s],enumerable:!(o=Yu(n,s))||o.enumerable});return e};var Ri=(e,n,i)=>(i=e!=null?Gu(qu(e)):{},Zu(n||!e||!e.__esModule?ra(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Te=require("./storage-entry-h5vhXs0r.cjs"),t=require("react/jsx-runtime"),f=require("react"),Ju=require("opencc-js/t2cn"),ql=require("./variant-supplement.cjs"),Qu=require("react-markdown"),em=require("remark-gfm"),tm=e=>`/item/${e}`,Xl=f.createContext(tm);function nm({buildUrl:e,children:n}){const i=f.useMemo(()=>e,[e]);return t.jsx(Xl.Provider,{value:i,children:n})}function kt(){return f.useContext(Xl)}const Zl="",Jl="";function Eo(e){const n=[];let i=!1,o=e;for(;o.length;){const s=i?Jl:Zl,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 Tt(e,n){return{title:e,tokens:n}}const oa='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',im=[Tt("基础(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"}}),Tt("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),Tt("提示与警告",{"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)"}}),Tt("遮罩与阴影",{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)"}}),Tt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),Tt("资源",{"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"}}),Tt("整理本(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:"中性灰:占位"}}),Tt("版本传承(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"}}),Tt("编辑器视图(主要在 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")'}}),Tt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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:"唯一的状态色块「有影印」"},"mark-bg":{value:"#fde68a",note:"专名出处:从「古籍中的出处」跳到阅读页时高亮的字、出处摘录里的专名(A12)"},"mark-flash":{value:"#f59e0b",note:"专名出处:跳到阅读页时高亮先闪一下的颜色"},"mark-soft":{value:"rgba(253, 230, 138, 0.45)",note:"专名出处:阅读页 `#e=` 时本章提到该实体的其余各处(当前一处用 mark-bg)"},"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}}),Tt('版式(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"}}),Tt("阅读器(整理本 / 全文)",{"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:"版心外边线"}}),Tt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),Tt("字体(全站无衬线,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:oa,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:oa,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],rm=Object.assign({},...im.map(e=>e.tokens)),Ql={};for(const[e,n]of Object.entries(rm))Ql[e]=`var(--bim-${e}, ${n.value})`;function r(e){const n=Ql[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function rn(e){return e.types&&e.types.length>0?e.types:[]}function om(e,n){return rn(e).includes(n)}const sm={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 am={"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 Hn(e){try{return am[new URL(e).hostname]}catch{return}}const sa={text:0,image:1,physical:2};function Ro(e){return e.length===0?"physical":[...e].sort((n,i)=>(sa[n]??99)-(sa[i]??99)).join("+")}function lm(e){return e.includes("text")&&e.includes("image")?"text+image":e[0]||"physical"}function Io(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[m,g]=p,u=`${m}|${Ro(rn(c))}`;i.has(u)||i.set(u,{base:{...c,name:m,url:"",volumes:[]},volumes:[],indices:[]});const h=i.get(u);h.volumes.push({volume:g,url:c.url||void 0,status:"found"}),h.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 ec(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 tc(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||ec(n)}))}function Qi(e){const n=tc(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 Lo(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 Ao(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 Dn(e){if(!e.url)return;const n=Lo(e.metadata);return n?Ao(e.url,n):e.url}const qt=f.createContext(null),nc=["曹霑"];function cm(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dm(e,n=nc){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(cm).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 qn=null;function ic(){if(qn)return qn;try{const e=Ju.Converter({from:"t",to:"cn"});qn=dm(n=>e(Te.normalizeVariants(n)))}catch{qn=e=>e}return qn}const pm={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:"圖片資源"}},um={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 Ct(e,n,i){return{"zh-Hant":e,"zh-Hans":n,...i?{en:i}:{}}}const mm=Ct({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:"无数据"}),er=Ct({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:"作品信息"}),gm=Ct({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:"附记"}}),fm=Ct({fact:{written:"成書",measure:"卷帙",loss:"存佚",authenticity:"真偽",forged:"偽書",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:"種版本",sameEditionCopies:"同版另藏 {n} 部:",inferredEraNote:"部分年代據版本題名推斷,非著錄原文",empty:"尚未著錄該作品的版本與書目收錄。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"歷代書目 {n} 家",tablist:"著錄書目",titleOnly:"僅著錄書名,無提要。",prev:"上一家:{name}",next:"下一家:{name}"}},{fact:{written:"成书",measure:"卷帙",loss:"存佚",authenticity:"真伪",forged:"伪书",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:"种版本",sameEditionCopies:"同版另藏 {n} 部:",inferredEraNote:"部分年代据版本题名推断,非著录原文",empty:"尚未著录该作品的版本与书目收录。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"历代书目 {n} 家",tablist:"著录书目",titleOnly:"仅著录书名,无提要。",prev:"上一家:{name}",next:"下一家:{name}"}}),hm=Ct({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:"上级丛编"}),xm=Ct({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 為自動匹配,未經人工核對",sealAlt:"{name}印影",imgCredit:"圖像:{credit}",imgLicense:"授權:{license}",imgSource:"來源"},{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 为自动匹配,未经人工核对",sealAlt:"{name}印影",imgCredit:"图像:{credit}",imgLicense:"授权:{license}",imgSource:"来源"}),bm=Ct({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",settingsShort:"設置",closeSettings:"收起設置",groupText:"文字",groupMark:"標註",groupLayout:"版面",groupMore:"更多",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:"原字",scriptOrigUnavailable:"此文本沒有規範層,無「原字」可選",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}",tocExpand:"展開",tocCollapse:"收起",searchChapters:"搜索全部章節",searchChaptersPlaceholder:"搜索全部章節…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"來源",originalSource:"本站獨立整理",charGuess:"殘字(推測)",figLabel:"圖形符號:{alt}",figPlain:"圖形符號",lacunaGuess:"闕文,推測為「{guess}」",pendingReason:"待審:{label}",upstream:"上游",chapterFailed:"無法加載章節內容",references:"參考文獻",entityDetail:"查看詳情 →"},{imagesLoading:"加载书影…",noImages:"暂无书影",noImagesHint:"这一卷还没有配上影像;接入后在此与正文逐页对看",imageAlt:"书影 第 {label} 页",prevImage:"上一页书影",nextImage:"下一页书影",back:"阅读",backAria:"返回{label}首页",skipToText:"跳到正文",settings:"阅读设置",settingsShort:"设置",closeSettings:"收起设置",groupText:"文字",groupMark:"标注",groupLayout:"版面",groupMore:"更多",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:"原字",scriptOrigUnavailable:"此文本没有规范层,无「原字」可选",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}",tocExpand:"展开",tocCollapse:"收起",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",originalSource:"本站独立整理",charGuess:"残字(推测)",figLabel:"图形符号:{alt}",figPlain:"图形符号",lacunaGuess:"阙文,推测为「{guess}」",pendingReason:"待审:{label}",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献",entityDetail:"查看详情 →"}),ym=Ct({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:"本卷条目"}),jm=Ct({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:"古籍元數據以 CC BY-SA 4.0 發布,可自由複製、改編、再發布,但須註明出處,並以相同方式共享。",repo:"數據倉庫:",repoNote:"(GitHub,CC BY-SA 4.0)",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:"古籍元数据以 CC BY-SA 4.0 发布,可自由复制、改编、再发布,但须注明出处,并以相同方式共享。",repo:"数据仓库:",repoNote:"(GitHub,CC BY-SA 4.0)",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:"规模、存佚、许可与版本"}),Mo=Ct({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:"按作者浏览全部 →"}),vm=Ct({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} 条"}),km=Ct({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:"搜索"}),wm=Ct({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:"回复"}),Sm=Ct({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:"有争议"}}),_m=Ct({title:"古籍中的出處",total:"{n} 處,見於 {b} 部書",inBook:"{n} 處",more:"再看 {n} 處",loading:"載入中…",hint:"文中寫法可能是略稱、字號;點一條到閱讀頁,人名會標出來。",examples:"摘錄",byBook:"按書看",bookLine:"{n} 處 · {c} 章",chapterLine:"{n} 處",moreBooks:"再列 {n} 部書",navLabel:"本章出處",navCount:"本章 {k}/{n} 處",prev:"上一處",next:"下一處",close:"不再標出"},{title:"古籍中的出处",total:"{n} 处,见于 {b} 部书",inBook:"{n} 处",more:"再看 {n} 处",loading:"载入中…",hint:"文中写法可能是略称、字号;点一条到阅读页,人名会标出来。",examples:"摘录",byBook:"按书看",bookLine:"{n} 处 · {c} 章",chapterLine:"{n} 处",moreBooks:"再列 {n} 部书",navLabel:"本章出处",navCount:"本章 {k}/{n} 处",prev:"上一处",next:"下一处",close:"不再标出"},{title:"Mentions in texts",total:"{n} mentions in {b} books",inBook:"{n}",more:"Show {n} more",loading:"Loading…",hint:"The text may use a short form or courtesy name. Open one to see it highlighted in the reader.",examples:"Excerpts",byBook:"By book",bookLine:"{n} in {c} chapters",chapterLine:"{n}",moreBooks:"Show {n} more books",navLabel:"Mentions in this chapter",navCount:"{k} of {n} here",prev:"Previous",next:"Next",close:"Clear highlights"}),$m={common:mm,detail:er,bookPage:gm,workPage:fm,collectionPage:hm,entityPage:xm,reader:bm,collated:ym,metaHome:jm,readHome:Mo,catalogPage:vm,searchPage:km,feedback:wm,lineage:Sm,mentions:_m};function Cm(e){const n={};for(const[i,o]of Object.entries($m))n[i]=o[e];return n}function Bt(e,n){return e.replace(/\{(\w+)\}/g,(i,o)=>String(n[o]??""))}const aa=new Map;function Un(e){let n=aa.get(e);return n||(n={...e==="zh-Hans"?um:pm,...Cm(e)},aa.set(e,n)),n}function la(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 rc(e){return(n,i)=>{const o=la(e,n)??la(Un("zh-Hant"),n)??n;return i?Bt(o,i):o}}const ca=new Map;function Vn(e){let n=ca.get(e);return n||(n=rc(Un(e)),ca.set(e,n)),n}const oc="bim-locale";function zm(){try{const e=localStorage.getItem(oc);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function Nm(e){try{localStorage.setItem(oc,e)}catch{}}const Tm="zh-Hans",Em=({locale:e,onLocaleChange:n,converter:i,children:o})=>{const[s,a]=f.useState(e??Tm),l=e??s;f.useEffect(()=>{if(e)return;const m=zm();m&&m!==s&&a(m)},[]);const d=f.useMemo(()=>l==="zh-Hans"?i??ic():null,[l,i]),c=f.useCallback(m=>{a(m),Nm(m),n==null||n(m)},[n]),p=f.useMemo(()=>({locale:l,setLocale:c,messages:Un(l),converter:d}),[l,c,d]);return t.jsx(qt.Provider,{value:p,children:o})};function Ae(){const e=f.useContext(qt);return(e==null?void 0:e.messages)??Un("zh-Hant")}const Rm=2e3;function Ge(){const e=f.useContext(qt),n=(e==null?void 0:e.locale)??"zh-Hant",i=(e==null?void 0:e.converter)??null,o=f.useRef(new Map),s=f.useRef(n),a=f.useRef(i);(s.current!==n||a.current!==i)&&(o.current.clear(),s.current=n,a.current=i);const l=f.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>=Rm){const m=o.current.keys().next().value;m!==void 0&&o.current.delete(m)}return o.current.set(d,p),p},[i]);return f.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function ae(){const e=f.useContext(qt),{convert:n,locale:i,isSimplified:o}=Ge(),s=(e==null?void 0:e.messages)??Un("zh-Hant"),a=f.useMemo(()=>e?rc(s):Vn("zh-Hant"),[e,s]);return f.useMemo(()=>({t:a,convert:n,locale:i,isSimplified:o,messages:s}),[a,n,i,o,s])}const sc=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),Im=new Set([...sc,...Object.keys(Te.VARIANT_CHARS),...Object.keys(ql.VARIANT_SUPPLEMENT)]),ac=[...nc,"切換為繁體","漢籍リポジトリ"];function Lm(e,n=ac){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)=>{Im.has(a)&&o.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),o}function Am(e,n,i){return e?e==="orig"?null:n==="zh-Hans"?i??ic():e==="hant"?Te.normalizeVariants:i:n==="zh-Hans"?i:Te.normalizeVariants}const Mm=({mode:e,children:n})=>{const i=f.useContext(qt),o=f.useMemo(()=>i&&{...i,converter:Am(e,i.locale,i.converter)},[i,e]);return t.jsx(qt.Provider,{value:o,children:n})};function Pm(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 da(e){return e==="text+image"?["text","image"]:[e]}function pa(e){const n=rn(e);return n.length===0?"text":lm(n)}function Bm(){return{id:"",name:"",url:"",types:["text"],details:""}}const no=({items:e,onChange:n,onDownload:i,downloadStatuses:o,filterType:s})=>{const a=Ae(),[l,d]=f.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}],m=k=>{if(!s)return!0;const w=rn(k);return s==="text"?w.includes("text"):s==="image"?w.includes("image")||w.includes("physical"):s==="physical"?w.includes("physical"):w.includes(s)},g=e.map((k,w)=>({item:k,originalIndex:w})).filter(({item:k})=>m(k)),u=()=>{const k=Bm();s&&(k.types=da(s)),n([...e,k]),d(e.length)},h=k=>{n(e.filter((w,v)=>v!==k)),d(null)},x=(k,w,v)=>{const $=[...e];if($[k]={...$[k],[w]:v},w==="url"&&!$[k].id){const _=Pm(v);_&&($[k].id=_)}n($)},j=(k,w)=>{const v=[...e],{type:$,..._}=v[k];v[k]={..._,types:da(w)},n(v)},y=(k,w,v)=>{const _={...e[k].metadata||{}};v?_[w]=v:delete _[w],x(k,"metadata",Object.keys(_).length>0?_:void 0)},S=(k,w)=>{const v=w.trim()?w.split(/[,,、]/).map($=>$.trim()).filter(Boolean):void 0;x(k,"structure",v)},b=(k,w,v)=>{const _=e[k].coverage||{level:1,ranges:""};w==="level"?_.level=parseInt(v)||1:_.ranges=v,x(k,"coverage",_.ranges?_:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[g.map(({item:k,originalIndex:w})=>{var v,$,_;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===w?null:w),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:l===w?"▼":"▶"}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:Om(pa(k)),color:r("on-color-fg")},children:(()=>{var I,E;const C=rn(k);return C.length===0?"text":C.length===1?((I=c.find(T=>T.value===C[0]))==null?void 0:I.label)??C[0]:C.includes("text")&&C.includes("image")?((E=c.find(T=>T.value==="text+image"))==null?void 0:E.label)??"text+image":C.join("+")})()}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:k.name||`${a.editor.resourcePlaceholder} ${w+1}`}),k.id&&t.jsx("span",{style:{fontSize:"11px",opacity:.5},children:k.id}),k.url&&t.jsx("a",{href:k.url,target:"_blank",rel:"noopener noreferrer",onClick:C=>C.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),i&&k.url&&Wm(w,o==null?void 0:o[w],i,a),t.jsx("button",{onClick:C=>{C.stopPropagation(),h(w)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:a.editor.deleteThisResource,children:"✕"})]}),l===w&&t.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:[om(k,"image")&&k.url&&Fm(k,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Xn,children:[t.jsx("span",{style:Zn,children:a.label.type}),t.jsx("select",{value:pa(k),onChange:C=>j(w,C.target.value),style:{...Vt,flex:1},children:c.map(C=>t.jsx("option",{value:C.value,children:C.label},C.value))})]}),t.jsxs("label",{style:Xn,children:[t.jsx("span",{style:Zn,children:a.label.rootType}),t.jsx("select",{value:k.root_type||"catalog",onChange:C=>x(w,"root_type",C.target.value),style:{...Vt,flex:1},children:p.map(C=>t.jsx("option",{value:C.value,children:C.label},C.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:k.id,onChange:C=>x(w,"id",C.target.value),placeholder:a.editor.idAutoExtract,style:{...Vt,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:k.name,onChange:C=>x(w,"name",C.target.value),placeholder:a.editor.resourceName,style:{...Vt,flex:1}})]}),t.jsx("input",{type:"text",value:k.url,onChange:C=>x(w,"url",C.target.value),placeholder:a.editor.resourceUrl,style:Vt}),t.jsx("input",{type:"text",value:((v=k.structure)==null?void 0:v.join("、"))||"",onChange:C=>S(w,C.target.value),placeholder:a.editor.structurePlaceholder,style:Vt}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Xn,children:[t.jsx("span",{style:Zn,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:(($=k.coverage)==null?void 0:$.level)??"",onChange:C=>b(w,"level",C.target.value),placeholder:"1",style:{...Vt,width:"60px"}})]}),t.jsxs("label",{style:{...Xn,flex:1},children:[t.jsx("span",{style:Zn,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:((_=k.coverage)==null?void 0:_.ranges)||"",onChange:C=>b(w,"ranges",C.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...Vt,flex:1}})]})]}),t.jsx("textarea",{value:k.details||"",onChange:C=>x(w,"details",C.target.value),placeholder:a.editor.detailsPlaceholder,style:{...Vt,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(([C,I])=>{var E;return t.jsxs("label",{style:{...Xn,gap:"4px"},children:[t.jsx("span",{style:{...Zn,minWidth:"56px"},children:I}),t.jsx("input",{type:"text",value:((E=k.metadata)==null?void 0:E[C])||"",onChange:T=>y(w,C,T.target.value),placeholder:I,style:{...Vt,flex:1}})]},C)})})]})]})]})]},w)}),t.jsxs("button",{onClick:u,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 Om(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 Wm(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 Fm(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 Vt={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"},Xn={display:"flex",alignItems:"center",gap:"6px"},Zn={fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap"},ua={text:r("restype-text"),image:r("restype-image"),"text+image":r("restype-text-image"),physical:r("restype-physical")};function Hm(e){return e.includes("text")&&e.includes("image")?ua["text+image"]:ua[e[0]||"physical"]}const Po=({items:e,groupByType:n=!0,resourceGroups:i,onNavigate:o,renderLink:s})=>{const a=Ae(),{convert:l}=Ge(),d=f.useMemo(()=>Io(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p,labelOnlyKeys:m}=f.useMemo(()=>{const S=new Map,b=[],k=new Map;d.forEach((w,v)=>{const $=w.group||(w.label?`_label:${v}`:void 0);!w.group&&w.label&&$&&k.set($,w.label),$?(S.has($)||S.set($,[]),S.get($).push(w)):b.push(w)});for(const w of S.values())w.sort((v,$)=>{const _=C=>C.group_role==="origin"?0:C.group_role==="mirror"?1:2;return _(v)-_($)});return{mirrorGroups:S,ungroupedItems:b,labelOnlyKeys:k}},[d]),g={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},u=S=>g[S]?g[S]:S.split("+").map(b=>g[b]||b).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((S,b)=>t.jsx(Ar,{item:S},S.id||b))});const h=(S,b)=>{const k=i==null?void 0:i[S],w=m.get(S)||(k==null?void 0:k.label)||S,v=k==null?void 0:k.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)}),v&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.5},children:l(v)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:b.map(($,_)=>t.jsx(Ar,{item:$,onNavigate:o,renderLink:s},$.id||_))})]},`group-${S}`)},x=new Map;for(const S of p){const b=Ro(rn(S));x.has(b)||x.set(b,[]),x.get(b).push(S)}const j=["text","image","text+image","physical"],y=[...j.filter(S=>x.has(S)),...[...x.keys()].filter(S=>!j.includes(S)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([S,b])=>h(S,b)),y.map(S=>{const b=x.get(S),k=Hm(S.split("+"));return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:k,whiteSpace:"nowrap",flexShrink:0},children:u(S)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:b.map((w,v)=>t.jsx(Ar,{item:w,onNavigate:o,renderLink:s},w.id||v))})]},S)})]})},Dm={bw:{label:"",bg:r("colormode-bw-bg"),fg:r("colormode-bw-fg")},color:{label:"",bg:r("colormode-color-bg"),fg:r("colormode-color-fg")}},Ar=({item:e})=>{const n=Ae(),{convert:i}=Ge(),[o,s]=f.useState(!1),a=f.useMemo(()=>(e.url?Hn(e.url):void 0)||i(e.name),[e.url,e.name,i]),l=f.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||ec(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,m=e.expected_volumes??(d?c+p:0),g=e.color_mode?{...Dm[e.color_mode],label:n.colorMode[e.color_mode]}:null,u=e.details&&!d?i(e.details):null,h={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:h,children:[t.jsx("span",{style:{fontWeight:500},children:a}),g&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:g.bg,color:g.fg},children:g.label}),u&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:u}),d&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[c,"/",m,n.unit.volume,p>0&&t.jsx("span",{style:{color:r("missing-fg"),marginLeft:"3px"},children:Bt(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=Lo(e.metadata);return x?Ao(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 j=x.status==="missing";return x.url&&!j?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(j?"missing-fg":"desc-fg"),textDecoration:j?"line-through":"none",opacity:j?.6:1},children:x.volume},x.volume)})})]})},lc=({indexSource:e,syncConfig:n,variant:i="index-browser",onSwitchMode:o,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=Ae(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,m=(n==null?void 0:n.repoPath)||"",g=m?m.split(/[/\\]/).pop()||m:"",u={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")},h={onMouseOver:j=>j.currentTarget.style.opacity="0.8",onMouseOut:j=>j.currentTarget.style.opacity="1"},x=t.jsxs("div",{onClick:s,title:p?d.mode.switchToOfficial:d.mode.switchToDraft,style:{...u,background:r(p?"warning":"success"),color:r("on-color-fg")},...h,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:u,...h,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:m||d.mode.selectFolder,style:{...u,paddingLeft:"8px",paddingRight:"8px"},...h,children:[t.jsx("span",{children:"📂"}),g&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:g})]})]}):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:u,...h,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:g||d.mode.configurePath,style:{...u,background:"transparent",padding:"6px",fontSize:"12px"},...h,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:u,...h,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:m||d.mode.selectFolder,style:{...u,paddingLeft:"8px",paddingRight:"8px",minWidth:m?"100px":"auto",justifyContent:"space-between"},...h,children:[t.jsx("span",{children:"📂"}),g&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:g})]}),!c&&g&&t.jsxs("div",{style:{...u,background:r("mode-active-bg"),color:r("on-color-fg"),cursor:"default"},title:m,children:[t.jsx("span",{children:"📂"}),t.jsx("span",{style:{fontSize:"11px"},children:g})]})]})},tr="bim-search-history",ma=10,ga=8;function si(){try{const e=localStorage.getItem(tr);return e?JSON.parse(e):[]}catch{return[]}}function cc(e){try{const n=si().filter(i=>i!==e);n.unshift(e),n.length>ma&&(n.length=ma),localStorage.setItem(tr,JSON.stringify(n))}catch{}}function Um(e){try{const n=si().filter(i=>i!==e);localStorage.setItem(tr,JSON.stringify(n))}catch{}}function Vm(){try{localStorage.removeItem(tr)}catch{}}const dc=({transport:e,value:n,onChange:i,onSearch:o,onEntrySelect:s,placeholder:a})=>{const l=Ae(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,m]=f.useState(!1),[g,u]=f.useState([]),[h,x]=f.useState(-1),[j,y]=f.useState(si),S=f.useRef(null),b=f.useRef(null),k=f.useRef(null),w=f.useRef(!1);f.useEffect(()=>{x(-1);const T=n.trim();if(!T){u(j.map(W=>({type:"history",text:W})));return}if(!e.searchAll){u([]);return}let N=!1;const P=setTimeout(()=>{e.searchAll(T,ga).then(W=>{if(N)return;const L=[...W.works,...W.books,...W.collections,...W.entities??[]];u(L.slice(0,ga).map(K=>({type:"entry",text:K.title||K.id,entry:K})))}).catch(()=>{N||u([])})},80);return()=>{N=!0,clearTimeout(P)}},[n,j,e]),f.useEffect(()=>{const T=N=>{k.current&&!k.current.contains(N.target)&&m(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]),f.useEffect(()=>{const T=N=>{var P,W;if(N.key==="/"&&document.activeElement!==S.current){const L=(P=document.activeElement)==null?void 0:P.tagName;if(L==="INPUT"||L==="TEXTAREA"||L==="SELECT")return;N.preventDefault(),(W=S.current)==null||W.focus()}};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[]);const v=f.useCallback(T=>{T.trim()&&(cc(T.trim()),y(si())),o(T),m(!1)},[o]),$=f.useCallback(T=>{T.type==="history"?(i(T.text),v(T.text)):T.entry&&(s?(s(T.entry),m(!1)):(i(T.text),v(T.text)))},[i,v,s]),_=f.useCallback(T=>{if(!p||g.length===0){T.key==="Enter"&&v(n);return}switch(T.key){case"ArrowDown":T.preventDefault(),x(N=>(N+1)%g.length);break;case"ArrowUp":T.preventDefault(),x(N=>(N-1+g.length)%g.length);break;case"Enter":T.preventDefault(),h>=0&&h<g.length?$(g[h]):v(n);break;case"Escape":T.preventDefault(),m(!1);break}},[p,g,h,n,v,$]),C=f.useCallback((T,N)=>{N.stopPropagation(),Um(T),y(si()),u(P=>P.filter(W=>!(W.type==="history"&&W.text===T)))},[]),I=f.useCallback(T=>{T.stopPropagation(),Vm(),y([]),u([])},[]);f.useEffect(()=>{if(h>=0&&b.current){const T=b.current.children;T[h]&&T[h].scrollIntoView({block:"nearest"})}},[h]);const E=!n.trim()&&j.length>0;return t.jsxs("div",{ref:k,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:S,type:"text",placeholder:d,value:n,onChange:T=>{i(T.target.value),m(!0)},onCompositionStart:()=>{w.current=!0},onCompositionEnd:()=>{w.current=!1},onFocus:()=>{m(!0)},onKeyDown:_,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&&g.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:[E&&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:I,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),g.map((T,N)=>t.jsxs("div",{onClick:()=>$(T),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:r("fg"),background:N===h?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:P=>C(T.text,P),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}-${N}`))]})]})},Gn=({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"}});function nn(e){const n=[],i=new Set;for(const o of e.base_edition??[]){if(!o||!o.relation)continue;const s=!!o.hypothetical_id,a=s?o.hypothetical_id:o.book_id;if(!a)continue;const l=`${a}|${s?"hypothetical":"book"}`;i.has(l)||(i.add(l),n.push({ref:a,ref_type:s?"hypothetical":"book",relation:o.relation,confidence:o.confidence??void 0,evidence:o.evidence,note:o.note}))}return n}function wn(e){const n=[];for(const i of e.related_books??[])i&&typeof i=="object"&&i.book_id&&i.relation&&n.push({book_id:i.book_id,relation:i.relation,confidence:i.confidence??void 0,evidence:i.evidence});return n}function pc(e){return(e.related_books??[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_id).filter(n=>typeof n=="string"&&n.length>0)}function Vi(e){return!!e.lineage||nn(e).length>0||wn(e).length>0}function Gm(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 Ym(e,n){var o,s,a,l,d;if(!Vi(e))return null;const i=e.lineage??{};return{id:e.id,kind:"book",label:e.title,year:((o=e.dating)==null?void 0:o.year)??((a=(s=e.dating)==null?void 0:s.year_range)==null?void 0:a[0]),year_text:(l=e.dating)==null?void 0:l.text,year_uncertain:(d=e.dating)==null?void 0:d.year_uncertain,category:e.edition_type,status:i.status,extant_juan:i.extant_juan,group:n[e.id],note:i.note}}function fa(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 Km(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 qm(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[m,g]of Object.entries(e.node_groups))l.has(g)&&d.add(m);let c=null;if(i.hypothetical_ids&&(c=new Set(i.hypothetical_ids)),l){c||(c=new Set);for(const m of e.hypothetical_nodes??[])m.group&&l.has(m.group)&&c.add(m.id)}return{books:d,hypos:c}}function Pi(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=qm(o,i??o.default_collection??"all"),c=d!==null,p=(d==null?void 0:d.books)??null,m=(d==null?void 0:d.hypos)??null,g=new Set,u=new Set;if(c){const w=new Map(n.map(E=>[E.id,E])),v=new Map((o.hypothetical_nodes??[]).map(E=>[E.id,E])),$=E=>{const T=w.get(E);if(T&&Vi(T))return nn(T).map(P=>P.ref);const N=v.get(E);return N?(N.derived_from??[]).map(P=>P.ref):[]},_=E=>v.has(E)?!m||m.has(E):!p||p.has(E),C=new Set,I=E=>{if(!C.has(E)){C.add(E);for(const T of $(E))a.has(T)||(_(T)||(v.has(T)?u.add(T):w.has(T)&&g.add(T)),I(T))}};for(const E of n)p&&p.has(E.id)&&!a.has(E.id)&&I(E.id);for(const E of o.hypothetical_nodes??[])m&&m.has(E.id)&&I(E.id)}const h=n.filter(w=>!a.has(w.id)).filter(w=>!p||p.has(w.id)||g.has(w.id)).map(w=>{const v=Ym(w,l);return v&&g.has(w.id)&&(v.bridge=!0),v}).filter(w=>w!==null),x=(o.hypothetical_nodes??[]).filter(w=>!m||m.has(w.id)||u.has(w.id)).map(w=>{const v=Gm(w);return u.has(w.id)&&(v.bridge=!0),v}),j=[...h,...x],y=new Set(j.map(w=>w.id)),S=new Set,b=[],k=w=>{S.has(w.id)||!y.has(w.source)||!y.has(w.target)||(S.add(w.id),b.push(w))};for(const w of n)a.has(w.id)||!Vi(w)||p&&!p.has(w.id)&&!g.has(w.id)||(nn(w).forEach((v,$)=>{k(fa(w.id,v,$))}),wn(w).forEach((v,$)=>{k(Km(w.id,v,$))}));for(const w of o.hypothetical_nodes??[])m&&!m.has(w.id)&&!u.has(w.id)||(w.derived_from??[]).forEach((v,$)=>{k(fa(w.id,v,$))});return{nodes:j,edges:b,groups:o.groups??[],title:o.title,description:o.description,layout:o.layout??"LR",excluded:Array.from(a)}}function uc(e,n,i){const o=(e??(n!=null?String(n):"")).trim();return o?!i||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(o)?o:`约 ${o}`:""}function Xm(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(!Vi(c))continue;const p=`Book ${c.id} (${c.title})`;nn(c).forEach(m=>d(p,m)),wn(c).forEach(m=>{s.has(m.book_id)||i.push(`${p}: related_to.book_id "${m.book_id}" 不在 books 列表中`)})}for(const c of o.hypothetical_nodes??[]){const p=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(m=>d(p,m))}return i}const mc=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],Zm={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function It(e){return Zm[e]??e}const Bn=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],On={熹平: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},gc={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function nr(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 Jm(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 Qm=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,ha={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function Bo(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(ha))if(n.startsWith(s))return ha[s];const i=It(n);if(Ln[i]!=null)return i;const o=un(n);if(o&&n.length<=o.length+1)return It(o)}function yn(e,n){if(n){const i=gc[`${n}|${e}`];if(i!=null)return i}return On[e]}const eg=1911;function tg(e){const n=On[e];if(n==null)return;const i=Kt[e];let o;for(const[s,a]of Object.entries(On))Kt[s]===i&&a>n&&(o==null||a<o)&&(o=a);return o!=null?o-1:void 0}const ng={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function Gi(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=ng[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 un(e){for(const n of mc)if(e.startsWith(n))return n}const Kt={};{const e=(n,i)=>{for(const o of i)Kt[o]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function Mn(e,n){const i=n==="北宋"||n==="南宋"?"宋":n;for(const o of Object.keys(On))if(e.includes(o)&&!(i&&Kt[o]&&Kt[o]!==i&&gc[`${i}|${o}`]==null))return o}function ig(e){var i;if((i=e.publication_info)!=null&&i.year)return e.publication_info.year;const n=e.dating;if(n){if(n.text)return n.text;if(n.year!=null)return String(n.year);if(n.year_range&&n.year_range.length===2)return`${n.year_range[0]}-${n.year_range[1]}`}}function ir(e){var o;const n=e.dating;if(!n||n.era||n.reign||(o=e.publication_info)!=null&&o.year)return e;const i=n.text??(n.year!=null?String(n.year):n.year_range&&n.year_range.length===2?`${n.year_range[0]}-${n.year_range[1]}`:void 0);return i?{...e,publication_info:{...e.publication_info,year:i}}:e}function mi(e){var a,l;e=ir(e);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=(a=e.publication_info)==null?void 0:a.year;if(o){const d=nr(o);if(d)return{era:Jm(d.from),reign:"",source:"publication"};const c=un(o)??Bo(o)??((l=Bn.find(g=>g.pattern.test(o)))==null?void 0:l.era)??"",p=Mn(o,c)??"",m=c||(p?Kt[p]??"":"");if(m||p)return{era:It(m),reign:p,source:"publication"}}const s=e.edition||e.title||"";if(s){const d=un(s);if(d)return{era:It(d),reign:Mn(s,d)??"",source:"edition"};const c=Bn.find(p=>p.pattern.test(s));if(c)return{era:It(c.era),reign:Mn(s,c.era)??c.reign??"",source:"edition"}}return n}function rr(e){var o,s,a,l,d,c;if(e=ir(e),((o=e.dating)==null?void 0:o.year)!=null)return e.dating.year;const n=(s=e.publication_info)==null?void 0:s.year;if(n){const p=nr(n);if(p)return p.from}const i=[(a=e.publication_info)==null?void 0:a.year,e.edition,e.edition?void 0:e.title].filter(Boolean);for(const p of i){const m=(l=e.publication_info)==null?void 0:l.year;if(m&&p!==m&&(un(m)||Bo(m)))break;const g=p.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??p.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(g){const y=parseInt(g[1],10);if(y>=100&&y<=2100)return y}const u=p.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(u){const y=un(p);if(!y||It(y)==="民國"){const b=Gi(u[1]);if(b!=null&&b>=1&&b<=120)return eg+b}}const h=un(p)??((d=Bn.find(y=>y.pattern.test(p)))==null?void 0:d.era),x=h?It(h):void 0,j=Mn(p,x)??(un(p)||(c=Bn.find(y=>y.pattern.test(p)))==null?void 0:c.reign);if(j){const y=yn(j,x);if(y==null)continue;const S=p.indexOf(j),b=S>=0?p.slice(S+j.length):"",k=b.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??b.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),w=k?Gi(k[1]):void 0;return y+(w?w-1:0)}}}function Oo(e){var s,a,l,d;e=ir(e);const n=(s=e.dating)==null?void 0:s.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const i=(a=e.publication_info)==null?void 0:a.year;if(i){const c=nr(i);if((c==null?void 0:c.to)!=null)return{from:c.from,to:c.to};const p=i.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(p){const m=fc[It(p[1])],g=Ln[It(p[2])];if(m!=null&&g!=null)return{from:Math.min(m,g)-20,to:Math.max(m,g)+40}}}const o=[(l=e.publication_info)==null?void 0:l.year,e.edition,e.title].filter(Boolean);for(const c of o){if(!/[間间]/.test(c))continue;const p=un(c)??Bo(c)??((d=Bn.find(u=>u.pattern.test(c)))==null?void 0:d.era),m=p?It(p):void 0,g=[];for(const u of Object.keys(On))c.includes(u)&&(m&&Kt[u]&&Kt[u]!==m||yn(u,m)!=null&&g.push(u));if(g.length===0){const u=c.match(/([一-鿿])([一-鿿])[間间]/);if(u&&m){for(const h of[u[1],u[2]])for(const x of Object.keys(On))if(Kt[x]===m&&!(x[0]!==h&&x[x.length-1]!==h)&&yn(x,m)!=null){g.push(x);break}}}if(g.length>0){const u=g.map(y=>yn(y,m)).filter(y=>y!=null),h=Math.min(...u),x=g.reduce((y,S)=>yn(y,m)>=yn(S,m)?y:S),j=tg(x)??Mr(m??"")??Math.max(...u);return{from:h,to:j>h?j:Mr(m??Kt[x]??"")??h}}if(m&&Ln[m]!=null)return{from:Ln[m],to:Mr(m)??Ln[m]}}}const Ln={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},rg=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],og=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,xa=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function ba(e,n){for(const i of mc){const o=e.indexOf(i);if(o<0)continue;if(i.length===1){const c=e[o+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!Mn(e.slice(o),It(i)))continue}const s=It(i);if(s===n)continue;const a=e.slice(o),l=Mn(a,s)??"";let d;if(l){const c=yn(l,s);if(c!=null){const m=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),g=m?Gi(m[1]):void 0;d=c+(g?g-1:0)}}return{era:s,reign:l,year:d}}for(const i of Bn)if(i.pattern.test(e))return{era:It(i.era),reign:i.reign??""}}function sg(e){var j,y;e=ir(e);const n=mi(e),i=((j=e.publication_info)==null?void 0:j.year)??"",o=i?nr(i):void 0;if(!n.era&&!n.reign&&!o)return;const s=e.edition||e.title||"",a=/[間间]/.test(s),l=n.source==="publication"&&Qm.test(i),d=n.source==="publication"&&/[間间]/.test(i),c=i.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let p;a||l||d?p=void 0:c?p=parseInt(c[2],10):p=rr(e);const m=p==null?Oo(e):void 0;let g;n.source==="publication"&&(l||xa.test(i))?g="uncertain":n.source==="publication"?g="attested":xa.test(s)||!n.reign&&p==null?g="uncertain":g="inferred";const u=n.source==="edition"?`題名「${s}」`:`出版著錄「${((y=e.publication_info)==null?void 0:y.year)??""}」`,h={era:n.era,reign:n.reign,year:p,yearRange:m,certainty:g,source:n.source==="edition"?"edition":"catalog",basis:u};if(c){const S=i.match(/[、,,]\s*([宋元明清])/);S&&S[1]!==h.era&&(h.laterRepair={era:S[1]})}if(!h.laterRepair&&og.test(s)){const S=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);S&&S[1]!==n.era&&(h.laterRepair={era:S[1]})}const x=rg.find(S=>S.re.test(s));if(x){const S=s.search(x.re),b=s.slice(S),k=ba(b,n.era)??ba(s,n.era);k&&(h.basedOn={era:k.era,reign:k.reign,year:k.year,relation:x.relation})}return h}const fc={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function Mr(e){return fc[e]}function Yi(e){const n=rr(e);if(n!=null)return n;const i=Oo(e);if(i)return i.from;const o=mi(e).era;return o?Ln[o]:void 0}const ya=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function io(e){const n=ya.indexOf(e);return n===-1?ya.length:n}function ag(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 Wo(e,n){const i=Io(e||[]),o=new Map,s=[],a=new Map;i.forEach((m,g)=>{if(m.group)o.has(m.group)||o.set(m.group,[]),o.get(m.group).push(m);else if(m.label){const u=`_label:${g}`;o.set(u,[m]),a.set(u,m.label)}else s.push(m)});for(const m of o.values())m.sort((g,u)=>{const h=x=>x.group_role==="origin"?0:x.group_role==="mirror"?1:2;return h(g)-h(u)});const l={text:[],image:[],textImage:[],physical:[]};for(const m of s){const g=rn(m),u=g.includes("text"),h=g.includes("image");u&&h?l.textImage.push(m):u?l.text.push(m):h?l.image.push(m):l.physical.push(m)}const c=["text","image","textImage","physical"].filter(m=>l[m].length>0).map(m=>({key:m,items:l[m]})),p=[...o.entries()].map(([m,g])=>{var u,h;return{key:m,label:a.get(m)||((u=n==null?void 0:n[m])==null?void 0:u.label)||m,description:a.has(m)||(h=n==null?void 0:n[m])==null?void 0:h.description,items:g}});return{buckets:c,mirrors:p,total:i.length}}function or(e,n=Vn("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=Qi(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 hc(e,n){if(or(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""}const lg="同版";function cg(e){const n=e==null?void 0:e.metadata;return((n==null?void 0:n.item_id)||(n==null?void 0:n.call_number)||"").trim()||void 0}function dg(e){for(const n of wn(e)){const i=n.ref??n.book_id;if(n.relation===lg&&i&&i!==e.id)return i}}function pg(e){const n=new Map(e.map(a=>[a.id,a])),i=a=>{const l=n.get(a);return!!l&&!l.copyOf},o=new Map;for(const a of e)if(a.copyOf&&i(a.copyOf)){const l=o.get(a.copyOf)??[];l.push(a),o.set(a.copyOf,l)}if(o.size===0)return e;const s=[];for(const a of e){if(a.copyOf&&i(a.copyOf))continue;const l=o.get(a.id);if(!l){s.push(a);continue}const d=[...l].sort((c,p)=>(c.callNumber??c.id).localeCompare(p.callNumber??p.id));s.push({...a,copies:d,hasImage:a.hasImage||d.some(c=>c.hasImage)})}return s}function xc(e,n){var a,l,d,c;const i=e.resources||[],o=[],s=[];for(const p of i){const m=rn(p);m.includes("image")&&o.push(p),m.includes("physical")&&s.push(p)}return{id:e.id,name:e.edition||e.title||e.id,era:mi(e),year:rr(e),sortYear:Yi(e),images:o,holders:s,locationName:((a=e.current_location)==null?void 0:a.name)||((d=(l=e.provenance)==null?void 0:l[0])==null?void 0:d.institution)||void 0,callNumber:cg(s[0]),copyOf:dg(e),summary:e.summary,important:ug(e.id,n),group:(c=n==null?void 0:n.node_groups)==null?void 0:c[e.id],hasImage:o.length>0}}function ug(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 bc(e,n,i={}){const o=new Set((n==null?void 0:n.excluded_books)??[]),s=pg(e.filter(c=>!o.has(c.id)).map(c=>xc(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 m=c.r.sortYear,g=p.r.sortYear;return m!=null&&g!=null?m-g||c.i-p.i:m!=null?-1:g!=null?1:c.i-p.i}).map(c=>c.r):a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const m=g=>(g.important?0:1)*2+(g.hasImage?0:1);return m(c.r)-m(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)=>io(c)-io(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function mg(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 k=n.node_groups[b];return k!=null&&d.has(k)},m=[],g=new Map,u=[];for(const b of e)if(!((S=n.excluded_books)!=null&&S.includes(b)))if(p(b))m.push(b);else{const k=n.node_groups[b];k?(g.has(k)||g.set(k,[]),g.get(k).push(b)):u.push(b)}if(u.length+[...g.values()].reduce((b,k)=>b+k.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const x=new Map((n.groups??[]).map(b=>[b.id,b])),j=[...g.entries()].map(([b,k])=>{const w=x.get(b);return{id:b,label:(w==null?void 0:w.label)??b,description:w==null?void 0:w.description,ids:k}});return u.length>0&&j.push({id:"__other__",label:"其他版本",description:void 0,ids:u}),{useGrouping:!0,coreIds:m,groupedIds:j}}const yc=["撰","編","注","校","譯","繪","其他"],gg=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function Fo(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n)return"撰";for(const{cls:i,re:o}of gg)if(o.test(n))return i;return"其他"}function Ho(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function jc(e,n="全部"){const i=new Map;for(const s of e){const a=Fo(s);i.set(a,(i.get(a)??0)+1)}const o=[{cls:"全部",label:n,count:e.length}];for(const s of yc){const a=i.get(s);a&&o.push({cls:s,label:s,count:a})}return o.length>2?o:[]}function Do(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 vc(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:ai(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 fg(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 kc(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}=vc(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 ai(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 sr(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 hg=["〇","一","二","三","四","五","六","七","八","九"],ja=["","十","百","千"];function Sn(e){if(!Number.isInteger(e)||e<=0)return"";if(e>=1e8)return String(e);if(e<1e4)return Pr(e,!0);const n=Math.floor(e/1e4),i=e%1e4;let o=Pr(n,!0)+"萬";return i>0&&(o+=(i<1e3?"〇":"")+Pr(i,!1)),o}function Pr(e,n){const i=String(e),o=i.length;let s="",a=!1;for(let l=0;l<o;l++){const d=parseInt(i[l]),c=o-1-l;d===0?a=!0:(a&&s&&(s+="〇"),a=!1,n&&d===1&&c===1&&l===0?s+=ja[c]:s+=hg[d]+ja[c])}return s}function xg(e){return e==null?"":typeof e=="string"?e:"name"in e&&e.name?e.name:"title"in e&&e.title||""}function bg(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 on(e,n="卷"){var s,a;const i=e;if(i.measure_info)return i.measure_info;if((s=i.juan_count)!=null&&s.number)return Sn(i.juan_count.number)+n;if((a=i.juan_count)!=null&&a.description)return i.juan_count.description;const o=(i.measures??[]).filter(l=>l&&typeof l.number=="number"&&l.number>0&&l.unit);return o.length?o.map(l=>Sn(l.number)+(l.unit==="卷"?n:l.unit)).join(""):""}function wc(e){if(e.edition_type)return e.edition_type;const n=e.edition||e.title||"",i=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/油印/,"油印本"],[/曬印|晒印/,"曬印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[o,s]of i)if(o.test(n))return s;return""}const ar={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},Sc=new Set(["work","book","entity"]);function yg(e){return Cc(e)||!!e.sort}function jg(e,n){return n.sort&&Sc.has(e)?n.sort:void 0}const lr=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],cr=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],_c=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],$c={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function dr(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 Cc(e){return dr(e)>0}function vg(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 zc(e,n){const i=$c[e];return vg(n).every(o=>i.has(o))}const Jn=e=>JSON.stringify(e);function kg(e,n){if(!zc(n,e))return null;const i=[];if(e.dynasty.length){const o=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=lr.find(l=>l.key===s))==null?void 0:a.values)??[]})));o.length===1?i.push(`dynasty = ${Jn(o[0])}`):o.length>1&&i.push(`dynasty IN [${o.map(Jn).join(", ")}]`)}return e.classification.length&&i.push(e.classification.length===1?`classification = ${Jn(e.classification[0])}`:`classification IN [${e.classification.map(Jn).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 = ${Jn(e.loss)}`),i.join(" AND ")}const $t={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},Nc="_";function Ki(e,n=new URLSearchParams){for(const i of Object.values($t))n.delete(i);return e.dynasty.length&&n.set($t.dynasty,e.dynasty.join(",")),e.classification.length&&n.set($t.classification,e.classification.map(i=>i||Nc).join(",")),e.hasImage&&n.set($t.hasImage,"1"),e.hasText&&n.set($t.hasText,"1"),e.hasCollated&&n.set($t.hasCollated,"1"),e.loss&&n.set($t.loss,e.loss),e.sort&&n.set($t.sort,e.sort),n}function wg(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),i=new Set(lr.map(a=>a.key)),o=new Set(cr.map(a=>a.value)),s=e.get($t.loss);return{dynasty:Array.from(new Set(n($t.dynasty).filter(a=>i.has(a)))),classification:Array.from(new Set(n($t.classification).map(a=>a===Nc?"":a).filter(a=>o.has(a)))),hasImage:e.get($t.hasImage)==="1",hasText:e.get($t.hasText)==="1"||e.get($t.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($t.sort))??""}}function Sg(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 va(e,n){return e.includes(n)?e.filter(i=>i!==n):[...e,n]}const _g=({filters:e,onChange:n})=>{const i=Ae(),o=i.searchV4,{convert:s}=Ge(),[a,l]=f.useState(!1),d=f.useId(),c=dr(e),p=m=>n({...e,...m});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(m=>!m),children:[t.jsxs("span",{children:[s(o.filterButton),c>0&&t.jsx("span",{className:"bim-sr-fn",children:s(Bt(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:lr.map(m=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(m.key),onClick:()=>p({dynasty:va(e.dynasty,m.key)}),children:s(m.key)},m.key))})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.classification)}),cr.map(m=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(m.value),onChange:()=>p({classification:va(e.classification,m.value)})}),m.value?s(m.label):i.searchPage.unclassified]},m.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:m=>p({hasImage:m.target.checked})}),s(o.hasImage)]}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasText,onChange:m=>p({hasText:m.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:_c.map(m=>t.jsx("button",{type:"button","aria-pressed":e.loss===m.value,onClick:()=>p({loss:m.value}),children:i.searchPage.loss[m.value||"all"]},m.value||"all"))})]}),c>0&&t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...ar,sort:e.sort}),children:s(o.clearAllFilters)})]})]})};function Tc({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 ka=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ae(),a=s.searchV4,{convert:l}=Ge(),d=kt();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),m=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",g=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)}`:""}`:"",u=c.type==="book"?c.era??c.dynasty:c.dynasty,h=u?l(u):"",x=c.classification?l(c.classification):"",j=[];c.has_image&&j.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&j.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&j.push({label:a.tagLost,cls:"bim-sr-tag--lost"});const y=[g,h,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(Tc,{text:p,query:n?l(n):void 0})}),m&&t.jsx("span",{className:"bim-sr-measure",children:m})]}),y&&t.jsx("span",{className:"bim-sr-sub",children:y})]}),t.jsxs("td",{className:"bim-sr-c-type",children:[t.jsx(Gn,{type:c.type,size:6})," ",o(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:g||"—"}),t.jsx("td",{className:"bim-sr-c-era",children:h||"—"}),t.jsx("td",{className:"bim-sr-c-cls",children:x||"—"}),t.jsx("td",{className:"bim-sr-c-res",children:j.map(S=>t.jsx("span",{className:`bim-sr-tag ${S.cls}`,children:l(S.label)},S.label))})]},c.id)})})]})})},$g=`
|
|
1
|
+
"use strict";var Zu=Object.create;var ua=Object.defineProperty;var Ju=Object.getOwnPropertyDescriptor;var Qu=Object.getOwnPropertyNames;var em=Object.getPrototypeOf,tm=Object.prototype.hasOwnProperty;var nm=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Qu(n))!tm.call(e,s)&&s!==i&&ua(e,s,{get:()=>n[s],enumerable:!(o=Ju(n,s))||o.enumerable});return e};var Li=(e,n,i)=>(i=e!=null?Zu(em(e)):{},nm(n||!e||!e.__esModule?ua(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const xe=require("./storage-entry-Bw_cAsLM.cjs"),t=require("react/jsx-runtime"),h=require("react"),im=require("opencc-js/t2cn"),ic=require("./variant-supplement.cjs"),rm=require("react-markdown"),om=require("remark-gfm"),sm=e=>`/item/${e}`,rc=h.createContext(sm);function am({buildUrl:e,children:n}){const i=h.useMemo(()=>e,[e]);return t.jsx(rc.Provider,{value:i,children:n})}function kt(){return h.useContext(rc)}const oc="",sc="";function Ao(e){const n=[];let i=!1,o=e;for(;o.length;){const s=i?sc:oc,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 zt(e,n){return{title:e,tokens:n}}const ma='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',lm=[zt("基础(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"}}),zt("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),zt("提示与警告",{"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)"}}),zt("遮罩与阴影",{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)"}}),zt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),zt("资源",{"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"}}),zt("整理本(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:"中性灰:占位"}}),zt("版本传承(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"}}),zt("编辑器视图(主要在 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")'}}),zt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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:"唯一的状态色块「有影印」"},"mark-bg":{value:"#fde68a",note:"专名出处:从「古籍中的出处」跳到阅读页时高亮的字、出处摘录里的专名(A12)"},"mark-flash":{value:"#f59e0b",note:"专名出处:跳到阅读页时高亮先闪一下的颜色"},"mark-soft":{value:"rgba(253, 230, 138, 0.45)",note:"专名出处:阅读页 `#e=` 时本章提到该实体的其余各处(当前一处用 mark-bg)"},"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}}),zt('版式(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"}}),zt("阅读器(整理本 / 全文)",{"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:"版心外边线"}}),zt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),zt("字体(全站无衬线,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:ma,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:ma,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],cm=Object.assign({},...lm.map(e=>e.tokens)),ac={};for(const[e,n]of Object.entries(cm))ac[e]=`var(--bim-${e}, ${n.value})`;function r(e){const n=ac[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function on(e){return e.types&&e.types.length>0?e.types:[]}function dm(e,n){return on(e).includes(n)}const pm={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 um={"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 Dn(e){try{return um[new URL(e).hostname]}catch{return}}const ga={text:0,image:1,physical:2};function Po(e){return e.length===0?"physical":[...e].sort((n,i)=>(ga[n]??99)-(ga[i]??99)).join("+")}function mm(e){return e.includes("text")&&e.includes("image")?"text+image":e[0]||"physical"}function Bo(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[m,g]=p,u=`${m}|${Po(on(c))}`;i.has(u)||i.set(u,{base:{...c,name:m,url:"",volumes:[]},volumes:[],indices:[]});const f=i.get(u);f.volumes.push({volume:g,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 lc(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 cc(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||lc(n)}))}function nr(e){const n=cc(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 Oo(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 Wo(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 Un(e){if(!e.url)return;const n=Oo(e.metadata);return n?Wo(e.url,n):e.url}const qt=h.createContext(null),dc=["曹霑"];function gm(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function hm(e,n=dc){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(gm).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 Jn=null;function pc(){if(Jn)return Jn;try{const e=im.Converter({from:"t",to:"cn"});Jn=hm(n=>e(xe.normalizeVariants(n)))}catch{Jn=e=>e}return Jn}const fm={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:"圖片資源"}},xm={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 _t(e,n,i){return{"zh-Hant":e,"zh-Hans":n,...i?{en:i}:{}}}const bm=_t({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:"无数据"}),ir=_t({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:"作品信息"}),ym=_t({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:"附记"}}),jm=_t({fact:{written:"成書",measure:"卷帙",loss:"存佚",authenticity:"真偽",forged:"偽書",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:"種版本",sameEditionCopies:"同版另藏 {n} 部:",inferredEraNote:"部分年代據版本題名推斷,非著錄原文",empty:"尚未著錄該作品的版本與書目收錄。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"歷代書目 {n} 家",tablist:"著錄書目",titleOnly:"僅著錄書名,無提要。",prev:"上一家:{name}",next:"下一家:{name}"}},{fact:{written:"成书",measure:"卷帙",loss:"存佚",authenticity:"真伪",forged:"伪书",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:"种版本",sameEditionCopies:"同版另藏 {n} 部:",inferredEraNote:"部分年代据版本题名推断,非著录原文",empty:"尚未著录该作品的版本与书目收录。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"历代书目 {n} 家",tablist:"著录书目",titleOnly:"仅著录书名,无提要。",prev:"上一家:{name}",next:"下一家:{name}"}}),vm=_t({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:"上级丛编"}),km=_t({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 為自動匹配,未經人工核對",sealAlt:"{name}印影",imgCredit:"圖像:{credit}",imgLicense:"授權:{license}",imgSource:"來源"},{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 为自动匹配,未经人工核对",sealAlt:"{name}印影",imgCredit:"图像:{credit}",imgLicense:"授权:{license}",imgSource:"来源"}),wm=_t({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",settingsShort:"設置",closeSettings:"收起設置",groupText:"文字",groupMark:"標註",groupLayout:"版面",groupMore:"更多",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:"原字",scriptOrigUnavailable:"此文本沒有規範層,無「原字」可選",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}",tocExpand:"展開",tocCollapse:"收起",searchChapters:"搜索全部章節",searchChaptersPlaceholder:"搜索全部章節…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"來源",originalSource:"本站獨立整理",charGuess:"殘字(推測)",figLabel:"圖形符號:{alt}",figPlain:"圖形符號",lacunaGuess:"闕文,推測為「{guess}」",pendingReason:"待審:{label}",upstream:"上游",chapterFailed:"無法加載章節內容",references:"參考文獻",entityDetail:"查看詳情 →"},{imagesLoading:"加载书影…",noImages:"暂无书影",noImagesHint:"这一卷还没有配上影像;接入后在此与正文逐页对看",imageAlt:"书影 第 {label} 页",prevImage:"上一页书影",nextImage:"下一页书影",back:"阅读",backAria:"返回{label}首页",skipToText:"跳到正文",settings:"阅读设置",settingsShort:"设置",closeSettings:"收起设置",groupText:"文字",groupMark:"标注",groupLayout:"版面",groupMore:"更多",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:"原字",scriptOrigUnavailable:"此文本没有规范层,无「原字」可选",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}",tocExpand:"展开",tocCollapse:"收起",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",originalSource:"本站独立整理",charGuess:"残字(推测)",figLabel:"图形符号:{alt}",figPlain:"图形符号",lacunaGuess:"阙文,推测为「{guess}」",pendingReason:"待审:{label}",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献",entityDetail:"查看详情 →"}),Sm=_t({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:"本卷条目"}),$m=_t({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:"古籍元數據以 CC BY-SA 4.0 發布,可自由複製、改編、再發布,但須註明出處,並以相同方式共享。",repo:"數據倉庫:",repoNote:"(GitHub,CC BY-SA 4.0)",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:"古籍元数据以 CC BY-SA 4.0 发布,可自由复制、改编、再发布,但须注明出处,并以相同方式共享。",repo:"数据仓库:",repoNote:"(GitHub,CC BY-SA 4.0)",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:"规模、存佚、许可与版本"}),Fo=_t({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:"按作者浏览全部 →"}),_m=_t({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} 条"}),Cm=_t({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:"搜索"}),zm=_t({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:"回复"}),Nm=_t({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:"有争议"}}),Tm=_t({title:"古籍中的出處",total:"{n} 處,見於 {b} 部書",inBook:"{n} 處",more:"再看 {n} 處",loading:"載入中…",hint:"文中寫法可能是略稱、字號;點一條到閱讀頁,人名會標出來。",examples:"摘錄",byBook:"按書看",bookLine:"{n} 處 · {c} 章",chapterLine:"{n} 處",moreBooks:"再列 {n} 部書",navLabel:"本章出處",navCount:"本章 {k}/{n} 處",prev:"上一處",next:"下一處",close:"不再標出"},{title:"古籍中的出处",total:"{n} 处,见于 {b} 部书",inBook:"{n} 处",more:"再看 {n} 处",loading:"载入中…",hint:"文中写法可能是略称、字号;点一条到阅读页,人名会标出来。",examples:"摘录",byBook:"按书看",bookLine:"{n} 处 · {c} 章",chapterLine:"{n} 处",moreBooks:"再列 {n} 部书",navLabel:"本章出处",navCount:"本章 {k}/{n} 处",prev:"上一处",next:"下一处",close:"不再标出"},{title:"Mentions in texts",total:"{n} mentions in {b} books",inBook:"{n}",more:"Show {n} more",loading:"Loading…",hint:"The text may use a short form or courtesy name. Open one to see it highlighted in the reader.",examples:"Excerpts",byBook:"By book",bookLine:"{n} in {c} chapters",chapterLine:"{n}",moreBooks:"Show {n} more books",navLabel:"Mentions in this chapter",navCount:"{k} of {n} here",prev:"Previous",next:"Next",close:"Clear highlights"}),Rm={common:bm,detail:ir,bookPage:ym,workPage:jm,collectionPage:vm,entityPage:km,reader:wm,collated:Sm,metaHome:$m,readHome:Fo,catalogPage:_m,searchPage:Cm,feedback:zm,lineage:Nm,mentions:Tm};function Em(e){const n={};for(const[i,o]of Object.entries(Rm))n[i]=o[e];return n}function Pt(e,n){return e.replace(/\{(\w+)\}/g,(i,o)=>String(n[o]??""))}const ha=new Map;function Vn(e){let n=ha.get(e);return n||(n={...e==="zh-Hans"?xm:fm,...Em(e)},ha.set(e,n)),n}function fa(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 uc(e){return(n,i)=>{const o=fa(e,n)??fa(Vn("zh-Hant"),n)??n;return i?Pt(o,i):o}}const xa=new Map;function Gn(e){let n=xa.get(e);return n||(n=uc(Vn(e)),xa.set(e,n)),n}const mc="bim-locale";function Im(){try{const e=localStorage.getItem(mc);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function Lm(e){try{localStorage.setItem(mc,e)}catch{}}const Mm="zh-Hans",Am=({locale:e,onLocaleChange:n,converter:i,children:o})=>{const[s,a]=h.useState(e??Mm),l=e??s;h.useEffect(()=>{if(e)return;const m=Im();m&&m!==s&&a(m)},[]);const d=h.useMemo(()=>l==="zh-Hans"?i??pc():null,[l,i]),c=h.useCallback(m=>{a(m),Lm(m),n==null||n(m)},[n]),p=h.useMemo(()=>({locale:l,setLocale:c,messages:Vn(l),converter:d}),[l,c,d]);return t.jsx(qt.Provider,{value:p,children:o})};function Be(){const e=h.useContext(qt);return(e==null?void 0:e.messages)??Vn("zh-Hant")}const Pm=2e3;function Ge(){const e=h.useContext(qt),n=(e==null?void 0:e.locale)??"zh-Hant",i=(e==null?void 0:e.converter)??null,o=h.useRef(new Map),s=h.useRef(n),a=h.useRef(i);(s.current!==n||a.current!==i)&&(o.current.clear(),s.current=n,a.current=i);const l=h.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>=Pm){const m=o.current.keys().next().value;m!==void 0&&o.current.delete(m)}return o.current.set(d,p),p},[i]);return h.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function oe(){const e=h.useContext(qt),{convert:n,locale:i,isSimplified:o}=Ge(),s=(e==null?void 0:e.messages)??Vn("zh-Hant"),a=h.useMemo(()=>e?uc(s):Gn("zh-Hant"),[e,s]);return h.useMemo(()=>({t:a,convert:n,locale:i,isSimplified:o,messages:s}),[a,n,i,o,s])}const gc=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),Bm=new Set([...gc,...Object.keys(xe.VARIANT_CHARS),...Object.keys(ic.VARIANT_SUPPLEMENT)]),hc=[...dc,"切換為繁體","漢籍リポジトリ"];function Om(e,n=hc){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)=>{Bm.has(a)&&o.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),o}function Wm(e,n,i){return e?e==="orig"?null:n==="zh-Hans"?i??pc():e==="hant"?xe.normalizeVariants:i:n==="zh-Hans"?i:xe.normalizeVariants}const Fm=({mode:e,children:n})=>{const i=h.useContext(qt),o=h.useMemo(()=>i&&{...i,converter:Wm(e,i.locale,i.converter)},[i,e]);return t.jsx(qt.Provider,{value:o,children:n})};function Hm(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 ba(e){return e==="text+image"?["text","image"]:[e]}function ya(e){const n=on(e);return n.length===0?"text":mm(n)}function Dm(){return{id:"",name:"",url:"",types:["text"],details:""}}const ao=({items:e,onChange:n,onDownload:i,downloadStatuses:o,filterType:s})=>{const a=Be(),[l,d]=h.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}],m=v=>{if(!s)return!0;const w=on(v);return s==="text"?w.includes("text"):s==="image"?w.includes("image")||w.includes("physical"):s==="physical"?w.includes("physical"):w.includes(s)},g=e.map((v,w)=>({item:v,originalIndex:w})).filter(({item:v})=>m(v)),u=()=>{const v=Dm();s&&(v.types=ba(s)),n([...e,v]),d(e.length)},f=v=>{n(e.filter((w,k)=>k!==v)),d(null)},x=(v,w,k)=>{const _=[...e];if(_[v]={..._[v],[w]:k},w==="url"&&!_[v].id){const $=Hm(k);$&&(_[v].id=$)}n(_)},j=(v,w)=>{const k=[...e],{type:_,...$}=k[v];k[v]={...$,types:ba(w)},n(k)},y=(v,w,k)=>{const $={...e[v].metadata||{}};k?$[w]=k:delete $[w],x(v,"metadata",Object.keys($).length>0?$:void 0)},S=(v,w)=>{const k=w.trim()?w.split(/[,,、]/).map(_=>_.trim()).filter(Boolean):void 0;x(v,"structure",k)},b=(v,w,k)=>{const $=e[v].coverage||{level:1,ranges:""};w==="level"?$.level=parseInt(k)||1:$.ranges=k,x(v,"coverage",$.ranges?$:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[g.map(({item:v,originalIndex:w})=>{var k,_,$;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===w?null:w),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:l===w?"▼":"▶"}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:Um(ya(v)),color:r("on-color-fg")},children:(()=>{var L,E;const C=on(v);return C.length===0?"text":C.length===1?((L=c.find(T=>T.value===C[0]))==null?void 0:L.label)??C[0]:C.includes("text")&&C.includes("image")?((E=c.find(T=>T.value==="text+image"))==null?void 0:E.label)??"text+image":C.join("+")})()}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:v.name||`${a.editor.resourcePlaceholder} ${w+1}`}),v.id&&t.jsx("span",{style:{fontSize:"11px",opacity:.5},children:v.id}),v.url&&t.jsx("a",{href:v.url,target:"_blank",rel:"noopener noreferrer",onClick:C=>C.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),i&&v.url&&Vm(w,o==null?void 0:o[w],i,a),t.jsx("button",{onClick:C=>{C.stopPropagation(),f(w)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:a.editor.deleteThisResource,children:"✕"})]}),l===w&&t.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:[dm(v,"image")&&v.url&&Gm(v,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Qn,children:[t.jsx("span",{style:ei,children:a.label.type}),t.jsx("select",{value:ya(v),onChange:C=>j(w,C.target.value),style:{...Vt,flex:1},children:c.map(C=>t.jsx("option",{value:C.value,children:C.label},C.value))})]}),t.jsxs("label",{style:Qn,children:[t.jsx("span",{style:ei,children:a.label.rootType}),t.jsx("select",{value:v.root_type||"catalog",onChange:C=>x(w,"root_type",C.target.value),style:{...Vt,flex:1},children:p.map(C=>t.jsx("option",{value:C.value,children:C.label},C.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:v.id,onChange:C=>x(w,"id",C.target.value),placeholder:a.editor.idAutoExtract,style:{...Vt,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:v.name,onChange:C=>x(w,"name",C.target.value),placeholder:a.editor.resourceName,style:{...Vt,flex:1}})]}),t.jsx("input",{type:"text",value:v.url,onChange:C=>x(w,"url",C.target.value),placeholder:a.editor.resourceUrl,style:Vt}),t.jsx("input",{type:"text",value:((k=v.structure)==null?void 0:k.join("、"))||"",onChange:C=>S(w,C.target.value),placeholder:a.editor.structurePlaceholder,style:Vt}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Qn,children:[t.jsx("span",{style:ei,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((_=v.coverage)==null?void 0:_.level)??"",onChange:C=>b(w,"level",C.target.value),placeholder:"1",style:{...Vt,width:"60px"}})]}),t.jsxs("label",{style:{...Qn,flex:1},children:[t.jsx("span",{style:ei,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:(($=v.coverage)==null?void 0:$.ranges)||"",onChange:C=>b(w,"ranges",C.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...Vt,flex:1}})]})]}),t.jsx("textarea",{value:v.details||"",onChange:C=>x(w,"details",C.target.value),placeholder:a.editor.detailsPlaceholder,style:{...Vt,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(([C,L])=>{var E;return t.jsxs("label",{style:{...Qn,gap:"4px"},children:[t.jsx("span",{style:{...ei,minWidth:"56px"},children:L}),t.jsx("input",{type:"text",value:((E=v.metadata)==null?void 0:E[C])||"",onChange:T=>y(w,C,T.target.value),placeholder:L,style:{...Vt,flex:1}})]},C)})})]})]})]})]},w)}),t.jsxs("button",{onClick:u,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 Um(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 Vm(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 Gm(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 Vt={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"},Qn={display:"flex",alignItems:"center",gap:"6px"},ei={fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap"},ja={text:r("restype-text"),image:r("restype-image"),"text+image":r("restype-text-image"),physical:r("restype-physical")};function Ym(e){return e.includes("text")&&e.includes("image")?ja["text+image"]:ja[e[0]||"physical"]}const Ho=({items:e,groupByType:n=!0,resourceGroups:i,onNavigate:o,renderLink:s})=>{const a=Be(),{convert:l}=Ge(),d=h.useMemo(()=>Bo(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p,labelOnlyKeys:m}=h.useMemo(()=>{const S=new Map,b=[],v=new Map;d.forEach((w,k)=>{const _=w.group||(w.label?`_label:${k}`:void 0);!w.group&&w.label&&_&&v.set(_,w.label),_?(S.has(_)||S.set(_,[]),S.get(_).push(w)):b.push(w)});for(const w of S.values())w.sort((k,_)=>{const $=C=>C.group_role==="origin"?0:C.group_role==="mirror"?1:2;return $(k)-$(_)});return{mirrorGroups:S,ungroupedItems:b,labelOnlyKeys:v}},[d]),g={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},u=S=>g[S]?g[S]:S.split("+").map(b=>g[b]||b).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((S,b)=>t.jsx(Fr,{item:S},S.id||b))});const f=(S,b)=>{const v=i==null?void 0:i[S],w=m.get(S)||(v==null?void 0:v.label)||S,k=v==null?void 0:v.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)}),k&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.5},children:l(k)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:b.map((_,$)=>t.jsx(Fr,{item:_,onNavigate:o,renderLink:s},_.id||$))})]},`group-${S}`)},x=new Map;for(const S of p){const b=Po(on(S));x.has(b)||x.set(b,[]),x.get(b).push(S)}const j=["text","image","text+image","physical"],y=[...j.filter(S=>x.has(S)),...[...x.keys()].filter(S=>!j.includes(S)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([S,b])=>f(S,b)),y.map(S=>{const b=x.get(S),v=Ym(S.split("+"));return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:v,whiteSpace:"nowrap",flexShrink:0},children:u(S)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:b.map((w,k)=>t.jsx(Fr,{item:w,onNavigate:o,renderLink:s},w.id||k))})]},S)})]})},Km={bw:{label:"",bg:r("colormode-bw-bg"),fg:r("colormode-bw-fg")},color:{label:"",bg:r("colormode-color-bg"),fg:r("colormode-color-fg")}},Fr=({item:e})=>{const n=Be(),{convert:i}=Ge(),[o,s]=h.useState(!1),a=h.useMemo(()=>(e.url?Dn(e.url):void 0)||i(e.name),[e.url,e.name,i]),l=h.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||lc(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,m=e.expected_volumes??(d?c+p:0),g=e.color_mode?{...Km[e.color_mode],label:n.colorMode[e.color_mode]}:null,u=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}),g&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:g.bg,color:g.fg},children:g.label}),u&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:u}),d&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[c,"/",m,n.unit.volume,p>0&&t.jsx("span",{style:{color:r("missing-fg"),marginLeft:"3px"},children:Pt(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=Oo(e.metadata);return x?Wo(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 j=x.status==="missing";return x.url&&!j?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(j?"missing-fg":"desc-fg"),textDecoration:j?"line-through":"none",opacity:j?.6:1},children:x.volume},x.volume)})})]})},fc=({indexSource:e,syncConfig:n,variant:i="index-browser",onSwitchMode:o,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=Be(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,m=(n==null?void 0:n.repoPath)||"",g=m?m.split(/[/\\]/).pop()||m:"",u={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:j=>j.currentTarget.style.opacity="0.8",onMouseOut:j=>j.currentTarget.style.opacity="1"},x=t.jsxs("div",{onClick:s,title:p?d.mode.switchToOfficial:d.mode.switchToDraft,style:{...u,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:u,...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:m||d.mode.selectFolder,style:{...u,paddingLeft:"8px",paddingRight:"8px"},...f,children:[t.jsx("span",{children:"📂"}),g&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:g})]})]}):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:u,...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:g||d.mode.configurePath,style:{...u,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:u,...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:m||d.mode.selectFolder,style:{...u,paddingLeft:"8px",paddingRight:"8px",minWidth:m?"100px":"auto",justifyContent:"space-between"},...f,children:[t.jsx("span",{children:"📂"}),g&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:g})]}),!c&&g&&t.jsxs("div",{style:{...u,background:r("mode-active-bg"),color:r("on-color-fg"),cursor:"default"},title:m,children:[t.jsx("span",{children:"📂"}),t.jsx("span",{style:{fontSize:"11px"},children:g})]})]})},rr="bim-search-history",va=10,ka=8;function ci(){try{const e=localStorage.getItem(rr);return e?JSON.parse(e):[]}catch{return[]}}function xc(e){try{const n=ci().filter(i=>i!==e);n.unshift(e),n.length>va&&(n.length=va),localStorage.setItem(rr,JSON.stringify(n))}catch{}}function qm(e){try{const n=ci().filter(i=>i!==e);localStorage.setItem(rr,JSON.stringify(n))}catch{}}function Xm(){try{localStorage.removeItem(rr)}catch{}}const bc=({transport:e,value:n,onChange:i,onSearch:o,onEntrySelect:s,placeholder:a})=>{const l=Be(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,m]=h.useState(!1),[g,u]=h.useState([]),[f,x]=h.useState(-1),[j,y]=h.useState(ci),S=h.useRef(null),b=h.useRef(null),v=h.useRef(null),w=h.useRef(!1);h.useEffect(()=>{x(-1);const T=n.trim();if(!T){u(j.map(F=>({type:"history",text:F})));return}if(!e.searchAll){u([]);return}let N=!1;const W=setTimeout(()=>{e.searchAll(T,ka).then(F=>{if(N)return;const R=[...F.works,...F.books,...F.collections,...F.entities??[]];u(R.slice(0,ka).map(G=>({type:"entry",text:G.title||G.id,entry:G})))}).catch(()=>{N||u([])})},80);return()=>{N=!0,clearTimeout(W)}},[n,j,e]),h.useEffect(()=>{const T=N=>{v.current&&!v.current.contains(N.target)&&m(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]),h.useEffect(()=>{const T=N=>{var W,F;if(N.key==="/"&&document.activeElement!==S.current){const R=(W=document.activeElement)==null?void 0:W.tagName;if(R==="INPUT"||R==="TEXTAREA"||R==="SELECT")return;N.preventDefault(),(F=S.current)==null||F.focus()}};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[]);const k=h.useCallback(T=>{T.trim()&&(xc(T.trim()),y(ci())),o(T),m(!1)},[o]),_=h.useCallback(T=>{T.type==="history"?(i(T.text),k(T.text)):T.entry&&(s?(s(T.entry),m(!1)):(i(T.text),k(T.text)))},[i,k,s]),$=h.useCallback(T=>{if(!p||g.length===0){T.key==="Enter"&&k(n);return}switch(T.key){case"ArrowDown":T.preventDefault(),x(N=>(N+1)%g.length);break;case"ArrowUp":T.preventDefault(),x(N=>(N-1+g.length)%g.length);break;case"Enter":T.preventDefault(),f>=0&&f<g.length?_(g[f]):k(n);break;case"Escape":T.preventDefault(),m(!1);break}},[p,g,f,n,k,_]),C=h.useCallback((T,N)=>{N.stopPropagation(),qm(T),y(ci()),u(W=>W.filter(F=>!(F.type==="history"&&F.text===T)))},[]),L=h.useCallback(T=>{T.stopPropagation(),Xm(),y([]),u([])},[]);h.useEffect(()=>{if(f>=0&&b.current){const T=b.current.children;T[f]&&T[f].scrollIntoView({block:"nearest"})}},[f]);const E=!n.trim()&&j.length>0;return t.jsxs("div",{ref:v,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:S,type:"text",placeholder:d,value:n,onChange:T=>{i(T.target.value),m(!0)},onCompositionStart:()=>{w.current=!0},onCompositionEnd:()=>{w.current=!1},onFocus:()=>{m(!0)},onKeyDown:$,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&&g.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:[E&&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:L,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),g.map((T,N)=>t.jsxs("div",{onClick:()=>_(T),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:r("fg"),background:N===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=>C(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}-${N}`))]})]})},Yn=({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"}});function rn(e){const n=[],i=new Set;for(const o of e.base_edition??[]){if(!o||!o.relation)continue;const s=!!o.hypothetical_id,a=s?o.hypothetical_id:o.book_id;if(!a)continue;const l=`${a}|${s?"hypothetical":"book"}`;i.has(l)||(i.add(l),n.push({ref:a,ref_type:s?"hypothetical":"book",relation:o.relation,confidence:o.confidence??void 0,evidence:o.evidence,note:o.note}))}return n}function wn(e){const n=[];for(const i of e.related_books??[])i&&typeof i=="object"&&i.book_id&&i.relation&&n.push({book_id:i.book_id,relation:i.relation,confidence:i.confidence??void 0,evidence:i.evidence});return n}function yc(e){return(e.related_books??[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_id).filter(n=>typeof n=="string"&&n.length>0)}function Ki(e){return!!e.lineage||rn(e).length>0||wn(e).length>0}function Zm(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 Jm(e,n){var o,s,a,l,d;if(!Ki(e))return null;const i=e.lineage??{};return{id:e.id,kind:"book",label:e.title,year:((o=e.dating)==null?void 0:o.year)??((a=(s=e.dating)==null?void 0:s.year_range)==null?void 0:a[0]),year_text:(l=e.dating)==null?void 0:l.text,year_uncertain:(d=e.dating)==null?void 0:d.year_uncertain,category:e.edition_type,status:i.status,extant_juan:i.extant_juan,group:n[e.id],note:i.note}}function wa(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 Qm(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 eg(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[m,g]of Object.entries(e.node_groups))l.has(g)&&d.add(m);let c=null;if(i.hypothetical_ids&&(c=new Set(i.hypothetical_ids)),l){c||(c=new Set);for(const m of e.hypothetical_nodes??[])m.group&&l.has(m.group)&&c.add(m.id)}return{books:d,hypos:c}}function Oi(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=eg(o,i??o.default_collection??"all"),c=d!==null,p=(d==null?void 0:d.books)??null,m=(d==null?void 0:d.hypos)??null,g=new Set,u=new Set;if(c){const w=new Map(n.map(E=>[E.id,E])),k=new Map((o.hypothetical_nodes??[]).map(E=>[E.id,E])),_=E=>{const T=w.get(E);if(T&&Ki(T))return rn(T).map(W=>W.ref);const N=k.get(E);return N?(N.derived_from??[]).map(W=>W.ref):[]},$=E=>k.has(E)?!m||m.has(E):!p||p.has(E),C=new Set,L=E=>{if(!C.has(E)){C.add(E);for(const T of _(E))a.has(T)||($(T)||(k.has(T)?u.add(T):w.has(T)&&g.add(T)),L(T))}};for(const E of n)p&&p.has(E.id)&&!a.has(E.id)&&L(E.id);for(const E of o.hypothetical_nodes??[])m&&m.has(E.id)&&L(E.id)}const f=n.filter(w=>!a.has(w.id)).filter(w=>!p||p.has(w.id)||g.has(w.id)).map(w=>{const k=Jm(w,l);return k&&g.has(w.id)&&(k.bridge=!0),k}).filter(w=>w!==null),x=(o.hypothetical_nodes??[]).filter(w=>!m||m.has(w.id)||u.has(w.id)).map(w=>{const k=Zm(w);return u.has(w.id)&&(k.bridge=!0),k}),j=[...f,...x],y=new Set(j.map(w=>w.id)),S=new Set,b=[],v=w=>{S.has(w.id)||!y.has(w.source)||!y.has(w.target)||(S.add(w.id),b.push(w))};for(const w of n)a.has(w.id)||!Ki(w)||p&&!p.has(w.id)&&!g.has(w.id)||(rn(w).forEach((k,_)=>{v(wa(w.id,k,_))}),wn(w).forEach((k,_)=>{v(Qm(w.id,k,_))}));for(const w of o.hypothetical_nodes??[])m&&!m.has(w.id)&&!u.has(w.id)||(w.derived_from??[]).forEach((k,_)=>{v(wa(w.id,k,_))});return{nodes:j,edges:b,groups:o.groups??[],title:o.title,description:o.description,layout:o.layout??"LR",excluded:Array.from(a)}}function jc(e,n,i){const o=(e??(n!=null?String(n):"")).trim();return o?!i||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(o)?o:`约 ${o}`:""}function tg(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(!Ki(c))continue;const p=`Book ${c.id} (${c.title})`;rn(c).forEach(m=>d(p,m)),wn(c).forEach(m=>{s.has(m.book_id)||i.push(`${p}: related_to.book_id "${m.book_id}" 不在 books 列表中`)})}for(const c of o.hypothetical_nodes??[]){const p=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(m=>d(p,m))}return i}const vc=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],ng={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function Et(e){return ng[e]??e}const On=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],Wn={熹平: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},kc={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function or(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 ig(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 rg=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,Sa={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function Do(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(Sa))if(n.startsWith(s))return Sa[s];const i=Et(n);if(Mn[i]!=null)return i;const o=pn(n);if(o&&n.length<=o.length+1)return Et(o)}function yn(e,n){if(n){const i=kc[`${n}|${e}`];if(i!=null)return i}return Wn[e]}const og=1911;function sg(e){const n=Wn[e];if(n==null)return;const i=Kt[e];let o;for(const[s,a]of Object.entries(Wn))Kt[s]===i&&a>n&&(o==null||a<o)&&(o=a);return o!=null?o-1:void 0}const ag={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function qi(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=ag[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 pn(e){for(const n of vc)if(e.startsWith(n))return n}const Kt={};{const e=(n,i)=>{for(const o of i)Kt[o]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function Pn(e,n){const i=n==="北宋"||n==="南宋"?"宋":n;for(const o of Object.keys(Wn))if(e.includes(o)&&!(i&&Kt[o]&&Kt[o]!==i&&kc[`${i}|${o}`]==null))return o}function lg(e){var i;if((i=e.publication_info)!=null&&i.year)return e.publication_info.year;const n=e.dating;if(n){if(n.text)return n.text;if(n.year!=null)return String(n.year);if(n.year_range&&n.year_range.length===2)return`${n.year_range[0]}-${n.year_range[1]}`}}function sr(e){var o;const n=e.dating;if(!n||n.era||n.reign||(o=e.publication_info)!=null&&o.year)return e;const i=n.text??(n.year!=null?String(n.year):n.year_range&&n.year_range.length===2?`${n.year_range[0]}-${n.year_range[1]}`:void 0);return i?{...e,publication_info:{...e.publication_info,year:i}}:e}function fi(e){var a,l;e=sr(e);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=(a=e.publication_info)==null?void 0:a.year;if(o){const d=or(o);if(d)return{era:ig(d.from),reign:"",source:"publication"};const c=pn(o)??Do(o)??((l=On.find(g=>g.pattern.test(o)))==null?void 0:l.era)??"",p=Pn(o,c)??"",m=c||(p?Kt[p]??"":"");if(m||p)return{era:Et(m),reign:p,source:"publication"}}const s=e.edition||e.title||"";if(s){const d=pn(s);if(d)return{era:Et(d),reign:Pn(s,d)??"",source:"edition"};const c=On.find(p=>p.pattern.test(s));if(c)return{era:Et(c.era),reign:Pn(s,c.era)??c.reign??"",source:"edition"}}return n}function ar(e){var o,s,a,l,d,c;if(e=sr(e),((o=e.dating)==null?void 0:o.year)!=null)return e.dating.year;const n=(s=e.publication_info)==null?void 0:s.year;if(n){const p=or(n);if(p)return p.from}const i=[(a=e.publication_info)==null?void 0:a.year,e.edition,e.edition?void 0:e.title].filter(Boolean);for(const p of i){const m=(l=e.publication_info)==null?void 0:l.year;if(m&&p!==m&&(pn(m)||Do(m)))break;const g=p.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??p.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(g){const y=parseInt(g[1],10);if(y>=100&&y<=2100)return y}const u=p.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(u){const y=pn(p);if(!y||Et(y)==="民國"){const b=qi(u[1]);if(b!=null&&b>=1&&b<=120)return og+b}}const f=pn(p)??((d=On.find(y=>y.pattern.test(p)))==null?void 0:d.era),x=f?Et(f):void 0,j=Pn(p,x)??(pn(p)||(c=On.find(y=>y.pattern.test(p)))==null?void 0:c.reign);if(j){const y=yn(j,x);if(y==null)continue;const S=p.indexOf(j),b=S>=0?p.slice(S+j.length):"",v=b.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??b.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),w=v?qi(v[1]):void 0;return y+(w?w-1:0)}}}function Uo(e){var s,a,l,d;e=sr(e);const n=(s=e.dating)==null?void 0:s.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const i=(a=e.publication_info)==null?void 0:a.year;if(i){const c=or(i);if((c==null?void 0:c.to)!=null)return{from:c.from,to:c.to};const p=i.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(p){const m=wc[Et(p[1])],g=Mn[Et(p[2])];if(m!=null&&g!=null)return{from:Math.min(m,g)-20,to:Math.max(m,g)+40}}}const o=[(l=e.publication_info)==null?void 0:l.year,e.edition,e.title].filter(Boolean);for(const c of o){if(!/[間间]/.test(c))continue;const p=pn(c)??Do(c)??((d=On.find(u=>u.pattern.test(c)))==null?void 0:d.era),m=p?Et(p):void 0,g=[];for(const u of Object.keys(Wn))c.includes(u)&&(m&&Kt[u]&&Kt[u]!==m||yn(u,m)!=null&&g.push(u));if(g.length===0){const u=c.match(/([一-鿿])([一-鿿])[間间]/);if(u&&m){for(const f of[u[1],u[2]])for(const x of Object.keys(Wn))if(Kt[x]===m&&!(x[0]!==f&&x[x.length-1]!==f)&&yn(x,m)!=null){g.push(x);break}}}if(g.length>0){const u=g.map(y=>yn(y,m)).filter(y=>y!=null),f=Math.min(...u),x=g.reduce((y,S)=>yn(y,m)>=yn(S,m)?y:S),j=sg(x)??Hr(m??"")??Math.max(...u);return{from:f,to:j>f?j:Hr(m??Kt[x]??"")??f}}if(m&&Mn[m]!=null)return{from:Mn[m],to:Hr(m)??Mn[m]}}}const Mn={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},cg=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],dg=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,$a=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function _a(e,n){for(const i of vc){const o=e.indexOf(i);if(o<0)continue;if(i.length===1){const c=e[o+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!Pn(e.slice(o),Et(i)))continue}const s=Et(i);if(s===n)continue;const a=e.slice(o),l=Pn(a,s)??"";let d;if(l){const c=yn(l,s);if(c!=null){const m=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),g=m?qi(m[1]):void 0;d=c+(g?g-1:0)}}return{era:s,reign:l,year:d}}for(const i of On)if(i.pattern.test(e))return{era:Et(i.era),reign:i.reign??""}}function pg(e){var j,y;e=sr(e);const n=fi(e),i=((j=e.publication_info)==null?void 0:j.year)??"",o=i?or(i):void 0;if(!n.era&&!n.reign&&!o)return;const s=e.edition||e.title||"",a=/[間间]/.test(s),l=n.source==="publication"&&rg.test(i),d=n.source==="publication"&&/[間间]/.test(i),c=i.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let p;a||l||d?p=void 0:c?p=parseInt(c[2],10):p=ar(e);const m=p==null?Uo(e):void 0;let g;n.source==="publication"&&(l||$a.test(i))?g="uncertain":n.source==="publication"?g="attested":$a.test(s)||!n.reign&&p==null?g="uncertain":g="inferred";const u=n.source==="edition"?`題名「${s}」`:`出版著錄「${((y=e.publication_info)==null?void 0:y.year)??""}」`,f={era:n.era,reign:n.reign,year:p,yearRange:m,certainty:g,source:n.source==="edition"?"edition":"catalog",basis:u};if(c){const S=i.match(/[、,,]\s*([宋元明清])/);S&&S[1]!==f.era&&(f.laterRepair={era:S[1]})}if(!f.laterRepair&&dg.test(s)){const S=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);S&&S[1]!==n.era&&(f.laterRepair={era:S[1]})}const x=cg.find(S=>S.re.test(s));if(x){const S=s.search(x.re),b=s.slice(S),v=_a(b,n.era)??_a(s,n.era);v&&(f.basedOn={era:v.era,reign:v.reign,year:v.year,relation:x.relation})}return f}const wc={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function Hr(e){return wc[e]}function Xi(e){const n=ar(e);if(n!=null)return n;const i=Uo(e);if(i)return i.from;const o=fi(e).era;return o?Mn[o]:void 0}const Ca=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function lo(e){const n=Ca.indexOf(e);return n===-1?Ca.length:n}function ug(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 Vo(e,n){const i=Bo(e||[]),o=new Map,s=[],a=new Map;i.forEach((m,g)=>{if(m.group)o.has(m.group)||o.set(m.group,[]),o.get(m.group).push(m);else if(m.label){const u=`_label:${g}`;o.set(u,[m]),a.set(u,m.label)}else s.push(m)});for(const m of o.values())m.sort((g,u)=>{const f=x=>x.group_role==="origin"?0:x.group_role==="mirror"?1:2;return f(g)-f(u)});const l={text:[],image:[],textImage:[],physical:[]};for(const m of s){const g=on(m),u=g.includes("text"),f=g.includes("image");u&&f?l.textImage.push(m):u?l.text.push(m):f?l.image.push(m):l.physical.push(m)}const c=["text","image","textImage","physical"].filter(m=>l[m].length>0).map(m=>({key:m,items:l[m]})),p=[...o.entries()].map(([m,g])=>{var u,f;return{key:m,label:a.get(m)||((u=n==null?void 0:n[m])==null?void 0:u.label)||m,description:a.has(m)||(f=n==null?void 0:n[m])==null?void 0:f.description,items:g}});return{buckets:c,mirrors:p,total:i.length}}function lr(e,n=Gn("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=nr(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 Sc(e,n){if(lr(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""}const mg="同版";function gg(e){const n=e==null?void 0:e.metadata;return((n==null?void 0:n.item_id)||(n==null?void 0:n.call_number)||"").trim()||void 0}function hg(e){for(const n of wn(e)){const i=n.ref??n.book_id;if(n.relation===mg&&i&&i!==e.id)return i}}function fg(e){const n=new Map(e.map(a=>[a.id,a])),i=a=>{const l=n.get(a);return!!l&&!l.copyOf},o=new Map;for(const a of e)if(a.copyOf&&i(a.copyOf)){const l=o.get(a.copyOf)??[];l.push(a),o.set(a.copyOf,l)}if(o.size===0)return e;const s=[];for(const a of e){if(a.copyOf&&i(a.copyOf))continue;const l=o.get(a.id);if(!l){s.push(a);continue}const d=[...l].sort((c,p)=>(c.callNumber??c.id).localeCompare(p.callNumber??p.id));s.push({...a,copies:d,hasImage:a.hasImage||d.some(c=>c.hasImage)})}return s}function $c(e,n){var a,l,d,c;const i=e.resources||[],o=[],s=[];for(const p of i){const m=on(p);m.includes("image")&&o.push(p),m.includes("physical")&&s.push(p)}return{id:e.id,name:e.edition||e.title||e.id,era:fi(e),year:ar(e),sortYear:Xi(e),images:o,holders:s,locationName:((a=e.current_location)==null?void 0:a.name)||((d=(l=e.provenance)==null?void 0:l[0])==null?void 0:d.institution)||void 0,callNumber:gg(s[0]),copyOf:hg(e),summary:e.summary,important:xg(e.id,n),group:(c=n==null?void 0:n.node_groups)==null?void 0:c[e.id],hasImage:o.length>0}}function xg(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 _c(e,n,i={}){const o=new Set((n==null?void 0:n.excluded_books)??[]),s=fg(e.filter(c=>!o.has(c.id)).map(c=>$c(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 m=c.r.sortYear,g=p.r.sortYear;return m!=null&&g!=null?m-g||c.i-p.i:m!=null?-1:g!=null?1:c.i-p.i}).map(c=>c.r):a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const m=g=>(g.important?0:1)*2+(g.hasImage?0:1);return m(c.r)-m(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)=>lo(c)-lo(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function bg(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 v=n.node_groups[b];return v!=null&&d.has(v)},m=[],g=new Map,u=[];for(const b of e)if(!((S=n.excluded_books)!=null&&S.includes(b)))if(p(b))m.push(b);else{const v=n.node_groups[b];v?(g.has(v)||g.set(v,[]),g.get(v).push(b)):u.push(b)}if(u.length+[...g.values()].reduce((b,v)=>b+v.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const x=new Map((n.groups??[]).map(b=>[b.id,b])),j=[...g.entries()].map(([b,v])=>{const w=x.get(b);return{id:b,label:(w==null?void 0:w.label)??b,description:w==null?void 0:w.description,ids:v}});return u.length>0&&j.push({id:"__other__",label:"其他版本",description:void 0,ids:u}),{useGrouping:!0,coreIds:m,groupedIds:j}}const Cc=["撰","編","注","校","譯","繪","其他"],yg=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function Go(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n)return"撰";for(const{cls:i,re:o}of yg)if(o.test(n))return i;return"其他"}function Yo(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function zc(e,n="全部"){const i=new Map;for(const s of e){const a=Go(s);i.set(a,(i.get(a)??0)+1)}const o=[{cls:"全部",label:n,count:e.length}];for(const s of Cc){const a=i.get(s);a&&o.push({cls:s,label:s,count:a})}return o.length>2?o:[]}function Ko(e){return(e._books??[]).map(n=>n.id).filter(n=>typeof n=="string")}function qo(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 Nc(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:di(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 jg(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}=Nc(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 di(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 cr(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 vg=["〇","一","二","三","四","五","六","七","八","九"],za=["","十","百","千"];function Sn(e){if(!Number.isInteger(e)||e<=0)return"";if(e>=1e8)return String(e);if(e<1e4)return Dr(e,!0);const n=Math.floor(e/1e4),i=e%1e4;let o=Dr(n,!0)+"萬";return i>0&&(o+=(i<1e3?"〇":"")+Dr(i,!1)),o}function Dr(e,n){const i=String(e),o=i.length;let s="",a=!1;for(let l=0;l<o;l++){const d=parseInt(i[l]),c=o-1-l;d===0?a=!0:(a&&s&&(s+="〇"),a=!1,n&&d===1&&c===1&&l===0?s+=za[c]:s+=vg[d]+za[c])}return s}function kg(e){return e==null?"":typeof e=="string"?e:"name"in e&&e.name?e.name:"title"in e&&e.title||""}function wg(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 sn(e,n="卷"){var s,a;const i=e;if(i.measure_info)return i.measure_info;if((s=i.juan_count)!=null&&s.number)return Sn(i.juan_count.number)+n;if((a=i.juan_count)!=null&&a.description)return i.juan_count.description;const o=(i.measures??[]).filter(l=>l&&typeof l.number=="number"&&l.number>0&&l.unit);return o.length?o.map(l=>Sn(l.number)+(l.unit==="卷"?n:l.unit)).join(""):""}function Rc(e){if(e.edition_type)return e.edition_type;const n=e.edition||e.title||"",i=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/油印/,"油印本"],[/曬印|晒印/,"曬印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[o,s]of i)if(o.test(n))return s;return""}const dr={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},Ec=new Set(["work","book","entity"]);function Sg(e){return Mc(e)||!!e.sort}function $g(e,n){return n.sort&&Ec.has(e)?n.sort:void 0}const pr=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],ur=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],Ic=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],Lc={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function mr(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 Mc(e){return mr(e)>0}function _g(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 Ac(e,n){const i=Lc[e];return _g(n).every(o=>i.has(o))}const ti=e=>JSON.stringify(e);function Cg(e,n){if(!Ac(n,e))return null;const i=[];if(e.dynasty.length){const o=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=pr.find(l=>l.key===s))==null?void 0:a.values)??[]})));o.length===1?i.push(`dynasty = ${ti(o[0])}`):o.length>1&&i.push(`dynasty IN [${o.map(ti).join(", ")}]`)}return e.classification.length&&i.push(e.classification.length===1?`classification = ${ti(e.classification[0])}`:`classification IN [${e.classification.map(ti).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 = ${ti(e.loss)}`),i.join(" AND ")}const $t={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},Pc="_";function Zi(e,n=new URLSearchParams){for(const i of Object.values($t))n.delete(i);return e.dynasty.length&&n.set($t.dynasty,e.dynasty.join(",")),e.classification.length&&n.set($t.classification,e.classification.map(i=>i||Pc).join(",")),e.hasImage&&n.set($t.hasImage,"1"),e.hasText&&n.set($t.hasText,"1"),e.hasCollated&&n.set($t.hasCollated,"1"),e.loss&&n.set($t.loss,e.loss),e.sort&&n.set($t.sort,e.sort),n}function zg(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),i=new Set(pr.map(a=>a.key)),o=new Set(ur.map(a=>a.value)),s=e.get($t.loss);return{dynasty:Array.from(new Set(n($t.dynasty).filter(a=>i.has(a)))),classification:Array.from(new Set(n($t.classification).map(a=>a===Pc?"":a).filter(a=>o.has(a)))),hasImage:e.get($t.hasImage)==="1",hasText:e.get($t.hasText)==="1"||e.get($t.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($t.sort))??""}}function Ng(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 Na(e,n){return e.includes(n)?e.filter(i=>i!==n):[...e,n]}const Tg=({filters:e,onChange:n})=>{const i=Be(),o=i.searchV4,{convert:s}=Ge(),[a,l]=h.useState(!1),d=h.useId(),c=mr(e),p=m=>n({...e,...m});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(m=>!m),children:[t.jsxs("span",{children:[s(o.filterButton),c>0&&t.jsx("span",{className:"bim-sr-fn",children:s(Pt(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:pr.map(m=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(m.key),onClick:()=>p({dynasty:Na(e.dynasty,m.key)}),children:s(m.key)},m.key))})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.classification)}),ur.map(m=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(m.value),onChange:()=>p({classification:Na(e.classification,m.value)})}),m.value?s(m.label):i.searchPage.unclassified]},m.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:m=>p({hasImage:m.target.checked})}),s(o.hasImage)]}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasText,onChange:m=>p({hasText:m.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:Ic.map(m=>t.jsx("button",{type:"button","aria-pressed":e.loss===m.value,onClick:()=>p({loss:m.value}),children:i.searchPage.loss[m.value||"all"]},m.value||"all"))})]}),c>0&&t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...dr,sort:e.sort}),children:s(o.clearAllFilters)})]})]})};function Bc({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 Ta=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Be(),a=s.searchV4,{convert:l}=Ge(),d=kt();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),m=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",g=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)}`:""}`:"",u=c.type==="book"?c.era??c.dynasty:c.dynasty,f=u?l(u):"",x=c.classification?l(c.classification):"",j=[];c.has_image&&j.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&j.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&j.push({label:a.tagLost,cls:"bim-sr-tag--lost"});const y=[g,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(Bc,{text:p,query:n?l(n):void 0})}),m&&t.jsx("span",{className:"bim-sr-measure",children:m})]}),y&&t.jsx("span",{className:"bim-sr-sub",children:y})]}),t.jsxs("td",{className:"bim-sr-c-type",children:[t.jsx(Yn,{type:c.type,size:6})," ",o(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:g||"—"}),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:j.map(S=>t.jsx("span",{className:`bim-sr-tag ${S.cls}`,children:l(S.label)},S.label))})]},c.id)})})]})})},Rg=`
|
|
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
|
+
`,Ra=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Be(),a=s.searchV4,{convert:l}=Ge(),d=kt();return t.jsxs("div",{className:"bim-sc-grid",children:[t.jsx("style",{children:Rg}),e.map(c=>{const p=l(c.title||c.primary_name||c.id),m=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??"?"}`:"":`${c.dynasty?`〔${l(c.dynasty)}〕`:""}${c.author?l(c.author):""}`,c.type==="book"&&c.edition?l(c.edition):"",m].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:j=>i(c,j),children:[t.jsx("span",{className:"bim-sc-t",children:t.jsx(Bc,{text:p,query:n?l(n):void 0})}),u&&t.jsx("span",{className:"bim-sc-m",children:u}),c.descriptionSnippet&&t.jsx("p",{className:"bim-sc-s",children:Ao(c.descriptionSnippet).map((j,y)=>j.marked?t.jsx("mark",{children:l(j.text)},y):t.jsx(h.Fragment,{children:l(j.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(j=>t.jsx("span",{className:`bim-sr-tag ${j.cls}`,children:l(j.label)},j.label))})]})]},c.id)})]})};function Eg(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 Ig(e,n,i){const o=Math.max(1,Math.ceil(n/i));return Math.min(Math.max(1,e),o)}const Lg=({page:e,pageSize:n,total:i,totalLabel:o,onPage:s})=>{const a=Be().searchV4,{convert:l}=Ge(),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(Pt(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)})}),Eg(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)})})]})]})},Oc="(max-width: 719px)",Mg=`${Oc}, (pointer: coarse)`,Ag=`
|
|
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 ${Oc} {
|
|
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 ${Mg} {
|
|
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
|
-
`,Vo="bim-search-view",Br=50,Sa=5,li=1e3;function Bi(e){return e>=li?`${li.toLocaleString()}+`:e.toLocaleString()}const Rg={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function Ig(e){return e&&Rg[e.toLowerCase()]||"all"}function Lg(e){return e==="all"?null:e}const _a=["work","collection","book","entity"],Ag={work:"works",collection:"collections",book:"books",entity:"entities"},Mg={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function Pg(){try{return window.localStorage.getItem(Vo)==="card"?"card":"table"}catch{return"table"}}function Bg(e){try{window.localStorage.setItem(Vo,e)}catch{}}const Tn=(e,n)=>(e==null?void 0:e[Mg[n]])??0,Or=(e,n)=>(e==null?void 0:e[Ag[n]])??[],Rc=({transport:e,query:n,filters:i,onFiltersChange:o,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const m=Ae(),g=m.searchV4,{convert:u}=Ge(),h=!!e.supportsSearchFilters,x=f.useMemo(()=>h?i:ar,[h,i]),[j,y]=f.useState("table");f.useEffect(()=>{y(Pg())},[]);const S=O=>{y(O),Bg(O)},[b,k]=f.useState(l??"all"),w=f.useRef(b);w.current=b,f.useEffect(()=>{l!==void 0&&l!==w.current&&(k(l),$(1))},[l]);const[v,$]=f.useState(c&&c>0?c:1),_=f.useRef(v);_.current=v,f.useEffect(()=>{c!==void 0&&c>0&&c!==_.current&&$(c)},[c]);const C=f.useRef(null),I=f.useCallback(O=>{var ke;$(O),p==null||p(O);const ee=C.current;ee&&ee.getBoundingClientRect().top<0&&((ke=ee.scrollIntoView)==null||ke.call(ee,{block:"start",behavior:"instant"}))},[p]),[E,T]=f.useState(null),[N,P]=f.useState(null),[W,L]=f.useState(!1),[K,Q]=f.useState(""),Z=Ki(x).toString(),ue=dr(x)>0,J=Ki({...x,sort:""}).toString(),le=f.useRef({query:n,filterOnlyKey:J,sort:x.sort});f.useEffect(()=>{const O=le.current;O.query!==n||O.filterOnlyKey!==J?(k("all"),$(1)):O.sort!==x.sort&&$(1),le.current={query:n,filterOnlyKey:J,sort:x.sort}},[n,J,x.sort]),f.useEffect(()=>{let O=!1;return L(!0),Q(""),(async()=>{try{let ee;if(e.searchAll)ee=await e.searchAll(n,Sa,x);else{const ke=["work","book","collection","entity"],ve=await Promise.all(ke.map(Ve=>e.search(n,Ve,{page:1,pageSize:Sa,filters:x})));ee={works:ve[0].entries,books:ve[1].entries,collections:ve[2].entries,entities:ve[3].entries,totalWorks:ve[0].total,totalBooks:ve[1].total,totalCollections:ve[2].total,totalEntities:ve[3].total}}O||T(ee)}catch(ee){O||(Q(ee instanceof Error?ee.message:String(ee)),T(null))}finally{O||L(!1)}})(),()=>{O=!0}},[e,n,Z]);const H=b;f.useEffect(()=>{if(b==="all"){P(null);return}let O=!1;return L(!0),(async()=>{try{const ee=await e.search(n,b,{page:v,pageSize:Br,filters:x});O||P({key:H,entries:ee.entries,total:ee.total})}catch(ee){O||(Q(ee instanceof Error?ee.message:String(ee)),P(null))}finally{O||L(!1)}})(),()=>{O=!0}},[e,n,Z,b,v]);const oe=N&&N.key===H?N:null;f.useEffect(()=>{if(b==="all"||!oe||W)return;const O=Math.min(oe.total,li),ee=zg(v,O,Br);oe.entries.length===0&&O>0&&ee!==v&&($(ee),p==null||p(ee))},[b,oe,W,v]);const be=f.useMemo(()=>_a.filter(O=>Tn(E,O)>0),[E]),ze=be.reduce((O,ee)=>O+Tn(E,ee),0),Le=be.some(O=>Tn(E,O)>=li)?`${ze.toLocaleString()}+`:ze.toLocaleString(),_e=!W&&!K&&E!==null&&ze===0,re=f.useCallback(O=>{k(O),$(1),d==null||d(O)},[d]),xe=f.useMemo(()=>{const O=[];return x.dynasty.forEach(ee=>O.push({name:ee,remove:()=>o({...x,dynasty:x.dynasty.filter(ke=>ke!==ee)})})),x.classification.forEach(ee=>{var ke;return O.push({name:ee?((ke=cr.find(ve=>ve.value===ee))==null?void 0:ke.label)??ee:m.searchPage.unclassified,remove:()=>o({...x,classification:x.classification.filter(ve=>ve!==ee)})})}),x.hasImage&&O.push({name:g.hasImage,remove:()=>o({...x,hasImage:!1})}),x.hasText&&O.push({name:g.hasText,remove:()=>o({...x,hasText:!1})}),x.hasCollated&&O.push({name:g.hasCollated,remove:()=>o({...x,hasCollated:!1})}),x.loss&&O.push({name:`${g.extant}:${m.searchPage.loss[x.loss]}`,remove:()=>o({...x,loss:""})}),O},[x,o,g,m]),R={query:n,onEntryLinkClick:s,typeName:a},se=O=>j==="table"?t.jsx(ka,{entries:O,...R}):t.jsx(wa,{entries:O,...R}),de=_a.flatMap(O=>Or(E,O));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":h?void 0:"true",children:[t.jsx("style",{children:Eg}),h&&t.jsx(_g,{filters:x,onChange:o}),t.jsxs("div",{className:"bim-sr-main","aria-busy":W,ref:C,children:[be.length>0&&t.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":m.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${r("rule")}`},children:[t.jsxs($a,{on:b==="all",onClick:()=>re("all"),children:[m.search.allTab," ",t.jsx("small",{children:Le})]}),be.map(O=>t.jsxs($a,{on:b===O,onClick:()=>re(O),children:[a(O)," ",t.jsx("small",{children:Bi(Tn(E,O))})]},O))]}),t.jsxs("div",{className:"bim-sr-tools",children:[h&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":u(g.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>o({...x,sort:""}),children:u(g.sortRelevance)}),["era","title"].map(O=>{const ee=x.sort.startsWith(`${O}:`)?x.sort.endsWith("desc")?"desc":"asc":null,ke=O==="era"?g.sortEra:g.sortTitle,ve=O==="era"?ee==="desc"?g.sortEraDesc:g.sortEraAsc:ee==="desc"?g.sortTitleDesc:g.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":ee!==null,title:u(ve),onClick:()=>o({...x,sort:`${O}:${ee==="asc"?"desc":"asc"}`}),children:[u(ke),ee?t.jsxs("span",{"aria-hidden":"true",children:[" ",ee==="asc"?"↑":"↓"]}):null]},O)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":u(g.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":j==="table",onClick:()=>S("table"),children:u(g.viewTable)}),t.jsx("button",{type:"button","aria-pressed":j==="card",onClick:()=>S("card"),children:u(g.viewCard)})]})]}),ue&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:u(Bt(g.filteredCount,{n:Le}))}),xe.map(O=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":u(Bt(g.removeFilter,{name:O.name})),onClick:O.remove,children:[u(O.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},O.name))]}),K&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:K}),_e&&t.jsx("div",{className:"bim-sr-empty",children:u(ue?g.emptyFiltered:Bt(m.search.noResultsFor,{query:n}))}),!K&&!_e&&b==="all"&&E&&(j==="table"?t.jsxs(t.Fragment,{children:[t.jsx(ka,{entries:de,...R}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:u(g.limitedNote)})]}):t.jsx(t.Fragment,{children:be.map(O=>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(Gn,{type:O,size:8}),a(O),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:r("meta-fg")},children:[Bi(Tn(E,O))," ",m.unit.items]})]}),Tn(E,O)>Or(E,O).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>re(O),children:m.action.viewAll})]}),t.jsx(wa,{entries:Or(E,O),...R})]},O))})),!K&&b!=="all"&&!oe&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:m.search.loading}),!K&&b!=="all"&&oe&&oe.entries.length>0&&t.jsxs(t.Fragment,{children:[se(oe.entries),t.jsx(Ng,{page:v,pageSize:Br,total:Math.min(oe.total,li),totalLabel:Bi(oe.total),onPage:I})]}),!K&&b!=="all"&&oe&&oe.entries.length===0&&!W&&t.jsxs("div",{className:"bim-sr-empty",children:[u(ue?g.emptyFiltered:Bt(m.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>re("all"),children:m.search.allTab})})]})]})]})};function $a({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 Wn="bim-recent-ids",Ca="bim-recent-entries",za=50;function mn(){try{const e=localStorage.getItem(Wn);if(e)return JSON.parse(e);const n=localStorage.getItem(Ca);if(n){const i=JSON.parse(n).map(o=>o.id);return localStorage.setItem(Wn,JSON.stringify(i)),localStorage.removeItem(Ca),i}return[]}catch{return[]}}function ro(e){try{const n=mn().filter(i=>i!==e);n.unshift(e),n.length>za&&(n.length=za),localStorage.setItem(Wn,JSON.stringify(n))}catch{}}function Ic(e){try{const n=mn().filter(i=>i!==e);localStorage.setItem(Wn,JSON.stringify(n))}catch{}}function Go(){try{localStorage.removeItem(Wn)}catch{}}async function Yo(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 Wr=5,Og=50,Wg=200,Na={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},oo=({transport:e,indexSource:n="local",syncConfig:i,onEntryClick:o,onNewEntry:s,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c,hideModeIndicator:p,resultVariant:m="compact",renderEntry:g,initialQuery:u,onQueryChange:h,headerRight:x,reserveViewportHeight:j=!1,filtersEnabled:y=!1,filters:S=ar,onFiltersChange:b,resultTab:k,onResultTabChange:w,resultPage:v,onResultPageChange:$})=>{const _=Ae(),C=[{type:"work",name:_.indexType.work,key:"works"},{type:"book",name:_.indexType.book,key:"books"},{type:"collection",name:_.indexType.collection,key:"collections"},{type:"entity",name:_.indexType.entity,key:"entities"}],I=["work","collection","book","entity"],[E,T]=f.useState(u??""),[N,P]=f.useState(null),[W,L]=f.useState(u??""),K=Ki(S).toString(),[Q,Z]=f.useState(S);f.useEffect(()=>{Z(S)},[K]);const ue=G=>{Z(G),b==null||b(G)},[J,le]=f.useState(null),[H,oe]=f.useState("all"),[be,ze]=f.useState(!1),[Le,_e]=f.useState(null),[re,xe]=f.useState(""),[R,se]=f.useState(!(u!=null&&u.trim())),[de,O]=f.useState(mn),[ee,ke]=f.useState([]),[ve,Ve]=f.useState(!1),[F,fe]=f.useState(!1),[te,U]=f.useState(null),[pe,Me]=f.useState(null),Ke=f.useRef(void 0),nt=f.useRef(!1),it=f.useCallback(async(G,Se)=>{if(!G.trim()){se(!0),P(null),le(null);return}if(se(!1),y){L(G);return}ze(!0),xe("");try{if(e.searchAll){const ye=await e.searchAll(G,Se??Wr);P(ye)}else{const ye=["work","book","collection","entity"],Ee=await Promise.all(ye.map(Xe=>e.search(G,Xe,{page:1,pageSize:Se??Wr})));P({works:Ee[0].entries,books:Ee[1].entries,collections:Ee[2].entries,entities:Ee[3].entries,totalWorks:Ee[0].total,totalBooks:Ee[1].total,totalCollections:Ee[2].total,totalEntities:Ee[3].total})}}catch(ye){xe(ye instanceof Error?ye.message:String(ye)),P(null)}finally{ze(!1)}},[e,y]);f.useEffect(()=>{let G=!1;const Se=()=>{var Qe,ut;const ye=["work","book","collection","entity"],Ee=Promise.all(ye.map(X=>e.loadEntries(X,{page:1,pageSize:1}).catch(()=>({total:0})))),Xe=((Qe=e.getResourceCounts)==null?void 0:Qe.call(e).catch(()=>null))??Promise.resolve(null),Fe=((ut=e.getSubtypeStats)==null?void 0:ut.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([Ee,Xe,Fe]).then(([X,$e,je])=>{G||(U({works:X[0].total,books:X[1].total,collections:X[2].total,entities:X[3].total,hasText:$e==null?void 0:$e.hasText,hasImage:$e==null?void 0:$e.hasImage}),je&&Me(je))})};return e.getCounts?e.getCounts().then(ye=>{var Ee,Xe;G||(U({works:ye.works,books:ye.books,collections:ye.collections,entities:ye.entities,hasText:(Ee=ye.resourceCounts)==null?void 0:Ee.hasText,hasImage:(Xe=ye.resourceCounts)==null?void 0:Xe.hasImage}),ye.subtypeStats&&Me(ye.subtypeStats))}).catch(()=>{G||Se()}):Se(),()=>{G=!0}},[e]),f.useEffect(()=>{nt.current||!(u!=null&&u.trim())||(nt.current=!0,it(u))},[u,it]);const at=f.useCallback(G=>{if(T(G),!G.trim()){h==null||h(G),se(!0),P(null),le(null),oe("all");return}Ke.current&&clearTimeout(Ke.current),Ke.current=setTimeout(()=>{le(null),oe("all"),h==null||h(G),it(G)},Wg)},[it,h]),lt=f.useCallback(G=>{Ke.current&&clearTimeout(Ke.current),oe("all"),h==null||h(G),it(G)},[it,h]),rt=f.useCallback(G=>{le(G),it(E,Og)},[E,it]);f.useEffect(()=>{if(!de.length){ke([]);return}let G=!1;return Ve(!0),Promise.all(de.slice(0,10).map(Se=>Yo(e,Se))).then(Se=>{G||(ke(Se),Ve(!1))}),()=>{G=!0}},[de,e]);const Pe=G=>{_e(G.id),ro(G.id),O(mn()),o==null||o(G)},z=(G,Se)=>{if(o&&Hg(Se)){Se.preventDefault(),Pe(G);return}ro(G.id),O(mn())},ne=G=>{Ic(G),O(mn())},q=()=>{Go(),O([])},he=G=>C.find(Se=>Se.type===G),Ie=!R&&!N&&!re,M=N&&(N.works.length>0||N.books.length>0||N.collections.length>0),me=t.jsxs(t.Fragment,{children:[t.jsx(dc,{transport:e,value:E,onChange:at,onSearch:lt,onEntrySelect:Pe}),y&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const G=E.trim();G&&cc(G),lt(E)},children:_.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:_.action.newEntry})]});return t.jsxs("div",{className:"bim-browser-container",style:j?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:Dg+(y?Ug:"")}),(!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:_.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!p&&t.jsx(lc,{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:me})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:me}),R&&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:te&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:pe?t.jsxs(t.Fragment,{children:[(pe.book??0)>0&&t.jsxs(t.Fragment,{children:[_.searchPage.statBook," ",t.jsx("strong",{style:{color:r("fg")},children:pe.book.toLocaleString()})," ",_.unit.bu,_.searchPage.statComma,t.jsx("strong",{style:{color:r("fg")},children:te.books.toLocaleString()})," ",_.searchPage.statBookCopies]}),pe.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statArticle," ",t.jsx("strong",{style:{color:r("fg")},children:pe.article.toLocaleString()})," ",_.searchPage.statArticleUnit]}):null,pe.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statPoem," ",t.jsx("strong",{style:{color:r("fg")},children:pe.poem.toLocaleString()})," ",_.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statCollection," ",t.jsx("strong",{style:{color:r("fg")},children:te.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[_.indexType.work," ",t.jsx("strong",{style:{color:r("fg")},children:te.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.book," ",t.jsx("strong",{style:{color:r("fg")},children:te.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.collection," ",t.jsx("strong",{style:{color:r("fg")},children:te.collections.toLocaleString()}),te.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.entity," ",t.jsx("strong",{style:{color:r("fg")},children:te.entities.toLocaleString()})]})]})}),te.hasImage!=null&&te.hasText!=null&&t.jsxs("span",{children:[_.resourceType.image," ",t.jsx("strong",{style:{color:r("fg")},children:te.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.resourceType.text," ",t.jsx("strong",{style:{color:r("fg")},children:te.hasText.toLocaleString()})]})]})}),y&&!R&&t.jsx(Rc,{transport:e,query:W,filters:Q,onFiltersChange:ue,onEntryLinkClick:z,typeName:G=>he(G).name,tab:k,onTabChange:w,page:v,onPageChange:$}),!(y&&!R)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:be||Ie?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg"),minHeight:Fg,boxSizing:"border-box"},children:_.search.searching}):re?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:r("desc-fg")},children:re})}):R?t.jsx("div",{style:{flex:1},children:ve?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg")},children:_.search.loading}):ee.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:_.search.recentBrowse}),t.jsx("button",{onClick:q,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:_.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:ee.slice(0,F?10:3).map(G=>G.notFound?t.jsx(Kg,{id:G.id,onRemove:ne,t:_},G.id):t.jsx(Ta,{entry:G,selected:Le===G.id,onClick:z,getConfig:he,onRemove:ne},G.id))}),!F&&ee.length>3&&t.jsx("button",{onClick:()=>fe(!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:_.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:_.search.searchTitle}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:_.search.searchSubtitle})]})}):M?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:Vg}),(()=>{const G=Fe=>N[Na[Fe]]??0,Se=I.map(Fe=>C.find(Qe=>Qe.type===Fe)).filter(Fe=>G(Fe.key)>0);if(Se.length<2)return null;const ye=Se.reduce((Fe,Qe)=>Fe+G(Qe.key),0),Ee=Fe=>{if(oe(Fe),Fe!=="all"&&J!==Fe){const Qe=C.find(X=>X.type===Fe),ut=(N[Qe.key]??[]).length;G(Qe.key)>ut&&rt(Fe)}},Xe=Fe=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:r(Fe?"fg":"desc-fg"),fontWeight:Fe?700:400,boxShadow:Fe?`inset 0 -2px 0 ${r("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":_.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":H==="all",style:Xe(H==="all"),onClick:()=>Ee("all"),children:[_.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:ye.toLocaleString()})]}),Se.map(Fe=>t.jsxs("button",{type:"button","aria-pressed":H===Fe.type,style:Xe(H===Fe.type),onClick:()=>Ee(Fe.type),children:[Fe.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:G(Fe.key).toLocaleString()})]},Fe.type))]})})(),C.map(({type:G,name:Se,key:ye})=>{const Ee=N[ye]??[],Xe=Na[ye],Fe=N[Xe]??0;if(Ee.length===0||H!=="all"&&H!==G)return null;const ut=H==="all"&&!(J===G)&&Fe>Wr;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(Gn,{type:G})," ",Se,t.jsxs("span",{style:{fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:[Fe," ",_.unit.items]})]}),ut&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>rt(G),style:{border:"none",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"12px"},children:_.action.viewAll})]}),t.jsx("div",{style:m==="list"?{display:"flex",flexDirection:"column",gap:0}:m==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:Ee.map(X=>{if(g)return t.jsx(f.Fragment,{children:g(X)},X.id);const $e=m==="card"?Yg:Ta;return t.jsx($e,{entry:X,selected:Le===X.id,onClick:z,getConfig:he,query:E},X.id)})})]},G)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:Bt(_.search.noResultsFor,{query:E})}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:_.search.tryOther})]})})]})},Fg=240;function Hg(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const Dg=`
|
|
120
|
+
`,Xo="bim-search-view",Ur=50,Ea=5,pi=1e3;function Wi(e){return e>=pi?`${pi.toLocaleString()}+`:e.toLocaleString()}const Pg={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function Bg(e){return e&&Pg[e.toLowerCase()]||"all"}function Og(e){return e==="all"?null:e}const Ia=["work","collection","book","entity"],Wg={work:"works",collection:"collections",book:"books",entity:"entities"},Fg={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function Hg(){try{return window.localStorage.getItem(Xo)==="card"?"card":"table"}catch{return"table"}}function Dg(e){try{window.localStorage.setItem(Xo,e)}catch{}}const Rn=(e,n)=>(e==null?void 0:e[Fg[n]])??0,Vr=(e,n)=>(e==null?void 0:e[Wg[n]])??[],Wc=({transport:e,query:n,filters:i,onFiltersChange:o,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const m=Be(),g=m.searchV4,{convert:u}=Ge(),f=!!e.supportsSearchFilters,x=h.useMemo(()=>f?i:dr,[f,i]),[j,y]=h.useState("table");h.useEffect(()=>{y(Hg())},[]);const S=M=>{y(M),Dg(M)},[b,v]=h.useState(l??"all"),w=h.useRef(b);w.current=b,h.useEffect(()=>{l!==void 0&&l!==w.current&&(v(l),_(1))},[l]);const[k,_]=h.useState(c&&c>0?c:1),$=h.useRef(k);$.current=k,h.useEffect(()=>{c!==void 0&&c>0&&c!==$.current&&_(c)},[c]);const C=h.useRef(null),L=h.useCallback(M=>{var ye;_(M),p==null||p(M);const J=C.current;J&&J.getBoundingClientRect().top<0&&((ye=J.scrollIntoView)==null||ye.call(J,{block:"start",behavior:"instant"}))},[p]),[E,T]=h.useState(null),[N,W]=h.useState(null),[F,R]=h.useState(!1),[G,Q]=h.useState(""),ie=Zi(x).toString(),de=mr(x)>0,q=Zi({...x,sort:""}).toString(),ee=h.useRef({query:n,filterOnlyKey:q,sort:x.sort});h.useEffect(()=>{const M=ee.current;M.query!==n||M.filterOnlyKey!==q?(v("all"),_(1)):M.sort!==x.sort&&_(1),ee.current={query:n,filterOnlyKey:q,sort:x.sort}},[n,q,x.sort]),h.useEffect(()=>{let M=!1;return R(!0),Q(""),(async()=>{try{let J;if(e.searchAll)J=await e.searchAll(n,Ea,x);else{const ye=["work","book","collection","entity"],je=await Promise.all(ye.map(Ue=>e.search(n,Ue,{page:1,pageSize:Ea,filters:x})));J={works:je[0].entries,books:je[1].entries,collections:je[2].entries,entities:je[3].entries,totalWorks:je[0].total,totalBooks:je[1].total,totalCollections:je[2].total,totalEntities:je[3].total}}M||T(J)}catch(J){M||(Q(J instanceof Error?J.message:String(J)),T(null))}finally{M||R(!1)}})(),()=>{M=!0}},[e,n,ie]);const U=b;h.useEffect(()=>{if(b==="all"){W(null);return}let M=!1;return R(!0),(async()=>{try{const J=await e.search(n,b,{page:k,pageSize:Ur,filters:x});M||W({key:U,entries:J.entries,total:J.total})}catch(J){M||(Q(J instanceof Error?J.message:String(J)),W(null))}finally{M||R(!1)}})(),()=>{M=!0}},[e,n,ie,b,k]);const se=N&&N.key===U?N:null;h.useEffect(()=>{if(b==="all"||!se||F)return;const M=Math.min(se.total,pi),J=Ig(k,M,Ur);se.entries.length===0&&M>0&&J!==k&&(_(J),p==null||p(J))},[b,se,F,k]);const pe=h.useMemo(()=>Ia.filter(M=>Rn(E,M)>0),[E]),_e=pe.reduce((M,J)=>M+Rn(E,J),0),Le=pe.some(M=>Rn(E,M)>=pi)?`${_e.toLocaleString()}+`:_e.toLocaleString(),Ee=!F&&!G&&E!==null&&_e===0,ue=h.useCallback(M=>{v(M),_(1),d==null||d(M)},[d]),be=h.useMemo(()=>{const M=[];return x.dynasty.forEach(J=>M.push({name:J,remove:()=>o({...x,dynasty:x.dynasty.filter(ye=>ye!==J)})})),x.classification.forEach(J=>{var ye;return M.push({name:J?((ye=ur.find(je=>je.value===J))==null?void 0:ye.label)??J:m.searchPage.unclassified,remove:()=>o({...x,classification:x.classification.filter(je=>je!==J)})})}),x.hasImage&&M.push({name:g.hasImage,remove:()=>o({...x,hasImage:!1})}),x.hasText&&M.push({name:g.hasText,remove:()=>o({...x,hasText:!1})}),x.hasCollated&&M.push({name:g.hasCollated,remove:()=>o({...x,hasCollated:!1})}),x.loss&&M.push({name:`${g.extant}:${m.searchPage.loss[x.loss]}`,remove:()=>o({...x,loss:""})}),M},[x,o,g,m]),A={query:n,onEntryLinkClick:s,typeName:a},K=M=>j==="table"?t.jsx(Ta,{entries:M,...A}):t.jsx(Ra,{entries:M,...A}),le=Ia.flatMap(M=>Vr(E,M));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":f?void 0:"true",children:[t.jsx("style",{children:Ag}),f&&t.jsx(Tg,{filters:x,onChange:o}),t.jsxs("div",{className:"bim-sr-main","aria-busy":F,ref:C,children:[pe.length>0&&t.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":m.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${r("rule")}`},children:[t.jsxs(La,{on:b==="all",onClick:()=>ue("all"),children:[m.search.allTab," ",t.jsx("small",{children:Le})]}),pe.map(M=>t.jsxs(La,{on:b===M,onClick:()=>ue(M),children:[a(M)," ",t.jsx("small",{children:Wi(Rn(E,M))})]},M))]}),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":u(g.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>o({...x,sort:""}),children:u(g.sortRelevance)}),["era","title"].map(M=>{const J=x.sort.startsWith(`${M}:`)?x.sort.endsWith("desc")?"desc":"asc":null,ye=M==="era"?g.sortEra:g.sortTitle,je=M==="era"?J==="desc"?g.sortEraDesc:g.sortEraAsc:J==="desc"?g.sortTitleDesc:g.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":J!==null,title:u(je),onClick:()=>o({...x,sort:`${M}:${J==="asc"?"desc":"asc"}`}),children:[u(ye),J?t.jsxs("span",{"aria-hidden":"true",children:[" ",J==="asc"?"↑":"↓"]}):null]},M)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":u(g.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":j==="table",onClick:()=>S("table"),children:u(g.viewTable)}),t.jsx("button",{type:"button","aria-pressed":j==="card",onClick:()=>S("card"),children:u(g.viewCard)})]})]}),de&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:u(Pt(g.filteredCount,{n:Le}))}),be.map(M=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":u(Pt(g.removeFilter,{name:M.name})),onClick:M.remove,children:[u(M.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},M.name))]}),G&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:G}),Ee&&t.jsx("div",{className:"bim-sr-empty",children:u(de?g.emptyFiltered:Pt(m.search.noResultsFor,{query:n}))}),!G&&!Ee&&b==="all"&&E&&(j==="table"?t.jsxs(t.Fragment,{children:[t.jsx(Ta,{entries:le,...A}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:u(g.limitedNote)})]}):t.jsx(t.Fragment,{children:pe.map(M=>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(Yn,{type:M,size:8}),a(M),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:r("meta-fg")},children:[Wi(Rn(E,M))," ",m.unit.items]})]}),Rn(E,M)>Vr(E,M).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>ue(M),children:m.action.viewAll})]}),t.jsx(Ra,{entries:Vr(E,M),...A})]},M))})),!G&&b!=="all"&&!se&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:m.search.loading}),!G&&b!=="all"&&se&&se.entries.length>0&&t.jsxs(t.Fragment,{children:[K(se.entries),t.jsx(Lg,{page:k,pageSize:Ur,total:Math.min(se.total,pi),totalLabel:Wi(se.total),onPage:L})]}),!G&&b!=="all"&&se&&se.entries.length===0&&!F&&t.jsxs("div",{className:"bim-sr-empty",children:[u(de?g.emptyFiltered:Pt(m.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>ue("all"),children:m.search.allTab})})]})]})]})};function La({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 Fn="bim-recent-ids",Ma="bim-recent-entries",Aa=50;function un(){try{const e=localStorage.getItem(Fn);if(e)return JSON.parse(e);const n=localStorage.getItem(Ma);if(n){const i=JSON.parse(n).map(o=>o.id);return localStorage.setItem(Fn,JSON.stringify(i)),localStorage.removeItem(Ma),i}return[]}catch{return[]}}function co(e){try{const n=un().filter(i=>i!==e);n.unshift(e),n.length>Aa&&(n.length=Aa),localStorage.setItem(Fn,JSON.stringify(n))}catch{}}function Fc(e){try{const n=un().filter(i=>i!==e);localStorage.setItem(Fn,JSON.stringify(n))}catch{}}function Zo(){try{localStorage.removeItem(Fn)}catch{}}async function Jo(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 Gr=5,Ug=50,Vg=200,Pa={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},po=({transport:e,indexSource:n="local",syncConfig:i,onEntryClick:o,onNewEntry:s,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c,hideModeIndicator:p,resultVariant:m="compact",renderEntry:g,initialQuery:u,onQueryChange:f,headerRight:x,reserveViewportHeight:j=!1,filtersEnabled:y=!1,filters:S=dr,onFiltersChange:b,resultTab:v,onResultTabChange:w,resultPage:k,onResultPageChange:_})=>{const $=Be(),C=[{type:"work",name:$.indexType.work,key:"works"},{type:"book",name:$.indexType.book,key:"books"},{type:"collection",name:$.indexType.collection,key:"collections"},{type:"entity",name:$.indexType.entity,key:"entities"}],L=["work","collection","book","entity"],[E,T]=h.useState(u??""),[N,W]=h.useState(null),[F,R]=h.useState(u??""),G=Zi(S).toString(),[Q,ie]=h.useState(S);h.useEffect(()=>{ie(S)},[G]);const de=X=>{ie(X),b==null||b(X)},[q,ee]=h.useState(null),[U,se]=h.useState("all"),[pe,_e]=h.useState(!1),[Le,Ee]=h.useState(null),[ue,be]=h.useState(""),[A,K]=h.useState(!(u!=null&&u.trim())),[le,M]=h.useState(un),[J,ye]=h.useState([]),[je,Ue]=h.useState(!1),[H,me]=h.useState(!1),[ge,ne]=h.useState(null),[Ne,he]=h.useState(null),Ce=h.useRef(void 0),Ie=h.useRef(!1),Qe=h.useCallback(async(X,Te)=>{if(!X.trim()){K(!0),W(null),ee(null);return}if(K(!1),y){R(X);return}_e(!0),be("");try{if(e.searchAll){const Se=await e.searchAll(X,Te??Gr);W(Se)}else{const Se=["work","book","collection","entity"],ze=await Promise.all(Se.map(qe=>e.search(X,qe,{page:1,pageSize:Te??Gr})));W({works:ze[0].entries,books:ze[1].entries,collections:ze[2].entries,entities:ze[3].entries,totalWorks:ze[0].total,totalBooks:ze[1].total,totalCollections:ze[2].total,totalEntities:ze[3].total})}}catch(Se){be(Se instanceof Error?Se.message:String(Se)),W(null)}finally{_e(!1)}},[e,y]);h.useEffect(()=>{let X=!1;const Te=()=>{var it,pt;const Se=["work","book","collection","entity"],ze=Promise.all(Se.map(Z=>e.loadEntries(Z,{page:1,pageSize:1}).catch(()=>({total:0})))),qe=((it=e.getResourceCounts)==null?void 0:it.call(e).catch(()=>null))??Promise.resolve(null),Pe=((pt=e.getSubtypeStats)==null?void 0:pt.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([ze,qe,Pe]).then(([Z,$e,ke])=>{X||(ne({works:Z[0].total,books:Z[1].total,collections:Z[2].total,entities:Z[3].total,hasText:$e==null?void 0:$e.hasText,hasImage:$e==null?void 0:$e.hasImage}),ke&&he(ke))})};return e.getCounts?e.getCounts().then(Se=>{var ze,qe;X||(ne({works:Se.works,books:Se.books,collections:Se.collections,entities:Se.entities,hasText:(ze=Se.resourceCounts)==null?void 0:ze.hasText,hasImage:(qe=Se.resourceCounts)==null?void 0:qe.hasImage}),Se.subtypeStats&&he(Se.subtypeStats))}).catch(()=>{X||Te()}):Te(),()=>{X=!0}},[e]),h.useEffect(()=>{Ie.current||!(u!=null&&u.trim())||(Ie.current=!0,Qe(u))},[u,Qe]);const gt=h.useCallback(X=>{if(T(X),!X.trim()){f==null||f(X),K(!0),W(null),ee(null),se("all");return}Ce.current&&clearTimeout(Ce.current),Ce.current=setTimeout(()=>{ee(null),se("all"),f==null||f(X),Qe(X)},Vg)},[Qe,f]),lt=h.useCallback(X=>{Ce.current&&clearTimeout(Ce.current),se("all"),f==null||f(X),Qe(X)},[Qe,f]),tt=h.useCallback(X=>{ee(X),Qe(E,Ug)},[E,Qe]);h.useEffect(()=>{if(!le.length){ye([]);return}let X=!1;return Ue(!0),Promise.all(le.slice(0,10).map(Te=>Jo(e,Te))).then(Te=>{X||(ye(Te),Ue(!1))}),()=>{X=!0}},[le,e]);const Oe=X=>{Ee(X.id),co(X.id),M(un()),o==null||o(X)},z=(X,Te)=>{if(o&&Yg(Te)){Te.preventDefault(),Oe(X);return}co(X.id),M(un())},re=X=>{Fc(X),M(un())},te=()=>{Zo(),M([])},fe=X=>C.find(Te=>Te.type===X),Me=!A&&!N&&!ue,P=N&&(N.works.length>0||N.books.length>0||N.collections.length>0),ce=t.jsxs(t.Fragment,{children:[t.jsx(bc,{transport:e,value:E,onChange:gt,onSearch:lt,onEntrySelect:Oe}),y&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const X=E.trim();X&&xc(X),lt(E)},children:$.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:$.action.newEntry})]});return t.jsxs("div",{className:"bim-browser-container",style:j?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:Kg+(y?qg:"")}),(!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:$.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!p&&t.jsx(fc,{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:ce})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:ce}),A&&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:ge&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:Ne?t.jsxs(t.Fragment,{children:[(Ne.book??0)>0&&t.jsxs(t.Fragment,{children:[$.searchPage.statBook," ",t.jsx("strong",{style:{color:r("fg")},children:Ne.book.toLocaleString()})," ",$.unit.bu,$.searchPage.statComma,t.jsx("strong",{style:{color:r("fg")},children:ge.books.toLocaleString()})," ",$.searchPage.statBookCopies]}),Ne.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),$.searchPage.statArticle," ",t.jsx("strong",{style:{color:r("fg")},children:Ne.article.toLocaleString()})," ",$.searchPage.statArticleUnit]}):null,Ne.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),$.searchPage.statPoem," ",t.jsx("strong",{style:{color:r("fg")},children:Ne.poem.toLocaleString()})," ",$.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),$.searchPage.statCollection," ",t.jsx("strong",{style:{color:r("fg")},children:ge.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[$.indexType.work," ",t.jsx("strong",{style:{color:r("fg")},children:ge.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),$.indexType.book," ",t.jsx("strong",{style:{color:r("fg")},children:ge.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),$.indexType.collection," ",t.jsx("strong",{style:{color:r("fg")},children:ge.collections.toLocaleString()}),ge.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),$.indexType.entity," ",t.jsx("strong",{style:{color:r("fg")},children:ge.entities.toLocaleString()})]})]})}),ge.hasImage!=null&&ge.hasText!=null&&t.jsxs("span",{children:[$.resourceType.image," ",t.jsx("strong",{style:{color:r("fg")},children:ge.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),$.resourceType.text," ",t.jsx("strong",{style:{color:r("fg")},children:ge.hasText.toLocaleString()})]})]})}),y&&!A&&t.jsx(Wc,{transport:e,query:F,filters:Q,onFiltersChange:de,onEntryLinkClick:z,typeName:X=>fe(X).name,tab:v,onTabChange:w,page:k,onPageChange:_}),!(y&&!A)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:pe||Me?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg"),minHeight:Gg,boxSizing:"border-box"},children:$.search.searching}):ue?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:r("desc-fg")},children:ue})}):A?t.jsx("div",{style:{flex:1},children:je?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg")},children:$.search.loading}):J.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:$.search.recentBrowse}),t.jsx("button",{onClick:te,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:$.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:J.slice(0,H?10:3).map(X=>X.notFound?t.jsx(Qg,{id:X.id,onRemove:re,t:$},X.id):t.jsx(Ba,{entry:X,selected:Le===X.id,onClick:z,getConfig:fe,onRemove:re},X.id))}),!H&&J.length>3&&t.jsx("button",{onClick:()=>me(!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:$.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:$.search.searchTitle}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:$.search.searchSubtitle})]})}):P?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:Xg}),(()=>{const X=Pe=>N[Pa[Pe]]??0,Te=L.map(Pe=>C.find(it=>it.type===Pe)).filter(Pe=>X(Pe.key)>0);if(Te.length<2)return null;const Se=Te.reduce((Pe,it)=>Pe+X(it.key),0),ze=Pe=>{if(se(Pe),Pe!=="all"&&q!==Pe){const it=C.find(Z=>Z.type===Pe),pt=(N[it.key]??[]).length;X(it.key)>pt&&tt(Pe)}},qe=Pe=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:r(Pe?"fg":"desc-fg"),fontWeight:Pe?700:400,boxShadow:Pe?`inset 0 -2px 0 ${r("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":$.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":U==="all",style:qe(U==="all"),onClick:()=>ze("all"),children:[$.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:Se.toLocaleString()})]}),Te.map(Pe=>t.jsxs("button",{type:"button","aria-pressed":U===Pe.type,style:qe(U===Pe.type),onClick:()=>ze(Pe.type),children:[Pe.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:X(Pe.key).toLocaleString()})]},Pe.type))]})})(),C.map(({type:X,name:Te,key:Se})=>{const ze=N[Se]??[],qe=Pa[Se],Pe=N[qe]??0;if(ze.length===0||U!=="all"&&U!==X)return null;const pt=U==="all"&&!(q===X)&&Pe>Gr;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(Yn,{type:X})," ",Te,t.jsxs("span",{style:{fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:[Pe," ",$.unit.items]})]}),pt&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>tt(X),style:{border:"none",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"12px"},children:$.action.viewAll})]}),t.jsx("div",{style:m==="list"?{display:"flex",flexDirection:"column",gap:0}:m==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:ze.map(Z=>{if(g)return t.jsx(h.Fragment,{children:g(Z)},Z.id);const $e=m==="card"?Jg:Ba;return t.jsx($e,{entry:Z,selected:Le===Z.id,onClick:z,getConfig:fe,query:E},Z.id)})})]},X)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:Pt($.search.noResultsFor,{query:E})}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:$.search.tryOther})]})})]})},Gg=240;function Yg(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const Kg=`
|
|
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
|
+
`,qg=`
|
|
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
|
+
`,Xg=`
|
|
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
|
-
}`,Lc={color:"inherit",textDecoration:"none"},Gg=({snippet:e})=>{const{convert:n}=Ge();return t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.6},children:Eo(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(f.Fragment,{children:n(i.text)},o))})},Yg=({entry:e,selected:n,onClick:i,getConfig:o,query:s})=>{const a=Ae(),{convert:l}=Ge(),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?`${Sn(e.juan_count)}${a.unit.juan}`:"",p=[...e.additional_titles||[],...e.attached_texts||[]],m=s&&p.length?p.find(h=>{const x=typeof h=="string"?h:h==null?void 0:h.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,g=r("cover-accent"),u=kt();return t.jsxs("a",{href:u(e.id),onClick:h=>i(e,h),className:"bim-result-card",style:{...Lc,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, ${g} 50%, ${r("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${g} 14%, ${r("bg")}), color-mix(in srgb, ${g} 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, ${g} 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:g},children:Array.from(d).map((h,x)=>t.jsx("span",{children:h},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)})]}),m&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg")},children:[a.search.alias,":",l(typeof m=="string"?m:m.book_title||"")]}),e.descriptionSnippet&&t.jsx(Gg,{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(Gn,{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})]})]})]})},Ta=({entry:e,selected:n,onClick:i,getConfig:o,query:s,onRemove:a})=>{const l=Ae(),{convert:d}=Ge(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(g=>{const u=typeof g=="string"?g:g==null?void 0:g.book_title;return u==null?void 0:u.toLowerCase().includes(s.toLowerCase())}):void 0,m=kt();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:m(e.id),onClick:g=>i(e,g),className:"bim-result-card",style:{...Lc,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(Gn,{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:[Sn(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:"×"})]})},Kg=({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 qg(e){var n,i,o;return!e.dynasty&&((n=e.dates)==null?void 0:n.birth)==null&&((i=e.dates)==null?void 0:i.death)==null&&(!e.alt_names||e.alt_names.length===0)&&!((o=e.description)!=null&&o.text)}function Xg({data:e}){var l,d;const{convert:n}=Ge(),{dynasty:i}=e,o=((l=e.dates)==null?void 0:l.birth)??void 0,s=((d=e.dates)==null?void 0:d.death)??void 0,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 Zg({alt_names:e}){const{convert:n}=Ge(),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 Jg({data:e}){const n=Ae(),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 Qg({works:e,transport:n,onNavigate:i,renderLink:o}){const s=Ae(),{convert:a}=Ge(),l=kt(),[d,c]=f.useState(new Map);f.useEffect(()=>{if(!n)return;let u=!1;const h=e.map(j=>j.work_id);return(async()=>{const j=new Map;if(n.getEntriesByIds)try{const k=await n.getEntriesByIds(h);let w=!0;for(let v=0;v<h.length;v++){const $=k[v];$!=null&&$.title?j.set(h[v],$.title):$!=null&&$.primary_name?j.set(h[v],$.primary_name):w=!1}if(w)return j}catch{}const y=[...h],S=8,b=new Array(S).fill(0).map(async()=>{for(;y.length;){const k=y.shift();if(!k)break;if(!j.has(k))try{if(n.getEntry){const $=await n.getEntry(k);if($!=null&&$.title){j.set(k,$.title);continue}}const w=await n.getItem(k),v=w&&(w.title||w.primary_name)||k;j.set(k,v)}catch{j.set(k,k)}}});return await Promise.all(b),j})().then(j=>{u||c(j)}),()=>{u=!0}},[e,n]);const p=new Map;for(const u of e){const h=u.role||"";p.has(h)||p.set(h,[]),p.get(h).push(u)}const m=["撰","編","注","輯","集","校","評","譯","述","作",""],g=[...p.keys()].sort((u,h)=>{const x=m.indexOf(u),j=m.indexOf(h);return x===-1&&j===-1?u.localeCompare(h):x===-1?1:j===-1?-1:x-j});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,")"]})]}),g.map(u=>{const h=p.get(u);return t.jsxs("div",{style:{marginBottom:"8px"},children:[u&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"2px"},children:[a(u)," ",t.jsxs("span",{style:{color:r("desc-fg")},children:["(",h.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:u?"16px":"0",listStyle:u?"disc":"none",fontSize:"14px",lineHeight:1.8},children:h.map((x,j)=>{const y=a(d.get(x.work_id)||x.work_id);return o?t.jsx("li",{children:o(x.work_id,y)},j):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})},j):t.jsx("li",{children:y},j)})})]},u)})]})}const Ac=({data:e,transport:n,onNavigate:i,renderLink:o,headerExtra:s,hideHeader:a})=>{var g;const l=Ae(),{convert:d}=Ge();let c=!1;try{c=Te.extractStatus(e.id)==="draft"}catch{}const p=qg(e),m=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(Xg,{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}),m&&e.subtype!=="people"&&t.jsx("span",{children:m}),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(Zg,{alt_names:e.alt_names}),t.jsx(Jg,{data:e}),((g=e.description)==null?void 0:g.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(Qg,{works:e.works,transport:n,onNavigate:i,renderLink:o})]})},ef=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function tf(e){const n=e.search(ef);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const Mc={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===nf(e))){const[a,l]=tf(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 nf(e){try{return decodeURI(e)}catch{return e}}const rf={...Mc,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},sn=({text:e,plainStrong:n,style:i,className:o})=>{const{convert:s}=Ge(),a=n?rf:Mc;return t.jsx("div",{className:o,style:i,children:t.jsx(Qu,{remarkPlugins:[em],components:a,children:s(e)})})};function Pc(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 of={book:r("type-book"),work:r("type-work"),collection:r("type-collection"),entity:r("type-entity")};function sf({type:e}){const n=Ae();return t.jsx("span",{style:Pc(of[e]),children:n.indexType[e]})}function af({isDraft:e}){const n=Ae(),i=r(e?"status-draft":"status-official");return t.jsx("span",{style:Pc(i),children:e?n.status.draft:n.status.official})}function lf({id:e}){const n=Ae(),[i,o]=f.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 Wt({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 Yt({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 Bc({authors:e,type:n,onNavigate:i,renderLink:o}){const{convert:s}=Ge();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(Ut,{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 Ut({id:e,label:n,onNavigate:i,renderLink:o}){const s=kt();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 cf({id:e,title:n,edition:i,type:o,isDraft:s,authors:a,volumeText:l,meta:d,headerExtra:c,onNavigate:p,renderLink:m}){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(sf,{type:o}),t.jsx(af,{isDraft:s}),t.jsx(lf,{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(Bc,{authors:a,type:o,onNavigate:p,renderLink:m}),d]})]})}function Oc({items:e,label:n,showMeta:i,onNavigate:o,renderLink:s}){const a=Ae(),{convert:l}=Ge();if(!e.length)return null;const[d,c]=f.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(Wt,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((p,m)=>{const g=d===m;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...g?{boxShadow:r("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(g?null:m),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:g?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(p.source)}),!g&&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:u=>u.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(Ut,{id:p.source_bid,label:a.action.view,onNavigate:o,renderLink:s})})]}),g&&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(Yt,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx(Yt,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx(Yt,{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)})]})]})]},m)})})]})}function df({items:e,onNavigate:n,renderLink:i}){const o=Ae();return t.jsx(Oc,{items:e,label:o.section.indexed,showMeta:!0,onNavigate:n,renderLink:i})}function Wc({items:e,onNavigate:n,renderLink:i}){const o=Ae();return t.jsx(Oc,{items:e,label:o.section.emendated,onNavigate:n,renderLink:i})}function Fc({label:e,items:n}){const{convert:i}=Ge();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(Wt,{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 pf({items:e}){const n=Ae();return t.jsx(Fc,{label:n.section.aliases,items:e})}function uf({items:e}){const n=Ae();return t.jsx(Fc,{label:n.section.attachedTexts,items:e})}function mf({items:e}){const n=Ae(),{convert:i}=Ge();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Wt,{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 gf({items:e}){const n=Ae(),{convert:i}=Ge();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Wt,{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.location||"")}),o.description&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),marginLeft:"8px"},children:i(o.description)})]},s))]})]}):null}function ff({items:e}){const n=Ae(),{convert:i}=Ge();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Wt,{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 Ea({title:e,ids:n,transport:i,onNavigate:o,renderLink:s}){const{convert:a}=Ge(),[l,d]=f.useState([]);return f.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(m=>({id:p,title:m?m.title:void 0,edition:m?m.edition:void 0,type:m?m.type:void 0})).catch(()=>({id:p})))).then(p=>{c||d(p)}),()=>{c=!0}},[n,i]),n.length?t.jsxs(t.Fragment,{children:[t.jsxs(Wt,{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(Ut,{id:c.id,label:p,onNavigate:o,renderLink:s})},c.id)})})]}):null}function Fr({book:e,onNavigate:n,renderLink:i}){const o=Ae(),{convert:s}=Ge(),[a,l]=f.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(Ut,{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(Po,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:i})})]})}function hf({ids:e,workData:n,transport:i,onNavigate:o,renderLink:s,footer:a}){const l=Ae(),{convert:d}=Ge(),[c,p]=f.useState([]);if(f.useEffect(()=>{if(!e.length){p([]);return}if(!i){p(e.map(j=>({id:j})));return}let x=!1;return Promise.all(e.map(j=>i.getItem(j).then(y=>({id:j,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:j})))).then(j=>{x||p(j)}),()=>{x=!0}},[e,i]),!e.length)return null;const m=c.length?c:e.map(x=>({id:x})),g=new Map(m.map(x=>[x.id,x])),u=n==null?void 0:n.version_graph,h=xf(e,u,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(Wt,{children:[l.section.relatedVersions,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",e.length,")"]})]}),a,h.useGrouping?t.jsxs(t.Fragment,{children:[h.coreIds.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:h.coreIds.map(x=>{const j=g.get(x);return j?t.jsx(Fr,{book:j,onNavigate:o,renderLink:s},x):null})}),h.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(j=>{const y=g.get(j);return y?t.jsx(Fr,{book:y,onNavigate:o,renderLink:s},j):null})})]},x.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:m.map(x=>t.jsx(Fr,{book:x,onNavigate:o,renderLink:s},x.id))})]})}function xf(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]),m=k=>{if(p.has(k))return!0;const w=n.node_groups[k];return w!=null&&c.has(w)},g=[],u=new Map,h=[];for(const k of e)if(!((b=n.excluded_books)!=null&&b.includes(k)))if(m(k))g.push(k);else{const w=n.node_groups[k];w?(u.has(w)||u.set(w,[]),u.get(w).push(k)):h.push(k)}if(h.length+[...u.values()].reduce((k,w)=>k+w.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const j=new Map((n.groups??[]).map(k=>[k.id,k])),y=[...u.entries()].map(([k,w])=>{const v=j.get(k);return{id:k,label:(v==null?void 0:v.label)??k,description:v==null?void 0:v.description,ids:w}});return h.length>0&&y.push({id:"__other__",label:i,description:void 0,ids:h}),{useGrouping:!0,coreIds:g,groupedIds:y}}function bf({workData:e,onNavigate:n,renderLink:i}){var l,d,c,p;const o=Ae(),{convert:s}=Ge(),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(Ut,{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:[Sn(e.juan_count.number),o.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(Bc,{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(sn,{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(Yt,{label:o.label.parentWork,children:t.jsx(Ut,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:i})})})]})]})}function yf({items:e,onNavigate:n,renderLink:i}){const o=Ae(),{convert:s}=Ge();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(Ut,{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:Bt(o.catalog.volume,{n:a.volume_index})})]},a.id))}):null}const Ko=({data:e,id:n,transport:i,onNavigate:o,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var W,L,K,Q,Z,ue,J,le;const p=Ae(),{convert:m}=Ge(),[g,u]=f.useState(null),[h,x]=f.useState(!1),[j,y]=f.useState(null),[S,b]=f.useState(null),[k,w]=f.useState([]),v=e||g,$=Te.splitExtraTitles(v==null?void 0:v.additional_titles);if(f.useEffect(()=>{if(e||!n||!i)return;let H=!1;return x(!0),y(null),i.getItem(n).then(oe=>{H||(oe?u(oe):y(p.misc.notFoundEntry))}).catch(oe=>{H||y(oe instanceof Error?oe.message:p.misc.loadFailed)}).finally(()=>{H||x(!1)}),()=>{H=!0}},[e,n,i]),f.useEffect(()=>{if(!v||!i){b(null),w([]);return}let H=!1;const oe=v.type==="book"||v.type==="collection"?v.work_id:void 0;if(oe?i.getItem(oe).then(be=>{!H&&be&&be.type==="work"&&b(be)}).catch(()=>{}):b(null),v.type==="book"){const be=v;be.contained_in&&be.contained_in.length>0?Promise.all(be.contained_in.map(ze=>{const Le=typeof ze=="string"?ze:ze.id,_e=typeof ze=="string"?void 0:ze.volume_index;return i.getItem(Le).then(re=>({id:Le,title:re&&re.title||Le,volume_index:_e})).catch(()=>({id:Le,title:Le,volume_index:_e}))})).then(ze=>{H||w(ze)}):w([])}else w([]);return()=>{H=!0}},[v,i]),h)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((H,oe)=>t.jsx("div",{style:{height:oe===1?"32px":"16px",width:`${H}px`,background:r("widget-border"),borderRadius:"4px",opacity:.4}},oe))})});if(j)return t.jsx("div",{className:d,style:{...c,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:j});if(!v)return null;if(v.type==="entity")return t.jsx("div",{className:d,style:c,children:t.jsx(Ac,{data:v,transport:i,onNavigate:o,renderLink:s,headerExtra:a})});const _=v.type==="book"?v:null,C=v.type==="collection"?v:null,I=v.type==="work"?v:null;let E=!1;try{E=Te.extractStatus(v.id)==="draft"}catch{}let T="";v.measure_info?T=m(v.measure_info):(W=v.juan_count)!=null&&W.number?T=Sn(v.juan_count.number)+p.unit.juan:(L=v.juan_count)!=null&&L.description&&(T=m(v.juan_count.description));const N=[],P=((K=v.publication_info)==null?void 0:K.year)??(v.type==="book"?ig(v):void 0);return P&&N.push(t.jsx(Yt,{label:p.label.year,children:P},"year")),(Q=v.current_location)!=null&&Q.name&&N.push(t.jsx(Yt,{label:p.label.currentLocation,children:m(v.current_location.name)},"loc")),(Z=v.page_count)!=null&&Z.description&&N.push(t.jsx(Yt,{label:p.label.pageCount,children:v.page_count.description},"page")),_!=null&&_.edition&&N.push(t.jsx(Yt,{label:p.label.edition,children:m(_.edition)},"ver")),I!=null&&I.parent_work&&N.push(t.jsx(Yt,{label:p.label.parentWork,children:t.jsx(Ut,{id:I.parent_work.id,label:m(I.parent_work.title),onNavigate:o,renderLink:s})},"pw")),I!=null&&I.parent_works&&I.parent_works.length>0&&!I.parent_work&&N.push(t.jsx(Yt,{label:p.label.parentWork,children:I.parent_works.map((H,oe)=>t.jsxs("span",{children:[oe>0&&"、",t.jsx(Ut,{id:H,onNavigate:o,renderLink:s})]},H))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(cf,{id:v.id,title:m(v.title),edition:v.edition?m(v.edition):void 0,type:v.type,isDraft:E,authors:v.authors,volumeText:T,meta:N,headerExtra:a,onNavigate:o,renderLink:s}),((ue=v.description)==null?void 0:ue.text)&&t.jsx(sn,{text:v.description.text,style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),v.appendix&&v.appendix.length>0&&t.jsx("div",{style:{marginTop:8,marginBottom:4},children:v.appendix.map((H,oe)=>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:m(H.title)}),t.jsx(sn,{text:H.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:r("fg")}})]},oe))}),k.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Wt,{children:p.section.containedIn}),t.jsx(yf,{items:k,onNavigate:o,renderLink:s})]}),S&&t.jsxs(t.Fragment,{children:[t.jsx(Wt,{children:p.section.belongsToWork}),t.jsx(bf,{workData:S,onNavigate:o,renderLink:s})]}),v.additional_works&&v.additional_works.length>0&&t.jsx(mf,{items:v.additional_works}),$.aliases.length>0&&t.jsx(pf,{items:$.aliases}),$.attached.length>0&&t.jsx(uf,{items:$.attached}),v.indexed_by&&v.indexed_by.length>0&&t.jsx(df,{items:v.indexed_by,onNavigate:o,renderLink:s}),v.emendated_by&&v.emendated_by.length>0&&t.jsx(Wc,{items:v.emendated_by,onNavigate:o,renderLink:s}),v.resources&&v.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Wt,{children:p.section.resources}),t.jsx(Po,{items:v.resources,resourceGroups:v.resource_groups,groupByType:!0,onNavigate:o,renderLink:s})]}),(_==null?void 0:_.location_history)&&_.location_history.length>0&&t.jsx(gf,{items:_.location_history}),(C==null?void 0:C.history)&&C.history.length>0&&t.jsx(ff,{items:C.history}),(_==null?void 0:_.related_books)&&_.related_books.length>0&&t.jsx(Ea,{title:p.section.relatedVersions,ids:pc(_),transport:i,onNavigate:o,renderLink:s}),(C==null?void 0:C.books)&&C.books.length>0&&t.jsx(Ea,{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(Wt,{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(H=>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(Ut,{id:H.id,label:m(H.title),onNavigate:o,renderLink:s})},H.id))})]}),(((J=I==null?void 0:I.books)==null?void 0:J.length)||0)+(((le=I==null?void 0:I.collections)==null?void 0:le.length)||0)>0&&t.jsx(hf,{ids:[...(I==null?void 0:I.books)||[],...(I==null?void 0:I.collections)||[]],workData:I??void 0,transport:i,onNavigate:o,renderLink:s,footer:l}),(I==null?void 0:I.related_works)&&I.related_works.length>0&&(()=>{const H=[],oe=I.related_works.filter(xe=>xe.relation==="part_of"),be=I.related_works.filter(xe=>xe.relation==="has_part"),ze=I.related_works.filter(xe=>xe.relation==="has_adaptation"),Le=I.related_works.filter(xe=>xe.relation==="text_carried_by"),_e=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),re=I.related_works.filter(xe=>!xe.relation||!_e.has(xe.relation));return oe.length>0&&H.push({label:p.section.belongsToWork,items:oe}),be.length>0&&H.push({label:p.section.containedWorks,items:be}),ze.length>0&&H.push({label:p.section.adaptations,items:ze}),Le.length>0&&H.push({label:p.section.derivativeWorks,items:Le}),re.length>0&&H.push({label:p.section.relatedWorks,items:re}),H.map(xe=>t.jsxs("div",{children:[t.jsxs(Wt,{children:[xe.label,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",xe.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:xe.items.map(R=>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(Ut,{id:R.id,label:m(R.title),onNavigate:o,renderLink:s})},R.id))})]},xe.label))})()]})};function jf({data:e}){const n=Ae(),{convert:i}=Ge(),{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 vf({sections:e,activeSection:n,onSelect:i}){const o=Ae();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>i(null),style:Ra(n===null),children:o.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>i(s.name),style:Ra(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 Ra(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 kf({id:e,label:n,onNavigate:i,renderLink:o}){const s=kt();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 wf(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 Ia({book:e,onNavigate:n,renderLink:i,showVolumes:o}){const s=Ae(),{convert:a}=Ge(),l=e.book_id||e.work_id,d=o&&e.volumes.length>0?wf(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(kf,{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 qo=({data:e,collectionId:n,transport:i,onNavigate:o,renderLink:s,className:a,style:l})=>{const d=Ae(),[c,p]=f.useState(null),[m,g]=f.useState(!1),[u,h]=f.useState(null),[x,j]=f.useState(null),[y,S]=f.useState(""),b=e||c;f.useEffect(()=>{if(e||!n||!(i!=null&&i.getCollectionCatalog))return;let _=!1;return g(!0),h(null),i.getCollectionCatalog(n).then(C=>{_||(C?p(C):h(d.catalog.notFound))}).catch(C=>{_||h(C instanceof Error?C.message:d.catalog.loadFailed)}).finally(()=>{_||g(!1)}),()=>{_=!0}},[e,n,i,d]);const k=(b==null?void 0:b.sections)&&b.sections.length>0,w=f.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const _=b.books.map(I=>I.volumes[0]).filter(I=>I!=null);return new Set(_).size<_.length},[b]),v=f.useMemo(()=>{if(!b)return[];let _=b.books;if(x&&(_=_.filter(C=>C.section===x)),y.trim()){const C=y.trim().toLowerCase();_=_.filter(I=>I.title.toLowerCase().includes(C)||I.sub_items&&I.sub_items.some(E=>E.toLowerCase().includes(C))||I.edition&&I.edition.toLowerCase().includes(C))}return _},[b,x,y]),$=f.useMemo(()=>{if(!w)return null;const _=[],C=new Map;for(const E of v){if(!E.volumes||E.volumes.length===0)continue;const T=E.volumes[0];C.has(T)||C.set(T,[]),C.get(T).push(E)}const I=[...C.keys()].sort((E,T)=>E-T);for(const E of I)_.push({volume:E,books:C.get(E)});return _},[v,w]);return m?t.jsx("div",{className:a,style:{...l,padding:"24px"},children:t.jsx("div",{style:{color:r("desc-fg"),fontSize:"13px"},children:d.catalog.loading})}):u?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:u}):b?t.jsxs("div",{className:a,style:l,children:[t.jsx(jf,{data:b}),k&&t.jsx(vf,{sections:b.sections,activeSection:x,onSelect:j}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:d.search.searchBookName,value:y,onChange:_=>S(_.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:[v.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:Bt(d.catalog.volume,{n:_.volume})}),_.books.map((I,E)=>t.jsx(Ia,{book:I,onNavigate:o,renderLink:s,showVolumes:I.volumes.length>1},`${_.volume}-${E}`))]},`${_.volume}-${C}`)):v.map((_,C)=>t.jsx(Ia,{book:_,onNavigate:o,renderLink:s,showVolumes:!0},C)),v.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},ri=e=>typeof e=="string"&&e?e:void 0;function Sf(e){if(!e||typeof e!="object")return e;const n=[],i=s=>{const a=ri(s);a&&!n.includes(a)&&n.push(a)};return i(e.work_id),Array.isArray(e.work_ids)&&e.work_ids.forEach(i),"work_id"in e||"work_ids"in e?{...e,work_ids:n,work_id:n[0]??null}:e}function _f(e){if(!e||typeof e!="object")return e??null;const n=e.meta,i={...e};return n&&typeof n=="object"&&(i.page_title===void 0&&ri(n.page_title)&&(i.page_title=ri(n.page_title)),i.source_url===void 0&&ri(n.source_url)&&(i.source_url=ri(n.source_url))),Array.isArray(e.sections)&&(i.sections=e.sections.map(Sf)),i}const Hr=e=>e?e.catch(()=>null):Promise.resolve(null);function Hc(e){const n=new Map;function i(o){var a;let s=n.get(o);return s||(s=Hr((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 Te.isSafeSegment(o)?i(o):Promise.resolve(null)},async getIndex(o,s){return!Te.isSafeSegment(o)||!Te.isSafeSegment(s)||!e.getTextIndex?null:Hr(e.getTextIndex(o,s))},async getChapter(o,s,a,l){if(!Te.isSafeSegment(o)||!Te.isSafeSegment(s)||!Te.isSafeSegment(a)||!e.getChapter)return null;const d=await Hr(e.getChapter(o,s,a,l));return d&&d.json?{...d,json:_f(d.json)}:d}}}const $n=()=>{const{t:e}=ae(),[n,i]=f.useState(1);return f.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)})},Dr=String.raw`https?:\/\/[^\s()()<>"]+`,$f=new RegExp(String.raw`\[([^\]\n]+)\]\((${Dr})\)`+String.raw`|(《[^》\n]+》)\s?[((](${Dr})[))]`+`|(${Dr})`,"g");function Cf(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function zf(e){const n=[];let i=0;for(const o of e.matchAll($f)){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:Cf(o[5]),url:o[5]}),i=s+o[0].length}return i<e.length&&n.push({text:e.slice(i)}),n}function Dc({text:e,convert:n,className:i="bim-rd-link"}){return t.jsx(t.Fragment,{children:zf(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(f.Fragment,{children:n(o.text)},s))})}const Uc="(min-width: 1100px)",Oi="(max-width: 719px)",so="(max-width: 859px)",Nf=`${Oi}, (pointer: coarse)`,Gt=r("reader-top"),Tf="48px",Vc=`
|
|
145
|
+
}`,Hc={color:"inherit",textDecoration:"none"},Zg=({snippet:e})=>{const{convert:n}=Ge();return t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.6},children:Ao(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(h.Fragment,{children:n(i.text)},o))})},Jg=({entry:e,selected:n,onClick:i,getConfig:o,query:s})=>{const a=Be(),{convert:l}=Ge(),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?`${Sn(e.juan_count)}${a.unit.juan}`:"",p=[...e.additional_titles||[],...e.attached_texts||[]],m=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,g=r("cover-accent"),u=kt();return t.jsxs("a",{href:u(e.id),onClick:f=>i(e,f),className:"bim-result-card",style:{...Hc,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, ${g} 50%, ${r("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${g} 14%, ${r("bg")}), color-mix(in srgb, ${g} 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, ${g} 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:g},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)})]}),m&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg")},children:[a.search.alias,":",l(typeof m=="string"?m:m.book_title||"")]}),e.descriptionSnippet&&t.jsx(Zg,{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(Yn,{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})]})]})]})},Ba=({entry:e,selected:n,onClick:i,getConfig:o,query:s,onRemove:a})=>{const l=Be(),{convert:d}=Ge(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(g=>{const u=typeof g=="string"?g:g==null?void 0:g.book_title;return u==null?void 0:u.toLowerCase().includes(s.toLowerCase())}):void 0,m=kt();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:m(e.id),onClick:g=>i(e,g),className:"bim-result-card",style:{...Hc,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(Yn,{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:[Sn(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:"×"})]})},Qg=({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 eh(e){var n,i,o;return!e.dynasty&&((n=e.dates)==null?void 0:n.birth)==null&&((i=e.dates)==null?void 0:i.death)==null&&(!e.alt_names||e.alt_names.length===0)&&!((o=e.description)!=null&&o.text)}function th({data:e}){var l,d;const{convert:n}=Ge(),{dynasty:i}=e,o=((l=e.dates)==null?void 0:l.birth)??void 0,s=((d=e.dates)==null?void 0:d.death)??void 0,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 nh({alt_names:e}){const{convert:n}=Ge(),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 ih({data:e}){const n=Be(),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 rh({works:e,transport:n,onNavigate:i,renderLink:o}){const s=Be(),{convert:a}=Ge(),l=kt(),[d,c]=h.useState(new Map);h.useEffect(()=>{if(!n)return;let u=!1;const f=e.map(j=>j.work_id);return(async()=>{const j=new Map;if(n.getEntriesByIds)try{const v=await n.getEntriesByIds(f);let w=!0;for(let k=0;k<f.length;k++){const _=v[k];_!=null&&_.title?j.set(f[k],_.title):_!=null&&_.primary_name?j.set(f[k],_.primary_name):w=!1}if(w)return j}catch{}const y=[...f],S=8,b=new Array(S).fill(0).map(async()=>{for(;y.length;){const v=y.shift();if(!v)break;if(!j.has(v))try{if(n.getEntry){const _=await n.getEntry(v);if(_!=null&&_.title){j.set(v,_.title);continue}}const w=await n.getItem(v),k=w&&(w.title||w.primary_name)||v;j.set(v,k)}catch{j.set(v,v)}}});return await Promise.all(b),j})().then(j=>{u||c(j)}),()=>{u=!0}},[e,n]);const p=new Map;for(const u of e){const f=u.role||"";p.has(f)||p.set(f,[]),p.get(f).push(u)}const m=["撰","編","注","輯","集","校","評","譯","述","作",""],g=[...p.keys()].sort((u,f)=>{const x=m.indexOf(u),j=m.indexOf(f);return x===-1&&j===-1?u.localeCompare(f):x===-1?1:j===-1?-1:x-j});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,")"]})]}),g.map(u=>{const f=p.get(u);return t.jsxs("div",{style:{marginBottom:"8px"},children:[u&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"2px"},children:[a(u)," ",t.jsxs("span",{style:{color:r("desc-fg")},children:["(",f.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:u?"16px":"0",listStyle:u?"disc":"none",fontSize:"14px",lineHeight:1.8},children:f.map((x,j)=>{const y=a(d.get(x.work_id)||x.work_id);return o?t.jsx("li",{children:o(x.work_id,y)},j):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})},j):t.jsx("li",{children:y},j)})})]},u)})]})}const Dc=({data:e,transport:n,onNavigate:i,renderLink:o,headerExtra:s,hideHeader:a})=>{var g;const l=Be(),{convert:d}=Ge();let c=!1;try{c=xe.extractStatus(e.id)==="draft"}catch{}const p=eh(e),m=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(th,{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}),m&&e.subtype!=="people"&&t.jsx("span",{children:m}),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(nh,{alt_names:e.alt_names}),t.jsx(ih,{data:e}),((g=e.description)==null?void 0:g.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(rh,{works:e.works,transport:n,onNavigate:i,renderLink:o})]})},oh=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function sh(e){const n=e.search(oh);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const Uc={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===ah(e))){const[a,l]=sh(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 ah(e){try{return decodeURI(e)}catch{return e}}const lh={...Uc,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},an=({text:e,plainStrong:n,style:i,className:o})=>{const{convert:s}=Ge(),a=n?lh:Uc;return t.jsx("div",{className:o,style:i,children:t.jsx(rm,{remarkPlugins:[om],components:a,children:s(e)})})};function Vc(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 ch={book:r("type-book"),work:r("type-work"),collection:r("type-collection"),entity:r("type-entity")};function dh({type:e}){const n=Be();return t.jsx("span",{style:Vc(ch[e]),children:n.indexType[e]})}function ph({isDraft:e}){const n=Be(),i=r(e?"status-draft":"status-official");return t.jsx("span",{style:Vc(i),children:e?n.status.draft:n.status.official})}function uh({id:e}){const n=Be(),[i,o]=h.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 Wt({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 Yt({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 Gc({authors:e,type:n,onNavigate:i,renderLink:o}){const{convert:s}=Ge();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(Ut,{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 Ut({id:e,label:n,onNavigate:i,renderLink:o}){const s=kt();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 mh({id:e,title:n,edition:i,type:o,isDraft:s,authors:a,volumeText:l,meta:d,headerExtra:c,onNavigate:p,renderLink:m}){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(dh,{type:o}),t.jsx(ph,{isDraft:s}),t.jsx(uh,{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(Gc,{authors:a,type:o,onNavigate:p,renderLink:m}),d]})]})}function Yc({items:e,label:n,showMeta:i,onNavigate:o,renderLink:s}){const a=Be(),{convert:l}=Ge();if(!e.length)return null;const[d,c]=h.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(Wt,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((p,m)=>{const g=d===m;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...g?{boxShadow:r("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(g?null:m),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:g?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(p.source)}),!g&&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:u=>u.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(Ut,{id:p.source_bid,label:a.action.view,onNavigate:o,renderLink:s})})]}),g&&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(Yt,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx(Yt,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx(Yt,{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)})]})]})]},m)})})]})}function gh({items:e,onNavigate:n,renderLink:i}){const o=Be();return t.jsx(Yc,{items:e,label:o.section.indexed,showMeta:!0,onNavigate:n,renderLink:i})}function Kc({items:e,onNavigate:n,renderLink:i}){const o=Be();return t.jsx(Yc,{items:e,label:o.section.emendated,onNavigate:n,renderLink:i})}function qc({label:e,items:n}){const{convert:i}=Ge();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(Wt,{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 hh({items:e}){const n=Be();return t.jsx(qc,{label:n.section.aliases,items:e})}function fh({items:e}){const n=Be();return t.jsx(qc,{label:n.section.attachedTexts,items:e})}function xh({items:e}){const n=Be(),{convert:i}=Ge();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Wt,{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 bh({items:e}){const n=Be(),{convert:i}=Ge();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Wt,{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.location||"")}),o.description&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),marginLeft:"8px"},children:i(o.description)})]},s))]})]}):null}function yh({items:e}){const n=Be(),{convert:i}=Ge();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Wt,{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 Oa({title:e,ids:n,transport:i,onNavigate:o,renderLink:s}){const{convert:a}=Ge(),[l,d]=h.useState([]);return h.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(m=>({id:p,title:m?m.title:void 0,edition:m?m.edition:void 0,type:m?m.type:void 0})).catch(()=>({id:p})))).then(p=>{c||d(p)}),()=>{c=!0}},[n,i]),n.length?t.jsxs(t.Fragment,{children:[t.jsxs(Wt,{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(Ut,{id:c.id,label:p,onNavigate:o,renderLink:s})},c.id)})})]}):null}function Yr({book:e,onNavigate:n,renderLink:i}){const o=Be(),{convert:s}=Ge(),[a,l]=h.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(Ut,{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(Ho,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:i})})]})}function jh({ids:e,workData:n,transport:i,onNavigate:o,renderLink:s,footer:a}){const l=Be(),{convert:d}=Ge(),[c,p]=h.useState([]);if(h.useEffect(()=>{if(!e.length){p([]);return}if(!i){p(e.map(j=>({id:j})));return}let x=!1;return Promise.all(e.map(j=>i.getItem(j).then(y=>({id:j,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:j})))).then(j=>{x||p(j)}),()=>{x=!0}},[e,i]),!e.length)return null;const m=c.length?c:e.map(x=>({id:x})),g=new Map(m.map(x=>[x.id,x])),u=n==null?void 0:n.version_graph,f=vh(e,u,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(Wt,{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 j=g.get(x);return j?t.jsx(Yr,{book:j,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(j=>{const y=g.get(j);return y?t.jsx(Yr,{book:y,onNavigate:o,renderLink:s},j):null})})]},x.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:m.map(x=>t.jsx(Yr,{book:x,onNavigate:o,renderLink:s},x.id))})]})}function vh(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]),m=v=>{if(p.has(v))return!0;const w=n.node_groups[v];return w!=null&&c.has(w)},g=[],u=new Map,f=[];for(const v of e)if(!((b=n.excluded_books)!=null&&b.includes(v)))if(m(v))g.push(v);else{const w=n.node_groups[v];w?(u.has(w)||u.set(w,[]),u.get(w).push(v)):f.push(v)}if(f.length+[...u.values()].reduce((v,w)=>v+w.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const j=new Map((n.groups??[]).map(v=>[v.id,v])),y=[...u.entries()].map(([v,w])=>{const k=j.get(v);return{id:v,label:(k==null?void 0:k.label)??v,description:k==null?void 0:k.description,ids:w}});return f.length>0&&y.push({id:"__other__",label:i,description:void 0,ids:f}),{useGrouping:!0,coreIds:g,groupedIds:y}}function kh({workData:e,onNavigate:n,renderLink:i}){var l,d,c,p;const o=Be(),{convert:s}=Ge(),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(Ut,{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:[Sn(e.juan_count.number),o.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(Gc,{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(an,{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(Yt,{label:o.label.parentWork,children:t.jsx(Ut,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:i})})})]})]})}function wh({items:e,onNavigate:n,renderLink:i}){const o=Be(),{convert:s}=Ge();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(Ut,{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:Pt(o.catalog.volume,{n:a.volume_index})})]},a.id))}):null}const Qo=({data:e,id:n,transport:i,onNavigate:o,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var F,R,G,Q,ie,de,q,ee;const p=Be(),{convert:m}=Ge(),[g,u]=h.useState(null),[f,x]=h.useState(!1),[j,y]=h.useState(null),[S,b]=h.useState(null),[v,w]=h.useState([]),k=e||g,_=xe.splitExtraTitles(k==null?void 0:k.additional_titles);if(h.useEffect(()=>{if(e||!n||!i)return;let U=!1;return x(!0),y(null),i.getItem(n).then(se=>{U||(se?u(se):y(p.misc.notFoundEntry))}).catch(se=>{U||y(se instanceof Error?se.message:p.misc.loadFailed)}).finally(()=>{U||x(!1)}),()=>{U=!0}},[e,n,i]),h.useEffect(()=>{if(!k||!i){b(null),w([]);return}let U=!1;const se=k.type==="book"||k.type==="collection"?k.work_id:void 0;if(se?i.getItem(se).then(pe=>{!U&&pe&&pe.type==="work"&&b(pe)}).catch(()=>{}):b(null),k.type==="book"){const pe=k;pe.contained_in&&pe.contained_in.length>0?Promise.all(pe.contained_in.map(_e=>{const Le=typeof _e=="string"?_e:_e.id,Ee=typeof _e=="string"?void 0:_e.volume_index;return i.getItem(Le).then(ue=>({id:Le,title:ue&&ue.title||Le,volume_index:Ee})).catch(()=>({id:Le,title:Le,volume_index:Ee}))})).then(_e=>{U||w(_e)}):w([])}else w([]);return()=>{U=!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((U,se)=>t.jsx("div",{style:{height:se===1?"32px":"16px",width:`${U}px`,background:r("widget-border"),borderRadius:"4px",opacity:.4}},se))})});if(j)return t.jsx("div",{className:d,style:{...c,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:j});if(!k)return null;if(k.type==="entity")return t.jsx("div",{className:d,style:c,children:t.jsx(Dc,{data:k,transport:i,onNavigate:o,renderLink:s,headerExtra:a})});const $=k.type==="book"?k:null,C=k.type==="collection"?k:null,L=k.type==="work"?k:null;let E=!1;try{E=xe.extractStatus(k.id)==="draft"}catch{}let T="";k.measure_info?T=m(k.measure_info):(F=k.juan_count)!=null&&F.number?T=Sn(k.juan_count.number)+p.unit.juan:(R=k.juan_count)!=null&&R.description&&(T=m(k.juan_count.description));const N=[],W=((G=k.publication_info)==null?void 0:G.year)??(k.type==="book"?lg(k):void 0);return W&&N.push(t.jsx(Yt,{label:p.label.year,children:W},"year")),(Q=k.current_location)!=null&&Q.name&&N.push(t.jsx(Yt,{label:p.label.currentLocation,children:m(k.current_location.name)},"loc")),(ie=k.page_count)!=null&&ie.description&&N.push(t.jsx(Yt,{label:p.label.pageCount,children:k.page_count.description},"page")),$!=null&&$.edition&&N.push(t.jsx(Yt,{label:p.label.edition,children:m($.edition)},"ver")),L!=null&&L.parent_work&&N.push(t.jsx(Yt,{label:p.label.parentWork,children:t.jsx(Ut,{id:L.parent_work.id,label:m(L.parent_work.title),onNavigate:o,renderLink:s})},"pw")),L!=null&&L.parent_works&&L.parent_works.length>0&&!L.parent_work&&N.push(t.jsx(Yt,{label:p.label.parentWork,children:L.parent_works.map((U,se)=>t.jsxs("span",{children:[se>0&&"、",t.jsx(Ut,{id:U,onNavigate:o,renderLink:s})]},U))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(mh,{id:k.id,title:m(k.title),edition:k.edition?m(k.edition):void 0,type:k.type,isDraft:E,authors:k.authors,volumeText:T,meta:N,headerExtra:a,onNavigate:o,renderLink:s}),((de=k.description)==null?void 0:de.text)&&t.jsx(an,{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((U,se)=>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:m(U.title)}),t.jsx(an,{text:U.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:r("fg")}})]},se))}),v.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Wt,{children:p.section.containedIn}),t.jsx(wh,{items:v,onNavigate:o,renderLink:s})]}),S&&t.jsxs(t.Fragment,{children:[t.jsx(Wt,{children:p.section.belongsToWork}),t.jsx(kh,{workData:S,onNavigate:o,renderLink:s})]}),k.additional_works&&k.additional_works.length>0&&t.jsx(xh,{items:k.additional_works}),_.aliases.length>0&&t.jsx(hh,{items:_.aliases}),_.attached.length>0&&t.jsx(fh,{items:_.attached}),k.indexed_by&&k.indexed_by.length>0&&t.jsx(gh,{items:k.indexed_by,onNavigate:o,renderLink:s}),k.emendated_by&&k.emendated_by.length>0&&t.jsx(Kc,{items:k.emendated_by,onNavigate:o,renderLink:s}),k.resources&&k.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Wt,{children:p.section.resources}),t.jsx(Ho,{items:k.resources,resourceGroups:k.resource_groups,groupByType:!0,onNavigate:o,renderLink:s})]}),($==null?void 0:$.location_history)&&$.location_history.length>0&&t.jsx(bh,{items:$.location_history}),(C==null?void 0:C.history)&&C.history.length>0&&t.jsx(yh,{items:C.history}),($==null?void 0:$.related_books)&&$.related_books.length>0&&t.jsx(Oa,{title:p.section.relatedVersions,ids:yc($),transport:i,onNavigate:o,renderLink:s}),(C==null?void 0:C.books)&&C.books.length>0&&t.jsx(Oa,{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(Wt,{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(U=>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(Ut,{id:U.id,label:m(U.title),onNavigate:o,renderLink:s})},U.id))})]}),(((q=L==null?void 0:L.books)==null?void 0:q.length)||0)+(((ee=L==null?void 0:L.collections)==null?void 0:ee.length)||0)>0&&t.jsx(jh,{ids:[...(L==null?void 0:L.books)||[],...(L==null?void 0:L.collections)||[]],workData:L??void 0,transport:i,onNavigate:o,renderLink:s,footer:l}),(L==null?void 0:L.related_works)&&L.related_works.length>0&&(()=>{const U=[],se=L.related_works.filter(be=>be.relation==="part_of"),pe=L.related_works.filter(be=>be.relation==="has_part"),_e=L.related_works.filter(be=>be.relation==="has_adaptation"),Le=L.related_works.filter(be=>be.relation==="text_carried_by"),Ee=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),ue=L.related_works.filter(be=>!be.relation||!Ee.has(be.relation));return se.length>0&&U.push({label:p.section.belongsToWork,items:se}),pe.length>0&&U.push({label:p.section.containedWorks,items:pe}),_e.length>0&&U.push({label:p.section.adaptations,items:_e}),Le.length>0&&U.push({label:p.section.derivativeWorks,items:Le}),ue.length>0&&U.push({label:p.section.relatedWorks,items:ue}),U.map(be=>t.jsxs("div",{children:[t.jsxs(Wt,{children:[be.label,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",be.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:be.items.map(A=>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(Ut,{id:A.id,label:m(A.title),onNavigate:o,renderLink:s})},A.id))})]},be.label))})()]})};function Sh({data:e}){const n=Be(),{convert:i}=Ge(),{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 $h({sections:e,activeSection:n,onSelect:i}){const o=Be();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>i(null),style:Wa(n===null),children:o.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>i(s.name),style:Wa(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 Wa(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 _h({id:e,label:n,onNavigate:i,renderLink:o}){const s=kt();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 Ch(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 Fa({book:e,onNavigate:n,renderLink:i,showVolumes:o}){const s=Be(),{convert:a}=Ge(),l=e.book_id||e.work_id,d=o&&e.volumes.length>0?Ch(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(_h,{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 es=({data:e,collectionId:n,transport:i,onNavigate:o,renderLink:s,className:a,style:l})=>{const d=Be(),[c,p]=h.useState(null),[m,g]=h.useState(!1),[u,f]=h.useState(null),[x,j]=h.useState(null),[y,S]=h.useState(""),b=e||c;h.useEffect(()=>{if(e||!n||!(i!=null&&i.getCollectionCatalog))return;let $=!1;return g(!0),f(null),i.getCollectionCatalog(n).then(C=>{$||(C?p(C):f(d.catalog.notFound))}).catch(C=>{$||f(C instanceof Error?C.message:d.catalog.loadFailed)}).finally(()=>{$||g(!1)}),()=>{$=!0}},[e,n,i,d]);const v=(b==null?void 0:b.sections)&&b.sections.length>0,w=h.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const $=b.books.map(L=>L.volumes[0]).filter(L=>L!=null);return new Set($).size<$.length},[b]),k=h.useMemo(()=>{if(!b)return[];let $=b.books;if(x&&($=$.filter(C=>C.section===x)),y.trim()){const C=y.trim().toLowerCase();$=$.filter(L=>L.title.toLowerCase().includes(C)||L.sub_items&&L.sub_items.some(E=>E.toLowerCase().includes(C))||L.edition&&L.edition.toLowerCase().includes(C))}return $},[b,x,y]),_=h.useMemo(()=>{if(!w)return null;const $=[],C=new Map;for(const E of k){if(!E.volumes||E.volumes.length===0)continue;const T=E.volumes[0];C.has(T)||C.set(T,[]),C.get(T).push(E)}const L=[...C.keys()].sort((E,T)=>E-T);for(const E of L)$.push({volume:E,books:C.get(E)});return $},[k,w]);return m?t.jsx("div",{className:a,style:{...l,padding:"24px"},children:t.jsx("div",{style:{color:r("desc-fg"),fontSize:"13px"},children:d.catalog.loading})}):u?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:u}):b?t.jsxs("div",{className:a,style:l,children:[t.jsx(Sh,{data:b}),v&&t.jsx($h,{sections:b.sections,activeSection:x,onSelect:j}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:d.search.searchBookName,value:y,onChange:$=>S($.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:Pt(d.catalog.volume,{n:$.volume})}),$.books.map((L,E)=>t.jsx(Fa,{book:L,onNavigate:o,renderLink:s,showVolumes:L.volumes.length>1},`${$.volume}-${E}`))]},`${$.volume}-${C}`)):k.map(($,C)=>t.jsx(Fa,{book:$,onNavigate:o,renderLink:s,showVolumes:!0},C)),k.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},ai=e=>typeof e=="string"&&e?e:void 0;function zh(e){if(!e||typeof e!="object")return e;const n=[],i=s=>{const a=ai(s);a&&!n.includes(a)&&n.push(a)};return i(e.work_id),Array.isArray(e.work_ids)&&e.work_ids.forEach(i),"work_id"in e||"work_ids"in e?{...e,work_ids:n,work_id:n[0]??null}:e}function Nh(e){if(!e||typeof e!="object")return e??null;const n=e.meta,i={...e};return n&&typeof n=="object"&&(i.page_title===void 0&&ai(n.page_title)&&(i.page_title=ai(n.page_title)),i.source_url===void 0&&ai(n.source_url)&&(i.source_url=ai(n.source_url))),Array.isArray(e.sections)&&(i.sections=e.sections.map(zh)),i}const Kr=e=>e?e.catch(()=>null):Promise.resolve(null);function Xc(e){const n=new Map;function i(o){var a;let s=n.get(o);return s||(s=Kr((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 xe.isSafeSegment(o)?i(o):Promise.resolve(null)},async getIndex(o,s){return!xe.isSafeSegment(o)||!xe.isSafeSegment(s)||!e.getTextIndex?null:Kr(e.getTextIndex(o,s))},async getChapter(o,s,a,l){if(!xe.isSafeSegment(o)||!xe.isSafeSegment(s)||!xe.isSafeSegment(a)||!e.getChapter)return null;const d=await Kr(e.getChapter(o,s,a,l));return d&&d.json?{...d,json:Nh(d.json)}:d}}}const _n=()=>{const{t:e}=oe(),[n,i]=h.useState(1);return h.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)})},qr=String.raw`https?:\/\/[^\s()()<>"]+`,Th=new RegExp(String.raw`\[([^\]\n]+)\]\((${qr})\)`+String.raw`|(《[^》\n]+》)\s?[((](${qr})[))]`+`|(${qr})`,"g");function Rh(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function Eh(e){const n=[];let i=0;for(const o of e.matchAll(Th)){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:Rh(o[5]),url:o[5]}),i=s+o[0].length}return i<e.length&&n.push({text:e.slice(i)}),n}function Zc({text:e,convert:n,className:i="bim-rd-link"}){return t.jsx(t.Fragment,{children:Eh(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(h.Fragment,{children:n(o.text)},s))})}const Jc="(min-width: 1100px)",Fi="(max-width: 719px)",uo="(max-width: 859px)",Ih=`${Fi}, (pointer: coarse)`,Gt=r("reader-top"),Lh="48px",Qc=`
|
|
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: ${Lh};
|
|
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")});
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
.bim-rd-mnav span { margin-right: 6px; font-variant-numeric: tabular-nums; }
|
|
175
175
|
.bim-rd-mnav button { min-width: 36px; height: 36px; border: 0; border-radius: 999px; background: transparent; color: ${r("accent")}; font-size: 20px; line-height: 1; cursor: pointer; }
|
|
176
176
|
.bim-rd-mnav button:hover { background: ${r("row-hover-bg")}; }
|
|
177
|
-
@media ${
|
|
177
|
+
@media ${uo} { .bim-rd-mnav { bottom: calc(68px + env(safe-area-inset-bottom, 0px)); } }
|
|
178
178
|
|
|
179
179
|
/* 跳到正文:平时按标准 visually-hidden 收成 1px 并裁掉(任何宽度都不外露),
|
|
180
180
|
获得焦点时才还原成左上角的按钮 */
|
|
@@ -471,7 +471,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
471
471
|
.bim-rd-sheet-head .bim-rd-t { margin-left: auto; min-width: 44px; min-height: 44px; justify-content: center; letter-spacing: 0; }
|
|
472
472
|
.bim-rd-sheet-img { display: flex; flex-direction: column; gap: 8px; min-height: 40vh; }
|
|
473
473
|
.bim-rd-sheet-img .bim-rd-img-fig img { max-height: 60vh; }
|
|
474
|
-
@media ${
|
|
474
|
+
@media ${uo} {
|
|
475
475
|
.bim-rd[data-bb] .bim-rd-text { padding-bottom: calc(56px + 64px + env(safe-area-inset-bottom, 0px)); }
|
|
476
476
|
/* 底栏上已有的,工具条上不再重复(目录、字号) */
|
|
477
477
|
.bim-rd[data-bb] .bim-rd-bb-dup { display: none !important; }
|
|
@@ -516,7 +516,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
516
516
|
|
|
517
517
|
/* ── 点击区 ≥44×44(INT Q4):伪元素向外扩,按钮外观与排布不变;
|
|
518
518
|
A− A+ 挨着,两边各扩约 10px 会叠在一起,所以二者之间多留 12px ── */
|
|
519
|
-
@media ${
|
|
519
|
+
@media ${Ih} {
|
|
520
520
|
.bim-rd-tools .bim-rd-t, .bim-rd-toc-head .bim-rd-t { position: relative; }
|
|
521
521
|
.bim-rd-tools .bim-rd-t::after, .bim-rd-toc-head .bim-rd-t::after {
|
|
522
522
|
content: ""; position: absolute; left: 50%; top: 50%;
|
|
@@ -529,7 +529,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
529
529
|
}
|
|
530
530
|
|
|
531
531
|
/* ── 中屏以下:目录改抽屉 ── */
|
|
532
|
-
@media not all and ${
|
|
532
|
+
@media not all and ${Jc} {
|
|
533
533
|
.bim-rd-toc {
|
|
534
534
|
position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; height: auto;
|
|
535
535
|
width: min(86vw, 320px);
|
|
@@ -543,7 +543,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
543
543
|
}
|
|
544
544
|
|
|
545
545
|
/* ── 窄屏:书影收起,只留正文 ── */
|
|
546
|
-
@media ${
|
|
546
|
+
@media ${Fi} {
|
|
547
547
|
.bim-rd-bar { padding: 0 12px; gap: 10px; }
|
|
548
548
|
.bim-rd-ttl span, .bim-rd-hide-narrow { display: none !important; }
|
|
549
549
|
/* 工具条放不下时(版本、自然段、标出作品链接都在)在条内左右滑,不撑宽页面 */
|
|
@@ -739,7 +739,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
739
739
|
}
|
|
740
740
|
|
|
741
741
|
/* ── 手机:正文两侧不留白(放在对读、界栏规则之后才压得过它们) ── */
|
|
742
|
-
@media ${
|
|
742
|
+
@media ${Fi} {
|
|
743
743
|
.bim-rd-text, .bim-rd[data-warp="true"] .bim-rd-text { padding-left: 0; padding-right: 0; }
|
|
744
744
|
.bim-rd-col, :root[data-layout="boxed"] .bim-rd-col { padding-left: 14px; padding-right: 14px; }
|
|
745
745
|
:root[data-layout="boxed"] .bim-rd-col { border-left: 0; border-right: 0; }
|
|
@@ -750,17 +750,17 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
750
750
|
.guji-page-indicator { opacity: 0.55; transition: opacity 0.15s; outline: none; }
|
|
751
751
|
.guji-page-indicator:hover, .guji-page-indicator:focus-visible { opacity: 1; }
|
|
752
752
|
.guji-page-indicator:focus-visible { outline: 2px solid ${r("accent")}; outline-offset: 1px; border-radius: 3px; }
|
|
753
|
-
@media ${
|
|
754
|
-
`;function Xo(e,n){var i;return n?e.key===n?!0:!!((i=e.children)!=null&&i.some(o=>Xo(o,n))):!1}const La=()=>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 Ef({item:e,activeKey:n,onSelect:i,tabKey:o}){const{t:s}=ae(),a=Xo(e,n),[l,d]=f.useState(a||!!e.defaultExpanded);return f.useEffect(()=>{a&&d(!0)},[a]),f.useEffect(()=>{e.defaultExpanded&&d(!0)},[e.defaultExpanded]),e.selectable?t.jsxs("li",{children:[t.jsxs("div",{className:"bim-rd-ti-row",children:[t.jsx("button",{type:"button",className:"bim-rd-ti-tw","aria-expanded":l,"aria-label":s(l?"reader.tocCollapse":"reader.tocExpand"),tabIndex:-1,onClick:()=>d(c=>!c),children:t.jsx(La,{})}),t.jsxs("button",{type:"button",className:`bim-rd-ti${e.inChapter?"":" bim-rd-ti-group"}`,"aria-current":e.key===n?"true":void 0,disabled:e.disabled,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>{d(!0),i(e.key)},onKeyDown:c=>{c.key==="ArrowRight"&&!l?(c.preventDefault(),d(!0)):c.key==="ArrowLeft"&&l&&(c.preventDefault(),d(!1))},children:[t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]})]}),l&&t.jsx(ao,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]}):t.jsxs("li",{children:[t.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":l,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>d(c=>!c),children:[t.jsx(La,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),l&&t.jsx(ao,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]})}function ao({items:e,activeKey:n,onSelect:i,tabKey:o}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(Ef,{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 Aa(e,n){var i;for(const o of e)if(o.key===n||Xo(o,n))return o.key;return((i=e[0])==null?void 0:i.key)??null}function Gc({items:e,activeKey:n,onSelect:i,label:o}){const{t:s}=ae(),a=o??s("reader.toc"),l=f.useRef(null),[d,c]=f.useState(null);f.useEffect(()=>{c(null)},[n]);const p=f.useMemo(()=>d||(n??Aa(e,n)),[d,n,e]);f.useEffect(()=>{const g=l.current;if(!g)return;const u=Array.from(g.querySelectorAll("[data-rd-toc-key]"));if(u.length===0)return;const h=u.find(x=>x.dataset.rdTocKey===p)??u.find(x=>x.dataset.rdTocKey===Aa(e,n))??u.find(x=>!x.disabled)??u[0];for(const x of u)x.tabIndex=x===h?0:-1}),f.useEffect(()=>{const g=l.current,u=g==null?void 0:g.closest(".bim-rd-toc");if(!g||!u||!n)return;const h=Array.from(g.querySelectorAll("[data-rd-toc-key]")).find(j=>j.dataset.rdTocKey===n);if(!h)return;const x=h.getBoundingClientRect().top-u.getBoundingClientRect().top+u.scrollTop;(x<u.scrollTop+80||x>u.scrollTop+u.clientHeight-40)&&(u.scrollTop=Math.max(0,x-u.clientHeight/3))},[n]);const m=f.useCallback(g=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(g.key))return;const h=l.current;if(!h)return;const x=Array.from(h.querySelectorAll("[data-rd-toc-key]")).filter(b=>!b.disabled),j=x.indexOf(document.activeElement);let y=j;if(g.key==="ArrowDown"?y=Math.min(x.length-1,j+1):g.key==="ArrowUp"?y=Math.max(0,j-1):g.key==="Home"?y=0:g.key==="End"&&(y=x.length-1),y<0||y===j)return;g.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:m,children:t.jsx(ao,{items:e,activeKey:n,onSelect:i,tabKey:p})})}function Ma({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 Rf(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 h of n)[h.x,h.y,h.w,h.h].every(Number.isFinite)&&(s=Math.min(s,h.x),a=Math.min(a,h.y),l=Math.max(l,h.x+h.w),d=Math.max(d,h.y+h.h));if(!(l>s)||!(d>a))return null;const c=Math.min(i,o)*.03,p=Math.min(i,Math.max(0,s-c)),m=Math.min(o,Math.max(0,a-c)),g=Math.min(i,Math.max(0,l+c))-p,u=Math.min(o,Math.max(0,d+c))-m;return!(g>0)||!(u>0)||g>=i*.98&&u>=o*.98?null:{x:p,y:m,w:g,h:u}}function lo({pages:e,loading:n,page:i,onPageChange:o,renderOverlay:s,preserveMargins:a=!0}){const{t:l}=ae(),[d,c]=f.useState(0),p=i??d,m=j=>{o?o(j):c(j)};if(f.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 g=Math.max(0,Math.min(e.length-1,p)),u=e[g],h=u.label??`${g+1}`,x=!a&&!s?Rf(u):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:u.url,alt:u.alt??l("reader.imageAlt",{label:h}),decoding:"async",style:{position:"absolute",maxWidth:"none",maxHeight:"none",width:`${u.width/x.w*100}%`,left:`${-x.x/x.w*100}%`,top:`${-x.y/x.h*100}%`}}),t.jsx(Ma,{page:u,crop:x})]}):t.jsxs("figure",{className:"bim-rd-img-fig",children:[t.jsx("img",{src:u.url,alt:u.alt??l("reader.imageAlt",{label:h}),width:u.width,height:u.height,loading:"lazy",decoding:"async"}),t.jsx(Ma,{page:u}),s==null?void 0:s(u,g)]})}),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:g===0,onClick:()=>m(g-1),children:"‹"}),t.jsx("span",{"aria-live":"polite",children:u.label??`${g+1} / ${e.length}`}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.nextImage"),disabled:g===e.length-1,onClick:()=>m(g+1),children:"›"})]})]})}function If(e){return e==="lite"||e==="full"}const pi=[.1,.9],Yc=[{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 Lf(e){var n;return((n=Yc.find(i=>i.key===e))==null?void 0:n.stack)??null}const Zo={fontSize:null,readingMode:"line",properNameMode:null,writingMode:"horizontal",workLinks:!0,fontFamily:"song",pageBreaks:!1,pageIndicatorY:.33,bookTitleStyle:"bracket",showWorks:!0,quoteStyle:"original",scriptMode:null,preserveMargins:!0},en=[15,16,17,18,20,22,24],co=18,Kc="bim-reader-prefs",qc=2,Af="bim-reading-mode";function Mf(){const e={...Zo};try{const n=localStorage.getItem(Kc),i=n?JSON.parse(n):{};typeof i.fontSize=="number"&&en.includes(i.fontSize)&&(e.fontSize=i.fontSize),(i.readingMode??localStorage.getItem(Af))==="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);const s=i.v===qc;s&&typeof i.pageBreaks=="boolean"&&(e.pageBreaks=i.pageBreaks),typeof i.pageIndicatorY=="number"&&Number.isFinite(i.pageIndicatorY)&&i.pageIndicatorY>=pi[0]&&i.pageIndicatorY<=pi[1]&&(e.pageIndicatorY=i.pageIndicatorY),s&&(i.bookTitleStyle==="wavy"||i.bookTitleStyle==="bracket")&&(e.bookTitleStyle=i.bookTitleStyle),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 Pf(e){try{localStorage.setItem(Kc,JSON.stringify({...e,v:qc}))}catch{}}function Ii(e,n){const i=e??co,o=en;let s=o.indexOf(i);return s<0&&(s=o.indexOf(co)),o[Math.max(0,Math.min(o.length-1,s+n))]}function Xc(){const[e,n]=f.useState(Zo);f.useEffect(()=>{n(Mf())},[]);const i=f.useCallback(o=>{n(s=>{const a={...s,...o};return Pf(a),a})},[]);return[e,i]}function po(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 Zc(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 Jc(e){const n=[],i=o=>{for(const s of o){if(s.inChapter)continue;const a=!!s.children&&s.children.length>0;(!a||s.selectable)&&n.push(s),a&&i(s.children)}};return i(e),n}const Pa=()=>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"})}),Bf=()=>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"})}),Of=()=>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"})}),Ba=()=>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"})]}),Oa=()=>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 Wa(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 Fa(e,n){const[i,o]=f.useState(n);return f.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 Wf({prefs:e,onPrefsChange:n,origAvailable:i}){const o=f.useContext(qt),{t:s}=ae();if(!o)return null;const a=o.locale==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a,d=[{key:"orig",short:s("reader.scriptOrigShort"),title:s(i?"reader.scriptOrig":"reader.scriptOrigUnavailable"),disabled:!i},{key:"hant",short:s("common.localeShortHant"),title:s("reader.scriptHant")},{key:"hans",short:s("common.localeShortHans"),title:s("reader.scriptHans")}];return t.jsx("span",{className:"bim-rd-script-sw",role:"group","aria-label":s("reader.scriptQuick"),children:d.map((c,p)=>t.jsxs(f.Fragment,{children:[p>0&&t.jsx("span",{className:"bim-rd-off","aria-hidden":"true",children:"|"}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":l===c.key,title:c.title,"aria-label":c.title,disabled:c.disabled,onClick:()=>{c.disabled||(n({scriptMode:c.key}),c.key==="hant"?o.setLocale("zh-Hant"):c.key==="hans"&&o.setLocale("zh-Hans"))},children:c.short})]},c.key))})}function Wi({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,disabled:a.disabled,onClick:()=>{a.disabled||o(a.key)},children:a.label},a.key))})]})}function Ff({prefs:e,onPrefsChange:n,origAvailable:i}){const o=f.useContext(qt),{t:s}=ae(),a=(o==null?void 0:o.locale)==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a;return t.jsx(Wi,{label:s("reader.script"),value:l,options:[{key:"orig",label:s("reader.scriptOrig"),title:i?void 0:s("reader.scriptOrigUnavailable"),disabled:!i},{key:"hant",label:s("reader.scriptHant")},{key:"hans",label:s("reader.scriptHans")}],onPick:d=>{n({scriptMode:d}),d==="hant"?o==null||o.setLocale("zh-Hant"):d==="hans"&&(o==null||o.setLocale("zh-Hans"))}})}function Hf(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 Df(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 Qc({title:e,subtitle:n,toc:i,activeKey:o,tocActiveKey:s,onSelect:a,tocHeader:l,tocCaption:d,images:c,imagesLoading:p,renderImageOverlay:m,imagePanel:g="auto",prefs:u,onPrefsChange:h,paragraphToggle:x,properNameToggle:j=!0,allowVertical:y,origScriptAvailable:S=!0,byline:b,current:k,workLinkToggle:w,rail:v,onReportError:$,revisedAt:_,backHref:C,backLabel:I,bottomBar:E=!0,pager:T=!0,contentLoading:N=!1,pagerUnit:P,versions:W,currentVersionKey:L,onVersionChange:K,versionSource:Q=!0,keepChapterOnVersionChange:Z=!1,customImagePanel:ue,toolbarExtra:J,settingsAnnotate:le,settingsLayout:H,settingsExtra:oe,settingsExtraTitle:be,isWarpMode:ze,showPreserveMargins:Le=!0,children:_e,className:re,style:xe}){const{t:R,convert:se}=ae(),de=I??R("reader.back"),O=se(P??R("reader.unitJuan")),ee=f.useId().replace(/:/g,""),ke=`bim-rd-toc-${ee}`,ve=`bim-rd-text-${ee}`,Ve=f.useRef(null),F=f.useRef(null),fe=f.useRef(null),te=f.useRef(null),U=Fa(Uc,!0),pe=Fa(so,!1),Me=E&&pe,[Ke,nt]=f.useState(null),[it,at]=f.useState(!1),lt=f.useRef(null),rt=`bim-rd-set-${ee}`,Pe=f.useRef(null),z=f.useRef(null),ne=(B,ge)=>{z.current=ge,nt(Be=>Be===B?null:B)},q=f.useCallback(()=>{var B;nt(null),(B=z.current)==null||B.focus()},[]);f.useEffect(()=>{Me||nt(null)},[Me]),f.useEffect(()=>{var B,ge;Ke&&((ge=(B=Pe.current)==null?void 0:B.querySelector("button:not([disabled])"))==null||ge.focus())},[Ke]);const[he,Ie]=f.useState("auto"),M=he==="auto"?U:he==="open",me=!U,G=!!ue||!!c&&c.length>0,[Se,ye]=f.useState(g);f.useEffect(()=>{ye(g)},[g]);const Ee=Se==="auto"?G||!!p:Se==="open",Xe=f.useCallback(B=>{var ge;Ie("auto"),B&&((ge=te.current)==null||ge.focus())},[]),Fe=()=>Ie(M?"closed":"open");f.useEffect(()=>{if(!me||he!=="open")return;const B=fe.current,ge=B==null?void 0:B.querySelector('input, [data-rd-toc-key][tabindex="0"]');ge==null||ge.focus()},[me,he]);const Qe=f.useCallback(B=>{a(B),me&&Xe(!1);const ge=F.current,Be=Ve.current;if(ge&&Be&&typeof window<"u"){const Ye=ge.getBoundingClientRect().top-Be.getBoundingClientRect().bottom;Ye<0&&window.scrollBy({top:Ye})}},[a,me,Xe]),ut=f.useMemo(()=>Jc(i),[i]),[X,$e]=f.useState(null),je=Zc(W,L!==void 0?L:X),De=(je==null?void 0:je.key)??null,ce=f.useMemo(()=>ut.map(B=>B.key).join(`
|
|
755
|
-
`),[ut]),He=f.useRef(null),ft=B=>{B!==De&&(Z||(He.current={key:B,sig:ce,done:!1}),L===void 0&&$e(B),K==null||K(B))};f.useEffect(()=>{const B=He.current;if(!B||B.key!==De)return;const ge=ut.find(Ye=>!Ye.disabled);if(!ge)return;const Be=ce!==B.sig;!Be&&B.done||(Be?He.current=null:B.done=!0,ge.key!==o&&Qe(ge.key))},[De,ce,ut,o,Qe]);const gt=ut.find(B=>B.key===o),yt=()=>{var B;$==null||$({chapterKey:o,chapterLabel:typeof(gt==null?void 0:gt.label)=="string"?gt.label:void 0,anchor:Hf(F.current,((B=Ve.current)==null?void 0:B.getBoundingClientRect().bottom)??0),selectedText:Df(F.current)})},qe=ut.findIndex(B=>B.key===o),V=qe>0?ut.slice(0,qe).reverse().find(B=>!B.disabled):void 0,D=qe>=0?ut.slice(qe+1).find(B=>!B.disabled):void 0,Y=u.fontSize??co,we=Lf(u.fontFamily),Ce={...xe,...u.fontSize?{"--bimrd-fs":`${u.fontSize}px`}:null,...we?{"--bimrd-ff":we}:null},Ne={song:R("reader.fontSong"),kai:R("reader.fontKai"),system:R("reader.fontSystem")},et=j||!!le,Je=t.jsxs("div",{className:"bim-rd-sp",children:[t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${rt}-g1`,children:[t.jsx("h3",{id:`${rt}-g1`,className:"bim-rd-sp-h",children:R("reader.groupText")}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:R("reader.font")}),t.jsx("select",{className:"bim-rd-sp-sel","aria-label":R("reader.font"),value:u.fontFamily,onChange:B=>h({fontFamily:B.target.value}),children:Yc.map(B=>t.jsx("option",{value:B.key,children:Ne[B.key]},B.key))})]}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:R("reader.fontSize")}),t.jsxs("span",{className:"bim-rd-sp-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":R("reader.fontSmaller"),disabled:Y<=en[0],onClick:()=>h({fontSize:Ii(u.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[Y,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":R("reader.fontLarger"),disabled:Y>=en[en.length-1],onClick:()=>h({fontSize:Ii(u.fontSize,1)}),children:"A+"})]})]}),t.jsx(Ff,{prefs:u,onPrefsChange:h,origAvailable:S}),t.jsx(Wi,{label:R("reader.quoteStyle"),value:u.quoteStyle,options:[{key:"modern",label:R("reader.quoteModern")},{key:"classic",label:R("reader.quoteClassic")},{key:"original",label:R("reader.quoteOriginal")}],onPick:B=>h({quoteStyle:B})})]}),et&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${rt}-g2`,children:[t.jsx("h3",{id:`${rt}-g2`,className:"bim-rd-sp-h",children:R("reader.groupMark")}),j&&t.jsxs(t.Fragment,{children:[t.jsx(Wi,{label:R("reader.properName"),value:u.properNameMode,title:R("reader.properNameTitle"),options:[{key:"off",label:R("reader.properNameOff")},{key:"lite",label:R("reader.properNameLite"),title:R("reader.properNameLiteTitle")},{key:"full",label:R("reader.properNameFull")}],onPick:B=>h({properNameMode:B})}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.showWorks,onChange:B=>h({showWorks:B.target.checked})}),t.jsx("span",{children:R("reader.showWorks")})]}),t.jsx(Wi,{label:R("reader.bookTitleStyle"),value:u.bookTitleStyle,options:[{key:"wavy",label:R("reader.bookTitleWavy")},{key:"bracket",label:R("reader.bookTitleBracket")}],onPick:B=>h({bookTitleStyle:B})})]}),le]}),t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${rt}-g3`,children:[t.jsx("h3",{id:`${rt}-g3`,className:"bim-rd-sp-h",children:R("reader.groupLayout")}),x&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.readingMode==="paragraph",title:R("reader.paragraphTitle"),onClick:()=>h({readingMode:u.readingMode==="paragraph"?"line":"paragraph"}),children:R("reader.paragraph")}),w&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.workLinks,onChange:B=>h({workLinks:B.target.checked})}),t.jsx("span",{children:R("reader.workLinks")})]}),y&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.writingMode==="vertical",onClick:()=>h({writingMode:u.writingMode==="vertical"?"horizontal":"vertical"}),children:R("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:B=>h({pageBreaks:B.target.checked})}),t.jsx("span",{children:R("reader.pageBreaks")})]}),Le&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.preserveMargins,onChange:B=>h({preserveMargins:B.target.checked})}),t.jsx("span",{children:R("reader.preserveMargins")})]}),H]}),oe&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${rt}-g4`,children:[t.jsx("h3",{id:`${rt}-g4`,className:"bim-rd-sp-h",children:be??R("reader.groupMore")}),oe]})]}),Ue=f.useRef(null);return f.useEffect(()=>{const B=Ue.current;if(!B||!Ee)return;let ge=0,Be=-1;const Ye=()=>{ge=0;const ct=parseFloat(getComputedStyle(B).top);if(!Number.isFinite(ct))return;const jt=Math.max(0,Math.round(B.getBoundingClientRect().top-ct));jt!==Be&&(Be=jt,B.style.setProperty("--bimrd-img-lead",`${jt}px`))},Oe=()=>{ge||(ge=requestAnimationFrame(Ye))};Oe(),window.addEventListener("scroll",Oe,{passive:!0}),window.addEventListener("resize",Oe);const Ze=typeof ResizeObserver<"u"?new ResizeObserver(Oe):null;return Ze==null||Ze.observe(document.body),()=>{window.removeEventListener("scroll",Oe),window.removeEventListener("resize",Oe),Ze==null||Ze.disconnect(),ge&&cancelAnimationFrame(ge),B.style.removeProperty("--bimrd-img-lead")}},[Ee]),t.jsxs("div",{className:["bim-rd",u.writingMode==="vertical"&&y?"bim-rd-vertical":"",re].filter(Boolean).join(" "),"data-toc":he,"data-img":Ee?"open":"closed","data-bb":Me?"":void 0,"data-set":!Me&&it?"open":void 0,"data-warp":ze?"true":void 0,style:Ce,children:[t.jsx("style",{children:Vc}),t.jsx("a",{className:"bim-rd-skip",href:`#${ve}`,onClick:B=>{var ge,Be,Ye;B.preventDefault(),(ge=F.current)==null||ge.focus(),(Ye=(Be=F.current)==null?void 0:Be.scrollIntoView)==null||Ye.call(Be,{block:"start"})},children:R("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:Ve,children:[C&&t.jsxs("a",{className:"bim-rd-back",href:C,"aria-label":R("reader.backAria",{label:de}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:de})]}),(e||n||b||k)&&t.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[e&&t.jsx("b",{children:e}),b&&t.jsx("span",{className:"bim-rd-by",children:b}),k&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-rd-cur",children:k})]}),n&&t.jsx("span",{className:"bim-rd-ttl-src",children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":R("reader.settings"),children:[W&&W.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:je?se(po(je)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:R("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:R("reader.versionShort")}),t.jsx("select",{"aria-label":R("reader.version"),value:De??"",onChange:B=>ft(B.target.value),children:W.map(B=>t.jsx("option",{value:B.key,children:se(po(B))},B.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),T&&(V||D)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":R("reader.pagerGroup",{unit:O}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":R("reader.prevUnit",{unit:O}),title:V?typeof V.label=="string"&&V.label?R("reader.prevUnitTitle",{unit:O,label:V.label}):R("reader.prevUnit",{unit:O}):R("reader.firstUnit",{unit:O}),disabled:!V,onClick:()=>V&&Qe(V.key),children:t.jsx(Bf,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":R("reader.nextUnit",{unit:O}),title:D?typeof D.label=="string"&&D.label?R("reader.nextUnitTitle",{unit:O,label:D.label}):R("reader.nextUnit",{unit:O}):R("reader.lastUnit",{unit:O}),disabled:!D,onClick:()=>D&&Qe(D.key),children:t.jsx(Of,{})})]}),T&&(V||D)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:te,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":M,"aria-controls":ke,onClick:Fe,children:[t.jsx(Pa,{}),t.jsx("span",{className:"bim-rd-tlabel",children:R("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":Ee,onClick:()=>ye(Ee?"closed":"open"),children:[t.jsx(Oa,{}),R("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(Wf,{prefs:u,onPrefsChange:h,origAvailable:S}),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":R("reader.fontSmaller"),disabled:Y<=en[0],onClick:()=>h({fontSize:Ii(u.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":R("reader.fontLarger"),disabled:Y>=en[en.length-1],onClick:()=>h({fontSize:Ii(u.fontSize,1)}),children:"A+"}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsxs("button",{ref:lt,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":it,"aria-controls":rt,onClick:()=>at(B=>!B),children:[t.jsx(Ba,{}),t.jsx("span",{className:"bim-rd-tlabel",children:R("reader.settings")})]}),J]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:ke,ref:fe,role:me&&M?"dialog":void 0,"aria-modal":me&&M?!0:void 0,"aria-label":me&&M?R("reader.toc"):void 0,onKeyDown:B=>{if(!(!me||!M)){if(B.key==="Escape"){B.stopPropagation(),Xe(!0);return}B.key==="Tab"&&Wa(B,fe.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:d??R("reader.toc")}),me&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":R("reader.closeToc"),onClick:()=>Xe(!0),children:"✕"})]}),l]}),t.jsx(Gc,{items:i,activeKey:s!==void 0?s:o,onSelect:Qe})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>Xe(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":R("reader.images"),ref:Ue,children:Ee&&(ue||t.jsx(lo,{pages:c??null,loading:p,renderOverlay:m,preserveMargins:u.preserveMargins}))}),!Me&&it&&t.jsxs("aside",{className:"bim-rd-set",id:rt,"aria-label":R("reader.settings"),onKeyDown:B=>{var ge;B.key==="Escape"&&(B.stopPropagation(),at(!1),(ge=lt.current)==null||ge.focus())},children:[t.jsxs("div",{className:"bim-rd-sp-top",children:[t.jsx("span",{children:R("reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":R("reader.closeSettings"),onClick:()=>{var B;at(!1),(B=lt.current)==null||B.focus()},children:"✕"})]}),Je]}),t.jsxs("div",{className:"bim-rd-text",id:ve,ref:F,tabIndex:-1,"data-rail":(v||$)&&!ze?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[_e,Q&&je&&(je.sourceName||je.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":je.key,children:[je.sourceName&&t.jsxs(t.Fragment,{children:[R("reader.sourceLabel")," ",je.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:je.sourceUrl,target:"_blank",rel:"noreferrer",children:se(je.sourceName)}):se(je.sourceName)]}),je.sourceName&&je.license&&t.jsx("span",{className:"bim-rd-dot"}),je.license&&t.jsx(t.Fragment,{children:R("reader.licenseOf",{license:je.license})})]}),_&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:R("reader.revisedAt",{date:_})}),$&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:B=>B.preventDefault(),onClick:yt,children:R("reader.reportError")})}),T&&!N&&(V||D)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":R("reader.pagerNav"),children:[V?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>Qe(V.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),R("reader.prevUnit",{unit:O})]}),t.jsx("span",{className:"bim-rd-pglabel",children:V.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",R("reader.firstUnit",{unit:O})]}),D?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>Qe(D.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[R("reader.nextUnit",{unit:O}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:D.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[R("reader.lastUnit",{unit:O})," →"]})]})]}),(v||$)&&!ze&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":R("reader.rail"),children:[v,$&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:B=>B.preventDefault(),onClick:yt,children:R("reader.reportError")})})]})]})]}),Me&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":R("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":M,"aria-controls":ke,onClick:()=>{nt(null),Fe()},children:[t.jsx(Pa,{}),t.jsx("span",{children:R("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":Ke==="img","aria-haspopup":"dialog",onClick:B=>ne("img",B.currentTarget),children:[t.jsx(Oa,{}),t.jsx("span",{children:R("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":Ke==="set","aria-haspopup":"dialog",onClick:B=>ne("set",B.currentTarget),children:[t.jsx(Ba,{}),t.jsx("span",{children:R("reader.settingsShort")})]}),$&&t.jsxs("button",{type:"button",onMouseDown:B=>B.preventDefault(),onClick:()=>{nt(null),yt()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:R("reader.reportError")})]})]}),Me&&Ke&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:q}),t.jsxs("div",{className:"bim-rd-sheet",ref:Pe,role:"dialog","aria-modal":"true","aria-label":R(Ke==="img"?"reader.images":"reader.settings"),onKeyDown:B=>{if(B.key==="Escape"){B.stopPropagation(),q();return}B.key==="Tab"&&Wa(B,Pe.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:R(Ke==="img"?"reader.images":"reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":R("reader.close"),onClick:q,children:"✕"})]}),Ke==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(lo,{pages:c??null,loading:p,renderOverlay:m,preserveMargins:u.preserveMargins})}):Je]})]})]})}function Uf(e,n,i){return i?ed(e).includes("\r")?"lone-cr":Array.from(e).length!==Array.from(n).length?"convert-length":n.includes(":::")?"tables":null:"quoteStyle"}function ed(e){return e.replace(/\r\n/g,`
|
|
756
|
-
`)}const
|
|
757
|
-
`)return-1;if(s==="\\"){o++;continue}if(s==="[")i++;else if(s==="]"&&(i--,i===0))return o}return-1}function
|
|
758
|
-
`)<0?{node:{type:"qw",label:e.slice(n+2,o)},end:o+2}:null}if(i===":"&&e.startsWith(":zi[",n)){const o=
|
|
759
|
-
`)return null}const m=
|
|
760
|
-
.bim-d-main.bim-d-main-grid { max-width: ${
|
|
753
|
+
@media ${Fi} { .guji-page-indicator { display: none; } }
|
|
754
|
+
`;function ts(e,n){var i;return n?e.key===n?!0:!!((i=e.children)!=null&&i.some(o=>ts(o,n))):!1}const Ha=()=>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 Mh({item:e,activeKey:n,onSelect:i,tabKey:o}){const{t:s}=oe(),a=ts(e,n),[l,d]=h.useState(a||!!e.defaultExpanded);return h.useEffect(()=>{a&&d(!0)},[a]),h.useEffect(()=>{e.defaultExpanded&&d(!0)},[e.defaultExpanded]),e.selectable?t.jsxs("li",{children:[t.jsxs("div",{className:"bim-rd-ti-row",children:[t.jsx("button",{type:"button",className:"bim-rd-ti-tw","aria-expanded":l,"aria-label":s(l?"reader.tocCollapse":"reader.tocExpand"),tabIndex:-1,onClick:()=>d(c=>!c),children:t.jsx(Ha,{})}),t.jsxs("button",{type:"button",className:`bim-rd-ti${e.inChapter?"":" bim-rd-ti-group"}`,"aria-current":e.key===n?"true":void 0,disabled:e.disabled,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>{d(!0),i(e.key)},onKeyDown:c=>{c.key==="ArrowRight"&&!l?(c.preventDefault(),d(!0)):c.key==="ArrowLeft"&&l&&(c.preventDefault(),d(!1))},children:[t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]})]}),l&&t.jsx(mo,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]}):t.jsxs("li",{children:[t.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":l,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>d(c=>!c),children:[t.jsx(Ha,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),l&&t.jsx(mo,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]})}function mo({items:e,activeKey:n,onSelect:i,tabKey:o}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(Mh,{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 Da(e,n){var i;for(const o of e)if(o.key===n||ts(o,n))return o.key;return((i=e[0])==null?void 0:i.key)??null}function ed({items:e,activeKey:n,onSelect:i,label:o}){const{t:s}=oe(),a=o??s("reader.toc"),l=h.useRef(null),[d,c]=h.useState(null);h.useEffect(()=>{c(null)},[n]);const p=h.useMemo(()=>d||(n??Da(e,n)),[d,n,e]);h.useEffect(()=>{const g=l.current;if(!g)return;const u=Array.from(g.querySelectorAll("[data-rd-toc-key]"));if(u.length===0)return;const f=u.find(x=>x.dataset.rdTocKey===p)??u.find(x=>x.dataset.rdTocKey===Da(e,n))??u.find(x=>!x.disabled)??u[0];for(const x of u)x.tabIndex=x===f?0:-1}),h.useEffect(()=>{const g=l.current,u=g==null?void 0:g.closest(".bim-rd-toc");if(!g||!u||!n)return;const f=Array.from(g.querySelectorAll("[data-rd-toc-key]")).find(j=>j.dataset.rdTocKey===n);if(!f)return;const x=f.getBoundingClientRect().top-u.getBoundingClientRect().top+u.scrollTop;(x<u.scrollTop+80||x>u.scrollTop+u.clientHeight-40)&&(u.scrollTop=Math.max(0,x-u.clientHeight/3))},[n]);const m=h.useCallback(g=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(g.key))return;const f=l.current;if(!f)return;const x=Array.from(f.querySelectorAll("[data-rd-toc-key]")).filter(b=>!b.disabled),j=x.indexOf(document.activeElement);let y=j;if(g.key==="ArrowDown"?y=Math.min(x.length-1,j+1):g.key==="ArrowUp"?y=Math.max(0,j-1):g.key==="Home"?y=0:g.key==="End"&&(y=x.length-1),y<0||y===j)return;g.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:m,children:t.jsx(mo,{items:e,activeKey:n,onSelect:i,tabKey:p})})}function Ua({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 Ah(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)),m=Math.min(o,Math.max(0,a-c)),g=Math.min(i,Math.max(0,l+c))-p,u=Math.min(o,Math.max(0,d+c))-m;return!(g>0)||!(u>0)||g>=i*.98&&u>=o*.98?null:{x:p,y:m,w:g,h:u}}function go({pages:e,loading:n,page:i,onPageChange:o,renderOverlay:s,preserveMargins:a=!0}){const{t:l}=oe(),[d,c]=h.useState(0),p=i??d,m=j=>{o?o(j):c(j)};if(h.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 g=Math.max(0,Math.min(e.length-1,p)),u=e[g],f=u.label??`${g+1}`,x=!a&&!s?Ah(u):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:u.url,alt:u.alt??l("reader.imageAlt",{label:f}),decoding:"async",style:{position:"absolute",maxWidth:"none",maxHeight:"none",width:`${u.width/x.w*100}%`,left:`${-x.x/x.w*100}%`,top:`${-x.y/x.h*100}%`}}),t.jsx(Ua,{page:u,crop:x})]}):t.jsxs("figure",{className:"bim-rd-img-fig",children:[t.jsx("img",{src:u.url,alt:u.alt??l("reader.imageAlt",{label:f}),width:u.width,height:u.height,loading:"lazy",decoding:"async"}),t.jsx(Ua,{page:u}),s==null?void 0:s(u,g)]})}),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:g===0,onClick:()=>m(g-1),children:"‹"}),t.jsx("span",{"aria-live":"polite",children:u.label??`${g+1} / ${e.length}`}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.nextImage"),disabled:g===e.length-1,onClick:()=>m(g+1),children:"›"})]})]})}function Ph(e){return e==="lite"||e==="full"}const gi=[.1,.9],td=[{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 Bh(e){var n;return((n=td.find(i=>i.key===e))==null?void 0:n.stack)??null}const ns={fontSize:null,readingMode:"line",properNameMode:null,writingMode:"horizontal",workLinks:!0,fontFamily:"song",pageBreaks:!1,pageIndicatorY:.33,bookTitleStyle:"bracket",showWorks:!0,quoteStyle:"original",scriptMode:null,preserveMargins:!0},tn=[15,16,17,18,20,22,24],ho=18,nd="bim-reader-prefs",id=2,Oh="bim-reading-mode";function Wh(){const e={...ns};try{const n=localStorage.getItem(nd),i=n?JSON.parse(n):{};typeof i.fontSize=="number"&&tn.includes(i.fontSize)&&(e.fontSize=i.fontSize),(i.readingMode??localStorage.getItem(Oh))==="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);const s=i.v===id;s&&typeof i.pageBreaks=="boolean"&&(e.pageBreaks=i.pageBreaks),typeof i.pageIndicatorY=="number"&&Number.isFinite(i.pageIndicatorY)&&i.pageIndicatorY>=gi[0]&&i.pageIndicatorY<=gi[1]&&(e.pageIndicatorY=i.pageIndicatorY),s&&(i.bookTitleStyle==="wavy"||i.bookTitleStyle==="bracket")&&(e.bookTitleStyle=i.bookTitleStyle),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 Fh(e){try{localStorage.setItem(nd,JSON.stringify({...e,v:id}))}catch{}}function Mi(e,n){const i=e??ho,o=tn;let s=o.indexOf(i);return s<0&&(s=o.indexOf(ho)),o[Math.max(0,Math.min(o.length-1,s+n))]}function rd(){const[e,n]=h.useState(ns);h.useEffect(()=>{n(Wh())},[]);const i=h.useCallback(o=>{n(s=>{const a={...s,...o};return Fh(a),a})},[]);return[e,i]}function fo(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 od(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 sd(e){const n=[],i=o=>{for(const s of o){if(s.inChapter)continue;const a=!!s.children&&s.children.length>0;(!a||s.selectable)&&n.push(s),a&&i(s.children)}};return i(e),n}const Va=()=>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"})}),Hh=()=>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"})}),Dh=()=>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"})}),Ga=()=>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"})]}),Ya=()=>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 Ka(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 qa(e,n){const[i,o]=h.useState(n);return h.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 Uh({prefs:e,onPrefsChange:n,origAvailable:i}){const o=h.useContext(qt),{t:s}=oe();if(!o)return null;const a=o.locale==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a,d=[{key:"orig",short:s("reader.scriptOrigShort"),title:s(i?"reader.scriptOrig":"reader.scriptOrigUnavailable"),disabled:!i},{key:"hant",short:s("common.localeShortHant"),title:s("reader.scriptHant")},{key:"hans",short:s("common.localeShortHans"),title:s("reader.scriptHans")}];return t.jsx("span",{className:"bim-rd-script-sw",role:"group","aria-label":s("reader.scriptQuick"),children:d.map((c,p)=>t.jsxs(h.Fragment,{children:[p>0&&t.jsx("span",{className:"bim-rd-off","aria-hidden":"true",children:"|"}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":l===c.key,title:c.title,"aria-label":c.title,disabled:c.disabled,onClick:()=>{c.disabled||(n({scriptMode:c.key}),c.key==="hant"?o.setLocale("zh-Hant"):c.key==="hans"&&o.setLocale("zh-Hans"))},children:c.short})]},c.key))})}function Hi({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,disabled:a.disabled,onClick:()=>{a.disabled||o(a.key)},children:a.label},a.key))})]})}function Vh({prefs:e,onPrefsChange:n,origAvailable:i}){const o=h.useContext(qt),{t:s}=oe(),a=(o==null?void 0:o.locale)==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a;return t.jsx(Hi,{label:s("reader.script"),value:l,options:[{key:"orig",label:s("reader.scriptOrig"),title:i?void 0:s("reader.scriptOrigUnavailable"),disabled:!i},{key:"hant",label:s("reader.scriptHant")},{key:"hans",label:s("reader.scriptHans")}],onPick:d=>{n({scriptMode:d}),d==="hant"?o==null||o.setLocale("zh-Hant"):d==="hans"&&(o==null||o.setLocale("zh-Hans"))}})}function Gh(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 Yh(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 ad({title:e,subtitle:n,toc:i,activeKey:o,tocActiveKey:s,onSelect:a,tocHeader:l,tocCaption:d,images:c,imagesLoading:p,renderImageOverlay:m,imagePanel:g="auto",prefs:u,onPrefsChange:f,paragraphToggle:x,properNameToggle:j=!0,allowVertical:y,origScriptAvailable:S=!0,byline:b,current:v,workLinkToggle:w,rail:k,onReportError:_,revisedAt:$,backHref:C,backLabel:L,bottomBar:E=!0,pager:T=!0,contentLoading:N=!1,pagerUnit:W,versions:F,currentVersionKey:R,onVersionChange:G,versionSource:Q=!0,keepChapterOnVersionChange:ie=!1,customImagePanel:de,toolbarExtra:q,settingsAnnotate:ee,settingsLayout:U,settingsExtra:se,settingsExtraTitle:pe,isWarpMode:_e,showPreserveMargins:Le=!0,children:Ee,className:ue,style:be}){const{t:A,convert:K}=oe(),le=L??A("reader.back"),M=K(W??A("reader.unitJuan")),J=h.useId().replace(/:/g,""),ye=`bim-rd-toc-${J}`,je=`bim-rd-text-${J}`,Ue=h.useRef(null),H=h.useRef(null),me=h.useRef(null),ge=h.useRef(null),ne=qa(Jc,!0),Ne=qa(uo,!1),he=E&&Ne,[Ce,Ie]=h.useState(null),[Qe,gt]=h.useState(!1),lt=h.useRef(null),tt=`bim-rd-set-${J}`,Oe=h.useRef(null),z=h.useRef(null),re=(O,ae)=>{z.current=ae,Ie(Fe=>Fe===O?null:O)},te=h.useCallback(()=>{var O;Ie(null),(O=z.current)==null||O.focus()},[]);h.useEffect(()=>{he||Ie(null)},[he]),h.useEffect(()=>{var O,ae;Ce&&((ae=(O=Oe.current)==null?void 0:O.querySelector("button:not([disabled])"))==null||ae.focus())},[Ce]);const[fe,Me]=h.useState("auto"),P=fe==="auto"?ne:fe==="open",ce=!ne,X=!!de||!!c&&c.length>0,[Te,Se]=h.useState(g);h.useEffect(()=>{Se(g)},[g]);const ze=Te==="auto"?X||!!p:Te==="open",qe=h.useCallback(O=>{var ae;Me("auto"),O&&((ae=ge.current)==null||ae.focus())},[]),Pe=()=>Me(P?"closed":"open");h.useEffect(()=>{if(!ce||fe!=="open")return;const O=me.current,ae=O==null?void 0:O.querySelector('input, [data-rd-toc-key][tabindex="0"]');ae==null||ae.focus()},[ce,fe]);const it=h.useCallback(O=>{a(O),ce&&qe(!1);const ae=H.current,Fe=Ue.current;if(ae&&Fe&&typeof window<"u"){const Ke=ae.getBoundingClientRect().top-Fe.getBoundingClientRect().bottom;Ke<0&&window.scrollBy({top:Ke})}},[a,ce,qe]),pt=h.useMemo(()=>sd(i),[i]),[Z,$e]=h.useState(null),ke=od(F,R!==void 0?R:Z),Ye=(ke==null?void 0:ke.key)??null,We=h.useMemo(()=>pt.map(O=>O.key).join(`
|
|
755
|
+
`),[pt]),De=h.useRef(null),ht=O=>{O!==Ye&&(ie||(De.current={key:O,sig:We,done:!1}),R===void 0&&$e(O),G==null||G(O))};h.useEffect(()=>{const O=De.current;if(!O||O.key!==Ye)return;const ae=pt.find(Ke=>!Ke.disabled);if(!ae)return;const Fe=We!==O.sig;!Fe&&O.done||(Fe?De.current=null:O.done=!0,ae.key!==o&&it(ae.key))},[Ye,We,pt,o,it]);const ct=pt.find(O=>O.key===o),yt=()=>{var O;_==null||_({chapterKey:o,chapterLabel:typeof(ct==null?void 0:ct.label)=="string"?ct.label:void 0,anchor:Gh(H.current,((O=Ue.current)==null?void 0:O.getBoundingClientRect().bottom)??0),selectedText:Yh(H.current)})},Xe=pt.findIndex(O=>O.key===o),V=Xe>0?pt.slice(0,Xe).reverse().find(O=>!O.disabled):void 0,D=Xe>=0?pt.slice(Xe+1).find(O=>!O.disabled):void 0,B=u.fontSize??ho,ve=Bh(u.fontFamily),Re={...be,...u.fontSize?{"--bimrd-fs":`${u.fontSize}px`}:null,...ve?{"--bimrd-ff":ve}:null},Ae={song:A("reader.fontSong"),kai:A("reader.fontKai"),system:A("reader.fontSystem")},Je=j||!!ee,rt=t.jsxs("div",{className:"bim-rd-sp",children:[t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${tt}-g1`,children:[t.jsx("h3",{id:`${tt}-g1`,className:"bim-rd-sp-h",children:A("reader.groupText")}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:A("reader.font")}),t.jsx("select",{className:"bim-rd-sp-sel","aria-label":A("reader.font"),value:u.fontFamily,onChange:O=>f({fontFamily:O.target.value}),children:td.map(O=>t.jsx("option",{value:O.key,children:Ae[O.key]},O.key))})]}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:A("reader.fontSize")}),t.jsxs("span",{className:"bim-rd-sp-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.fontSmaller"),disabled:B<=tn[0],onClick:()=>f({fontSize:Mi(u.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[B,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.fontLarger"),disabled:B>=tn[tn.length-1],onClick:()=>f({fontSize:Mi(u.fontSize,1)}),children:"A+"})]})]}),t.jsx(Vh,{prefs:u,onPrefsChange:f,origAvailable:S}),t.jsx(Hi,{label:A("reader.quoteStyle"),value:u.quoteStyle,options:[{key:"modern",label:A("reader.quoteModern")},{key:"classic",label:A("reader.quoteClassic")},{key:"original",label:A("reader.quoteOriginal")}],onPick:O=>f({quoteStyle:O})})]}),Je&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${tt}-g2`,children:[t.jsx("h3",{id:`${tt}-g2`,className:"bim-rd-sp-h",children:A("reader.groupMark")}),j&&t.jsxs(t.Fragment,{children:[t.jsx(Hi,{label:A("reader.properName"),value:u.properNameMode,title:A("reader.properNameTitle"),options:[{key:"off",label:A("reader.properNameOff")},{key:"lite",label:A("reader.properNameLite"),title:A("reader.properNameLiteTitle")},{key:"full",label:A("reader.properNameFull")}],onPick:O=>f({properNameMode:O})}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.showWorks,onChange:O=>f({showWorks:O.target.checked})}),t.jsx("span",{children:A("reader.showWorks")})]}),t.jsx(Hi,{label:A("reader.bookTitleStyle"),value:u.bookTitleStyle,options:[{key:"wavy",label:A("reader.bookTitleWavy")},{key:"bracket",label:A("reader.bookTitleBracket")}],onPick:O=>f({bookTitleStyle:O})})]}),ee]}),t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${tt}-g3`,children:[t.jsx("h3",{id:`${tt}-g3`,className:"bim-rd-sp-h",children:A("reader.groupLayout")}),x&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.readingMode==="paragraph",title:A("reader.paragraphTitle"),onClick:()=>f({readingMode:u.readingMode==="paragraph"?"line":"paragraph"}),children:A("reader.paragraph")}),w&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.workLinks,onChange:O=>f({workLinks:O.target.checked})}),t.jsx("span",{children:A("reader.workLinks")})]}),y&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.writingMode==="vertical",onClick:()=>f({writingMode:u.writingMode==="vertical"?"horizontal":"vertical"}),children:A("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:O=>f({pageBreaks:O.target.checked})}),t.jsx("span",{children:A("reader.pageBreaks")})]}),Le&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.preserveMargins,onChange:O=>f({preserveMargins:O.target.checked})}),t.jsx("span",{children:A("reader.preserveMargins")})]}),U]}),se&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${tt}-g4`,children:[t.jsx("h3",{id:`${tt}-g4`,className:"bim-rd-sp-h",children:pe??A("reader.groupMore")}),se]})]}),Ve=h.useRef(null);return h.useEffect(()=>{const O=Ve.current;if(!O||!ze)return;let ae=0,Fe=-1;const Ke=()=>{ae=0;const ot=parseFloat(getComputedStyle(O).top);if(!Number.isFinite(ot))return;const ft=Math.max(0,Math.round(O.getBoundingClientRect().top-ot));ft!==Fe&&(Fe=ft,O.style.setProperty("--bimrd-img-lead",`${ft}px`))},He=()=>{ae||(ae=requestAnimationFrame(Ke))};He(),window.addEventListener("scroll",He,{passive:!0}),window.addEventListener("resize",He);const Ze=typeof ResizeObserver<"u"?new ResizeObserver(He):null;return Ze==null||Ze.observe(document.body),()=>{window.removeEventListener("scroll",He),window.removeEventListener("resize",He),Ze==null||Ze.disconnect(),ae&&cancelAnimationFrame(ae),O.style.removeProperty("--bimrd-img-lead")}},[ze]),t.jsxs("div",{className:["bim-rd",u.writingMode==="vertical"&&y?"bim-rd-vertical":"",ue].filter(Boolean).join(" "),"data-toc":fe,"data-img":ze?"open":"closed","data-bb":he?"":void 0,"data-set":!he&&Qe?"open":void 0,"data-warp":_e?"true":void 0,style:Re,children:[t.jsx("style",{children:Qc}),t.jsx("a",{className:"bim-rd-skip",href:`#${je}`,onClick:O=>{var ae,Fe,Ke;O.preventDefault(),(ae=H.current)==null||ae.focus(),(Ke=(Fe=H.current)==null?void 0:Fe.scrollIntoView)==null||Ke.call(Fe,{block:"start"})},children:A("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:Ue,children:[C&&t.jsxs("a",{className:"bim-rd-back",href:C,"aria-label":A("reader.backAria",{label:le}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:le})]}),(e||n||b||v)&&t.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[e&&t.jsx("b",{children:e}),b&&t.jsx("span",{className:"bim-rd-by",children:b}),v&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-rd-cur",children:v})]}),n&&t.jsx("span",{className:"bim-rd-ttl-src",children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":A("reader.settings"),children:[F&&F.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:ke?K(fo(ke)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:A("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:A("reader.versionShort")}),t.jsx("select",{"aria-label":A("reader.version"),value:Ye??"",onChange:O=>ht(O.target.value),children:F.map(O=>t.jsx("option",{value:O.key,children:K(fo(O))},O.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),T&&(V||D)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":A("reader.pagerGroup",{unit:M}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.prevUnit",{unit:M}),title:V?typeof V.label=="string"&&V.label?A("reader.prevUnitTitle",{unit:M,label:V.label}):A("reader.prevUnit",{unit:M}):A("reader.firstUnit",{unit:M}),disabled:!V,onClick:()=>V&&it(V.key),children:t.jsx(Hh,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.nextUnit",{unit:M}),title:D?typeof D.label=="string"&&D.label?A("reader.nextUnitTitle",{unit:M,label:D.label}):A("reader.nextUnit",{unit:M}):A("reader.lastUnit",{unit:M}),disabled:!D,onClick:()=>D&&it(D.key),children:t.jsx(Dh,{})})]}),T&&(V||D)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:ge,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":P,"aria-controls":ye,onClick:Pe,children:[t.jsx(Va,{}),t.jsx("span",{className:"bim-rd-tlabel",children:A("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":ze,onClick:()=>Se(ze?"closed":"open"),children:[t.jsx(Ya,{}),A("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(Uh,{prefs:u,onPrefsChange:f,origAvailable:S}),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":A("reader.fontSmaller"),disabled:B<=tn[0],onClick:()=>f({fontSize:Mi(u.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":A("reader.fontLarger"),disabled:B>=tn[tn.length-1],onClick:()=>f({fontSize:Mi(u.fontSize,1)}),children:"A+"}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsxs("button",{ref:lt,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":Qe,"aria-controls":tt,onClick:()=>gt(O=>!O),children:[t.jsx(Ga,{}),t.jsx("span",{className:"bim-rd-tlabel",children:A("reader.settings")})]}),q]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:ye,ref:me,role:ce&&P?"dialog":void 0,"aria-modal":ce&&P?!0:void 0,"aria-label":ce&&P?A("reader.toc"):void 0,onKeyDown:O=>{if(!(!ce||!P)){if(O.key==="Escape"){O.stopPropagation(),qe(!0);return}O.key==="Tab"&&Ka(O,me.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:d??A("reader.toc")}),ce&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.closeToc"),onClick:()=>qe(!0),children:"✕"})]}),l]}),t.jsx(ed,{items:i,activeKey:s!==void 0?s:o,onSelect:it})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>qe(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":A("reader.images"),ref:Ve,children:ze&&(de||t.jsx(go,{pages:c??null,loading:p,renderOverlay:m,preserveMargins:u.preserveMargins}))}),!he&&Qe&&t.jsxs("aside",{className:"bim-rd-set",id:tt,"aria-label":A("reader.settings"),onKeyDown:O=>{var ae;O.key==="Escape"&&(O.stopPropagation(),gt(!1),(ae=lt.current)==null||ae.focus())},children:[t.jsxs("div",{className:"bim-rd-sp-top",children:[t.jsx("span",{children:A("reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.closeSettings"),onClick:()=>{var O;gt(!1),(O=lt.current)==null||O.focus()},children:"✕"})]}),rt]}),t.jsxs("div",{className:"bim-rd-text",id:je,ref:H,tabIndex:-1,"data-rail":(k||_)&&!_e?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[Ee,Q&&ke&&(ke.sourceName||ke.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":ke.key,children:[ke.sourceName&&t.jsxs(t.Fragment,{children:[A("reader.sourceLabel")," ",ke.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:ke.sourceUrl,target:"_blank",rel:"noreferrer",children:K(ke.sourceName)}):K(ke.sourceName)]}),ke.sourceName&&ke.license&&t.jsx("span",{className:"bim-rd-dot"}),ke.license&&t.jsx(t.Fragment,{children:A("reader.licenseOf",{license:ke.license})})]}),$&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:A("reader.revisedAt",{date:$})}),_&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:O=>O.preventDefault(),onClick:yt,children:A("reader.reportError")})}),T&&!N&&(V||D)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":A("reader.pagerNav"),children:[V?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>it(V.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),A("reader.prevUnit",{unit:M})]}),t.jsx("span",{className:"bim-rd-pglabel",children:V.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",A("reader.firstUnit",{unit:M})]}),D?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>it(D.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[A("reader.nextUnit",{unit:M}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:D.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[A("reader.lastUnit",{unit:M})," →"]})]})]}),(k||_)&&!_e&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":A("reader.rail"),children:[k,_&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:O=>O.preventDefault(),onClick:yt,children:A("reader.reportError")})})]})]})]}),he&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":A("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":P,"aria-controls":ye,onClick:()=>{Ie(null),Pe()},children:[t.jsx(Va,{}),t.jsx("span",{children:A("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":Ce==="img","aria-haspopup":"dialog",onClick:O=>re("img",O.currentTarget),children:[t.jsx(Ya,{}),t.jsx("span",{children:A("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":Ce==="set","aria-haspopup":"dialog",onClick:O=>re("set",O.currentTarget),children:[t.jsx(Ga,{}),t.jsx("span",{children:A("reader.settingsShort")})]}),_&&t.jsxs("button",{type:"button",onMouseDown:O=>O.preventDefault(),onClick:()=>{Ie(null),yt()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:A("reader.reportError")})]})]}),he&&Ce&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:te}),t.jsxs("div",{className:"bim-rd-sheet",ref:Oe,role:"dialog","aria-modal":"true","aria-label":A(Ce==="img"?"reader.images":"reader.settings"),onKeyDown:O=>{if(O.key==="Escape"){O.stopPropagation(),te();return}O.key==="Tab"&&Ka(O,Oe.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:A(Ce==="img"?"reader.images":"reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.close"),onClick:te,children:"✕"})]}),Ce==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(go,{pages:c??null,loading:p,renderOverlay:m,preserveMargins:u.preserveMargins})}):rt]})]})]})}function Kh(e,n,i){return i?ld(e).includes("\r")?"lone-cr":Array.from(e).length!==Array.from(n).length?"convert-length":n.includes(":::")?"tables":null:"quoteStyle"}function ld(e){return e.replace(/\r\n/g,`
|
|
756
|
+
`)}const Xa=2,qh=400,Xh=6,cd=e=>e==="*"||e==="#"||e==="<"||e===">"||/\s/.test(e);function dd(e,n){if(e[n]!=="<"||e[n+1]!=="!"||e[n+2]!=="-"||e[n+3]!=="-")return-1;for(let i=n+4;i+2<e.length;i++)if(e[i]==="-"&&e[i+1]==="-"&&e[i+2]===">")return i+2;return-1}function Zh(e,n,i){let o=n;for(let s=0;s<i.length;){if(o>=e.length)return-1;if(i[s]===e[o]){s++,o++;continue}const a=dd(e,o);if(a>=0){o=a+1;continue}if(cd(e[o])){o++;continue}if(i[s]===" "){s++;continue}return-1}return o}function Jh(e){const n=Array.from(ld(e));let i=0;return{align(o){if(!o)return;const s=Array.from(o);if(s.every(d=>d===" "||/\s/.test(d)))return;const a=s.length>=Xh;let l=0;for(let d=i;d<n.length&&d-i<=(a?qh:Xa+64);d++){const c=dd(n,d);if(c>=0){d=c;continue}if(!cd(n[d])){const m=Zh(n,d,s);if(m>=0)return i=m,d;if(l++,!a&&l>Xa)return}}}}}const Qh=65536,ef="guji_markdown";function tf(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 nf=/^□\{guess=([^\s{}]+)\}/;function rf(e,n){const i=e[n+1];return i!==void 0&&!/[A-Za-z/!?>\s]/.test(i)}function pd(e,n){let i=0;for(let o=n;o<e.length;o++){const s=e[o];if(s===`
|
|
757
|
+
`)return-1;if(s==="\\"){o++;continue}if(s==="[")i++;else if(s==="]"&&(i--,i===0))return o}return-1}function of(e){return e.replace(/\\([\\[\]<>|{}])/g,"$1")}function sf(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(`
|
|
758
|
+
`)<0?{node:{type:"qw",label:e.slice(n+2,o)},end:o+2}:null}if(i===":"&&e.startsWith(":zi[",n)){const o=pd(e,n+3);return o>n+4?{node:{type:"zi",label:of(e.slice(n+4,o))},end:o+1}:null}if(i==="□"&&e[n+1]==="{"){const o=nf.exec(e.slice(n,n+64));if(o)return{node:{type:"qz",guess:o[1]},end:n+o[0].length}}return null}function ud(e,n,i,o,s){const a=[];let l="",d=!1;const c=()=>{if(!l)return;let p=l;o&&(p=l.replace(/\\?\|/g,m=>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===`
|
|
759
|
+
`)return null}const m=sf(e,n);if(m){c(),a.push(m.node),n=m.end;continue}let g=null;if(p==="<"&&rf(e,n)&&(g=">"),g){const u=ud(e,n+1,g,!0,s);if(u&&!(u.end-(n+1)>s)){c(),a.push({type:"jz",children:u.nodes}),n=u.end+1;continue}}l+=p,n++}return i!==null?null:(c(),{nodes:a,end:n})}function md(e,n){return ud(e,0,null,!1,(n==null?void 0:n.jzMaxLength)??Qh).nodes}function af(e){return/[<□]|\[\[|:zi\[/.test(e)}function gd(e){return e.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${gd(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const lf=216,Za="clamp(280px, 23vw, 360px)",cf=1440,xo="(max-width: 719px)",df=`${xo}, (pointer: coarse)`,pf=`
|
|
760
|
+
.bim-d-main.bim-d-main-grid { max-width: ${cf}px; padding: 16px 32px 0; }
|
|
761
761
|
.bim-d-grid {
|
|
762
762
|
display: grid;
|
|
763
|
-
grid-template-columns: ${
|
|
763
|
+
grid-template-columns: ${lf}px minmax(0, 1fr) ${Za};
|
|
764
764
|
grid-template-rows: auto 1fr;
|
|
765
765
|
grid-template-areas: "rail main card" "rail main side";
|
|
766
766
|
column-gap: 32px; row-gap: 28px; align-items: start;
|
|
@@ -1138,7 +1138,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1138
1138
|
.bim-d-side li .bim-d-meta { font-size: 12px; flex: none; }
|
|
1139
1139
|
|
|
1140
1140
|
/* 点击目标 ≥44px(Q5):触屏与窄屏 */
|
|
1141
|
-
@media ${
|
|
1141
|
+
@media ${df} {
|
|
1142
1142
|
.bim-d-tab, .bim-d-check, .bim-d-more, .bim-d-rail-back,
|
|
1143
1143
|
.bim-d-card-foot summary, .bim-d-card-toggle, .bim-d-card details.bim-d-more-names summary,
|
|
1144
1144
|
.bim-d-tl summary, .bim-d-chap a { min-height: 44px; }
|
|
@@ -1176,7 +1176,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1176
1176
|
/* 中等宽度:左栏折到顶部一行 */
|
|
1177
1177
|
@media (max-width: 1100px) {
|
|
1178
1178
|
.bim-d-grid {
|
|
1179
|
-
grid-template-columns: minmax(0, 1fr) ${
|
|
1179
|
+
grid-template-columns: minmax(0, 1fr) ${Za};
|
|
1180
1180
|
grid-template-rows: auto auto 1fr;
|
|
1181
1181
|
grid-template-areas: "rail rail" "main card" "main side";
|
|
1182
1182
|
}
|
|
@@ -1190,7 +1190,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1190
1190
|
}
|
|
1191
1191
|
|
|
1192
1192
|
/* 手机:左栏收起,提要卡 → 正文 → 旁栏 */
|
|
1193
|
-
@media ${
|
|
1193
|
+
@media ${xo} {
|
|
1194
1194
|
.bim-d-main.bim-d-main-grid { padding: 8px 16px 0; }
|
|
1195
1195
|
.bim-d-grid {
|
|
1196
1196
|
grid-template-columns: minmax(0, 1fr);
|
|
@@ -1265,7 +1265,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1265
1265
|
:root[data-layout="boxed"] .bim-d-g-rail { border: ${r("fr-bd")}; background: ${r("fr-bg")}; padding: 14px 8px; }
|
|
1266
1266
|
:root[data-layout="boxed"] .bim-d-filters { border-bottom: 1px solid ${r("fr-tab-bd")}; }
|
|
1267
1267
|
:root[data-layout="boxed"] .bim-d-filters .bim-d-tab { margin-bottom: -1px; }
|
|
1268
|
-
@media ${
|
|
1268
|
+
@media ${xo} {
|
|
1269
1269
|
:root[data-layout="boxed"] .bim-d-card { padding: 16px; }
|
|
1270
1270
|
:root[data-layout="boxed"] .bim-d-g-rail { border: 0; background: transparent; padding: 0; }
|
|
1271
1271
|
}
|
|
@@ -1280,7 +1280,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1280
1280
|
: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 {
|
|
1281
1281
|
text-decoration-color: currentColor; text-decoration-thickness: 2px;
|
|
1282
1282
|
}
|
|
1283
|
-
`;function
|
|
1283
|
+
`;function xi({railTop:e,back:n,up:i,nav:o,railLinks:s,main:a,card:l,side:d}){const{t:c,convert:p}=oe(),m=(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,m.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:m.map(g=>t.jsx("li",{children:t.jsxs("a",{href:`#${g.id}`,children:[t.jsx("span",{children:p(g.label)}),g.count!=null&&t.jsx("span",{className:"bim-d-meta",children:g.count})]})},g.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(g=>t.jsx("li",{children:t.jsxs("a",{href:g.href??"#",onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),g.onClick())},children:[t.jsx("span",{children:p(g.label)}),t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:"→"})]})},g.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 hd({caption:e,children:n}){const{convert:i}=oe();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 St({id:e,title:n,meta:i,action:o,children:s}){const{convert:a}=oe();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 vt({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(h.Fragment,{children:[a>0&&t.jsx("span",{className:"bim-d-dot"}),t.jsx("span",{children:s})]},a))}):null}function gr({items:e,value:n,onChange:i}){const{convert:o}=oe();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 fd({label:e,checked:n,onChange:i}){const{convert:o}=oe();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 xd=6,hr=e=>e>xd+1;function is({total:e,shown:n,unit:i,onClick:o}){const{t:s,convert:a}=oe(),l=e-n,d=hr(e)?e-Math.min(n,xd):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 rs({label:e,onClick:n}){const{convert:i}=oe();return t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:i(e)})}function bi({kind:e,title:n,subtitle:i,byline:o,meta:s,description:a,clampDescription:l,facts:d,stats:c,readAction:p,secondaryAction:m,children:g,foot:u}){const{t:f,convert:x}=oe(),j=(d||[]).filter(w=>w.value!=null&&w.value!==""),y=(c||[]).filter(w=>w.value!=null&&w.value!==""&&w.value!==0),[S,b]=h.useState(!1),v=!!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:v?"bim-d-card-desc bim-d-clamp":"bim-d-card-desc",style:v?{"--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(w=>!w),children:f(S?"action.collapse":"action.expand")}),y.length>0&&t.jsx("div",{className:"bim-d-stats bim-d-ui",children:y.map((w,k)=>t.jsxs("div",{children:[t.jsx("b",{children:w.value}),t.jsx("span",{children:x(w.label)})]},k))}),j.length>0&&t.jsx("dl",{className:"bim-d-ui",children:j.map((w,k)=>t.jsxs(h.Fragment,{children:[t.jsx("dt",{children:x(w.label)}),t.jsx("dd",{title:w.title,children:w.value})]},k))}),g,p,m,u&&t.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:u})]})}function os(e){return!!e&&[...e.replace(/\s+/g,"")].length>110}function bo({href:e,onClick:n,label:i}){const{t:o,convert:s}=oe(),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 vn({id:e,title:n,meta:i,items:o,metas:s,currentIndex:a,cap:l=8,moreLabel:d,foot:c,sub:p,timeline:m}){const{t:g,convert:u}=oe(),[f,x]=h.useState(!1);if(!o.length)return null;const j=f?o:o.slice(0,l),y=o.length-j.length;return t.jsxs("div",{id:e,className:m?"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:[u(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:j.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(rs,{label:d?d(y):g("detail.showMore",{n:y}),onClick:()=>x(!0)}),c&&t.jsx("p",{className:"bim-d-side-note bim-d-ui",children:c})]})}const uf=new Set(["reviewed","disputed","unreviewed","draft"]);function yi({revision:e,revisedAt:n,review:i,todo:o}){const{t:s,convert:a}=oe(),l=i&&uf.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(m=>m&&m.what);return!c.length&&!p.length?null:t.jsxs(t.Fragment,{children:[c.length>0&&t.jsx(vt,{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((m,g)=>t.jsxs("li",{children:[a(m.what),(m.by||m.date)&&t.jsxs("span",{style:{marginLeft:6},children:["(",[m.by&&a(m.by),m.date].filter(Boolean).join(" · "),")"]})]},g))})]})]})}const Di=1e3,Ja=208,mf=1440,gf="(max-width: 719px)",bd=`
|
|
1284
1284
|
.bim-d-page {
|
|
1285
1285
|
background: ${r("page-bg")};
|
|
1286
1286
|
color: ${r("ink")};
|
|
@@ -1289,7 +1289,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1289
1289
|
padding-bottom: 64px;
|
|
1290
1290
|
}
|
|
1291
1291
|
.bim-d-main {
|
|
1292
|
-
max-width: ${
|
|
1292
|
+
max-width: ${Di}px;
|
|
1293
1293
|
margin: 0 auto;
|
|
1294
1294
|
padding: 24px clamp(16px, 4vw, 28px) 0;
|
|
1295
1295
|
}
|
|
@@ -1300,7 +1300,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1300
1300
|
* PAGE_MAX_WIDTH,读者的行宽体验不变。
|
|
1301
1301
|
*/
|
|
1302
1302
|
.bim-d-main.bim-d-main-wide {
|
|
1303
|
-
max-width: ${
|
|
1303
|
+
max-width: ${mf}px;
|
|
1304
1304
|
}
|
|
1305
1305
|
.bim-d-ui { font-family: var(--bim-font-ui, system-ui, sans-serif); }
|
|
1306
1306
|
|
|
@@ -1332,9 +1332,9 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1332
1332
|
*/
|
|
1333
1333
|
.bim-d-reader {
|
|
1334
1334
|
display: grid;
|
|
1335
|
-
grid-template-columns: ${
|
|
1335
|
+
grid-template-columns: ${Ja}px minmax(0, ${Di}px);
|
|
1336
1336
|
gap: 32px;
|
|
1337
|
-
max-width: ${
|
|
1337
|
+
max-width: ${Ja+Di+32}px;
|
|
1338
1338
|
margin: 0 auto;
|
|
1339
1339
|
align-items: start;
|
|
1340
1340
|
}
|
|
@@ -1357,7 +1357,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1357
1357
|
align-items: start; margin-bottom: 48px; }
|
|
1358
1358
|
.bim-d-pair-wide { grid-template-columns: 1fr 1.2fr; }
|
|
1359
1359
|
|
|
1360
|
-
@media ${
|
|
1360
|
+
@media ${gf} {
|
|
1361
1361
|
.bim-d-intro { grid-template-columns: 1fr; gap: 20px; margin-bottom: 32px; }
|
|
1362
1362
|
.bim-d-pair, .bim-d-pair-wide { grid-template-columns: 1fr; gap: 40px; }
|
|
1363
1363
|
/* 表格:meta 列折到第二行,表头隐藏 */
|
|
@@ -1375,22 +1375,22 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1375
1375
|
padding-right: 0; padding-bottom: 12px;
|
|
1376
1376
|
}
|
|
1377
1377
|
}
|
|
1378
|
-
${
|
|
1379
|
-
`)||(n.push({start:i,end:l+1,inner:d}),i=l)}return n}function
|
|
1378
|
+
${pf}`;function li({children:e,style:n,wide:i,grid:o}){return t.jsxs("div",{className:"bim-d-page",style:n,children:[t.jsx("style",{children:bd}),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 yo({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 ss({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 jo({items:e}){const n=kt();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(h.Fragment,{children:[a,d]},o)})})}function yd({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 hf({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 ff({items:e,horizontal:n}){const{convert:i}=Ge();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 xf({glyph:e,tone:n,title:i,count:o,actions:s,id:a}){const{convert:l}=Ge();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(ss,{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 jd({label:e,active:n,onClick:i,dashed:o}){const{convert:s}=Ge();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 bf({label:e,onClick:n}){const{convert:i}=Ge();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 yf({label:e,onClick:n,inline:i}){const{convert:o}=Ge();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 vd({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 jf({children:e}){return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e})}function vf({volumes:e,unit:n,max:i=60}){const{t:o}=oe(),s=n??o("unit.volume"),[a,l]=h.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 kf({children:e}){return t.jsx("div",{style:{borderTop:`1px solid ${r("rule-strong")}`},children:e})}function wf({spec:e}){const{convert:n}=Ge();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 Sf({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 $f(e){return String(e+1).padStart(2,"0")}function _f(){return t.jsx("span",{style:{color:r("hint-fg")},children:"—"})}function Cf({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 kd(e){const n=[];for(let i=0;i<e.length;i++){if(e[i]!=="<")continue;const s=e[i+1];if(s===void 0||/[A-Za-z/!?>\s]/.test(s))continue;const l=e.indexOf(">",i+1);if(l<0)continue;const d=e.slice(i+1,l);d.includes(`
|
|
1379
|
+
`)||(n.push({start:i,end:l+1,inner:d}),i=l)}return n}function wd(e,n){if(e.length<=n)return e;let i=n;for(const o of kd(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 Sd={fontSize:".78em",color:r("meta-fg"),lineHeight:1.55},zf={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 $d(e,n,i,o){return e.map((s,a)=>{switch(s.type){case"text":return t.jsx(h.Fragment,{children:n(s.text)},a);case"jz":return t.jsx("span",{className:"bim-jiazhu",style:i===0?Sd:void 0,children:$d(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:zf,children:s.label},a)}})}function Bt(e,n=o=>o,i){if(!e)return"";if(i!=null&&i.gujiMarkdown)return af(e)?$d(md(e,{jzMaxLength:i.jzMaxLength}),n,0,i.t??Gn("zh-Hant")):n(e);if(e.indexOf("<")<0)return n(e);const o=[];let s=0,a=0;for(const l of kd(e))l.start>s&&o.push(t.jsx(h.Fragment,{children:n(e.slice(s,l.start))},a++)),o.push(t.jsx("span",{className:"bim-jiazhu",style:Sd,children:n(l.inner)},a++)),s=l.end;return s<e.length&&o.push(t.jsx(h.Fragment,{children:n(e.slice(s))},a++)),o}function Nf({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 Tf({title:e,tag:n,children:i}){const{convert:o}=Ge();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 _d({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 Rf({item:e,siblings:n,showVolumes:i=!0,fallbackNote:o}){const{t:s,convert:a}=oe(),[l,d]=h.useState(!1),c=nr(e),p=i&&!!c&&c.expected>0,m=(e.url?Dn(e.url):void 0)||a(e.name),g=n?Sc(e,n):"",u=g?`${m}(${g})`:m;return t.jsx(_d,{name:u,note:lr(e,s)||o,href:Un(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(as,{item:e})]}):void 0})}function as({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 Cd({label:e,items:n}){const{convert:i}=Ge();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(vd,{children:i(o)},s))]}):null}function Ef({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(Cd,{label:i.label,items:i.items},i.label))}):null}function zd(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Nd({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 If({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 jt({id:e,label:n,onNavigate:i,renderLink:o,style:s,dense:a}){const l=kt();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 Lf({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 Td="guji-table-v1";function Mf(e){return!!e&&e.table_notation===Td}const Af=/^:::table(?:\{[^}]*\})?[ \t]*$/,Pf=/^:::[ \t]*$/;function Rd(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=pd(e,o+3);if(l>o+4){i+=e.slice(o,l+1),o=l;continue}}let a=null;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 Bf=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function Of(e){if(e==="^")return{cont:!0};const n=Bf.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 Ed(e,n=1){const i=[],o=[],s=[];let a=[];e.forEach((d,c)=>{const p=c+n+1;let m=d.trim();if(!m)return;let g=!1;m.startsWith("!")&&(g=!0,m=m.slice(1));const u=Rd(m).map(Of),f=a.map(S=>S>0),x=a.map(S=>S>0?S-1:0),j=[];let y=0;for(const S of u){if(S.cont){f[y]||i.push(`第 ${p} 行第 ${y+1} 列:续格 ^ 上方没有跨行格`),y+=1;continue}const{cell:b}=S;for(let v=y;v<y+b.colspan;v++)if(f[v]){i.push(`第 ${p} 行第 ${v+1} 列:此处被上方跨行格占住,应写 ^`);break}if(b.rowspan>1)for(let v=y;v<y+b.colspan;v++)x[v]=b.rowspan-1;j.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:g,cells:j}),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 ls(e){const n=e.split(`
|
|
1380
1380
|
`),i=[];let o=[];const s=()=>{if(o.length===0)return;const l=o.join(`
|
|
1381
|
-
`);o=[],i.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(
|
|
1382
|
-
`)}),a=l+1;continue}}o.push(n[a]),a++}return s(),i.map((l,d)=>{var p,m;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+/,"")),((m=i[d+1])==null?void 0:m.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(l=>l.type!=="text"||l.text!=="")}const
|
|
1383
|
-
`).map(n=>n.trim()).filter(n=>n&&!
|
|
1384
|
-
`)){const s=o.trim();if(!s||
|
|
1381
|
+
`);o=[],i.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(Af.test(n[a].trim())){let l=a+1;for(;l<n.length&&!Pf.test(n[l].trim());)l++;if(l<n.length){s();const d=n.slice(a+1,l);i.push({type:"table",table:Ed(d,a+1),source:n.slice(a,l+1).join(`
|
|
1382
|
+
`)}),a=l+1;continue}}o.push(n[a]),a++}return s(),i.map((l,d)=>{var p,m;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+/,"")),((m=i[d+1])==null?void 0:m.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(l=>l.type!=="text"||l.text!=="")}const Wf={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},Ff={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},Hf=`1px solid ${r("table-border")}`,Id={border:Hf,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},Df={...Id,background:r("table-head-bg"),fontWeight:600};function cs({table:e,opts:n}){return t.jsx("div",{className:"bim-guji-table-wrap",style:Wf,children:t.jsx("table",{className:"bim-guji-table",style:Ff,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?Df:Id,children:s.empty?null:Bt(s.text,void 0,n)},a)})},o))})})})}function Uf(e,n){return e.indexOf("**")<0?Bt(e,void 0,n):e.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((o,s)=>s%2===1?t.jsx("strong",{children:Bt(o.trim().slice(2,-2),void 0,n)},s):t.jsx(h.Fragment,{children:Bt(o,void 0,n)},s))}function Vf(e,n,i=!1){const o=i?{gujiMarkdown:!0}:void 0;return n?ls(e).map((s,a)=>s.type==="table"?t.jsx(cs,{table:s.table,opts:o},a):t.jsx(h.Fragment,{children:Uf(s.text,o)},a)):Bt(e,void 0,o)}const Gf=/^(#{1,6})\s+(.*)$/,Yf=/^\*\*([^*\n]+)\*\*\s*$/;function ds(e){const n=e.match(Gf);if(n)return{level:n[1].length,text:n[2].trim()};const i=e.trim().match(Yf);return i?{level:3,text:i[1].trim()}:null}const ps=/^<!--.*-->$/;function Ld(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function Md(e){return e.split(`
|
|
1383
|
+
`).map(n=>n.trim()).filter(n=>n&&!ps.test(n))}const Kf=60;function Ad(e){let n=0,i=0;for(const o of e.split(`
|
|
1384
|
+
`)){const s=o.trim();if(!s||ps.test(s)||ds(s))continue;const a=s.replace(/<[^<>\n]*>/g,"").replace(/\s/g,"").length;n+=a,a>Kf&&(i+=a)}return n>0&&i*2>=n}function qf(e){return e.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function fr(e){if(e=qf(e),Ad(e))return"unknown";const n=Ld(e);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const i=n.map(s=>Md(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 Xf(e){const n=e.split(`
|
|
1385
1385
|
`),i=[];let o=null,s=[];const a=()=>{i.push({heading:o,body:s.join(`
|
|
1386
|
-
`)}),s=[]};for(const l of n){const d=
|
|
1387
|
-
`)){const o=
|
|
1388
|
-
`)?"":n)}function
|
|
1389
|
-
`);let p=0;return t.jsx(t.Fragment,{children:c.map((m,g)=>{const u=m.match(
|
|
1390
|
-
,。、;:?!「」『』()…—·`));function
|
|
1386
|
+
`)}),s=[]};for(const l of n){const d=ds(l);if(d){a(),o={kind:"heading",level:d.level,text:d.text};continue}s.push(l)}return a(),i}function Qa(e){const n=[];for(const i of e.split(`
|
|
1387
|
+
`)){const o=ds(i);if(o){n.push({kind:"heading",level:o.level,text:o.text});continue}const s=i.trim();!s||ps.test(s)||n.push({kind:"body",text:i})}return n}function Pd(e){if(!e)return[];const n=fr(e);if(n==="unknown")return Qa(e);const i=[];for(const{heading:o,body:s}of Xf(e)){o&&i.push(o);const a=Ld(s);if(a.length!==0){if(Ad(s)){i.push(...Qa(s));continue}if(n==="record"){const l=a.join(" ");l&&i.push({kind:"body",text:l})}else for(const l of a){const d=Md(l);d.length&&i.push({kind:"body",text:d.join(" ")})}}}return i}const Zf={"「":"“","」":"”","『":"‘","』":"’"},Jf={"“":"「","”":"」","‘":"『","’":"』"},Qf=new Set(["《","》","〈","〉"]);function Bd(e,n){const i=n.quoteStyle==="modern"?Zf:n.quoteStyle==="classic"?Jf:null;let o="";for(const s of e)n.hideBookBrackets&&Qf.has(s)||(o+=(i==null?void 0:i[s])??s);return o}const Od=e=>e;function us(e){return e.showWorks?e.bookTitleStyle==="bracket"?"bracket":Ph(e.properNameMode)?"wavy":"bracket":"none"}function Wd(e,n=Od,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(h.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(h.Fragment,{children:c},l++)),a=d.index+d[0].length}return a===0?n(e):(a<e.length&&o.push(t.jsx(h.Fragment,{children:n(e.slice(a))},l++)),o)}function xr(e,n={}){let i=n.renderText??Od;const o=n.quoteStyle;if(o&&o!=="original"){const d=i;i=c=>d(Bd(c,{quoteStyle:o}))}const s=n.bookMarking??(n.properNames?"wavy":"bracket"),a=s==="bracket"?i:d=>Wd(d,i,s),l=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return Bt(e,a,l)}function el(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(h.Fragment,{children:n(s)},`${i}-${a}`))}const Xr=/^(#{1,6})\s+(.*)$/,ex=/^\s*<!--.*-->\s*$/;function Fd(e){return e.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
|
|
1388
|
+
`)?"":n)}function tx(e){return e<=1?2:e===2?3:4}function nx(){let e=1;return n=>{const i=tx(n),o=Math.min(i,e+1);return e=o,{Tag:`h${o}`,className:`bim-rd-hl${i}`}}}function Ji(e){return e?fr(Fd(e))!=="unknown":!1}function ix(e){return/^\u3000{2}/.test(e)}const tl=e=>ix(e)?"bim-rd-noindent":void 0;function nl({text:e,mode:n,inline:i,dropTitle:o,onStart:s}){s==null||s();const a=Fd(e),l=(m,g,u)=>!!o&&u<=1&&m<=2&&g.trim()===o.trim(),d=nx();if(n==="paragraph"&&fr(a)!=="unknown"){const m=Pd(a);return t.jsx(t.Fragment,{children:m.map((g,u)=>{if(g.kind==="heading"){if(l(g.level??1,g.text,u))return null;const{Tag:f,className:x}=d(g.level??1);return t.jsx(f,{className:x,children:i(g.text)},u)}return t.jsx("p",{className:tl(g.text),children:el(g.text,i,u)},u)})})}const c=a.split(`
|
|
1389
|
+
`);let p=0;return t.jsx(t.Fragment,{children:c.map((m,g)=>{const u=m.match(Xr);if(u){const x=p++;if(l(u[1].length,u[2],x))return null;const{Tag:j,className:y}=d(u[1].length);return t.jsx(j,{className:y,children:i(u[2])},g)}if(!m.trim())return g>=2&&!!c[g-1].trim()&&!!c[g-2].trim()&&!Xr.test(c[g-1])&&!Xr.test(c[g-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},g):null;if(ex.test(m))return null;if(p++,/^\*\*[^*]+\*\*\s*$/.test(m.trim())){const{Tag:x,className:j}=d(3);return t.jsx(x,{className:j,children:i(m.trim().slice(2,-2))},g)}return t.jsx("p",{className:tl(m),children:el(m,i,g)},g)})})}function rx(e){const{convert:n}=Ge();return h.useMemo(()=>e?n(e):"",[e,n])}function ms({text:e,mode:n,tables:i=!1,gujiMarkdown:o=!1,properNames:s=!1,bookMarking:a,quoteStyle:l,renderText:d,dropTitle:c}){const p=rx(e),{t:m,convert:g}=oe();let u=null;const f=!!d&&!Kh(e,p,!l||l==="original"),x=d&&f?v=>d(v,{mdStart:u==null?void 0:u.align(v)}):d,j=f?()=>{u=Jh(e)}:void 0,y=v=>xr(v,{renderText:x,properNames:s,bookMarking:a,quoteStyle:l,gujiMarkdown:o,t:m}),S=o?{gujiMarkdown:!0,t:m}:void 0,b=c?g(c):void 0;return!i||p.indexOf(":::")<0?t.jsx(nl,{text:p,mode:n,inline:y,dropTitle:b,onStart:j}):t.jsx(t.Fragment,{children:ls(p).map((v,w)=>v.type==="table"?t.jsx(cs,{table:v.table,opts:S},w):t.jsx(nl,{text:v.text,mode:n,inline:y,dropTitle:w===0?b:void 0},w))})}const il={work:"work",book:"work",people:"people",person:"people",place:"place",office:"office",dynasty:"dynasty",reign:"reign"};function ox(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(il,e)&&il[e]||"other"}function $n(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 dn(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function ut(e){return typeof e=="string"&&e?e:void 0}function sx(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={};ut(s.entity_id)!==void 0&&(a.entity_id=ut(s.entity_id)),ut(s.canonical_name)!==void 0&&(a.canonical_name=ut(s.canonical_name)),dn(s.confidence)!==void 0&&(a.confidence=dn(s.confidence)),i.push(a)}return i}function ax(e){if(!Array.isArray(e.targets))return;const n=[];for(const i of e.targets){if(!i||typeof i!="object"||Array.isArray(i))continue;const o=i,s=$n(ut(o.entity_id))??$n(ut(o.href));s&&n.push({id:s,...ut(o.canonical_name)?{canonicalName:ut(o.canonical_name)}:{},...ut(o.part)?{part:ut(o.part)}:{}})}return n.length>=2?n:void 0}function lx(e){const n=e&&typeof e=="object"?e.parts:void 0;if(!Array.isArray(n))return;const i=[];for(const o of n){if(!o||typeof o!="object")continue;const s=o,a=s.target??{},l=$n(ut(a.entity_id))??$n(ut(a.href)),d=s.offset;!l||!Array.isArray(d)||typeof d[0]!="number"||typeof d[1]!="number"||d[0]<0||d[1]<=d[0]||i.push({id:l,offset:[d[0],d[1]]})}return i.length?i:void 0}const An=e=>e.start!==void 0&&e.end!==void 0;function Hd(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=dn(l.start_offset)??dn(a.start_offset),p=dn(l.end_offset)??dn(a.end_offset),m=c!==void 0&&p!==void 0&&c>=0&&p>c,g=a.anchor??{},u=ut(g.start),f=ut(g.end);if(!m&&!!!(u&&f))return;const j=ut(d.status),y=j===void 0||j==="matched"?$n(ut(d.entity_id))??$n(ut(d.href))??void 0:void 0,S=dn(d.confidence),b=j==="matched_multi"?ax(d):void 0,v=sx(a.ambiguous),w=lx(a.decomposition);i.push({...u&&f?{anchor:{start:u,end:f}}:{},key:ut(a.id)??`e${s}`,kind:ox(a.type),...m?{start:c,end:p}:{},text:ut(a.text),targetId:y,canonicalName:ut(d.canonical_name),...b?{targets:b}:{},confidence:dn(a.confidence)??S,...S!==void 0?{targetConfidence:S}:{},...ut(d.level)!==void 0?{targetLevel:ut(d.level)}:{},...ut(d.note)!==void 0?{targetNote:ut(d.note)}:{},...ut(a.group)!==void 0?{group:ut(a.group)}:{},...v!==void 0?{candidates:v}:{},...w?{parts:w}:{}})}),i.sort((o,s)=>!An(o)||!An(s)?+!An(o)-+!An(s):o.start-s.start||s.end-o.end)}const cx=new Set(Array.from(`《》/<>\r
|
|
1390
|
+
,。、;:?!「」『』()…—·`));function gs(e){return!cx.has(e)}function Dd(e,n,i=0){const o=[],s=Array.from(e);let a=0;for(const d of s)gs(d)&&o.push(a),a+=d.length;const l=[];for(const d of n){if(!An(d))continue;const c=d.start-i,p=d.end-i;if(c<0||p>o.length||p<=c)continue;const m=o[p-1],g=e.codePointAt(m)>65535?2:1;l.push({...d,start:o[c],end:m+g})}return l}function dx(e,n){return n.text?Array.from(e.slice(n.start,n.end)).filter(gs).join("")===n.text:!0}function px(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 Ud(e,n,i=16){const o=[];for(const l of n){if(!An(l))continue;let d={...l,start:Math.max(0,l.start),end:Math.min(e.length,l.end)};(d.end<=d.start||!dx(e,d))&&(d=px(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 ux={off:[],lite:["people","place","dynasty"],full:["people","place","dynasty","office","reign","other"]};function mx(e,n,i){const o=(i==null?void 0:i.showWorks)!==!1,s=new Set(ux[n]);return e.filter(a=>a.kind==="work"?o:s.has(a.kind))}function gx(e,n,i,o=""){const s=`${o}
|
|
1391
1391
|
${i.versionKey??""}
|
|
1392
|
-
${n??""}`,[a,l]=f.useState({tag:"",images:null}),d=f.useRef(0);f.useEffect(()=>{const p=++d.current,m=u=>{p===d.current&&l({tag:s,images:u})};if(!e||!n){m(null);return}let g;try{g=e(n,i)}catch{m(null);return}if(!g||typeof g.then!="function"){m(g??null);return}g.then(u=>m(u??null),()=>m(null))},[e,n,i,s]);const c=a.tag===s;return{images:c?a.images:null,loading:!!e&&!!n&&!c}}function dx(){let e=null;const n=new Set;return{get:()=>e,set:i=>{i!==e&&(e=i,n.forEach(o=>o()))},subscribe:i=>(n.add(i),()=>{n.delete(i)})}}function px(e){return f.useSyncExternalStore(e.subscribe,e.get,e.get)}function Xa({store:e,children:n}){const i=px(e);return f.createElement(f.Fragment,null,n(i))}function ux(e){return typeof e!="string"?null:e==="published"?"source":Object.prototype.hasOwnProperty.call(sm,e)?e:null}function mx(e){if(e==="none")return{color:r("quality-none"),fontWeight:400};if(e==="placeholder")return{color:r("quality-placeholder"),fontWeight:400}}const gx={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释",tally:"小计"},Pd="\0";function fx(e,n,i){const[o,s=""]=e.split(Pd);return t.jsxs(t.Fragment,{children:[o,t.jsx(Dc,{text:n,convert:i}),s]})}function Ft(e){return typeof e!="string"?"":gx[e]??e}const hx=["〇","一","二","三","四","五","六","七","八","九"],Za=["","十","百","千"],xx=["","萬","億"];function ds(e){if(e===0)return"〇";if(e<0)return`負${ds(-e)}`;const n=[];let i=e,o=0;for(;i>0;){const s=i%1e4;s>0?n.unshift(bx(s,o>0)+xx[o]):n.length>0&&n.unshift("〇"),i=Math.floor(i/1e4),o++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function bx(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+=Za[d]:s+=hx[l]+Za[d]}return s.replace(/〇$/,"")}let ci=null,Li=null;const Xi=new Set;function yx(){return ci?Promise.resolve():Li||(Li=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});ci=i=>n(Te.normalizeVariants(i)),Xi.forEach(i=>i())}).catch(()=>{ci=e=>e,Xi.forEach(e=>e())}),Li)}const jx=e=>e;function Cn(){const[,e]=f.useState(0);return f.useEffect(()=>{if(ci)return;const n=()=>e(i=>i+1);return Xi.add(n),yx(),()=>{Xi.delete(n)}},[]),ci??jx}function Fn(e,n){return n(e).toLowerCase()}const vx=r("highlight-bg");function xi(e,n,i){if(!n)return e;const o=Fn(n,i);if(!o)return e;const s=Fn(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,j)=>{d.set(c,j),c+=x.length});const p=Array.from(o).length,m=[];let g=0,u=0,h=0;for(;g<a.length;){const x=s.indexOf(o,u),j=x===-1?void 0:d.get(x);if(x===-1){m.push(a.slice(g).join(""));break}if(j===void 0){u=x+1;continue}j>g&&m.push(a.slice(g,j).join("")),m.push(t.jsx("mark",{style:{background:vx,padding:0,color:"inherit"},children:a.slice(j,j+p).join("")},h++)),g=j+p,u=x+o.length}return t.jsx(t.Fragment,{children:m})}function ps(e,n,i,o){if(!n)return!0;const s=Fn(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"&&Fn(l,o).includes(s))}function kx(e,n,i){return n?Fn(e,i).includes(Fn(n,i)):!0}const us={类:r("section-lei"),书:r("section-shu"),序:r("section-xu"),结语:r("section-jieyu"),注释:r("section-zhushi")},wx={考证:r("section-kaozhen")};function ms(e,n,i){return e.collated.sectionType[n]??i(n)}function Bd(e){var o;const n=e.files.length,i=((o=e.children)==null?void 0:o.reduce((s,a)=>s+Bd(a),0))||0;return n+i}function Sx(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 _x={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function gs({enabled:e,expanded:n,onClick:i,style:o,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:i,style:{..._x,...o},children:s}):t.jsx("span",{style:o,children:s})}function $x({type:e}){const{convert:n,messages:i}=ae(),o=Ft(e),s=us[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:ms(i,o,n)})}function Cx({section:e,onNavigate:n,highlightQuery:i="",no:o,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=ae(),c=kt(),p=Cn(),m=k=>k?Ot(d(k),w=>i?xi(w,i,p):w,{t:l}):"",[g,u]=f.useState(!1),h=!!e.summary,x=!!e.comment,j=!!e.additional_comment,y=!!(e.content&&e.content.length>60),S=h||x||j||y;f.useEffect(()=>{i&&u(!0)},[i]);const b=!g&&y?fd(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&&u(!g),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(gs,{enabled:S,expanded:g,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:g?"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:["《",m(e.book_title),"》"]}):m(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(ds(e.n_juan))})}),(e.author_info||e.author)&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"8px"},children:m(e.author_info||e.author)})]}),!g&&b&&t.jsx("span",{style:{display:"block",fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:m(b)})]})]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:m(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:k=>{k.metaKey||k.ctrlKey||(k.preventDefault(),k.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")})]}),g&&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:m(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:m(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:m(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:m(e.additional_comment)})]}),y&&!h&&!x&&!j&&t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:m(e.content)})]})]})}function zx({section:e,highlightQuery:n=""}){const{t:i,convert:o}=ae(),s=Cn(),a=p=>p?Ot(o(p),m=>n?xi(m,n,s):m,{t:i}):"",[l,d]=f.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(gs,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx($x,{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, ${us[Ft(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 Nx=100;function fs(e){return Ft(e.type)!=="page_header"?!1:(e.content||"").length>=Nx}function Tx({section:e,highlightQuery:n=""}){const{t:i,convert:o,messages:s}=ae(),a=Cn();if(Ft(e.type)==="page_header"&&!fs(e)||!e.content&&!e.title)return null;const l=o((e.content||e.title||"").replace(/\n{2,}/g,`
|
|
1393
|
-
`)),d=Ot(l,g=>n?xi(g,n,a):g,{t:i}),c=Ft(e.type),p=us[c]||r("desc-fg"),m=c==="序"||c==="结语"||c==="注释";return t.jsxs("div",{style:{padding:m?"10px 12px":"6px 0",margin:m?"8px 0":void 0,fontSize:"13px",color:r("desc-fg"),lineHeight:1.8,whiteSpace:"pre-line",borderLeft:m?`3px solid ${p}40`:void 0,background:m?r("bg"):void 0,borderRadius:m?"0 4px 4px 0":void 0,position:"relative"},children:[m&&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:ms(s,c,o)}),d]})}function Ex(e,n,i){const[o,s]=f.useState({});return f.useEffect(()=>{var p;if(!n||e.length===0)return;let a=!1;const l=e.filter(m=>{var g;return!((g=i==null?void 0:i.current)!=null&&g.has(m))}),d={};for(const m of e)(p=i==null?void 0:i.current)!=null&&p.has(m)&&(d[m]=i.current.get(m));if(Object.keys(d).length>0&&s(d),l.length===0)return;const c=async m=>{var g;try{if(n.getEntry){const y=await n.getEntry(m);if(y)return{title:y.title,author:y.author}}const u=await n.getItem(m);if(!u)return null;const h=u.title||m,x=u.authors,j=(g=x==null?void 0:x[0])==null?void 0:g.name;return{title:h,author:j}}catch{return null}};return Promise.all(l.map(async m=>{var u;const g=await c(m);return(u=i==null?void 0:i.current)==null||u.set(m,g),[m,g]})).then(m=>{a||s(g=>{const u={...g};for(const[h,x]of m)u[h]=x;return u})}),()=>{a=!0}},[e.join(","),n]),o}function Rx({section:e,onNavigate:n,transport:i,workLabelCache:o,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=ae(),c=kt(),p=Cn(),m=w=>w?Ot(l(w),v=>s?xi(v,s,p):v,{t:a}):"",[g,u]=f.useState(!1);f.useEffect(()=>{s&&u(!0)},[s]);const h=Ft(e.type),x=wx[h]||r("desc-fg"),j=!!e.content,y=e.work_ids||[],S=y.length>1,b=Ex(S?y:[],i,o),k=j&&!g&&e.content.length>80?fd(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${r("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>j&&u(!g),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:j?"pointer":"default",userSelect:"none"},children:[t.jsxs(gs,{enabled:j,expanded:g,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[j&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:g?"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?m(e.header_line):m(e.title)}),!g&&k&&t.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:r("desc-fg"),lineHeight:1.7},children:m(k)})]})]}),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:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),w.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:ms(d,h,l)})]})]}),S&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:y.map(w=>{const v=b[w],$=v?`${l(v.title)}${v.author?`(${l(v.author)})`:""}`:w.slice(0,8)+"…";return t.jsxs("a",{href:c(w),onClick:_=>{_.metaKey||_.ctrlKey||(_.preventDefault(),_.stopPropagation(),n(w))},style:{fontSize:"12px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:w,children:["→",$]},w)})}),g&&j&&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:m(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:m(e.comment)})]})]})}function Ix({juan:e,searchQuery:n,onNavigate:i,transport:o,workLabelCache:s}){const{t:a}=ae(),l=Cn(),d=n.trim(),c=f.useMemo(()=>d?e.sections.filter(p=>ps(p,d,!0,l)):e.sections,[e.sections,d,l]);return t.jsxs("div",{children:[t.jsx("div",{children:c.map((p,m)=>t.jsx(Rx,{section:p,onNavigate:i,transport:o,workLabelCache:s,highlightQuery:d},m))}),c.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:a("collated.noMatch")})]})}function Lx(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function Ax({sections:e,onNavigate:n,inline:i,workLinks:o=!0}){const s=kt(),{t:a,convert:l}=ae(),d=Lx();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const m=Ft(c.type);if(m==="page_header"&&!fs(c))return null;if(m==="类")return t.jsxs(f.Fragment,{children:[f.createElement(d("类"),null,i(l(c.title))),c.content&&t.jsx("p",{children:i(l(c.content))})]},p);if(m==="书"||m==="诗"||m==="考证"||m==="注释"){const g=c.book_title?`《${c.book_title}》${c.n_juan!=null?a("collated.nJuan",{n:ds(c.n_juan)}):""}`:c.title,u=i(l(g));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[f.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:h=>{h.metaKey||h.ctrlKey||(h.preventDefault(),n(c.work_id))},title:a("collated.viewWork"),children:u}),t.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:h=>{h.metaKey||h.ctrlKey||(h.preventDefault(),n(c.work_id))},"aria-label":a("collated.viewWorkOf",{title:l(g)}),children:a("collated.workArrow")})]}):u),c.author_info&&t.jsx("p",{className:"bim-rd-sub",children:i(l(c.author_info))}),c.content&&c.content.split(/\n+/).map((h,x)=>t.jsx("p",{children:i(l(h))},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 m==="小计"&&c.title?t.jsx("p",{children:i(l(c.title))},p):c.content?t.jsx("p",{children:i(l(c.content))},p):null})})}function Od(e){return e.some(n=>{const i=Ft(n.type);return i==="书"||i==="诗"||i==="考证"||i==="注释"||i==="类"||(i==="序"||i==="结语")&&!!n.content||i==="page_header"&&fs(n)})}function Mx({juan:e,rawText:n,positionLabel:i,groupLabel:o,index:s,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c,prefs:p,view:m,onViewChange:g}){var H;const{t:u,convert:h,messages:x}=ae(),j=Cn(),[y,S]=f.useState("text"),b=m??y,k=oe=>{S(oe),g==null||g(oe)},w=a.trim(),v=(s==null?void 0:s.type)==="kaozhen",$=f.useCallback(oe=>w?xi(oe,w,j):oe,[w,j]),_=as(p),C=oe=>gr(oe,{renderText:$,bookMarking:_,quoteStyle:p.quoteStyle,t:u}),I=f.useMemo(()=>w?e.sections.filter(oe=>ps(oe,w,v,j)):e.sections,[e.sections,w,v,j]),E=(oe,be)=>be.filter(ze=>Ft(ze.type)===oe).length,T=E("书",e.sections),N=E("诗",e.sections),P=E("考证",e.sections);let W="";v?W=w?u("collated.countTiaoOf",{m:E("考证",I),n:P}):u("collated.countTiao",{n:P}):N>0?W=w?u("collated.countPoemsOf",{m:E("诗",I),n:N}):u("collated.countPoems",{n:N}):T>0&&(W=w?u("collated.countBooksOf",{m:E("书",I),n:T}):u("collated.countBooks",{n:T}));const L=s!=null&&s.text_quality?ux(s.text_quality.grade):null,K=[];if(W&&K.push(W),v&&(s!=null&&s.target_source)&&K.push(t.jsx(t.Fragment,{children:u("collated.kaozhenTarget",{target:h(s.target_source)})})),L){const oe=t.jsx("span",{className:"bim-rd-grade",style:mx(L),children:x.collated.qualityLabel[L]});K.push(t.jsx("span",{title:x.collated.qualityCriteria[L],children:(H=s==null?void 0:s.text_quality)!=null&&H.source_note?t.jsxs(t.Fragment,{children:[fx(u("collated.baseText",{note:Pd}),s.text_quality.source_note,h),oe]}):t.jsxs(t.Fragment,{children:[u("collated.textQuality"),oe]})}))}e.source_url&&K.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:u("collated.originalSource")}));const Q=!v&&Od(e.sections),Z=!!n&&(!Q||p.readingMode==="paragraph"&&qi(n)),ue=!v&&(Q||!!n),J=v||!ue?"entries":b;let le=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&&h(o)]}),t.jsx("h1",{className:"bim-rd-h1",children:h(e.title)}),K.length>0&&t.jsx("p",{className:"bim-rd-meta",children:K.map((oe,be)=>t.jsxs(f.Fragment,{children:[be>0&&t.jsx("span",{className:"bim-rd-dot"}),oe]},be))}),ue&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":u("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":J==="text",onClick:()=>k("text"),children:u("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":J==="entries",onClick:()=>k("entries"),children:u("collated.viewEntries")})]})]}),J==="text"&&t.jsx("article",{className:"bim-rd-prose",children:Z?t.jsx(ls,{text:n,mode:p.readingMode,bookMarking:_,quoteStyle:p.quoteStyle,renderText:$,dropTitle:e.title}):t.jsx(Ax,{sections:e.sections,onNavigate:l,inline:C,workLinks:p.workLinks})}),J==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:v?t.jsx(Ix,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[I.some(oe=>["书","诗","考证"].includes(Ft(oe.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:u("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:u("collated.rowHeadTitle")}),t.jsx("span",{children:u("collated.rowHeadWork")})]}),I.map((oe,be)=>{const ze=Ft(oe.type);return ze==="书"||ze==="诗"||ze==="考证"?(le+=1,t.jsx(Cx,{domId:`rd-e-${e.sections.indexOf(oe)}`,section:oe,onNavigate:p.workLinks?l:void 0,highlightQuery:w,no:le,showUnlinked:p.workLinks&&!!l},be)):ze==="类"?t.jsx(zx,{section:oe,highlightQuery:w},be):t.jsx(Tx,{section:oe,highlightQuery:w},be)}),I.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:u("collated.noMatch")})]})})]})}function Px(e){const{resetKey:n,load:i,files:o,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=Cn(),m=f.useRef(new Map),[g,u]=f.useState({}),[h,x]=f.useState({}),j=f.useCallback((S,b)=>{const k=b==null?void 0:b.title;k&&x(w=>w[S]===k?w:{...w,[S]:k})},[]);f.useEffect(()=>{s&&a&&(m.current.set(s,{juan:a,rawText:l}),j(s,a))},[s,a,l,j]),f.useEffect(()=>{m.current.clear(),u({}),x({})},[n]);const y=f.useCallback((S,b)=>{let k=0;if(S.juan)for(const w of S.juan.sections)ps(w,b,c,p)&&k++;return k===0&&S.rawText&&kx(S.rawText,b,p)&&(k=1),k},[c,p]);return f.useEffect(()=>{const S=d.trim();if(!S){u({});return}if(!i||o.length===0)return;let b=!1;const k={},w=[];for(const I of o){const E=m.current.get(I);E?k[I]=y(E,S):(k[I]="loading",w.push(I))}u(k);const v=8;let $=0;const _=async()=>{for(;$<w.length;){if(b)return;const I=$++,E=w[I];try{const T=await i(E),N=T.juan;if(m.current.set(E,T),j(E,N),b)return;u(P=>({...P,[E]:y(T,S)}))}catch{if(b)return;u(T=>({...T,[E]:0}))}}},C=Array.from({length:Math.min(v,w.length)},()=>_());return Promise.all(C),()=>{b=!0}},[d,n,i,o.join(","),y,p,j]),{matchStates:g,titles:h}}function Bx({juan:e,view:n,onView:i,textHasEntries:o}){const{t:s,convert:a}=ae(),l=e.sections.map((m,g)=>({s:m,i:g,t:Ft(m.type)})).filter(m=>m.t==="书"||m.t==="诗");if(l.length===0)return null;const d=l.filter(m=>!!m.s.work_id).length,c=l.every(m=>m.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),p=m=>{const g=()=>{var u,h;return(h=(u=document.getElementById(`rd-e-${m}`))==null?void 0:u.scrollIntoView)==null?void 0:h.call(u,{block:"start",behavior:"smooth"})};n==="text"&&!o&&i("entries"),n==="text"&&!o?setTimeout(g,0):g()};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:m,i:g})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${g}`,onClick:u=>{u.preventDefault(),p(g)},children:[t.jsx("span",{className:`bim-rd-rail-dot${m.work_id?" on":""}`,"aria-hidden":"true"}),t.jsx("span",{children:gr(a(m.book_title||m.title),{t:s})})]})},g))})]})]})}const Ox=`
|
|
1392
|
+
${n??""}`,[a,l]=h.useState({tag:"",images:null}),d=h.useRef(0);h.useEffect(()=>{const p=++d.current,m=u=>{p===d.current&&l({tag:s,images:u})};if(!e||!n){m(null);return}let g;try{g=e(n,i)}catch{m(null);return}if(!g||typeof g.then!="function"){m(g??null);return}g.then(u=>m(u??null),()=>m(null))},[e,n,i,s]);const c=a.tag===s;return{images:c?a.images:null,loading:!!e&&!!n&&!c}}function hx(){let e=null;const n=new Set;return{get:()=>e,set:i=>{i!==e&&(e=i,n.forEach(o=>o()))},subscribe:i=>(n.add(i),()=>{n.delete(i)})}}function fx(e){return h.useSyncExternalStore(e.subscribe,e.get,e.get)}function rl({store:e,children:n}){const i=fx(e);return h.createElement(h.Fragment,null,n(i))}function xx(e){return typeof e!="string"?null:e==="published"?"source":Object.prototype.hasOwnProperty.call(pm,e)?e:null}function bx(e){if(e==="none")return{color:r("quality-none"),fontWeight:400};if(e==="placeholder")return{color:r("quality-placeholder"),fontWeight:400}}const yx={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释",tally:"小计"},Vd="\0";function jx(e,n,i){const[o,s=""]=e.split(Vd);return t.jsxs(t.Fragment,{children:[o,t.jsx(Zc,{text:n,convert:i}),s]})}function Ft(e){return typeof e!="string"?"":yx[e]??e}const vx=["〇","一","二","三","四","五","六","七","八","九"],ol=["","十","百","千"],kx=["","萬","億"];function hs(e){if(e===0)return"〇";if(e<0)return`負${hs(-e)}`;const n=[];let i=e,o=0;for(;i>0;){const s=i%1e4;s>0?n.unshift(wx(s,o>0)+kx[o]):n.length>0&&n.unshift("〇"),i=Math.floor(i/1e4),o++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function wx(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+=ol[d]:s+=vx[l]+ol[d]}return s.replace(/〇$/,"")}let ui=null,Ai=null;const Qi=new Set;function Sx(){return ui?Promise.resolve():Ai||(Ai=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});ui=i=>n(xe.normalizeVariants(i)),Qi.forEach(i=>i())}).catch(()=>{ui=e=>e,Qi.forEach(e=>e())}),Ai)}const $x=e=>e;function Cn(){const[,e]=h.useState(0);return h.useEffect(()=>{if(ui)return;const n=()=>e(i=>i+1);return Qi.add(n),Sx(),()=>{Qi.delete(n)}},[]),ui??$x}function Hn(e,n){return n(e).toLowerCase()}const _x=r("highlight-bg");function ji(e,n,i){if(!n)return e;const o=Hn(n,i);if(!o)return e;const s=Hn(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,j)=>{d.set(c,j),c+=x.length});const p=Array.from(o).length,m=[];let g=0,u=0,f=0;for(;g<a.length;){const x=s.indexOf(o,u),j=x===-1?void 0:d.get(x);if(x===-1){m.push(a.slice(g).join(""));break}if(j===void 0){u=x+1;continue}j>g&&m.push(a.slice(g,j).join("")),m.push(t.jsx("mark",{style:{background:_x,padding:0,color:"inherit"},children:a.slice(j,j+p).join("")},f++)),g=j+p,u=x+o.length}return t.jsx(t.Fragment,{children:m})}function fs(e,n,i,o){if(!n)return!0;const s=Hn(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"&&Hn(l,o).includes(s))}function Cx(e,n,i){return n?Hn(e,i).includes(Hn(n,i)):!0}const xs={类:r("section-lei"),书:r("section-shu"),序:r("section-xu"),结语:r("section-jieyu"),注释:r("section-zhushi")},zx={考证:r("section-kaozhen")};function bs(e,n,i){return e.collated.sectionType[n]??i(n)}function Gd(e){var o;const n=e.files.length,i=((o=e.children)==null?void 0:o.reduce((s,a)=>s+Gd(a),0))||0;return n+i}function Nx(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 Tx={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function ys({enabled:e,expanded:n,onClick:i,style:o,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:i,style:{...Tx,...o},children:s}):t.jsx("span",{style:o,children:s})}function Rx({type:e}){const{convert:n,messages:i}=oe(),o=Ft(e),s=xs[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:bs(i,o,n)})}function Ex({section:e,onNavigate:n,highlightQuery:i="",no:o,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=oe(),c=kt(),p=Cn(),m=v=>v?Bt(d(v),w=>i?ji(w,i,p):w,{t:l}):"",[g,u]=h.useState(!1),f=!!e.summary,x=!!e.comment,j=!!e.additional_comment,y=!!(e.content&&e.content.length>60),S=f||x||j||y;h.useEffect(()=>{i&&u(!0)},[i]);const b=!g&&y?wd(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&&u(!g),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(ys,{enabled:S,expanded:g,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:g?"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:["《",m(e.book_title),"》"]}):m(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(hs(e.n_juan))})}),(e.author_info||e.author)&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"8px"},children:m(e.author_info||e.author)})]}),!g&&b&&t.jsx("span",{style:{display:"block",fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:m(b)})]})]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:m(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:v=>{v.metaKey||v.ctrlKey||(v.preventDefault(),v.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")})]}),g&&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:m(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:m(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:m(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:m(e.additional_comment)})]}),y&&!f&&!x&&!j&&t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:m(e.content)})]})]})}function Ix({section:e,highlightQuery:n=""}){const{t:i,convert:o}=oe(),s=Cn(),a=p=>p?Bt(o(p),m=>n?ji(m,n,s):m,{t:i}):"",[l,d]=h.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(ys,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(Rx,{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, ${xs[Ft(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 Lx=100;function js(e){return Ft(e.type)!=="page_header"?!1:(e.content||"").length>=Lx}function Mx({section:e,highlightQuery:n=""}){const{t:i,convert:o,messages:s}=oe(),a=Cn();if(Ft(e.type)==="page_header"&&!js(e)||!e.content&&!e.title)return null;const l=o((e.content||e.title||"").replace(/\n{2,}/g,`
|
|
1393
|
+
`)),d=Bt(l,g=>n?ji(g,n,a):g,{t:i}),c=Ft(e.type),p=xs[c]||r("desc-fg"),m=c==="序"||c==="结语"||c==="注释";return t.jsxs("div",{style:{padding:m?"10px 12px":"6px 0",margin:m?"8px 0":void 0,fontSize:"13px",color:r("desc-fg"),lineHeight:1.8,whiteSpace:"pre-line",borderLeft:m?`3px solid ${p}40`:void 0,background:m?r("bg"):void 0,borderRadius:m?"0 4px 4px 0":void 0,position:"relative"},children:[m&&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:bs(s,c,o)}),d]})}function Ax(e,n,i){const[o,s]=h.useState({});return h.useEffect(()=>{var p;if(!n||e.length===0)return;let a=!1;const l=e.filter(m=>{var g;return!((g=i==null?void 0:i.current)!=null&&g.has(m))}),d={};for(const m of e)(p=i==null?void 0:i.current)!=null&&p.has(m)&&(d[m]=i.current.get(m));if(Object.keys(d).length>0&&s(d),l.length===0)return;const c=async m=>{var g;try{if(n.getEntry){const y=await n.getEntry(m);if(y)return{title:y.title,author:y.author}}const u=await n.getItem(m);if(!u)return null;const f=u.title||m,x=u.authors,j=(g=x==null?void 0:x[0])==null?void 0:g.name;return{title:f,author:j}}catch{return null}};return Promise.all(l.map(async m=>{var u;const g=await c(m);return(u=i==null?void 0:i.current)==null||u.set(m,g),[m,g]})).then(m=>{a||s(g=>{const u={...g};for(const[f,x]of m)u[f]=x;return u})}),()=>{a=!0}},[e.join(","),n]),o}function Px({section:e,onNavigate:n,transport:i,workLabelCache:o,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=oe(),c=kt(),p=Cn(),m=w=>w?Bt(l(w),k=>s?ji(k,s,p):k,{t:a}):"",[g,u]=h.useState(!1);h.useEffect(()=>{s&&u(!0)},[s]);const f=Ft(e.type),x=zx[f]||r("desc-fg"),j=!!e.content,y=e.work_ids||[],S=y.length>1,b=Ax(S?y:[],i,o),v=j&&!g&&e.content.length>80?wd(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${r("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>j&&u(!g),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:j?"pointer":"default",userSelect:"none"},children:[t.jsxs(ys,{enabled:j,expanded:g,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[j&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:g?"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?m(e.header_line):m(e.title)}),!g&&v&&t.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:r("desc-fg"),lineHeight:1.7},children:m(v)})]})]}),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:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),w.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:bs(d,f,l)})]})]}),S&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:y.map(w=>{const k=b[w],_=k?`${l(k.title)}${k.author?`(${l(k.author)})`:""}`:w.slice(0,8)+"…";return t.jsxs("a",{href:c(w),onClick:$=>{$.metaKey||$.ctrlKey||($.preventDefault(),$.stopPropagation(),n(w))},style:{fontSize:"12px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:w,children:["→",_]},w)})}),g&&j&&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:m(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:m(e.comment)})]})]})}function Bx({juan:e,searchQuery:n,onNavigate:i,transport:o,workLabelCache:s}){const{t:a}=oe(),l=Cn(),d=n.trim(),c=h.useMemo(()=>d?e.sections.filter(p=>fs(p,d,!0,l)):e.sections,[e.sections,d,l]);return t.jsxs("div",{children:[t.jsx("div",{children:c.map((p,m)=>t.jsx(Px,{section:p,onNavigate:i,transport:o,workLabelCache:s,highlightQuery:d},m))}),c.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:a("collated.noMatch")})]})}function Ox(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function Wx({sections:e,onNavigate:n,inline:i,workLinks:o=!0}){const s=kt(),{t:a,convert:l}=oe(),d=Ox();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const m=Ft(c.type);if(m==="page_header"&&!js(c))return null;if(m==="类")return t.jsxs(h.Fragment,{children:[h.createElement(d("类"),null,i(l(c.title))),c.content&&t.jsx("p",{children:i(l(c.content))})]},p);if(m==="书"||m==="诗"||m==="考证"||m==="注释"){const g=c.book_title?`《${c.book_title}》${c.n_juan!=null?a("collated.nJuan",{n:hs(c.n_juan)}):""}`:c.title,u=i(l(g));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[h.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:u}),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(g)}),children:a("collated.workArrow")})]}):u),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 m==="小计"&&c.title?t.jsx("p",{children:i(l(c.title))},p):c.content?t.jsx("p",{children:i(l(c.content))},p):null})})}function Yd(e){return e.some(n=>{const i=Ft(n.type);return i==="书"||i==="诗"||i==="考证"||i==="注释"||i==="类"||(i==="序"||i==="结语")&&!!n.content||i==="page_header"&&js(n)})}function Fx({juan:e,rawText:n,positionLabel:i,groupLabel:o,index:s,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c,prefs:p,view:m,onViewChange:g}){var U;const{t:u,convert:f,messages:x}=oe(),j=Cn(),[y,S]=h.useState("text"),b=m??y,v=se=>{S(se),g==null||g(se)},w=a.trim(),k=(s==null?void 0:s.type)==="kaozhen",_=h.useCallback(se=>w?ji(se,w,j):se,[w,j]),$=us(p),C=se=>xr(se,{renderText:_,bookMarking:$,quoteStyle:p.quoteStyle,t:u}),L=h.useMemo(()=>w?e.sections.filter(se=>fs(se,w,k,j)):e.sections,[e.sections,w,k,j]),E=(se,pe)=>pe.filter(_e=>Ft(_e.type)===se).length,T=E("书",e.sections),N=E("诗",e.sections),W=E("考证",e.sections);let F="";k?F=w?u("collated.countTiaoOf",{m:E("考证",L),n:W}):u("collated.countTiao",{n:W}):N>0?F=w?u("collated.countPoemsOf",{m:E("诗",L),n:N}):u("collated.countPoems",{n:N}):T>0&&(F=w?u("collated.countBooksOf",{m:E("书",L),n:T}):u("collated.countBooks",{n:T}));const R=s!=null&&s.text_quality?xx(s.text_quality.grade):null,G=[];if(F&&G.push(F),k&&(s!=null&&s.target_source)&&G.push(t.jsx(t.Fragment,{children:u("collated.kaozhenTarget",{target:f(s.target_source)})})),R){const se=t.jsx("span",{className:"bim-rd-grade",style:bx(R),children:x.collated.qualityLabel[R]});G.push(t.jsx("span",{title:x.collated.qualityCriteria[R],children:(U=s==null?void 0:s.text_quality)!=null&&U.source_note?t.jsxs(t.Fragment,{children:[jx(u("collated.baseText",{note:Vd}),s.text_quality.source_note,f),se]}):t.jsxs(t.Fragment,{children:[u("collated.textQuality"),se]})}))}e.source_url&&G.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:u("collated.originalSource")}));const Q=!k&&Yd(e.sections),ie=!!n&&(!Q||p.readingMode==="paragraph"&&Ji(n)),de=!k&&(Q||!!n),q=k||!de?"entries":b;let ee=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)}),G.length>0&&t.jsx("p",{className:"bim-rd-meta",children:G.map((se,pe)=>t.jsxs(h.Fragment,{children:[pe>0&&t.jsx("span",{className:"bim-rd-dot"}),se]},pe))}),de&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":u("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":q==="text",onClick:()=>v("text"),children:u("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":q==="entries",onClick:()=>v("entries"),children:u("collated.viewEntries")})]})]}),q==="text"&&t.jsx("article",{className:"bim-rd-prose",children:ie?t.jsx(ms,{text:n,mode:p.readingMode,bookMarking:$,quoteStyle:p.quoteStyle,renderText:_,dropTitle:e.title}):t.jsx(Wx,{sections:e.sections,onNavigate:l,inline:C,workLinks:p.workLinks})}),q==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:k?t.jsx(Bx,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[L.some(se=>["书","诗","考证"].includes(Ft(se.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:u("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:u("collated.rowHeadTitle")}),t.jsx("span",{children:u("collated.rowHeadWork")})]}),L.map((se,pe)=>{const _e=Ft(se.type);return _e==="书"||_e==="诗"||_e==="考证"?(ee+=1,t.jsx(Ex,{domId:`rd-e-${e.sections.indexOf(se)}`,section:se,onNavigate:p.workLinks?l:void 0,highlightQuery:w,no:ee,showUnlinked:p.workLinks&&!!l},pe)):_e==="类"?t.jsx(Ix,{section:se,highlightQuery:w},pe):t.jsx(Mx,{section:se,highlightQuery:w},pe)}),L.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:u("collated.noMatch")})]})})]})}function Hx(e){const{resetKey:n,load:i,files:o,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=Cn(),m=h.useRef(new Map),[g,u]=h.useState({}),[f,x]=h.useState({}),j=h.useCallback((S,b)=>{const v=b==null?void 0:b.title;v&&x(w=>w[S]===v?w:{...w,[S]:v})},[]);h.useEffect(()=>{s&&a&&(m.current.set(s,{juan:a,rawText:l}),j(s,a))},[s,a,l,j]),h.useEffect(()=>{m.current.clear(),u({}),x({})},[n]);const y=h.useCallback((S,b)=>{let v=0;if(S.juan)for(const w of S.juan.sections)fs(w,b,c,p)&&v++;return v===0&&S.rawText&&Cx(S.rawText,b,p)&&(v=1),v},[c,p]);return h.useEffect(()=>{const S=d.trim();if(!S){u({});return}if(!i||o.length===0)return;let b=!1;const v={},w=[];for(const L of o){const E=m.current.get(L);E?v[L]=y(E,S):(v[L]="loading",w.push(L))}u(v);const k=8;let _=0;const $=async()=>{for(;_<w.length;){if(b)return;const L=_++,E=w[L];try{const T=await i(E),N=T.juan;if(m.current.set(E,T),j(E,N),b)return;u(W=>({...W,[E]:y(T,S)}))}catch{if(b)return;u(T=>({...T,[E]:0}))}}},C=Array.from({length:Math.min(k,w.length)},()=>$());return Promise.all(C),()=>{b=!0}},[d,n,i,o.join(","),y,p,j]),{matchStates:g,titles:f}}function Dx({juan:e,view:n,onView:i,textHasEntries:o}){const{t:s,convert:a}=oe(),l=e.sections.map((m,g)=>({s:m,i:g,t:Ft(m.type)})).filter(m=>m.t==="书"||m.t==="诗");if(l.length===0)return null;const d=l.filter(m=>!!m.s.work_id).length,c=l.every(m=>m.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),p=m=>{const g=()=>{var u,f;return(f=(u=document.getElementById(`rd-e-${m}`))==null?void 0:u.scrollIntoView)==null?void 0:f.call(u,{block:"start",behavior:"smooth"})};n==="text"&&!o&&i("entries"),n==="text"&&!o?setTimeout(g,0):g()};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:m,i:g})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${g}`,onClick:u=>{u.preventDefault(),p(g)},children:[t.jsx("span",{className:`bim-rd-rail-dot${m.work_id?" on":""}`,"aria-hidden":"true"}),t.jsx("span",{children:xr(a(m.book_title||m.title),{t:s})})]})},g))})]})]})}const Ux=`
|
|
1394
1394
|
attribute vec2 a_position; // 目标画布像素坐标 [0, canvasWidth] x [0, canvasHeight]
|
|
1395
1395
|
attribute vec2 a_texCoord; // 原图像素坐标 [0, imgWidth] x [0, imgHeight]
|
|
1396
1396
|
|
|
@@ -1408,7 +1408,7 @@ ${n??""}`,[a,l]=f.useState({tag:"",images:null}),d=f.useRef(0);f.useEffect(()=>{
|
|
|
1408
1408
|
// 纹理坐标归一化 [0, 1]
|
|
1409
1409
|
v_texCoord = a_texCoord / u_imgResolution;
|
|
1410
1410
|
}
|
|
1411
|
-
`,
|
|
1411
|
+
`,Vx=`
|
|
1412
1412
|
precision mediump float;
|
|
1413
1413
|
uniform sampler2D u_image;
|
|
1414
1414
|
uniform float u_alpha;
|
|
@@ -1418,7 +1418,7 @@ ${n??""}`,[a,l]=f.useState({tag:"",images:null}),d=f.useRef(0);f.useEffect(()=>{
|
|
|
1418
1418
|
vec4 tex = texture2D(u_image, v_texCoord);
|
|
1419
1419
|
gl_FragColor = vec4(tex.rgb, tex.a * u_alpha);
|
|
1420
1420
|
}
|
|
1421
|
-
`;function Ja(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 ho{constructor(n){const i=n.getContext("webgl",{alpha:!0,antialias:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1});if(!i)throw new Error("WebGL not supported");this.gl=i;const o=Ja(i,i.VERTEX_SHADER,Ox),s=Ja(i,i.FRAGMENT_SHADER,Wx);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,o.drawingBufferWidth,o.drawingBufferHeight),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,c.drawingBufferWidth,c.drawingBufferHeight),c.useProgram(this.program),c.uniform2f(this.uResolutionLoc,i,o),c.uniform2f(this.uImgResolutionLoc,s,a),c.uniform1f(this.uAlphaLoc,d);const p=[],m=[],g=8;for(const u of l){const h=u.colOffsetX||0,x=u.colOffsetY||0,{srcQuad:j,dstRect:y}=u.strip,[S,b,k,w]=y,v=h+S,$=x+b,[_,C,I,E]=j;for(let T=0;T<g;T++){const N=T/g,P=(T+1)/g,W=$+w*N,L=$+w*P,K=[_[0]+(E[0]-_[0])*N,_[1]+(E[1]-_[1])*N],Q=[_[0]+(E[0]-_[0])*P,_[1]+(E[1]-_[1])*P],Z=[C[0]+(I[0]-C[0])*N,C[1]+(I[1]-C[1])*N],ue=[C[0]+(I[0]-C[0])*P,C[1]+(I[1]-C[1])*P],J=[v,W],le=[v+k,W],H=[v,L],oe=[v+k,L];p.push(J[0],J[1],le[0],le[1],H[0],H[1]),m.push(K[0],K[1],Z[0],Z[1],Q[0],Q[1]),p.push(le[0],le[1],oe[0],oe[1],H[0],H[1]),m.push(Z[0],Z[1],ue[0],ue[1],Q[0],Q[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(m),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 Fx(e){const[n,i]=e.image_size||[0,0];if(!(n>0)||!(i>0)||e.columns.some(u=>{var h;return(((h=u.strips)==null?void 0:h.length)??0)>0}))return null;let o=1/0,s=1/0,a=-1/0,l=-1/0;for(const u of e.columns)for(const h of u.chars){const[x,j,y,S]=h.bbox_col;![x,j,y,S].every(Number.isFinite)||!(y>x)||!(S>j)||(o=Math.min(o,u.offset_x+x),s=Math.min(s,j),a=Math.max(a,u.offset_x+y),l=Math.max(l,S))}for(const u of e.figBlocks??[]){const[h,x,j,y]=u.box;![h,x,j,y].every(Number.isFinite)||!(j>h)||!(y>x)||(o=Math.min(o,h),s=Math.min(s,x),a=Math.max(a,j),l=Math.max(l,y))}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)),m=Math.min(n,Math.max(0,a+d))-c,g=Math.min(i,Math.max(0,l+d))-p;return!(m>0)||!(g>0)||m>=n*.98&&g>=i*.98?null:{x:c,y:p,w:m,h:g}}const Qa=typeof window>"u"?f.useEffect:f.useLayoutEffect;function Hx(e,n){const i=Math.max(1,Math.round(e)),o=Math.max(1,Math.round(n));return`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${i}" height="${o}"/>`)}`}const Vr=[1,1.5,2,3,4,6];function Dx(e){for(const n of Vr)if(e<=n)return n;return Vr[Vr.length-1]}function Ux(e,n,i,o,s=1){if(!(e>0)||!(n>0))return[1,1];if(i===null||!(i>0))return[1,1];const a=Math.ceil(i*Math.min(Math.max(o,1),2)*Dx(s)/64)*64,l=Math.max(1,Math.min(Math.round(e),a)),d=Math.max(1,Math.round(l*n/e));return[l,d]}const cn=new Map,Vx=8;function xo(e){let n=cn.get(e);if(n)return cn.delete(e),cn.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=()=>{cn.delete(e),i(null)},o.src=e}),cn.set(e,n);cn.size>Vx;)cn.delete(cn.keys().next().value);return n}function Gx(e,n){if(!n||!(n.w>0)||!(n.h>0))return e;const[i,o]=e.image_size||[0,0];if(!(i>0)||!(o>0)||e.columns.some(l=>{var d;return(((d=l.strips)==null?void 0:d.length)??0)>0}))return e;const s=i*n.h/n.w;if(Math.abs(s/o-1)<=.01)return e;const a=s/o;return{...e,image_size:[i,s],columns:e.columns.map(l=>({...l,warped_h:l.warped_h*a,chars:l.chars.map(d=>({...d,bbox_col:[d.bbox_col[0],d.bbox_col[1]*a,d.bbox_col[2],d.bbox_col[3]*a]}))})),...e.figBlocks?{figBlocks:e.figBlocks.map(l=>({...l,box:[l.box[0],l.box[1]*a,l.box[2],l.box[3]*a]}))}:{}}}const hs=({imageUrl:e,pageData:n,selectedCharIds:i,hoveredCharId:o,preserveMargins:s=!1,onCharClick:a,onCharHover:l,selectedFigBlock:d,onFigBlockClick:c,renderScale:p=1})=>{const[m,g]=f.useState(null),u=f.useMemo(()=>Gx(n,m&&m.url===e?m:null),[n,m,e]),h=f.useRef(null),x=f.useRef(null),j=typeof ResizeObserver<"u",[y,S]=f.useState(null);Qa(()=>{const R=x.current;if(!R||typeof ResizeObserver>"u")return;const se=new ResizeObserver(de=>{var ee;const O=((ee=de[de.length-1])==null?void 0:ee.contentRect.width)??0;S(ke=>ke===O?ke:O)});return se.observe(R),()=>se.disconnect()},[]);const b=!j||y!==null&&y>0,k=f.useRef(null),w=f.useRef(null),v=f.useRef(null),$=f.useRef(null),_=f.useRef(null),[C,I]=f.useState(0),[E,T]=f.useState(0),N=f.useRef(""),P=f.useMemo(()=>Math.max(...u.columns.map(R=>R.warped_h),2440),[u]),W=u.total_warped_w,L=u.banxin,K=f.useMemo(()=>!u.columns.some(R=>{var se;return(((se=R.strips)==null?void 0:se.length)??0)>0}),[u]),Q=f.useMemo(()=>{var ve;if(!s||K)return{top:0,bottom:0,left:0,right:0};const[R,se]=u.image_size||[2386,3082];let de=1/0,O=-1/0,ee=1/0,ke=-1/0;for(const Ve of u.columns)for(const F of Ve.strips||[])for(const fe of F.srcQuad)fe[0]<de&&(de=fe[0]),fe[0]>O&&(O=fe[0]),fe[1]<ee&&(ee=fe[1]),fe[1]>ke&&(ke=fe[1]);if((ve=u.banxin)!=null&&ve.current_page_strips)for(const Ve of u.banxin.current_page_strips)for(const F of Ve.srcQuad)F[0]<de&&(de=F[0]),F[0]>O&&(O=F[0]),F[1]<ee&&(ee=F[1]),F[1]>ke&&(ke=F[1]);return isFinite(de)||(de=0),isFinite(O)||(O=R),isFinite(ee)||(ee=0),isFinite(ke)||(ke=se),{top:Math.max(0,Math.round(ee)),bottom:Math.max(0,Math.round(se-ke)),left:Math.max(0,Math.round(de)),right:Math.max(0,Math.round(R-O)),rawMinX:de,rawMaxX:O,rawMinY:ee,rawMaxY:ke,imgW:R,imgH:se}},[u,s,K]),Z=f.useMemo(()=>{if(!K)return null;const[R,se]=u.image_size||[0,0];return!(R>0)||!(se>0)?null:!s&&Fx(u)||{x:0,y:0,w:R,h:se}},[u,s,K]),ue=W+(L?L.total_w:0),J=Z?Z.w:ue+Q.left+Q.right,le=Z?Z.h:P+Q.top+Q.bottom,H=typeof window<"u"&&window.devicePixelRatio||1,[oe,be]=j?Ux(J,le,y,H,p):[Math.round(J),Math.round(le)],ze=f.useCallback(()=>{const R=k.current;if(!(!R||!h.current)&&!(e&&N.current!==e)){if(R.clear(J,le),s&&Q.rawMinX!==void 0&&$.current&&w.current){const{rawMinX:se,rawMaxX:de,rawMinY:O,rawMaxY:ee,imgW:ke,imgH:ve,top:Ve,bottom:F,left:fe,right:te}=Q,U=[];fe>0&&U.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[se,0],[se,ve],[0,ve]],dstRect:[0,0,fe,le]}}),Ve>0&&U.push({colOffsetX:fe,colOffsetY:0,strip:{srcQuad:[[se,0],[de,0],[de,O],[se,O]],dstRect:[0,0,ue,Ve]}}),F>0&&U.push({colOffsetX:fe,colOffsetY:Ve+P,strip:{srcQuad:[[se,ee],[de,ee],[de,ve],[se,ve]],dstRect:[0,0,ue,F]}}),te>0&&U.push({colOffsetX:fe+ue,colOffsetY:0,strip:{srcQuad:[[de,0],[ke,0],[ke,ve],[de,ve]],dstRect:[0,0,te,le]}}),R.renderStripsWithTexture($.current,J,le,u.image_size[0],u.image_size[1],U,1)}if($.current&&w.current){const se=u.columns.flatMap(de=>(de.strips||[]).map(O=>({colOffsetX:Q.left+de.offset_x,colOffsetY:Q.top,strip:O})));if(se.length>0?R.renderStripsWithTexture($.current,J,le,u.image_size[0],u.image_size[1],se,1):R.renderStripsWithTexture($.current,J,le,u.image_size[0],u.image_size[1],[{colOffsetX:0,colOffsetY:0,strip:{srcQuad:Z?[[Z.x,Z.y],[Z.x+Z.w,Z.y],[Z.x+Z.w,Z.y+Z.h],[Z.x,Z.y+Z.h]]:[[0,0],[u.image_size[0],0],[u.image_size[0],u.image_size[1]],[0,u.image_size[1]]],dstRect:[0,0,J,le]}}],1),L&&L.current_page_strips.length>0){const de=L.current_page_strips.map(O=>({colOffsetX:Q.left+W,colOffsetY:Q.top,strip:O}));R.renderStripsWithTexture($.current,J,le,u.image_size[0],u.image_size[1],de,1)}}if(L&&_.current&&v.current&&L.mate_page_strips.length>0){const se=L.mate_page_strips.map(de=>({colOffsetX:Q.left+W+L.half_w,colOffsetY:Q.top,strip:de}));R.renderStripsWithTexture(_.current,J,le,L.mate_img_size[0],L.mate_img_size[1],se,.65)}}},[e,u,L,J,le,W,P,ue,Q,s,Z]),Le=f.useRef(ze);Le.current=ze,f.useEffect(()=>{const R=h.current;if(!R)return;const se=ee=>{$.current=w.current?ee.createTexture(w.current):null,_.current=v.current?ee.createTexture(v.current):null,Le.current()};try{const ee=new ho(R);k.current=ee,se(ee)}catch(ee){console.error("Failed to init WebGL renderer:",ee)}const de=ee=>{ee.preventDefault(),console.warn("WebGL context lost")},O=()=>{console.info("WebGL context restored, re-initializing..."),h.current&&(k.current=new ho(h.current),se(k.current))};return R.addEventListener("webglcontextlost",de,!1),R.addEventListener("webglcontextrestored",O,!1),()=>{R.removeEventListener("webglcontextlost",de),R.removeEventListener("webglcontextrestored",O),k.current&&(k.current.deleteTexture($.current),k.current.deleteTexture(_.current),k.current.destroy(),k.current=null)}},[]),f.useEffect(()=>{if(!e||!b)return;let R=!0;return xo(e).then(se=>{if(!R||!se)return;w.current=se,N.current=e,g(O=>O&&O.url===e&&O.w===se.naturalWidth&&O.h===se.naturalHeight?O:{url:e,w:se.naturalWidth,h:se.naturalHeight});const de=k.current;de&&(de.deleteTexture($.current),$.current=de.createTexture(se)),I(O=>O+1)}),()=>{R=!1}},[e,b]);const _e=L==null?void 0:L.mate_image_url;f.useEffect(()=>{if(!_e||!b)return;let R=!0;return xo(_e).then(se=>{if(!R||!se)return;v.current=se;const de=k.current;de&&(de.deleteTexture(_.current),_.current=de.createTexture(se)),T(O=>O+1)}),()=>{R=!1}},[_e,b]),Qa(()=>{b&&ze()},[ze,C,E,oe,be,b]);const re=f.useMemo(()=>(u.figBlocks??[]).map(R=>{const[se,de,O,ee]=R.box;return{id:R.id,x:Q.left+se-((Z==null?void 0:Z.x)??0),y:Q.top+de-((Z==null?void 0:Z.y)??0),w:Math.max(O-se,1),h:Math.max(ee-de,1)}}),[u,Q,Z]),xe=f.useMemo(()=>{const R=[];for(const se of u.columns)for(const de of se.chars){const[O,ee,ke,ve]=de.bbox_col;R.push({id:de.id,char:de.char,x:Q.left+se.offset_x+O-((Z==null?void 0:Z.x)??0),y:Q.top+ee-((Z==null?void 0:Z.y)??0),w:Math.max(ke-O,1),h:Math.max(ve-ee,1)})}return R},[u,Q,Z]);return t.jsxs("div",{ref:x,className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${J} / ${le}`,backgroundColor:r("warp-bg"),boxShadow:r("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("img",{alt:"","aria-hidden":"true","data-warp-sizer":"",src:Hx(J,le),style:{display:"block",width:"100%",height:"100%",visibility:"hidden"}}),t.jsx("canvas",{ref:h,width:oe,height:be,"data-logical-size":`${Math.floor(J)}x${Math.floor(le)}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block",backgroundColor:r("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${J} ${le}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[xe.map(R=>{const se=i.has(R.id),de=o===R.id;return t.jsx("rect",{"data-selected":se?"true":void 0,x:R.x,y:R.y,width:R.w,height:R.h,fill:se?r("warp-sel-bg"):de?r("warp-hover-bg"):"transparent",stroke:se?r("warp-sel-stroke"):de?r("warp-hover-stroke"):"transparent",strokeWidth:se?3.5:de?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>a==null?void 0:a(R.id),onMouseEnter:()=>l==null?void 0:l(R.id),onMouseLeave:()=>l==null?void 0:l(null),children:t.jsx("title",{children:R.char})},R.id)}),re.map(R=>{const se=d===R.id;return t.jsx("rect",{"data-fig-block":R.id,"data-selected":se?"true":void 0,x:R.x,y:R.y,width:R.w,height:R.h,fill:se?r("warp-sel-bg"):"transparent",stroke:r(se?"warp-sel-stroke":"warp-hover-stroke"),strokeWidth:se?3.5:2,strokeDasharray:se?void 0:"10 8",style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>c==null?void 0:c(R.id),children:t.jsx("title",{children:R.id})},`fig-${R.id}`)}),L&&t.jsxs("g",{children:[t.jsx("line",{x1:Q.left+W,y1:Q.top,x2:Q.left+W,y2:Q.top+P,stroke:r("warp-banxin-border"),strokeWidth:1.5}),t.jsx("line",{x1:Q.left+W+L.half_w,y1:Q.top,x2:Q.left+W+L.half_w,y2:Q.top+P,stroke:r("warp-banxin-fold"),strokeWidth:1.5,strokeDasharray:"8 6"}),t.jsx("line",{x1:Q.left+ue,y1:Q.top,x2:Q.left+ue,y2:Q.top+P,stroke:r("warp-banxin-outer"),strokeWidth:1})]})]})]})},el={seg_page_unaligned:"整页对不上",seg_col_unaligned:"整列对不上",col_width_out_of_band:"列宽异常",seg_defect:"切坏格",occluded_with_ref:"有遮挡",occluded_no_ref:"有遮挡且参校本缺",hard_pair:"极难形近",group_abstain:"形近字·没把握",group_conflict:"形近字·判法打架",group_demoted:"形近字·复核推翻",group_ref_dissent:"形近字·与参校本不同",group_weak:"形近字·证据弱",group_form_open:"写法待定",near_form_guard:"形近字",variant_pair:"异体字",lib_missing:"少见的字",lib_sparse_dissent:"刻例太少·不一致",lib_sparse_agree:"刻例太少",lib_unrecognized:"库认不出",garble_gate:"像框线或墨点",ref_lacuna:"参校本缺字",ref_gap:"参校本这里没字",ref_replaced:"参校本改过字",ref_mismatch:"和参校本不一致",ruling_conflict:"裁定有冲突",vision_flagged:"看图觉得不对",machine_changed:"机器改了字",recheck:"复审",unknown:"原因不明"},Yx=/^[a-z][a-z0-9_]*$/;function tl(e){return el[e]??el.unknown??e}const xs=`
|
|
1421
|
+
`;function sl(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 vo{constructor(n){const i=n.getContext("webgl",{alpha:!0,antialias:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1});if(!i)throw new Error("WebGL not supported");this.gl=i;const o=sl(i,i.VERTEX_SHADER,Ux),s=sl(i,i.FRAGMENT_SHADER,Vx);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,o.drawingBufferWidth,o.drawingBufferHeight),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,c.drawingBufferWidth,c.drawingBufferHeight),c.useProgram(this.program),c.uniform2f(this.uResolutionLoc,i,o),c.uniform2f(this.uImgResolutionLoc,s,a),c.uniform1f(this.uAlphaLoc,d);const p=[],m=[],g=8;for(const u of l){const f=u.colOffsetX||0,x=u.colOffsetY||0,{srcQuad:j,dstRect:y}=u.strip,[S,b,v,w]=y,k=f+S,_=x+b,[$,C,L,E]=j;for(let T=0;T<g;T++){const N=T/g,W=(T+1)/g,F=_+w*N,R=_+w*W,G=[$[0]+(E[0]-$[0])*N,$[1]+(E[1]-$[1])*N],Q=[$[0]+(E[0]-$[0])*W,$[1]+(E[1]-$[1])*W],ie=[C[0]+(L[0]-C[0])*N,C[1]+(L[1]-C[1])*N],de=[C[0]+(L[0]-C[0])*W,C[1]+(L[1]-C[1])*W],q=[k,F],ee=[k+v,F],U=[k,R],se=[k+v,R];p.push(q[0],q[1],ee[0],ee[1],U[0],U[1]),m.push(G[0],G[1],ie[0],ie[1],Q[0],Q[1]),p.push(ee[0],ee[1],se[0],se[1],U[0],U[1]),m.push(ie[0],ie[1],de[0],de[1],Q[0],Q[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(m),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 Gx(e){const[n,i]=e.image_size||[0,0];if(!(n>0)||!(i>0)||e.columns.some(u=>{var f;return(((f=u.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 u of e.columns)for(const f of u.chars){const[x,j,y,S]=f.bbox_col;![x,j,y,S].every(Number.isFinite)||!(y>x)||!(S>j)||(o=Math.min(o,u.offset_x+x),s=Math.min(s,j),a=Math.max(a,u.offset_x+y),l=Math.max(l,S))}for(const u of e.figBlocks??[]){const[f,x,j,y]=u.box;![f,x,j,y].every(Number.isFinite)||!(j>f)||!(y>x)||(o=Math.min(o,f),s=Math.min(s,x),a=Math.max(a,j),l=Math.max(l,y))}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)),m=Math.min(n,Math.max(0,a+d))-c,g=Math.min(i,Math.max(0,l+d))-p;return!(m>0)||!(g>0)||m>=n*.98&&g>=i*.98?null:{x:c,y:p,w:m,h:g}}const al=typeof window>"u"?h.useEffect:h.useLayoutEffect;function Yx(e,n){const i=Math.max(1,Math.round(e)),o=Math.max(1,Math.round(n));return`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${i}" height="${o}"/>`)}`}const Zr=[1,1.5,2,3,4,6];function Kx(e){for(const n of Zr)if(e<=n)return n;return Zr[Zr.length-1]}function qx(e,n,i,o,s=1){if(!(e>0)||!(n>0))return[1,1];if(i===null||!(i>0))return[1,1];const a=Math.ceil(i*Math.min(Math.max(o,1),2)*Kx(s)/64)*64,l=Math.max(1,Math.min(Math.round(e),a)),d=Math.max(1,Math.round(l*n/e));return[l,d]}const Nt=new Map,ll=8;let Ui=null;function Xx(e){Ui=e}function ko(e){let n=Nt.get(e);if(n)return Nt.delete(e),Nt.set(e,n),n;const i=Ui==null?void 0:Ui(e);if(i){for(n=i.then(o=>(o||Nt.delete(e),o),()=>(Nt.delete(e),null)),Nt.set(e,n);Nt.size>ll;)Nt.delete(Nt.keys().next().value);return n}for(n=new Promise(o=>{const s=new Image;s.crossOrigin="anonymous",s.onload=()=>{(s.decode?s.decode().catch(()=>{}):Promise.resolve()).then(()=>o(s))},s.onerror=()=>{Nt.delete(e),o(null)},s.src=e}),Nt.set(e,n);Nt.size>ll;)Nt.delete(Nt.keys().next().value);return n}function Zx(e,n){if(!n||!(n.w>0)||!(n.h>0))return e;const[i,o]=e.image_size||[0,0];if(!(i>0)||!(o>0)||e.columns.some(l=>{var d;return(((d=l.strips)==null?void 0:d.length)??0)>0}))return e;const s=i*n.h/n.w;if(Math.abs(s/o-1)<=.01)return e;const a=s/o;return{...e,image_size:[i,s],columns:e.columns.map(l=>({...l,warped_h:l.warped_h*a,chars:l.chars.map(d=>({...d,bbox_col:[d.bbox_col[0],d.bbox_col[1]*a,d.bbox_col[2],d.bbox_col[3]*a]}))})),...e.figBlocks?{figBlocks:e.figBlocks.map(l=>({...l,box:[l.box[0],l.box[1]*a,l.box[2],l.box[3]*a]}))}:{}}}const vs=({imageUrl:e,pageData:n,selectedCharIds:i,hoveredCharId:o,preserveMargins:s=!1,onCharClick:a,onCharHover:l,selectedFigBlock:d,onFigBlockClick:c,renderScale:p=1})=>{const[m,g]=h.useState(null),u=h.useMemo(()=>Zx(n,m&&m.url===e?m:null),[n,m,e]),f=h.useRef(null),x=h.useRef(null),j=typeof ResizeObserver<"u",[y,S]=h.useState(null);al(()=>{const A=x.current;if(!A||typeof ResizeObserver>"u")return;const K=new ResizeObserver(le=>{var J;const M=((J=le[le.length-1])==null?void 0:J.contentRect.width)??0;S(ye=>ye===M?ye:M)});return K.observe(A),()=>K.disconnect()},[]);const b=!j||y!==null&&y>0,v=h.useRef(null),w=h.useRef(null),k=h.useRef(null),_=h.useRef(null),$=h.useRef(null),[C,L]=h.useState(0),[E,T]=h.useState(0),N=h.useRef(""),W=h.useMemo(()=>Math.max(...u.columns.map(A=>A.warped_h),2440),[u]),F=u.total_warped_w,R=u.banxin,G=h.useMemo(()=>!u.columns.some(A=>{var K;return(((K=A.strips)==null?void 0:K.length)??0)>0}),[u]),Q=h.useMemo(()=>{var je;if(!s||G)return{top:0,bottom:0,left:0,right:0};const[A,K]=u.image_size||[2386,3082];let le=1/0,M=-1/0,J=1/0,ye=-1/0;for(const Ue of u.columns)for(const H of Ue.strips||[])for(const me of H.srcQuad)me[0]<le&&(le=me[0]),me[0]>M&&(M=me[0]),me[1]<J&&(J=me[1]),me[1]>ye&&(ye=me[1]);if((je=u.banxin)!=null&&je.current_page_strips)for(const Ue of u.banxin.current_page_strips)for(const H of Ue.srcQuad)H[0]<le&&(le=H[0]),H[0]>M&&(M=H[0]),H[1]<J&&(J=H[1]),H[1]>ye&&(ye=H[1]);return isFinite(le)||(le=0),isFinite(M)||(M=A),isFinite(J)||(J=0),isFinite(ye)||(ye=K),{top:Math.max(0,Math.round(J)),bottom:Math.max(0,Math.round(K-ye)),left:Math.max(0,Math.round(le)),right:Math.max(0,Math.round(A-M)),rawMinX:le,rawMaxX:M,rawMinY:J,rawMaxY:ye,imgW:A,imgH:K}},[u,s,G]),ie=h.useMemo(()=>{if(!G)return null;const[A,K]=u.image_size||[0,0];return!(A>0)||!(K>0)?null:!s&&Gx(u)||{x:0,y:0,w:A,h:K}},[u,s,G]),de=F+(R?R.total_w:0),q=ie?ie.w:de+Q.left+Q.right,ee=ie?ie.h:W+Q.top+Q.bottom,U=typeof window<"u"&&window.devicePixelRatio||1,[se,pe]=j?qx(q,ee,y,U,p):[Math.round(q),Math.round(ee)],_e=h.useCallback(()=>{const A=v.current;if(!(!A||!f.current)&&!(e&&N.current!==e)){if(A.clear(q,ee),s&&Q.rawMinX!==void 0&&_.current&&w.current){const{rawMinX:K,rawMaxX:le,rawMinY:M,rawMaxY:J,imgW:ye,imgH:je,top:Ue,bottom:H,left:me,right:ge}=Q,ne=[];me>0&&ne.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[K,0],[K,je],[0,je]],dstRect:[0,0,me,ee]}}),Ue>0&&ne.push({colOffsetX:me,colOffsetY:0,strip:{srcQuad:[[K,0],[le,0],[le,M],[K,M]],dstRect:[0,0,de,Ue]}}),H>0&&ne.push({colOffsetX:me,colOffsetY:Ue+W,strip:{srcQuad:[[K,J],[le,J],[le,je],[K,je]],dstRect:[0,0,de,H]}}),ge>0&&ne.push({colOffsetX:me+de,colOffsetY:0,strip:{srcQuad:[[le,0],[ye,0],[ye,je],[le,je]],dstRect:[0,0,ge,ee]}}),A.renderStripsWithTexture(_.current,q,ee,u.image_size[0],u.image_size[1],ne,1)}if(_.current&&w.current){const K=u.columns.flatMap(le=>(le.strips||[]).map(M=>({colOffsetX:Q.left+le.offset_x,colOffsetY:Q.top,strip:M})));if(K.length>0?A.renderStripsWithTexture(_.current,q,ee,u.image_size[0],u.image_size[1],K,1):A.renderStripsWithTexture(_.current,q,ee,u.image_size[0],u.image_size[1],[{colOffsetX:0,colOffsetY:0,strip:{srcQuad:ie?[[ie.x,ie.y],[ie.x+ie.w,ie.y],[ie.x+ie.w,ie.y+ie.h],[ie.x,ie.y+ie.h]]:[[0,0],[u.image_size[0],0],[u.image_size[0],u.image_size[1]],[0,u.image_size[1]]],dstRect:[0,0,q,ee]}}],1),R&&R.current_page_strips.length>0){const le=R.current_page_strips.map(M=>({colOffsetX:Q.left+F,colOffsetY:Q.top,strip:M}));A.renderStripsWithTexture(_.current,q,ee,u.image_size[0],u.image_size[1],le,1)}}if(R&&$.current&&k.current&&R.mate_page_strips.length>0){const K=R.mate_page_strips.map(le=>({colOffsetX:Q.left+F+R.half_w,colOffsetY:Q.top,strip:le}));A.renderStripsWithTexture($.current,q,ee,R.mate_img_size[0],R.mate_img_size[1],K,.65)}}},[e,u,R,q,ee,F,W,de,Q,s,ie]),Le=h.useRef(_e);Le.current=_e,h.useEffect(()=>{const A=f.current;if(!A)return;const K=J=>{_.current=w.current?J.createTexture(w.current):null,$.current=k.current?J.createTexture(k.current):null,Le.current()};try{const J=new vo(A);v.current=J,K(J)}catch(J){console.error("Failed to init WebGL renderer:",J)}const le=J=>{J.preventDefault(),console.warn("WebGL context lost")},M=()=>{console.info("WebGL context restored, re-initializing..."),f.current&&(v.current=new vo(f.current),K(v.current))};return A.addEventListener("webglcontextlost",le,!1),A.addEventListener("webglcontextrestored",M,!1),()=>{A.removeEventListener("webglcontextlost",le),A.removeEventListener("webglcontextrestored",M),v.current&&(v.current.deleteTexture(_.current),v.current.deleteTexture($.current),v.current.destroy(),v.current=null)}},[]),h.useEffect(()=>{if(!e||!b)return;let A=!0;return ko(e).then(K=>{if(!A||!K)return;w.current=K,N.current=e,g(M=>M&&M.url===e&&M.w===K.naturalWidth&&M.h===K.naturalHeight?M:{url:e,w:K.naturalWidth,h:K.naturalHeight});const le=v.current;le&&(le.deleteTexture(_.current),_.current=le.createTexture(K)),L(M=>M+1)}),()=>{A=!1}},[e,b]);const Ee=R==null?void 0:R.mate_image_url;h.useEffect(()=>{if(!Ee||!b)return;let A=!0;return ko(Ee).then(K=>{if(!A||!K)return;k.current=K;const le=v.current;le&&(le.deleteTexture($.current),$.current=le.createTexture(K)),T(M=>M+1)}),()=>{A=!1}},[Ee,b]),al(()=>{b&&_e()},[_e,C,E,se,pe,b]);const ue=h.useMemo(()=>(u.figBlocks??[]).map(A=>{const[K,le,M,J]=A.box;return{id:A.id,x:Q.left+K-((ie==null?void 0:ie.x)??0),y:Q.top+le-((ie==null?void 0:ie.y)??0),w:Math.max(M-K,1),h:Math.max(J-le,1)}}),[u,Q,ie]),be=h.useMemo(()=>{const A=[];for(const K of u.columns)for(const le of K.chars){const[M,J,ye,je]=le.bbox_col;A.push({id:le.id,char:le.char,x:Q.left+K.offset_x+M-((ie==null?void 0:ie.x)??0),y:Q.top+J-((ie==null?void 0:ie.y)??0),w:Math.max(ye-M,1),h:Math.max(je-J,1)})}return A},[u,Q,ie]);return t.jsxs("div",{ref:x,className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${q} / ${ee}`,backgroundColor:r("warp-bg"),boxShadow:r("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("img",{alt:"","aria-hidden":"true","data-warp-sizer":"",src:Yx(q,ee),style:{display:"block",width:"100%",height:"100%",visibility:"hidden"}}),t.jsx("canvas",{ref:f,width:se,height:pe,"data-logical-size":`${Math.floor(q)}x${Math.floor(ee)}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block",backgroundColor:r("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${q} ${ee}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[be.map(A=>{const K=i.has(A.id),le=o===A.id;return t.jsx("rect",{"data-selected":K?"true":void 0,x:A.x,y:A.y,width:A.w,height:A.h,fill:K?r("warp-sel-bg"):le?r("warp-hover-bg"):"transparent",stroke:K?r("warp-sel-stroke"):le?r("warp-hover-stroke"):"transparent",strokeWidth:K?3.5:le?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>a==null?void 0:a(A.id),onMouseEnter:()=>l==null?void 0:l(A.id),onMouseLeave:()=>l==null?void 0:l(null),children:t.jsx("title",{children:A.char})},A.id)}),ue.map(A=>{const K=d===A.id;return t.jsx("rect",{"data-fig-block":A.id,"data-selected":K?"true":void 0,x:A.x,y:A.y,width:A.w,height:A.h,fill:K?r("warp-sel-bg"):"transparent",stroke:r(K?"warp-sel-stroke":"warp-hover-stroke"),strokeWidth:K?3.5:2,strokeDasharray:K?void 0:"10 8",style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>c==null?void 0:c(A.id),children:t.jsx("title",{children:A.id})},`fig-${A.id}`)}),R&&t.jsxs("g",{children:[t.jsx("line",{x1:Q.left+F,y1:Q.top,x2:Q.left+F,y2:Q.top+W,stroke:r("warp-banxin-border"),strokeWidth:1.5}),t.jsx("line",{x1:Q.left+F+R.half_w,y1:Q.top,x2:Q.left+F+R.half_w,y2:Q.top+W,stroke:r("warp-banxin-fold"),strokeWidth:1.5,strokeDasharray:"8 6"}),t.jsx("line",{x1:Q.left+de,y1:Q.top,x2:Q.left+de,y2:Q.top+W,stroke:r("warp-banxin-outer"),strokeWidth:1})]})]})]})},ks=`
|
|
1422
1422
|
.bim-et-w { position: relative; display: inline; }
|
|
1423
1423
|
.bim-et {
|
|
1424
1424
|
color: inherit; text-decoration-line: underline;
|
|
@@ -1505,23 +1505,23 @@ a.bim-et:focus-visible { outline: 2px solid ${r("accent")}; outline-offset: 2px;
|
|
|
1505
1505
|
.bim-et-card[data-sheet] { animation: bim-et-up 160ms ease-out; }
|
|
1506
1506
|
@keyframes bim-et-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
|
|
1507
1507
|
}
|
|
1508
|
-
`,Kx=120;function Et(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function qx(e,n=Kx){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 Xx(e){const n=e.dates&&typeof e.dates=="object"?e.dates:{},i=typeof n.birth=="number"?n.birth:void 0,o=typeof n.death=="number"?n.death:void 0;if(!(i===void 0&&o===void 0))return`${i??"?"}–${o??"?"}`}function Zx(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(i=>{if(!i||typeof i!="object")return"";const o=i,s=Et(o.name);return s?[Et(o.dynasty)&&`〔${Et(o.dynasty)}〕`,s,Et(o.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function Wd(e,n){const i=Et(n.type),o=Et(n.primary_name)??Et(n.title)??e,s=i==="entity"?[Et(n.dynasty),Xx(n),Et(n.native_place)].filter(Boolean).join(" · "):[Zx(n),Et(n.edition),Et(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?Et(n.description.text):Et(n.description);return{id:Et(n.id)??e,type:i,title:o,meta:s||void 0,description:qx(a)}}function Fd(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 Hd(e){return async n=>{const i=await e.getItem(n);if(i)return Wd(n,i);if(e.getEntry){const o=await e.getEntry(n);if(o)return Fd(o)}return null}}const nl=new WeakMap;function Dd(e,n,i){let o=nl.get(e);o||(o=new Map,nl.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 Ud=e=>`/item/${encodeURIComponent(e)}`,bo={work:"書名",people:"人名",place:"地名",office:"官職",dynasty:"朝代",reign:"年號",other:"專名"},bs=typeof window>"u"?f.useEffect:f.useLayoutEffect;function ys(e,n){return f.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:Hd(e)}:null,[n,e])}const Jx=e=>e,Qx=({text:e,entities:n,offsets:i="text",plainBase:o=0,transport:s,loadSummary:a,buildHref:l=Ud,onNavigate:d,renderText:c=Jx,hoverDelayMs:p=250,closeDelayMs:m,injectStyles:g=!0,className:u})=>{const h=f.useMemo(()=>{const j=i==="plain"?Ad(e,n,o):n;return Md(e,j)},[e,n,i,o]),x=ys(s,a);return t.jsxs("span",{className:u?`bim-et-root ${u}`:"bim-et-root",children:[g&&t.jsx("style",{children:xs}),h.map(j=>j.type==="text"?t.jsx(f.Fragment,{children:c(j.text)},`t${j.start}`):t.jsx(js,{span:j.span,label:j.text,hasBrackets:e[j.start-1]==="《"&&e[j.start+j.text.length]==="》",loader:x,buildHref:l,onNavigate:d,renderText:c,hoverDelayMs:p,closeDelayMs:m},`${j.span.key}@${j.start}`))]})};let dn=null;const js=({span:e,label:n,hasBrackets:i,plain:o,loader:s,buildHref:a,onNavigate:l,onCardNavigate:d=l,cardNewTab:c,renderText:p,hoverDelayMs:m,closeDelayMs:g=280})=>{const u=f.useId(),[h,x]=f.useState(!1),[j,y]=f.useState(!1),[S,b]=f.useState(!1),k=f.useRef(!1),w=f.useRef(null),v=f.useRef(null),$=`bim-et bim-et-${e.kind}${o?" bim-et-nu":""}`,_=e.kind==="work"&&!i,C=t.jsxs(t.Fragment,{children:[_&&t.jsx("span",{className:"bim-et-sr",children:"《"}),p(n),_&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),I=()=>{w.current&&(clearTimeout(w.current),w.current=null)},E=()=>{v.current&&(clearTimeout(v.current),v.current=null)},T=f.useRef(!1),N=f.useCallback(()=>{T.current=!1,I(),E(),x(!1),y(!1),b(!1),dn===N&&(dn=null)},[]);f.useEffect(()=>()=>{I(),E(),dn===N&&(dn=null)},[N]);const P=f.useCallback(()=>{dn&&dn!==N&&dn(),dn=N,x(!0)},[N]),W=f.useCallback(le=>{E(),y(!0),!h&&(I(),le<=0?P():w.current=setTimeout(P,le))},[h,P]),L=f.useCallback(()=>{I(),E(),!T.current&&(v.current=setTimeout(N,g))},[N,g]),K=f.useRef(null);f.useEffect(()=>{if(!h||!(e.targets||S))return;const le=S?"click":"pointerdown",H=oe=>{var be;(be=K.current)!=null&&be.contains(oe.target)||N()};return document.addEventListener(le,H),()=>document.removeEventListener(le,H)},[h,S,e.targets,N]);const Q=f.useCallback(()=>{I(),E(),T.current=!0,y(!0),b(!0),P()},[P]);bs(()=>{if(!h||!S)return;const le=K.current,H=le==null?void 0:le.querySelector(".bim-et-card");if(!le||!H||typeof window>"u")return;const oe=()=>{const ze=le.getClientRects(),Le=ze[ze.length-1];if(!Le)return;const _e=Le.bottom+12-H.getBoundingClientRect().top;_e>0&&window.scrollBy({top:_e,behavior:"smooth"})};if(oe(),typeof ResizeObserver>"u")return;const be=new ResizeObserver(oe);return be.observe(H),()=>be.disconnect()},[h,S]);const Z=!!e.targetId,ue=e.targetId,J={className:"bim-et-w","data-active":j?"":void 0,onPointerEnter:le=>{k.current=le.pointerType==="touch"},onPointerDown:le=>{k.current=le.pointerType==="touch"},onMouseEnter:()=>{k.current||W(m)},onMouseLeave:()=>{k.current||L()},onBlur:le=>{le.currentTarget.contains(le.relatedTarget)||N()},onKeyDown:le=>{le.key==="Escape"&&h&&(le.stopPropagation(),N())}};return e.targets?t.jsxs("span",{...J,ref:K,children:[t.jsx("span",{className:`${$} bim-et-multi`,role:"button",tabIndex:0,"aria-haspopup":"true","aria-expanded":h,"aria-controls":h?u:void 0,onFocus:()=>{k.current||W(0)},onClick:()=>{k.current?Q():(E(),T.current=!0,y(!0),P())},onKeyDown:le=>{(le.key==="Enter"||le.key===" ")&&(le.preventDefault(),h?N():(T.current=!0,y(!0),P()))},children:C}),h&&t.jsx(eb,{id:u,span:e,loader:s,buildHref:a,onNavigate:c?void 0:d,newTab:c,sheet:S,onClose:N})]}):!Z||!ue?t.jsxs("span",{...J,ref:K,children:[t.jsx("span",{className:$,children:C}),h&&!k.current&&t.jsx(il,{id:u,entityId:null,span:e,loader:null,buildHref:a,onNavigate:l})]}):t.jsxs("span",{...J,ref:K,children:[t.jsx("a",{className:$,href:a(ue),"data-entity-id":ue,"aria-describedby":h?u:void 0,onFocus:()=>{k.current||W(0)},onClick:le=>{if(k.current&&le.detail>0){le.preventDefault(),Q();return}l==null||l(ue,le)},children:C}),h&&t.jsx(il,{id:u,entityId:ue,span:e,loader:s,buildHref:a,onNavigate:c?void 0:d,newTab:c,sheet:S,onClose:N})]})},il=({id:e,entityId:n,span:i,loader:o,buildHref:s,onNavigate:a,newTab:l,sheet:d,onClose:c})=>{const{convert:p,t:m}=ae(),g=f.useRef(null),[u,h]=f.useState("start"),[x,j]=f.useState(o&&n?{status:"loading"}:{status:"ready",summary:null});f.useEffect(()=>{if(!o||!n)return;let b=!1;return j({status:"loading"}),Dd(o.owner,o.load,n).then(k=>{b||j({status:"ready",summary:k})}).catch(()=>{b||j({status:"error"})}),()=>{b=!0}},[o,n]),bs(()=>{const b=g.current;if(!b||typeof window>"u")return;const k=b.getBoundingClientRect(),w=document.documentElement.clientWidth||window.innerWidth;!d&&k.right>w-8&&u==="start"&&h("end")},[x,u,d]);const y=x.status==="ready"?x.summary:null,S=(y==null?void 0:y.title)??i.canonicalName??i.text;return n?t.jsxs("span",{ref:g,id:e,role:d?"dialog":"tooltip","aria-label":d?S:void 0,className:"bim-et-card","data-align":u,"data-sheet":d?"":void 0,children:[d&&c&&t.jsx(Vd,{onClose:c}),t.jsx("span",{className:"bim-et-card-k",children:p(bo[i.kind])}),S&&t.jsx("span",{className:"bim-et-card-t",children:p(S)}),(y==null?void 0:y.meta)&&t.jsx("span",{className:"bim-et-card-m",children:p(y.meta)}),(y==null?void 0:y.description)&&t.jsx("span",{className:"bim-et-card-d",children:p(y.description)}),x.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:p("載入中…")}),x.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:p("摘要載入失敗")}),y&&t.jsx("a",{className:"bim-et-card-a",href:s(y.id||n),...l?{target:"_blank",rel:"noopener"}:{},onClick:a?b=>a(y.id||n,b):void 0,children:m("reader.entityDetail")})]}):t.jsx("span",{ref:g,id:e,role:"tooltip",className:"bim-et-card","data-align":u,children:t.jsx("span",{className:"bim-et-card-k",children:p(bo[i.kind])})})},eb=({id:e,span:n,loader:i,buildHref:o,onNavigate:s,newTab:a,sheet:l,onClose:d})=>{const{convert:c}=ae(),p=f.useRef(null),[m,g]=f.useState(0);bs(()=>{const h=p.current;if(!h||l||typeof window>"u")return;const x=h.getBoundingClientRect();if(!x.width)return;const j=document.documentElement.clientWidth||window.innerWidth;g(Math.max(8-x.left,Math.min(0,j-8-x.right)))},[]);const u=n.targets??[];return t.jsxs("span",{ref:p,id:e,role:"group","aria-label":c(`合稱,${u.length} 條`),className:`bim-et-card bim-et-card-multi${u.length>3?" bim-et-dense":""}`,"data-sheet":l?"":void 0,style:m&&!l?{left:m}:void 0,children:[l&&d&&t.jsx(Vd,{onClose:d}),t.jsxs("span",{className:"bim-et-card-k",children:[c("合稱")," · ",c(`${u.length} 條`)]}),u.map(h=>t.jsx(tb,{target:h,kind:n.kind,loader:i,buildHref:o,onNavigate:s,newTab:a},h.id))]})},tb=({target:e,kind:n,loader:i,buildHref:o,onNavigate:s,newTab:a})=>{const{convert:l,t:d}=ae(),[c,p]=f.useState(i?{status:"loading"}:{status:"ready",summary:null});f.useEffect(()=>{if(!i)return;let u=!1;return p({status:"loading"}),Dd(i.owner,i.load,e.id).then(h=>{u||p({status:"ready",summary:h})}).catch(()=>{u||p({status:"error"})}),()=>{u=!0}},[i,e.id]);const m=c.status==="ready"?c.summary:null,g=(m==null?void 0:m.title)??e.canonicalName??e.id;return t.jsxs("span",{className:"bim-et-row","data-entity-id":e.id,children:[t.jsxs("span",{className:"bim-et-row-t",children:[e.part&&t.jsx("span",{className:"bim-et-row-p",children:nb(e.part,l)}),t.jsx("span",{className:"bim-et-card-t",children:l(g)}),t.jsx("span",{className:"bim-et-row-k",children:l(bo[n])})]}),(m==null?void 0:m.meta)&&t.jsx("span",{className:"bim-et-card-m",children:l(m.meta)}),(m==null?void 0:m.description)&&t.jsx("span",{className:"bim-et-card-d bim-et-card-d2",children:l(m.description)}),c.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:l("載入中…")}),c.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:l("摘要載入失敗")}),m&&t.jsx("a",{className:"bim-et-card-a",href:o(m.id||e.id),...a?{target:"_blank",rel:"noopener"}:{},onClick:s?u=>s(m.id||e.id,u):void 0,children:d("reader.entityDetail")})]})},nb=(e,n)=>`${n(e)} →`,Vd=({onClose:e})=>{const{t:n}=ae();return t.jsx("button",{type:"button",className:"bim-et-card-x","aria-label":n("reader.close"),onClick:e,children:"×"})},vs=e=>`〔图:${e}〕`,Gd=(e,n)=>e&&n?n(e.file):null;function Yd({fig:e,info:n,figUrl:i,block:o,failed:s,onFail:a}){const l=(n==null?void 0:n.alt)??"图形符号",d=Gd(n,i);if(!d||s)return t.jsx("span",{className:"guji-fig-missing","data-fig-missing":e,children:vs(l)});const c=n.width>0&&n.height>0?`${n.width} / ${n.height}`:void 0;return n.mime==="image/svg+xml"?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"guji-fig-img is-svg",role:"img","aria-label":l,"data-fig":e,style:{"--guji-fig-src":`url("${d}")`,aspectRatio:c}}),t.jsx("img",{src:d,alt:"",hidden:!0,onError:a})]}):t.jsx("img",{className:`guji-fig-img${o?" is-block":""}`,src:d,alt:o?l:"","data-fig":e,"data-raster":"1",loading:o?"lazy":void 0,decoding:"async",draggable:!1,style:c?{aspectRatio:c}:void 0,onError:a})}function ib({id:e,fig:n,info:i,figUrl:o,cells:s,cont:a,className:l,pageStart:d,children:c}){const{t:p}=ae(),m=(i==null?void 0:i.alt)??"",g=m&&m!==p("reader.figPlain")?p("reader.figLabel",{alt:m}):p("reader.figPlain"),[u,h]=f.useState(!1),x=u||!Gd(i,o);return t.jsxs("span",{"data-char-id":e,"data-page-start":d,"data-fig-copy":a?"":vs((i==null?void 0:i.alt)??"图形符号"),className:`${l} is-fig${a?" is-fig-cont":""}${x&&!a?" is-fig-missing":""}`,style:a?void 0:{"--guji-fig-n":s},title:g,"aria-label":g,role:"img",children:[t.jsx("span",{className:"guji-fig-glyph",children:c}),!a&&t.jsx(Yd,{fig:n,info:i,figUrl:o,failed:u,onFail:()=>h(!0)})]})}function rb({fig:e,info:n,figUrl:i,onClick:o}){const{t:s}=ae(),a=(n==null?void 0:n.alt)??"图形符号",l=a!==s("reader.figPlain")?s("reader.figLabel",{alt:a}):s("reader.figPlain"),[d,c]=f.useState(!1);return t.jsxs("figure",{className:"guji-fig-block","data-fig-block":e,"data-fig-copy":vs(a),title:l,onClick:o,style:o?{cursor:"pointer"}:void 0,children:[t.jsx(Yd,{fig:e,info:n,figUrl:i,block:!0,failed:d,onFail:()=>c(!0)}),t.jsx("figcaption",{className:"guji-fig-caption",children:a})]})}const ob=new Set(["P","H1","H2","H3","H4","H5","H6","FIGURE","SECTION","DIV","LI"]);function sb(e){const n=e.cloneContents();if(!n.querySelector("[data-fig-copy]"))return null;let i="";const o=()=>{i&&!i.endsWith(`
|
|
1508
|
+
`,Jx=120;function Tt(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function Qx(e,n=Jx){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 eb(e){const n=e.dates&&typeof e.dates=="object"?e.dates:{},i=typeof n.birth=="number"?n.birth:void 0,o=typeof n.death=="number"?n.death:void 0;if(!(i===void 0&&o===void 0))return`${i??"?"}–${o??"?"}`}function tb(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(i=>{if(!i||typeof i!="object")return"";const o=i,s=Tt(o.name);return s?[Tt(o.dynasty)&&`〔${Tt(o.dynasty)}〕`,s,Tt(o.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function Kd(e,n){const i=Tt(n.type),o=Tt(n.primary_name)??Tt(n.title)??e,s=i==="entity"?[Tt(n.dynasty),eb(n),Tt(n.native_place)].filter(Boolean).join(" · "):[tb(n),Tt(n.edition),Tt(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?Tt(n.description.text):Tt(n.description);return{id:Tt(n.id)??e,type:i,title:o,meta:s||void 0,description:Qx(a)}}function qd(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 Xd(e){return async n=>{const i=await e.getItem(n);if(i)return Kd(n,i);if(e.getEntry){const o=await e.getEntry(n);if(o)return qd(o)}return null}}const cl=new WeakMap;function Zd(e,n,i){let o=cl.get(e);o||(o=new Map,cl.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 Jd=e=>`/item/${encodeURIComponent(e)}`,wo={work:"書名",people:"人名",place:"地名",office:"官職",dynasty:"朝代",reign:"年號",other:"專名"},ws=typeof window>"u"?h.useEffect:h.useLayoutEffect;function Ss(e,n){return h.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:Xd(e)}:null,[n,e])}const nb=e=>e,ib=({text:e,entities:n,offsets:i="text",plainBase:o=0,transport:s,loadSummary:a,buildHref:l=Jd,onNavigate:d,renderText:c=nb,hoverDelayMs:p=250,closeDelayMs:m,injectStyles:g=!0,className:u})=>{const f=h.useMemo(()=>{const j=i==="plain"?Dd(e,n,o):n;return Ud(e,j)},[e,n,i,o]),x=Ss(s,a);return t.jsxs("span",{className:u?`bim-et-root ${u}`:"bim-et-root",children:[g&&t.jsx("style",{children:ks}),f.map(j=>j.type==="text"?t.jsx(h.Fragment,{children:c(j.text)},`t${j.start}`):t.jsx($s,{span:j.span,label:j.text,hasBrackets:e[j.start-1]==="《"&&e[j.start+j.text.length]==="》",loader:x,buildHref:l,onNavigate:d,renderText:c,hoverDelayMs:p,closeDelayMs:m},`${j.span.key}@${j.start}`))]})};let cn=null;const $s=({span:e,label:n,hasBrackets:i,plain:o,loader:s,buildHref:a,onNavigate:l,onCardNavigate:d=l,cardNewTab:c,renderText:p,hoverDelayMs:m,closeDelayMs:g=280})=>{const u=h.useId(),[f,x]=h.useState(!1),[j,y]=h.useState(!1),[S,b]=h.useState(!1),v=h.useRef(!1),w=h.useRef(null),k=h.useRef(null),_=`bim-et bim-et-${e.kind}${o?" bim-et-nu":""}`,$=e.kind==="work"&&!i,C=t.jsxs(t.Fragment,{children:[$&&t.jsx("span",{className:"bim-et-sr",children:"《"}),p(n),$&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),L=()=>{w.current&&(clearTimeout(w.current),w.current=null)},E=()=>{k.current&&(clearTimeout(k.current),k.current=null)},T=h.useRef(!1),N=h.useCallback(()=>{T.current=!1,L(),E(),x(!1),y(!1),b(!1),cn===N&&(cn=null)},[]);h.useEffect(()=>()=>{L(),E(),cn===N&&(cn=null)},[N]);const W=h.useCallback(()=>{cn&&cn!==N&&cn(),cn=N,x(!0)},[N]),F=h.useCallback(ee=>{E(),y(!0),!f&&(L(),ee<=0?W():w.current=setTimeout(W,ee))},[f,W]),R=h.useCallback(()=>{L(),E(),!T.current&&(k.current=setTimeout(N,g))},[N,g]),G=h.useRef(null);h.useEffect(()=>{if(!f||!(e.targets||S))return;const ee=S?"click":"pointerdown",U=se=>{var pe;(pe=G.current)!=null&&pe.contains(se.target)||N()};return document.addEventListener(ee,U),()=>document.removeEventListener(ee,U)},[f,S,e.targets,N]);const Q=h.useCallback(()=>{L(),E(),T.current=!0,y(!0),b(!0),W()},[W]);ws(()=>{if(!f||!S)return;const ee=G.current,U=ee==null?void 0:ee.querySelector(".bim-et-card");if(!ee||!U||typeof window>"u")return;const se=()=>{const _e=ee.getClientRects(),Le=_e[_e.length-1];if(!Le)return;const Ee=Le.bottom+12-U.getBoundingClientRect().top;Ee>0&&window.scrollBy({top:Ee,behavior:"smooth"})};if(se(),typeof ResizeObserver>"u")return;const pe=new ResizeObserver(se);return pe.observe(U),()=>pe.disconnect()},[f,S]);const ie=!!e.targetId,de=e.targetId,q={className:"bim-et-w","data-active":j?"":void 0,onPointerEnter:ee=>{v.current=ee.pointerType==="touch"},onPointerDown:ee=>{v.current=ee.pointerType==="touch"},onMouseEnter:()=>{v.current||F(m)},onMouseLeave:()=>{v.current||R()},onBlur:ee=>{ee.currentTarget.contains(ee.relatedTarget)||N()},onKeyDown:ee=>{ee.key==="Escape"&&f&&(ee.stopPropagation(),N())}};return e.targets?t.jsxs("span",{...q,ref:G,children:[t.jsx("span",{className:`${_} bim-et-multi`,role:"button",tabIndex:0,"aria-haspopup":"true","aria-expanded":f,"aria-controls":f?u:void 0,onFocus:()=>{v.current||F(0)},onClick:()=>{v.current?Q():(E(),T.current=!0,y(!0),W())},onKeyDown:ee=>{(ee.key==="Enter"||ee.key===" ")&&(ee.preventDefault(),f?N():(T.current=!0,y(!0),W()))},children:C}),f&&t.jsx(rb,{id:u,span:e,loader:s,buildHref:a,onNavigate:c?void 0:d,newTab:c,sheet:S,onClose:N})]}):!ie||!de?t.jsxs("span",{...q,ref:G,children:[t.jsx("span",{className:_,children:C}),f&&!v.current&&t.jsx(dl,{id:u,entityId:null,span:e,loader:null,buildHref:a,onNavigate:l})]}):t.jsxs("span",{...q,ref:G,children:[t.jsx("a",{className:_,href:a(de),"data-entity-id":de,"aria-describedby":f?u:void 0,onFocus:()=>{v.current||F(0)},onClick:ee=>{if(v.current&&ee.detail>0){ee.preventDefault(),Q();return}l==null||l(de,ee)},children:C}),f&&t.jsx(dl,{id:u,entityId:de,span:e,loader:s,buildHref:a,onNavigate:c?void 0:d,newTab:c,sheet:S,onClose:N})]})},dl=({id:e,entityId:n,span:i,loader:o,buildHref:s,onNavigate:a,newTab:l,sheet:d,onClose:c})=>{const{convert:p,t:m}=oe(),g=h.useRef(null),[u,f]=h.useState("start"),[x,j]=h.useState(o&&n?{status:"loading"}:{status:"ready",summary:null});h.useEffect(()=>{if(!o||!n)return;let b=!1;return j({status:"loading"}),Zd(o.owner,o.load,n).then(v=>{b||j({status:"ready",summary:v})}).catch(()=>{b||j({status:"error"})}),()=>{b=!0}},[o,n]),ws(()=>{const b=g.current;if(!b||typeof window>"u")return;const v=b.getBoundingClientRect(),w=document.documentElement.clientWidth||window.innerWidth;!d&&v.right>w-8&&u==="start"&&f("end")},[x,u,d]);const y=x.status==="ready"?x.summary:null,S=(y==null?void 0:y.title)??i.canonicalName??i.text;return n?t.jsxs("span",{ref:g,id:e,role:d?"dialog":"tooltip","aria-label":d?S:void 0,className:"bim-et-card","data-align":u,"data-sheet":d?"":void 0,children:[d&&c&&t.jsx(Qd,{onClose:c}),t.jsx("span",{className:"bim-et-card-k",children:p(wo[i.kind])}),S&&t.jsx("span",{className:"bim-et-card-t",children:p(S)}),(y==null?void 0:y.meta)&&t.jsx("span",{className:"bim-et-card-m",children:p(y.meta)}),(y==null?void 0:y.description)&&t.jsx("span",{className:"bim-et-card-d",children:p(y.description)}),x.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:p("載入中…")}),x.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:p("摘要載入失敗")}),y&&t.jsx("a",{className:"bim-et-card-a",href:s(y.id||n),...l?{target:"_blank",rel:"noopener"}:{},onClick:a?b=>a(y.id||n,b):void 0,children:m("reader.entityDetail")})]}):t.jsx("span",{ref:g,id:e,role:"tooltip",className:"bim-et-card","data-align":u,children:t.jsx("span",{className:"bim-et-card-k",children:p(wo[i.kind])})})},rb=({id:e,span:n,loader:i,buildHref:o,onNavigate:s,newTab:a,sheet:l,onClose:d})=>{const{convert:c}=oe(),p=h.useRef(null),[m,g]=h.useState(0);ws(()=>{const f=p.current;if(!f||l||typeof window>"u")return;const x=f.getBoundingClientRect();if(!x.width)return;const j=document.documentElement.clientWidth||window.innerWidth;g(Math.max(8-x.left,Math.min(0,j-8-x.right)))},[]);const u=n.targets??[];return t.jsxs("span",{ref:p,id:e,role:"group","aria-label":c(`合稱,${u.length} 條`),className:`bim-et-card bim-et-card-multi${u.length>3?" bim-et-dense":""}`,"data-sheet":l?"":void 0,style:m&&!l?{left:m}:void 0,children:[l&&d&&t.jsx(Qd,{onClose:d}),t.jsxs("span",{className:"bim-et-card-k",children:[c("合稱")," · ",c(`${u.length} 條`)]}),u.map(f=>t.jsx(ob,{target:f,kind:n.kind,loader:i,buildHref:o,onNavigate:s,newTab:a},f.id))]})},ob=({target:e,kind:n,loader:i,buildHref:o,onNavigate:s,newTab:a})=>{const{convert:l,t:d}=oe(),[c,p]=h.useState(i?{status:"loading"}:{status:"ready",summary:null});h.useEffect(()=>{if(!i)return;let u=!1;return p({status:"loading"}),Zd(i.owner,i.load,e.id).then(f=>{u||p({status:"ready",summary:f})}).catch(()=>{u||p({status:"error"})}),()=>{u=!0}},[i,e.id]);const m=c.status==="ready"?c.summary:null,g=(m==null?void 0:m.title)??e.canonicalName??e.id;return t.jsxs("span",{className:"bim-et-row","data-entity-id":e.id,children:[t.jsxs("span",{className:"bim-et-row-t",children:[e.part&&t.jsx("span",{className:"bim-et-row-p",children:sb(e.part,l)}),t.jsx("span",{className:"bim-et-card-t",children:l(g)}),t.jsx("span",{className:"bim-et-row-k",children:l(wo[n])})]}),(m==null?void 0:m.meta)&&t.jsx("span",{className:"bim-et-card-m",children:l(m.meta)}),(m==null?void 0:m.description)&&t.jsx("span",{className:"bim-et-card-d bim-et-card-d2",children:l(m.description)}),c.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:l("載入中…")}),c.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:l("摘要載入失敗")}),m&&t.jsx("a",{className:"bim-et-card-a",href:o(m.id||e.id),...a?{target:"_blank",rel:"noopener"}:{},onClick:s?u=>s(m.id||e.id,u):void 0,children:d("reader.entityDetail")})]})},sb=(e,n)=>`${n(e)} →`,Qd=({onClose:e})=>{const{t:n}=oe();return t.jsx("button",{type:"button",className:"bim-et-card-x","aria-label":n("reader.close"),onClick:e,children:"×"})},_s=e=>`〔图:${e}〕`,ep=(e,n)=>e&&n?n(e.file):null;function tp({fig:e,info:n,figUrl:i,block:o,failed:s,onFail:a}){const l=(n==null?void 0:n.alt)??"图形符号",d=ep(n,i);if(!d||s)return t.jsx("span",{className:"guji-fig-missing","data-fig-missing":e,children:_s(l)});const c=n.width>0&&n.height>0?`${n.width} / ${n.height}`:void 0;return n.mime==="image/svg+xml"?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"guji-fig-img is-svg",role:"img","aria-label":l,"data-fig":e,style:{"--guji-fig-src":`url("${d}")`,aspectRatio:c}}),t.jsx("img",{src:d,alt:"",hidden:!0,onError:a})]}):t.jsx("img",{className:`guji-fig-img${o?" is-block":""}`,src:d,alt:o?l:"","data-fig":e,"data-raster":"1",loading:o?"lazy":void 0,decoding:"async",draggable:!1,style:c?{aspectRatio:c}:void 0,onError:a})}function ab({id:e,fig:n,info:i,figUrl:o,cells:s,cont:a,className:l,pageStart:d,children:c}){const{t:p}=oe(),m=(i==null?void 0:i.alt)??"",g=m&&m!==p("reader.figPlain")?p("reader.figLabel",{alt:m}):p("reader.figPlain"),[u,f]=h.useState(!1),x=u||!ep(i,o);return t.jsxs("span",{"data-char-id":e,"data-page-start":d,"data-fig-copy":a?"":_s((i==null?void 0:i.alt)??"图形符号"),className:`${l} is-fig${a?" is-fig-cont":""}${x&&!a?" is-fig-missing":""}`,style:a?void 0:{"--guji-fig-n":s},title:g,"aria-label":g,role:"img",children:[t.jsx("span",{className:"guji-fig-glyph",children:c}),!a&&t.jsx(tp,{fig:n,info:i,figUrl:o,failed:u,onFail:()=>f(!0)})]})}function lb({fig:e,info:n,figUrl:i,onClick:o}){const{t:s}=oe(),a=(n==null?void 0:n.alt)??"图形符号",l=a!==s("reader.figPlain")?s("reader.figLabel",{alt:a}):s("reader.figPlain"),[d,c]=h.useState(!1);return t.jsxs("figure",{className:"guji-fig-block","data-fig-block":e,"data-fig-copy":_s(a),title:l,onClick:o,style:o?{cursor:"pointer"}:void 0,children:[t.jsx(tp,{fig:e,info:n,figUrl:i,block:!0,failed:d,onFail:()=>c(!0)}),t.jsx("figcaption",{className:"guji-fig-caption",children:a})]})}const cb=new Set(["P","H1","H2","H3","H4","H5","H6","FIGURE","SECTION","DIV","LI"]);function db(e){const n=e.cloneContents();if(!n.querySelector("[data-fig-copy]"))return null;let i="";const o=()=>{i&&!i.endsWith(`
|
|
1509
1509
|
`)&&(i+=`
|
|
1510
|
-
`)},s=a=>{if(a.nodeType===3){i+=a.nodeValue??"";return}if(!(a.nodeType!==1&&a.nodeType!==11)){if(a.nodeType===1){const l=a;if(l.classList.contains("guji-page-divider")||l.style.userSelect==="none")return;const d=l.getAttribute("data-fig-copy");if(d!==null){l.tagName==="FIGURE"?(o(),i+=d,o()):i+=d;return}const c=ob.has(l.tagName);c&&o(),l.childNodes.forEach(s),c&&o();return}a.childNodes.forEach(s)}};return s(n),i.replace(/\n+$/,"")}const ab=e=>`/item/${encodeURIComponent(e)}`;function lb(e){const n=e.filter(i=>i.kind==null||i.kind==="point");return{before:n.filter(i=>i.pos==="before"),after:n.filter(i=>i.pos!=="before")}}function cb(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 ks=({pageData:e,pages:n,punctuations:i=yo,selectedCharIds:o,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:m,convert:g,scrollToPage:u,scrollToAnchor:h,onVisibleHeadingChange:x,entities:j,entityTransport:y,loadEntitySummary:S,buildEntityHref:b,onEntityNavigate:k,pageBreaks:w=!0,pageIndicatorY:v,onPageIndicatorYChange:$,quoteStyle:_,bookTitleStyle:C,showWorks:I,figures:E,figUrl:T,onFigureBlockClick:N})=>{var gt,yt,qe;const{t:P}=ae(),W=f.useRef(null),L=f.useRef(0),K=f.useMemo(()=>{const V=new Map;return p&&i.forEach((D,Y)=>{const we=D.id?D:{...D,id:`${D.anchor}#${Y}`},Ce=V.get(we.anchor)||[];Ce.push(we),V.set(we.anchor,Ce)}),V},[i,p]),Q=f.useMemo(()=>_===void 0&&C===void 0&&I===void 0?null:{quoteStyle:_??"original",hideBookBrackets:C==="wavy"||I===!1},[_,C,I]),Z=C==="bracket",ue=f.useMemo(()=>{var Ue;const V=n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}],D=new Map;for(const B of V)for(const ge of B.columns)ge.chars.length>0&&!ge.raised&&D.set(ge.lead_blank||0,(D.get(ge.lead_blank||0)||0)+1);let Y=0,we=-1;for(const[B,ge]of D)(ge>we||ge===we&&B<Y)&&(Y=B,we=ge);const Ce=B=>!!B.raised||(B.lead_blank||0)<Y,Ne=V.filter(B=>B.columns.some(ge=>ge.chars.length>0||ge.kind==="figure")).map(B=>{const ge=[...B.columns].sort((We,Nt)=>We.col-Nt.col),Be=[];let Ye=[];const Oe=()=>{const We=fb(K.get(Ye[0].charData.id));Be.push({id:`para-p${B.page}-${Be.length}`,chars:Ye,...We?{heading:{level:We.mark.length,anchor:Ye[0].charData.id,...We.toc===!1?{toc:!1}:{}}}:{}}),Ye=[]};let Ze=!1,ct=0,jt;const ot=[];for(const We of ge){if(We.kind==="figure"&&We.fig){Ye.length>0?Oe():Be.length===0&&(Ze=!0),ot.push({before:Be.length,fig:We.fig,...We.figBox?{box:We.figBox}:{}}),ct=0;continue}if(We.chars.length===0){We.kind==="blank"&&ct++;continue}const Nt=We.raised||We.lead_blank||ct?{raised:We.raised,leadBlank:We.lead_blank,blankBefore:ct}:void 0;ct=0,Ce(We)||(jt=We.lead_blank||0);let dt=!0;for(const St of We.chars){const Lt=K.get(St.id),{before:_t,after:ji}=Lt?lb(Lt):mb,vi=!!Lt&&Lt.some(an=>an.kind==="break"&&an.pos!=="before");Lt&&Lt.some(an=>an.kind==="heading")&&(Ye.length>0?Oe():Be.length===0&&(Ze=!0)),Ye.push({charData:St,col:We.col,beforePuncts:_t,afterPuncts:ji,...dt&&Nt?{start:Nt}:{}}),dt=!1,vi&&Oe()}}const zt=Ye.length>0;return zt&&Oe(),{page:B.page,paragraphs:Be,endsOpen:zt,...jt!==void 0?{tailLead:jt}:{},...Ze?{leadStarts:Ze}:{},...B.label?{label:B.label}:{},...ct>0?{trailingBlank:ct}:{},...ot.length>0?{blocks:ot}:{}}}),et=new Map;if(!w){let B=null;for(const ge of Ne){const Be=ge.paragraphs[0],Ye=(Ue=Be==null?void 0:Be.chars[0])==null?void 0:Ue.start,Oe=(Ye==null?void 0:Ye.leadBlank)||0,Ze=!!Ye&&!Ye.raised&&Oe>=Y&&Oe>((B==null?void 0:B.tailLead)??Y),ct=!!ge.leadStarts||!!(Ye!=null&&Ye.blankBefore)||Ze,jt=ge.paragraphs.length===1&&!!ge.trailingBlank;if(B&&Be&&!ct&&!jt){for(const ot of Be.chars)et.set(ot.charData.id,B.owner);B.para.chars=B.para.chars.concat(Be.chars),ge.leadFirstId=Be.chars[0].charData.id,ge.paragraphs=ge.paragraphs.slice(1),ge.blocks&&(ge.blocks=ge.blocks.map(ot=>({...ot,before:ot.before-1})))}if(ge.endsOpen&&!ge.trailingBlank){const ot=ge.paragraphs[ge.paragraphs.length-1];ot?B={para:ot,owner:ge.page,tailLead:ge.tailLead??(B==null?void 0:B.tailLead)??Y}:B&&ge.tailLead!==void 0&&(B.tailLead=ge.tailLead)}else B=null}}const Je=new Map;for(const B of Ne)B.leadFirstId&&Je.set(B.leadFirstId,B.page);return{pages:Ne,mergedOwner:et,pageStarts:Je}},[n,e,K,w]),J=ue.pages,le=f.useRef(J);le.current=J;const H=f.useMemo(()=>J.map(V=>V.paragraphs.reduce((D,Y)=>D+Y.chars.length,0)),[J]),oe=f.useCallback((V,D)=>{let Y=V,we=0;for(;Y<H.length&&(Y===V||we+H[Y]<=D);)we+=H[Y++];return Y},[H]),be=`${J.length}:${((qe=(yt=(gt=J[0])==null?void 0:gt.paragraphs[0])==null?void 0:yt.chars[0])==null?void 0:qe.charData.id)??""}`,[ze,Le]=f.useState(()=>({sig:be,n:oe(0,ol)}));let _e=ze.n;ze.sig!==be&&(_e=oe(0,ol),Le({sig:be,n:_e})),_e=Math.min(_e,J.length);const re=_e>=J.length;f.useEffect(()=>re?void 0:(D=>{const Y=window;if(Y.requestIdleCallback){const Ce=Y.requestIdleCallback(D,{timeout:300});return()=>{var Ne;return(Ne=Y.cancelIdleCallback)==null?void 0:Ne.call(Y,Ce)}}const we=setTimeout(D,16);return()=>clearTimeout(we)})(()=>Le(D=>D.sig===be?{sig:D.sig,n:Math.max(D.n,oe(D.n,db))}:D)),[re,_e,be,oe]);const xe=f.useCallback(V=>{const D=le.current.findIndex(we=>we.page>=V),Y=(D<0?le.current.length:D)+2;Le(we=>we.n>=Y?we:{...we,n:Y})},[]),R=re?J:J.slice(0,_e);f.useEffect(()=>{let V;const D=requestAnimationFrame(()=>{V=setTimeout(()=>{const Y=W.current,we=Y==null?void 0:Y.querySelector(".guji-reflow-paragraph");if(!Y||!we)return;const Ce=getComputedStyle(we),Ne=parseFloat(Ce.fontSize),et=we.clientWidth;if(!(Ne>0)||!(et>0))return;const Je=parseFloat(Ce.lineHeight);Y.style.setProperty("--gtv-cpl",String(Math.max(8,Math.floor(et/Ne)))),Y.style.setProperty("--gtv-lh",`${Math.round(Je>0?Je:Ne*2)}px`)},0)});return()=>{cancelAnimationFrame(D),V&&clearTimeout(V)}},[be]);const se=f.useMemo(()=>{const V=[];for(const D of J)for(const Y of D.paragraphs)for(const we of Y.chars)V.push(we.charData.id);return V},[J]),de=f.useMemo(()=>new Map(se.map((V,D)=>[V,D])),[se]),O=f.useMemo(()=>{const V=new Map;if(!j||j.length===0)return V;const D=de;for(const Y of j){if(!Y.anchor)continue;const we=D.get(Y.anchor.start),Ce=D.get(Y.anchor.end);if(!(we===void 0||Ce===void 0||Ce<we))for(let Ne=we;Ne<=Ce;Ne++)V.has(se[Ne])||V.set(se[Ne],Y)}return V},[j,se,de]),ee=f.useMemo(()=>{const V=h==null?void 0:h.anchor;return V&&V.startsWith("e=")?new Set(V.slice(2).split(",").filter(Boolean)):null},[h==null?void 0:h.anchor]),ke=f.useMemo(()=>{var we;if(!ee||!j)return[];const V=new Set,D=[],Y=(Ce,Ne)=>{const et=`${Ce}:${Ne}`;V.has(et)||(V.add(et),D.push([Ce,Ne]))};for(const Ce of j){if(!Ce.anchor)continue;const Ne=de.get(Ce.anchor.start),et=de.get(Ce.anchor.end);if(!(Ne===void 0||et===void 0||et<Ne)){(Ce.targetId&&ee.has(Ce.targetId)||(we=Ce.targets)!=null&&we.some(Je=>ee.has(Je.id)))&&Y(Ne,et);for(const Je of Ce.parts??[]){if(!ee.has(Je.id))continue;const Ue=Ne+Je.offset[0],B=Ne+Je.offset[1]-1;B>=Ue&&B<=et&&Y(Ue,B)}}}return D.sort((Ce,Ne)=>Ce[0]-Ne[0]||Ce[1]-Ne[1])},[ee,j,de]),ve=ys(y,S),Ve=O.size>0,F=f.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:m,onEntityNavigate:k,onVisibleHeadingChange:x,onFigureBlockClick:N});F.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:m,onEntityNavigate:k,onVisibleHeadingChange:x,onFigureBlockClick:N};const fe=f.useMemo(()=>({click:V=>{var D,Y;L.current=Date.now()+1200,(Y=(D=F.current).onCharClick)==null||Y.call(D,V)},enter:V=>{var D,Y;return(Y=(D=F.current).onCharHover)==null?void 0:Y.call(D,V)},leave:()=>{var V,D;return(D=(V=F.current).onCharHover)==null?void 0:D.call(V,null)},figBlock:V=>{var D,Y;return(Y=(D=F.current).onFigureBlockClick)==null?void 0:Y.call(D,V)},navigate:(V,D)=>{D.ctrlKey||D.metaKey||D.shiftKey||(D.preventDefault(),D.detail===0&&window.open(D.currentTarget.href,"_blank","noopener"))}}),[]),te=gb(o,ue.mergedOwner),U=f.useRef(_e);U.current=_e;const pe=f.useRef(null),Me=f.useCallback(V=>{const D=pe.current,Y=D==null?void 0:D.map.get(V);if(Y&&Y.isConnected)return Y;if(D&&D.for===le.current&&D.n===U.current&&!Y)return null;const we=W.current;if(!we)return null;const Ce=new Map;return we.querySelectorAll("span[data-char-id]").forEach(Ne=>{Ce.set(Ne.getAttribute("data-char-id"),Ne)}),pe.current={for:le.current,n:U.current,map:Ce},Ce.get(V)??null},[]),Ke=f.useRef(null);f.useEffect(()=>{var D;if((D=Ke.current)==null||D.classList.remove("is-hovered"),Ke.current=null,!s)return;const V=Me(s);V&&(V.classList.add("is-hovered"),Ke.current=V)},[s,Me]);const nt=f.useRef(null),it=V=>{var Y;const D=V instanceof Element?V.closest("span[data-char-id]"):null;return D&&((Y=W.current)!=null&&Y.contains(D))?D.getAttribute("data-char-id"):null},at=V=>{const D=it(V.target);D&&fe.click(D)},lt=V=>{const D=it(V.target);D!==nt.current&&(nt.current=D,D?fe.enter(D):fe.leave())},rt=V=>{const D=typeof window<"u"?window.getSelection():null;if(!D||D.isCollapsed||D.rangeCount===0)return;const Y=sb(D.getRangeAt(0));Y!==null&&(V.clipboardData.setData("text/plain",Y),V.preventDefault())},Pe=()=>{nt.current!==null&&(nt.current=null,fe.leave())};f.useEffect(()=>{let V=null;const D=()=>{var ct,jt;V=null;const we=window.getSelection(),Ce=W.current;if(!we||we.isCollapsed||we.rangeCount===0||!Ce)return;const Ne=we.getRangeAt(0),et=Ne.commonAncestorContainer,Je=et.nodeType===3?et.parentElement:et;if(!Je||!Ce.contains(Je))return;const Ue=Ce.querySelectorAll("span[data-char-id]"),B=ot=>{let zt=ot;for(;zt.nodeType!==3&&zt.firstChild;)zt=zt.firstChild;return zt};let ge=0,Be=Ue.length;for(;ge<Be;){const ot=ge+Be>>1;Ne.comparePoint(B(Ue[ot]),0)<0?ge=ot+1:Be=ot}const Ye=ge;for(Be=Ue.length;ge<Be;){const ot=ge+Be>>1;Ne.comparePoint(B(Ue[ot]),0)<=0?ge=ot+1:Be=ot}let Oe=ge-1;if(Oe>=Ye&&Ne.endOffset===0&&Ne.endContainer===B(Ue[Oe])&&Oe--,Oe<Ye)return;const Ze=[];for(let ot=Ye;ot<=Oe;ot++)Ze.push(Ue[ot].getAttribute("data-char-id"));Ze.length>0&&(L.current=Date.now()+1200,(jt=(ct=F.current).onSelectionChange)==null||jt.call(ct,Ze))},Y=()=>{V&&clearTimeout(V),V=setTimeout(D,120)};return document.addEventListener("selectionchange",Y),()=>{document.removeEventListener("selectionchange",Y),V&&clearTimeout(V)}},[]);const z=f.useRef(null);f.useEffect(()=>{if(o.size!==1||z.current===o)return;const V=Array.from(o)[0],D=Me(V);if(D)z.current=o,D.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"});else{const Y=parseInt(V.split(":")[0],10);isNaN(Y)||xe(Y)}},[o,_e,Me,xe]);const ne=V=>{var we;const D=W.current;if(!D)return null;const Y=(we=J.find(Ce=>Ce.page===V))==null?void 0:we.leadFirstId;return Y?D.querySelector(`span[data-char-id="${Y}"]`):D.querySelector(`[data-page-section="${V}"]`)},q=u==null?void 0:u.nonce,he=f.useRef(null);f.useEffect(()=>{if(!u||he.current===u.nonce)return;const V=ne(u.page);if(!V){!re&&J.some(D=>D.page>=u.page)&&xe(u.page);return}he.current=u.nonce,L.current=Date.now()+800,V.scrollIntoView({behavior:"auto",block:"start"})},[q,_e]);const Ie=f.useRef(null),M=f.useRef([]);f.useEffect(()=>{var Ne,et,Je;if(!h||Ie.current===h.nonce||h.anchor.startsWith("e="))return;const[V,D]=h.anchor.split("~"),Y=W.current,we=Y==null?void 0:Y.querySelector(`span[data-char-id="${Qn(V)}"]`),Ce=parseInt(V.split(":")[0],10);if(!we){if(!re&&!isNaN(Ce)&&J.some(Ue=>Ue.page>=Ce)){xe(Ce);return}D&&!isNaN(Ce)&&(Ie.current=h.nonce,(Ne=ne(Ce))==null||Ne.scrollIntoView({behavior:"auto",block:"start"}));return}Ie.current=h.nonce,L.current=Date.now()+800;for(const Ue of M.current)Ue.classList.remove("guji-hl");if(M.current=[],D){const Ue=de.get(V),B=de.get(D);if(Ue!==void 0&&B!==void 0&&B>=Ue&&B-Ue<64)for(let ge=Ue;ge<=B;ge++){const Be=Y==null?void 0:Y.querySelector(`span[data-char-id="${Qn(se[ge])}"]`);Be&&(Be.classList.add("guji-hl"),M.current.push(Be))}rl(we,L)}else(we.closest(".guji-reflow-paragraph")??we).scrollIntoView({behavior:"auto",block:"start"});isNaN(Ce)||(Je=(et=F.current).onVisiblePageChange)==null||Je.call(et,Ce)},[h,J,_e,re,xe,se,de]);const[me,G]=f.useState(null),[Se,ye]=f.useState(!1),Ee=f.useRef(null);f.useEffect(()=>{!h||!ee||Ee.current===h.nonce||ke.length===0||(Ee.current=h.nonce,ye(!1),G({k:0,nonce:Date.now()}))},[h,ee,ke]);const Xe=f.useRef(null);f.useEffect(()=>{var Ne,et;if(!me||Xe.current===me.nonce)return;const V=ke[me.k];if(!V)return;const D=W.current,Y=se[V[0]],we=D==null?void 0:D.querySelector(`span[data-char-id="${Qn(Y)}"]`),Ce=parseInt(Y.split(":")[0],10);if(!we){!re&&!isNaN(Ce)&&xe(Ce);return}Xe.current=me.nonce;for(const Je of M.current)Je.classList.remove("guji-hl");M.current=[];for(let Je=V[0];Je<=V[1];Je++){const Ue=D==null?void 0:D.querySelector(`span[data-char-id="${Qn(se[Je])}"]`);Ue&&(Ue.classList.add("guji-hl"),M.current.push(Ue))}rl(we,L),isNaN(Ce)||(et=(Ne=F.current).onVisiblePageChange)==null||et.call(Ne,Ce)},[me,ke,se,_e,re,xe]);const Fe=f.useMemo(()=>{if(!ee||Se||ke.length===0)return"";const V=[];for(const[D,Y]of ke)for(let we=D;we<=Y;we++)V.push(`.guji-text-pane-content span[data-char-id="${Qn(se[we])}"]`);return`${V.join(",")}{background:${r("mark-soft")};border-radius:2px}`},[ee,Se,ke,se]),Qe=V=>G(D=>{const Y=ke.length;return{k:(((D==null?void 0:D.k)??0)+V+Y)%Y,nonce:Date.now()}}),ut=()=>{ye(!0);for(const V of M.current)V.classList.remove("guji-hl");M.current=[]},X=!!m||!!x,$e=!!m&&typeof v=="number",[je,De]=f.useState(null),ce=jo(je??v??0),He=f.useRef(null);He.current=$e?ce:null;const ft=f.useRef(()=>{});return f.useEffect(()=>{var Be,Ye;if(!X)return;const V=new Map,D=new Map;(Be=W.current)==null||Be.querySelectorAll("[data-page-section],[data-page-start]").forEach(Oe=>{const Ze=Oe.getAttribute("data-page-section");Ze!==null?V.set(Ze,Oe):D.set(Oe.getAttribute("data-page-start"),Oe)});const Y=[],we=[];for(const Oe of R){const Ze=V.get(String(Oe.page));Ze&&(Y.push(Ze),we.push(Oe.page))}if(Y.length===0)return;const Ce=new Map(Y.map((Oe,Ze)=>[Oe,Ze])),Ne=Y.map(()=>[]);let et=0;(Ye=W.current)==null||Ye.querySelectorAll('.guji-reflow-heading:not([data-heading-toc="0"])').forEach(Oe=>{const Ze=Ce.get(Oe.closest("[data-page-section]"));Ze!==void 0&&(Ne[Ze].push(Oe),et++)});let Je,Ue=0;const B=()=>{var We,Nt;if(Ue=0,Date.now()<L.current)return;const Oe=dt=>dt.getBoundingClientRect().top;if(Y.length>1&&Oe(Y[0])===Oe(Y[Y.length-1]))return;const Ze=He.current===null?120:He.current*window.innerHeight;let ct=0,jt=Y.length-1;for(;ct<jt;){const dt=ct+jt+1>>1;Oe(Y[dt])<=Ze?ct=dt:jt=dt-1}const ot=Oe(Y[0])>Ze;let zt=we[ct];for(let dt=ct+1;dt<Y.length;dt++){const St=D.get(String(we[dt]));if(!St||!Y[ct].contains(St)||Oe(St)>Ze)break;zt=we[dt]}if(et>0&&F.current.onVisibleHeadingChange){let dt=null;if(!ot){const Lt=Ne[ct];for(let _t=Lt.length-1;_t>=0&&!dt;_t--)Oe(Lt[_t])<=Ze&&(dt=Lt[_t]);for(let _t=ct-1;_t>=0&&!dt;_t--)Ne[_t].length>0&&(dt=Ne[_t][Ne[_t].length-1])}const St=dt?hb(dt):null;St!==Je&&(Je=St,F.current.onVisibleHeadingChange(St))}(Nt=(We=F.current).onVisiblePageChange)==null||Nt.call(We,zt)},ge=()=>{Ue||(Ue=requestAnimationFrame(B))};return ft.current=()=>{Ue||(Ue=requestAnimationFrame(B))},window.addEventListener("scroll",ge,{passive:!0}),ge(),()=>{window.removeEventListener("scroll",ge),Ue&&cancelAnimationFrame(Ue),ft.current=()=>{}}},[X,J,_e]),f.useEffect(()=>{$e&&ft.current()},[$e,ce]),t.jsxs("div",{ref:W,className:"guji-text-pane-content",onClick:at,onMouseOver:lt,onMouseLeave:Pe,onCopy:rt,children:[Ve&&t.jsx("style",{children:xs}),Fe&&t.jsx("style",{children:Fe}),Fe&&me&&t.jsxs("div",{className:"bim-rd-mnav bim-d-ui",role:"navigation","aria-label":P("mentions.navLabel"),children:[t.jsx("span",{children:P("mentions.navCount",{k:me.k+1,n:ke.length})}),t.jsx("button",{type:"button",onClick:()=>Qe(-1),"aria-label":P("mentions.prev"),title:P("mentions.prev"),children:"‹"}),t.jsx("button",{type:"button",onClick:()=>Qe(1),"aria-label":P("mentions.next"),title:P("mentions.next"),children:"›"}),t.jsx("button",{type:"button",onClick:ut,"aria-label":P("mentions.close"),title:P("mentions.close"),children:"×"})]}),$e&&t.jsx(kb,{y:ce,containerRef:W,onDrag:De,onCommit:V=>{De(null),$==null||$(V)}}),t.jsx("div",{className:"guji-text-reflow-view",children:R.map((V,D)=>t.jsx(yb,{pGroup:V,first:D===0,pageBreaks:w,markOpts:Q,plainBooks:Z,selected:te.get(V.page)??ub,entityOfChar:O,entityLoader:ve,convert:g,buildHref:b??ab,handlers:fe,charCount:H[D]??0,pageStarts:ue.pageStarts,figures:E,figUrl:T},`page-sec-${V.page}`))})]})};function rl(e,n){n.current=Date.now()+800,e.scrollIntoView({behavior:"instant",block:"center",inline:"center"});let i=!1;const o=()=>{i=!0},s=["wheel","touchstart","keydown","mousedown"];s.forEach(a=>window.addEventListener(a,o,{once:!0,passive:!0})),[120,350,700,1100,1500].forEach((a,l,d)=>setTimeout(()=>{if(!i&&e.isConnected){const c=e.getBoundingClientRect();(c.top<80||c.bottom>window.innerHeight-40)&&(n.current=Date.now()+800,e.scrollIntoView({behavior:"instant",block:"center",inline:"center"}))}l===d.length-1&&s.forEach(c=>window.removeEventListener(c,o))},a))}const ol=1800,db=800,pb="auto calc((var(--gtv-pc) / var(--gtv-cpl, 30) + var(--gtv-pp) * 1.4) * var(--gtv-lh, 44px) + 64px)",ub=new Set,yo=[],mb={before:yo,after:yo};function gb(e,n){const i=f.useRef(new Map);return f.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 fb(e){return e==null?void 0:e.find(n=>n.kind==="heading"&&/^#{1,6}$/.test(n.mark))}function hb(e){return e.getAttribute("data-heading-anchor")}function Qn(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}function sl({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 xb(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))}function bb({heading:e,children:n}){if(!e)return t.jsx("p",{className:"guji-reflow-paragraph",children:n});const i=`h${Math.min(6,e.level+1)}`;return t.jsx(i,{className:`guji-reflow-paragraph guji-reflow-heading guji-reflow-h${e.level}`,"data-heading-anchor":e.anchor,"data-heading-level":e.level,"data-heading-toc":e.toc===!1?"0":void 0,children:n})}const yb=f.memo(function({pGroup:n,first:i,pageBreaks:o,markOpts:s,plainBooks:a,selected:l,entityOfChar:d,entityLoader:c,convert:p,buildHref:m,handlers:g,charCount:u,pageStarts:h,figures:x,figUrl:j}){const y=f.useMemo(()=>{const v=new Map;if(!p)return v;for(const $ of n.paragraphs){const _=xb($.chars.map(C=>C.charData.fig?C.charData.char:C.charData.norm??C.charData.char),p);$.chars.forEach((C,I)=>v.set(C.charData.id,C.charData.fig?C.charData.char:_[I]))}return v},[n,p]),S=v=>y.get(v.id)??v.char,{t:b}=ae(),k=v=>{const $=s?Td(v.mark,s):v.mark;return $?t.jsx("span",{className:"guji-text-punct","data-punct-id":v.id,children:$},v.id):null},w=v=>{var $;return($=n.blocks)==null?void 0:$.map((_,C)=>_.before===v&&t.jsx(rb,{fig:_.fig,info:x==null?void 0:x.get(_.fig),figUrl:j,onClick:()=>g.figBlock({page:n.page,fig:_.fig,..._.box?{box:_.box}:{}})},`fig-${_.fig}-${C}`))};return t.jsxs("section",{"data-page-section":n.page,className:"guji-page-section",style:{position:"relative",scrollMarginTop:96,contentVisibility:"auto",containIntrinsicSize:pb,"--gtv-pc":u,"--gtv-pp":n.paragraphs.length},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((v,$)=>t.jsxs(f.Fragment,{children:[w($),t.jsxs(bb,{heading:v.heading,children:[cb(v.chars,d).map((_,C)=>{const I=_.chars.map(({charData:N,beforePuncts:P,afterPuncts:W,start:L},K)=>{var be;const Q=!!_.entity&&K===0,Z=!!_.entity&&K===_.chars.length-1,ue=Q?[]:P,J=Z?[]:W,le=!!N.fig&&K>0&&_.chars[K-1].charData.fig===N.fig;let H=1;if(N.fig&&!le)for(;((be=_.chars[K+H])==null?void 0:be.charData.fig)===N.fig;)H++;const oe=`guji-text-char${l.has(N.id)?" is-selected":""}${N.sub?" is-sub":""}${N.lane==="solo"?" is-solo":""}${L!=null&&L.raised?" is-raised":""}`;return t.jsxs(f.Fragment,{children:[L&&L.blankBefore>0&&t.jsx(sl,{n:L.blankBefore}),ue.map(k),N.fig?t.jsx(ib,{id:N.id,fig:N.fig,info:x==null?void 0:x.get(N.fig),figUrl:j,cells:H,cont:le,className:oe,pageStart:h.get(N.id),children:S(N)}):t.jsx("span",{"data-char-id":N.id,"data-page-start":h.get(N.id),className:`guji-text-char${l.has(N.id)?" is-selected":""}${N.sub?" is-sub":""}${N.lane==="solo"?" is-solo":""}${N.lacuna||N.pending&&N.char==="□"?" is-lacuna":""}${N.pending?" is-pending":""}${N.lacuna&&N.guess_c?" has-guess":""}${N.guess?" is-guess":""}${N.zi?" is-zi":""}${L!=null&&L.raised?" is-raised":""}`,"data-raised":(L==null?void 0:L.raised)||void 0,"data-guji-guess":N.lacuna&&N.guess_c?N.guess_c:void 0,title:N.pending?b("reader.pendingReason",{label:p?p(tl(N.pending)):tl(N.pending)}):N.lacuna?N.guess_c?b("reader.lacunaGuess",{guess:p?p(N.guess_c):N.guess_c}):b("detail.lacuna"):N.zi?b("detail.composedChar",{label:N.zi}):N.guess?b("reader.charGuess"):void 0,children:S(N)}),J.map(k)]},N.id)});if(!_.entity)return t.jsx(f.Fragment,{children:I},`r${C}`);const E=_.chars[0].beforePuncts.map(k),T=_.chars[_.chars.length-1].afterPuncts.map(k);return t.jsxs(f.Fragment,{children:[E,t.jsx(js,{span:_.entity,label:_.chars.map(N=>S(N.charData)).join(""),hasBrackets:!0,plain:a&&_.entity.kind==="work",loader:c,buildHref:m,onNavigate:g.navigate,cardNewTab:!0,renderText:()=>I,hoverDelayMs:250}),T]},`${_.entity.key}@${C}`)}),$===n.paragraphs.length-1&&n.trailingBlank?t.jsx(sl,{n:n.trailingBlank}):null]})]},v.id)),w(n.paragraphs.length)]})});function jo(e){const[n,i]=pi,o=Number.isFinite(e)?e:.33;return Math.round(Math.min(i,Math.max(n,o))*1e3)/1e3}const jb=.02,En=16,vb=4;function kb({y:e,containerRef:n,onDrag:i,onCommit:o}){const{t:s}=ae(),[a,l]=f.useState(0),d=f.useRef(!1),c=f.useRef(null),p=f.useRef(e);p.current=e;const m=f.useCallback(()=>{var j;const u=((j=c.current)==null?void 0:j.parentElement)??n.current,h=(u==null?void 0:u.closest(".bim-rd-col"))??u,x=h==null?void 0:h.getBoundingClientRect();l(Math.max(0,((x==null?void 0:x.left)??0)-En-vb))},[n]);f.useLayoutEffect(()=>{var j;window.addEventListener("resize",m);const u=((j=c.current)==null?void 0:j.parentElement)??n.current,h=(u==null?void 0:u.closest(".bim-rd-col"))??u,x=typeof ResizeObserver<"u"?new ResizeObserver(()=>m()):null;for(const y of[h,u==null?void 0:u.closest(".bim-rd-text"),u==null?void 0:u.closest(".bim-rd-body")])y&&(x==null||x.observe(y));return x||m(),()=>{window.removeEventListener("resize",m),x==null||x.disconnect()}},[m,n]);const g=u=>jo(u/Math.max(1,window.innerHeight));return t.jsx("div",{ref:c,role:"slider",tabIndex:0,className:"guji-page-indicator","aria-label":s("reader.pageIndicator"),"aria-orientation":"vertical","aria-valuemin":Math.round(pi[0]*100),"aria-valuemax":Math.round(pi[1]*100),"aria-valuenow":Math.round(e*100),"data-indicator-y":e,style:{position:"fixed",left:a,top:`calc(${e*100}vh - ${En/2}px)`,width:En,height:En,zIndex:20,cursor:"ns-resize",touchAction:"none",display:"flex",alignItems:"center",justifyContent:"center",color:r("meta-fg")},onPointerDown:u=>{d.current=!0;try{u.currentTarget.setPointerCapture(u.pointerId)}catch{}u.preventDefault()},onPointerMove:u=>{if(!d.current)return;const h=g(u.clientY);p.current=h,i(h)},onPointerUp:u=>{if(d.current){d.current=!1;try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}o(g(u.clientY))}},onPointerCancel:()=>{d.current&&(d.current=!1,o(p.current))},onKeyDown:u=>{const h=u.key==="ArrowUp"?-1:u.key==="ArrowDown"?1:0;h&&(u.preventDefault(),o(jo(e+h*(u.shiftKey?5:1)*jb)))},children:t.jsx("svg",{width:En,height:En,viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M2 8h11M9 4l4 4-4 4"})})})}const Kd=1,qd=6,Ai={s:1,x:0,y:0},Hi=(e,n,i)=>Math.min(i,Math.max(n,e));function ws(e,n,i){const o=Hi(e.s,Kd,qd);return{s:o,x:Hi(e.x,n*(1-o),0),y:Hi(e.y,i*(1-o),0)}}function Gr(e,n,i,o,s,a){const l=Hi(e.s*o,Kd,qd),d=l/e.s;return ws({s:l,x:n-(n-e.x)*d,y:i-(i-e.y)*d},s,a)}function wb(e,n,i,o,s){return ws({s:e.s,x:e.x+n,y:e.y+i},o,s)}function Sb(e,n,i){const o=n===1?e*16:n===2?e*400:e;return Math.exp(-o*(i?.01:.0015))}const al=4,_b=f.forwardRef(function({children:n,onScaleChange:i,resetKey:o,style:s},a){const l=f.useRef(null),[d,c]=f.useState(Ai),p=f.useRef(d),m=f.useRef(i);m.current=i;const g=b=>{var w;const k=p.current;p.current=b,c(b),b.s!==k.s&&((w=m.current)==null||w.call(m,b.s))},u=()=>{var k;const b=(k=l.current)==null?void 0:k.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}};f.useImperativeHandle(a,()=>({zoomBy(b){const{w:k,h:w}=u();g(Gr(p.current,k/2,w/2,b,k,w))},reset(){g(Ai)}})),f.useEffect(()=>{g(Ai)},[o]),f.useEffect(()=>{const b=l.current;if(!b||typeof ResizeObserver>"u")return;const k=new ResizeObserver(()=>{const{w,h:v}=u(),$=ws(p.current,w,v);($.x!==p.current.x||$.y!==p.current.y)&&g($)});return k.observe(b),()=>k.disconnect()},[]),f.useEffect(()=>{const b=l.current;if(!b)return;const k=w=>{const v=Sb(w.deltaY,w.deltaMode,w.ctrlKey);if(p.current.s<=1&&v<1)return;w.preventDefault();const{w:$,h:_,left:C,top:I}=u();g(Gr(p.current,w.clientX-C,w.clientY-I,v,$,_))};return b.addEventListener("wheel",k,{passive:!1}),()=>b.removeEventListener("wheel",k)},[]);const h=f.useRef(new Map),x=f.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),j=b=>{if(b.pointerType==="mouse"&&b.button!==0)return;h.current.set(b.pointerId,{x:b.clientX,y:b.clientY});const k=x.current;if(k.swallowClick=!1,h.current.size===1&&(k.moved=0,k.dragging=!1),h.current.size===2){const[w,v]=[...h.current.values()];k.pinchDist=Math.hypot(w.x-v.x,w.y-v.y),k.moved=al+1}},y=b=>{var N;const k=h.current.get(b.pointerId);if(!k)return;const w={x:b.clientX,y:b.clientY};h.current.set(b.pointerId,w);const v=x.current,{w:$,h:_,left:C,top:I}=u();if(h.current.size>=2){const[P,W]=[...h.current.values()],L=Math.hypot(P.x-W.x,P.y-W.y);if(v.pinchDist>0&&L>0){const K=(P.x+W.x)/2-C,Q=(P.y+W.y)/2-I;g(Gr(p.current,K,Q,L/v.pinchDist,$,_))}v.pinchDist=L,v.swallowClick=!0;return}const E=w.x-k.x,T=w.y-k.y;if(v.moved+=Math.abs(E)+Math.abs(T),!(v.moved<=al)){if(!v.dragging){v.dragging=!0;try{(N=l.current)==null||N.setPointerCapture(b.pointerId)}catch{}}v.swallowClick=!0,p.current.s>1&&g(wb(p.current,E,T,$,_))}},S=b=>{h.current.delete(b.pointerId);const k=x.current;k.pinchDist=0,h.current.size===0&&(k.dragging=!1)};return t.jsx("div",{ref:l,className:"bim-zp","data-zoom":d.s.toFixed(2),onPointerDown:j,onPointerMove:y,onPointerUp:S,onPointerCancel:S,onClickCapture:b=>{x.current.swallowClick&&(x.current.swallowClick=!1,b.stopPropagation(),b.preventDefault())},onDoubleClick:()=>g(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 Xd(e,n,i,o,s=""){const a=`${s}
|
|
1510
|
+
`)},s=a=>{if(a.nodeType===3){i+=a.nodeValue??"";return}if(!(a.nodeType!==1&&a.nodeType!==11)){if(a.nodeType===1){const l=a;if(l.classList.contains("guji-page-divider")||l.style.userSelect==="none")return;const d=l.getAttribute("data-fig-copy");if(d!==null){l.tagName==="FIGURE"?(o(),i+=d,o()):i+=d;return}const c=cb.has(l.tagName);c&&o(),l.childNodes.forEach(s),c&&o();return}a.childNodes.forEach(s)}};return s(n),i.replace(/\n+$/,"")}const pb=e=>`/item/${encodeURIComponent(e)}`;function ub(e){const n=e.filter(i=>i.kind==null||i.kind==="point");return{before:n.filter(i=>i.pos==="before"),after:n.filter(i=>i.pos!=="before")}}function mb(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 Cs=({pageData:e,pages:n,punctuations:i=So,selectedCharIds:o,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:m,convert:g,scrollToPage:u,scrollToAnchor:f,onVisibleHeadingChange:x,entities:j,entityTransport:y,loadEntitySummary:S,buildEntityHref:b,onEntityNavigate:v,pageBreaks:w=!0,pageIndicatorY:k,onPageIndicatorYChange:_,quoteStyle:$,bookTitleStyle:C,showWorks:L,figures:E,figUrl:T,onFigureBlockClick:N})=>{var ct,yt,Xe;const{t:W}=oe(),F=h.useRef(null),R=h.useRef(0),G=h.useMemo(()=>{const V=new Map;return p&&i.forEach((D,B)=>{const ve=D.id?D:{...D,id:`${D.anchor}#${B}`},Re=V.get(ve.anchor)||[];Re.push(ve),V.set(ve.anchor,Re)}),V},[i,p]),Q=h.useMemo(()=>$===void 0&&C===void 0&&L===void 0?null:{quoteStyle:$??"original",hideBookBrackets:C==="wavy"||L===!1},[$,C,L]),ie=C==="bracket",de=h.useMemo(()=>{var Ve;const V=n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}],D=new Map;for(const O of V)for(const ae of O.columns)ae.chars.length>0&&!ae.raised&&D.set(ae.lead_blank||0,(D.get(ae.lead_blank||0)||0)+1);let B=0,ve=-1;for(const[O,ae]of D)(ae>ve||ae===ve&&O<B)&&(B=O,ve=ae);const Re=O=>!!O.raised||(O.lead_blank||0)<B,Ae=V.filter(O=>O.columns.some(ae=>ae.chars.length>0||ae.kind==="figure")).map(O=>{const ae=[...O.columns].sort((dt,Xt)=>dt.col-Xt.col),Fe=[];let Ke=[];const He=()=>{const dt=yb(G.get(Ke[0].charData.id));Fe.push({id:`para-p${O.page}-${Fe.length}`,chars:Ke,...dt?{heading:{level:dt.mark.length,anchor:Ke[0].charData.id,...dt.toc===!1?{toc:!1}:{}}}:{}}),Ke=[]};let Ze=!1,ot=0,ft;const nt=[];for(const dt of ae){if(dt.kind==="figure"&&dt.fig){Ke.length>0?He():Fe.length===0&&(Ze=!0),nt.push({before:Fe.length,fig:dt.fig,...dt.figBox?{box:dt.figBox}:{}}),ot=0;continue}if(dt.chars.length===0){dt.kind==="blank"&&ot++;continue}const Xt=dt.raised||dt.lead_blank||ot?{raised:dt.raised,leadBlank:dt.lead_blank,blankBefore:ot}:void 0;ot=0,Re(dt)||(ft=dt.lead_blank||0);let mt=!0;for(const wt of dt.chars){const Ot=G.get(wt.id),{before:Ct,after:Cr}=Ot?ub(Ot):xb,wi=!!Ot&&Ot.some(hn=>hn.kind==="break"&&hn.pos!=="before");Ot&&Ot.some(hn=>hn.kind==="heading")&&(Ke.length>0?He():Fe.length===0&&(Ze=!0)),Ke.push({charData:wt,col:dt.col,beforePuncts:Ct,afterPuncts:Cr,...mt&&Xt?{start:Xt}:{}}),mt=!1,wi&&He()}}const It=Ke.length>0;return It&&He(),{page:O.page,paragraphs:Fe,endsOpen:It,...ft!==void 0?{tailLead:ft}:{},...Ze?{leadStarts:Ze}:{},...O.label?{label:O.label}:{},...ot>0?{trailingBlank:ot}:{},...nt.length>0?{blocks:nt}:{}}}),Je=new Map;if(!w){let O=null;for(const ae of Ae){const Fe=ae.paragraphs[0],Ke=(Ve=Fe==null?void 0:Fe.chars[0])==null?void 0:Ve.start,He=(Ke==null?void 0:Ke.leadBlank)||0,Ze=!!Ke&&!Ke.raised&&He>=B&&He>((O==null?void 0:O.tailLead)??B),ot=!!ae.leadStarts||!!(Ke!=null&&Ke.blankBefore)||Ze,ft=ae.paragraphs.length===1&&!!ae.trailingBlank;if(O&&Fe&&!ot&&!ft){for(const nt of Fe.chars)Je.set(nt.charData.id,O.owner);O.para.chars=O.para.chars.concat(Fe.chars),ae.leadFirstId=Fe.chars[0].charData.id,ae.paragraphs=ae.paragraphs.slice(1),ae.blocks&&(ae.blocks=ae.blocks.map(nt=>({...nt,before:nt.before-1})))}if(ae.endsOpen&&!ae.trailingBlank){const nt=ae.paragraphs[ae.paragraphs.length-1];nt?O={para:nt,owner:ae.page,tailLead:ae.tailLead??(O==null?void 0:O.tailLead)??B}:O&&ae.tailLead!==void 0&&(O.tailLead=ae.tailLead)}else O=null}}const rt=new Map;for(const O of Ae)O.leadFirstId&&rt.set(O.leadFirstId,O.page);return{pages:Ae,mergedOwner:Je,pageStarts:rt}},[n,e,G,w]),q=de.pages,ee=h.useRef(q);ee.current=q;const U=h.useMemo(()=>q.map(V=>V.paragraphs.reduce((D,B)=>D+B.chars.length,0)),[q]),se=h.useCallback((V,D)=>{let B=V,ve=0;for(;B<U.length&&(B===V||ve+U[B]<=D);)ve+=U[B++];return B},[U]),pe=`${q.length}:${((Xe=(yt=(ct=q[0])==null?void 0:ct.paragraphs[0])==null?void 0:yt.chars[0])==null?void 0:Xe.charData.id)??""}`,[_e,Le]=h.useState(()=>({sig:pe,n:se(0,ul)}));let Ee=_e.n;_e.sig!==pe&&(Ee=se(0,ul),Le({sig:pe,n:Ee})),Ee=Math.min(Ee,q.length);const ue=Ee>=q.length;h.useEffect(()=>ue?void 0:(D=>{const B=window;if(B.requestIdleCallback){const Re=B.requestIdleCallback(D,{timeout:300});return()=>{var Ae;return(Ae=B.cancelIdleCallback)==null?void 0:Ae.call(B,Re)}}const ve=setTimeout(D,16);return()=>clearTimeout(ve)})(()=>Le(D=>D.sig===pe?{sig:D.sig,n:Math.max(D.n,se(D.n,gb))}:D)),[ue,Ee,pe,se]);const be=h.useCallback(V=>{const D=ee.current.findIndex(ve=>ve.page>=V),B=(D<0?ee.current.length:D)+2;Le(ve=>ve.n>=B?ve:{...ve,n:B})},[]),A=ue?q:q.slice(0,Ee);h.useEffect(()=>{let V;const D=requestAnimationFrame(()=>{V=setTimeout(()=>{const B=F.current,ve=B==null?void 0:B.querySelector(".guji-reflow-paragraph");if(!B||!ve)return;const Re=getComputedStyle(ve),Ae=parseFloat(Re.fontSize),Je=ve.clientWidth;if(!(Ae>0)||!(Je>0))return;const rt=parseFloat(Re.lineHeight);B.style.setProperty("--gtv-cpl",String(Math.max(8,Math.floor(Je/Ae)))),B.style.setProperty("--gtv-lh",`${Math.round(rt>0?rt:Ae*2)}px`)},0)});return()=>{cancelAnimationFrame(D),V&&clearTimeout(V)}},[pe]);const K=h.useMemo(()=>{const V=[];for(const D of q)for(const B of D.paragraphs)for(const ve of B.chars)V.push(ve.charData.id);return V},[q]),le=h.useMemo(()=>new Map(K.map((V,D)=>[V,D])),[K]),M=h.useMemo(()=>{const V=new Map;if(!j||j.length===0)return V;const D=le;for(const B of j){if(!B.anchor)continue;const ve=D.get(B.anchor.start),Re=D.get(B.anchor.end);if(!(ve===void 0||Re===void 0||Re<ve))for(let Ae=ve;Ae<=Re;Ae++)V.has(K[Ae])||V.set(K[Ae],B)}return V},[j,K,le]),J=h.useMemo(()=>{const V=f==null?void 0:f.anchor;return V&&V.startsWith("e=")?new Set(V.slice(2).split(",").filter(Boolean)):null},[f==null?void 0:f.anchor]),ye=h.useMemo(()=>{var ve;if(!J||!j)return[];const V=new Set,D=[],B=(Re,Ae)=>{const Je=`${Re}:${Ae}`;V.has(Je)||(V.add(Je),D.push([Re,Ae]))};for(const Re of j){if(!Re.anchor)continue;const Ae=le.get(Re.anchor.start),Je=le.get(Re.anchor.end);if(!(Ae===void 0||Je===void 0||Je<Ae)){(Re.targetId&&J.has(Re.targetId)||(ve=Re.targets)!=null&&ve.some(rt=>J.has(rt.id)))&&B(Ae,Je);for(const rt of Re.parts??[]){if(!J.has(rt.id))continue;const Ve=Ae+rt.offset[0],O=Ae+rt.offset[1]-1;O>=Ve&&O<=Je&&B(Ve,O)}}}return D.sort((Re,Ae)=>Re[0]-Ae[0]||Re[1]-Ae[1])},[J,j,le]),je=Ss(y,S),Ue=M.size>0,H=h.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:m,onEntityNavigate:v,onVisibleHeadingChange:x,onFigureBlockClick:N});H.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:m,onEntityNavigate:v,onVisibleHeadingChange:x,onFigureBlockClick:N};const me=h.useMemo(()=>({click:V=>{var D,B;R.current=Date.now()+1200,(B=(D=H.current).onCharClick)==null||B.call(D,V)},enter:V=>{var D,B;return(B=(D=H.current).onCharHover)==null?void 0:B.call(D,V)},leave:()=>{var V,D;return(D=(V=H.current).onCharHover)==null?void 0:D.call(V,null)},figBlock:V=>{var D,B;return(B=(D=H.current).onFigureBlockClick)==null?void 0:B.call(D,V)},navigate:(V,D)=>{D.ctrlKey||D.metaKey||D.shiftKey||(D.preventDefault(),D.detail===0&&window.open(D.currentTarget.href,"_blank","noopener"))}}),[]),ge=bb(o,de.mergedOwner),ne=h.useRef(Ee);ne.current=Ee;const Ne=h.useRef(null),he=h.useCallback(V=>{const D=Ne.current,B=D==null?void 0:D.map.get(V);if(B&&B.isConnected)return B;if(D&&D.for===ee.current&&D.n===ne.current&&!B)return null;const ve=F.current;if(!ve)return null;const Re=new Map;return ve.querySelectorAll("span[data-char-id]").forEach(Ae=>{Re.set(Ae.getAttribute("data-char-id"),Ae)}),Ne.current={for:ee.current,n:ne.current,map:Re},Re.get(V)??null},[]),Ce=h.useRef(null);h.useEffect(()=>{var D;if((D=Ce.current)==null||D.classList.remove("is-hovered"),Ce.current=null,!s)return;const V=he(s);V&&(V.classList.add("is-hovered"),Ce.current=V)},[s,he]);const Ie=h.useRef(null),Qe=V=>{var B;const D=V instanceof Element?V.closest("span[data-char-id]"):null;return D&&((B=F.current)!=null&&B.contains(D))?D.getAttribute("data-char-id"):null},gt=V=>{const D=Qe(V.target);D&&me.click(D)},lt=V=>{const D=Qe(V.target);D!==Ie.current&&(Ie.current=D,D?me.enter(D):me.leave())},tt=V=>{const D=typeof window<"u"?window.getSelection():null;if(!D||D.isCollapsed||D.rangeCount===0)return;const B=db(D.getRangeAt(0));B!==null&&(V.clipboardData.setData("text/plain",B),V.preventDefault())},Oe=()=>{Ie.current!==null&&(Ie.current=null,me.leave())};h.useEffect(()=>{let V=null;const D=()=>{var ot,ft;V=null;const ve=window.getSelection(),Re=F.current;if(!ve||ve.isCollapsed||ve.rangeCount===0||!Re)return;const Ae=ve.getRangeAt(0),Je=Ae.commonAncestorContainer,rt=Je.nodeType===3?Je.parentElement:Je;if(!rt||!Re.contains(rt))return;const Ve=Re.querySelectorAll("span[data-char-id]"),O=nt=>{let It=nt;for(;It.nodeType!==3&&It.firstChild;)It=It.firstChild;return It};let ae=0,Fe=Ve.length;for(;ae<Fe;){const nt=ae+Fe>>1;Ae.comparePoint(O(Ve[nt]),0)<0?ae=nt+1:Fe=nt}const Ke=ae;for(Fe=Ve.length;ae<Fe;){const nt=ae+Fe>>1;Ae.comparePoint(O(Ve[nt]),0)<=0?ae=nt+1:Fe=nt}let He=ae-1;if(He>=Ke&&Ae.endOffset===0&&Ae.endContainer===O(Ve[He])&&He--,He<Ke)return;const Ze=[];for(let nt=Ke;nt<=He;nt++)Ze.push(Ve[nt].getAttribute("data-char-id"));Ze.length>0&&(R.current=Date.now()+1200,(ft=(ot=H.current).onSelectionChange)==null||ft.call(ot,Ze))},B=()=>{V&&clearTimeout(V),V=setTimeout(D,120)};return document.addEventListener("selectionchange",B),()=>{document.removeEventListener("selectionchange",B),V&&clearTimeout(V)}},[]);const z=h.useRef(null);h.useEffect(()=>{if(o.size!==1||z.current===o)return;const V=Array.from(o)[0],D=he(V);if(D)z.current=o,D.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"});else{const B=parseInt(V.split(":")[0],10);isNaN(B)||be(B)}},[o,Ee,he,be]);const re=V=>{var ve;const D=F.current;if(!D)return null;const B=(ve=q.find(Re=>Re.page===V))==null?void 0:ve.leadFirstId;return B?D.querySelector(`span[data-char-id="${B}"]`):D.querySelector(`[data-page-section="${V}"]`)},te=u==null?void 0:u.nonce,fe=h.useRef(null);h.useEffect(()=>{if(!u||fe.current===u.nonce)return;const V=re(u.page);if(!V){!ue&&q.some(D=>D.page>=u.page)&&be(u.page);return}fe.current=u.nonce,R.current=Date.now()+800,V.scrollIntoView({behavior:"auto",block:"start"})},[te,Ee]);const Me=h.useRef(null),P=h.useRef([]);h.useEffect(()=>{var Ae,Je,rt;if(!f||Me.current===f.nonce||f.anchor.startsWith("e="))return;const[V,D]=f.anchor.split("~"),B=F.current,ve=B==null?void 0:B.querySelector(`span[data-char-id="${ni(V)}"]`),Re=parseInt(V.split(":")[0],10);if(!ve){if(!ue&&!isNaN(Re)&&q.some(Ve=>Ve.page>=Re)){be(Re);return}D&&!isNaN(Re)&&(Me.current=f.nonce,(Ae=re(Re))==null||Ae.scrollIntoView({behavior:"auto",block:"start"}));return}Me.current=f.nonce,R.current=Date.now()+800;for(const Ve of P.current)Ve.classList.remove("guji-hl");if(P.current=[],D){const Ve=le.get(V),O=le.get(D);if(Ve!==void 0&&O!==void 0&&O>=Ve&&O-Ve<64)for(let ae=Ve;ae<=O;ae++){const Fe=B==null?void 0:B.querySelector(`span[data-char-id="${ni(K[ae])}"]`);Fe&&(Fe.classList.add("guji-hl"),P.current.push(Fe))}pl(ve,R)}else(ve.closest(".guji-reflow-paragraph")??ve).scrollIntoView({behavior:"auto",block:"start"});isNaN(Re)||(rt=(Je=H.current).onVisiblePageChange)==null||rt.call(Je,Re)},[f,q,Ee,ue,be,K,le]);const[ce,X]=h.useState(null),[Te,Se]=h.useState(!1),ze=h.useRef(null);h.useEffect(()=>{!f||!J||ze.current===f.nonce||ye.length===0||(ze.current=f.nonce,Se(!1),X({k:0,nonce:Date.now()}))},[f,J,ye]);const qe=h.useRef(null);h.useEffect(()=>{var Ae,Je;if(!ce||qe.current===ce.nonce)return;const V=ye[ce.k];if(!V)return;const D=F.current,B=K[V[0]],ve=D==null?void 0:D.querySelector(`span[data-char-id="${ni(B)}"]`),Re=parseInt(B.split(":")[0],10);if(!ve){!ue&&!isNaN(Re)&&be(Re);return}qe.current=ce.nonce;for(const rt of P.current)rt.classList.remove("guji-hl");P.current=[];for(let rt=V[0];rt<=V[1];rt++){const Ve=D==null?void 0:D.querySelector(`span[data-char-id="${ni(K[rt])}"]`);Ve&&(Ve.classList.add("guji-hl"),P.current.push(Ve))}pl(ve,R),isNaN(Re)||(Je=(Ae=H.current).onVisiblePageChange)==null||Je.call(Ae,Re)},[ce,ye,K,Ee,ue,be]);const Pe=h.useMemo(()=>{if(!J||Te||ye.length===0)return"";const V=[];for(const[D,B]of ye)for(let ve=D;ve<=B;ve++)V.push(`.guji-text-pane-content span[data-char-id="${ni(K[ve])}"]`);return`${V.join(",")}{background:${r("mark-soft")};border-radius:2px}`},[J,Te,ye,K]),it=V=>X(D=>{const B=ye.length;return{k:(((D==null?void 0:D.k)??0)+V+B)%B,nonce:Date.now()}}),pt=()=>{Se(!0);for(const V of P.current)V.classList.remove("guji-hl");P.current=[]},Z=!!m||!!x,$e=!!m&&typeof k=="number",[ke,Ye]=h.useState(null),We=$o(ke??k??0),De=h.useRef(null);De.current=$e?We:null;const ht=h.useRef(()=>{});return h.useEffect(()=>{var Fe,Ke;if(!Z)return;const V=new Map,D=new Map;(Fe=F.current)==null||Fe.querySelectorAll("[data-page-section],[data-page-start]").forEach(He=>{const Ze=He.getAttribute("data-page-section");Ze!==null?V.set(Ze,He):D.set(He.getAttribute("data-page-start"),He)});const B=[],ve=[];for(const He of A){const Ze=V.get(String(He.page));Ze&&(B.push(Ze),ve.push(He.page))}if(B.length===0)return;const Re=new Map(B.map((He,Ze)=>[He,Ze])),Ae=B.map(()=>[]);let Je=0;(Ke=F.current)==null||Ke.querySelectorAll('.guji-reflow-heading:not([data-heading-toc="0"])').forEach(He=>{const Ze=Re.get(He.closest("[data-page-section]"));Ze!==void 0&&(Ae[Ze].push(He),Je++)});let rt,Ve=0;const O=()=>{var dt,Xt;if(Ve=0,Date.now()<R.current)return;const He=mt=>mt.getBoundingClientRect().top;if(B.length>1&&He(B[0])===He(B[B.length-1]))return;const Ze=De.current===null?120:De.current*window.innerHeight;let ot=0,ft=B.length-1;for(;ot<ft;){const mt=ot+ft+1>>1;He(B[mt])<=Ze?ot=mt:ft=mt-1}const nt=He(B[0])>Ze;let It=ve[ot];for(let mt=ot+1;mt<B.length;mt++){const wt=D.get(String(ve[mt]));if(!wt||!B[ot].contains(wt)||He(wt)>Ze)break;It=ve[mt]}if(Je>0&&H.current.onVisibleHeadingChange){let mt=null;if(!nt){const Ot=Ae[ot];for(let Ct=Ot.length-1;Ct>=0&&!mt;Ct--)He(Ot[Ct])<=Ze&&(mt=Ot[Ct]);for(let Ct=ot-1;Ct>=0&&!mt;Ct--)Ae[Ct].length>0&&(mt=Ae[Ct][Ae[Ct].length-1])}const wt=mt?jb(mt):null;wt!==rt&&(rt=wt,H.current.onVisibleHeadingChange(wt))}(Xt=(dt=H.current).onVisiblePageChange)==null||Xt.call(dt,It)},ae=()=>{Ve||(Ve=requestAnimationFrame(O))};return ht.current=()=>{Ve||(Ve=requestAnimationFrame(O))},window.addEventListener("scroll",ae,{passive:!0}),ae(),()=>{window.removeEventListener("scroll",ae),Ve&&cancelAnimationFrame(Ve),ht.current=()=>{}}},[Z,q,Ee]),h.useEffect(()=>{$e&&ht.current()},[$e,We]),t.jsxs("div",{ref:F,className:"guji-text-pane-content",onClick:gt,onMouseOver:lt,onMouseLeave:Oe,onCopy:tt,children:[Ue&&t.jsx("style",{children:ks}),Pe&&t.jsx("style",{children:Pe}),Pe&&ce&&t.jsxs("div",{className:"bim-rd-mnav bim-d-ui",role:"navigation","aria-label":W("mentions.navLabel"),children:[t.jsx("span",{children:W("mentions.navCount",{k:ce.k+1,n:ye.length})}),t.jsx("button",{type:"button",onClick:()=>it(-1),"aria-label":W("mentions.prev"),title:W("mentions.prev"),children:"‹"}),t.jsx("button",{type:"button",onClick:()=>it(1),"aria-label":W("mentions.next"),title:W("mentions.next"),children:"›"}),t.jsx("button",{type:"button",onClick:pt,"aria-label":W("mentions.close"),title:W("mentions.close"),children:"×"})]}),$e&&t.jsx(_b,{y:We,containerRef:F,onDrag:Ye,onCommit:V=>{Ye(null),_==null||_(V)}}),t.jsx("div",{className:"guji-text-reflow-view",children:A.map((V,D)=>t.jsx(wb,{pGroup:V,first:D===0,pageBreaks:w,markOpts:Q,plainBooks:ie,selected:ge.get(V.page)??fb,entityOfChar:M,entityLoader:je,convert:g,buildHref:b??pb,handlers:me,charCount:U[D]??0,pageStarts:de.pageStarts,figures:E,figUrl:T},`page-sec-${V.page}`))})]})};function pl(e,n){n.current=Date.now()+800,e.scrollIntoView({behavior:"instant",block:"center",inline:"center"});let i=!1;const o=()=>{i=!0},s=["wheel","touchstart","keydown","mousedown"];s.forEach(a=>window.addEventListener(a,o,{once:!0,passive:!0})),[120,350,700,1100,1500].forEach((a,l,d)=>setTimeout(()=>{if(!i&&e.isConnected){const c=e.getBoundingClientRect();(c.top<80||c.bottom>window.innerHeight-40)&&(n.current=Date.now()+800,e.scrollIntoView({behavior:"instant",block:"center",inline:"center"}))}l===d.length-1&&s.forEach(c=>window.removeEventListener(c,o))},a))}const ul=1800,gb=800,hb="auto calc((var(--gtv-pc) / var(--gtv-cpl, 30) + var(--gtv-pp) * 1.4) * var(--gtv-lh, 44px) + 64px)",fb=new Set,So=[],xb={before:So,after:So};function bb(e,n){const i=h.useRef(new Map);return h.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 yb(e){return e==null?void 0:e.find(n=>n.kind==="heading"&&/^#{1,6}$/.test(n.mark))}function jb(e){return e.getAttribute("data-heading-anchor")}function ni(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}function ml({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 vb(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))}function kb({heading:e,children:n}){if(!e)return t.jsx("p",{className:"guji-reflow-paragraph",children:n});const i=`h${Math.min(6,e.level+1)}`;return t.jsx(i,{className:`guji-reflow-paragraph guji-reflow-heading guji-reflow-h${e.level}`,"data-heading-anchor":e.anchor,"data-heading-level":e.level,"data-heading-toc":e.toc===!1?"0":void 0,children:n})}const wb=h.memo(function({pGroup:n,first:i,pageBreaks:o,markOpts:s,plainBooks:a,selected:l,entityOfChar:d,entityLoader:c,convert:p,buildHref:m,handlers:g,charCount:u,pageStarts:f,figures:x,figUrl:j}){const y=h.useMemo(()=>{const k=new Map;if(!p)return k;for(const _ of n.paragraphs){const $=vb(_.chars.map(C=>C.charData.fig?C.charData.char:C.charData.norm??C.charData.char),p);_.chars.forEach((C,L)=>k.set(C.charData.id,C.charData.fig?C.charData.char:$[L]))}return k},[n,p]),S=k=>y.get(k.id)??k.char,{t:b}=oe(),v=k=>{const _=s?Bd(k.mark,s):k.mark;return _?t.jsx("span",{className:"guji-text-punct","data-punct-id":k.id,children:_},k.id):null},w=k=>{var _;return(_=n.blocks)==null?void 0:_.map(($,C)=>$.before===k&&t.jsx(lb,{fig:$.fig,info:x==null?void 0:x.get($.fig),figUrl:j,onClick:()=>g.figBlock({page:n.page,fig:$.fig,...$.box?{box:$.box}:{}})},`fig-${$.fig}-${C}`))};return t.jsxs("section",{"data-page-section":n.page,className:"guji-page-section",style:{position:"relative",scrollMarginTop:96,contentVisibility:"auto",containIntrinsicSize:hb,"--gtv-pc":u,"--gtv-pp":n.paragraphs.length},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((k,_)=>t.jsxs(h.Fragment,{children:[w(_),t.jsxs(kb,{heading:k.heading,children:[mb(k.chars,d).map(($,C)=>{const L=$.chars.map(({charData:N,beforePuncts:W,afterPuncts:F,start:R},G)=>{var pe;const Q=!!$.entity&&G===0,ie=!!$.entity&&G===$.chars.length-1,de=Q?[]:W,q=ie?[]:F,ee=!!N.fig&&G>0&&$.chars[G-1].charData.fig===N.fig;let U=1;if(N.fig&&!ee)for(;((pe=$.chars[G+U])==null?void 0:pe.charData.fig)===N.fig;)U++;const se=`guji-text-char${l.has(N.id)?" is-selected":""}${N.sub?" is-sub":""}${N.lane==="solo"?" is-solo":""}${R!=null&&R.raised?" is-raised":""}`;return t.jsxs(h.Fragment,{children:[R&&R.blankBefore>0&&t.jsx(ml,{n:R.blankBefore}),de.map(v),N.fig?t.jsx(ab,{id:N.id,fig:N.fig,info:x==null?void 0:x.get(N.fig),figUrl:j,cells:U,cont:ee,className:se,pageStart:f.get(N.id),children:S(N)}):t.jsx("span",{"data-char-id":N.id,"data-page-start":f.get(N.id),className:`guji-text-char${l.has(N.id)?" is-selected":""}${N.sub?" is-sub":""}${N.lane==="solo"?" is-solo":""}${N.lacuna||N.pending&&N.char==="□"?" is-lacuna":""}${N.pending?" is-pending":""}${N.lacuna&&N.guess_c?" has-guess":""}${N.guess?" is-guess":""}${N.zi?" is-zi":""}${R!=null&&R.raised?" is-raised":""}`,"data-raised":(R==null?void 0:R.raised)||void 0,"data-guji-guess":N.lacuna&&N.guess_c?N.guess_c:void 0,title:N.pending?b("reader.pendingReason",{label:p?p(xe.pendingReasonLabel(N.pending)):xe.pendingReasonLabel(N.pending)}):N.lacuna?N.guess_c?b("reader.lacunaGuess",{guess:p?p(N.guess_c):N.guess_c}):b("detail.lacuna"):N.zi?b("detail.composedChar",{label:N.zi}):N.guess?b("reader.charGuess"):void 0,children:S(N)}),q.map(v)]},N.id)});if(!$.entity)return t.jsx(h.Fragment,{children:L},`r${C}`);const E=$.chars[0].beforePuncts.map(v),T=$.chars[$.chars.length-1].afterPuncts.map(v);return t.jsxs(h.Fragment,{children:[E,t.jsx($s,{span:$.entity,label:$.chars.map(N=>S(N.charData)).join(""),hasBrackets:!0,plain:a&&$.entity.kind==="work",loader:c,buildHref:m,onNavigate:g.navigate,cardNewTab:!0,renderText:()=>L,hoverDelayMs:250}),T]},`${$.entity.key}@${C}`)}),_===n.paragraphs.length-1&&n.trailingBlank?t.jsx(ml,{n:n.trailingBlank}):null]})]},k.id)),w(n.paragraphs.length)]})});function $o(e){const[n,i]=gi,o=Number.isFinite(e)?e:.33;return Math.round(Math.min(i,Math.max(n,o))*1e3)/1e3}const Sb=.02,En=16,$b=4;function _b({y:e,containerRef:n,onDrag:i,onCommit:o}){const{t:s}=oe(),[a,l]=h.useState(0),d=h.useRef(!1),c=h.useRef(null),p=h.useRef(e);p.current=e;const m=h.useCallback(()=>{var j;const u=((j=c.current)==null?void 0:j.parentElement)??n.current,f=(u==null?void 0:u.closest(".bim-rd-col"))??u,x=f==null?void 0:f.getBoundingClientRect();l(Math.max(0,((x==null?void 0:x.left)??0)-En-$b))},[n]);h.useLayoutEffect(()=>{var j;window.addEventListener("resize",m);const u=((j=c.current)==null?void 0:j.parentElement)??n.current,f=(u==null?void 0:u.closest(".bim-rd-col"))??u,x=typeof ResizeObserver<"u"?new ResizeObserver(()=>m()):null;for(const y of[f,u==null?void 0:u.closest(".bim-rd-text"),u==null?void 0:u.closest(".bim-rd-body")])y&&(x==null||x.observe(y));return x||m(),()=>{window.removeEventListener("resize",m),x==null||x.disconnect()}},[m,n]);const g=u=>$o(u/Math.max(1,window.innerHeight));return t.jsx("div",{ref:c,role:"slider",tabIndex:0,className:"guji-page-indicator","aria-label":s("reader.pageIndicator"),"aria-orientation":"vertical","aria-valuemin":Math.round(gi[0]*100),"aria-valuemax":Math.round(gi[1]*100),"aria-valuenow":Math.round(e*100),"data-indicator-y":e,style:{position:"fixed",left:a,top:`calc(${e*100}vh - ${En/2}px)`,width:En,height:En,zIndex:20,cursor:"ns-resize",touchAction:"none",display:"flex",alignItems:"center",justifyContent:"center",color:r("meta-fg")},onPointerDown:u=>{d.current=!0;try{u.currentTarget.setPointerCapture(u.pointerId)}catch{}u.preventDefault()},onPointerMove:u=>{if(!d.current)return;const f=g(u.clientY);p.current=f,i(f)},onPointerUp:u=>{if(d.current){d.current=!1;try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}o(g(u.clientY))}},onPointerCancel:()=>{d.current&&(d.current=!1,o(p.current))},onKeyDown:u=>{const f=u.key==="ArrowUp"?-1:u.key==="ArrowDown"?1:0;f&&(u.preventDefault(),o($o(e+f*(u.shiftKey?5:1)*Sb)))},children:t.jsx("svg",{width:En,height:En,viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M2 8h11M9 4l4 4-4 4"})})})}const np=1,ip=6,Pi={s:1,x:0,y:0},Vi=(e,n,i)=>Math.min(i,Math.max(n,e));function zs(e,n,i){const o=Vi(e.s,np,ip);return{s:o,x:Vi(e.x,n*(1-o),0),y:Vi(e.y,i*(1-o),0)}}function Jr(e,n,i,o,s,a){const l=Vi(e.s*o,np,ip),d=l/e.s;return zs({s:l,x:n-(n-e.x)*d,y:i-(i-e.y)*d},s,a)}function Cb(e,n,i,o,s){return zs({s:e.s,x:e.x+n,y:e.y+i},o,s)}function zb(e,n,i){const o=n===1?e*16:n===2?e*400:e;return Math.exp(-o*(i?.01:.0015))}const gl=4,Nb=h.forwardRef(function({children:n,onScaleChange:i,resetKey:o,style:s},a){const l=h.useRef(null),[d,c]=h.useState(Pi),p=h.useRef(d),m=h.useRef(i);m.current=i;const g=b=>{var w;const v=p.current;p.current=b,c(b),b.s!==v.s&&((w=m.current)==null||w.call(m,b.s))},u=()=>{var v;const b=(v=l.current)==null?void 0:v.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}};h.useImperativeHandle(a,()=>({zoomBy(b){const{w:v,h:w}=u();g(Jr(p.current,v/2,w/2,b,v,w))},reset(){g(Pi)}})),h.useEffect(()=>{g(Pi)},[o]),h.useEffect(()=>{const b=l.current;if(!b||typeof ResizeObserver>"u")return;const v=new ResizeObserver(()=>{const{w,h:k}=u(),_=zs(p.current,w,k);(_.x!==p.current.x||_.y!==p.current.y)&&g(_)});return v.observe(b),()=>v.disconnect()},[]),h.useEffect(()=>{const b=l.current;if(!b)return;const v=w=>{const k=zb(w.deltaY,w.deltaMode,w.ctrlKey);if(p.current.s<=1&&k<1)return;w.preventDefault();const{w:_,h:$,left:C,top:L}=u();g(Jr(p.current,w.clientX-C,w.clientY-L,k,_,$))};return b.addEventListener("wheel",v,{passive:!1}),()=>b.removeEventListener("wheel",v)},[]);const f=h.useRef(new Map),x=h.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),j=b=>{if(b.pointerType==="mouse"&&b.button!==0)return;f.current.set(b.pointerId,{x:b.clientX,y:b.clientY});const v=x.current;if(v.swallowClick=!1,f.current.size===1&&(v.moved=0,v.dragging=!1),f.current.size===2){const[w,k]=[...f.current.values()];v.pinchDist=Math.hypot(w.x-k.x,w.y-k.y),v.moved=gl+1}},y=b=>{var N;const v=f.current.get(b.pointerId);if(!v)return;const w={x:b.clientX,y:b.clientY};f.current.set(b.pointerId,w);const k=x.current,{w:_,h:$,left:C,top:L}=u();if(f.current.size>=2){const[W,F]=[...f.current.values()],R=Math.hypot(W.x-F.x,W.y-F.y);if(k.pinchDist>0&&R>0){const G=(W.x+F.x)/2-C,Q=(W.y+F.y)/2-L;g(Jr(p.current,G,Q,R/k.pinchDist,_,$))}k.pinchDist=R,k.swallowClick=!0;return}const E=w.x-v.x,T=w.y-v.y;if(k.moved+=Math.abs(E)+Math.abs(T),!(k.moved<=gl)){if(!k.dragging){k.dragging=!0;try{(N=l.current)==null||N.setPointerCapture(b.pointerId)}catch{}}k.swallowClick=!0,p.current.s>1&&g(Cb(p.current,E,T,_,$))}},S=b=>{f.current.delete(b.pointerId);const v=x.current;v.pinchDist=0,f.current.size===0&&(v.dragging=!1)};return t.jsx("div",{ref:l,className:"bim-zp","data-zoom":d.s.toFixed(2),onPointerDown:j,onPointerMove:y,onPointerUp:S,onPointerCancel:S,onClickCapture:b=>{x.current.swallowClick&&(x.current.swallowClick=!1,b.stopPropagation(),b.preventDefault())},onDoubleClick:()=>g(Pi),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 rp(e,n,i,o,s=""){const a=`${s}
|
|
1511
1511
|
${o.versionKey??""}
|
|
1512
|
-
${i??""}`,[l,d]=
|
|
1512
|
+
${i??""}`,[l,d]=h.useState({tag:"",data:null}),c=h.useRef(0);if(h.useEffect(()=>{if(n!==void 0)return;const m=++c.current,g=u=>{m===c.current&&d({tag:a,data:u})};if(!i)return g(null);if(e){let u;try{u=e(i,o)}catch{return g(null)}if(!u||typeof u.then!="function")return g(u??null);u.then(f=>g(f??null),()=>g(null));return}g(null)},[e,n,i,o,a]),n!==void 0)return{warpData:n,loading:!1};const p=l.tag===a;return{warpData:p?l.data:null,loading:!!e&&!!i&&!p}}function Tb(e,n,i,o=""){const s=`${o}
|
|
1513
1513
|
${i.versionKey??""}
|
|
1514
|
-
${n??""}`,[a,l]=
|
|
1515
|
-
${
|
|
1516
|
-
${
|
|
1517
|
-
${
|
|
1518
|
-
${
|
|
1519
|
-
${
|
|
1520
|
-
${
|
|
1521
|
-
${
|
|
1522
|
-
${
|
|
1523
|
-
${
|
|
1524
|
-
${U??""}`,[St,Lt]=f.useState({key:dt,data:ce,started:!!ce});if(St.key!==dt)Lt({key:dt,data:ce,started:!1});else if(ce!==St.data&&(Lt({key:dt,data:ce,started:!!ce}),ce)){const A=ce.pages??[];(!St.started||!A.some(ie=>ie.page===We))&&Nt(zt(ce))}f.useEffect(()=>{Ne(new Set),Ue.set(null)},[U,R,Ue]);const _t=St.key===dt&&St.started,ji=!!pe&&vo(pe.headings).length===0,vi=f.useMemo(()=>ji&&_t&&ce?Zd(ce.pages,ce.punctuations):[],[ji,_t,ce]),an=f.useCallback(A=>{const ie=vo(A.headings);return ie.length>0?ie:A.file===U?vi:[]},[U,vi]),Nu=f.useCallback(A=>{if(Ne(new Set(A)),A.length>0){const ie=A[0],Re=parseInt(ie.split(":")[0],10);isNaN(Re)||Nt(Re)}},[]),Xt=f.useMemo(()=>{const A=new Map;for(const ie of(ce==null?void 0:ce.pages)??[])A.set(ie.page,ie);return A},[ce]),Yn=ot(ce),ki=f.useCallback(A=>{var mt;const ie=De.images;if(!ie||ie.length===0)return;const Re=(mt=Xt.get(A))==null?void 0:mt.seq;return(Re?ie.find(tt=>tt.seq===Re):void 0)??ie.find(tt=>tt.pageNo===A)??ie[A-1]},[De.images,Xt]),Fs=Oe>1.5,wi=f.useCallback((A,ie=!1)=>{const Re=ki(A);return Re?A===Yn||ie?Re.hiresUrl??Re.url:Re.url:A===Yn?(ce==null?void 0:ce.imageUrl)??"":""},[ki,ce,Yn]),Tu=f.useMemo(()=>wi(We,Fs),[wi,We,Fs]),Zt=f.useMemo(()=>[...Xt.keys()].sort((A,ie)=>A-ie),[Xt]),hn=f.useRef(We);hn.current=We;const Sr=f.useRef(0),_r=f.useRef({page:null,timer:null}),Eu=f.useCallback(A=>{const ie=_r.current;A!==ie.page&&(ie.timer&&(clearTimeout(ie.timer),ie.timer=null),ie.page=null,!(A===hn.current||Date.now()<Sr.current)&&(ie.page=A,ie.timer=setTimeout(()=>{ie.timer=null,ie.page=null,!(Date.now()<Sr.current||hn.current===A)&&(hn.current=A,Nt(A))},Eb)))},[]);f.useEffect(()=>()=>{_r.current.timer&&clearTimeout(_r.current.timer)},[]);const Si=f.useCallback(A=>{var ie;hn.current===A||!Xt.has(A)||(Sr.current=Date.now()+1e3,hn.current=A,Nt(A),(ie=Xt.get(A))!=null&&ie.columns.some(Re=>Re.chars.length>0)&&jt(Re=>({page:A,nonce:((Re==null?void 0:Re.nonce)??0)+1})))},[Xt]),Kn=f.useCallback(A=>{const ie=hn.current,Re=Zt.indexOf(ie),mt=Zt[Re<0?0:Re+A];mt===void 0||mt===ie||Si(mt)},[Zt,Si]),Hs=f.useCallback(A=>{if(!A.trim().match(/^\d+$/)||Zt.length===0)return null;const Re=parseInt(A.trim(),10),mt=Number.isFinite(Re)?Re:Number.MAX_SAFE_INTEGER;return Zt.reduce((tt,Ht)=>Math.abs(Ht-mt)<Math.abs(tt-mt)?Ht:tt,Zt[0])},[Zt]),[$r,Cr]=f.useState(null),_i=f.useRef(null),Ru=f.useCallback(A=>{_i.current=A,Cr(A)},[]),Ds=f.useCallback(()=>{const A=_i.current;if(_i.current=null,Cr(null),A===null)return;const ie=Hs(A);ie!==null&&Si(ie)},[Hs,Si]),zr=Zt.indexOf(We),Iu=f.useCallback(A=>{if(A.altKey||A.ctrlKey||A.metaKey)return;const ie=A.target.tagName;ie==="INPUT"||ie==="TEXTAREA"||ie==="SELECT"||(A.key==="ArrowLeft"||A.key==="PageUp"?(A.preventDefault(),Kn(-1)):(A.key==="ArrowRight"||A.key==="PageDown")&&(A.preventDefault(),Kn(1)))},[Kn]),Us=f.useRef(null);f.useEffect(()=>{if(!ce)return;const A=Us.current;if(!(!A||A.offsetWidth===0))for(const ie of[1,-1]){const Re=wi(We+ie);Re&&xo(Re)}},[ce,We,wi]);const Vs=f.useMemo(()=>{var ia;if(!ce)return null;if(We===Yn)return ce;const A=Xt.get(We);if(A&&A.width>0&&A.height>0)return{page_id:`p:${We}`,title:`第${We}葉`,image_size:[A.width,A.height],total_warped_w:A.width,columns:[{col:1,warped_w:A.width,warped_h:A.height,offset_x:0,strips:[],chars:A.columns.flatMap(st=>st.chars).map(st=>({id:st.id,char:st.char,slot:st.slot,pos:st.pos,sub:st.sub,bbox_col:st.bbox??[0,0,0,0]}))}],...A.columns.some(st=>st.kind==="figure"&&st.figBox)?{figBlocks:A.columns.filter(st=>st.kind==="figure"&&st.figBox).map(st=>({id:st.fig,box:st.figBox}))}:{}};const ie=(ia=ce.pages)==null?void 0:ia.find(st=>st.page===We),[Re,mt]=ce.image_size||[2386,3082];if(!(Re>0&&mt>0))return null;const tt=ki(We),Ht=(tt==null?void 0:tt.width)??Re,Ir=(tt==null?void 0:tt.height)??mt,ea=Ht/Re,ta=Ir/mt,na=new Map;for(const st of ce.columns){const Mt=(st.strips||[]).flatMap(Ti=>Ti.srcQuad.map(Ei=>Ei[0]));if(Mt.length===0)continue;const Jt=st.top_y??0,Lr=st.bottom_y??Jt+st.warped_h;na.set(st.col,{x0:Math.min(...Mt),x1:Math.max(...Mt),top:Jt,slotH:(Lr-Jt)/21})}return{page_id:`p:${We}`,title:`第${We}葉`,image_size:[Ht,Ir],total_warped_w:Ht,columns:ie?ie.columns.map(st=>{const Mt=na.get(st.col)??{x0:0,x1:0,top:0,slotH:118};return{col:st.col,warped_w:Ht,warped_h:Ir,offset_x:0,strips:[],chars:st.chars.map(Jt=>{const Lr=Jt.slot??Jt.pos??0,Ti=(Mt.top+(Lr-1)*Mt.slotH)*ta,Ei=(Mt.x0+Mt.x1)/2,[Uu,Vu]=Jt.sub==="a"?[Ei,Mt.x1]:Jt.sub==="b"?[Mt.x0,Ei]:[Mt.x0,Mt.x1];return{...Jt,bbox_col:[Uu*ea,Ti,Vu*ea,Ti+Mt.slotH*ta]}})}}):[]}},[ce,We,Yn,Xt,ki]),{entryTitle:$i,authors:Gs}=Ob(n,i,c===void 0),[Ys,Nr]=f.useState("text");f.useEffect(()=>{Nr("text")},[U,R]);const Lu=f.useMemo(()=>te?Ab(te,X,ul(re,te),N,ye,an):[],[te,X,re,N,ye,an]);if(J==="loading")return t.jsx(dl,{className:I,style:E,title:c??$i,label:T("reader.loading")});if(J==="missing"||!Z||!re)return t.jsx("div",{className:I,style:{...E,...cl},children:T("reader.noText")});if(Ve==="failed")return t.jsx("div",{className:I,style:{...E,...cl},children:T("reader.tocFailed")});if(!te)return t.jsx(dl,{className:I,style:E,title:c??$i,label:T("reader.tocLoading")});const zn=ul(re,te),Au=Lu,Ks=at&&U&&at.chapter===U?Ss(U,at.anchor):null,Mu=Ks&&pe&&an(pe).some(A=>A.anchor===at.anchor)?Ks:U??null,Tr=Z.versions.map(A=>({key:A.key,label:Te.textVersionLabel(A),optionLabel:N(Te.textVersionLabel(A)),sourceName:ml(A)?T("reader.originalSource"):A.source_name?N(A.source_name):void 0,license:A.license??void 0,sourceUrl:A.source_url??void 0,primary:A.key===xe})),At=Ib((Qs=te.source)==null?void 0:Qs.upstream),Ci=(typeof c=="string"?N(c):c)??(te.title?N(te.title):$i?N($i):void 0),qs=re.edition_label?N(re.edition_label):void 0,Er=Ci?t.jsx("a",{href:K(n),title:T("reader.viewEntry"),onClick:l?A=>{A.metaKey||A.ctrlKey||(A.preventDefault(),l(n))}:void 0,children:Ci}):void 0,Pu=Er&&qs?t.jsxs(t.Fragment,{children:[Er,t.jsxs("span",{className:"bim-rd-ed",children:["·",qs]})]}):Er,Bu=Gs.length>0?N(Gs.slice(0,2).map(A=>`${A.dynasty?`〔${A.dynasty}〕`:""}${A.name}${` ${A.role||T("reader.defaultRole")}`}`).join("、")):void 0,Rr=pe?ep(pe,zn,N,ye):void 0,xn=ye&&!!(q!=null&&q.json),bn=(q==null?void 0:q.json)??null,Nn=(q==null?void 0:q.md)??null,Xs=xn&&!Qe&&Od(bn.sections),Ou=Xs&&!(Nn&&Y.readingMode==="paragraph"&&qi(Nn)),Wu=xn&&Xs?t.jsx(Bx,{juan:bn,view:Ys,onView:Nr,textHasEntries:Ou}):void 0,Fu=!0,zi=Nn?Nn.replace(/^##\s+[^\n]+\n+/,""):null,Ni=ml(re),ln=Ni?T("reader.originalSource"):re.source_name?N(re.source_name):void 0,Hu=(typeof p=="string"?N(p):p)??(Ni?void 0:ln??N(Te.textVersionLabel(re))),Du=(ce==null?void 0:ce.hasNorm)===!0;return t.jsxs(Qc,{className:I,style:E,title:Pu,subtitle:Hu,byline:Bu,current:Rr,pagerUnit:zn,rail:Wu,revisedAt:b,backHref:k,backLabel:w,onReportError:S?A=>S({...A,bookTitle:typeof Ci=="string"?Ci:void 0,entryId:n}):void 0,workLinkToggle:xn&&!Qe&&!!l&&!!(bn!=null&&bn.sections.some(A=>A.work_id)),toc:Au,tocCaption:T("reader.tocCaption",{n:te.chapters.length,unit:N(zn)}),tocHeader:ye&&te.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:Qe?T("reader.searchChaptersPlaceholder"):T("reader.searchUnitPlaceholder",{unit:N(zn)}),"aria-label":Qe?T("reader.searchChapters"):T("reader.searchUnit",{unit:N(zn)}),value:Ee,onChange:A=>Xe(A.target.value)}):void 0,activeKey:U??null,tocActiveKey:Mu,onSelect:z,images:Di(pe)&&He&&!ce?null:De.images,renderImageOverlay:h,imagePanel:ce||yt?"open":x,imagesLoading:qe,isWarpMode:!!ce,showPreserveMargins:!j,customImagePanel:ce&&Vs?t.jsxs("div",{ref:Us,className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:Iu,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:[Ce.size>0&&t.jsxs("button",{type:"button",onClick:()=>Ne(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${r("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",Ce.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:Oe<=1,onClick:()=>{var A;return(A=Ye.current)==null?void 0:A.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(Oe*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:Oe>=6,onClick:()=>{var A;return(A=Ye.current)==null?void 0:A.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:Oe===1,onClick:()=>{var A;return(A=Ye.current)==null?void 0:A.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(_b,{ref:Ye,resetKey:We,onScaleChange:Ze,style:{flex:1,minHeight:0},children:t.jsx(Xa,{store:Ue,children:A=>t.jsx(hs,{imageUrl:Tu,pageData:Vs,selectedCharIds:Ce,hoveredCharId:A,preserveMargins:Be,renderScale:Oe,selectedFigBlock:et,onFigBlockClick:ie=>Je(ie),onCharClick:ie=>{Je(null),Ne(mt=>{const tt=new Set(mt);return tt.has(ie)?tt.delete(ie):(tt.clear(),tt.add(ie)),tt});const Re=document.querySelector(`[data-char-id="${ie}"]`);Re&&Re.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:Ue.set})})}),t.jsxs("div",{"data-testid":"facsimile-pager",role:"group","aria-label":T("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:zr<=0,onClick:()=>Kn(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":We,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":T("reader.facsimilePageInput"),size:Math.max(2,String($r??We).length),value:$r??String(We),onFocus:A=>A.currentTarget.select(),onChange:A=>Ru(A.target.value),onKeyDown:A=>{A.key==="Enter"?(A.preventDefault(),Ds()):A.key==="Escape"&&(_i.current=null,Cr(null)),A.stopPropagation()},onBlur:Ds,style:{width:`${Math.max(2,String($r??We).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:zr<0||zr>=Zt.length-1,onClick:()=>Kn(1),children:"›"})]})]}):void 0,settingsExtra:m,settingsExtraTitle:g,settingsAnnotate:ce?t.jsx("button",{type:"button",className:`bim-rd-t bim-rd-sp-tg ${B?"bim-rd-on":""}`,"aria-pressed":B,title:"切换外挂现代断句标点",onClick:()=>ge(A=>!A),children:B?"标点":"无标点"}):void 0,prefs:Y,onPrefsChange:L,versions:Tr.length>1?Tr:void 0,currentVersionKey:Tr.length>1?re.key:void 0,onVersionChange:Ke,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:qi(Nn),allowVertical:y,origScriptAvailable:Du,contentLoading:G,children:[(G||He&&!ce&&!xn&&zi==null)&&t.jsx($n,{}),!G&&ce&&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:pe!=null&&pe.title?N(pe.title):Rr}),(ln||re.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[ln,re.license&&t.jsxs(t.Fragment,{children:[ln&&t.jsx("span",{className:"bim-rd-dot"}),re.license]})]})]}),t.jsx(Xa,{store:Ue,children:A=>t.jsx(ks,{pageData:ce,pages:ce.pages,punctuations:ce.punctuations||Rb,selectedCharIds:Ce,hoveredCharId:A,onSelectionChange:Nu,figures:ce.figures,figUrl:ce.figUrl,onFigureBlockClick:({page:ie,fig:Re})=>{Ne(new Set),Je(Re),Nt(ie)},onCharClick:ie=>{Je(null),Ne(mt=>{const tt=new Set(mt);return tt.has(ie)?tt.delete(ie):(tt.clear(),tt.add(ie)),tt});const Re=parseInt(ie.split(":")[0],10);isNaN(Re)||Nt(Re)},onCharHover:Ue.set,mode:"horizontal",showPunctuation:B,entities:we,entityTransport:i,onEntityNavigate:C,onVisiblePageChange:Eu,convert:N,scrollToPage:ct,scrollToAnchor:nt&&nt.chapter===U&&_t?nt:null,onVisibleHeadingChange:ie=>lt(ie&&U?{chapter:U,anchor:ie}:null),pageBreaks:Y.pageBreaks,pageIndicatorY:Y.pageIndicatorY,onPageIndicatorYChange:ie=>L({pageIndicatorY:ie}),quoteStyle:Y.quoteStyle,bookTitleStyle:Y.bookTitleStyle,showWorks:Y.showWorks})})]}),!G&&!ce&&xn&&bn&&t.jsx(Mx,{juan:bn,rawText:Nn,positionLabel:Pb(pe,te,zn,N),groupLabel:Bb(te,U??null),index:Lb(n,te),searchQuery:Ee,onNavigate:l,transport:i,workLabelCache:$e,prefs:Y,view:Ys,onViewChange:Nr},`${R}/${U}`),!G&&!ce&&!xn&&zi!=null&&pe&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:pe.title?N(pe.title):Rr}),(ln||re.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[Ni&&ln&&t.jsx(t.Fragment,{children:ln}),!Ni&&re.source_name&&t.jsxs(t.Fragment,{children:[T("reader.textSource")," ",re.source_url?t.jsx("a",{className:"bim-rd-link",href:re.source_url,target:"_blank",rel:"noreferrer",children:N(re.source_name)}):N(re.source_name)]}),ln&&re.license&&t.jsx("span",{className:"bim-rd-dot"}),re.license]}),At&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[T("reader.upstream")," ",At.url?t.jsx("a",{className:"bim-rd-link",href:At.url,target:"_blank",rel:"noreferrer",children:N(At.name??At.url)}):N(At.name??""),At.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),At.license_url?t.jsx("a",{className:"bim-rd-link",href:At.license_url,target:"_blank",rel:"noreferrer",children:At.license}):At.license]}),At.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(Dc,{text:At.note,convert:N})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(ls,{text:zi,mode:Y.readingMode,tables:Fu,gujiMarkdown:!0,bookMarking:as(Y),quoteStyle:Y.quoteStyle})})]}),!G&&!He&&!ce&&!xn&&zi==null&&pe&&t.jsx("div",{className:"bim-rd-state",children:T("reader.chapterFailed")}),!G&&te.references&&te.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:T("reader.references")}),t.jsx("ol",{children:te.references.map((A,ie)=>t.jsxs("li",{children:[A.url?t.jsx("a",{className:"bim-rd-link",href:A.url,target:"_blank",rel:"noopener noreferrer",children:N(A.title)}):t.jsx("span",{children:N(A.title)}),A.author&&t.jsxs("span",{children:[",",N(A.author)]}),A.note&&t.jsxs("span",{children:["。",N(A.note)]})]},ie))})]})]})};function ml(e){return e.is_original===!0||e.source==="original"}function Pb(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 Bb(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 Ob(e,n,i){const[o,s]=f.useState({entryTitle:void 0,authors:[]});return f.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 np={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")}},Wb=np.other,ip={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")}},Fb=ip.pending;function Hb(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 Db(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 $s=({items:e,loading:n})=>{const i=kt(),{t:o,convert:s}=ae();return n?t.jsx($n,{}):e.length===0?t.jsx("div",{style:Ub,children:o("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=np[a.type]||Wb,d=ip[a.status]||Fb,c=typeof window<"u"&&Db(a.pageUrl,window.location.href);return t.jsxs("div",{style:Vb,children:[t.jsxs("div",{style:Gb,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...gl,background:l.color},children:o(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...gl,background:d.color},children:o(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:Yb,children:Hb(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:Kb,children:[a.resourceId&&t.jsx("a",{href:i(a.resourceId),style:Yr,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:Yr,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:Yr,children:a.pageUrl}))]}),t.jsx("div",{style:qb,children:s(a.content)}),a.reply&&t.jsxs("div",{style:Xb,children:[t.jsx("div",{style:Zb,children:o("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},Ub={textAlign:"center",padding:"40px 0",color:r("desc-fg"),fontSize:"14px"},Vb={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"16px"},Gb={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},gl={fontSize:"12px",color:r("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},Yb={fontSize:"12px",color:r("desc-fg")},Kb={fontSize:"12px",marginBottom:"6px"},Yr={color:r("primary"),textDecoration:"none",borderBottom:`1px dashed ${r("primary")}`},qb={fontSize:"14px",lineHeight:"1.6",color:r("fg"),whiteSpace:"pre-wrap"},Xb={marginTop:"12px",padding:"10px 12px",background:r("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:r("fg")},Zb={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:r("primary")},ko=({transport:e,onNavigate:n,recommendedIds:i,activeTab:o,onTabChange:s,feedbackApiUrl:a})=>{const l=Ae(),[d,c]=f.useState(null),[p,m]=f.useState([]),[g,u]=f.useState("recommend"),[h,x]=f.useState([]),[j,y]=f.useState(!1),S=o??g,b=L=>{u(L),s==null||s(L)},[k,w]=f.useState(!0),[v,$]=f.useState(null),[_,C]=f.useState(null),[I,E]=f.useState(null);f.useEffect(()=>{let L=!1;if(e.getCounts)return e.getCounts().then(K=>{L||c({works:K.works,books:K.books,collections:K.collections})}).catch(()=>{}),()=>{L=!0}},[e]),f.useEffect(()=>{let L=!1;return(async()=>{if(i)return i;if(e.getRecommended)try{const Q=await e.getRecommended();if(Q!=null&&Q.groups)return Q.groups.flatMap(Z=>Z.items.map(ue=>({...ue,group:Z.name})))}catch{}return[]})().then(async Q=>{if(L)return;const Z=Q.filter(J=>J.id);if(Z.length===0){w(!1);return}const ue=await Promise.all(Z.map(async J=>{if(J.type)return{id:J.id,title:J.title,type:J.type,author:J.author,dynasty:J.dynasty,role:J.role,edition:J.edition,has_text:J.has_text,has_image:J.has_image,has_collated:J.has_collated,subtype:J.subtype,primary_name:J.primary_name,group:J.group,fallbackDescription:J.description};try{let le=null;if(e.getEntry)le=await e.getEntry(J.id);else{const H=await e.getItem(J.id);H&&(le={id:J.id,title:H.title||J.id,type:H.type||"work"})}if(le)return{...le,group:J.group,fallbackDescription:J.description}}catch{}return{id:J.id,title:J.title,type:Te.extractType(J.id),group:J.group,fallbackDescription:J.description}}));L||(m(ue.filter(J=>J!==null)),w(!1))}),()=>{L=!0}},[e,i]);const T=f.useRef(!1),N=f.useRef(!1),P=f.useRef(!1);f.useEffect(()=>{if(S!=="catalog"||T.current)return;const L=e.getCatalogProgress??e.getResourceProgress;if(!L)return;T.current=!0;let K=!1;return L.call(e).then(Q=>{K||$(Q)}).catch(()=>{T.current=!1}),()=>{K=!0}},[e,S]),f.useEffect(()=>{if(S!=="collection"||N.current||!e.getCollectionProgress)return;N.current=!0;let L=!1;return e.getCollectionProgress().then(K=>{L||C(K)}).catch(()=>{N.current=!1}),()=>{L=!0}},[e,S]),f.useEffect(()=>{if(S!=="site"||P.current||!e.getSiteProgress)return;P.current=!0;let L=!1;return e.getSiteProgress().then(K=>{L||E(K)}).catch(()=>{P.current=!1}),()=>{L=!0}},[e,S]),f.useEffect(()=>{if(!a||S!=="feedback")return;let L=!1;return y(!0),fetch(a).then(K=>K.json()).then(K=>{!L&&K.success&&x(K.items||[])}).catch(()=>{}).finally(()=>{L||y(!1)}),()=>{L=!0}},[a,S]);const W=L=>t.jsx(Gn,{type:L,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(ei,{label:l.home.recommendTab,active:S==="recommend",onClick:()=>b("recommend")}),t.jsx(ei,{label:l.home.catalogTab,active:S==="catalog",onClick:()=>b("catalog")}),t.jsx(ei,{label:l.home.collectionTab,active:S==="collection",onClick:()=>b("collection")}),t.jsx(ei,{label:l.home.siteTab,active:S==="site",onClick:()=>b("site")}),a&&t.jsx(ei,{label:l.home.feedbackTab,active:S==="feedback",onClick:()=>b("feedback")})]}),S==="recommend"&&t.jsx(Jb,{recommended:p,loading:k,onNavigate:n,getIcon:W,t:l}),S==="catalog"&&t.jsx(fl,{progress:v,t:l,onNavigate:n}),S==="collection"&&t.jsx(fl,{progress:_,t:l,onNavigate:n}),S==="site"&&t.jsx(ey,{progress:I,t:l,totalWorks:(d==null?void 0:d.works)??0}),S==="feedback"&&a&&t.jsx($s,{items:h,loading:j})]})})},ei=({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}),Jb=({recommended:e,loading:n,onNavigate:i,getIcon:o,t:s})=>{const a=kt();if(n)return t.jsx($n,{});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 m=p.dynasty||p.author?`${p.dynasty?`〔${p.dynasty}〕`:""}${p.author||""}`:p.fallbackDescription;return t.jsxs("a",{href:a(p.id),onClick:g=>{g.metaKey||g.ctrlKey||(g.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})]}),m&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m})]})]},p.id)})})]},d))})},fl=({progress:e,t:n,onNavigate:i})=>{if(!e)return t.jsx($n,{});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(Qb,{item:p,t:n,statusColor:l[d],onNavigate:i},p.id))})]},d)})})},Qb=({item:e,t:n,statusColor:i,onNavigate:o})=>{const s=kt(),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?Bt(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})]})},ey=({progress:e,t:n,totalWorks:i})=>{if(!e)return t.jsx($n,{});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(hl,{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(hl,{item:c,t:n,totalWorks:i},c.id))})]})]})},hl=({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})]})},xl="(max-width: 768px)";function ty(){const[e,n]=f.useState(()=>typeof window>"u"?!1:window.matchMedia(xl).matches);return f.useEffect(()=>{const i=window.matchMedia(xl),o=s=>n(s.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),e}const ny=({transport:e,hideModeIndicator:n=!0,onEntryClick:i,recommendedIds:o,headerRight:s})=>{var N;const a=Ae(),{convert:l}=Ge(),d=ty(),[c,p]=f.useState(null),[m,g]=f.useState(null),[u,h]=f.useState(!1),[x,j]=f.useState("detail"),[y,S]=f.useState([]),[b,k]=f.useState(!1),w=f.useCallback(async P=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){S([]);return}k(!0);try{if(e.getCollectionCatalogs){const W=await e.getCollectionCatalogs(P);S(W||[])}else if(e.getCollectionCatalog){const W=await e.getCollectionCatalog(P);S(W?[{resource_id:"",data:W}]:[])}}catch{S([])}finally{k(!1)}},[e]),v=f.useCallback(async P=>{if(i){i(P);return}p(P),g(null),S([]),j("detail"),h(!0);try{const W=await e.getItem(P.id);W&&(g(W),W.type==="collection"&&w(P.id))}catch(W){console.error("加载详情失败:",W)}finally{h(!1)}},[e,i,w]),$=f.useCallback(async P=>{g(null),S([]),j("detail"),h(!0);try{const W=await e.getItem(P);W&&(g(W),p({id:P,title:W.title||P,type:W.type||"book"}),W.type==="collection"&&w(P))}catch(W){console.error("导航失败:",W)}finally{h(!1)}},[e,w]),_=typeof(m==null?void 0:m.text_count)=="number"&&m.text_count>0,C=(m==null?void 0:m.type)==="collection"&&(y.length>0||b)||(m==null?void 0:m.type)==="work"&&_,I=d&&(u||m),E=f.useCallback(()=>{p(null),g(null),S([]),j("detail")},[]),T=t.jsx(t.Fragment,{children:u?t.jsx($n,{}):m?t.jsxs(t.Fragment,{children:[(C||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:[C&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>j("detail"),style:Mi(x==="detail"),children:a.detailTab.basicInfo}),m.type==="collection"&&b&&y.length===0&&t.jsxs("button",{onClick:()=>{},style:Mi(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),m.type==="collection"&&y.map(P=>t.jsx("button",{onClick:()=>j(`catalog:${P.resource_id}`),style:Mi(x===`catalog:${P.resource_id}`),children:P.short_name?`${l(P.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},P.resource_id)),m.type==="work"&&_&&t.jsx("button",{onClick:()=>j("collated"),style:Mi(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(Ko,{data:m,transport:e,onNavigate:$}):x.startsWith("catalog:")?t.jsx(qo,{data:(N=y.find(P=>`catalog:${P.resource_id}`===x))==null?void 0:N.data,onNavigate:$}):x==="collated"?t.jsx(_s,{id:m.id,transport:e,onNavigate:$}):null})]}):t.jsx(ko,{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:I?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:E,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(oo,{transport:e,onEntryClick:v,hideModeIndicator:n}),!m&&t.jsx(ko,{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(oo,{transport:e,onEntryClick:v,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:r("bg"),display:"flex",flexDirection:"column"},children:T})]})};function Mi(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 iy=({pageData:e,rawImageUrl:n="",punctuations:i=[],title:o,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=f.useState(new Set),[m,g]=f.useState(null),[u,h]=f.useState("horizontal"),[x,j]=f.useState(!0),y=f.useRef(null),S=f.useCallback(v=>{p(new Set(v))},[]),b=f.useCallback(v=>{if(p($=>{const _=new Set($);return _.has(v)?_.delete(v):(_.clear(),_.add(v)),_}),y.current){const $=y.current.querySelector(`[data-char-id="${v}"]`);$&&$.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),k=()=>{var v;p(new Set),window.getSelection&&((v=window.getSelection())==null||v.removeAllRanges())},w=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:k,className:"guji-reader-btn",children:"清除选中"}),t.jsx("button",{type:"button",onClick:()=>j(v=>!v),className:`guji-reader-btn ${x?"active":""}`,title:"独立外挂标点 (guji-punct v0.1)",children:x?"✓ 标点":"底本文本"}),t.jsx("button",{type:"button",onClick:()=>h(v=>v==="horizontal"?"vertical":"horizontal"),className:"guji-reader-btn primary",children:u==="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(hs,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:m,onCharClick:b,onCharHover:g})})]}),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:u==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(ks,{pageData:e,punctuations:w,selectedCharIds:c,hoveredCharId:m,onSelectionChange:S,onCharClick:b,onCharHover:g,mode:u,showPunctuation:x})]})]})]})},ry=e=>typeof e=="string"&&Array.from(e).length===1,oy=new Set(["point","break","heading"]),sy=/^#{1,6}$/;function ay(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;if(typeof s.anchor!="string"||typeof s.mark!="string"||s.pre_char!=null&&!ry(s.pre_char)||s.kind!=null&&!oy.has(s.kind)||s.pos!=null&&s.pos!=="after"&&s.pos!=="before")continue;const a={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};if(!(s.kind==="break"&&s.pos==="before")){if(s.kind==="heading"){if(s.pos!=="before"||!sy.test(s.mark))continue;typeof s.label=="string"&&s.label.trim()&&(a.label=s.label.trim()),s.toc===!1&&(a.toc=!1)}i.push(a)}}return i}function ly(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 rp=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function xt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}const Cs=/^[a-z0-9][a-z0-9-]*$/,cy=new Set(["main","solo","jz_r","jz_l"]),dy=new Set(["body","banxin","blank"]);function py(e){const n={};return typeof e.lane=="string"&&cy.has(e.lane)&&e.lane!=="main"&&(n.lane=e.lane),e.lacuna===!0&&(n.lacuna=!0),e.lacuna===!0&&e.guess!==!0&&typeof e.guess_c=="string"&&e.guess_c.trim()&&(n.guess_c=e.guess_c.trim()),e.guess===!0&&(n.guess=!0),typeof e.pending_reason=="string"&&Yx.test(e.pending_reason)&&e.lacuna!==!0&&e.guess_c===void 0&&e.fig===void 0&&(n.pending=e.pending_reason),typeof e.zi=="string"&&e.zi&&(n.zi=e.zi),typeof e.fig=="string"&&Cs.test(e.fig)&&e.c==="□"&&!e.lacuna&&!e.guess&&e.guess_c===void 0&&e.zi===void 0&&(n.fig=e.fig),n}function uy(e){const n={};typeof e.kind=="string"&&dy.has(e.kind)&&e.kind!=="body"&&(n.kind=e.kind);const i=xt(e.raised);i!==void 0&&Number.isInteger(i)&&i>0&&(n.raised=i);const o=xt(e.lead_blank);return o!==void 0&&Number.isInteger(o)&&o>0&&(n.lead_blank=o),n}function Kr(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(i=>!!i&&typeof i=="object"):[]}function my(e){return typeof e=="string"&&Array.from(e).length===1}function op(e){const n=new Map,i={badAnchor:0,badChar:0,badWhy:0,notObject:0},o=e&&typeof e=="object"?e.items:void 0;for(const s of Array.isArray(o)?o:[]){if(!s||typeof s!="object"){i.notObject++;continue}const{a,t:l,why:d}=s;if(typeof a!="string"||!rp.test(a)){i.badAnchor++;continue}if(!my(l)){i.badChar++;continue}if(d!==void 0&&d!=="异体"){i.badWhy++;continue}n.set(a,l)}return{map:n,dropped:i}}function sp(e){return op(e).map}function gy(e,n,i){var g,u,h,x,j,y,S,b,k,w;const o=i==null?null:sp(i),s=new Map,a=new Map;for(const v of Kr(n)){const $=xt(v.page);if($!==void 0){s.set($,v);for(const _ of Array.isArray(v.cells)?v.cells:[]){const C=_==null?void 0:_.box;typeof(_==null?void 0:_.a)=="string"&&Array.isArray(C)&&C.length===4&&C.every(I=>xt(I)!==void 0)&&a.set(_.a,[C[0],C[1],C[0]+C[2],C[1]+C[3]])}}}const l=new Map;for(const[v,$]of s)for(const _ of Array.isArray($.marks)?$.marks:[]){const C=_==null?void 0:_.box;if((_==null?void 0:_.kind)!=="figure"||typeof _.fig!="string"||!Array.isArray(C)||C.length!==4||!C.every(E=>xt(E)!==void 0))continue;let I=l.get(v);I||l.set(v,I=new Map),I.set(_.fig,[C[0],C[1],C[0]+C[2],C[1]+C[3]])}const d=[],c=new Map,p=new Map;for(const v of Kr(e)){const $=xt(v.page);$!==void 0&&typeof v.label=="string"&&v.label&&c.set($,v.label)}for(const v of Kr(e)){const $=xt(v.page);if($===void 0)continue;const _=[],C=l.get($);for(const E of Array.isArray(v.columns)?v.columns:[]){const T=xt(E==null?void 0:E.col);if(T===void 0)continue;if(E.kind==="figure"){if(typeof E.fig!="string"||!Cs.test(E.fig))continue;const W=xt(E.span),L=C==null?void 0:C.get(E.fig);_.push({col:T,chars:[],kind:"figure",fig:E.fig,...W!==void 0&&Number.isInteger(W)&&W>1?{span:W}:{},...L?{figBox:L}:{}});continue}const N=[];for(const W of Array.isArray(E.cells)?E.cells:[]){const L=rp.exec(String((W==null?void 0:W.a)??""));if(!L||typeof W.c!="string")continue;const K=parseInt(L[3],10),Q=o==null?void 0:o.get(W.a);N.push({id:W.a,char:W.c,slot:K,pos:K,sub:L[4]||null,bbox:a.get(W.a)??null,...py(W),...Q!==void 0&&Q!==W.c?{norm:Q}:{}})}const P=uy(E);(N.length>0||P.kind==="blank")&&_.push({col:T,chars:N,...P})}if(!_.some(E=>E.chars.length>0||E.kind==="figure")){_.length>0&&p.set($,_);continue}_.sort((E,T)=>E.col-T.col);const I=s.get($);d.push({page:$,seq:String(((g=I==null?void 0:I.canvas)==null?void 0:g.seq)??""),width:xt((u=I==null?void 0:I.canvas)==null?void 0:u.width)??xt((h=I==null?void 0:I.image)==null?void 0:h.width)??0,height:xt((x=I==null?void 0:I.canvas)==null?void 0:x.height)??xt((j=I==null?void 0:I.image)==null?void 0:j.height)??0,...typeof v.label=="string"&&v.label?{label:v.label}:{},columns:_})}const m=new Set(d.map(v=>v.page));for(const[v,$]of s){const _=(y=$==null?void 0:$.canvas)==null?void 0:y.seq;m.has(v)||typeof _!="string"&&typeof _!="number"||String(_)===""||d.push({page:v,seq:String(_),width:xt((S=$.canvas)==null?void 0:S.width)??xt((b=$.image)==null?void 0:b.width)??0,height:xt((k=$.canvas)==null?void 0:k.height)??xt((w=$.image)==null?void 0:w.height)??0,...c.has(v)?{label:c.get(v)}:{},columns:p.get(v)??[]})}return d.sort((v,$)=>v.page-$.page)}const fy=new Set(["image/png","image/webp","image/svg+xml"]);function hy(e){const n=new Map,i=e&&typeof e=="object"?e.figures:void 0;for(const o of Array.isArray(i)?i:[]){if(!o||typeof o!="object")continue;const s=o;if(typeof s.id!="string"||!Cs.test(s.id))continue;const a=s.kind==="block"?"block":s.kind==="inline"?"inline":null;a&&(typeof s.file!="string"||!/^fig\/[\w./-]+$/.test(s.file)||s.file.split("/").includes("..")||typeof s.mime!="string"||!fy.has(s.mime)||n.set(s.id,{id:s.id,kind:a,alt:typeof s.alt=="string"&&s.alt.trim()?s.alt.trim():"图形符号",file:s.file,mime:s.mime,width:xt(s.width)??0,height:xt(s.height)??0}))}return n}const xy=({data:e,onNavigate:n,className:i,style:o})=>{var m;const{t:s,convert:a}=ae(),[l,d]=f.useState(((m=e.divisions[0])==null?void 0:m.name)??null),[c,p]=f.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(g=>t.jsx(by,{division:g,expanded:l===g.name,onToggle:()=>d(l===g.name?null:g.name),expandedCat:c,onCatToggle:u=>p(c===u?null:u),onNavigate:n},g.name))})]})},by=({division:e,expanded:n,onToggle:i,expandedCat:o,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=ae(),c=e.categories.reduce((p,m)=>{const g=m.stats||{zhulu:0,cunmu:0};return p+(g.zhulu||0)+(g.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 m=`${e.name}/${p.name}`;return t.jsx(yy,{category:p,expanded:o===m,onToggle:()=>s(m),onNavigate:a},p.name)})})]})},yy=({category:e,expanded:n,onToggle:i,onNavigate:o})=>{var p,m,g,u;const{t:s,convert:a}=ae(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((m=e.books)==null?void 0:m.cunmu)||[],c=(((g=e.stats)==null?void 0:g.zhulu)||l.length)+(((u=e.stats)==null?void 0:u.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(bl,{label:s("catalogPage.zhulu"),books:l,onNavigate:o}),d.length>0&&t.jsx(bl,{label:s("catalogPage.cunmu"),books:d,onNavigate:o})]})]})},bl=({label:e,books:n,onNavigate:i})=>{const{t:o,convert:s}=ae(),a=kt(),[l,d]=f.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,m)=>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:g=>{g.metaKey||g.ctrlKey||(g.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)})]},m))}),!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})})]})},Dt=({title:e,onSave:n,onAskAI:i,extraButtons:o,children:s})=>{const a=Ae();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:vy,children:"AI"}),n&&t.jsx("button",{onClick:n,style:jy,children:a.action.save})]})]}),s]})},jy={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},vy={padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},Pt=({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"}})]}),kn=({value:e,onChange:n,placeholder:i})=>{const o=f.useRef(null);return f.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"}})},Zi=({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 ky(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const Ui=({value:e,onChange:n,label:i})=>{const[o,s]=f.useState(!1),a=f.useRef(null),l=ky(e||"");return f.useEffect(()=>{o&&a.current&&a.current.focus()},[o]),!o&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:yl,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(Zi,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:yl,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"}})]})},yl={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500};function wy(e){switch(e){case"url":return r("source-url");case"bookID":return r("source-bookid");default:return r("desc-fg")}}function Sy(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const ap=({items:e,onChange:n,onOpenEntityPicker:i})=>{const o=Ae(),[s,a]=f.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=g=>{n(e.filter((u,h)=>h!==g)),s===g&&a(null)},c=(g,u,h)=>{const x=[...e];x[g]={...x[g],[u]:h},n(x)},p=(g,u)=>{const h=[...e];h[g]={...h[g],type:u,id:"",name:""},n(h),u==="bookID"&&i&&i(x=>{const j=[...e];j[g]={...j[g],id:x.id,name:x.title,type:"bookID"},n(j)})},m=g=>{i&&i(u=>{const h=[...e];h[g]={...h[g],id:u.id,name:u.title,type:"bookID"},n(h)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((g,u)=>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===u?null:u),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===u?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:r("fg")},children:g.name||`${o.editor.sourcePlaceholder} ${u+1}`}),g.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:wy(g.type),color:r("on-color-fg"),borderRadius:"3px",fontWeight:500},children:Sy(g.type)}),t.jsx("button",{onClick:h=>{h.stopPropagation(),d(u)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:o.editor.deleteThisSource,children:"✕"})]}),s===u&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!g.type&&t.jsxs("div",{children:[t.jsx("label",{style:Qt,children:o.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(u,"bookID"),style:{...jl,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(u,"url"),style:{...jl,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})]})]})]}),g.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:Qt,children:o.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const h=[...e];h[u]={...h[u],type:"",id:"",name:""},n(h)},style:vl,children:o.action.changeType})]}),g.id&&g.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:g.name}),t.jsx("code",{style:{fontSize:"11px",background:r("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:g.id})]}),t.jsx("button",{onClick:()=>m(u),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:()=>m(u),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})]})]})}),g.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:Qt,children:o.label.sourceName}),t.jsx("button",{onClick:()=>{const h=[...e];h[u]={...h[u],type:"",id:"",name:""},n(h)},style:vl,children:o.action.changeType})]}),t.jsx("input",{type:"text",value:g.name,onChange:h=>c(u,"name",h.target.value),placeholder:o.editor.sourceNamePlaceholder,style:Rn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Qt,children:o.label.urlAddress}),t.jsx("input",{type:"text",value:g.id,onChange:h=>c(u,"id",h.target.value),placeholder:"https://...",style:Rn})]})]}),g.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:{...Qt,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:Qt,children:o.label.detailsOptional}),t.jsx("input",{type:"text",value:g.details,onChange:h=>c(u,"details",h.target.value),placeholder:o.editor.detailsPlaceholder,style:Rn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Qt,children:o.label.positionOptional}),t.jsx("input",{type:"text",value:g.position,onChange:h=>c(u,"position",h.target.value),placeholder:"如: 卷三, p.52",style:Rn})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Qt,children:o.label.dataVersionOptional}),t.jsx("input",{type:"text",value:g.version,onChange:h=>c(u,"version",h.target.value),placeholder:"如: v1.0, 2024-01",style:Rn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Qt,children:o.label.processorVersionOptional}),t.jsx("input",{type:"text",value:g.processor_version,onChange:h=>c(u,"processor_version",h.target.value),placeholder:"如: v0.1",style:Rn})]})]})]})]})})]},u)),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})]})]})},Qt={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},Rn={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"},jl={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"},vl={background:"transparent",border:"none",color:r("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function lp(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 cp(e){return!e||e.length===0?"":JSON.stringify(e)}const dp=({entityType:e,entityId:n,entityTitle:i,parentWork:o,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:m,onLinkEntity:g,onUnlinkEntity:u,onViewEntity:h,onCreateAndLink:x,onSaveRelations:j})=>{const y=Ae();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})]}),j&&t.jsx("button",{onClick:j,style:_y,children:y.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(ti,{direction:"up",title:y.relation.belongsToWork,entity:a,onView:h,onUnlink:()=>u("workId"),onLink:()=>g("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(ti,{direction:"up",title:y.relation.containedInCollection,entity:l,onView:h,onUnlink:()=>u("collectionId"),onLink:()=>g("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&&m&&m.length>0&&t.jsx(In,{direction:"horizontal",title:`${y.relation.siblingVersions} (${m.length})`,entities:m,onView:h,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(ti,{direction:"up",title:y.relation.parentWork,entity:o,onView:h,onUnlink:()=>u("parentWorkId"),onLink:()=>g("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(In,{direction:"down",title:`${y.relation.childWorks} (${d.length})`,entities:d,onView:h,onAdd:()=>x("childWork","work",{parentWorkId:n}),addLabel:y.action.addSubWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),c&&c.length>0&&t.jsx(In,{direction:"down",title:`${y.relation.collectionImpl} (${c.length})`,entities:c,onView:h,onAdd:()=>x("childCollection","collection",{workId:n}),addLabel:y.action.addCollectionImpl,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(In,{direction:"down",title:`${y.relation.allVersions} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:h,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(ti,{direction:"up",title:y.relation.correspondingWork,entity:a,onView:h,onUnlink:()=>u("workId"),onLink:()=>g("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(ti,{direction:"up",title:y.relation.parentCollection,entity:s,onView:h,onUnlink:()=>u("parentCollectionId"),onLink:()=>g("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(In,{direction:"down",title:`${y.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:h,onAdd:()=>x("childCollection","collection",{parentCollectionId:n}),addLabel:y.action.addSubCollection,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(In,{direction:"down",title:`${y.relation.containedBooks} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:h,onAdd:()=>x("childBook","book",{collectionId:n}),addLabel:y.action.addBook,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]})]})]})},ti=({direction:e,title:n,entity:i,onView:o,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:m,unlinkLabel:g})=>{const u=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),h=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:u,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:h}),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:pp(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(kl,{onClick:()=>o(i),title:m,children:"👁️"}),t.jsx(kl,{onClick:s,title:g,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(wo,{onClick:a,children:d}),t.jsx(wo,{onClick:l,primary:!0,children:c})]})]})},In=({direction:e,title:n,entities:i,onView:o,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=f.useState(!1),m=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),g=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",u=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:m,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:g}),t.jsx("span",{children:n})]}),i.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[u.map(h=>t.jsxs("div",{onClick:()=>o(h),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:r("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[t.jsx("span",{children:pp(h.type)}),t.jsx("span",{children:h.title})]},h.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(wo,{onClick:s,primary:!0,children:["+ ",a]})})]})},kl=({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}),wo=({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 pp(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const _y={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},up=({isOpen:e,entityType:n,title:i,onSelect:o,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[m,g]=f.useState(""),u=p?l.filter(y=>y.id!==p):l;f.useEffect(()=>{e&&(g(""),d(""))},[e]);const h=y=>{g(y),d(y)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",j=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:$y,children:t.jsxs("div",{style:Cy,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:zy,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:m,onChange:y=>h(y.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:Ny})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:qr,children:"搜索中..."}):u.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:u.map(y=>t.jsxs("div",{onClick:()=>o(y),style:Ty,children:[t.jsx("span",{style:{fontSize:"16px"},children:j}),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))}):m?t.jsxs("div",{style:qr,children:["未找到匹配的",x]}):t.jsxs("div",{style:qr,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:Ey,children:["创建新",x,"并关联"]})]})]})})},$y={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Cy={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")},zy={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},Ny={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"},Ty={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:r("primary-soft")},qr={padding:"20px",textAlign:"center",color:r("desc-fg")},Ey={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},wl={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},Ry={work:"📜",book:"📖",collection:"📚",entity:"👤"},mp=({isOpen:e,entityType:n,relationField:i,inheritData:o,onConfirm:s,onCancel:a})=>{const[l,d]=f.useState(""),c=f.useRef(null);f.useEffect(()=>{e&&(d((o==null?void 0:o.title)||""),setTimeout(()=>{var u,h;(u=c.current)==null||u.focus(),(h=c.current)==null||h.select()},100))},[e,o==null?void 0:o.title]);const p=u=>{u.key==="Enter"&&l.trim()?m():u.key==="Escape"&&a()},m=()=>{l.trim()&&s(l.trim(),{...o,title:l.trim()})};if(!e)return null;const g=()=>{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`创建新${wl[n]}`}};return t.jsx("div",{style:Iy,onClick:u=>{u.target===u.currentTarget&&a()},children:t.jsxs("div",{style:Ly,onClick:u=>u.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Ry[n]}),t.jsx("span",{children:g()})]}),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:u=>d(u.target.value),onKeyDown:p,placeholder:`请输入${wl[n]}名称...`,style:Ay})]}),((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:My,children:"取消"}),t.jsx("button",{onClick:m,disabled:!l.trim(),style:{...Py,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},Iy={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Ly={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")},Ay={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"},My={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},Py={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg")};function By(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function gp(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Oy(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 fp=({isOpen:e,title:n,filterType:i="all",recentEntities:o=[],excludeId:s,showCreateButton:a=!1,createButtonText:l,onSelect:d,onCancel:c,onCreate:p,onSearch:m})=>{const[g,u]=f.useState(""),[h,x]=f.useState([]),[j,y]=f.useState(!1),[S,b]=f.useState("recent");f.useEffect(()=>{e&&(u(""),x([]),b(o.length>0?"recent":"search"))},[e,o.length]),f.useEffect(()=>{if(!g.trim()){x([]);return}const C=setTimeout(async()=>{y(!0);try{x(await m(g,i))}catch{x([])}finally{y(!1)}},300);return()=>clearTimeout(C)},[g,i,m]);const k=f.useCallback(C=>{u(C.target.value),C.target.value.trim()&&b("search")},[]),w=f.useCallback(C=>s?C.filter(I=>I.id!==s):C,[s]);if(!e)return null;const v=n||(i==="all"?"选择实体":`选择${gp(i)}`),$=w(o),_=w(h);return t.jsx("div",{style:Fy,children:t.jsxs("div",{style:Hy,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:v}),t.jsx("button",{onClick:c,style:Dy,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:g,onChange:k,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Uy}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),j&&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(Sl,{active:S==="recent",onClick:()=>b("recent"),children:["最近使用 (",$.length,")"]}),t.jsxs(Sl,{active:S==="search",onClick:()=>b("search"),children:["搜索结果 ",_.length>0&&`(${_.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:S==="recent"&&$.length>0?t.jsx(_l,{entities:$,onSelect:d}):g.trim()?j?t.jsx(Xr,{message:"搜索中..."}):_.length>0?t.jsx(_l,{entities:_,onSelect:d}):t.jsx(Xr,{message:"未找到匹配的结果"}):t.jsx(Xr,{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:Vy,children:l||"创建新实体"})]})]})})},Sl=({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}),_l=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(i=>t.jsx(Wy,{entity:i,onClick:()=>n(i)},i.id))}),Wy=({entity:e,onClick:n})=>{const[i,o]=f.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:By(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:Oy(e.type),color:r("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:gp(e.type)})]})},Xr=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:e}),Fy={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Hy={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")},Dy={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Uy={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"},Vy={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Gy={work:r("editor-type-work"),collection:r("editor-type-collection"),book:r("editor-type-book"),entity:r("editor-type-entity")},Yy={work:"📜",collection:"📚",book:"📖",entity:"👤"},hp=({data:e,onChange:n,onSave:i,transport:o,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:m,relations:g,onRelationsChange:u})=>{var te;const h=Ae(),[x,j]=f.useState(!1),[y,S]=f.useState("work"),[b,k]=f.useState(""),[w,v]=f.useState(""),[$,_]=f.useState([]),[C,I]=f.useState(!1),[E,T]=f.useState(!1),[N,P]=f.useState("work"),[W,L]=f.useState(""),[K,Q]=f.useState(),[Z,ue]=f.useState(!1),[J,le]=f.useState(null),[H,oe]=f.useState([]);f.useRef(null);const be=e.type,ze=be==="work",Le=be==="collection",_e=be==="book",re=f.useCallback((U,pe)=>{n({...e,[U]:pe})},[e,n]),xe=f.useCallback((U,pe)=>{k(U),S(pe),v(h.editor.selectToLink+h.indexType[pe]),_([]),j(!0)},[h]),R=f.useCallback(U=>{o!=null&&o.unlinkEntity&&o.unlinkEntity(e.id,U)},[o,e.id]),se=f.useCallback(U=>{s==null||s(U.id,U.type)},[s]),de=f.useCallback((U,pe,Me)=>{const Ke={...Me,author:(Me==null?void 0:Me.author)||e.author,dynasty:Me==null?void 0:Me.dynasty};P(pe),L(U),Q(Ke),T(!0)},[e.author]),O=f.useCallback((U,pe)=>{o!=null&&o.createAndLink&&o.createAndLink(e.id,W,{type:N,title:U,inheritData:pe}),T(!1)},[o,e.id,W,N]),ee=f.useCallback(U=>{if(!U.trim()){_([]);return}I(!0),o!=null&&o.searchEntities&&o.searchEntities(U,y).then(pe=>{_(pe),I(!1)}).catch(()=>{_([]),I(!1)})},[o,y]),ke=f.useCallback(U=>{o!=null&&o.linkEntity&&o.linkEntity(e.id,b,U.id),j(!1)},[o,e.id,b]),ve=f.useCallback(()=>{i()},[i]),Ve=f.useCallback(U=>{le(()=>U),ue(!0),o!=null&&o.getRecentEntities&&o.getRecentEntities().then(oe).catch(()=>{})},[o]),F=f.useCallback((U,pe)=>o!=null&&o.searchEntities?o.searchEntities(U,pe==="all"?void 0:pe):Promise.resolve([]),[o]),fe=f.useCallback(U=>{o!=null&&o.addRecentEntity&&o.addRecentEntity(U),oe(pe=>[U,...pe.filter(Me=>Me.id!==U.id)].slice(0,10)),J==null||J(U),ue(!1),le(null)},[o,J]);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:Yy[be]}),t.jsx("span",{children:e.title||h.editor.untitled}),t.jsx(Zi,{children:e.id}),t.jsx(Zi,{color:Gy[be],children:h.indexType[be]})]})}),t.jsx(Dt,{title:h.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(Ui,{label:ze?h.editor.workTitle:Le?h.editor.collectionTitle:h.editor.bookTitle,value:e.title,onChange:U=>re("title",U)}),_e&&t.jsx(Ui,{label:h.editor.belongsToWork,value:e.workName||"",onChange:U=>re("workName",U)}),t.jsx(Pt,{label:h.editor.authorLabel,value:e.author||"",onChange:U=>re("author",U)}),t.jsx(Pt,{label:h.editor.publicationYearLabel,value:e.publicationYear||"",onChange:U=>re("publicationYear",U)}),(_e||Le)&&t.jsx(Ui,{label:h.editor.containedIn,value:e.collection||"",onChange:U=>re("collection",U)}),(_e||Le)&&t.jsx(Pt,{label:h.editor.holderLabel,value:e.holder||"",onChange:U=>re("holder",U)}),(_e||Le)&&t.jsx(Pt,{label:_e?h.editor.pageLabel:h.editor.volumeLabel,value:e.pages||"",onChange:U=>re("pages",U)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(Pt,{label:h.editor.firstImageLabel,value:e.firstImage||"",onChange:U=>re("firstImage",U)})})]})}),t.jsx(Dt,{title:h.section.description,onSave:i,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(kn,{value:e.description||"",onChange:U=>re("description",U),placeholder:h.editor.descriptionPlaceholder})}),(((te=e.additional_works)==null?void 0:te.length)||0)>0&&t.jsx(Dt,{title:h.section.additionalWorks,onSave:i,children:t.jsx(Ky,{items:e.additional_works||[],onChange:U=>re("additional_works",U)})}),t.jsx(Dt,{title:h.section.indexedBy,onSave:i,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(qy,{items:e.indexed_by||[],onChange:U=>re("indexed_by",U)})}),t.jsx(Dt,{title:h.section.emendatedBy,onSave:i,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(Xy,{items:e.emendated_by||[],onChange:U=>re("emendated_by",U)})}),t.jsx(Dt,{title:h.section.textResources,onSave:i,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(no,{items:e.resources||[],onChange:U=>re("resources",U),onDownload:p,downloadStatuses:m,filterType:"text"})}),t.jsx(Dt,{title:h.section.imageResources,onSave:i,children:t.jsx(no,{items:e.resources||[],onChange:U=>re("resources",U),onDownload:p,downloadStatuses:m,filterType:"image"})}),t.jsx(Dt,{title:h.section.sources,onSave:i,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(ap,{items:lp(e.sources||""),onChange:U=>re("sources",cp(U)),onOpenEntityPicker:Ve})}),(_e||Le)&&t.jsx(Dt,{title:h.section.provenance,onSave:i,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(kn,{value:e.provenance||"",onChange:U=>re("provenance",U),placeholder:h.editor.provenancePlaceholder})}),_e&&t.jsx(Dt,{title:h.section.otherEditions,onSave:i,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(kn,{value:e.otherEditions||"",onChange:U=>re("otherEditions",U),placeholder:h.editor.otherEditionsPlaceholder})}),t.jsx(dp,{entityType:be,entityId:e.id,entityTitle:e.title,parentWork:g==null?void 0:g.parentWork,parentCollection:g==null?void 0:g.parentCollection,belongsToWork:g==null?void 0:g.belongsToWork,belongsToCollection:g==null?void 0:g.belongsToCollection,childWorks:g==null?void 0:g.childWorks,childCollections:g==null?void 0:g.childCollections,containedBooks:g==null?void 0:g.containedBooks,siblingBooks:g==null?void 0:g.siblingBooks,onLinkEntity:xe,onUnlinkEntity:R,onViewEntity:se,onCreateAndLink:de,onSaveRelations:ve}),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:h.section.dangerZone}),t.jsx("p",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"12px"},children:h.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:h.editor.deleteEntity})]}),t.jsx(up,{isOpen:x,entityType:y,title:w,onSelect:ke,onCancel:()=>j(!1),onCreate:()=>{j(!1),de(b,y)},searchResults:$,onSearch:ee,isLoading:C,excludeId:e.id}),t.jsx(mp,{isOpen:E,entityType:N,relationField:W,inheritData:K,onConfirm:O,onCancel:()=>T(!1)}),t.jsx(fp,{isOpen:Z,title:h.action.selectBookOrWork,filterType:"all",recentEntities:H,excludeId:e.id,onSelect:fe,onCancel:()=>{ue(!1),le(null)},onSearch:F})]})};function Ky({items:e,onChange:n}){const i=Ae(),o=(l,d,c)=>{const p=e.map((m,g)=>g===l?{...m,[d]:c}:m);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(Pt,{label:i.editor.bookNameLabel,value:l.book_title,onChange:c=>o(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(Pt,{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 xp({items:e,onChange:n,showMeta:i,addLabel:o}){const s=Ae(),[a,l]=f.useState(null),d=(m,g,u)=>{const h=e.map((x,j)=>j===m?{...x,[g]:u||void 0}:x);n(h)},c=m=>{n(e.filter((g,u)=>u!==m)),a===m&&l(null)},p=()=>{n([...e,{source:""}]),l(e.length)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((m,g)=>{const u=a===g;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:u?`color-mix(in srgb, ${r("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(u?null:g),children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.2s",transform:u?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:m.source||s.editor.unnamedSource}),m.source_bid&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:m.source_bid}),t.jsx("button",{onClick:h=>{h.stopPropagation(),c(g)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${r("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:r("muted")},children:"✕"})]}),!u&&i&&(m.title_info||m.author_info)&&t.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:r("desc-fg")},children:[m.title_info,m.title_info&&m.author_info&&" — ",m.author_info]}),u&&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(Pt,{label:s.label.sourceName,value:m.source,onChange:h=>d(g,"source",h)}),t.jsx(Pt,{label:s.label.sourceBid,value:m.source_bid||"",onChange:h=>d(g,"source_bid",h)})]}),i&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(Pt,{label:s.label.titleInfo,value:m.title_info||"",onChange:h=>d(g,"title_info",h)}),t.jsx(Pt,{label:s.label.authorInfo,value:m.author_info||"",onChange:h=>d(g,"author_info",h)})]}),t.jsx(Pt,{label:s.label.edition,value:m.edition||"",onChange:h=>d(g,"edition",h)})]}),t.jsx(kn,{value:m.summary||"",onChange:h=>d(g,"summary",h),placeholder:s.editor.summaryPlaceholder}),t.jsx(kn,{value:m.comment||"",onChange:h=>d(g,"comment",h),placeholder:s.editor.commentPlaceholder}),t.jsx(kn,{value:m.additional_comment||"",onChange:h=>d(g,"additional_comment",h),placeholder:s.editor.additionalCommentPlaceholder})]})]},g)}),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 qy({items:e,onChange:n}){const i=Ae();return t.jsx(xp,{items:e,onChange:n,showMeta:!0,addLabel:i.action.addIndexedBy})}function Xy({items:e,onChange:n}){const i=Ae();return t.jsx(xp,{items:e,onChange:n,addLabel:i.action.addEmendatedBy})}function bp(e){var d,c,p,m,g,u,h;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=((m=e.current_location)==null?void 0:m.name)||"",s=(g=e.page_count)!=null&&g.number?String(e.page_count.number):((u=e.page_count)==null?void 0:u.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 j=x.related_works.find(y=>y.relation==="part_of");j&&(l.parentWorkId=j.id,l.parentWorkName=j.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=(h=x.contained_in[0])==null?void 0:h.id)}return l}function Zy(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 Jy=e=>{const{data:n,id:i,transport:o,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:m,onAskAI:g,renderSectionActions:u,onDownloadResource:h,downloadStatuses:x,relations:j,onRelationsChange:y,headerExtra:S,className:b,style:k}=e,w=Ae(),[v,$]=f.useState(s),_=a?s:v;f.useEffect(()=>{s!==v&&$(s)},[s]);const C=f.useCallback(()=>{const L=_==="view"?"edit":"view";a?a(L):$(L)},[_,a]),[I,E]=f.useState(null);f.useEffect(()=>{i&&o&&o.getItem(i).then(L=>{L&&E(L)})},[i,o]);const T=n||I,N=f.useMemo(()=>T?bp(T):null,[T]),P=a||!n?t.jsx("button",{onClick:C,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:_==="edit"?r("accent-bg"):"transparent",color:r(_==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:_==="view"?w.common.switchToEdit:w.common.switchToView,children:_==="view"?w.common.modeEdit:w.common.modeView}):null,W=t.jsxs(t.Fragment,{children:[P,S]});return!T&&!N?t.jsx($n,{}):_==="view"?t.jsx(Ko,{data:T,transport:o,onNavigate:p?L=>p(L):void 0,renderLink:m,headerExtra:W,className:b,style:k}):N?t.jsxs("div",{className:b,style:k,children:[W&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:W}),t.jsx(hp,{data:N,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:o,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:g,renderSectionActions:u,onDownloadResource:h,downloadStatuses:x,relations:j,onRelationsChange:y})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:r("muted")},children:w.common.noData})},Qy=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],yp=({isOpen:e,onClose:n,onSubmit:i,feedbackListUrl:o})=>{const{t:s}=ae(),[a,l]=f.useState(null),[d,c]=f.useState(""),[p,m]=f.useState(""),[g,u]=f.useState("idle"),[h,x]=f.useState(""),j=f.useRef(null);f.useEffect(()=>{e&&(l(null),c(""),m(""),u("idle"),x(""))},[e]),f.useEffect(()=>{a&&setTimeout(()=>{var b;return(b=j.current)==null?void 0:b.focus()},100)},[a]),f.useEffect(()=>{if(g==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[g,n]),f.useEffect(()=>{if(!e)return;const b=k=>{k.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,n]);const y=async()=>{if(!(!a||!d.trim())){u("submitting"),x("");try{await i({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),u("success")}catch(b){u("error"),x(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const S=a&&d.trim()&&g!=="submitting";return t.jsx("div",{style:e0,onClick:b=>{b.target===b.currentTarget&&n()},children:t.jsxs("div",{style:t0,onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{style:n0,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:i0,"aria-label":s("feedback.close"),children:"✕"})]}),g==="success"?t.jsxs("div",{style:l0,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:Qy.map(b=>t.jsxs("button",{onClick:()=>l(b.value),style:{...r0,...a===b.value?o0:{}},children:[t.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),t.jsx("textarea",{ref:j,value:d,onChange:b=>c(b.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||g==="submitting",style:{...s0,opacity:a?1:.6}}),t.jsx("input",{type:"text",value:p,onChange:b=>m(b.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!a||g==="submitting","aria-label":s("feedback.contactLabel"),style:d0}),t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),g==="error"&&t.jsx("div",{style:c0,children:h}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:y,disabled:!S,style:{...a0,opacity:S?1:.6,cursor:S?"pointer":"not-allowed"},children:s(g==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},e0={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},t0={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:r("shadow-dialog")},n0={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},i0={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:r("desc-fg"),padding:"4px 8px",borderRadius:"4px"},r0={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"},o0={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},s0={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"},a0={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},l0={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:r("success")},c0={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginBottom:"12px"},d0={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"},So="--bim-feedback-fab-offset",_o=48,p0=16,u0=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:i,hidden:o=!1,zIndex:s})=>{const{t:a}=ae(),[l,d]=f.useState(!1),c=n.bottom??24;return f.useEffect(()=>{if(o||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(So,`calc(${c+_o+p0}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(So)}},[o,c]),t.jsxs(t.Fragment,{children:[!o&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...m0,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(yp,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:i})]})},m0={position:"fixed",width:`${_o}px`,height:`${_o}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"},g0=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],jp=({onSubmit:e})=>{const{t:n}=ae(),[i,o]=f.useState("bug"),[s,a]=f.useState(""),[l,d]=f.useState(""),[c,p]=f.useState("idle"),[m,g]=f.useState(""),u=f.useRef(null);f.useEffect(()=>{i&&setTimeout(()=>{var j;return(j=u.current)==null?void 0:j.focus()},100)},[i]);const h=async()=>{if(!(!i||!s.trim())){p("submitting"),g("");try{await e({type:i,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),o("bug")}catch(j){p("error"),g(j instanceof Error?j.message:n("feedback.submitFailedRetry"))}}},x=i&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:$l,children:t.jsxs("div",{style:y0,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:j0,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:$l,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:g0.map(j=>t.jsxs("button",{onClick:()=>o(j.value),style:{...f0,...i===j.value?h0:{}},children:[t.jsx("span",{children:j.icon})," ",n(`feedback.submitType.${j.value}`)]},j.value))}),t.jsx("textarea",{ref:u,value:s,onChange:j=>a(j.target.value),placeholder:n(i?`feedback.placeholder.${i}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...x0}}),t.jsx("input",{type:"text",value:l,onChange:j=>d(j.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:k0}),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:h,disabled:!x,style:{...b0,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:v0,children:m})]})},$l={padding:"16px",border:`1px solid ${r("widget-border")}`,borderRadius:"8px",background:r("input-bg")},f0={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"},h0={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},x0={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"},b0={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},y0={display:"flex",alignItems:"center",gap:"12px",color:r("success"),fontSize:"14px"},j0={background:"none",border:"none",color:r("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},v0={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginTop:"8px"},k0={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 Cl(e){return typeof e=="function"?e():e??"/api/feedback"}const vp=({resourceId:e,apiUrl:n})=>{const{t:i}=ae(),[o,s]=f.useState([]),[a,l]=f.useState(!0),d=f.useCallback(async()=>{const p=Cl(n);l(!0);try{const g=await(await fetch(`${p}?resourceId=${encodeURIComponent(e)}`)).json();g.success&&s(g.items)}catch{}finally{l(!1)}},[e,n]);f.useEffect(()=>{d()},[d]);const c=async p=>{const m=Cl(n),g=await fetch(m,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!g.ok){const u=await g.json().catch(()=>null);throw new Error((u==null?void 0:u.error)||i("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx($s,{items:o,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(jp,{onSubmit:c})})]})},fr=8;async function hr(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 w0=er["zh-Hant"].relation,S0=er["zh-Hant"].lossStatus,_0=er["zh-Hant"].resourceKind,xr=Vn("zh-Hant"),zs=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function zl(e,n=xr){return e?zs(w0,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function $0(e,n=xr){return zs(S0,e)?n(`detail.lossStatus.${e}`):e}function C0(e,n=xr){return zs(_0,e)?n(`detail.resourceKind.${e}`):""}function Ns({authors:e,onNavigate:n,renderLink:i}){const{convert:o}=ae(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=Ho(a.role);return t.jsxs(f.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(bt,{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 kp(e,n,i=xr){var c,p;const o=Wo(e,n),s=o.mirrors.map(m=>({key:m.key,label:m.label,description:m.description,rows:m.items.filter(g=>g.group_role!=="mirror"),mirrors:m.items.filter(g=>g.group_role==="mirror")})),a=o.buckets.filter(m=>m.key==="image"||m.key==="textImage").flatMap(m=>m.items);a.length&&s.push({key:"_images",label:s.length?i("detail.otherImages"):void 0,rows:a,mirrors:[]});const l=((c=o.buckets.find(m=>m.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(m=>m.key==="text"))==null?void 0:p.items)??[],groups:s}}function wp(e,n){const i=(e.url?Hn(e.url):void 0)||e.name,o=hc(e,n);return o?`${i}(${o})`:i}function Ts({item:e,siblings:n,listedVolumeCounts:i}){const{t:o,convert:s}=ae(),[a,l]=f.useState(!1),d=Qi(e),c=!!d&&d.expected>0&&!(i!=null&&i.has(d.expected)),p=s(wp(e,n)),m=Dn(e),g=or(e,o)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var h,x;const u=(h=e.metadata)!=null&&h.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 m?t.jsxs("a",{href:m,target:"_blank",rel:"noopener noreferrer",children:[p," ",t.jsx("span",{"aria-hidden":"true",children:"↗"}),u]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,u]})})(),g&&t.jsx("span",{className:"bim-d-meta",children:s(g)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(ns,{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(u=>!u),children:a?o("detail.collapseVolumes"):o("detail.expandVolumes",{n:d.expected})})})]})}function Sp({groups:e,listedVolumeCounts:n}){const{t:i,convert:o}=ae();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(Ts,{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=Dn(a),c=o(wp(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 di=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function $o(e){var i;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(i=di.find(o=>n.startsWith(o.key[0])))==null?void 0:i.key}const Nl=12,z0=60,_p=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,railTop:a,back:l,railLinks:d})=>{var ke,ve,Ve;const{t:c,convert:p,messages:m}=ae(),g=f.useMemo(()=>Do({_books:e._books}),[e._books]),[u,h]=f.useState(new Map),[x,j]=f.useState(!1),[y,S]=f.useState(""),[b,k]=f.useState(!1),w=g.length<=z0,v=w||x||!!y||b,$=f.useMemo(()=>v?g:g.slice(0,Nl),[g,v]);f.useEffect(()=>{if(!n||$.length===0)return;const F=$.filter(te=>!u.has(te));if(F.length===0)return;let fe=!1;return hr(F,fr,te=>n.getItem(te).then(U=>{var Me;const pe=U??{};return[te,{id:te,title:pe.title,edition:pe.edition,resources:pe.resources,publication_info:pe.publication_info,current_location:pe.current_location,provenance:pe.provenance,lineage:pe.lineage,related_books:pe.related_books,dating:pe.dating,measure_info:pe.measure_info,summary:T0((Me=U==null?void 0:U.description)==null?void 0:Me.text)}]}).catch(()=>[te,{id:te}]),()=>fe).then(te=>{fe||h(U=>{const pe=new Map(U);for(const[Me,Ke]of te)pe.set(Me,Ke);return pe})}),()=>{fe=!0}},[n,$,u]);const _=f.useMemo(()=>g.map(F=>u.get(F)??{id:F}),[g,u]),C=g.length>0&&g.every(F=>u.has(F)),I=!!n&&$.some(F=>!u.has(F)),E=w||v,T=f.useMemo(()=>bc(_,e.version_graph,{era:y,scanOnly:b,sort:E?"year":"default"}),[_,e.version_graph,y,b,E]),N=x?T.rows:T.rows.slice(0,Nl),P=T.allRows.filter(F=>F.hasImage).length,W=T.allRows.reduce((F,fe)=>{var te;return F+(((te=fe.copies)==null?void 0:te.length)??0)},0),L=f.useMemo(()=>(e._related||[]).map(F=>({...F,title:F.title??""})),[e._related]),K=L.filter(F=>F.relation==="collected_in"),Q=f.useMemo(()=>{const F=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],fe=te=>{const U=F.indexOf(te??"");return U<0?F.length:U};return L.filter(te=>te.relation!=="collected_in").map((te,U)=>({r:te,i:U})).sort((te,U)=>fe(te.r.relation)-fe(U.r.relation)||te.i-U.i).map(te=>te.r)},[L]),Z=f.useMemo(()=>{const F=Wo(e.resources,e.resource_groups);return[...F.mirrors.flatMap(fe=>fe.items.map(te=>({r:te,kind:p(fe.label)}))),...F.buckets.flatMap(fe=>fe.items.map(te=>({r:te,kind:p(C0(fe.key,c))})))]},[e.resources,e.resource_groups,p,c]),ue=e.indexed_by||[],J=e.emendated_by||[],le=f.useMemo(()=>{var nt,it,at,lt,rt;const F=[],fe=(it=(nt=e.authors)==null?void 0:nt[0])==null?void 0:it.dynasty;fe&&F.push({label:c("workPage.fact.written"),value:p(fe)});const te=on(e,m.unit.juan);if(te){const Pe=((at=e.juan_count)==null?void 0:at.description)??((rt=(lt=e.measures)==null?void 0:lt.find(z=>(z==null?void 0:z.unit)==="卷"&&z.note))==null?void 0:rt.note);F.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(te),Pe&&Pe!==te?t.jsxs("span",{className:"bim-d-meta",children:["(",p(Pe),")"]}):null]})})}e.loss_status&&F.push({label:c("workPage.fact.loss"),value:p($0(e.loss_status,c))}),e.authenticity==="forged"&&F.push({label:c("workPage.fact.authenticity"),value:p(c("workPage.fact.forged")),title:e.authenticity_basis?p(e.authenticity_basis):void 0});const U=T.allRows.filter(Pe=>Pe.sortYear!=null),pe=U.length>0?U.reduce((Pe,z)=>Pe.sortYear<=z.sortYear?Pe:z):null;pe!=null&&pe.era.era?F.push({label:c("workPage.fact.earliest"),value:p([pe.era.era,pe.era.reign].filter(Boolean).join(" ")),title:pe.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):I&&F.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),J.length&&F.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:J.length})});const Me=N0(e.additional_titles);Me.length&&F.push({label:c("workPage.fact.alias"),value:Me.map(p).join("、")});const Ke=(e.additional_works||[]).map(Pe=>p(Pe.book_title)+(Pe.n_juan!=null?` ${Pe.n_juan}${m.unit.juan}`:""));return Ke.length&&F.push({label:c("workPage.fact.appendix"),value:Ke.join("、")}),F},[e,p,c,m,I,T.allRows,J.length]),oe=[{value:e._edition_count??g.length,label:c("workPage.stat.editions")},{value:C?P:0,label:c("workPage.stat.hasImage")},{value:ue.length,label:c("workPage.stat.catalogs")}],be=Uo(e),ze=be?[be.l1,be.l2,be.l3,be.l4].filter(Boolean).map(F=>p(F)):[],Le=e.subtype?m.workSubtype[e.subtype]??p(e.subtype):"",_e=t.jsx(fi,{title:p(e.title),byline:t.jsx(Ns,{authors:e.authors,onNavigate:i,renderLink:o}),meta:t.jsx(vt,{items:[...ze,be!=null&&be.source?c("workPage.classifiedBy",{source:p(be.source.split("/")[0])}):"",Le]}),description:(ke=e.description)!=null&&ke.text?t.jsxs(t.Fragment,{children:[t.jsx(sn,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(ve=e.description.sources)!=null&&ve.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(F=>({text:p(xg(F)),href:bg(F)})).filter(F=>F.text).map((F,fe)=>t.jsxs(f.Fragment,{children:[fe>0?" · ":null,F.href?t.jsx("a",{href:F.href,target:"_blank",rel:"noopener noreferrer",children:F.text}):F.text]},fe))}):null]}):void 0,stats:oe,facts:le,readAction:s,foot:t.jsx(hi,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(Ve=e.appendix)==null?void 0:Ve.map((F,fe)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(F.title)}),t.jsx(sn,{text:F.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},fe))}),re=T.eras.length>=2?[{key:"",label:c("catalog.all")},...T.eras.map(F=>({key:F,label:`${F} ${T.allRows.filter(fe=>fe.era.era===F).length}`}))]:[],xe=[];g.length&&xe.push({id:"versions",label:c("workPage.sec.versions"),count:g.length}),ue.length&&xe.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:ue.length}),K.length&&xe.push({id:"collected",label:c("workPage.sec.collected"),count:K.length}),Q.length&&xe.push({id:"related",label:c("workPage.sec.related"),count:Q.length}),Z.length&&xe.push({id:"resources",label:c("workPage.sec.resources"),count:Z.length});const R=g.length===0&&ue.length===0,se=t.jsxs(t.Fragment,{children:[g.length>0&&t.jsxs(wt,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(vt,{items:[c("workPage.versionsTotal",{n:g.length-W}),C&&P?c("workPage.versionsWithImage",{n:P}):"",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":I&&re.length===0&&g.length>1?"":void 0,children:[re.length>0&&t.jsx(pr,{items:re,value:y,onChange:F=>{S(F),j(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(ld,{label:c("workPage.scanOnly"),checked:b,onChange:F=>{k(F),j(!1)}}),t.jsx("span",{className:"bim-d-meta",children:c(E?"workPage.sortByYear":"workPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&ur(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:N.map(F=>{var fe;return t.jsx(R0,{row:F,measure:(fe=u.get(F.id))==null?void 0:fe.measure_info,loaded:u.has(F.id),onNavigate:i,renderLink:o},`${F.id}:${u.has(F.id)?"r":"p"}`)})})]}),N.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(Jo,{total:T.rows.length,shown:N.length,unit:c("workPage.moreUnit"),onClick:()=>j(!0)}),T.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),ue.length>0&&t.jsx(I0,{items:ue,transport:n,onNavigate:i,renderLink:o}),R&&t.jsx(wt,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),de=(F,fe)=>t.jsx(bt,{id:F,label:p(fe),onNavigate:i,renderLink:o,dense:!0}),O=f.useMemo(()=>{const F=new Map;for(const fe of Q){const te=zl(fe.relation,c);F.set(te,(F.get(te)??0)+1)}return F.size>1?[...F.entries()].sort((fe,te)=>te[1]-fe[1]).slice(0,4).map(([fe,te])=>`${p(fe)} ${te}`).join(" · "):void 0},[Q,p,c]),ee=t.jsxs(t.Fragment,{children:[t.jsx(vn,{id:"collected",title:c("workPage.sec.collected"),items:K.map(F=>de(F.id,F.title))}),t.jsx(vn,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:Q.length}),sub:O,items:Q.map(F=>t.jsxs(t.Fragment,{children:[de(F.id,F.title),t.jsx("span",{className:"bim-d-meta",title:F.note?p(F.note):void 0,children:p(zl(F.relation,c))})]}))}),t.jsx(vn,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:Z.map(({r:F,kind:fe})=>{const te=p((F.url?Hn(F.url):void 0)||F.name),U=Dn(F);return t.jsxs(t.Fragment,{children:[U?t.jsxs("a",{href:U,target:"_blank",rel:"noopener noreferrer",children:[te," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:te}),fe&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:fe})]})})})]});return t.jsx(gi,{railTop:a,back:l,nav:xe,railLinks:d,main:se,card:_e,side:ee})};function N0(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Co(e,n){return n((e.url?Hn(e.url):void 0)||e.name)}function T0(e){var a;if(!e)return;const i=e.replace(/\*\*/g,"").split(/\n/)[0].trim().match(/[^。]+。?/g)??[],s=((i.length>1&&((a=i[0])!=null&&a.startsWith("《"))?i[1]:i[0])??"").trim();return s?s.length>120?`${s.slice(0,120)}…`:s:void 0}function E0({copies:e,onNavigate:n,renderLink:i}){const{t:o,convert:s}=ae(),a=new Map;for(const l of e){const d=l.locationName||(l.holders[0]?Co(l.holders[0],s):"")||"",c=a.get(d)??[];c.push(l),a.set(d,c)}return t.jsxs("span",{className:"bim-d-zt-copies",children:[o("workPage.sameEditionCopies",{n:e.length}),[...a].map(([l,d],c)=>t.jsxs(f.Fragment,{children:[c>0?";":"",l?`${s(l)} `:"",d.map((p,m)=>t.jsxs(f.Fragment,{children:[m>0?" · ":"",t.jsx(bt,{id:p.id,label:p.callNumber||p.id,onNavigate:n,renderLink:i,dense:!0})]},p.id))]},l||c))]})}function R0({row:e,measure:n,loaded:i,onNavigate:o,renderLink:s}){const{t:a,convert:l}=ae(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],m=e.copies??[],g=m.length&&e.locationName?l(e.locationName):p?Co(p,l):e.locationName?l(e.locationName):"",u=e.images[0],h=u?Dn(u):void 0,x=e.images.map(j=>Co(j,l)).join("、");return t.jsxs("tr",{"data-loading":i?void 0:"",className:m.length?"bim-d-zt-group":void 0,children:[t.jsxs("td",{className:m.length?"bim-d-zt-main bim-d-zt-rep":"bim-d-zt-main",children:[t.jsx(bt,{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:" "}),m.length>0&&e.summary&&t.jsx("span",{className:"bim-d-zt-summary",children:l(e.summary)}),m.length>0&&t.jsx(E0,{copies:m,onNavigate:o,renderLink:s})]}),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${g?"":" bim-d-zt-blank"}`,children:[g||(i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),m.length>0&&e.callNumber&&t.jsx("span",{className:"bim-d-meta",style:{display:"block",fontSize:12},children:e.callNumber}),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&&(h?t.jsx("a",{className:"bim-d-flag",href:h,target:"_blank",rel:"noopener noreferrer",title:x,children:a("workPage.hasImage")}):t.jsx("span",{className:"bim-d-flag",title:x,children:a("workPage.hasImage")}))})]})}function I0({items:e,transport:n,onNavigate:i,renderLink:o}){const{t:s,convert:a}=ae(),[l,d]=f.useState(0),c=Math.min(l,e.length-1),p=e[c],[m,g]=f.useState(new Map);return f.useEffect(()=>{if(!n)return;const u=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(u.length===0)return;let h=!1;return Promise.all(u.map(x=>n.getItem(x).then(j=>{var y,S;return[x,((S=(y=j==null?void 0:j.authors)==null?void 0:y[0])==null?void 0:S.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{h||g(new Map(x.filter(([,j])=>j)))}),()=>{h=!0}},[n,e]),t.jsx(wt,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(vt,{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((u,h)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":h===c,"aria-label":a(u.source),onClick:()=>d(h),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:m.get(u.source_bid??"")?a(m.get(u.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(u.source)].slice(0,9).map((x,j)=>t.jsx("span",{children:x},j))})]})},h))}),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(vt,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(bt,{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:Ot(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:Ot(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:Ot(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"})]})]})]})})}const $p=({graph:e,renderLink:n,className:i,style:o})=>{const{t:s,convert:a}=ae();if(!e.nodes.length)return t.jsx("div",{style:{...Y0,...o},className:i,children:s("lineage.emptyGraph")});const l=new Map,d=new Map;for(const h of e.edges)if(h.kind==="derive"){const x=l.get(h.target)??[];x.push(h),l.set(h.target,x)}else for(const x of[h.source,h.target]){const j=d.get(x)??[];j.push(h),d.set(x,j)}const c=new Map(e.nodes.map(h=>[h.id,h])),p=new Map,m=[];for(const h of e.nodes)if(h.group){const x=p.get(h.group)??[];x.push(h),p.set(h.group,x)}else m.push(h);const g=(h,x)=>(h.year??9999)-(x.year??9999);p.forEach(h=>h.sort(g)),m.sort(g);const u=e.groups.filter(h=>p.has(h.id));return t.jsxs("div",{className:i,style:{...A0,...o},children:[e.title&&t.jsx("div",{style:M0,children:a(e.title)}),e.description&&t.jsx("div",{style:P0,children:a(e.description)}),u.map(h=>t.jsx(Tl,{label:h.label,color:h.color,nodes:p.get(h.id),incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n},h.id)),m.length>0&&t.jsx(Tl,{label:s("lineage.otherGroup"),nodes:m,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},Tl=({label:e,color:n,nodes:i,incomingMap:o,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=ae();return t.jsxs("div",{style:B0,children:[t.jsx("div",{style:{...O0,borderLeftColor:n??r("widget-border")},children:d(e)}),i.map(c=>t.jsx(L0,{node:c,incoming:o.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},L0=({node:e,incoming:n,siblings:i,nodeMap:o,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=ae();return t.jsxs("div",{style:{...W0,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:F0,children:[t.jsx("span",{style:H0,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:D0,children:uc(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:U0,children:[e.category&&t.jsx(ni,{children:c(e.category)}),e.status==="lost"&&t.jsx(ni,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(ni,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(ni,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(ni,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:V0,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:G0,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:Rl,children:[t.jsx("div",{style:Il,children:d("lineage.sources")}),n.map(p=>{const m=o.get(p.source);return t.jsxs("div",{style:Ll(p.confidence),children:[t.jsx("span",{style:Al,children:c(p.relation)}),t.jsx("span",{children:(m==null?void 0:m.kind)==="book"&&s?s(m.id,c(m.label)):c((m==null?void 0:m.label)??p.source)}),p.confidence!=="consensus"&&p.confidence!=="certain"&&t.jsx(El,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Ml,children:["· ",c(p.evidence)]})]},p.id)})]}),i.length>0&&t.jsxs("div",{style:Rl,children:[t.jsx("div",{style:Il,children:d("lineage.related")}),i.map(p=>{const m=p.source===e.id?p.target:p.source,g=o.get(m);return t.jsxs("div",{style:Ll(p.confidence),children:[t.jsx("span",{style:Al,children:c(p.relation)}),t.jsx("span",{children:(g==null?void 0:g.kind)==="book"&&s?s(g.id,c(g.label)):c((g==null?void 0:g.label)??m)}),t.jsx(El,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Ml,children:["· ",c(p.evidence)]})]},p.id)})]})]})},ni=({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})},El=({level:e})=>{const{t:n}=ae(),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},A0={fontSize:"14px",color:r("fg")},M0={fontSize:"16px",fontWeight:600,marginBottom:"8px"},P0={fontSize:"13px",color:r("muted"),marginBottom:"16px",lineHeight:1.6},B0={marginBottom:"16px"},O0={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:r("fg")},W0={border:`1px solid ${r("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:r("bg")},F0={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},H0={fontSize:"15px",fontWeight:600},D0={fontSize:"12px",color:r("muted")},U0={marginBottom:"6px"},V0={fontSize:"12px",color:r("muted"),margin:"2px 0"},G0={fontSize:"12px",color:r("muted"),fontStyle:"italic",margin:"4px 0"},Rl={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${r("widget-border")}`},Il={fontSize:"11px",color:r("muted"),marginBottom:"2px"},Ll=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),Al={display:"inline-block",padding:"0 6px",fontSize:"11px",background:r("tag-bg"),color:r("fg"),borderRadius:"3px",marginRight:"6px"},Ml={fontSize:"11px",color:r("muted")},Y0={padding:"20px",textAlign:"center",color:r("muted"),fontSize:"13px"},Cp=({selectedNodeId:e,...n})=>{const{t:i}=ae(),[o,s]=f.useState("loading"),[a,l]=f.useState(null);return f.useEffect(()=>{let d=!1;return K0().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),o==="loading"?t.jsx("div",{style:Bl,children:i("lineage.graphLoading")}):o==="missing"||!a?t.jsxs("div",{style:Bl,children:[t.jsx("div",{children:Pl(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:Pl(i("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(q0,{modules:a,selectedNodeId:e,...n})};function Pl(e,n){return e.split(/(\{\w+\})/).map((i,o)=>{const s=/^\{(\w+)\}$/.exec(i);return t.jsx(f.Fragment,{children:s&&s[1]in n?n[s[1]]:i},o)})}async function K0(){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 q0=({graph:e,renderLink:n,height:i=600,className:o,style:s,selectedNodeId:a,modules:l})=>{const{ReactFlow:d,Background:c,Controls:p,Handle:m,Position:g,BaseEdge:u,EdgeLabelRenderer:h,getSmoothStepPath:x,dagre:j}=l,y=f.useMemo(()=>({lineage:$=>{var K,Q,Z,ue;const _=((K=$.data)==null?void 0:K.stepPosition)??.85,[C,I,E]=x({sourceX:$.sourceX,sourceY:$.sourceY,sourcePosition:$.sourcePosition,targetX:$.targetX,targetY:$.targetY,targetPosition:$.targetPosition,stepPosition:_,borderRadius:5}),T=!!((Q=$.data)!=null&&Q.isSibling),N=T?I:$.targetX-18,P=T?E:$.targetY-12,W=(Z=$.data)==null?void 0:Z.labelStyle,L=(ue=$.data)==null?void 0:ue.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(u,{id:$.id,path:C,style:$.style,markerStart:$.markerStart,markerEnd:$.markerEnd}),$.label&&t.jsx(h,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${N}px,${P}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:r("bg"),border:`0.5px solid ${r("widget-border")}`,...L,...W},children:$.label})})]})}}),[u,h,x]),S=f.useMemo(()=>({version:$=>{const{t:_}=ae(),C=$.data,I=C.kind==="hypothetical",E=C.status==="lost",T=C.isSelected,N=C.bridge,P=C.borderColor??r("muted"),W=N||I?"dashed":"solid",L=N?.5:E?.6:1;return t.jsxs("div",{style:{background:r(N?"bg-subtle":"bg"),border:`2px ${W} ${T?r("primary"):P}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:L,boxShadow:T?r("shadow-node-selected"):I||N?"none":r("shadow-node")},title:N?_("lineage.bridgeTitle"):void 0,children:[t.jsx(m,{type:"target",position:g.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:I||!C.renderLink?C.label:C.renderLink(C.bookId,C.label)}),C.description&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.25,marginTop:1},children:C.description}),C.yearText&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.2},children:uc(C.yearText,void 0,C.uncertain)}),E&&t.jsx("div",{style:{fontSize:9,color:r("lost-fg"),marginTop:1},children:_("lineage.lost")}),t.jsx(m,{type:"source",position:g.Right,style:{visibility:"hidden"}})]})}}),[m,g]),{convert:b}=ae(),{rfNodes:k,rfEdges:w}=f.useMemo(()=>X0(e,j,n,a,b),[e,j,n,a,b]);return t.jsx("div",{style:{width:"100%",height:i,...s},className:o,children:t.jsxs(d,{nodes:k,edges:w,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 X0(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 m=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const S of e.edges)S.kind==="derive"&&(m.has(S.relation)||c.setEdge(S.source,S.target));n.layout(c);const g=e.nodes.map(S=>{const b=c.node(S.id),k=o?S.id===o:void 0,w={kind:S.kind,label:s(S.label),bookId:S.kind==="book"?S.id:void 0,yearText:s(S.year_text??J0(S)),uncertain:S.year_uncertain,category:S.category,status:S.status,borderColor:S.group?p.get(S.group):void 0,renderLink:i,isSelected:k,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:w,draggable:!1,selected:k}}),u=.78,h=.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 j=new Map;for(const[S,b]of x){if(b.length<=1)continue;const k=[...b].sort((v,$)=>{var I,E;const _=((I=c.node(v.target))==null?void 0:I.y)??0,C=((E=c.node($.target))==null?void 0:E.y)??0;return _-C}),w=k.length;k.forEach((v,$)=>{const _=($-(w-1)/2)*h;j.set(v.id,u+_)})}const y=e.edges.map(S=>Z0(S,j.get(S.id),s));return{rfNodes:g,rfEdges:y}}function Z0(e,n,i=o=>o??""){const o=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=Q0(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 J0(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function Q0(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 Bl={padding:"40px 20px",textAlign:"center",color:r("muted"),fontSize:"13px",border:`1px dashed ${r("widget-border")}`,borderRadius:8,background:r("bg")},Es=({graph:e,defaultMode:n="list",renderLink:i,graphHeight:o=600,selectedNodeId:s,onModeChange:a,collection:l,onCollectionChange:d,collectionsAvailable:c,collectionCounts:p,className:m,style:g})=>{var w;const{t:u,convert:h}=ae(),[x,j]=f.useState(n),y=v=>{j(v),a==null||a(v)},S=(()=>{if(!c)return[];const v=Object.entries(c);return v.length===0||c.all?v:[...v,["all",{label:u("lineage.collectionAll"),description:u("lineage.collectionAllDesc")}]]})(),b=!!(d&&S.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:r("muted"),textAlign:"center"},children:u("lineage.empty")});const k=l?(w=c==null?void 0:c[l])==null?void 0:w.description:void 0;return t.jsxs("div",{className:m,style:g,children:[t.jsxs("div",{style:e1,children:[t.jsx("button",{onClick:()=>y("list"),style:Zr(x==="list"),children:u("lineage.modeList")}),t.jsx("button",{onClick:()=>y("graph"),style:Zr(x==="graph"),children:u("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:u("lineage.collectionLabel")}),S.map(([v,$])=>{const _=p==null?void 0:p[v];return t.jsxs("button",{onClick:()=>d==null?void 0:d(v),style:Zr(l===v),title:$.description?h($.description):void 0,children:[h($.label),_!=null?` ${_}`:""]},v)})]})]}),b&&k&&t.jsx("div",{style:{fontSize:12,color:r("muted"),marginBottom:8,padding:"4px 8px",background:r("bg-subtle"),borderRadius:4},children:h(k)}),x==="list"?t.jsx($p,{graph:e,renderLink:i}):t.jsx(Cp,{graph:e,renderLink:i,height:o,selectedNodeId:s})]})},e1={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},Zr=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"}),Ol=40,Wl=2,t1=9,n1=new Set(["certain","consensus","probable","disputed"]);function Jr(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const zp=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:m})=>{var it,at,lt,rt,Pe,z,ne,q,he,Ie;const g=Ae(),{t:u,convert:h}=ae(),[x,j]=f.useState(null),[y,S]=f.useState(new Map),[b,k]=f.useState([]),[w,v]=f.useState(new Map),[$,_]=f.useState(!1),[C,I]=f.useState("flow"),[E,T]=f.useState(null);f.useEffect(()=>{if(!n||!e.work_id){j(null);return}let M=!1;return n.getItem(e.work_id).then(me=>{!M&&me&&me.type==="work"&&j(me)}).catch(()=>{}),()=>{M=!0}},[n,e.work_id]),f.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){T(null);return}let M=!1;return n.getLineageGraph(e.work_id).then(me=>{M||T(me&&me.nodes.length>1?me:null)}).catch(()=>{M||T(null)}),()=>{M=!0}},[n,e.work_id]),f.useEffect(()=>{const M=e._collections||[];if(!n||M.length===0){S(new Map);return}let me=!1;return Promise.all(M.map(G=>{const Se=G.id;return n.getItem(Se).then(ye=>[Se,ye]).catch(()=>[Se,null])})).then(G=>{if(me)return;const Se=new Map;for(const[ye,Ee]of G)Ee&&Se.set(ye,Ee);S(Se)}),()=>{me=!0}},[n,e._collections]);const N=f.useMemo(()=>{const M=new Set([...x?Do(x):[],...pc(e)]);return M.add(e.id),[...M]},[x,e.related_books,e.id]),P=N.length-1;f.useEffect(()=>{if(!n||P<=0){k([]);return}const M=N.length<=Ol,me=M?N:N.slice(0,8);let G=!1;return Promise.all(me.map(Se=>Se===e.id?Promise.resolve({id:Se,title:e.title,edition:e.edition,year:Yi(e)}):n.getItem(Se).then(ye=>{const Ee=ye??{};return{id:Se,title:Ee.title,edition:Ee.edition,year:ye?Yi(Ee):void 0}}).catch(()=>({id:Se})))).then(Se=>{if(G)return;const ye=Se.filter(Ee=>Ee.id===e.id||Ee.title||Ee.edition);M&&ye.sort((Ee,Xe)=>(Ee.year??1/0)-(Xe.year??1/0)),k(ye)}),()=>{G=!0}},[n,N,P,e]),e.lineage;const W=f.useMemo(()=>[...nn(e).filter(M=>M.ref_type==="book").map(M=>M.ref),...wn(e).map(M=>M.book_id)].filter(Boolean),[e]);f.useEffect(()=>{if(!n||W.length===0){v(new Map);return}let M=!1;return Promise.all(W.map(me=>n.getItem(me).then(G=>[me,{id:me,title:G==null?void 0:G.title,edition:G==null?void 0:G.edition}]).catch(()=>[me,{id:me}]))).then(me=>{M||v(new Map(me))}),()=>{M=!0}},[n,W]);const L=f.useMemo(()=>kp(e.resources,e.resource_groups,u),[e.resources,e.resource_groups,u]),K=L.groups.reduce((M,me)=>M+me.rows.length+me.mirrors.length,0),Q=L.groups.length>0&&L.groups.every(M=>M.key==="_physical"),Z=mi(e),ue=wc(e),J=on(e,g.unit.juan),le=new Set((e._collections||[]).map(M=>ai(M.vol).length).filter(M=>M>0)),H=M=>{var Se;const me=(Se=e.base_edition)==null?void 0:Se.find(ye=>ye.book_id===M&&ye.name);if(me!=null&&me.name)return me.name;const G=w.get(M);return(G==null?void 0:G.edition)||(G==null?void 0:G.title)||""},oe=f.useMemo(()=>{var Qe,ut;const M=[];ue&&M.push({label:u("bookPage.fact.editionType"),value:h(ue),title:e.edition_type?void 0:u("bookPage.inferredFromEdition")}),(Qe=e.publication_info)!=null&&Qe.details?M.push({label:u("bookPage.fact.publication"),value:h(e.publication_info.details)}):(Z.era||Z.reign)&&M.push({label:u("bookPage.fact.era"),value:h([Z.era,Z.reign].filter(Boolean).join(" ")),title:Z.source==="edition"?u("bookPage.inferredFromEdition"):void 0}),J&&M.push({label:u("bookPage.fact.measure"),value:h(J)});const me=(e._collections||[]).flatMap(X=>ai(X.vol));me.length&&M.push({label:u("bookPage.fact.volumes"),value:u("bookPage.volumesValue",{range:sr(me,g.unit.volume),unit:g.unit.volume,n:me.length})});const G=nn(e).find(X=>X.relation==="底本"&&X.ref_type==="book");G&&H(G.ref)&&M.push({label:u("bookPage.fact.baseEdition"),value:t.jsx(bt,{id:G.ref,label:h(H(G.ref)),onNavigate:i,renderLink:o,dense:!0})});const Se=(e.base_edition||[]).filter(X=>X&&X.name);for(const X of["底本","配補","參校"]){if(X==="底本"&&G&&H(G.ref))continue;const $e=Se.filter(je=>je.role===X);$e.length&&M.push({label:h(X),value:$e.map((je,De)=>t.jsxs(f.Fragment,{children:[De>0&&"、",je.book_id?t.jsx(bt,{id:je.book_id,label:h(je.name),onNavigate:i,renderLink:o,dense:!0}):h(je.name)]},De))})}const ye=(e.provenance||[]).filter(X=>X&&X.institution),Ee=(e.resources||[]).filter(X=>rn(X).includes("physical"));if(ye.length){M.push({label:u("bookPage.fact.holdings"),value:ye.slice(0,2).map(je=>h(je.institution)).join("、")+(ye.length>2?u("bookPage.andMorePlaces",{n:ye.length}):"")});const X=ye.filter(je=>je.call_number).slice(0,2).map(je=>`${h(je.institution)} ${je.call_number}`);X.length&&M.push({label:u("bookPage.fact.callNumber"),value:X.join(";")+(ye.filter(je=>je.call_number).length>2?"…":"")});const $e=ye.flatMap(je=>je.seals||[]).filter(Boolean);$e.length&&M.push({label:u("bookPage.fact.seals"),value:h($e.join("、"))})}else Ee.length&&M.push({label:u("bookPage.fact.holdings"),value:Ee.slice(0,2).map(X=>h(X.name)).join("、")+(Ee.length>2?u("bookPage.andMorePlaces",{n:Ee.length}):"")});const Xe=e.physical_description;if(Xe){const X=[[u("bookPage.fact.leafStyle"),Xe.leaf_style],[u("bookPage.fact.binding"),Xe.binding],[u("bookPage.fact.dimensions"),Xe.dimensions],[u("bookPage.fact.condition"),Xe.condition]];for(const[$e,je]of X)je&&je.trim()&&M.push({label:$e,value:h(je)})}(ut=e.page_count)!=null&&ut.description&&M.push({label:g.label.pageCount,value:h(e.page_count.description)});const Fe=jd(e.additional_titles);return Fe.length&&M.push({label:u("bookPage.fact.aliases"),value:Fe.map(h).join("、")}),M},[e,h,g,u,Z,ue,J,w,i,o]),be=h(e.title),ze=e.edition?h(e.edition):void 0,Le=((it=e.dating)==null?void 0:it.text)||"",_e=t.jsx(fi,{kind:u("bookPage.kind"),title:be,subtitle:ze,byline:t.jsx(Ns,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:i,renderLink:o}),meta:(()=>{const M=[ue?h(ue):"",Z.era?h([Z.era,Z.reign].filter(Boolean).join("")):"",J?h(J):""].filter(Boolean);return M.length?t.jsx("span",{className:"bim-d-tags",children:M.map((me,G)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(G,2)}`,children:me},G))}):null})(),description:(at=e.description)!=null&&at.text?t.jsx(sn,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:es((lt=e.description)==null?void 0:lt.text)?6:void 0,facts:oe,readAction:s,secondaryAction:s&&K>0&&!Q?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:u("bookPage.viewImages")}):void 0,foot:t.jsx(hi,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),re=e._collections||[],xe=(a==null?void 0:a.chapters)||[],R=h(xe[0]&&Jr(xe[0].title)[0].slice(-1)||"")||u("bookPage.chapterUnit"),se=u("bookPage.chapterCount",{n:xe.length,unit:R}),de=!!(nn(e).length||wn(e).length||(rt=e.appendix)!=null&&rt.length),O=[],ee=u(Q?"bookPage.sec.physical":"bookPage.sec.images");(xe.length||L.text.length||l)&&O.push({id:"fulltext",label:u("bookPage.sec.fulltext"),count:xe.length?se:void 0}),L.groups.length&&O.push({id:"images",label:ee,count:K}),de&&O.push({id:"lineage",label:u("bookPage.sec.lineage")}),re.length&&O.push({id:"collections",label:u("section.containedIn"),count:re.length}),(Pe=e.location_history)!=null&&Pe.length&&O.push({id:"provenance",label:u("section.locationHistory")});const ke=M=>(d==null?void 0:d(M))??null,ve=xe[0],Ve=ve?ke(ve.file):null,F=$?xe:xe.slice(0,t1),fe=(M,me,G)=>M?t.jsx("a",{className:G,href:M.href??"#",onClick:M.onClick?Se=>{Se.metaKey||Se.ctrlKey||(Se.preventDefault(),M.onClick())}:void 0,children:me}):t.jsx("span",{className:G,children:me}),te=t.jsxs(t.Fragment,{children:[(xe.length>0||L.text.length>0||l)&&t.jsxs(wt,{id:"fulltext",title:u("bookPage.sec.fulltext"),meta:xe.length>0?t.jsx(vt,{items:[se,(z=a==null?void 0:a.source)!=null&&z.name?u("bookPage.sourceBy",{src:h(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!ve&&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"})]}),ve&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:u("bookPage.readFrom",{ch:h(Jr(ve.title)[0])||u("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:h((ve.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),fe(Ve,t.jsxs(t.Fragment,{children:[u("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),xe.length>1&&t.jsx("ul",{className:"bim-d-chap",children:F.map(M=>{const[me,G]=Jr(M.title);return t.jsx("li",{children:fe(ke(M.file),t.jsxs(t.Fragment,{children:[me&&t.jsx("b",{children:h(me)}),h(G||M.file)]}))},M.file)})}),xe.length>F.length&&t.jsx(Qo,{label:u("detail.expandRest",{n:xe.length-F.length,unit:R}),onClick:()=>_(!0)}),L.text.length>0&&t.jsxs(t.Fragment,{children:[(xe.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:u("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:L.text.map((M,me)=>t.jsx(Ts,{item:M,siblings:L.text,listedVolumeCounts:le},`${M.id||M.url||M.name}-${me}`))})})]})]}),L.groups.length>0&&t.jsx(wt,{id:"images",title:ee,meta:t.jsx(vt,{items:[L.groups.length>1?u("bookPage.groupCount",{n:L.groups.length}):"",u("bookPage.placeCount",{n:K})]}),children:t.jsx(Sp,{groups:L.groups,listedVolumeCounts:le})}),de&&t.jsx(wt,{id:"lineage",title:u("bookPage.sec.lineage"),meta:nn(e).length?u("bookPage.lineageMeta"):void 0,action:E?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":u("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":C==="flow",onClick:()=>I("flow"),children:u("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":C==="graph",onClick:()=>I("graph"),children:u("bookPage.viewGraph")})]}):void 0,children:C==="graph"&&E?t.jsx(Es,{graph:E,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(M,me)=>t.jsx(bt,{id:M,label:h(me),onNavigate:i,renderLink:o,dense:!0})}):t.jsx(r1,{data:e,heading:ze||be,yearText:Le,refName:H,onNavigate:i,renderLink:o})}),re.length>0&&t.jsx(wt,{id:"collections",title:u("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:re.map((M,me)=>{const G=M.id,Se=ai(M.vol),ye=y.get(G),Ee=fg(ye);return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(bt,{id:G,label:ye?h(ye.title):G,onNavigate:i,renderLink:o,dense:!0}),Se.length>0&&t.jsx(i1,{volumes:Se,unit:g.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Ee?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:Ee>0&&u("bookPage.totalOf",{n:Ee,unit:g.unit.bu})})]},`${G}-${me}`)})})})}),(ne=e.location_history)!=null&&ne.length?t.jsx(wt,{id:"provenance",title:u("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((M,me)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:h(M.name||M.location||"")}),([M.start_date,M.end_date].filter(Boolean).join("—")||M.description||M.note)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(vt,{items:[[M.start_date,M.end_date].filter(Boolean).join("—"),M.description?h(M.description):"",M.note?h(M.note):""]})})]},me))})}):null,O.length===0&&t.jsx(wt,{title:u("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:u("bookPage.emptyText")})})]}),U=b.findIndex(M=>M.id===e.id),pe=N.length<=Ol,Me=pe&&U>=0?b.slice(Math.max(0,U-Wl),U+Wl+1):b.filter(M=>M.id!==e.id),Ke=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:h(g.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(bt,{id:x.id,label:h(x.title),onNavigate:i,renderLink:o})}),t.jsx(vt,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(M=>`${M.dynasty?`〔${h(M.dynasty)}〕`:""}${h(M.name)}`),h(on(x,g.unit.juan)),x._edition_count??((q=x._books)==null?void 0:q.length)?u("bookPage.editionCount",{n:x._edition_count??((he=x._books)==null?void 0:he.length)??0}):""]}),((Ie=x.description)==null?void 0:Ie.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:h(x.description.text.replace(/[#*_>`[\]]/g,""))})]}),P>0&&Me.length>0&&t.jsxs("div",{children:[t.jsx(vn,{id:"siblings",timeline:!0,title:pe?u("bookPage.siblings"):g.relation.siblingVersions,meta:pe?u("bookPage.byEra"):u("bookPage.kindCount",{n:P}),cap:Me.length,items:Me.map(M=>M.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:h(M.edition||M.title||M.id)}):t.jsx(bt,{id:M.id,label:h(M.edition||M.title||M.id),onNavigate:i,renderLink:o,dense:!0})),metas:Me.map(M=>[M.year!=null?M.year<0?u("detail.bce",{n:-M.year}):String(M.year):"",M.id===e.id?u("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:Me.findIndex(M=>M.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(bt,{id:x.id,label:u("bookPage.viewAllInWork",{n:N.length}),onNavigate:i,renderLink:o,dense:!0})})]})]}),nt=e.work_id?t.jsx(ad,{caption:g.section.belongsToWork,children:t.jsx(bt,{id:e.work_id,label:x?h(x.title):" ",onNavigate:i,renderLink:o,dense:!0})}):void 0;return t.jsx(gi,{railTop:c,back:p,up:nt,nav:O,railLinks:m,main:te,card:_e,side:Ke})};function i1({volumes:e,unit:n}){const{t:i}=ae();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[i("bookPage.volumeRange",{range:sr(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 r1({data:e,heading:n,yearText:i,refName:o,onNavigate:s,renderLink:a}){var S;const{t:l,convert:d}=ae(),c=e.lineage,p=nn(e),m=p.filter(b=>b.ref_type!=="book"),g=p.filter(b=>b.ref_type==="book"&&b.relation==="底本"),u=p.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),h=wn(e),x=p.length>0||h.length>0,j=b=>b&&n1.has(b)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${b}`)}):"",y=(b,k)=>t.jsx(bt,{id:b,label:d(k||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:[m.map((b,k)=>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),j(b.confidence)]})]})},`a-${k}`)),g.map((b,k)=>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),j(b.confidence)]})]})},`b-${k}`)),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)})]}),u.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:u.map((b,k)=>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),j(b.confidence)]})]},k))})]}),h.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:h.map((b,k)=>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)})]},k))})]})]}),(S=e.appendix)==null?void 0:S.map((b,k)=>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(sn,{text:b.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${k}`)),(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 ii=16,o1=200,s1=16,Np=({data:e,catalog:n,transport:i,onNavigate:o,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var pe,Me,Ke,nt,it,at,lt,rt,Pe;const{t:p,convert:m,messages:g}=ae(),[u,h]=f.useState(""),[x,j]=f.useState(!1),[y,S]=f.useState(null),[b,k]=f.useState(""),[w,v]=f.useState(!1),$=f.useMemo(()=>kc(e,n),[e,n]),_=f.useMemo(()=>vc(e),[e]),[C,I]=f.useState(new Map),E=!!i&&$.rows.length>0&&$.rows.length<=o1,T=E&&($.rows.length<=ii||w),N=T&&$.rows.every(z=>!z.id||C.has(z.id)),P=z=>{var ne;return $o(z?(ne=C.get(z))==null?void 0:ne.l1:void 0)},W=f.useMemo(()=>{const z=u.trim(),ne=z?m(z):"";return $.rows.filter(q=>{var Ie,M;if(b&&$o(q.id?(Ie=C.get(q.id))==null?void 0:Ie.l1:void 0)!==b)return!1;if(!ne)return!0;const he=q.id&&((M=C.get(q.id))==null?void 0:M.title)||q.title;return m(he).includes(ne)||(q.subItems||[]).some(me=>m(me).includes(ne))})},[$.rows,u,b,C,m]),L=x?W:W.slice(0,ii),K=f.useMemo(()=>(T?$.rows:L).filter(z=>z.id&&!C.has(z.id)).map(z=>z.id),[T,$.rows,L,C]);f.useEffect(()=>{if(!i||K.length===0)return;let z=!1;const ne=K.slice(0,s1);return hr(ne,fr,q=>i.getItem(q).then(he=>{var me,G;const Ie=he??{},M={title:Ie.title,edition:Ie.edition,authors:Ie.authors,measure:he?on(he,g.unit.juan):void 0,versionCount:Ie._edition_count??((me=Ie._books)==null?void 0:me.length),l1:((G=Uo(Ie))==null?void 0:G.l1)||void 0};return[q,M]}).catch(()=>[q,{}]),()=>z).then(q=>{z||I(he=>{const Ie=new Map(he);for(const[M,me]of q)Ie.set(M,me);return Ie})}),()=>{z=!0}},[i,K,g.unit.juan]);const Q=(pe=(e.contained_in||[])[0])==null?void 0:pe.id;f.useEffect(()=>{if(!Q){S(null);return}if(S({id:Q}),!i)return;let z=!1;return i.getItem(Q).then(ne=>{z||S({id:Q,title:ne==null?void 0:ne.title})}).catch(()=>{}),()=>{z=!0}},[i,Q]);const Z=f.useMemo(()=>kp(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),ue=Z.text.length+Z.groups.reduce((z,ne)=>z+ne.rows.length+ne.mirrors.length,0),J=_.works,le=new Set($.rows.map(z=>z.id).filter(Boolean)),H=J.length>0&&!J.every(z=>le.has(z.id)),oe=(()=>{const z=$.rows.map(ne=>ne.edition).filter(Boolean);return z.length>1&&new Set(z).size===1})(),be=$.rows.some(z=>z.volumes.length>0||z.expected!=null),ze=_.total,Le=_.truncated?ze:$.rows.length,_e=on(e,g.unit.juan),re=e.count,xe=z=>typeof z=="number"&&Number.isFinite(z)?z:null,R=xe(re==null?void 0:re.juan)??xe((Me=e.juan_count)==null?void 0:Me.number)??xe((nt=(Ke=e.measures)==null?void 0:Ke.find(z=>(z==null?void 0:z.unit)==="卷"))==null?void 0:nt.number),se=xe(re==null?void 0:re.ce)??($.totalVolumes||null),de=[{value:Le,label:p("collectionPage.stat.titles")},{value:R??0,label:g.unit.juan},{value:se??0,label:g.unit.volume}],O=f.useMemo(()=>{var q,he;const z=[];if((q=e.publication_info)!=null&&q.details&&z.push({label:p("collectionPage.fact.publication"),value:m(e.publication_info.details)}),ze&&(ze!==$.rows.length||_.truncated)){const Ie=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");z.push({label:Ie,value:`${ze} ${g.unit.bu}`,title:p("collectionPage.memberNote")})}const ne=[xe(re==null?void 0:re.zhong)!=null?p("collectionPage.nZhong",{n:re.zhong}):"",xe(re==null?void 0:re.han)!=null?p("collectionPage.nHan",{n:re.han}):""].filter(Boolean);return ne.length&&z.push({label:p("collectionPage.fact.expected"),value:ne.join(" ")}),R==null&&_e&&z.push({label:p("collectionPage.fact.measure"),value:m(_e),title:(he=e.juan_count)!=null&&he.description?m(e.juan_count.description):void 0}),z},[e,ze,_.truncated,$.rows.length,R,_e,re,m,p,g]),ee=f.useMemo(()=>{if(!N)return[];const z=new Map;for(const q of $.rows){const he=P(q.id);he&&z.set(he,(z.get(he)??0)+1)}const ne=di.filter(q=>(z.get(q.key)??0)>0);return ne.length<2?[]:[{key:"",label:`${g.catalog.all} ${Le}`},...ne.map(q=>({key:q.key,label:`${q.label} ${z.get(q.key)}`}))]},[N,$.rows,C,g]),ke=f.useMemo(()=>{if(!N||!$.rows.some(he=>he.volumes.length>0))return null;const z=[],ne=$.rows.filter(he=>he.volumes.length>0).map(he=>({k:P(he.id)??"",from:Math.min(...he.volumes),to:Math.max(...he.volumes)})).sort((he,Ie)=>he.from-Ie.from);for(const he of ne){const Ie=he.to-he.from+1,M=z[z.length-1];M&&M.key===he.k?(M.to=Math.max(M.to,he.to),M.n+=Ie):z.push({key:he.k,from:he.from,to:he.to,n:Ie})}const q=ne.reduce((he,Ie)=>Math.max(he,Ie.to),0);return z.length>1&&z.some(he=>he.key)?{segs:z,last:q}:null},[N,$.rows,C]),ve=(it=e.description)==null?void 0:it.text,Ve=t.jsx(fi,{kind:p("collectionPage.kind"),title:m(e.title),byline:t.jsx(Ns,{authors:e.authors,onNavigate:o,renderLink:s}),meta:t.jsx(vt,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(at=e.publication_info)!=null&&at.year?m(e.publication_info.year):""]}),description:ve||(lt=e.history)!=null&<.length?t.jsxs(t.Fragment,{children:[ve&&t.jsx(sn,{text:ve,style:{fontSize:15,lineHeight:1.85}}),(rt=e.history)!=null&&rt.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((z,ne)=>t.jsx("li",{children:m(z)},ne))}):null]}):void 0,clampDescription:es(ve)||(((Pe=e.history)==null?void 0:Pe.length)??0)>2?6:void 0,stats:de,facts:O,foot:t.jsx(hi,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:ke&&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:ke.segs.map((z,ne)=>{const q=di.find(he=>he.key===z.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!q,title:q?p("collectionPage.dist.segTitle",{section:m(q.label),from:z.from,to:z.to}):void 0,"aria-label":q?p("collectionPage.dist.only",{section:m(q.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!q&&b===z.key,style:{flexGrow:z.n,background:r(q?q.token:"rule")},onClick:()=>{q&&(k(b===z.key?"":z.key),j(!1))}},ne)})}),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:ke.last})})]})]})}),F=[];$.rows.length&&F.push({id:"titles",label:p("collectionPage.sec.titles"),count:Le}),ue&&F.push({id:"resources",label:p("collectionPage.sec.resources"),count:ue}),H&&F.push({id:"works",label:g.section.containedWorks,count:J.length});const fe=t.jsxs(t.Fragment,{children:[$.rows.length>0&&t.jsxs(wt,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(vt,{items:[`${Le} ${g.unit.items}`,$.totalVolumes?p("collectionPage.totalVolumes",{n:$.totalVolumes,unit:g.unit.volume}):"",W.length!==Le?p("collectionPage.currentN",{n:W.length,unit:g.unit.items}):""]}),action:a,children:[($.rows.length>ii||ee.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[ee.length>0&&t.jsx(pr,{items:ee,value:b,onChange:z=>{k(z),j(!1)}}),E&&$.rows.length>ii&&!N&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:w,onClick:()=>v(!0),title:p("collectionPage.loadAllTitle",{n:$.rows.length,unit:g.unit.items}),children:p(w?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),$.rows.length>ii&&t.jsx("input",{type:"search",className:"bim-d-find",value:u,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:z=>{h(z.target.value),j(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&ur(W.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[be&&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:L.map((z,ne)=>{var Se;const q=z.id?C.get(z.id):void 0,he=q!=null&&q.title&&z.title===z.id?q.title:z.title,Ie=((q==null?void 0:q.authors)||[]).find(ye=>ye&&ye.name),M=[Ie?`${Ie.dynasty?`〔${m(Ie.dynasty)}〕`:""}${m(Ie.name)}${Ie.role?` ${m(Ie.role)}`:""}`:"",q!=null&&q.measure?m(q.measure):"",(Se=z.subItems)!=null&&Se.length?z.subItems.map(ye=>m(ye)).join("、"):"",(q!=null&&q.edition||z.edition)&&!oe?m((q==null?void 0:q.edition)||z.edition||""):""].filter(Boolean),me=di.find(ye=>ye.key===P(z.id)),G=z.volumes.length>0?p("collectionPage.volumeRange",{range:sr(z.volumes,g.unit.volume),unit:g.unit.volume}):z.expected!=null?`${z.found??0}/${z.expected} ${g.unit.volume}`:"";return t.jsxs("tr",{children:[be&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${G?"":" bim-d-zt-blank"}`,children:[me&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:r(me.token)}}),G||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[z.id?t.jsx(bt,{id:z.id,label:m(he),onNavigate:o,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:m(he)}),M.length>0?t.jsx(vt,{items:M}):z.id&&!q&&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${q!=null&&q.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:q!=null&&q.versionCount?p("collectionPage.nZhong",{n:q.versionCount}):""})]},`${z.id??z.title}-${ne}`)})})]}),L.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!x&&t.jsx(Jo,{total:W.length,shown:L.length,unit:g.unit.items,onClick:()=>j(!0)})]}),ue>0&&t.jsxs(wt,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:ue}),children:[Z.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[Z.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:Z.text.map((z,ne)=>t.jsx(Ts,{item:z,siblings:Z.text},`${z.id||z.url||z.name}-${ne}`))})})]}),t.jsx(Sp,{groups:Z.groups})]}),$.rows.length===0&&ue===0&&t.jsx(wt,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),te=H?t.jsx(vn,{id:"works",title:g.section.containedWorks,meta:p("collectionPage.nZhong",{n:J.length}),cap:12,items:J.map(z=>t.jsx(bt,{id:z.id,label:m(z.title),onNavigate:o,renderLink:s,dense:!0}))}):null,U=y?t.jsx(ad,{caption:p("collectionPage.parent"),children:t.jsx(bt,{id:y.id,label:m(y.title||y.id),onNavigate:o,renderLink:s,dense:!0})}):void 0;return t.jsx(gi,{railTop:l,back:d,up:U,nav:F,railLinks:c,main:fe,card:Ve,side:te})},a1=8;function Tp(e){return typeof e!="string"||!e||e.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.split("/").some(n=>n==="..")?null:e}function l1(e){return(e||[]).filter(n=>{var i,o;return Tp(n==null?void 0:n.file)&&((i=n.credit)==null?void 0:i.trim())&&((o=n.license)==null?void 0:o.trim())}).slice(0,a1)}function c1({images:e,assetBase:n,name:i}){const{t:o,convert:s}=ae(),[a,l]=f.useState(0),[d,c]=f.useState(!1),p=n?l1(e):[];if(!n||d||p.length===0)return null;const m=n.endsWith("/")?n:n+"/",g=p[Math.min(a,p.length-1)],u=g.width&&g.height&&g.width>0&&g.height>0?`${g.width} / ${g.height}`:void 0,h=x=>m+Tp(x.file).split("/").map(encodeURIComponent).join("/");return t.jsxs("figure",{className:"bim-d-seal bim-d-ui",children:[t.jsx("img",{className:"bim-d-seal-main",src:h(g),alt:o("entityPage.sealAlt",{name:i})+(p.length>1?` ${a+1}`:""),style:u?{"--seal-ar":u}:void 0,width:g.width,height:g.height,decoding:"async",fetchPriority:"high",onError:()=>c(!0)},g.file),p.length>1&&t.jsx("div",{className:"bim-d-seal-thumbs",children:p.map((x,j)=>t.jsx("button",{type:"button","aria-pressed":j===a,"aria-label":`${o("entityPage.sealAlt",{name:i})} ${j+1}`,onClick:()=>l(j),children:t.jsx("img",{src:h(x),alt:"",loading:"lazy",decoding:"async"})},x.file))}),t.jsxs("figcaption",{children:[o("entityPage.imgCredit",{credit:s(g.credit)})," · ",o("entityPage.imgLicense",{license:s(g.license)}),g.source_url&&/^https?:\/\//i.test(g.source_url)&&t.jsxs(t.Fragment,{children:[" · ",t.jsx("a",{href:g.source_url,target:"_blank",rel:"noopener noreferrer nofollow",children:o("entityPage.imgSource")})]}),g.note&&t.jsxs(t.Fragment,{children:[" · ",s(g.note)]})]})]})}const Fl=8,Hl=10,Dl=30,Ep=(e,n,i)=>`/read/${e}${n&&n!=="default"?`/${n}`:""}/${i}`;function d1(e){return`${Ep(e.item,e.key,e.chapter)}#${e.start}~${e.end}`}function p1(e,n,i){var o;return`${Ep(n,i.key,i.chapter)}#e=${((o=i.ids)!=null&&o.length?i.ids:[e]).join(",")}`}const u1=({id:e,transport:n,renderLink:i,onTotal:o})=>{const{t:s,convert:a}=ae(),[l,d]=f.useState(null),[c,p]=f.useState("idle"),[m,g]=f.useState(Fl),[u,h]=f.useState(Hl),x=f.useRef(null),j=!!(n!=null&&n.getMentions),y=f.useRef(o);if(y.current=o,f.useEffect(()=>{if(d(null),p("idle"),g(Fl),h(Hl),!j)return;const v=x.current;let $=!1;const _=()=>{p("loading"),n.getMentions(e).then(I=>{var T,N;if($)return;const E=I&&"books"in I?I:null;if(!E||!E.total){p("none"),(T=y.current)==null||T.call(y,0);return}d(E),p("ok"),(N=y.current)==null||N.call(y,E.total)}).catch(()=>{$||p("none")})};if(!v||typeof IntersectionObserver>"u")return _(),()=>{$=!0};const C=new IntersectionObserver(I=>{I.some(E=>E.isIntersecting)&&(C.disconnect(),_())},{rootMargin:"400px"});return C.observe(v),()=>{$=!0,C.disconnect()}},[e,j,n]),c==="none"||!j)return t.jsx("div",{ref:x});const S=(v,$,_)=>i?i(v,$,_):t.jsx("a",{className:_,href:v,children:$}),b=new Map(((l==null?void 0:l.books)??[]).map(v=>[v.item,v.title])),k=(l==null?void 0:l.examples)??[],w=(l==null?void 0:l.books)??[];return t.jsx("div",{ref:x,children:t.jsxs(wt,{id:"mentions",title:s("mentions.title"),meta:l?t.jsx(vt,{items:[s("mentions.total",{n:l.total,b:w.length})]}):void 0,children:[!l&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:s("mentions.loading")}),l&&t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:s("mentions.hint")}),l&&k.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"bim-d-mentions-h bim-d-ui",children:s("mentions.examples")}),t.jsx("ol",{className:"bim-d-mentions",children:k.slice(0,m).map((v,$)=>{const _=[b.get(v.item),v.heading].filter(Boolean).map(I=>a(I)).join(" · "),C=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-d-mention-where bim-d-ui",children:_||v.chapter}),t.jsxs("span",{className:"bim-d-mention-ctx",children:[v.before?"…":"",a(v.before),t.jsx("b",{children:a(v.text)}),a(v.after),v.after?"…":""]})]});return t.jsx("li",{children:S(d1(v),C,"bim-d-mention")},`${v.item}|${v.key}|${v.chapter}|${v.start}|${$}`)})}),k.length>m&&t.jsx("button",{type:"button",className:"bim-d-tab bim-d-ui",onClick:()=>g(k.length),children:s("mentions.more",{n:k.length-m})})]}),l&&w.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"bim-d-mentions-h bim-d-ui",children:s("mentions.byBook")}),t.jsx("ul",{className:"bim-d-mbooks",children:w.slice(0,u).map(v=>t.jsx(m1,{entityId:e,book:v,open:w.length===1,transport:n,link:S},v.item))}),w.length>u&&t.jsx("button",{type:"button",className:"bim-d-tab bim-d-ui",onClick:()=>h(v=>v+Dl),children:s("mentions.moreBooks",{n:Math.min(Dl,w.length-u)})})]})]})})},m1=({entityId:e,book:n,open:i,transport:o,link:s})=>{const{t:a,convert:l}=ae(),[d,c]=f.useState(n.chapters??null),[p,m]=f.useState(!1);f.useEffect(()=>{c(n.chapters??null)},[n]);const g=u=>{!u.currentTarget.open||d||p||!(o!=null&&o.getMentions)||(m(!0),o.getMentions(e,n.item).then(h=>{h&&"chapters"in h&&Array.isArray(h.chapters)&&c(h.chapters)}).catch(()=>{}).finally(()=>m(!1)))};return t.jsx("li",{children:t.jsxs("details",{className:"bim-d-mbook",open:i,onToggle:g,children:[t.jsxs("summary",{children:[t.jsx("span",{className:"bim-d-mbook-t",children:l(n.title??n.item)}),t.jsx("span",{className:"bim-d-mbook-n bim-d-ui",children:a("mentions.bookLine",{n:n.count,c:n.chapter_count})})]}),p&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"0 0 8px 40px"},children:a("mentions.loading")}),d&&t.jsx("ul",{className:"bim-d-mchaps",children:d.map(u=>t.jsx("li",{children:s(p1(e,n.item,u),t.jsxs(t.Fragment,{children:[t.jsx("span",{children:u.heading?`${u.chapter} · ${l(u.heading)}`:u.chapter}),t.jsx("span",{className:"bim-d-ui",children:a("mentions.chapterLine",{n:u.count})})]}),"bim-d-mchap")},`${u.key}|${u.chapter}`))})]})})},g1=16,Qr=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function Ul(e){if(!e)return Qr.length;const n=Qr.indexOf(e);return n===-1?Qr.length:n}function f1(e,n,i){if(n)return e[n]??i(n)}function h1(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const x1={秦:[-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]},Rp=({data:e,transport:n,onNavigate:i,renderLink:o,railTop:s,back:a,railLinks:l,assetBase:d})=>{var nt,it,at,lt,rt,Pe;const{t:c,convert:p,messages:m}=ae(),g=z=>h1(z,c),[u,h]=f.useState("全部"),[x,j]=f.useState(!1),[y,S]=f.useState("default"),[b,k]=f.useState(new Map),[w,v]=f.useState(0),$=f.useMemo(()=>e._works||[],[e._works]),_=f.useMemo(()=>$.map(z=>{const ne=b.get(z.work_id);return{id:z.work_id,title:(ne==null?void 0:ne.title)??z.title??z.work_id,role:z.role||"",cls:Fo(z.role),versionCount:ne==null?void 0:ne.versionCount,section:ne==null?void 0:ne.cls,l1:ne==null?void 0:ne.l1,measure:ne==null?void 0:ne.measure,hasImage:ne==null?void 0:ne.hasImage,loaded:!!(ne!=null&&ne.loaded)}}),[$,b]),C=f.useMemo(()=>jc($.map(z=>z.role),c("detail.roleAll")),[$,c]),I=f.useMemo(()=>{const z=u==="全部"?_:_.filter(ne=>ne.cls===u);return y==="versions"?[...z].sort((ne,q)=>(q.versionCount??-1)-(ne.versionCount??-1)):z},[_,u,y]),E=x?I:I.slice(0,g1),T=f.useMemo(()=>E.filter(z=>!b.has(z.id)).map(z=>z.id),[E,b]);f.useEffect(()=>{if(!n||T.length===0)return;let z=!1;return hr(T,fr,ne=>n.getItem(ne).then(q=>{var G;const he=q??{},Ie=he._edition_count??((G=he._books)==null?void 0:G.length)??0,M=Uo(he),me=[M==null?void 0:M.l1,M==null?void 0:M.l2].filter(Boolean).join(" ");return[ne,{id:ne,title:he.title,versionCount:Ie,loaded:!0,cls:me||void 0,l1:(M==null?void 0:M.l1)||void 0,measure:q&&on(q,m.unit.juan)||void 0,hasImage:!!he._has_image}]}).catch(()=>[ne,{id:ne,loaded:!0}]),()=>z).then(ne=>{z||k(q=>{const he=new Map(q);for(const[Ie,M]of ne)he.set(Ie,M);return he})}),()=>{z=!0}},[n,T,m.unit.juan]);const N=f.useMemo(()=>{const z=new Map;for(const ne of e.alt_names||[]){const q=ne.type||m.section.aliases;z.has(q)||z.set(q,[]),z.get(q).push(ne.name)}return[...z.entries()].sort((ne,q)=>Ul(ne[0])-Ul(q[0])).map(([ne,q])=>({label:ne,names:q}))},[e.alt_names,m]),P=((nt=e.dates)==null?void 0:nt.birth)??void 0,W=((it=e.dates)==null?void 0:it.death)??void 0,L=(at=e.dates)==null?void 0:at.floruit,K=P!=null||W!=null?`${g(P)||"?"}—${g(W)||"?"}`:Array.isArray(L)&&L.length===2&&L.every(z=>Number.isFinite(z))?c("entityPage.floruit",{from:g(L[0]),to:g(L[1])}):"",Q=new Set(["本名","字","號","号"]),Z=N.filter(z=>Q.has(z.label)),ue=N.filter(z=>!Q.has(z.label)),J=ue.reduce((z,ne)=>z+ne.names.length,0),le=f.useMemo(()=>{const z=[];for(const q of Z)z.push({label:q.label,value:q.names.map(he=>p(he)).join("、")});const ne=$.length;return ne&&z.push({label:c("entityPage.fact.works"),value:c("entityPage.nZhong",{n:ne})}),z},[$,Z,p,c]),H=z=>{var ne;return(ne=N.find(q=>z.includes(q.label)))==null?void 0:ne.names[0]},oe=H(["字"]),be=H(["號","号"]),ze=[oe?c("entityPage.zi",{name:p(oe)}):"",be?c("entityPage.hao",{name:p(be)}):""].filter(Boolean).join(","),Le=e.native_place,_e=e.dynasty?x1[e.dynasty]:void 0,re=(()=>{if(!_e||P==null||W==null||W<P)return null;const[z,ne]=_e,q=Math.max(P,z),he=Math.min(W,ne);if(he<=q)return null;const Ie=ne-z;return t.jsxs("div",{className:"bim-d-life bim-d-ui",children:[t.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":c("entityPage.lifeAria",{birth:g(P),death:g(W),years:W-P+1}),children:t.jsx("i",{style:{left:`${(q-z)/Ie*100}%`,width:`${(he-q)/Ie*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${g(z)} ${p(e.dynasty)}`}),t.jsx("span",{children:c("entityPage.lifeYears",{years:W-P+1})}),t.jsx("span",{children:g(ne)})]})]})})(),xe=f.useMemo(()=>{if(!n||_.length===0||_.some(q=>!q.loaded))return null;const z=new Map;for(const q of _){const he=$o(q.l1);he&&z.set(he,(z.get(he)??0)+1)}const ne=di.map(q=>({...q,n:z.get(q.key)??0})).filter(q=>q.n>0);return ne.length?ne:null},[_,n]),R=t.jsxs(fi,{kind:f1(m.entityPage.subtype,e.subtype,p),title:p(e.primary_name||e.title),subtitle:ze||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(vt,{items:[e.dynasty?p(e.dynasty):"",K,Le?c("entityPage.nativePlace",{place:p(Le)}):""]}),re,t.jsx(c1,{images:e.images,assetBase:d,name:p(e.primary_name||e.title)})]}),description:(lt=e.description)!=null&<.text?t.jsx(sn,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:es((rt=e.description)==null?void 0:rt.text)?6:void 0,facts:le,foot:t.jsx(hi,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[J>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:c("entityPage.moreNames",{n:J})}),t.jsx("dl",{children:ue.map(z=>t.jsxs(f.Fragment,{children:[t.jsx("dt",{children:p(z.label)}),t.jsx("dd",{children:z.names.map(ne=>p(ne)).join("、")})]},z.label))})]}),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:c("entityPage.dist")})}),t.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:xe.map(z=>t.jsx("i",{style:{flexGrow:z.n,background:r(z.token)}},z.key))}),t.jsx("div",{className:"bim-d-dist-key",children:xe.map(z=>t.jsxs("span",{children:[t.jsx("i",{style:{background:r(z.token)}}),p(z.label)," ",z.n]},z.key))})]})]}),se=f.useMemo(()=>_.filter(z=>z.loaded&&(z.versionCount??0)>0).sort((z,ne)=>(ne.versionCount??0)-(z.versionCount??0)).slice(0,3),[_]),de=!!n&&_.length>=3&&E.some(z=>!z.loaded),O=u==="全部"&&(de||se.length>=2),ee=e.external_ids||{},ke=((Pe=e.external_ids_meta)==null?void 0:Pe.cbdb_match)??ee.cbdb_match,ve=[];ee.cbdb_id!=null&&ve.push({label:"CBDB",id:String(ee.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${ee.cbdb_id}`,note:ke==="auto"?c("entityPage.autoMatch"):void 0});const Ve=ee.wikidata_id;Ve&&ve.push({label:"Wikidata",id:Ve,href:`https://www.wikidata.org/wiki/${Ve}`});const F=ee.viaf_id;F&&ve.push({label:"VIAF",id:F,href:`https://viaf.org/viaf/${F}`});const fe=C.map(z=>({key:z.cls,label:`${z.label} ${z.count}`})),te=e.id?t.jsx(u1,{id:e.id,transport:n,onTotal:v}):null,U=[...O&&!de?[{id:"featured",label:c("entityPage.sec.featured"),count:se.length}]:[],..._.length?[{id:"works",label:c("entityPage.sec.allWorks"),count:_.length}]:[],...w?[{id:"mentions",label:c("mentions.title"),count:w}]:[],...ve.length?[{id:"external",label:c("entityPage.sec.external"),count:ve.length}]:[]],pe=O?t.jsxs(wt,{id:"featured",title:c("entityPage.sec.featured"),children:[t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:c("entityPage.featuredSub")}),t.jsxs("div",{className:"bim-d-picks","aria-busy":de||void 0,children:[de&&[0,1,2].map(z=>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:" "})]},z)),!de&&se.map(z=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(bt,{id:z.id,label:p(z.title),onNavigate:i,renderLink:o,dense:!0})}),t.jsx(vt,{items:[z.section?p(z.section):"",z.measure?p(z.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:z.versionCount}),t.jsx("span",{children:c("entityPage.versionsUnit")}),z.hasImage&&t.jsx("span",{className:"bim-d-flag",children:c("entityPage.hasImage")})]})]},z.id))]})]}):null,Me=_.length===0?t.jsxs(t.Fragment,{children:[t.jsx(wt,{title:c("entityPage.sec.works"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("entityPage.empty")})}),te]}):t.jsxs(t.Fragment,{children:[pe,t.jsxs(wt,{id:"works",title:c("entityPage.sec.works"),meta:t.jsx(vt,{items:[c("entityPage.total",{n:_.length}),I.length!==_.length?c("entityPage.current",{n:I.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[fe.length>1&&t.jsx(pr,{items:fe,value:u,onChange:z=>{h(z),j(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":y==="versions",onClick:()=>{y==="default"&&j(!0),S(z=>z==="default"?"versions":"default")},children:c(y==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&ur(I.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:c("entityPage.col.work")}),t.jsx("th",{children:c("entityPage.col.section")}),t.jsx("th",{children:c("entityPage.col.role")}),t.jsx("th",{children:c("entityPage.col.versions")}),t.jsx("th",{"aria-label":c("entityPage.col.image")})]})}),t.jsx("tbody",{children:E.map(z=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(bt,{id:z.id,label:p(z.title),onNavigate:i,renderLink:o,dense:!0}),z.measure?t.jsx(vt,{items:[p(z.measure)]}):!z.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${z.section||z.loaded?"":" bim-d-zt-blank"}`,children:z.section?p(z.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${z.role?"":" bim-d-zt-blank"}`,children:z.role?p(z.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${z.loaded?"":" bim-d-zt-blank"}`,children:z.loaded?z.versionCount?c("entityPage.nZhong",{n:z.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:c("entityPage.notRecorded")}):""}),t.jsx("td",{className:z.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:z.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:c("entityPage.hasImage")})})]},z.id))})]}),E.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c("entityPage.emptyRole")}),!x&&t.jsx(Jo,{total:I.length,shown:E.length,unit:c("entityPage.moreUnit"),onClick:()=>j(!0)})]}),te]}),Ke=ve.length>0?t.jsx(vn,{id:"external",title:c("entityPage.sec.external"),items:ve.map(z=>t.jsxs("a",{href:z.href,target:"_blank",rel:"noopener noreferrer",children:[z.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:ve.map(z=>z.id),foot:ee.cbdb_id!=null&&ke==="auto"?c("entityPage.cbdbAuto"):void 0}):null;return t.jsx(gi,{railTop:s,back:a,nav:U,railLinks:l,main:Me,card:R,side:Ke})},Rs="(max-width: 719px)",b1=`${Rs}, (pointer: coarse)`,Ip=`
|
|
1514
|
+
${n??""}`,[a,l]=h.useState({tag:"",spans:[]}),d=h.useRef(0);return h.useEffect(()=>{const c=++d.current,p=g=>{c===d.current&&l({tag:s,spans:g})};if(!e||!n){p([]);return}let m;try{m=e(n,i)}catch{p([]);return}Promise.resolve(m).then(g=>p(g?Hd(g):[]),()=>p([]))},[e,n,i,s]),a.tag===s?a.spans:Rb}const Rb=[],Eb=/^#{1,6}$/,Ib=/^([^《》]*)《([^《》]+)》\s*(?:[〇零一二三四五六七八九十百千]+|不分|無|无)卷/;function Lb(e){let n=e.trim();const i=Ib.exec(n);return i&&(n=i[1]+i[2]),n.replace(/[《》〈〉]/g,"").trim()}const hl=e=>e.kind==null||e.kind==="point";function op(e,n){var d;if(!e||!n||n.length===0)return[];const i=new Map;let o=!1;for(const c of n){c.kind==="heading"&&(o=!0);const p=i.get(c.anchor);p?p.push(c):i.set(c.anchor,[c])}if(!o)return[];const s=[];let a=null;const l=()=>{a&&(a.fixed||(a.h.label=Lb(a.text)),a.h.label&&s.push(a.h)),a=null};for(const c of e){const p=[...c.columns].sort((m,g)=>m.col-g.col);for(const m of p)for(const g of m.chars){const u=i.get(g.id)??[],f=u.find(x=>x.kind==="heading"&&x.pos==="before"&&Eb.test(x.mark));if(f&&l(),f&&f.toc!==!1){const x=(d=f.label)==null?void 0:d.trim();a={h:{level:f.mark.length,label:x??"",anchor:g.id},text:"",fixed:!!x}}if(a&&!a.fixed){for(const x of u)hl(x)&&x.pos==="before"&&(a.text+=x.mark);a.text+=g.char;for(const x of u)hl(x)&&x.pos!=="before"&&(a.text+=x.mark)}u.some(x=>x.kind==="break"&&x.pos!=="before")&&l()}}return l(),s}function _o(e){if(!Array.isArray(e))return[];const n=[];for(const i of e){if(!i||typeof i!="object")continue;const{level:o,label:s,anchor:a}=i;typeof o!="number"||!Number.isInteger(o)||o<1||o>6||typeof s!="string"||!s.trim()||typeof a!="string"||!a||n.push({level:o,label:s.trim(),anchor:a})}return n}function Ns(e,n){return`${e}#${n}`}function sp(e){const n=e.indexOf("#");return n<=0||n===e.length-1?null:{chapter:e.slice(0,n),anchor:e.slice(n+1)}}function ap(e){const n=[],i=[];for(const o of e){const s={...o,children:[]};for(;i.length>0&&i[i.length-1].level>=o.level;)i.pop();i.length===0?n.push(s):i[i.length-1].children.push(s),i.push(s)}return n}function Gi(e){return!!e&&!e.has_json&&typeof e.char_file=="string"&&!!e.char_file&&typeof e.cord_file=="string"&&!!e.cord_file}const Mb=150,fl="(min-width: 860px)";function Ab(){const[e,n]=h.useState(()=>typeof window>"u"||!window.matchMedia?!0:window.matchMedia(fl).matches);return h.useEffect(()=>{var s;if(!window.matchMedia)return;const i=window.matchMedia(fl),o=()=>n(i.matches);return o(),(s=i.addEventListener)==null||s.call(i,"change",o),()=>{var a;return(a=i.removeEventListener)==null?void 0:a.call(i,"change",o)}},[]),e}const xl={padding:24,color:r("desc-fg"),fontSize:14};function bl({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 yl=/^https?:\/\//i,Pb=[];function Bb(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&&yl.test(i)?i:void 0,license:n(e.license),license_url:o&&yl.test(o)?o:void 0,note:n(e.note)};return s.name||s.license||s.note?s:null}function Ob(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 jl(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)||Array.isArray(n==null?void 0:n.heading_levels)&&n.heading_levels.length>0?"冊":xe.isCollatedKind(e==null?void 0:e.kind)?"卷":"章"}function lp(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 cp(e,n,i){return n.map(o=>({key:Ns(e,o.anchor),label:i(o.label),inChapter:!0,...o.children.length>0?{selectable:!0,children:cp(e,o.children,i)}:{}}))}function Wb(e,n,i,o,s,a=()=>[]){var m;const l=new Map(e.chapters.map(g=>[g.file,g])),d=g=>g==="loading"?"…":typeof g=="number"&&g>0?g:void 0,c=(g,u)=>{const f=l.get(g),x=f?a(f):[];return{key:g,label:u??(f?lp(f,i,o,s):g),hint:d(n[g]),disabled:n[g]===0,...x.length>0?{selectable:!0,children:cp(g,ap(x),o)}:{}}},p=(m=e.juan_groups)==null?void 0:m.filter(g=>{var u;return g.files.some(f=>l.has(f))||((u=g.children)==null?void 0:u.length)});if(p&&p.length>0){const g=(u,f)=>{var j;if(u.files.length===1&&!((j=u.children)!=null&&j.length))return c(u.files[0],o(u.label));const x=Nx(u,n);return{key:`group:${f}`,label:o(u.label),hint:x==="loading"?"…":typeof x=="number"&&x>0?`${x}`:Gd(u),defaultExpanded:typeof x=="number"&&x>0,children:[...u.files.filter(y=>l.has(y)).map(y=>c(y)),...(u.children??[]).map((y,S)=>g(y,`${f}.${S}`))]}};return p.map((u,f)=>g(u,`${f}`))}return e.chapters.map(g=>c(g.file))}const Ts=e=>{const n=rd();return t.jsx(Fm,{mode:n[0].scriptMode,children:t.jsx(Fb,{...e,prefsState:n})})},Fb=({prefsState:e,id:n,transport:i,versionKey:o,chapter:s,onLocationChange:a,onNavigate:l,anchor:d,title:c,subtitle:p,settingsExtra:m,settingsExtraTitle:g,resolveImages:u,renderImageOverlay:f,imagePanel:x,facsimileTrimmed:j,allowVertical:y,onReportError:S,revisedAt:b,backHref:v,backLabel:w,resolveWarpData:k,textFileBase:_,onChapterData:$,hideSupersededVersions:C,warpData:L,resolveEntities:E,onEntityNavigate:T,className:N,style:W})=>{var ra,oa,sa,aa;const{t:F,convert:R}=oe(),G=h.useMemo(()=>Xc(i),[i]),[Q,ie]=e,de=kt(),q=h.useRef(a);q.current=a;const[ee,U]=h.useState(null),[se,pe]=h.useState("loading");h.useEffect(()=>{let I=!1;return U(null),pe("loading"),G.getManifest(n).then(Y=>{I||(Y?(U(C?xe.readerVersions(Y):Y),pe("ready")):pe("missing"))}).catch(()=>{I||pe("missing")}),()=>{I=!0}},[G,n,C]);const _e=o!==void 0,Le=s!==void 0,[Ee,ue]=h.useState(null),[be,A]=h.useState(null);h.useEffect(()=>{ue(null),A(null)},[n]);const K=xe.pickTextVersion(ee,_e?o:Ee),le=((ra=ee==null?void 0:ee.versions.find(I=>I.key==="default"))==null?void 0:ra.key)??((oa=ee==null?void 0:ee.versions[0])==null?void 0:oa.key)??"default",M=(K==null?void 0:K.key)??null,J=Le?s:be,ye=h.useCallback((I,Y,we,at)=>{var et;(et=q.current)==null||et.call(q,{key:I,chapter:Y,isDefault:I===le,...at?{anchor:at}:{}},we)},[le]);h.useEffect(()=>{!ee||!_e||o==null||ee.versions.some(I=>I.key===o)||ye(le,null,"auto")},[ee,_e,o,le,ye]);const je=h.useRef(new Map);h.useEffect(()=>{je.current.clear()},[G,n]);const Ue=h.useCallback(async I=>{const Y=`${n}
|
|
1515
|
+
${I}`;if(je.current.has(Y))return je.current.get(Y)??null;const we=await G.getIndex(n,I).catch(()=>null);return we&&je.current.set(Y,we),we},[G,n]),[H,me]=h.useState(null),[ge,ne]=h.useState("loading"),Ne=M?`${n}
|
|
1516
|
+
${M}`:null,he=H&&H.owner===Ne?H.idx:null;h.useEffect(()=>{if(!M)return;let I=!1;const Y=`${n}
|
|
1517
|
+
${M}`;return me(null),ne("loading"),Ue(M).then(we=>{I||(we&&we.chapters.length>0?(me({owner:Y,idx:we}),ne("ready")):ne("failed"))}),()=>{I=!0}},[n,M,Ue]),h.useEffect(()=>{if(!he||!M||J!=null&&he.chapters.some(we=>we.file===J))return;const Y=he.chapters[0].file;Le||A(Y),ye(M,Y,"auto")},[he,M,J,Le,ye]);const Ce=he?J!=null&&he.chapters.some(I=>I.file===J)?J:he.chapters[0].file:J,Ie=h.useMemo(()=>he&&Ce?he.chapters.find(I=>I.file===Ce)??null:null,[he,Ce]),Qe=h.useRef(0),gt=h.useCallback(async I=>{if(!ee||I===M||!ee.versions.some(Ht=>Ht.key===I))return;const Y=++Qe.current,we=await Ue(I);if(Y!==Qe.current)return;const at=Ie??(Ce?{file:Ce}:null),et=xe.matchChapterAcrossVersions(at,we);_e||ue(I),Le||A(et),ye(I,et,"version")},[ee,M,Ue,Ie,Ce,_e,Le,ye]),[lt,tt]=h.useState(null),[Oe,z]=h.useState(null),re=h.useRef(0),te=h.useCallback((I,Y)=>{tt({chapter:I,anchor:Y,nonce:++re.current}),z({chapter:I,anchor:Y})},[]),fe=h.useCallback(I=>{if(!M)return;const Y=sp(I);if(Y){te(Y.chapter,Y.anchor),Le||A(Y.chapter),ye(M,Y.chapter,"chapter",Y.anchor);return}Le||A(I),ye(M,I,"chapter")},[M,Le,ye,te]),Me=h.useRef(null);h.useEffect(()=>{!d||!Ce||d===Me.current||(Me.current=d,te(Ce,d))},[d,Ce,te]),h.useEffect(()=>{d||(Me.current=null)},[d]);const[P,ce]=h.useState(null),X=M&&Ie?`${n}
|
|
1518
|
+
${M}
|
|
1519
|
+
${Ie.file}`:null,[Te,Se]=h.useState(null),ze=X!==null&&Te!==X,qe=h.useRef(0);h.useEffect(()=>{if(!M||!Ie)return;const I=++qe.current,Y=`${n}
|
|
1520
|
+
${M}
|
|
1521
|
+
${Ie.file}`;if(ce(null),Gi(Ie)){Se(Y);return}G.getChapter(n,M,Ie.file,{json:!!Ie.has_json}).then(we=>{I===qe.current&&ce(we)}).catch(()=>{I===qe.current&&ce(null)}).finally(()=>{I===qe.current&&Se(Y)})},[G,n,M,Ie]);const Pe=xe.isCollatedKind(K==null?void 0:K.kind),[it,pt]=h.useState("");h.useEffect(()=>{pt("")},[n,M]);const Z=h.useMemo(()=>M&&Pe?async I=>{const Y=await G.getChapter(n,M,I,{json:!0});return{juan:(Y==null?void 0:Y.json)??null,rawText:(Y==null?void 0:Y.md)??null}}:null,[G,n,M,Pe]),$e=(he==null?void 0:he.type)==="kaozhen",ke=h.useMemo(()=>(he==null?void 0:he.chapters.map(I=>I.file))??[],[he]),{matchStates:Ye}=Hx({resetKey:`${n}
|
|
1522
|
+
${M??""}`,load:Z,files:ke,activeFile:Ce??null,activeJuan:(P==null?void 0:P.json)??null,activeRawText:(P==null?void 0:P.md)??null,query:it,isKaozhen:$e}),We=h.useRef(new Map);h.useEffect(()=>{We.current.clear()},[n]);const De=h.useMemo(()=>({versionKey:M,chapter:Ie??null}),[M,Ie]),ht=Ab(),ct=typeof i.getTextFile=="function"||!!_,yt=h.useRef($);yt.current=$;const Xe=h.useMemo(()=>k||L!==void 0||!ct?void 0:async(I,Y)=>{var at;const we=await xe.loadReaderChapter(i,{id:n,versionKey:Y==null?void 0:Y.versionKey,chapter:Y==null?void 0:Y.chapter},{cord:ht,textFileBase:_});return Y!=null&&Y.chapter&&((at=yt.current)==null||at.call(yt,{chapterKey:I,ctx:Y,data:we})),(we==null?void 0:we.warpData)??null},[k,L,ct,i,n,ht,_]),V=h.useMemo(()=>E||!ct?void 0:async(I,Y)=>{var we;return((we=await xe.loadReaderFiles(i,{id:n,versionKey:Y==null?void 0:Y.versionKey,chapter:Y==null?void 0:Y.chapter},{cord:ht,textFileBase:_}))==null?void 0:we.entity)??null},[E,ct,i,n,ht,_]),D=gx(u,Ce??null,De,n),{warpData:B,loading:ve}=rp(k??Xe,L,Ce??null,De,n),Re=h.useRef(!1);(B||D.images&&D.images.length>0)&&(Re.current=!0),h.useEffect(()=>{Re.current=!1},[n]);const Ae=D.loading||Gi(Ie)&&ve&&!B,Je=Re.current&&Ae,rt=Je,Ve=Tb(E??V,Ce??null,De,n),O=Q.properNameMode??(Ve.length>0?"full":"off"),ae=h.useMemo(()=>({...Q,properNameMode:O}),[Q,O]),Fe=h.useMemo(()=>mx(Ve,O,{showWorks:ae.showWorks}),[Ve,O,ae.showWorks]),[Ke,He]=h.useState(new Set),[Ze,ot]=h.useState(null),[ft]=h.useState(hx),[nt,It]=h.useState(!0),dt=j??((sa=K==null?void 0:K.facsimile)==null?void 0:sa.trimmed)??!1,Xt=dt?!0:Q.preserveMargins;h.useCallback(I=>ie({preserveMargins:I}),[ie]);const mt=h.useRef(null),[wt,Ot]=h.useState(1),[Ct,Cr]=h.useState(null),wi=I=>{var we;const Y=parseInt(((we=I==null?void 0:I.page_id)==null?void 0:we.split(":")[1])??"",10);return isNaN(Y)?null:Y},hn=I=>{var we,at;const Y=(I==null?void 0:I.pages)??[];return((we=Y.find(et=>et.columns.some(Ht=>Ht.chars.length>0)))==null?void 0:we.page)??wi(I)??((at=Y[0])==null?void 0:at.page)??1},[xt,zn]=h.useState(()=>hn(B)),Kn=`${n}
|
|
1523
|
+
${M}
|
|
1524
|
+
${Ce??""}`,[qn,Vs]=h.useState({key:Kn,data:B,started:!!B});if(qn.key!==Kn)Vs({key:Kn,data:B,started:!1});else if(B!==qn.data&&(Vs({key:Kn,data:B,started:!!B}),B)){const I=B.pages??[];(!qn.started||!I.some(Y=>Y.page===xt))&&zn(hn(B))}h.useEffect(()=>{He(new Set),ft.set(null)},[Ce,M,ft]);const zr=qn.key===Kn&&qn.started,Gs=!!Ie&&_o(Ie.headings).length===0,Ys=h.useMemo(()=>Gs&&zr&&B?op(B.pages,B.punctuations):[],[Gs,zr,B]),Nr=h.useCallback(I=>{const Y=_o(I.headings);return Y.length>0?Y:I.file===Ce?Ys:[]},[Ce,Ys]),Lu=h.useCallback(I=>{if(He(new Set(I)),I.length>0){const Y=I[0],we=parseInt(Y.split(":")[0],10);isNaN(we)||zn(we)}},[]),Zt=h.useMemo(()=>{const I=new Map;for(const Y of(B==null?void 0:B.pages)??[])I.set(Y.page,Y);return I},[B]),Xn=wi(B),Si=h.useCallback(I=>{var at;const Y=D.images;if(!Y||Y.length===0)return;const we=(at=Zt.get(I))==null?void 0:at.seq;return(we?Y.find(et=>et.seq===we):void 0)??Y.find(et=>et.pageNo===I)??Y[I-1]},[D.images,Zt]),Ks=wt>1.5,$i=h.useCallback((I,Y=!1)=>{const we=Si(I);return we?I===Xn||Y?we.hiresUrl??we.url:we.url:I===Xn?(B==null?void 0:B.imageUrl)??"":""},[Si,B,Xn]),Mu=h.useMemo(()=>$i(xt,Ks),[$i,xt,Ks]),Jt=h.useMemo(()=>[...Zt.keys()].sort((I,Y)=>I-Y),[Zt]),fn=h.useRef(xt);fn.current=xt;const Tr=h.useRef(0),Rr=h.useRef({page:null,timer:null}),Au=h.useCallback(I=>{const Y=Rr.current;I!==Y.page&&(Y.timer&&(clearTimeout(Y.timer),Y.timer=null),Y.page=null,!(I===fn.current||Date.now()<Tr.current)&&(Y.page=I,Y.timer=setTimeout(()=>{Y.timer=null,Y.page=null,!(Date.now()<Tr.current||fn.current===I)&&(fn.current=I,zn(I))},Mb)))},[]);h.useEffect(()=>()=>{Rr.current.timer&&clearTimeout(Rr.current.timer)},[]);const _i=h.useCallback(I=>{var Y;fn.current===I||!Zt.has(I)||(Tr.current=Date.now()+1e3,fn.current=I,zn(I),(Y=Zt.get(I))!=null&&Y.columns.some(we=>we.chars.length>0)&&Cr(we=>({page:I,nonce:((we==null?void 0:we.nonce)??0)+1})))},[Zt]),Zn=h.useCallback(I=>{const Y=fn.current,we=Jt.indexOf(Y),at=Jt[we<0?0:we+I];at===void 0||at===Y||_i(at)},[Jt,_i]),qs=h.useCallback(I=>{if(!I.trim().match(/^\d+$/)||Jt.length===0)return null;const we=parseInt(I.trim(),10),at=Number.isFinite(we)?we:Number.MAX_SAFE_INTEGER;return Jt.reduce((et,Ht)=>Math.abs(Ht-at)<Math.abs(et-at)?Ht:et,Jt[0])},[Jt]),[Er,Ir]=h.useState(null),Ci=h.useRef(null),Pu=h.useCallback(I=>{Ci.current=I,Ir(I)},[]),Xs=h.useCallback(()=>{const I=Ci.current;if(Ci.current=null,Ir(null),I===null)return;const Y=qs(I);Y!==null&&_i(Y)},[qs,_i]),Lr=Jt.indexOf(xt),Bu=h.useCallback(I=>{if(I.altKey||I.ctrlKey||I.metaKey)return;const Y=I.target.tagName;Y==="INPUT"||Y==="TEXTAREA"||Y==="SELECT"||(I.key==="ArrowLeft"||I.key==="PageUp"?(I.preventDefault(),Zn(-1)):(I.key==="ArrowRight"||I.key==="PageDown")&&(I.preventDefault(),Zn(1)))},[Zn]),Zs=h.useRef(null);h.useEffect(()=>{if(!B)return;const I=Zs.current;if(!(!I||I.offsetWidth===0))for(const Y of[1,-1]){const we=$i(xt+Y);we&&ko(we)}},[B,xt,$i]);const Js=h.useMemo(()=>{var pa;if(!B)return null;if(xt===Xn)return B;const I=Zt.get(xt);if(I&&I.width>0&&I.height>0)return{page_id:`p:${xt}`,title:`第${xt}葉`,image_size:[I.width,I.height],total_warped_w:I.width,columns:[{col:1,warped_w:I.width,warped_h:I.height,offset_x:0,strips:[],chars:I.columns.flatMap(st=>st.chars).map(st=>({id:st.id,char:st.char,slot:st.slot,pos:st.pos,sub:st.sub,bbox_col:st.bbox??[0,0,0,0]}))}],...I.columns.some(st=>st.kind==="figure"&&st.figBox)?{figBlocks:I.columns.filter(st=>st.kind==="figure"&&st.figBox).map(st=>({id:st.fig,box:st.figBox}))}:{}};const Y=(pa=B.pages)==null?void 0:pa.find(st=>st.page===xt),[we,at]=B.image_size||[2386,3082];if(!(we>0&&at>0))return null;const et=Si(xt),Ht=(et==null?void 0:et.width)??we,Or=(et==null?void 0:et.height)??at,la=Ht/we,ca=Or/at,da=new Map;for(const st of B.columns){const Mt=(st.strips||[]).flatMap(Ei=>Ei.srcQuad.map(Ii=>Ii[0]));if(Mt.length===0)continue;const Qt=st.top_y??0,Wr=st.bottom_y??Qt+st.warped_h;da.set(st.col,{x0:Math.min(...Mt),x1:Math.max(...Mt),top:Qt,slotH:(Wr-Qt)/21})}return{page_id:`p:${xt}`,title:`第${xt}葉`,image_size:[Ht,Or],total_warped_w:Ht,columns:Y?Y.columns.map(st=>{const Mt=da.get(st.col)??{x0:0,x1:0,top:0,slotH:118};return{col:st.col,warped_w:Ht,warped_h:Or,offset_x:0,strips:[],chars:st.chars.map(Qt=>{const Wr=Qt.slot??Qt.pos??0,Ei=(Mt.top+(Wr-1)*Mt.slotH)*ca,Ii=(Mt.x0+Mt.x1)/2,[qu,Xu]=Qt.sub==="a"?[Ii,Mt.x1]:Qt.sub==="b"?[Mt.x0,Ii]:[Mt.x0,Mt.x1];return{...Qt,bbox_col:[qu*la,Ei,Xu*la,Ei+Mt.slotH*ca]}})}}):[]}},[B,xt,Xn,Zt,Si]),{entryTitle:zi,authors:Qs}=Ub(n,i,c===void 0),[ea,Mr]=h.useState("text");h.useEffect(()=>{Mr("text")},[Ce,M]);const Ou=h.useMemo(()=>he?Wb(he,Ye,jl(K,he),R,Pe,Nr):[],[he,Ye,K,R,Pe,Nr]);if(se==="loading")return t.jsx(bl,{className:N,style:W,title:c??zi,label:F("reader.loading")});if(se==="missing"||!ee||!K)return t.jsx("div",{className:N,style:{...W,...xl},children:F("reader.noText")});if(ge==="failed")return t.jsx("div",{className:N,style:{...W,...xl},children:F("reader.tocFailed")});if(!he)return t.jsx(bl,{className:N,style:W,title:c??zi,label:F("reader.tocLoading")});const Nn=jl(K,he),Wu=Ou,ta=Oe&&Ce&&Oe.chapter===Ce?Ns(Ce,Oe.anchor):null,Fu=ta&&Ie&&Nr(Ie).some(I=>I.anchor===Oe.anchor)?ta:Ce??null,Ar=ee.versions.map(I=>({key:I.key,label:xe.textVersionLabel(I),optionLabel:R(xe.textVersionLabel(I)),sourceName:vl(I)?F("reader.originalSource"):I.source_name?R(I.source_name):void 0,license:I.license??void 0,sourceUrl:I.source_url??void 0,primary:I.key===le})),Lt=Bb((aa=he.source)==null?void 0:aa.upstream),Ni=(typeof c=="string"?R(c):c)??(he.title?R(he.title):zi?R(zi):void 0),na=K.edition_label?R(K.edition_label):void 0,Pr=Ni?t.jsx("a",{href:de(n),title:F("reader.viewEntry"),onClick:l?I=>{I.metaKey||I.ctrlKey||(I.preventDefault(),l(n))}:void 0,children:Ni}):void 0,Hu=Pr&&na?t.jsxs(t.Fragment,{children:[Pr,t.jsxs("span",{className:"bim-rd-ed",children:["·",na]})]}):Pr,Du=Qs.length>0?R(Qs.slice(0,2).map(I=>`${I.dynasty?`〔${I.dynasty}〕`:""}${I.name}${` ${I.role||F("reader.defaultRole")}`}`).join("、")):void 0,Br=Ie?lp(Ie,Nn,R,Pe):void 0,xn=Pe&&!!(P!=null&&P.json),bn=(P==null?void 0:P.json)??null,Tn=(P==null?void 0:P.md)??null,ia=xn&&!$e&&Yd(bn.sections),Uu=ia&&!(Tn&&ae.readingMode==="paragraph"&&Ji(Tn)),Vu=xn&&ia?t.jsx(Dx,{juan:bn,view:ea,onView:Mr,textHasEntries:Uu}):void 0,Gu=!0,Ti=Tn?Tn.replace(/^##\s+[^\n]+\n+/,""):null,Ri=vl(K),ln=Ri?F("reader.originalSource"):K.source_name?R(K.source_name):void 0,Yu=(typeof p=="string"?R(p):p)??(Ri?void 0:ln??R(xe.textVersionLabel(K))),Ku=(B==null?void 0:B.hasNorm)===!0;return t.jsxs(ad,{className:N,style:W,title:Hu,subtitle:Yu,byline:Du,current:Br,pagerUnit:Nn,rail:Vu,revisedAt:b,backHref:v,backLabel:w,onReportError:S?I=>S({...I,bookTitle:typeof Ni=="string"?Ni:void 0,entryId:n}):void 0,workLinkToggle:xn&&!$e&&!!l&&!!(bn!=null&&bn.sections.some(I=>I.work_id)),toc:Wu,tocCaption:F("reader.tocCaption",{n:he.chapters.length,unit:R(Nn)}),tocHeader:Pe&&he.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:$e?F("reader.searchChaptersPlaceholder"):F("reader.searchUnitPlaceholder",{unit:R(Nn)}),"aria-label":$e?F("reader.searchChapters"):F("reader.searchUnit",{unit:R(Nn)}),value:it,onChange:I=>pt(I.target.value)}):void 0,activeKey:Ce??null,tocActiveKey:Fu,onSelect:fe,images:Gi(Ie)&&ve&&!B?null:D.images,renderImageOverlay:f,imagePanel:B||Je?"open":x,imagesLoading:rt,isWarpMode:!!B,showPreserveMargins:!dt,customImagePanel:B&&Js?t.jsxs("div",{ref:Zs,className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:Bu,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:[Ke.size>0&&t.jsxs("button",{type:"button",onClick:()=>He(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${r("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",Ke.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:wt<=1,onClick:()=>{var I;return(I=mt.current)==null?void 0:I.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(wt*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:wt>=6,onClick:()=>{var I;return(I=mt.current)==null?void 0:I.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:wt===1,onClick:()=>{var I;return(I=mt.current)==null?void 0:I.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(Nb,{ref:mt,resetKey:xt,onScaleChange:Ot,style:{flex:1,minHeight:0},children:t.jsx(rl,{store:ft,children:I=>t.jsx(vs,{imageUrl:Mu,pageData:Js,selectedCharIds:Ke,hoveredCharId:I,preserveMargins:Xt,renderScale:wt,selectedFigBlock:Ze,onFigBlockClick:Y=>ot(Y),onCharClick:Y=>{ot(null),He(at=>{const et=new Set(at);return et.has(Y)?et.delete(Y):(et.clear(),et.add(Y)),et});const we=document.querySelector(`[data-char-id="${Y}"]`);we&&we.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:ft.set})})}),t.jsxs("div",{"data-testid":"facsimile-pager",role:"group","aria-label":F("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:Lr<=0,onClick:()=>Zn(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":xt,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":F("reader.facsimilePageInput"),size:Math.max(2,String(Er??xt).length),value:Er??String(xt),onFocus:I=>I.currentTarget.select(),onChange:I=>Pu(I.target.value),onKeyDown:I=>{I.key==="Enter"?(I.preventDefault(),Xs()):I.key==="Escape"&&(Ci.current=null,Ir(null)),I.stopPropagation()},onBlur:Xs,style:{width:`${Math.max(2,String(Er??xt).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:Lr<0||Lr>=Jt.length-1,onClick:()=>Zn(1),children:"›"})]})]}):void 0,settingsExtra:m,settingsExtraTitle:g,settingsAnnotate:B?t.jsx("button",{type:"button",className:`bim-rd-t bim-rd-sp-tg ${nt?"bim-rd-on":""}`,"aria-pressed":nt,title:"切换外挂现代断句标点",onClick:()=>It(I=>!I),children:nt?"标点":"无标点"}):void 0,prefs:ae,onPrefsChange:ie,versions:Ar.length>1?Ar:void 0,currentVersionKey:Ar.length>1?K.key:void 0,onVersionChange:gt,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:Ji(Tn),allowVertical:y,origScriptAvailable:Ku,contentLoading:ze,children:[(ze||ve&&!B&&!xn&&Ti==null)&&t.jsx(_n,{}),!ze&&B&&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:Ie!=null&&Ie.title?R(Ie.title):Br}),(ln||K.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[ln,K.license&&t.jsxs(t.Fragment,{children:[ln&&t.jsx("span",{className:"bim-rd-dot"}),K.license]})]})]}),t.jsx(rl,{store:ft,children:I=>t.jsx(Cs,{pageData:B,pages:B.pages,punctuations:B.punctuations||Pb,selectedCharIds:Ke,hoveredCharId:I,onSelectionChange:Lu,figures:B.figures,figUrl:B.figUrl,onFigureBlockClick:({page:Y,fig:we})=>{He(new Set),ot(we),zn(Y)},onCharClick:Y=>{ot(null),He(at=>{const et=new Set(at);return et.has(Y)?et.delete(Y):(et.clear(),et.add(Y)),et});const we=parseInt(Y.split(":")[0],10);isNaN(we)||zn(we)},onCharHover:ft.set,mode:"horizontal",showPunctuation:nt,entities:Fe,entityTransport:i,onEntityNavigate:T,onVisiblePageChange:Au,convert:R,scrollToPage:Ct,scrollToAnchor:lt&<.chapter===Ce&&zr?lt:null,onVisibleHeadingChange:Y=>z(Y&&Ce?{chapter:Ce,anchor:Y}:null),pageBreaks:ae.pageBreaks,pageIndicatorY:ae.pageIndicatorY,onPageIndicatorYChange:Y=>ie({pageIndicatorY:Y}),quoteStyle:ae.quoteStyle,bookTitleStyle:ae.bookTitleStyle,showWorks:ae.showWorks})})]}),!ze&&!B&&xn&&bn&&t.jsx(Fx,{juan:bn,rawText:Tn,positionLabel:Hb(Ie,he,Nn,R),groupLabel:Db(he,Ce??null),index:Ob(n,he),searchQuery:it,onNavigate:l,transport:i,workLabelCache:We,prefs:ae,view:ea,onViewChange:Mr},`${M}/${Ce}`),!ze&&!B&&!xn&&Ti!=null&&Ie&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:Ie.title?R(Ie.title):Br}),(ln||K.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[Ri&&ln&&t.jsx(t.Fragment,{children:ln}),!Ri&&K.source_name&&t.jsxs(t.Fragment,{children:[F("reader.textSource")," ",K.source_url?t.jsx("a",{className:"bim-rd-link",href:K.source_url,target:"_blank",rel:"noreferrer",children:R(K.source_name)}):R(K.source_name)]}),ln&&K.license&&t.jsx("span",{className:"bim-rd-dot"}),K.license]}),Lt&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[F("reader.upstream")," ",Lt.url?t.jsx("a",{className:"bim-rd-link",href:Lt.url,target:"_blank",rel:"noreferrer",children:R(Lt.name??Lt.url)}):R(Lt.name??""),Lt.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),Lt.license_url?t.jsx("a",{className:"bim-rd-link",href:Lt.license_url,target:"_blank",rel:"noreferrer",children:Lt.license}):Lt.license]}),Lt.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(Zc,{text:Lt.note,convert:R})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(ms,{text:Ti,mode:ae.readingMode,tables:Gu,gujiMarkdown:!0,bookMarking:us(ae),quoteStyle:ae.quoteStyle})})]}),!ze&&!ve&&!B&&!xn&&Ti==null&&Ie&&t.jsx("div",{className:"bim-rd-state",children:F("reader.chapterFailed")}),!ze&&he.references&&he.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:F("reader.references")}),t.jsx("ol",{children:he.references.map((I,Y)=>t.jsxs("li",{children:[I.url?t.jsx("a",{className:"bim-rd-link",href:I.url,target:"_blank",rel:"noopener noreferrer",children:R(I.title)}):t.jsx("span",{children:R(I.title)}),I.author&&t.jsxs("span",{children:[",",R(I.author)]}),I.note&&t.jsxs("span",{children:["。",R(I.note)]})]},Y))})]})]})};function vl(e){return e.is_original===!0||e.source==="original"}function Hb(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 Db(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 Ub(e,n,i){const[o,s]=h.useState({entryTitle:void 0,authors:[]});return h.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 dp={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")}},Vb=dp.other,pp={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")}},Gb=pp.pending;function Yb(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 Kb(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 Rs=({items:e,loading:n})=>{const i=kt(),{t:o,convert:s}=oe();return n?t.jsx(_n,{}):e.length===0?t.jsx("div",{style:qb,children:o("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=dp[a.type]||Vb,d=pp[a.status]||Gb,c=typeof window<"u"&&Kb(a.pageUrl,window.location.href);return t.jsxs("div",{style:Xb,children:[t.jsxs("div",{style:Zb,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...kl,background:l.color},children:o(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...kl,background:d.color},children:o(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:Jb,children:Yb(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:Qb,children:[a.resourceId&&t.jsx("a",{href:i(a.resourceId),style:Qr,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:Qr,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:Qr,children:a.pageUrl}))]}),t.jsx("div",{style:ey,children:s(a.content)}),a.reply&&t.jsxs("div",{style:ty,children:[t.jsx("div",{style:ny,children:o("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},qb={textAlign:"center",padding:"40px 0",color:r("desc-fg"),fontSize:"14px"},Xb={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"16px"},Zb={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},kl={fontSize:"12px",color:r("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},Jb={fontSize:"12px",color:r("desc-fg")},Qb={fontSize:"12px",marginBottom:"6px"},Qr={color:r("primary"),textDecoration:"none",borderBottom:`1px dashed ${r("primary")}`},ey={fontSize:"14px",lineHeight:"1.6",color:r("fg"),whiteSpace:"pre-wrap"},ty={marginTop:"12px",padding:"10px 12px",background:r("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:r("fg")},ny={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:r("primary")},Co=({transport:e,onNavigate:n,recommendedIds:i,activeTab:o,onTabChange:s,feedbackApiUrl:a})=>{const l=Be(),[d,c]=h.useState(null),[p,m]=h.useState([]),[g,u]=h.useState("recommend"),[f,x]=h.useState([]),[j,y]=h.useState(!1),S=o??g,b=R=>{u(R),s==null||s(R)},[v,w]=h.useState(!0),[k,_]=h.useState(null),[$,C]=h.useState(null),[L,E]=h.useState(null);h.useEffect(()=>{let R=!1;if(e.getCounts)return e.getCounts().then(G=>{R||c({works:G.works,books:G.books,collections:G.collections})}).catch(()=>{}),()=>{R=!0}},[e]),h.useEffect(()=>{let R=!1;return(async()=>{if(i)return i;if(e.getRecommended)try{const Q=await e.getRecommended();if(Q!=null&&Q.groups)return Q.groups.flatMap(ie=>ie.items.map(de=>({...de,group:ie.name})))}catch{}return[]})().then(async Q=>{if(R)return;const ie=Q.filter(q=>q.id);if(ie.length===0){w(!1);return}const de=await Promise.all(ie.map(async q=>{if(q.type)return{id:q.id,title:q.title,type:q.type,author:q.author,dynasty:q.dynasty,role:q.role,edition:q.edition,has_text:q.has_text,has_image:q.has_image,has_collated:q.has_collated,subtype:q.subtype,primary_name:q.primary_name,group:q.group,fallbackDescription:q.description};try{let ee=null;if(e.getEntry)ee=await e.getEntry(q.id);else{const U=await e.getItem(q.id);U&&(ee={id:q.id,title:U.title||q.id,type:U.type||"work"})}if(ee)return{...ee,group:q.group,fallbackDescription:q.description}}catch{}return{id:q.id,title:q.title,type:xe.extractType(q.id),group:q.group,fallbackDescription:q.description}}));R||(m(de.filter(q=>q!==null)),w(!1))}),()=>{R=!0}},[e,i]);const T=h.useRef(!1),N=h.useRef(!1),W=h.useRef(!1);h.useEffect(()=>{if(S!=="catalog"||T.current)return;const R=e.getCatalogProgress??e.getResourceProgress;if(!R)return;T.current=!0;let G=!1;return R.call(e).then(Q=>{G||_(Q)}).catch(()=>{T.current=!1}),()=>{G=!0}},[e,S]),h.useEffect(()=>{if(S!=="collection"||N.current||!e.getCollectionProgress)return;N.current=!0;let R=!1;return e.getCollectionProgress().then(G=>{R||C(G)}).catch(()=>{N.current=!1}),()=>{R=!0}},[e,S]),h.useEffect(()=>{if(S!=="site"||W.current||!e.getSiteProgress)return;W.current=!0;let R=!1;return e.getSiteProgress().then(G=>{R||E(G)}).catch(()=>{W.current=!1}),()=>{R=!0}},[e,S]),h.useEffect(()=>{if(!a||S!=="feedback")return;let R=!1;return y(!0),fetch(a).then(G=>G.json()).then(G=>{!R&&G.success&&x(G.items||[])}).catch(()=>{}).finally(()=>{R||y(!1)}),()=>{R=!0}},[a,S]);const F=R=>t.jsx(Yn,{type:R,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(ii,{label:l.home.recommendTab,active:S==="recommend",onClick:()=>b("recommend")}),t.jsx(ii,{label:l.home.catalogTab,active:S==="catalog",onClick:()=>b("catalog")}),t.jsx(ii,{label:l.home.collectionTab,active:S==="collection",onClick:()=>b("collection")}),t.jsx(ii,{label:l.home.siteTab,active:S==="site",onClick:()=>b("site")}),a&&t.jsx(ii,{label:l.home.feedbackTab,active:S==="feedback",onClick:()=>b("feedback")})]}),S==="recommend"&&t.jsx(iy,{recommended:p,loading:v,onNavigate:n,getIcon:F,t:l}),S==="catalog"&&t.jsx(wl,{progress:k,t:l,onNavigate:n}),S==="collection"&&t.jsx(wl,{progress:$,t:l,onNavigate:n}),S==="site"&&t.jsx(oy,{progress:L,t:l,totalWorks:(d==null?void 0:d.works)??0}),S==="feedback"&&a&&t.jsx(Rs,{items:f,loading:j})]})})},ii=({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}),iy=({recommended:e,loading:n,onNavigate:i,getIcon:o,t:s})=>{const a=kt();if(n)return t.jsx(_n,{});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 m=p.dynasty||p.author?`${p.dynasty?`〔${p.dynasty}〕`:""}${p.author||""}`:p.fallbackDescription;return t.jsxs("a",{href:a(p.id),onClick:g=>{g.metaKey||g.ctrlKey||(g.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})]}),m&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m})]})]},p.id)})})]},d))})},wl=({progress:e,t:n,onNavigate:i})=>{if(!e)return t.jsx(_n,{});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(ry,{item:p,t:n,statusColor:l[d],onNavigate:i},p.id))})]},d)})})},ry=({item:e,t:n,statusColor:i,onNavigate:o})=>{const s=kt(),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?Pt(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})]})},oy=({progress:e,t:n,totalWorks:i})=>{if(!e)return t.jsx(_n,{});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(Sl,{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(Sl,{item:c,t:n,totalWorks:i},c.id))})]})]})},Sl=({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})]})},$l="(max-width: 768px)";function sy(){const[e,n]=h.useState(()=>typeof window>"u"?!1:window.matchMedia($l).matches);return h.useEffect(()=>{const i=window.matchMedia($l),o=s=>n(s.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),e}const ay=({transport:e,hideModeIndicator:n=!0,onEntryClick:i,recommendedIds:o,headerRight:s})=>{var N;const a=Be(),{convert:l}=Ge(),d=sy(),[c,p]=h.useState(null),[m,g]=h.useState(null),[u,f]=h.useState(!1),[x,j]=h.useState("detail"),[y,S]=h.useState([]),[b,v]=h.useState(!1),w=h.useCallback(async W=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){S([]);return}v(!0);try{if(e.getCollectionCatalogs){const F=await e.getCollectionCatalogs(W);S(F||[])}else if(e.getCollectionCatalog){const F=await e.getCollectionCatalog(W);S(F?[{resource_id:"",data:F}]:[])}}catch{S([])}finally{v(!1)}},[e]),k=h.useCallback(async W=>{if(i){i(W);return}p(W),g(null),S([]),j("detail"),f(!0);try{const F=await e.getItem(W.id);F&&(g(F),F.type==="collection"&&w(W.id))}catch(F){console.error("加载详情失败:",F)}finally{f(!1)}},[e,i,w]),_=h.useCallback(async W=>{g(null),S([]),j("detail"),f(!0);try{const F=await e.getItem(W);F&&(g(F),p({id:W,title:F.title||W,type:F.type||"book"}),F.type==="collection"&&w(W))}catch(F){console.error("导航失败:",F)}finally{f(!1)}},[e,w]),$=typeof(m==null?void 0:m.text_count)=="number"&&m.text_count>0,C=(m==null?void 0:m.type)==="collection"&&(y.length>0||b)||(m==null?void 0:m.type)==="work"&&$,L=d&&(u||m),E=h.useCallback(()=>{p(null),g(null),S([]),j("detail")},[]),T=t.jsx(t.Fragment,{children:u?t.jsx(_n,{}):m?t.jsxs(t.Fragment,{children:[(C||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:[C&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>j("detail"),style:Bi(x==="detail"),children:a.detailTab.basicInfo}),m.type==="collection"&&b&&y.length===0&&t.jsxs("button",{onClick:()=>{},style:Bi(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),m.type==="collection"&&y.map(W=>t.jsx("button",{onClick:()=>j(`catalog:${W.resource_id}`),style:Bi(x===`catalog:${W.resource_id}`),children:W.short_name?`${l(W.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},W.resource_id)),m.type==="work"&&$&&t.jsx("button",{onClick:()=>j("collated"),style:Bi(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(Qo,{data:m,transport:e,onNavigate:_}):x.startsWith("catalog:")?t.jsx(es,{data:(N=y.find(W=>`catalog:${W.resource_id}`===x))==null?void 0:N.data,onNavigate:_}):x==="collated"?t.jsx(Ts,{id:m.id,transport:e,onNavigate:_}):null})]}):t.jsx(Co,{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:L?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:E,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(po,{transport:e,onEntryClick:k,hideModeIndicator:n}),!m&&t.jsx(Co,{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(po,{transport:e,onEntryClick:k,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:r("bg"),display:"flex",flexDirection:"column"},children:T})]})};function Bi(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 ly=({pageData:e,rawImageUrl:n="",punctuations:i=[],title:o,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=h.useState(new Set),[m,g]=h.useState(null),[u,f]=h.useState("horizontal"),[x,j]=h.useState(!0),y=h.useRef(null),S=h.useCallback(k=>{p(new Set(k))},[]),b=h.useCallback(k=>{if(p(_=>{const $=new Set(_);return $.has(k)?$.delete(k):($.clear(),$.add(k)),$}),y.current){const _=y.current.querySelector(`[data-char-id="${k}"]`);_&&_.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),v=()=>{var k;p(new Set),window.getSelection&&((k=window.getSelection())==null||k.removeAllRanges())},w=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:v,className:"guji-reader-btn",children:"清除选中"}),t.jsx("button",{type:"button",onClick:()=>j(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:u==="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(vs,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:m,onCharClick:b,onCharHover:g})})]}),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:u==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(Cs,{pageData:e,punctuations:w,selectedCharIds:c,hoveredCharId:m,onSelectionChange:S,onCharClick:b,onCharHover:g,mode:u,showPunctuation:x})]})]})]})},cy=({data:e,onNavigate:n,className:i,style:o})=>{var m;const{t:s,convert:a}=oe(),[l,d]=h.useState(((m=e.divisions[0])==null?void 0:m.name)??null),[c,p]=h.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(g=>t.jsx(dy,{division:g,expanded:l===g.name,onToggle:()=>d(l===g.name?null:g.name),expandedCat:c,onCatToggle:u=>p(c===u?null:u),onNavigate:n},g.name))})]})},dy=({division:e,expanded:n,onToggle:i,expandedCat:o,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=oe(),c=e.categories.reduce((p,m)=>{const g=m.stats||{zhulu:0,cunmu:0};return p+(g.zhulu||0)+(g.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 m=`${e.name}/${p.name}`;return t.jsx(py,{category:p,expanded:o===m,onToggle:()=>s(m),onNavigate:a},p.name)})})]})},py=({category:e,expanded:n,onToggle:i,onNavigate:o})=>{var p,m,g,u;const{t:s,convert:a}=oe(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((m=e.books)==null?void 0:m.cunmu)||[],c=(((g=e.stats)==null?void 0:g.zhulu)||l.length)+(((u=e.stats)==null?void 0:u.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(_l,{label:s("catalogPage.zhulu"),books:l,onNavigate:o}),d.length>0&&t.jsx(_l,{label:s("catalogPage.cunmu"),books:d,onNavigate:o})]})]})},_l=({label:e,books:n,onNavigate:i})=>{const{t:o,convert:s}=oe(),a=kt(),[l,d]=h.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,m)=>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:g=>{g.metaKey||g.ctrlKey||(g.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)})]},m))}),!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})})]})},Dt=({title:e,onSave:n,onAskAI:i,extraButtons:o,children:s})=>{const a=Be();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:my,children:"AI"}),n&&t.jsx("button",{onClick:n,style:uy,children:a.action.save})]})]}),s]})},uy={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},my={padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},At=({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"}})]}),kn=({value:e,onChange:n,placeholder:i})=>{const o=h.useRef(null);return h.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"}})},er=({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 gy(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const Yi=({value:e,onChange:n,label:i})=>{const[o,s]=h.useState(!1),a=h.useRef(null),l=gy(e||"");return h.useEffect(()=>{o&&a.current&&a.current.focus()},[o]),!o&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Cl,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(er,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Cl,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"}})]})},Cl={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500};function hy(e){switch(e){case"url":return r("source-url");case"bookID":return r("source-bookid");default:return r("desc-fg")}}function fy(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const up=({items:e,onChange:n,onOpenEntityPicker:i})=>{const o=Be(),[s,a]=h.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=g=>{n(e.filter((u,f)=>f!==g)),s===g&&a(null)},c=(g,u,f)=>{const x=[...e];x[g]={...x[g],[u]:f},n(x)},p=(g,u)=>{const f=[...e];f[g]={...f[g],type:u,id:"",name:""},n(f),u==="bookID"&&i&&i(x=>{const j=[...e];j[g]={...j[g],id:x.id,name:x.title,type:"bookID"},n(j)})},m=g=>{i&&i(u=>{const f=[...e];f[g]={...f[g],id:u.id,name:u.title,type:"bookID"},n(f)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((g,u)=>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===u?null:u),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===u?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:r("fg")},children:g.name||`${o.editor.sourcePlaceholder} ${u+1}`}),g.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:hy(g.type),color:r("on-color-fg"),borderRadius:"3px",fontWeight:500},children:fy(g.type)}),t.jsx("button",{onClick:f=>{f.stopPropagation(),d(u)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:o.editor.deleteThisSource,children:"✕"})]}),s===u&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!g.type&&t.jsxs("div",{children:[t.jsx("label",{style:en,children:o.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(u,"bookID"),style:{...zl,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(u,"url"),style:{...zl,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})]})]})]}),g.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:en,children:o.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const f=[...e];f[u]={...f[u],type:"",id:"",name:""},n(f)},style:Nl,children:o.action.changeType})]}),g.id&&g.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:g.name}),t.jsx("code",{style:{fontSize:"11px",background:r("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:g.id})]}),t.jsx("button",{onClick:()=>m(u),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:()=>m(u),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})]})]})}),g.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:en,children:o.label.sourceName}),t.jsx("button",{onClick:()=>{const f=[...e];f[u]={...f[u],type:"",id:"",name:""},n(f)},style:Nl,children:o.action.changeType})]}),t.jsx("input",{type:"text",value:g.name,onChange:f=>c(u,"name",f.target.value),placeholder:o.editor.sourceNamePlaceholder,style:In})]}),t.jsxs("div",{children:[t.jsx("label",{style:en,children:o.label.urlAddress}),t.jsx("input",{type:"text",value:g.id,onChange:f=>c(u,"id",f.target.value),placeholder:"https://...",style:In})]})]}),g.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:{...en,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:en,children:o.label.detailsOptional}),t.jsx("input",{type:"text",value:g.details,onChange:f=>c(u,"details",f.target.value),placeholder:o.editor.detailsPlaceholder,style:In})]}),t.jsxs("div",{children:[t.jsx("label",{style:en,children:o.label.positionOptional}),t.jsx("input",{type:"text",value:g.position,onChange:f=>c(u,"position",f.target.value),placeholder:"如: 卷三, p.52",style:In})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:en,children:o.label.dataVersionOptional}),t.jsx("input",{type:"text",value:g.version,onChange:f=>c(u,"version",f.target.value),placeholder:"如: v1.0, 2024-01",style:In})]}),t.jsxs("div",{children:[t.jsx("label",{style:en,children:o.label.processorVersionOptional}),t.jsx("input",{type:"text",value:g.processor_version,onChange:f=>c(u,"processor_version",f.target.value),placeholder:"如: v0.1",style:In})]})]})]})]})})]},u)),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})]})]})},en={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},In={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"},zl={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"},Nl={background:"transparent",border:"none",color:r("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function mp(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 gp(e){return!e||e.length===0?"":JSON.stringify(e)}const hp=({entityType:e,entityId:n,entityTitle:i,parentWork:o,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:m,onLinkEntity:g,onUnlinkEntity:u,onViewEntity:f,onCreateAndLink:x,onSaveRelations:j})=>{const y=Be();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})]}),j&&t.jsx("button",{onClick:j,style:xy,children:y.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(ri,{direction:"up",title:y.relation.belongsToWork,entity:a,onView:f,onUnlink:()=>u("workId"),onLink:()=>g("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(ri,{direction:"up",title:y.relation.containedInCollection,entity:l,onView:f,onUnlink:()=>u("collectionId"),onLink:()=>g("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&&m&&m.length>0&&t.jsx(Ln,{direction:"horizontal",title:`${y.relation.siblingVersions} (${m.length})`,entities:m,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(ri,{direction:"up",title:y.relation.parentWork,entity:o,onView:f,onUnlink:()=>u("parentWorkId"),onLink:()=>g("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(Ln,{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(Ln,{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(Ln,{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(ri,{direction:"up",title:y.relation.correspondingWork,entity:a,onView:f,onUnlink:()=>u("workId"),onLink:()=>g("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(ri,{direction:"up",title:y.relation.parentCollection,entity:s,onView:f,onUnlink:()=>u("parentCollectionId"),onLink:()=>g("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(Ln,{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(Ln,{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})]})]})]})},ri=({direction:e,title:n,entity:i,onView:o,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:m,unlinkLabel:g})=>{const u=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:u,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:fp(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(Tl,{onClick:()=>o(i),title:m,children:"👁️"}),t.jsx(Tl,{onClick:s,title:g,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(zo,{onClick:a,children:d}),t.jsx(zo,{onClick:l,primary:!0,children:c})]})]})},Ln=({direction:e,title:n,entities:i,onView:o,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=h.useState(!1),m=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),g=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",u=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:m,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:g}),t.jsx("span",{children:n})]}),i.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[u.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:fp(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(zo,{onClick:s,primary:!0,children:["+ ",a]})})]})},Tl=({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}),zo=({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 fp(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const xy={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},xp=({isOpen:e,entityType:n,title:i,onSelect:o,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[m,g]=h.useState(""),u=p?l.filter(y=>y.id!==p):l;h.useEffect(()=>{e&&(g(""),d(""))},[e]);const f=y=>{g(y),d(y)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",j=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:by,children:t.jsxs("div",{style:yy,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:jy,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:m,onChange:y=>f(y.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:vy})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:eo,children:"搜索中..."}):u.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:u.map(y=>t.jsxs("div",{onClick:()=>o(y),style:ky,children:[t.jsx("span",{style:{fontSize:"16px"},children:j}),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))}):m?t.jsxs("div",{style:eo,children:["未找到匹配的",x]}):t.jsxs("div",{style:eo,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:wy,children:["创建新",x,"并关联"]})]})]})})},by={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},yy={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")},jy={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},vy={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"},ky={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:r("primary-soft")},eo={padding:"20px",textAlign:"center",color:r("desc-fg")},wy={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Rl={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},Sy={work:"📜",book:"📖",collection:"📚",entity:"👤"},bp=({isOpen:e,entityType:n,relationField:i,inheritData:o,onConfirm:s,onCancel:a})=>{const[l,d]=h.useState(""),c=h.useRef(null);h.useEffect(()=>{e&&(d((o==null?void 0:o.title)||""),setTimeout(()=>{var u,f;(u=c.current)==null||u.focus(),(f=c.current)==null||f.select()},100))},[e,o==null?void 0:o.title]);const p=u=>{u.key==="Enter"&&l.trim()?m():u.key==="Escape"&&a()},m=()=>{l.trim()&&s(l.trim(),{...o,title:l.trim()})};if(!e)return null;const g=()=>{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`创建新${Rl[n]}`}};return t.jsx("div",{style:$y,onClick:u=>{u.target===u.currentTarget&&a()},children:t.jsxs("div",{style:_y,onClick:u=>u.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Sy[n]}),t.jsx("span",{children:g()})]}),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:u=>d(u.target.value),onKeyDown:p,placeholder:`请输入${Rl[n]}名称...`,style:Cy})]}),((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:zy,children:"取消"}),t.jsx("button",{onClick:m,disabled:!l.trim(),style:{...Ny,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},$y={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},_y={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")},Cy={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"},zy={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},Ny={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg")};function Ty(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function yp(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Ry(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 jp=({isOpen:e,title:n,filterType:i="all",recentEntities:o=[],excludeId:s,showCreateButton:a=!1,createButtonText:l,onSelect:d,onCancel:c,onCreate:p,onSearch:m})=>{const[g,u]=h.useState(""),[f,x]=h.useState([]),[j,y]=h.useState(!1),[S,b]=h.useState("recent");h.useEffect(()=>{e&&(u(""),x([]),b(o.length>0?"recent":"search"))},[e,o.length]),h.useEffect(()=>{if(!g.trim()){x([]);return}const C=setTimeout(async()=>{y(!0);try{x(await m(g,i))}catch{x([])}finally{y(!1)}},300);return()=>clearTimeout(C)},[g,i,m]);const v=h.useCallback(C=>{u(C.target.value),C.target.value.trim()&&b("search")},[]),w=h.useCallback(C=>s?C.filter(L=>L.id!==s):C,[s]);if(!e)return null;const k=n||(i==="all"?"选择实体":`选择${yp(i)}`),_=w(o),$=w(f);return t.jsx("div",{style:Iy,children:t.jsxs("div",{style:Ly,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:My,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:g,onChange:v,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Ay}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),j&&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(El,{active:S==="recent",onClick:()=>b("recent"),children:["最近使用 (",_.length,")"]}),t.jsxs(El,{active:S==="search",onClick:()=>b("search"),children:["搜索结果 ",$.length>0&&`(${$.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:S==="recent"&&_.length>0?t.jsx(Il,{entities:_,onSelect:d}):g.trim()?j?t.jsx(to,{message:"搜索中..."}):$.length>0?t.jsx(Il,{entities:$,onSelect:d}):t.jsx(to,{message:"未找到匹配的结果"}):t.jsx(to,{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:Py,children:l||"创建新实体"})]})]})})},El=({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}),Il=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(i=>t.jsx(Ey,{entity:i,onClick:()=>n(i)},i.id))}),Ey=({entity:e,onClick:n})=>{const[i,o]=h.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:Ty(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:Ry(e.type),color:r("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:yp(e.type)})]})},to=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:e}),Iy={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Ly={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")},My={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Ay={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"},Py={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},By={work:r("editor-type-work"),collection:r("editor-type-collection"),book:r("editor-type-book"),entity:r("editor-type-entity")},Oy={work:"📜",collection:"📚",book:"📖",entity:"👤"},vp=({data:e,onChange:n,onSave:i,transport:o,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:m,relations:g,onRelationsChange:u})=>{var ge;const f=Be(),[x,j]=h.useState(!1),[y,S]=h.useState("work"),[b,v]=h.useState(""),[w,k]=h.useState(""),[_,$]=h.useState([]),[C,L]=h.useState(!1),[E,T]=h.useState(!1),[N,W]=h.useState("work"),[F,R]=h.useState(""),[G,Q]=h.useState(),[ie,de]=h.useState(!1),[q,ee]=h.useState(null),[U,se]=h.useState([]);h.useRef(null);const pe=e.type,_e=pe==="work",Le=pe==="collection",Ee=pe==="book",ue=h.useCallback((ne,Ne)=>{n({...e,[ne]:Ne})},[e,n]),be=h.useCallback((ne,Ne)=>{v(ne),S(Ne),k(f.editor.selectToLink+f.indexType[Ne]),$([]),j(!0)},[f]),A=h.useCallback(ne=>{o!=null&&o.unlinkEntity&&o.unlinkEntity(e.id,ne)},[o,e.id]),K=h.useCallback(ne=>{s==null||s(ne.id,ne.type)},[s]),le=h.useCallback((ne,Ne,he)=>{const Ce={...he,author:(he==null?void 0:he.author)||e.author,dynasty:he==null?void 0:he.dynasty};W(Ne),R(ne),Q(Ce),T(!0)},[e.author]),M=h.useCallback((ne,Ne)=>{o!=null&&o.createAndLink&&o.createAndLink(e.id,F,{type:N,title:ne,inheritData:Ne}),T(!1)},[o,e.id,F,N]),J=h.useCallback(ne=>{if(!ne.trim()){$([]);return}L(!0),o!=null&&o.searchEntities&&o.searchEntities(ne,y).then(Ne=>{$(Ne),L(!1)}).catch(()=>{$([]),L(!1)})},[o,y]),ye=h.useCallback(ne=>{o!=null&&o.linkEntity&&o.linkEntity(e.id,b,ne.id),j(!1)},[o,e.id,b]),je=h.useCallback(()=>{i()},[i]),Ue=h.useCallback(ne=>{ee(()=>ne),de(!0),o!=null&&o.getRecentEntities&&o.getRecentEntities().then(se).catch(()=>{})},[o]),H=h.useCallback((ne,Ne)=>o!=null&&o.searchEntities?o.searchEntities(ne,Ne==="all"?void 0:Ne):Promise.resolve([]),[o]),me=h.useCallback(ne=>{o!=null&&o.addRecentEntity&&o.addRecentEntity(ne),se(Ne=>[ne,...Ne.filter(he=>he.id!==ne.id)].slice(0,10)),q==null||q(ne),de(!1),ee(null)},[o,q]);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:Oy[pe]}),t.jsx("span",{children:e.title||f.editor.untitled}),t.jsx(er,{children:e.id}),t.jsx(er,{color:By[pe],children:f.indexType[pe]})]})}),t.jsx(Dt,{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(Yi,{label:_e?f.editor.workTitle:Le?f.editor.collectionTitle:f.editor.bookTitle,value:e.title,onChange:ne=>ue("title",ne)}),Ee&&t.jsx(Yi,{label:f.editor.belongsToWork,value:e.workName||"",onChange:ne=>ue("workName",ne)}),t.jsx(At,{label:f.editor.authorLabel,value:e.author||"",onChange:ne=>ue("author",ne)}),t.jsx(At,{label:f.editor.publicationYearLabel,value:e.publicationYear||"",onChange:ne=>ue("publicationYear",ne)}),(Ee||Le)&&t.jsx(Yi,{label:f.editor.containedIn,value:e.collection||"",onChange:ne=>ue("collection",ne)}),(Ee||Le)&&t.jsx(At,{label:f.editor.holderLabel,value:e.holder||"",onChange:ne=>ue("holder",ne)}),(Ee||Le)&&t.jsx(At,{label:Ee?f.editor.pageLabel:f.editor.volumeLabel,value:e.pages||"",onChange:ne=>ue("pages",ne)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(At,{label:f.editor.firstImageLabel,value:e.firstImage||"",onChange:ne=>ue("firstImage",ne)})})]})}),t.jsx(Dt,{title:f.section.description,onSave:i,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(kn,{value:e.description||"",onChange:ne=>ue("description",ne),placeholder:f.editor.descriptionPlaceholder})}),(((ge=e.additional_works)==null?void 0:ge.length)||0)>0&&t.jsx(Dt,{title:f.section.additionalWorks,onSave:i,children:t.jsx(Wy,{items:e.additional_works||[],onChange:ne=>ue("additional_works",ne)})}),t.jsx(Dt,{title:f.section.indexedBy,onSave:i,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(Fy,{items:e.indexed_by||[],onChange:ne=>ue("indexed_by",ne)})}),t.jsx(Dt,{title:f.section.emendatedBy,onSave:i,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(Hy,{items:e.emendated_by||[],onChange:ne=>ue("emendated_by",ne)})}),t.jsx(Dt,{title:f.section.textResources,onSave:i,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(ao,{items:e.resources||[],onChange:ne=>ue("resources",ne),onDownload:p,downloadStatuses:m,filterType:"text"})}),t.jsx(Dt,{title:f.section.imageResources,onSave:i,children:t.jsx(ao,{items:e.resources||[],onChange:ne=>ue("resources",ne),onDownload:p,downloadStatuses:m,filterType:"image"})}),t.jsx(Dt,{title:f.section.sources,onSave:i,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(up,{items:mp(e.sources||""),onChange:ne=>ue("sources",gp(ne)),onOpenEntityPicker:Ue})}),(Ee||Le)&&t.jsx(Dt,{title:f.section.provenance,onSave:i,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(kn,{value:e.provenance||"",onChange:ne=>ue("provenance",ne),placeholder:f.editor.provenancePlaceholder})}),Ee&&t.jsx(Dt,{title:f.section.otherEditions,onSave:i,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(kn,{value:e.otherEditions||"",onChange:ne=>ue("otherEditions",ne),placeholder:f.editor.otherEditionsPlaceholder})}),t.jsx(hp,{entityType:pe,entityId:e.id,entityTitle:e.title,parentWork:g==null?void 0:g.parentWork,parentCollection:g==null?void 0:g.parentCollection,belongsToWork:g==null?void 0:g.belongsToWork,belongsToCollection:g==null?void 0:g.belongsToCollection,childWorks:g==null?void 0:g.childWorks,childCollections:g==null?void 0:g.childCollections,containedBooks:g==null?void 0:g.containedBooks,siblingBooks:g==null?void 0:g.siblingBooks,onLinkEntity:be,onUnlinkEntity:A,onViewEntity:K,onCreateAndLink:le,onSaveRelations:je}),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(xp,{isOpen:x,entityType:y,title:w,onSelect:ye,onCancel:()=>j(!1),onCreate:()=>{j(!1),le(b,y)},searchResults:_,onSearch:J,isLoading:C,excludeId:e.id}),t.jsx(bp,{isOpen:E,entityType:N,relationField:F,inheritData:G,onConfirm:M,onCancel:()=>T(!1)}),t.jsx(jp,{isOpen:ie,title:f.action.selectBookOrWork,filterType:"all",recentEntities:U,excludeId:e.id,onSelect:me,onCancel:()=>{de(!1),ee(null)},onSearch:H})]})};function Wy({items:e,onChange:n}){const i=Be(),o=(l,d,c)=>{const p=e.map((m,g)=>g===l?{...m,[d]:c}:m);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(At,{label:i.editor.bookNameLabel,value:l.book_title,onChange:c=>o(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(At,{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 kp({items:e,onChange:n,showMeta:i,addLabel:o}){const s=Be(),[a,l]=h.useState(null),d=(m,g,u)=>{const f=e.map((x,j)=>j===m?{...x,[g]:u||void 0}:x);n(f)},c=m=>{n(e.filter((g,u)=>u!==m)),a===m&&l(null)},p=()=>{n([...e,{source:""}]),l(e.length)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((m,g)=>{const u=a===g;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:u?`color-mix(in srgb, ${r("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(u?null:g),children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.2s",transform:u?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:m.source||s.editor.unnamedSource}),m.source_bid&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:m.source_bid}),t.jsx("button",{onClick:f=>{f.stopPropagation(),c(g)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${r("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:r("muted")},children:"✕"})]}),!u&&i&&(m.title_info||m.author_info)&&t.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:r("desc-fg")},children:[m.title_info,m.title_info&&m.author_info&&" — ",m.author_info]}),u&&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(At,{label:s.label.sourceName,value:m.source,onChange:f=>d(g,"source",f)}),t.jsx(At,{label:s.label.sourceBid,value:m.source_bid||"",onChange:f=>d(g,"source_bid",f)})]}),i&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(At,{label:s.label.titleInfo,value:m.title_info||"",onChange:f=>d(g,"title_info",f)}),t.jsx(At,{label:s.label.authorInfo,value:m.author_info||"",onChange:f=>d(g,"author_info",f)})]}),t.jsx(At,{label:s.label.edition,value:m.edition||"",onChange:f=>d(g,"edition",f)})]}),t.jsx(kn,{value:m.summary||"",onChange:f=>d(g,"summary",f),placeholder:s.editor.summaryPlaceholder}),t.jsx(kn,{value:m.comment||"",onChange:f=>d(g,"comment",f),placeholder:s.editor.commentPlaceholder}),t.jsx(kn,{value:m.additional_comment||"",onChange:f=>d(g,"additional_comment",f),placeholder:s.editor.additionalCommentPlaceholder})]})]},g)}),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 Fy({items:e,onChange:n}){const i=Be();return t.jsx(kp,{items:e,onChange:n,showMeta:!0,addLabel:i.action.addIndexedBy})}function Hy({items:e,onChange:n}){const i=Be();return t.jsx(kp,{items:e,onChange:n,addLabel:i.action.addEmendatedBy})}function wp(e){var d,c,p,m,g,u,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=((m=e.current_location)==null?void 0:m.name)||"",s=(g=e.page_count)!=null&&g.number?String(e.page_count.number):((u=e.page_count)==null?void 0:u.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 j=x.related_works.find(y=>y.relation==="part_of");j&&(l.parentWorkId=j.id,l.parentWorkName=j.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 Dy(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 Uy=e=>{const{data:n,id:i,transport:o,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:m,onAskAI:g,renderSectionActions:u,onDownloadResource:f,downloadStatuses:x,relations:j,onRelationsChange:y,headerExtra:S,className:b,style:v}=e,w=Be(),[k,_]=h.useState(s),$=a?s:k;h.useEffect(()=>{s!==k&&_(s)},[s]);const C=h.useCallback(()=>{const R=$==="view"?"edit":"view";a?a(R):_(R)},[$,a]),[L,E]=h.useState(null);h.useEffect(()=>{i&&o&&o.getItem(i).then(R=>{R&&E(R)})},[i,o]);const T=n||L,N=h.useMemo(()=>T?wp(T):null,[T]),W=a||!n?t.jsx("button",{onClick:C,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:$==="edit"?r("accent-bg"):"transparent",color:r($==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:$==="view"?w.common.switchToEdit:w.common.switchToView,children:$==="view"?w.common.modeEdit:w.common.modeView}):null,F=t.jsxs(t.Fragment,{children:[W,S]});return!T&&!N?t.jsx(_n,{}):$==="view"?t.jsx(Qo,{data:T,transport:o,onNavigate:p?R=>p(R):void 0,renderLink:m,headerExtra:F,className:b,style:v}):N?t.jsxs("div",{className:b,style:v,children:[F&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:F}),t.jsx(vp,{data:N,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:o,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:g,renderSectionActions:u,onDownloadResource:f,downloadStatuses:x,relations:j,onRelationsChange:y})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:r("muted")},children:w.common.noData})},Vy=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Sp=({isOpen:e,onClose:n,onSubmit:i,feedbackListUrl:o})=>{const{t:s}=oe(),[a,l]=h.useState(null),[d,c]=h.useState(""),[p,m]=h.useState(""),[g,u]=h.useState("idle"),[f,x]=h.useState(""),j=h.useRef(null);h.useEffect(()=>{e&&(l(null),c(""),m(""),u("idle"),x(""))},[e]),h.useEffect(()=>{a&&setTimeout(()=>{var b;return(b=j.current)==null?void 0:b.focus()},100)},[a]),h.useEffect(()=>{if(g==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[g,n]),h.useEffect(()=>{if(!e)return;const b=v=>{v.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,n]);const y=async()=>{if(!(!a||!d.trim())){u("submitting"),x("");try{await i({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),u("success")}catch(b){u("error"),x(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const S=a&&d.trim()&&g!=="submitting";return t.jsx("div",{style:Gy,onClick:b=>{b.target===b.currentTarget&&n()},children:t.jsxs("div",{style:Yy,onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{style:Ky,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:qy,"aria-label":s("feedback.close"),children:"✕"})]}),g==="success"?t.jsxs("div",{style:e0,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:Vy.map(b=>t.jsxs("button",{onClick:()=>l(b.value),style:{...Xy,...a===b.value?Zy:{}},children:[t.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),t.jsx("textarea",{ref:j,value:d,onChange:b=>c(b.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||g==="submitting",style:{...Jy,opacity:a?1:.6}}),t.jsx("input",{type:"text",value:p,onChange:b=>m(b.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!a||g==="submitting","aria-label":s("feedback.contactLabel"),style:n0}),t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),g==="error"&&t.jsx("div",{style:t0,children:f}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:y,disabled:!S,style:{...Qy,opacity:S?1:.6,cursor:S?"pointer":"not-allowed"},children:s(g==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},Gy={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Yy={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:r("shadow-dialog")},Ky={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},qy={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:r("desc-fg"),padding:"4px 8px",borderRadius:"4px"},Xy={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"},Zy={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},Jy={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"},Qy={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},e0={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:r("success")},t0={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginBottom:"12px"},n0={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"},No="--bim-feedback-fab-offset",To=48,i0=16,r0=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:i,hidden:o=!1,zIndex:s})=>{const{t:a}=oe(),[l,d]=h.useState(!1),c=n.bottom??24;return h.useEffect(()=>{if(o||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(No,`calc(${c+To+i0}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(No)}},[o,c]),t.jsxs(t.Fragment,{children:[!o&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...o0,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(Sp,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:i})]})},o0={position:"fixed",width:`${To}px`,height:`${To}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"},s0=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],$p=({onSubmit:e})=>{const{t:n}=oe(),[i,o]=h.useState("bug"),[s,a]=h.useState(""),[l,d]=h.useState(""),[c,p]=h.useState("idle"),[m,g]=h.useState(""),u=h.useRef(null);h.useEffect(()=>{i&&setTimeout(()=>{var j;return(j=u.current)==null?void 0:j.focus()},100)},[i]);const f=async()=>{if(!(!i||!s.trim())){p("submitting"),g("");try{await e({type:i,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),o("bug")}catch(j){p("error"),g(j instanceof Error?j.message:n("feedback.submitFailedRetry"))}}},x=i&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:Ll,children:t.jsxs("div",{style:p0,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:u0,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:Ll,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:s0.map(j=>t.jsxs("button",{onClick:()=>o(j.value),style:{...a0,...i===j.value?l0:{}},children:[t.jsx("span",{children:j.icon})," ",n(`feedback.submitType.${j.value}`)]},j.value))}),t.jsx("textarea",{ref:u,value:s,onChange:j=>a(j.target.value),placeholder:n(i?`feedback.placeholder.${i}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...c0}}),t.jsx("input",{type:"text",value:l,onChange:j=>d(j.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:g0}),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:{...d0,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:m0,children:m})]})},Ll={padding:"16px",border:`1px solid ${r("widget-border")}`,borderRadius:"8px",background:r("input-bg")},a0={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"},l0={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},c0={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"},d0={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},p0={display:"flex",alignItems:"center",gap:"12px",color:r("success"),fontSize:"14px"},u0={background:"none",border:"none",color:r("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},m0={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginTop:"8px"},g0={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 Ml(e){return typeof e=="function"?e():e??"/api/feedback"}const _p=({resourceId:e,apiUrl:n})=>{const{t:i}=oe(),[o,s]=h.useState([]),[a,l]=h.useState(!0),d=h.useCallback(async()=>{const p=Ml(n);l(!0);try{const g=await(await fetch(`${p}?resourceId=${encodeURIComponent(e)}`)).json();g.success&&s(g.items)}catch{}finally{l(!1)}},[e,n]);h.useEffect(()=>{d()},[d]);const c=async p=>{const m=Ml(n),g=await fetch(m,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!g.ok){const u=await g.json().catch(()=>null);throw new Error((u==null?void 0:u.error)||i("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(Rs,{items:o,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx($p,{onSubmit:c})})]})},br=8;async function yr(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 h0=ir["zh-Hant"].relation,f0=ir["zh-Hant"].lossStatus,x0=ir["zh-Hant"].resourceKind,jr=Gn("zh-Hant"),Es=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function Al(e,n=jr){return e?Es(h0,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function b0(e,n=jr){return Es(f0,e)?n(`detail.lossStatus.${e}`):e}function y0(e,n=jr){return Es(x0,e)?n(`detail.resourceKind.${e}`):""}function Is({authors:e,onNavigate:n,renderLink:i}){const{convert:o}=oe(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=Yo(a.role);return t.jsxs(h.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(jt,{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 Cp(e,n,i=jr){var c,p;const o=Vo(e,n),s=o.mirrors.map(m=>({key:m.key,label:m.label,description:m.description,rows:m.items.filter(g=>g.group_role!=="mirror"),mirrors:m.items.filter(g=>g.group_role==="mirror")})),a=o.buckets.filter(m=>m.key==="image"||m.key==="textImage").flatMap(m=>m.items);a.length&&s.push({key:"_images",label:s.length?i("detail.otherImages"):void 0,rows:a,mirrors:[]});const l=((c=o.buckets.find(m=>m.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(m=>m.key==="text"))==null?void 0:p.items)??[],groups:s}}function zp(e,n){const i=(e.url?Dn(e.url):void 0)||e.name,o=Sc(e,n);return o?`${i}(${o})`:i}function Ls({item:e,siblings:n,listedVolumeCounts:i}){const{t:o,convert:s}=oe(),[a,l]=h.useState(!1),d=nr(e),c=!!d&&d.expected>0&&!(i!=null&&i.has(d.expected)),p=s(zp(e,n)),m=Un(e),g=lr(e,o)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var f,x;const u=(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 m?t.jsxs("a",{href:m,target:"_blank",rel:"noopener noreferrer",children:[p," ",t.jsx("span",{"aria-hidden":"true",children:"↗"}),u]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,u]})})(),g&&t.jsx("span",{className:"bim-d-meta",children:s(g)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(as,{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(u=>!u),children:a?o("detail.collapseVolumes"):o("detail.expandVolumes",{n:d.expected})})})]})}function Np({groups:e,listedVolumeCounts:n}){const{t:i,convert:o}=oe();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(Ls,{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=Un(a),c=o(zp(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 mi=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function Ro(e){var i;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(i=mi.find(o=>n.startsWith(o.key[0])))==null?void 0:i.key}const Pl=12,j0=60,Tp=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,railTop:a,back:l,railLinks:d})=>{var ye,je,Ue;const{t:c,convert:p,messages:m}=oe(),g=h.useMemo(()=>Ko({_books:e._books}),[e._books]),[u,f]=h.useState(new Map),[x,j]=h.useState(!1),[y,S]=h.useState(""),[b,v]=h.useState(!1),w=g.length<=j0,k=w||x||!!y||b,_=h.useMemo(()=>k?g:g.slice(0,Pl),[g,k]);h.useEffect(()=>{if(!n||_.length===0)return;const H=_.filter(ge=>!u.has(ge));if(H.length===0)return;let me=!1;return yr(H,br,ge=>n.getItem(ge).then(ne=>{var he;const Ne=ne??{};return[ge,{id:ge,title:Ne.title,edition:Ne.edition,resources:Ne.resources,publication_info:Ne.publication_info,current_location:Ne.current_location,provenance:Ne.provenance,lineage:Ne.lineage,related_books:Ne.related_books,dating:Ne.dating,measure_info:Ne.measure_info,summary:k0((he=ne==null?void 0:ne.description)==null?void 0:he.text)}]}).catch(()=>[ge,{id:ge}]),()=>me).then(ge=>{me||f(ne=>{const Ne=new Map(ne);for(const[he,Ce]of ge)Ne.set(he,Ce);return Ne})}),()=>{me=!0}},[n,_,u]);const $=h.useMemo(()=>g.map(H=>u.get(H)??{id:H}),[g,u]),C=g.length>0&&g.every(H=>u.has(H)),L=!!n&&_.some(H=>!u.has(H)),E=w||k,T=h.useMemo(()=>_c($,e.version_graph,{era:y,scanOnly:b,sort:E?"year":"default"}),[$,e.version_graph,y,b,E]),N=x?T.rows:T.rows.slice(0,Pl),W=T.allRows.filter(H=>H.hasImage).length,F=T.allRows.reduce((H,me)=>{var ge;return H+(((ge=me.copies)==null?void 0:ge.length)??0)},0),R=h.useMemo(()=>(e._related||[]).map(H=>({...H,title:H.title??""})),[e._related]),G=R.filter(H=>H.relation==="collected_in"),Q=h.useMemo(()=>{const H=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],me=ge=>{const ne=H.indexOf(ge??"");return ne<0?H.length:ne};return R.filter(ge=>ge.relation!=="collected_in").map((ge,ne)=>({r:ge,i:ne})).sort((ge,ne)=>me(ge.r.relation)-me(ne.r.relation)||ge.i-ne.i).map(ge=>ge.r)},[R]),ie=h.useMemo(()=>{const H=Vo(e.resources,e.resource_groups);return[...H.mirrors.flatMap(me=>me.items.map(ge=>({r:ge,kind:p(me.label)}))),...H.buckets.flatMap(me=>me.items.map(ge=>({r:ge,kind:p(y0(me.key,c))})))]},[e.resources,e.resource_groups,p,c]),de=e.indexed_by||[],q=e.emendated_by||[],ee=h.useMemo(()=>{var Ie,Qe,gt,lt,tt;const H=[],me=(Qe=(Ie=e.authors)==null?void 0:Ie[0])==null?void 0:Qe.dynasty;me&&H.push({label:c("workPage.fact.written"),value:p(me)});const ge=sn(e,m.unit.juan);if(ge){const Oe=((gt=e.juan_count)==null?void 0:gt.description)??((tt=(lt=e.measures)==null?void 0:lt.find(z=>(z==null?void 0:z.unit)==="卷"&&z.note))==null?void 0:tt.note);H.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(ge),Oe&&Oe!==ge?t.jsxs("span",{className:"bim-d-meta",children:["(",p(Oe),")"]}):null]})})}e.loss_status&&H.push({label:c("workPage.fact.loss"),value:p(b0(e.loss_status,c))}),e.authenticity==="forged"&&H.push({label:c("workPage.fact.authenticity"),value:p(c("workPage.fact.forged")),title:e.authenticity_basis?p(e.authenticity_basis):void 0});const ne=T.allRows.filter(Oe=>Oe.sortYear!=null),Ne=ne.length>0?ne.reduce((Oe,z)=>Oe.sortYear<=z.sortYear?Oe:z):null;Ne!=null&&Ne.era.era?H.push({label:c("workPage.fact.earliest"),value:p([Ne.era.era,Ne.era.reign].filter(Boolean).join(" ")),title:Ne.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):L&&H.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),q.length&&H.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:q.length})});const he=v0(e.additional_titles);he.length&&H.push({label:c("workPage.fact.alias"),value:he.map(p).join("、")});const Ce=(e.additional_works||[]).map(Oe=>p(Oe.book_title)+(Oe.n_juan!=null?` ${Oe.n_juan}${m.unit.juan}`:""));return Ce.length&&H.push({label:c("workPage.fact.appendix"),value:Ce.join("、")}),H},[e,p,c,m,L,T.allRows,q.length]),se=[{value:e._edition_count??g.length,label:c("workPage.stat.editions")},{value:C?W:0,label:c("workPage.stat.hasImage")},{value:de.length,label:c("workPage.stat.catalogs")}],pe=qo(e),_e=pe?[pe.l1,pe.l2,pe.l3,pe.l4].filter(Boolean).map(H=>p(H)):[],Le=e.subtype?m.workSubtype[e.subtype]??p(e.subtype):"",Ee=t.jsx(bi,{title:p(e.title),byline:t.jsx(Is,{authors:e.authors,onNavigate:i,renderLink:o}),meta:t.jsx(vt,{items:[..._e,pe!=null&&pe.source?c("workPage.classifiedBy",{source:p(pe.source.split("/")[0])}):"",Le]}),description:(ye=e.description)!=null&&ye.text?t.jsxs(t.Fragment,{children:[t.jsx(an,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(je=e.description.sources)!=null&&je.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(H=>({text:p(kg(H)),href:wg(H)})).filter(H=>H.text).map((H,me)=>t.jsxs(h.Fragment,{children:[me>0?" · ":null,H.href?t.jsx("a",{href:H.href,target:"_blank",rel:"noopener noreferrer",children:H.text}):H.text]},me))}):null]}):void 0,stats:se,facts:ee,readAction:s,foot:t.jsx(yi,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(Ue=e.appendix)==null?void 0:Ue.map((H,me)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(H.title)}),t.jsx(an,{text:H.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},me))}),ue=T.eras.length>=2?[{key:"",label:c("catalog.all")},...T.eras.map(H=>({key:H,label:`${H} ${T.allRows.filter(me=>me.era.era===H).length}`}))]:[],be=[];g.length&&be.push({id:"versions",label:c("workPage.sec.versions"),count:g.length}),de.length&&be.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:de.length}),G.length&&be.push({id:"collected",label:c("workPage.sec.collected"),count:G.length}),Q.length&&be.push({id:"related",label:c("workPage.sec.related"),count:Q.length}),ie.length&&be.push({id:"resources",label:c("workPage.sec.resources"),count:ie.length});const A=g.length===0&&de.length===0,K=t.jsxs(t.Fragment,{children:[g.length>0&&t.jsxs(St,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(vt,{items:[c("workPage.versionsTotal",{n:g.length-F}),C&&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":L&&ue.length===0&&g.length>1?"":void 0,children:[ue.length>0&&t.jsx(gr,{items:ue,value:y,onChange:H=>{S(H),j(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(fd,{label:c("workPage.scanOnly"),checked:b,onChange:H=>{v(H),j(!1)}}),t.jsx("span",{className:"bim-d-meta",children:c(E?"workPage.sortByYear":"workPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&hr(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:N.map(H=>{var me;return t.jsx(S0,{row:H,measure:(me=u.get(H.id))==null?void 0:me.measure_info,loaded:u.has(H.id),onNavigate:i,renderLink:o},`${H.id}:${u.has(H.id)?"r":"p"}`)})})]}),N.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(is,{total:T.rows.length,shown:N.length,unit:c("workPage.moreUnit"),onClick:()=>j(!0)}),T.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),de.length>0&&t.jsx($0,{items:de,transport:n,onNavigate:i,renderLink:o}),A&&t.jsx(St,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),le=(H,me)=>t.jsx(jt,{id:H,label:p(me),onNavigate:i,renderLink:o,dense:!0}),M=h.useMemo(()=>{const H=new Map;for(const me of Q){const ge=Al(me.relation,c);H.set(ge,(H.get(ge)??0)+1)}return H.size>1?[...H.entries()].sort((me,ge)=>ge[1]-me[1]).slice(0,4).map(([me,ge])=>`${p(me)} ${ge}`).join(" · "):void 0},[Q,p,c]),J=t.jsxs(t.Fragment,{children:[t.jsx(vn,{id:"collected",title:c("workPage.sec.collected"),items:G.map(H=>le(H.id,H.title))}),t.jsx(vn,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:Q.length}),sub:M,items:Q.map(H=>t.jsxs(t.Fragment,{children:[le(H.id,H.title),t.jsx("span",{className:"bim-d-meta",title:H.note?p(H.note):void 0,children:p(Al(H.relation,c))})]}))}),t.jsx(vn,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:ie.map(({r:H,kind:me})=>{const ge=p((H.url?Dn(H.url):void 0)||H.name),ne=Un(H);return t.jsxs(t.Fragment,{children:[ne?t.jsxs("a",{href:ne,target:"_blank",rel:"noopener noreferrer",children:[ge," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:ge}),me&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:me})]})})})]});return t.jsx(xi,{railTop:a,back:l,nav:be,railLinks:d,main:K,card:Ee,side:J})};function v0(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Eo(e,n){return n((e.url?Dn(e.url):void 0)||e.name)}function k0(e){var a;if(!e)return;const i=e.replace(/\*\*/g,"").split(/\n/)[0].trim().match(/[^。]+。?/g)??[],s=((i.length>1&&((a=i[0])!=null&&a.startsWith("《"))?i[1]:i[0])??"").trim();return s?s.length>120?`${s.slice(0,120)}…`:s:void 0}function w0({copies:e,onNavigate:n,renderLink:i}){const{t:o,convert:s}=oe(),a=new Map;for(const l of e){const d=l.locationName||(l.holders[0]?Eo(l.holders[0],s):"")||"",c=a.get(d)??[];c.push(l),a.set(d,c)}return t.jsxs("span",{className:"bim-d-zt-copies",children:[o("workPage.sameEditionCopies",{n:e.length}),[...a].map(([l,d],c)=>t.jsxs(h.Fragment,{children:[c>0?";":"",l?`${s(l)} `:"",d.map((p,m)=>t.jsxs(h.Fragment,{children:[m>0?" · ":"",t.jsx(jt,{id:p.id,label:p.callNumber||p.id,onNavigate:n,renderLink:i,dense:!0})]},p.id))]},l||c))]})}function S0({row:e,measure:n,loaded:i,onNavigate:o,renderLink:s}){const{t:a,convert:l}=oe(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],m=e.copies??[],g=m.length&&e.locationName?l(e.locationName):p?Eo(p,l):e.locationName?l(e.locationName):"",u=e.images[0],f=u?Un(u):void 0,x=e.images.map(j=>Eo(j,l)).join("、");return t.jsxs("tr",{"data-loading":i?void 0:"",className:m.length?"bim-d-zt-group":void 0,children:[t.jsxs("td",{className:m.length?"bim-d-zt-main bim-d-zt-rep":"bim-d-zt-main",children:[t.jsx(jt,{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:" "}),m.length>0&&e.summary&&t.jsx("span",{className:"bim-d-zt-summary",children:l(e.summary)}),m.length>0&&t.jsx(w0,{copies:m,onNavigate:o,renderLink:s})]}),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${g?"":" bim-d-zt-blank"}`,children:[g||(i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),m.length>0&&e.callNumber&&t.jsx("span",{className:"bim-d-meta",style:{display:"block",fontSize:12},children:e.callNumber}),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&&(f?t.jsx("a",{className:"bim-d-flag",href:f,target:"_blank",rel:"noopener noreferrer",title:x,children:a("workPage.hasImage")}):t.jsx("span",{className:"bim-d-flag",title:x,children:a("workPage.hasImage")}))})]})}function $0({items:e,transport:n,onNavigate:i,renderLink:o}){const{t:s,convert:a}=oe(),[l,d]=h.useState(0),c=Math.min(l,e.length-1),p=e[c],[m,g]=h.useState(new Map);return h.useEffect(()=>{if(!n)return;const u=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(u.length===0)return;let f=!1;return Promise.all(u.map(x=>n.getItem(x).then(j=>{var y,S;return[x,((S=(y=j==null?void 0:j.authors)==null?void 0:y[0])==null?void 0:S.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{f||g(new Map(x.filter(([,j])=>j)))}),()=>{f=!0}},[n,e]),t.jsx(St,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(vt,{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((u,f)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":f===c,"aria-label":a(u.source),onClick:()=>d(f),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:m.get(u.source_bid??"")?a(m.get(u.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(u.source)].slice(0,9).map((x,j)=>t.jsx("span",{children:x},j))})]})},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(vt,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(jt,{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:Bt(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:Bt(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:Bt(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"})]})]})]})})}const Rp=({graph:e,renderLink:n,className:i,style:o})=>{const{t:s,convert:a}=oe();if(!e.nodes.length)return t.jsx("div",{style:{...O0,...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 j=d.get(x)??[];j.push(f),d.set(x,j)}const c=new Map(e.nodes.map(f=>[f.id,f])),p=new Map,m=[];for(const f of e.nodes)if(f.group){const x=p.get(f.group)??[];x.push(f),p.set(f.group,x)}else m.push(f);const g=(f,x)=>(f.year??9999)-(x.year??9999);p.forEach(f=>f.sort(g)),m.sort(g);const u=e.groups.filter(f=>p.has(f.id));return t.jsxs("div",{className:i,style:{...C0,...o},children:[e.title&&t.jsx("div",{style:z0,children:a(e.title)}),e.description&&t.jsx("div",{style:N0,children:a(e.description)}),u.map(f=>t.jsx(Bl,{label:f.label,color:f.color,nodes:p.get(f.id),incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n},f.id)),m.length>0&&t.jsx(Bl,{label:s("lineage.otherGroup"),nodes:m,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},Bl=({label:e,color:n,nodes:i,incomingMap:o,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=oe();return t.jsxs("div",{style:T0,children:[t.jsx("div",{style:{...R0,borderLeftColor:n??r("widget-border")},children:d(e)}),i.map(c=>t.jsx(_0,{node:c,incoming:o.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},_0=({node:e,incoming:n,siblings:i,nodeMap:o,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=oe();return t.jsxs("div",{style:{...E0,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:I0,children:[t.jsx("span",{style:L0,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:M0,children:jc(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:A0,children:[e.category&&t.jsx(oi,{children:c(e.category)}),e.status==="lost"&&t.jsx(oi,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(oi,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(oi,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(oi,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:P0,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:B0,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:Wl,children:[t.jsx("div",{style:Fl,children:d("lineage.sources")}),n.map(p=>{const m=o.get(p.source);return t.jsxs("div",{style:Hl(p.confidence),children:[t.jsx("span",{style:Dl,children:c(p.relation)}),t.jsx("span",{children:(m==null?void 0:m.kind)==="book"&&s?s(m.id,c(m.label)):c((m==null?void 0:m.label)??p.source)}),p.confidence!=="consensus"&&p.confidence!=="certain"&&t.jsx(Ol,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Ul,children:["· ",c(p.evidence)]})]},p.id)})]}),i.length>0&&t.jsxs("div",{style:Wl,children:[t.jsx("div",{style:Fl,children:d("lineage.related")}),i.map(p=>{const m=p.source===e.id?p.target:p.source,g=o.get(m);return t.jsxs("div",{style:Hl(p.confidence),children:[t.jsx("span",{style:Dl,children:c(p.relation)}),t.jsx("span",{children:(g==null?void 0:g.kind)==="book"&&s?s(g.id,c(g.label)):c((g==null?void 0:g.label)??m)}),t.jsx(Ol,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Ul,children:["· ",c(p.evidence)]})]},p.id)})]})]})},oi=({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})},Ol=({level:e})=>{const{t:n}=oe(),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},C0={fontSize:"14px",color:r("fg")},z0={fontSize:"16px",fontWeight:600,marginBottom:"8px"},N0={fontSize:"13px",color:r("muted"),marginBottom:"16px",lineHeight:1.6},T0={marginBottom:"16px"},R0={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:r("fg")},E0={border:`1px solid ${r("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:r("bg")},I0={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},L0={fontSize:"15px",fontWeight:600},M0={fontSize:"12px",color:r("muted")},A0={marginBottom:"6px"},P0={fontSize:"12px",color:r("muted"),margin:"2px 0"},B0={fontSize:"12px",color:r("muted"),fontStyle:"italic",margin:"4px 0"},Wl={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${r("widget-border")}`},Fl={fontSize:"11px",color:r("muted"),marginBottom:"2px"},Hl=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),Dl={display:"inline-block",padding:"0 6px",fontSize:"11px",background:r("tag-bg"),color:r("fg"),borderRadius:"3px",marginRight:"6px"},Ul={fontSize:"11px",color:r("muted")},O0={padding:"20px",textAlign:"center",color:r("muted"),fontSize:"13px"},Ep=({selectedNodeId:e,...n})=>{const{t:i}=oe(),[o,s]=h.useState("loading"),[a,l]=h.useState(null);return h.useEffect(()=>{let d=!1;return W0().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),o==="loading"?t.jsx("div",{style:Gl,children:i("lineage.graphLoading")}):o==="missing"||!a?t.jsxs("div",{style:Gl,children:[t.jsx("div",{children:Vl(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:Vl(i("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(F0,{modules:a,selectedNodeId:e,...n})};function Vl(e,n){return e.split(/(\{\w+\})/).map((i,o)=>{const s=/^\{(\w+)\}$/.exec(i);return t.jsx(h.Fragment,{children:s&&s[1]in n?n[s[1]]:i},o)})}async function W0(){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 F0=({graph:e,renderLink:n,height:i=600,className:o,style:s,selectedNodeId:a,modules:l})=>{const{ReactFlow:d,Background:c,Controls:p,Handle:m,Position:g,BaseEdge:u,EdgeLabelRenderer:f,getSmoothStepPath:x,dagre:j}=l,y=h.useMemo(()=>({lineage:_=>{var G,Q,ie,de;const $=((G=_.data)==null?void 0:G.stepPosition)??.85,[C,L,E]=x({sourceX:_.sourceX,sourceY:_.sourceY,sourcePosition:_.sourcePosition,targetX:_.targetX,targetY:_.targetY,targetPosition:_.targetPosition,stepPosition:$,borderRadius:5}),T=!!((Q=_.data)!=null&&Q.isSibling),N=T?L:_.targetX-18,W=T?E:_.targetY-12,F=(ie=_.data)==null?void 0:ie.labelStyle,R=(de=_.data)==null?void 0:de.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(u,{id:_.id,path:C,style:_.style,markerStart:_.markerStart,markerEnd:_.markerEnd}),_.label&&t.jsx(f,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${N}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")}`,...R,...F},children:_.label})})]})}}),[u,f,x]),S=h.useMemo(()=>({version:_=>{const{t:$}=oe(),C=_.data,L=C.kind==="hypothetical",E=C.status==="lost",T=C.isSelected,N=C.bridge,W=C.borderColor??r("muted"),F=N||L?"dashed":"solid",R=N?.5:E?.6:1;return t.jsxs("div",{style:{background:r(N?"bg-subtle":"bg"),border:`2px ${F} ${T?r("primary"):W}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:R,boxShadow:T?r("shadow-node-selected"):L||N?"none":r("shadow-node")},title:N?$("lineage.bridgeTitle"):void 0,children:[t.jsx(m,{type:"target",position:g.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:L||!C.renderLink?C.label:C.renderLink(C.bookId,C.label)}),C.description&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.25,marginTop:1},children:C.description}),C.yearText&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.2},children:jc(C.yearText,void 0,C.uncertain)}),E&&t.jsx("div",{style:{fontSize:9,color:r("lost-fg"),marginTop:1},children:$("lineage.lost")}),t.jsx(m,{type:"source",position:g.Right,style:{visibility:"hidden"}})]})}}),[m,g]),{convert:b}=oe(),{rfNodes:v,rfEdges:w}=h.useMemo(()=>H0(e,j,n,a,b),[e,j,n,a,b]);return t.jsx("div",{style:{width:"100%",height:i,...s},className:o,children:t.jsxs(d,{nodes:v,edges:w,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 H0(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 m=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const S of e.edges)S.kind==="derive"&&(m.has(S.relation)||c.setEdge(S.source,S.target));n.layout(c);const g=e.nodes.map(S=>{const b=c.node(S.id),v=o?S.id===o:void 0,w={kind:S.kind,label:s(S.label),bookId:S.kind==="book"?S.id:void 0,yearText:s(S.year_text??U0(S)),uncertain:S.year_uncertain,category:S.category,status:S.status,borderColor:S.group?p.get(S.group):void 0,renderLink:i,isSelected:v,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:w,draggable:!1,selected:v}}),u=.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 j=new Map;for(const[S,b]of x){if(b.length<=1)continue;const v=[...b].sort((k,_)=>{var L,E;const $=((L=c.node(k.target))==null?void 0:L.y)??0,C=((E=c.node(_.target))==null?void 0:E.y)??0;return $-C}),w=v.length;v.forEach((k,_)=>{const $=(_-(w-1)/2)*f;j.set(k.id,u+$)})}const y=e.edges.map(S=>D0(S,j.get(S.id),s));return{rfNodes:g,rfEdges:y}}function D0(e,n,i=o=>o??""){const o=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=V0(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 U0(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function V0(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 Gl={padding:"40px 20px",textAlign:"center",color:r("muted"),fontSize:"13px",border:`1px dashed ${r("widget-border")}`,borderRadius:8,background:r("bg")},Ms=({graph:e,defaultMode:n="list",renderLink:i,graphHeight:o=600,selectedNodeId:s,onModeChange:a,collection:l,onCollectionChange:d,collectionsAvailable:c,collectionCounts:p,className:m,style:g})=>{var w;const{t:u,convert:f}=oe(),[x,j]=h.useState(n),y=k=>{j(k),a==null||a(k)},S=(()=>{if(!c)return[];const k=Object.entries(c);return k.length===0||c.all?k:[...k,["all",{label:u("lineage.collectionAll"),description:u("lineage.collectionAllDesc")}]]})(),b=!!(d&&S.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:r("muted"),textAlign:"center"},children:u("lineage.empty")});const v=l?(w=c==null?void 0:c[l])==null?void 0:w.description:void 0;return t.jsxs("div",{className:m,style:g,children:[t.jsxs("div",{style:G0,children:[t.jsx("button",{onClick:()=>y("list"),style:no(x==="list"),children:u("lineage.modeList")}),t.jsx("button",{onClick:()=>y("graph"),style:no(x==="graph"),children:u("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:u("lineage.collectionLabel")}),S.map(([k,_])=>{const $=p==null?void 0:p[k];return t.jsxs("button",{onClick:()=>d==null?void 0:d(k),style:no(l===k),title:_.description?f(_.description):void 0,children:[f(_.label),$!=null?` ${$}`:""]},k)})]})]}),b&&v&&t.jsx("div",{style:{fontSize:12,color:r("muted"),marginBottom:8,padding:"4px 8px",background:r("bg-subtle"),borderRadius:4},children:f(v)}),x==="list"?t.jsx(Rp,{graph:e,renderLink:i}):t.jsx(Ep,{graph:e,renderLink:i,height:o,selectedNodeId:s})]})},G0={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},no=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"}),Yl=40,Kl=2,Y0=9,K0=new Set(["certain","consensus","probable","disputed"]);function io(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const Ip=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:m})=>{var Qe,gt,lt,tt,Oe,z,re,te,fe,Me;const g=Be(),{t:u,convert:f}=oe(),[x,j]=h.useState(null),[y,S]=h.useState(new Map),[b,v]=h.useState([]),[w,k]=h.useState(new Map),[_,$]=h.useState(!1),[C,L]=h.useState("flow"),[E,T]=h.useState(null);h.useEffect(()=>{if(!n||!e.work_id){j(null);return}let P=!1;return n.getItem(e.work_id).then(ce=>{!P&&ce&&ce.type==="work"&&j(ce)}).catch(()=>{}),()=>{P=!0}},[n,e.work_id]),h.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){T(null);return}let P=!1;return n.getLineageGraph(e.work_id).then(ce=>{P||T(ce&&ce.nodes.length>1?ce:null)}).catch(()=>{P||T(null)}),()=>{P=!0}},[n,e.work_id]),h.useEffect(()=>{const P=e._collections||[];if(!n||P.length===0){S(new Map);return}let ce=!1;return Promise.all(P.map(X=>{const Te=X.id;return n.getItem(Te).then(Se=>[Te,Se]).catch(()=>[Te,null])})).then(X=>{if(ce)return;const Te=new Map;for(const[Se,ze]of X)ze&&Te.set(Se,ze);S(Te)}),()=>{ce=!0}},[n,e._collections]);const N=h.useMemo(()=>{const P=new Set([...x?Ko(x):[],...yc(e)]);return P.add(e.id),[...P]},[x,e.related_books,e.id]),W=N.length-1;h.useEffect(()=>{if(!n||W<=0){v([]);return}const P=N.length<=Yl,ce=P?N:N.slice(0,8);let X=!1;return Promise.all(ce.map(Te=>Te===e.id?Promise.resolve({id:Te,title:e.title,edition:e.edition,year:Xi(e)}):n.getItem(Te).then(Se=>{const ze=Se??{};return{id:Te,title:ze.title,edition:ze.edition,year:Se?Xi(ze):void 0}}).catch(()=>({id:Te})))).then(Te=>{if(X)return;const Se=Te.filter(ze=>ze.id===e.id||ze.title||ze.edition);P&&Se.sort((ze,qe)=>(ze.year??1/0)-(qe.year??1/0)),v(Se)}),()=>{X=!0}},[n,N,W,e]),e.lineage;const F=h.useMemo(()=>[...rn(e).filter(P=>P.ref_type==="book").map(P=>P.ref),...wn(e).map(P=>P.book_id)].filter(Boolean),[e]);h.useEffect(()=>{if(!n||F.length===0){k(new Map);return}let P=!1;return Promise.all(F.map(ce=>n.getItem(ce).then(X=>[ce,{id:ce,title:X==null?void 0:X.title,edition:X==null?void 0:X.edition}]).catch(()=>[ce,{id:ce}]))).then(ce=>{P||k(new Map(ce))}),()=>{P=!0}},[n,F]);const R=h.useMemo(()=>Cp(e.resources,e.resource_groups,u),[e.resources,e.resource_groups,u]),G=R.groups.reduce((P,ce)=>P+ce.rows.length+ce.mirrors.length,0),Q=R.groups.length>0&&R.groups.every(P=>P.key==="_physical"),ie=fi(e),de=Rc(e),q=sn(e,g.unit.juan),ee=new Set((e._collections||[]).map(P=>di(P.vol).length).filter(P=>P>0)),U=P=>{var Te;const ce=(Te=e.base_edition)==null?void 0:Te.find(Se=>Se.book_id===P&&Se.name);if(ce!=null&&ce.name)return ce.name;const X=w.get(P);return(X==null?void 0:X.edition)||(X==null?void 0:X.title)||""},se=h.useMemo(()=>{var it,pt;const P=[];de&&P.push({label:u("bookPage.fact.editionType"),value:f(de),title:e.edition_type?void 0:u("bookPage.inferredFromEdition")}),(it=e.publication_info)!=null&&it.details?P.push({label:u("bookPage.fact.publication"),value:f(e.publication_info.details)}):(ie.era||ie.reign)&&P.push({label:u("bookPage.fact.era"),value:f([ie.era,ie.reign].filter(Boolean).join(" ")),title:ie.source==="edition"?u("bookPage.inferredFromEdition"):void 0}),q&&P.push({label:u("bookPage.fact.measure"),value:f(q)});const ce=(e._collections||[]).flatMap(Z=>di(Z.vol));ce.length&&P.push({label:u("bookPage.fact.volumes"),value:u("bookPage.volumesValue",{range:cr(ce,g.unit.volume),unit:g.unit.volume,n:ce.length})});const X=rn(e).find(Z=>Z.relation==="底本"&&Z.ref_type==="book");X&&U(X.ref)&&P.push({label:u("bookPage.fact.baseEdition"),value:t.jsx(jt,{id:X.ref,label:f(U(X.ref)),onNavigate:i,renderLink:o,dense:!0})});const Te=(e.base_edition||[]).filter(Z=>Z&&Z.name);for(const Z of["底本","配補","參校"]){if(Z==="底本"&&X&&U(X.ref))continue;const $e=Te.filter(ke=>ke.role===Z);$e.length&&P.push({label:f(Z),value:$e.map((ke,Ye)=>t.jsxs(h.Fragment,{children:[Ye>0&&"、",ke.book_id?t.jsx(jt,{id:ke.book_id,label:f(ke.name),onNavigate:i,renderLink:o,dense:!0}):f(ke.name)]},Ye))})}const Se=(e.provenance||[]).filter(Z=>Z&&Z.institution),ze=(e.resources||[]).filter(Z=>on(Z).includes("physical"));if(Se.length){P.push({label:u("bookPage.fact.holdings"),value:Se.slice(0,2).map(ke=>f(ke.institution)).join("、")+(Se.length>2?u("bookPage.andMorePlaces",{n:Se.length}):"")});const Z=Se.filter(ke=>ke.call_number).slice(0,2).map(ke=>`${f(ke.institution)} ${ke.call_number}`);Z.length&&P.push({label:u("bookPage.fact.callNumber"),value:Z.join(";")+(Se.filter(ke=>ke.call_number).length>2?"…":"")});const $e=Se.flatMap(ke=>ke.seals||[]).filter(Boolean);$e.length&&P.push({label:u("bookPage.fact.seals"),value:f($e.join("、"))})}else ze.length&&P.push({label:u("bookPage.fact.holdings"),value:ze.slice(0,2).map(Z=>f(Z.name)).join("、")+(ze.length>2?u("bookPage.andMorePlaces",{n:ze.length}):"")});const qe=e.physical_description;if(qe){const Z=[[u("bookPage.fact.leafStyle"),qe.leaf_style],[u("bookPage.fact.binding"),qe.binding],[u("bookPage.fact.dimensions"),qe.dimensions],[u("bookPage.fact.condition"),qe.condition]];for(const[$e,ke]of Z)ke&&ke.trim()&&P.push({label:$e,value:f(ke)})}(pt=e.page_count)!=null&&pt.description&&P.push({label:g.label.pageCount,value:f(e.page_count.description)});const Pe=zd(e.additional_titles);return Pe.length&&P.push({label:u("bookPage.fact.aliases"),value:Pe.map(f).join("、")}),P},[e,f,g,u,ie,de,q,w,i,o]),pe=f(e.title),_e=e.edition?f(e.edition):void 0,Le=((Qe=e.dating)==null?void 0:Qe.text)||"",Ee=t.jsx(bi,{kind:u("bookPage.kind"),title:pe,subtitle:_e,byline:t.jsx(Is,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:i,renderLink:o}),meta:(()=>{const P=[de?f(de):"",ie.era?f([ie.era,ie.reign].filter(Boolean).join("")):"",q?f(q):""].filter(Boolean);return P.length?t.jsx("span",{className:"bim-d-tags",children:P.map((ce,X)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(X,2)}`,children:ce},X))}):null})(),description:(gt=e.description)!=null&>.text?t.jsx(an,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:os((lt=e.description)==null?void 0:lt.text)?6:void 0,facts:se,readAction:s,secondaryAction:s&&G>0&&!Q?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:u("bookPage.viewImages")}):void 0,foot:t.jsx(yi,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),ue=e._collections||[],be=(a==null?void 0:a.chapters)||[],A=f(be[0]&&io(be[0].title)[0].slice(-1)||"")||u("bookPage.chapterUnit"),K=u("bookPage.chapterCount",{n:be.length,unit:A}),le=!!(rn(e).length||wn(e).length||(tt=e.appendix)!=null&&tt.length),M=[],J=u(Q?"bookPage.sec.physical":"bookPage.sec.images");(be.length||R.text.length||l)&&M.push({id:"fulltext",label:u("bookPage.sec.fulltext"),count:be.length?K:void 0}),R.groups.length&&M.push({id:"images",label:J,count:G}),le&&M.push({id:"lineage",label:u("bookPage.sec.lineage")}),ue.length&&M.push({id:"collections",label:u("section.containedIn"),count:ue.length}),(Oe=e.location_history)!=null&&Oe.length&&M.push({id:"provenance",label:u("section.locationHistory")});const ye=P=>(d==null?void 0:d(P))??null,je=be[0],Ue=je?ye(je.file):null,H=_?be:be.slice(0,Y0),me=(P,ce,X)=>P?t.jsx("a",{className:X,href:P.href??"#",onClick:P.onClick?Te=>{Te.metaKey||Te.ctrlKey||(Te.preventDefault(),P.onClick())}:void 0,children:ce}):t.jsx("span",{className:X,children:ce}),ge=t.jsxs(t.Fragment,{children:[(be.length>0||R.text.length>0||l)&&t.jsxs(St,{id:"fulltext",title:u("bookPage.sec.fulltext"),meta:be.length>0?t.jsx(vt,{items:[K,(z=a==null?void 0:a.source)!=null&&z.name?u("bookPage.sourceBy",{src:f(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!je&&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"})]}),je&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:u("bookPage.readFrom",{ch:f(io(je.title)[0])||u("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:f((je.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),me(Ue,t.jsxs(t.Fragment,{children:[u("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),be.length>1&&t.jsx("ul",{className:"bim-d-chap",children:H.map(P=>{const[ce,X]=io(P.title);return t.jsx("li",{children:me(ye(P.file),t.jsxs(t.Fragment,{children:[ce&&t.jsx("b",{children:f(ce)}),f(X||P.file)]}))},P.file)})}),be.length>H.length&&t.jsx(rs,{label:u("detail.expandRest",{n:be.length-H.length,unit:A}),onClick:()=>$(!0)}),R.text.length>0&&t.jsxs(t.Fragment,{children:[(be.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:u("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:R.text.map((P,ce)=>t.jsx(Ls,{item:P,siblings:R.text,listedVolumeCounts:ee},`${P.id||P.url||P.name}-${ce}`))})})]})]}),R.groups.length>0&&t.jsx(St,{id:"images",title:J,meta:t.jsx(vt,{items:[R.groups.length>1?u("bookPage.groupCount",{n:R.groups.length}):"",u("bookPage.placeCount",{n:G})]}),children:t.jsx(Np,{groups:R.groups,listedVolumeCounts:ee})}),le&&t.jsx(St,{id:"lineage",title:u("bookPage.sec.lineage"),meta:rn(e).length?u("bookPage.lineageMeta"):void 0,action:E?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":u("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":C==="flow",onClick:()=>L("flow"),children:u("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":C==="graph",onClick:()=>L("graph"),children:u("bookPage.viewGraph")})]}):void 0,children:C==="graph"&&E?t.jsx(Ms,{graph:E,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(P,ce)=>t.jsx(jt,{id:P,label:f(ce),onNavigate:i,renderLink:o,dense:!0})}):t.jsx(X0,{data:e,heading:_e||pe,yearText:Le,refName:U,onNavigate:i,renderLink:o})}),ue.length>0&&t.jsx(St,{id:"collections",title:u("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:ue.map((P,ce)=>{const X=P.id,Te=di(P.vol),Se=y.get(X),ze=jg(Se);return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(jt,{id:X,label:Se?f(Se.title):X,onNavigate:i,renderLink:o,dense:!0}),Te.length>0&&t.jsx(q0,{volumes:Te,unit:g.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${ze?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:ze>0&&u("bookPage.totalOf",{n:ze,unit:g.unit.bu})})]},`${X}-${ce}`)})})})}),(re=e.location_history)!=null&&re.length?t.jsx(St,{id:"provenance",title:u("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((P,ce)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:f(P.name||P.location||"")}),([P.start_date,P.end_date].filter(Boolean).join("—")||P.description||P.note)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(vt,{items:[[P.start_date,P.end_date].filter(Boolean).join("—"),P.description?f(P.description):"",P.note?f(P.note):""]})})]},ce))})}):null,M.length===0&&t.jsx(St,{title:u("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:u("bookPage.emptyText")})})]}),ne=b.findIndex(P=>P.id===e.id),Ne=N.length<=Yl,he=Ne&&ne>=0?b.slice(Math.max(0,ne-Kl),ne+Kl+1):b.filter(P=>P.id!==e.id),Ce=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(g.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(jt,{id:x.id,label:f(x.title),onNavigate:i,renderLink:o})}),t.jsx(vt,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(P=>`${P.dynasty?`〔${f(P.dynasty)}〕`:""}${f(P.name)}`),f(sn(x,g.unit.juan)),x._edition_count??((te=x._books)==null?void 0:te.length)?u("bookPage.editionCount",{n:x._edition_count??((fe=x._books)==null?void 0:fe.length)??0}):""]}),((Me=x.description)==null?void 0:Me.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&&he.length>0&&t.jsxs("div",{children:[t.jsx(vn,{id:"siblings",timeline:!0,title:Ne?u("bookPage.siblings"):g.relation.siblingVersions,meta:Ne?u("bookPage.byEra"):u("bookPage.kindCount",{n:W}),cap:he.length,items:he.map(P=>P.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:f(P.edition||P.title||P.id)}):t.jsx(jt,{id:P.id,label:f(P.edition||P.title||P.id),onNavigate:i,renderLink:o,dense:!0})),metas:he.map(P=>[P.year!=null?P.year<0?u("detail.bce",{n:-P.year}):String(P.year):"",P.id===e.id?u("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:he.findIndex(P=>P.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(jt,{id:x.id,label:u("bookPage.viewAllInWork",{n:N.length}),onNavigate:i,renderLink:o,dense:!0})})]})]}),Ie=e.work_id?t.jsx(hd,{caption:g.section.belongsToWork,children:t.jsx(jt,{id:e.work_id,label:x?f(x.title):" ",onNavigate:i,renderLink:o,dense:!0})}):void 0;return t.jsx(xi,{railTop:c,back:p,up:Ie,nav:M,railLinks:m,main:ge,card:Ee,side:Ce})};function q0({volumes:e,unit:n}){const{t:i}=oe();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[i("bookPage.volumeRange",{range:cr(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 X0({data:e,heading:n,yearText:i,refName:o,onNavigate:s,renderLink:a}){var S;const{t:l,convert:d}=oe(),c=e.lineage,p=rn(e),m=p.filter(b=>b.ref_type!=="book"),g=p.filter(b=>b.ref_type==="book"&&b.relation==="底本"),u=p.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),f=wn(e),x=p.length>0||f.length>0,j=b=>b&&K0.has(b)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${b}`)}):"",y=(b,v)=>t.jsx(jt,{id:b,label:d(v||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:[m.map((b,v)=>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),j(b.confidence)]})]})},`a-${v}`)),g.map((b,v)=>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),j(b.confidence)]})]})},`b-${v}`)),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)})]}),u.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:u.map((b,v)=>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),j(b.confidence)]})]},v))})]}),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,v)=>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)})]},v))})]})]}),(S=e.appendix)==null?void 0:S.map((b,v)=>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(an,{text:b.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${v}`)),(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 si=16,Z0=200,J0=16,Lp=({data:e,catalog:n,transport:i,onNavigate:o,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var Ne,he,Ce,Ie,Qe,gt,lt,tt,Oe;const{t:p,convert:m,messages:g}=oe(),[u,f]=h.useState(""),[x,j]=h.useState(!1),[y,S]=h.useState(null),[b,v]=h.useState(""),[w,k]=h.useState(!1),_=h.useMemo(()=>Tc(e,n),[e,n]),$=h.useMemo(()=>Nc(e),[e]),[C,L]=h.useState(new Map),E=!!i&&_.rows.length>0&&_.rows.length<=Z0,T=E&&(_.rows.length<=si||w),N=T&&_.rows.every(z=>!z.id||C.has(z.id)),W=z=>{var re;return Ro(z?(re=C.get(z))==null?void 0:re.l1:void 0)},F=h.useMemo(()=>{const z=u.trim(),re=z?m(z):"";return _.rows.filter(te=>{var Me,P;if(b&&Ro(te.id?(Me=C.get(te.id))==null?void 0:Me.l1:void 0)!==b)return!1;if(!re)return!0;const fe=te.id&&((P=C.get(te.id))==null?void 0:P.title)||te.title;return m(fe).includes(re)||(te.subItems||[]).some(ce=>m(ce).includes(re))})},[_.rows,u,b,C,m]),R=x?F:F.slice(0,si),G=h.useMemo(()=>(T?_.rows:R).filter(z=>z.id&&!C.has(z.id)).map(z=>z.id),[T,_.rows,R,C]);h.useEffect(()=>{if(!i||G.length===0)return;let z=!1;const re=G.slice(0,J0);return yr(re,br,te=>i.getItem(te).then(fe=>{var ce,X;const Me=fe??{},P={title:Me.title,edition:Me.edition,authors:Me.authors,measure:fe?sn(fe,g.unit.juan):void 0,versionCount:Me._edition_count??((ce=Me._books)==null?void 0:ce.length),l1:((X=qo(Me))==null?void 0:X.l1)||void 0};return[te,P]}).catch(()=>[te,{}]),()=>z).then(te=>{z||L(fe=>{const Me=new Map(fe);for(const[P,ce]of te)Me.set(P,ce);return Me})}),()=>{z=!0}},[i,G,g.unit.juan]);const Q=(Ne=(e.contained_in||[])[0])==null?void 0:Ne.id;h.useEffect(()=>{if(!Q){S(null);return}if(S({id:Q}),!i)return;let z=!1;return i.getItem(Q).then(re=>{z||S({id:Q,title:re==null?void 0:re.title})}).catch(()=>{}),()=>{z=!0}},[i,Q]);const ie=h.useMemo(()=>Cp(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),de=ie.text.length+ie.groups.reduce((z,re)=>z+re.rows.length+re.mirrors.length,0),q=$.works,ee=new Set(_.rows.map(z=>z.id).filter(Boolean)),U=q.length>0&&!q.every(z=>ee.has(z.id)),se=(()=>{const z=_.rows.map(re=>re.edition).filter(Boolean);return z.length>1&&new Set(z).size===1})(),pe=_.rows.some(z=>z.volumes.length>0||z.expected!=null),_e=$.total,Le=$.truncated?_e:_.rows.length,Ee=sn(e,g.unit.juan),ue=e.count,be=z=>typeof z=="number"&&Number.isFinite(z)?z:null,A=be(ue==null?void 0:ue.juan)??be((he=e.juan_count)==null?void 0:he.number)??be((Ie=(Ce=e.measures)==null?void 0:Ce.find(z=>(z==null?void 0:z.unit)==="卷"))==null?void 0:Ie.number),K=be(ue==null?void 0:ue.ce)??(_.totalVolumes||null),le=[{value:Le,label:p("collectionPage.stat.titles")},{value:A??0,label:g.unit.juan},{value:K??0,label:g.unit.volume}],M=h.useMemo(()=>{var te,fe;const z=[];if((te=e.publication_info)!=null&&te.details&&z.push({label:p("collectionPage.fact.publication"),value:m(e.publication_info.details)}),_e&&(_e!==_.rows.length||$.truncated)){const Me=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");z.push({label:Me,value:`${_e} ${g.unit.bu}`,title:p("collectionPage.memberNote")})}const re=[be(ue==null?void 0:ue.zhong)!=null?p("collectionPage.nZhong",{n:ue.zhong}):"",be(ue==null?void 0:ue.han)!=null?p("collectionPage.nHan",{n:ue.han}):""].filter(Boolean);return re.length&&z.push({label:p("collectionPage.fact.expected"),value:re.join(" ")}),A==null&&Ee&&z.push({label:p("collectionPage.fact.measure"),value:m(Ee),title:(fe=e.juan_count)!=null&&fe.description?m(e.juan_count.description):void 0}),z},[e,_e,$.truncated,_.rows.length,A,Ee,ue,m,p,g]),J=h.useMemo(()=>{if(!N)return[];const z=new Map;for(const te of _.rows){const fe=W(te.id);fe&&z.set(fe,(z.get(fe)??0)+1)}const re=mi.filter(te=>(z.get(te.key)??0)>0);return re.length<2?[]:[{key:"",label:`${g.catalog.all} ${Le}`},...re.map(te=>({key:te.key,label:`${te.label} ${z.get(te.key)}`}))]},[N,_.rows,C,g]),ye=h.useMemo(()=>{if(!N||!_.rows.some(fe=>fe.volumes.length>0))return null;const z=[],re=_.rows.filter(fe=>fe.volumes.length>0).map(fe=>({k:W(fe.id)??"",from:Math.min(...fe.volumes),to:Math.max(...fe.volumes)})).sort((fe,Me)=>fe.from-Me.from);for(const fe of re){const Me=fe.to-fe.from+1,P=z[z.length-1];P&&P.key===fe.k?(P.to=Math.max(P.to,fe.to),P.n+=Me):z.push({key:fe.k,from:fe.from,to:fe.to,n:Me})}const te=re.reduce((fe,Me)=>Math.max(fe,Me.to),0);return z.length>1&&z.some(fe=>fe.key)?{segs:z,last:te}:null},[N,_.rows,C]),je=(Qe=e.description)==null?void 0:Qe.text,Ue=t.jsx(bi,{kind:p("collectionPage.kind"),title:m(e.title),byline:t.jsx(Is,{authors:e.authors,onNavigate:o,renderLink:s}),meta:t.jsx(vt,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(gt=e.publication_info)!=null&>.year?m(e.publication_info.year):""]}),description:je||(lt=e.history)!=null&<.length?t.jsxs(t.Fragment,{children:[je&&t.jsx(an,{text:je,style:{fontSize:15,lineHeight:1.85}}),(tt=e.history)!=null&&tt.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((z,re)=>t.jsx("li",{children:m(z)},re))}):null]}):void 0,clampDescription:os(je)||(((Oe=e.history)==null?void 0:Oe.length)??0)>2?6:void 0,stats:le,facts:M,foot:t.jsx(yi,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:ye&&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:ye.segs.map((z,re)=>{const te=mi.find(fe=>fe.key===z.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!te,title:te?p("collectionPage.dist.segTitle",{section:m(te.label),from:z.from,to:z.to}):void 0,"aria-label":te?p("collectionPage.dist.only",{section:m(te.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!te&&b===z.key,style:{flexGrow:z.n,background:r(te?te.token:"rule")},onClick:()=>{te&&(v(b===z.key?"":z.key),j(!1))}},re)})}),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:ye.last})})]})]})}),H=[];_.rows.length&&H.push({id:"titles",label:p("collectionPage.sec.titles"),count:Le}),de&&H.push({id:"resources",label:p("collectionPage.sec.resources"),count:de}),U&&H.push({id:"works",label:g.section.containedWorks,count:q.length});const me=t.jsxs(t.Fragment,{children:[_.rows.length>0&&t.jsxs(St,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(vt,{items:[`${Le} ${g.unit.items}`,_.totalVolumes?p("collectionPage.totalVolumes",{n:_.totalVolumes,unit:g.unit.volume}):"",F.length!==Le?p("collectionPage.currentN",{n:F.length,unit:g.unit.items}):""]}),action:a,children:[(_.rows.length>si||J.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[J.length>0&&t.jsx(gr,{items:J,value:b,onChange:z=>{v(z),j(!1)}}),E&&_.rows.length>si&&!N&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:w,onClick:()=>k(!0),title:p("collectionPage.loadAllTitle",{n:_.rows.length,unit:g.unit.items}),children:p(w?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),_.rows.length>si&&t.jsx("input",{type:"search",className:"bim-d-find",value:u,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:z=>{f(z.target.value),j(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&hr(F.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[pe&&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:R.map((z,re)=>{var Te;const te=z.id?C.get(z.id):void 0,fe=te!=null&&te.title&&z.title===z.id?te.title:z.title,Me=((te==null?void 0:te.authors)||[]).find(Se=>Se&&Se.name),P=[Me?`${Me.dynasty?`〔${m(Me.dynasty)}〕`:""}${m(Me.name)}${Me.role?` ${m(Me.role)}`:""}`:"",te!=null&&te.measure?m(te.measure):"",(Te=z.subItems)!=null&&Te.length?z.subItems.map(Se=>m(Se)).join("、"):"",(te!=null&&te.edition||z.edition)&&!se?m((te==null?void 0:te.edition)||z.edition||""):""].filter(Boolean),ce=mi.find(Se=>Se.key===W(z.id)),X=z.volumes.length>0?p("collectionPage.volumeRange",{range:cr(z.volumes,g.unit.volume),unit:g.unit.volume}):z.expected!=null?`${z.found??0}/${z.expected} ${g.unit.volume}`:"";return t.jsxs("tr",{children:[pe&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${X?"":" bim-d-zt-blank"}`,children:[ce&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:r(ce.token)}}),X||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[z.id?t.jsx(jt,{id:z.id,label:m(fe),onNavigate:o,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:m(fe)}),P.length>0?t.jsx(vt,{items:P}):z.id&&!te&&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${te!=null&&te.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:te!=null&&te.versionCount?p("collectionPage.nZhong",{n:te.versionCount}):""})]},`${z.id??z.title}-${re}`)})})]}),R.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!x&&t.jsx(is,{total:F.length,shown:R.length,unit:g.unit.items,onClick:()=>j(!0)})]}),de>0&&t.jsxs(St,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:de}),children:[ie.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[ie.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:ie.text.map((z,re)=>t.jsx(Ls,{item:z,siblings:ie.text},`${z.id||z.url||z.name}-${re}`))})})]}),t.jsx(Np,{groups:ie.groups})]}),_.rows.length===0&&de===0&&t.jsx(St,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),ge=U?t.jsx(vn,{id:"works",title:g.section.containedWorks,meta:p("collectionPage.nZhong",{n:q.length}),cap:12,items:q.map(z=>t.jsx(jt,{id:z.id,label:m(z.title),onNavigate:o,renderLink:s,dense:!0}))}):null,ne=y?t.jsx(hd,{caption:p("collectionPage.parent"),children:t.jsx(jt,{id:y.id,label:m(y.title||y.id),onNavigate:o,renderLink:s,dense:!0})}):void 0;return t.jsx(xi,{railTop:l,back:d,up:ne,nav:H,railLinks:c,main:me,card:Ue,side:ge})},Q0=8;function Mp(e){return typeof e!="string"||!e||e.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.split("/").some(n=>n==="..")?null:e}function e1(e){return(e||[]).filter(n=>{var i,o;return Mp(n==null?void 0:n.file)&&((i=n.credit)==null?void 0:i.trim())&&((o=n.license)==null?void 0:o.trim())}).slice(0,Q0)}function t1({images:e,assetBase:n,name:i}){const{t:o,convert:s}=oe(),[a,l]=h.useState(0),[d,c]=h.useState(!1),p=n?e1(e):[];if(!n||d||p.length===0)return null;const m=n.endsWith("/")?n:n+"/",g=p[Math.min(a,p.length-1)],u=g.width&&g.height&&g.width>0&&g.height>0?`${g.width} / ${g.height}`:void 0,f=x=>m+Mp(x.file).split("/").map(encodeURIComponent).join("/");return t.jsxs("figure",{className:"bim-d-seal bim-d-ui",children:[t.jsx("img",{className:"bim-d-seal-main",src:f(g),alt:o("entityPage.sealAlt",{name:i})+(p.length>1?` ${a+1}`:""),style:u?{"--seal-ar":u}:void 0,width:g.width,height:g.height,decoding:"async",fetchPriority:"high",onError:()=>c(!0)},g.file),p.length>1&&t.jsx("div",{className:"bim-d-seal-thumbs",children:p.map((x,j)=>t.jsx("button",{type:"button","aria-pressed":j===a,"aria-label":`${o("entityPage.sealAlt",{name:i})} ${j+1}`,onClick:()=>l(j),children:t.jsx("img",{src:f(x),alt:"",loading:"lazy",decoding:"async"})},x.file))}),t.jsxs("figcaption",{children:[o("entityPage.imgCredit",{credit:s(g.credit)})," · ",o("entityPage.imgLicense",{license:s(g.license)}),g.source_url&&/^https?:\/\//i.test(g.source_url)&&t.jsxs(t.Fragment,{children:[" · ",t.jsx("a",{href:g.source_url,target:"_blank",rel:"noopener noreferrer nofollow",children:o("entityPage.imgSource")})]}),g.note&&t.jsxs(t.Fragment,{children:[" · ",s(g.note)]})]})]})}const ql=8,Xl=10,Zl=30,Ap=(e,n,i)=>`/read/${e}${n&&n!=="default"?`/${n}`:""}/${i}`;function n1(e){return`${Ap(e.item,e.key,e.chapter)}#${e.start}~${e.end}`}function i1(e,n,i){var o;return`${Ap(n,i.key,i.chapter)}#e=${((o=i.ids)!=null&&o.length?i.ids:[e]).join(",")}`}const r1=({id:e,transport:n,renderLink:i,onTotal:o})=>{const{t:s,convert:a}=oe(),[l,d]=h.useState(null),[c,p]=h.useState("idle"),[m,g]=h.useState(ql),[u,f]=h.useState(Xl),x=h.useRef(null),j=!!(n!=null&&n.getMentions),y=h.useRef(o);if(y.current=o,h.useEffect(()=>{if(d(null),p("idle"),g(ql),f(Xl),!j)return;const k=x.current;let _=!1;const $=()=>{p("loading"),n.getMentions(e).then(L=>{var T,N;if(_)return;const E=L&&"books"in L?L:null;if(!E||!E.total){p("none"),(T=y.current)==null||T.call(y,0);return}d(E),p("ok"),(N=y.current)==null||N.call(y,E.total)}).catch(()=>{_||p("none")})};if(!k||typeof IntersectionObserver>"u")return $(),()=>{_=!0};const C=new IntersectionObserver(L=>{L.some(E=>E.isIntersecting)&&(C.disconnect(),$())},{rootMargin:"400px"});return C.observe(k),()=>{_=!0,C.disconnect()}},[e,j,n]),c==="none"||!j)return t.jsx("div",{ref:x});const S=(k,_,$)=>i?i(k,_,$):t.jsx("a",{className:$,href:k,children:_}),b=new Map(((l==null?void 0:l.books)??[]).map(k=>[k.item,k.title])),v=(l==null?void 0:l.examples)??[],w=(l==null?void 0:l.books)??[];return t.jsx("div",{ref:x,children:t.jsxs(St,{id:"mentions",title:s("mentions.title"),meta:l?t.jsx(vt,{items:[s("mentions.total",{n:l.total,b:w.length})]}):void 0,children:[!l&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:s("mentions.loading")}),l&&t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:s("mentions.hint")}),l&&v.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"bim-d-mentions-h bim-d-ui",children:s("mentions.examples")}),t.jsx("ol",{className:"bim-d-mentions",children:v.slice(0,m).map((k,_)=>{const $=[b.get(k.item),k.heading].filter(Boolean).map(L=>a(L)).join(" · "),C=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-d-mention-where bim-d-ui",children:$||k.chapter}),t.jsxs("span",{className:"bim-d-mention-ctx",children:[k.before?"…":"",a(k.before),t.jsx("b",{children:a(k.text)}),a(k.after),k.after?"…":""]})]});return t.jsx("li",{children:S(n1(k),C,"bim-d-mention")},`${k.item}|${k.key}|${k.chapter}|${k.start}|${_}`)})}),v.length>m&&t.jsx("button",{type:"button",className:"bim-d-tab bim-d-ui",onClick:()=>g(v.length),children:s("mentions.more",{n:v.length-m})})]}),l&&w.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:"bim-d-mentions-h bim-d-ui",children:s("mentions.byBook")}),t.jsx("ul",{className:"bim-d-mbooks",children:w.slice(0,u).map(k=>t.jsx(o1,{entityId:e,book:k,open:w.length===1,transport:n,link:S},k.item))}),w.length>u&&t.jsx("button",{type:"button",className:"bim-d-tab bim-d-ui",onClick:()=>f(k=>k+Zl),children:s("mentions.moreBooks",{n:Math.min(Zl,w.length-u)})})]})]})})},o1=({entityId:e,book:n,open:i,transport:o,link:s})=>{const{t:a,convert:l}=oe(),[d,c]=h.useState(n.chapters??null),[p,m]=h.useState(!1);h.useEffect(()=>{c(n.chapters??null)},[n]);const g=u=>{!u.currentTarget.open||d||p||!(o!=null&&o.getMentions)||(m(!0),o.getMentions(e,n.item).then(f=>{f&&"chapters"in f&&Array.isArray(f.chapters)&&c(f.chapters)}).catch(()=>{}).finally(()=>m(!1)))};return t.jsx("li",{children:t.jsxs("details",{className:"bim-d-mbook",open:i,onToggle:g,children:[t.jsxs("summary",{children:[t.jsx("span",{className:"bim-d-mbook-t",children:l(n.title??n.item)}),t.jsx("span",{className:"bim-d-mbook-n bim-d-ui",children:a("mentions.bookLine",{n:n.count,c:n.chapter_count})})]}),p&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"0 0 8px 40px"},children:a("mentions.loading")}),d&&t.jsx("ul",{className:"bim-d-mchaps",children:d.map(u=>t.jsx("li",{children:s(i1(e,n.item,u),t.jsxs(t.Fragment,{children:[t.jsx("span",{children:u.heading?`${u.chapter} · ${l(u.heading)}`:u.chapter}),t.jsx("span",{className:"bim-d-ui",children:a("mentions.chapterLine",{n:u.count})})]}),"bim-d-mchap")},`${u.key}|${u.chapter}`))})]})})},s1=16,ro=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function Jl(e){if(!e)return ro.length;const n=ro.indexOf(e);return n===-1?ro.length:n}function a1(e,n,i){if(n)return e[n]??i(n)}function l1(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const c1={秦:[-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]},Pp=({data:e,transport:n,onNavigate:i,renderLink:o,railTop:s,back:a,railLinks:l,assetBase:d})=>{var Ie,Qe,gt,lt,tt,Oe;const{t:c,convert:p,messages:m}=oe(),g=z=>l1(z,c),[u,f]=h.useState("全部"),[x,j]=h.useState(!1),[y,S]=h.useState("default"),[b,v]=h.useState(new Map),[w,k]=h.useState(0),_=h.useMemo(()=>e._works||[],[e._works]),$=h.useMemo(()=>_.map(z=>{const re=b.get(z.work_id);return{id:z.work_id,title:(re==null?void 0:re.title)??z.title??z.work_id,role:z.role||"",cls:Go(z.role),versionCount:re==null?void 0:re.versionCount,section:re==null?void 0:re.cls,l1:re==null?void 0:re.l1,measure:re==null?void 0:re.measure,hasImage:re==null?void 0:re.hasImage,loaded:!!(re!=null&&re.loaded)}}),[_,b]),C=h.useMemo(()=>zc(_.map(z=>z.role),c("detail.roleAll")),[_,c]),L=h.useMemo(()=>{const z=u==="全部"?$:$.filter(re=>re.cls===u);return y==="versions"?[...z].sort((re,te)=>(te.versionCount??-1)-(re.versionCount??-1)):z},[$,u,y]),E=x?L:L.slice(0,s1),T=h.useMemo(()=>E.filter(z=>!b.has(z.id)).map(z=>z.id),[E,b]);h.useEffect(()=>{if(!n||T.length===0)return;let z=!1;return yr(T,br,re=>n.getItem(re).then(te=>{var X;const fe=te??{},Me=fe._edition_count??((X=fe._books)==null?void 0:X.length)??0,P=qo(fe),ce=[P==null?void 0:P.l1,P==null?void 0:P.l2].filter(Boolean).join(" ");return[re,{id:re,title:fe.title,versionCount:Me,loaded:!0,cls:ce||void 0,l1:(P==null?void 0:P.l1)||void 0,measure:te&&sn(te,m.unit.juan)||void 0,hasImage:!!fe._has_image}]}).catch(()=>[re,{id:re,loaded:!0}]),()=>z).then(re=>{z||v(te=>{const fe=new Map(te);for(const[Me,P]of re)fe.set(Me,P);return fe})}),()=>{z=!0}},[n,T,m.unit.juan]);const N=h.useMemo(()=>{const z=new Map;for(const re of e.alt_names||[]){const te=re.type||m.section.aliases;z.has(te)||z.set(te,[]),z.get(te).push(re.name)}return[...z.entries()].sort((re,te)=>Jl(re[0])-Jl(te[0])).map(([re,te])=>({label:re,names:te}))},[e.alt_names,m]),W=((Ie=e.dates)==null?void 0:Ie.birth)??void 0,F=((Qe=e.dates)==null?void 0:Qe.death)??void 0,R=(gt=e.dates)==null?void 0:gt.floruit,G=W!=null||F!=null?`${g(W)||"?"}—${g(F)||"?"}`:Array.isArray(R)&&R.length===2&&R.every(z=>Number.isFinite(z))?c("entityPage.floruit",{from:g(R[0]),to:g(R[1])}):"",Q=new Set(["本名","字","號","号"]),ie=N.filter(z=>Q.has(z.label)),de=N.filter(z=>!Q.has(z.label)),q=de.reduce((z,re)=>z+re.names.length,0),ee=h.useMemo(()=>{const z=[];for(const te of ie)z.push({label:te.label,value:te.names.map(fe=>p(fe)).join("、")});const re=_.length;return re&&z.push({label:c("entityPage.fact.works"),value:c("entityPage.nZhong",{n:re})}),z},[_,ie,p,c]),U=z=>{var re;return(re=N.find(te=>z.includes(te.label)))==null?void 0:re.names[0]},se=U(["字"]),pe=U(["號","号"]),_e=[se?c("entityPage.zi",{name:p(se)}):"",pe?c("entityPage.hao",{name:p(pe)}):""].filter(Boolean).join(","),Le=e.native_place,Ee=e.dynasty?c1[e.dynasty]:void 0,ue=(()=>{if(!Ee||W==null||F==null||F<W)return null;const[z,re]=Ee,te=Math.max(W,z),fe=Math.min(F,re);if(fe<=te)return null;const Me=re-z;return t.jsxs("div",{className:"bim-d-life bim-d-ui",children:[t.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":c("entityPage.lifeAria",{birth:g(W),death:g(F),years:F-W+1}),children:t.jsx("i",{style:{left:`${(te-z)/Me*100}%`,width:`${(fe-te)/Me*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${g(z)} ${p(e.dynasty)}`}),t.jsx("span",{children:c("entityPage.lifeYears",{years:F-W+1})}),t.jsx("span",{children:g(re)})]})]})})(),be=h.useMemo(()=>{if(!n||$.length===0||$.some(te=>!te.loaded))return null;const z=new Map;for(const te of $){const fe=Ro(te.l1);fe&&z.set(fe,(z.get(fe)??0)+1)}const re=mi.map(te=>({...te,n:z.get(te.key)??0})).filter(te=>te.n>0);return re.length?re:null},[$,n]),A=t.jsxs(bi,{kind:a1(m.entityPage.subtype,e.subtype,p),title:p(e.primary_name||e.title),subtitle:_e||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(vt,{items:[e.dynasty?p(e.dynasty):"",G,Le?c("entityPage.nativePlace",{place:p(Le)}):""]}),ue,t.jsx(t1,{images:e.images,assetBase:d,name:p(e.primary_name||e.title)})]}),description:(lt=e.description)!=null&<.text?t.jsx(an,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:os((tt=e.description)==null?void 0:tt.text)?6:void 0,facts:ee,foot:t.jsx(yi,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[q>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:c("entityPage.moreNames",{n:q})}),t.jsx("dl",{children:de.map(z=>t.jsxs(h.Fragment,{children:[t.jsx("dt",{children:p(z.label)}),t.jsx("dd",{children:z.names.map(re=>p(re)).join("、")})]},z.label))})]}),be&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:c("entityPage.dist")})}),t.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:be.map(z=>t.jsx("i",{style:{flexGrow:z.n,background:r(z.token)}},z.key))}),t.jsx("div",{className:"bim-d-dist-key",children:be.map(z=>t.jsxs("span",{children:[t.jsx("i",{style:{background:r(z.token)}}),p(z.label)," ",z.n]},z.key))})]})]}),K=h.useMemo(()=>$.filter(z=>z.loaded&&(z.versionCount??0)>0).sort((z,re)=>(re.versionCount??0)-(z.versionCount??0)).slice(0,3),[$]),le=!!n&&$.length>=3&&E.some(z=>!z.loaded),M=u==="全部"&&(le||K.length>=2),J=e.external_ids||{},ye=((Oe=e.external_ids_meta)==null?void 0:Oe.cbdb_match)??J.cbdb_match,je=[];J.cbdb_id!=null&&je.push({label:"CBDB",id:String(J.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${J.cbdb_id}`,note:ye==="auto"?c("entityPage.autoMatch"):void 0});const Ue=J.wikidata_id;Ue&&je.push({label:"Wikidata",id:Ue,href:`https://www.wikidata.org/wiki/${Ue}`});const H=J.viaf_id;H&&je.push({label:"VIAF",id:H,href:`https://viaf.org/viaf/${H}`});const me=C.map(z=>({key:z.cls,label:`${z.label} ${z.count}`})),ge=e.id?t.jsx(r1,{id:e.id,transport:n,onTotal:k}):null,ne=[...M&&!le?[{id:"featured",label:c("entityPage.sec.featured"),count:K.length}]:[],...$.length?[{id:"works",label:c("entityPage.sec.allWorks"),count:$.length}]:[],...w?[{id:"mentions",label:c("mentions.title"),count:w}]:[],...je.length?[{id:"external",label:c("entityPage.sec.external"),count:je.length}]:[]],Ne=M?t.jsxs(St,{id:"featured",title:c("entityPage.sec.featured"),children:[t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:c("entityPage.featuredSub")}),t.jsxs("div",{className:"bim-d-picks","aria-busy":le||void 0,children:[le&&[0,1,2].map(z=>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:" "})]},z)),!le&&K.map(z=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(jt,{id:z.id,label:p(z.title),onNavigate:i,renderLink:o,dense:!0})}),t.jsx(vt,{items:[z.section?p(z.section):"",z.measure?p(z.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:z.versionCount}),t.jsx("span",{children:c("entityPage.versionsUnit")}),z.hasImage&&t.jsx("span",{className:"bim-d-flag",children:c("entityPage.hasImage")})]})]},z.id))]})]}):null,he=$.length===0?t.jsxs(t.Fragment,{children:[t.jsx(St,{title:c("entityPage.sec.works"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("entityPage.empty")})}),ge]}):t.jsxs(t.Fragment,{children:[Ne,t.jsxs(St,{id:"works",title:c("entityPage.sec.works"),meta:t.jsx(vt,{items:[c("entityPage.total",{n:$.length}),L.length!==$.length?c("entityPage.current",{n:L.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[me.length>1&&t.jsx(gr,{items:me,value:u,onChange:z=>{f(z),j(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":y==="versions",onClick:()=>{y==="default"&&j(!0),S(z=>z==="default"?"versions":"default")},children:c(y==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&hr(L.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:c("entityPage.col.work")}),t.jsx("th",{children:c("entityPage.col.section")}),t.jsx("th",{children:c("entityPage.col.role")}),t.jsx("th",{children:c("entityPage.col.versions")}),t.jsx("th",{"aria-label":c("entityPage.col.image")})]})}),t.jsx("tbody",{children:E.map(z=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(jt,{id:z.id,label:p(z.title),onNavigate:i,renderLink:o,dense:!0}),z.measure?t.jsx(vt,{items:[p(z.measure)]}):!z.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${z.section||z.loaded?"":" bim-d-zt-blank"}`,children:z.section?p(z.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${z.role?"":" bim-d-zt-blank"}`,children:z.role?p(z.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${z.loaded?"":" bim-d-zt-blank"}`,children:z.loaded?z.versionCount?c("entityPage.nZhong",{n:z.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:c("entityPage.notRecorded")}):""}),t.jsx("td",{className:z.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:z.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:c("entityPage.hasImage")})})]},z.id))})]}),E.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c("entityPage.emptyRole")}),!x&&t.jsx(is,{total:L.length,shown:E.length,unit:c("entityPage.moreUnit"),onClick:()=>j(!0)})]}),ge]}),Ce=je.length>0?t.jsx(vn,{id:"external",title:c("entityPage.sec.external"),items:je.map(z=>t.jsxs("a",{href:z.href,target:"_blank",rel:"noopener noreferrer",children:[z.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:je.map(z=>z.id),foot:J.cbdb_id!=null&&ye==="auto"?c("entityPage.cbdbAuto"):void 0}):null;return t.jsx(xi,{railTop:s,back:a,nav:ne,railLinks:l,main:he,card:A,side:Ce})},As="(max-width: 719px)",d1=`${As}, (pointer: coarse)`,Bp=`
|
|
1525
1525
|
.bim-ct {
|
|
1526
1526
|
display: grid; grid-template-columns: 248px minmax(0, 1fr); column-gap: 32px; align-items: start;
|
|
1527
1527
|
max-width: 1440px; margin: 0 auto; padding: 20px 32px 48px; box-sizing: border-box;
|
|
@@ -1629,7 +1629,7 @@ ${U??""}`,[St,Lt]=f.useState({key:dt,data:ce,started:!!ce});if(St.key!==dt)Lt({k
|
|
|
1629
1629
|
.bim-ct-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1630
1630
|
}
|
|
1631
1631
|
|
|
1632
|
-
@media ${
|
|
1632
|
+
@media ${As} {
|
|
1633
1633
|
.bim-ct { display: block; padding: 12px 16px 40px; }
|
|
1634
1634
|
.bim-ct-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
|
|
1635
1635
|
.bim-ct-lrow > a { grid-template-columns: minmax(0, 1fr); }
|
|
@@ -1654,7 +1654,7 @@ ${U??""}`,[St,Lt]=f.useState({key:dt,data:ce,started:!!ce});if(St.key!==dt)Lt({k
|
|
|
1654
1654
|
}
|
|
1655
1655
|
|
|
1656
1656
|
/* 点击目标 ≥44px(Q5):触屏与窄屏 */
|
|
1657
|
-
@media ${
|
|
1657
|
+
@media ${d1} {
|
|
1658
1658
|
.bim-ct-row { min-height: 44px; }
|
|
1659
1659
|
.bim-ct-tw { width: 44px; }
|
|
1660
1660
|
.bim-ct-pg { min-width: 44px; height: 44px; }
|
|
@@ -1680,7 +1680,7 @@ ${U??""}`,[St,Lt]=f.useState({key:dt,data:ce,started:!!ce});if(St.key!==dt)Lt({k
|
|
|
1680
1680
|
/* 窄屏分类抽屉:界栏下按钮和面板都有框 */
|
|
1681
1681
|
:root[data-layout="boxed"] .bim-ct-drawer-btn { border: ${r("fr-bd")}; background: ${r("fr-bg")}; }
|
|
1682
1682
|
:root[data-layout="boxed"] .bim-ct-drawer { border: ${r("fr-bd")}; }
|
|
1683
|
-
`,jn="未分類",tn="all",Is=20;function bi(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 y1(e){const n=bi(e);return n.length?n.join("/"):jn}function j1(e){const n=bi(e);return n.length?n.map((i,o)=>n.slice(0,o+1).join("/")):[jn]}function v1(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(m=>!!m);p.forEach((m,g)=>{const u=p.slice(0,g+1).join("/");i.has(u)||i.set(u,c)})});const o=new Map;let s=0;for(const d of e){const c=bi(d.classification);if(!c.length){s++;continue}let p=o;c.forEach((m,g)=>{const u=c.slice(0,g+1).join("/");let h=p.get(m);h||(h={id:u,label:m,count:0,children:new Map},p.set(m,h)),h.count++,p=h.children})}const a=d=>[...d.values()].sort((c,p)=>{const m=c.label===jn?1:0,g=p.label===jn?1:0;if(m!==g)return m-g;const u=i.get(c.id)??1/0,h=i.get(p.id)??1/0;return u!==h?u-h: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:jn,label:jn,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 Ls(e){return e.reduce((n,i)=>n+i.count,0)}function k1(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function w1(e){var d,c,p;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)??((c=(d=e.measures)==null?void 0:d.find(m=>(m==null?void 0:m.unit)==="卷"&&typeof m.number=="number"))==null?void 0:c.number);typeof o=="number"&&o>0?n.juan=o:e.measure_info&&(n.juan=e.measure_info);const s=(e.authors??[]).filter(m=>m==null?void 0:m.name).map(m=>{const g=m.dynasty||(e.authors.length===1?e.dynasty:void 0);return g?{name:m.name,dynasty:g}:{name:m.name}});s.length&&(n.authors=s);const a=k1(typeof e.description=="string"?e.description:(p=e.description)==null?void 0:p.text);a&&(n.summary=a);const l=bi(e.classification);return l.length&&(n.classification=l),n}function S1(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 _1(e,n=Is){return Math.max(1,Math.ceil(e/n))}function Lp(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 $1=()=>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 C1(e,n,i){const o=[];i&&o.push({id:tn,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 Ap({tree:e,selectedId:n,onSelect:i,allLabel:o,label:s}){const{t:a,convert:l}=ae(),d=o===void 0?a("catalogPage.all"):o,c=s??a("catalogPage.classification"),p=f.useRef(null),m=n&&n!==tn?n:null,g=d!==null,[u,h]=f.useState(()=>{const C=new Set;for(const I of Pn(e,m))C.add(I.id);return C});f.useEffect(()=>{const C=Pn(e,m);C.length&&h(I=>{if(C.every(T=>I.has(T.id)))return I;const E=new Set(I);for(const T of C)E.add(T.id);return E})},[e,m]);const x=f.useMemo(()=>C1(e,u,g),[e,u,g]),[j,y]=f.useState(null);f.useEffect(()=>{y(null)},[n]);const S=m??(g?tn:null),b=f.useMemo(()=>{var E;const C=new Set(x.map(T=>T.id));if(j&&C.has(j))return j;if(S&&C.has(S))return S;const I=Pn(e,m).map(T=>T.id).filter(T=>C.has(T));return I.length?I[I.length-1]:((E=x[0])==null?void 0:E.id)??null},[x,j,S,e,m]),k=f.useCallback((C,I)=>{h(E=>{const T=E.has(C),N=I??!T;if(N===T)return E;const P=new Set(E);return N?P.add(C):P.delete(C),P})},[]),w=f.useCallback(C=>{y(C),requestAnimationFrame(()=>{var E;const I=Array.from(((E=p.current)==null?void 0:E.querySelectorAll("[data-ct-id]"))??[]).find(T=>T.dataset.ctId===C);I==null||I.focus()})},[]),v=f.useCallback((C,I)=>{I&&k(C,!0),i(C)},[i,k]),$=f.useCallback(C=>{const I=C.target.closest("[data-ct-id]");if(!I)return;const E=I.dataset.ctId,T=x.findIndex(W=>W.id===E);if(T<0)return;const N=x[T];let P=null;switch(C.key){case"ArrowDown":P=x[Math.min(x.length-1,T+1)].id;break;case"ArrowUp":P=x[Math.max(0,T-1)].id;break;case"Home":P=x[0].id;break;case"End":P=x[x.length-1].id;break;case"ArrowRight":if(!N.hasChildren)break;u.has(E)?P=N.firstChildId:k(E,!0);break;case"ArrowLeft":N.hasChildren&&u.has(E)?k(E,!1):P=N.parentId;break;case"Enter":case" ":C.preventDefault(),v(E,N.hasChildren);return;default:return}C.preventDefault(),P&&P!==E&&w(P)},[x,u,k,w,v]),_=(C,I)=>C.map((E,T)=>{var K;const N=(K=E.children)!=null&&K.length?E.children:null,P=!!N&&u.has(E.id),W=E.id===m,L=I===1&&C.length>1&&T===C.length-1;return t.jsxs("li",{role:"treeitem","aria-level":I,"aria-expanded":N?P:void 0,"aria-selected":W,tabIndex:b===E.id?0:-1,"data-ct-id":E.id,className:L?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":I-1},onClick:()=>{y(E.id),v(E.id,!!N)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:N?Q=>{Q.stopPropagation(),y(E.id),k(E.id)}:void 0,children:N?t.jsx($1,{}):null}),t.jsx("span",{className:"bim-ct-lb",children:l(E.label)}),t.jsx("span",{className:"bim-ct-n",children:E.count.toLocaleString("en-US")})]}),P&&t.jsx("ul",{role:"group",children:_(N,I+1)})]},E.id)});return t.jsxs("ul",{ref:p,role:"tree","aria-label":l(c),className:"bim-ct-tree",onKeyDown:$,children:[g&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!m,tabIndex:b===tn?0:-1,"data-ct-id":tn,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(tn),i(tn)},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:Ls(e).toLocaleString("en-US")})]})}),_(e,1)]})}const Mp=e=>`/item/${encodeURIComponent(e)}`;function z1(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function Pp(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function Bp({work:e,href:n}){var d,c;const{t:i,convert:o}=ae(),s=Pp(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,m)=>t.jsxs(f.Fragment,{children:[m>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},m))}),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 Op({work:e,href:n}){var d,c;const{t:i,convert:o}=ae(),s=Pp(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,m)=>t.jsxs(f.Fragment,{children:[m>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},m))}),t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function Wp({page:e,pageCount:n,onPage:i,pageHref:o,label:s}){const{t:a,convert:l}=ae();if(n<=1)return null;const d=p=>m=>{i&&(o&&!z1(m)||(m.preventDefault(),i(p)))},c=(p,m,g)=>{if(g.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:m});const u={className:"bim-ct-pg","aria-current":g.current?"page":void 0,"aria-label":g.aria};return o?t.jsx("a",{...u,href:o(p),onClick:d(p),children:m}):t.jsx("button",{type:"button",...u,onClick:g.current?void 0:d(p),children:m})};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:Lp(e,n).map((p,m)=>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${m}`))}),t.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[e," / ",n]}),c(e+1,a("catalogPage.nextPage"),{disabled:e>=n})]})}function Fp({works:e,workLink:n=Mp,emptyText:i,view:o="card",...s}){const{t:a,convert:l}=ae();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(Op,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(Bp,{work:d,href:n(d.id)},d.id))}),t.jsx(Wp,{...s})]})}const N1=()=>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 T1({tree:e,selectedId:n,page:i,pageCount:o,works:s,onSelect:a,onPage:l,searchSlot:d,workLink:c,pageHref:p,allLabel:m,allTitle:g,pageSize:u=Is,className:h,view:x,onViewChange:j}){const{t:y,convert:S}=ae(),b=m===void 0?y("catalogPage.all"):m,k=g??y("catalogPage.allTitle"),v=`bim-ct-drawer-${f.useId().replace(/:/g,"")}`,[$,_]=f.useState(!1),[C,I]=f.useState("card"),E=x??C,T=Q=>{I(Q),j==null||j(Q)},N=Pn(e,n&&n!==tn?n:null),P=N.length?N[N.length-1]:null,W=P?P.label:k,L=P?P.count:Ls(e),K=f.useCallback(Q=>{_(!1),a(Q)},[a]);return t.jsxs("div",{className:h?`bim-ct ${h}`:"bim-ct","data-drawer":$?"open":"closed",children:[t.jsx("style",{children:Ip}),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":v,onClick:()=>_(Q=>!Q),children:[t.jsx("span",{children:y("catalogPage.drawerLabel",{path:S(N.length?N.map(Q=>Q.label).join(" › "):b??k)})}),t.jsx(N1,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:v,children:[t.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),t.jsx(Ap,{tree:e,selectedId:n,onSelect:K,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(W)}),N.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:S(N.slice(0,-1).map(Q=>Q.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:L.toLocaleString("en-US"),size:u}),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":E==="card",onClick:()=>T("card"),children:y("catalogPage.viewCard")}),t.jsx("button",{type:"button","aria-pressed":E==="list",onClick:()=>T("list"),children:y("catalogPage.viewList")})]})]}),d&&t.jsx("div",{className:"bim-ct-search",children:d}),t.jsx(Fp,{works:s,view:E,workLink:c,page:i,pageCount:o,onPage:l,pageHref:p})]})]})}const yi="(max-width: 719px)",E1="(max-width: 1079px)",R1=`${yi}, (pointer: coarse)`,I1=[8,18,30,42,88],As=`
|
|
1683
|
+
`,jn="未分類",nn="all",Ps=20;function vi(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 p1(e){const n=vi(e);return n.length?n.join("/"):jn}function u1(e){const n=vi(e);return n.length?n.map((i,o)=>n.slice(0,o+1).join("/")):[jn]}function m1(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(m=>!!m);p.forEach((m,g)=>{const u=p.slice(0,g+1).join("/");i.has(u)||i.set(u,c)})});const o=new Map;let s=0;for(const d of e){const c=vi(d.classification);if(!c.length){s++;continue}let p=o;c.forEach((m,g)=>{const u=c.slice(0,g+1).join("/");let f=p.get(m);f||(f={id:u,label:m,count:0,children:new Map},p.set(m,f)),f.count++,p=f.children})}const a=d=>[...d.values()].sort((c,p)=>{const m=c.label===jn?1:0,g=p.label===jn?1:0;if(m!==g)return m-g;const u=i.get(c.id)??1/0,f=i.get(p.id)??1/0;return u!==f?u-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:jn,label:jn,count:s}),l}function Bn(e,n){if(!n)return[];for(const i of e){if(i.id===n)return[i];if(i.children){const o=Bn(i.children,n);if(o.length)return[i,...o]}}return[]}function Bs(e){return e.reduce((n,i)=>n+i.count,0)}function g1(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function h1(e){var d,c,p;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)??((c=(d=e.measures)==null?void 0:d.find(m=>(m==null?void 0:m.unit)==="卷"&&typeof m.number=="number"))==null?void 0:c.number);typeof o=="number"&&o>0?n.juan=o:e.measure_info&&(n.juan=e.measure_info);const s=(e.authors??[]).filter(m=>m==null?void 0:m.name).map(m=>{const g=m.dynasty||(e.authors.length===1?e.dynasty:void 0);return g?{name:m.name,dynasty:g}:{name:m.name}});s.length&&(n.authors=s);const a=g1(typeof e.description=="string"?e.description:(p=e.description)==null?void 0:p.text);a&&(n.summary=a);const l=vi(e.classification);return l.length&&(n.classification=l),n}function f1(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 x1(e,n=Ps){return Math.max(1,Math.ceil(e/n))}function Op(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 b1=()=>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 y1(e,n,i){const o=[];i&&o.push({id:nn,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 Wp({tree:e,selectedId:n,onSelect:i,allLabel:o,label:s}){const{t:a,convert:l}=oe(),d=o===void 0?a("catalogPage.all"):o,c=s??a("catalogPage.classification"),p=h.useRef(null),m=n&&n!==nn?n:null,g=d!==null,[u,f]=h.useState(()=>{const C=new Set;for(const L of Bn(e,m))C.add(L.id);return C});h.useEffect(()=>{const C=Bn(e,m);C.length&&f(L=>{if(C.every(T=>L.has(T.id)))return L;const E=new Set(L);for(const T of C)E.add(T.id);return E})},[e,m]);const x=h.useMemo(()=>y1(e,u,g),[e,u,g]),[j,y]=h.useState(null);h.useEffect(()=>{y(null)},[n]);const S=m??(g?nn:null),b=h.useMemo(()=>{var E;const C=new Set(x.map(T=>T.id));if(j&&C.has(j))return j;if(S&&C.has(S))return S;const L=Bn(e,m).map(T=>T.id).filter(T=>C.has(T));return L.length?L[L.length-1]:((E=x[0])==null?void 0:E.id)??null},[x,j,S,e,m]),v=h.useCallback((C,L)=>{f(E=>{const T=E.has(C),N=L??!T;if(N===T)return E;const W=new Set(E);return N?W.add(C):W.delete(C),W})},[]),w=h.useCallback(C=>{y(C),requestAnimationFrame(()=>{var E;const L=Array.from(((E=p.current)==null?void 0:E.querySelectorAll("[data-ct-id]"))??[]).find(T=>T.dataset.ctId===C);L==null||L.focus()})},[]),k=h.useCallback((C,L)=>{L&&v(C,!0),i(C)},[i,v]),_=h.useCallback(C=>{const L=C.target.closest("[data-ct-id]");if(!L)return;const E=L.dataset.ctId,T=x.findIndex(F=>F.id===E);if(T<0)return;const N=x[T];let W=null;switch(C.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(!N.hasChildren)break;u.has(E)?W=N.firstChildId:v(E,!0);break;case"ArrowLeft":N.hasChildren&&u.has(E)?v(E,!1):W=N.parentId;break;case"Enter":case" ":C.preventDefault(),k(E,N.hasChildren);return;default:return}C.preventDefault(),W&&W!==E&&w(W)},[x,u,v,w,k]),$=(C,L)=>C.map((E,T)=>{var G;const N=(G=E.children)!=null&&G.length?E.children:null,W=!!N&&u.has(E.id),F=E.id===m,R=L===1&&C.length>1&&T===C.length-1;return t.jsxs("li",{role:"treeitem","aria-level":L,"aria-expanded":N?W:void 0,"aria-selected":F,tabIndex:b===E.id?0:-1,"data-ct-id":E.id,className:R?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":L-1},onClick:()=>{y(E.id),k(E.id,!!N)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:N?Q=>{Q.stopPropagation(),y(E.id),v(E.id)}:void 0,children:N?t.jsx(b1,{}):null}),t.jsx("span",{className:"bim-ct-lb",children:l(E.label)}),t.jsx("span",{className:"bim-ct-n",children:E.count.toLocaleString("en-US")})]}),W&&t.jsx("ul",{role:"group",children:$(N,L+1)})]},E.id)});return t.jsxs("ul",{ref:p,role:"tree","aria-label":l(c),className:"bim-ct-tree",onKeyDown:_,children:[g&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!m,tabIndex:b===nn?0:-1,"data-ct-id":nn,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(nn),i(nn)},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:Bs(e).toLocaleString("en-US")})]})}),$(e,1)]})}const Fp=e=>`/item/${encodeURIComponent(e)}`;function j1(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function Hp(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function Dp({work:e,href:n}){var d,c;const{t:i,convert:o}=oe(),s=Hp(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,m)=>t.jsxs(h.Fragment,{children:[m>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},m))}),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 Up({work:e,href:n}){var d,c;const{t:i,convert:o}=oe(),s=Hp(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,m)=>t.jsxs(h.Fragment,{children:[m>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},m))}),t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function Vp({page:e,pageCount:n,onPage:i,pageHref:o,label:s}){const{t:a,convert:l}=oe();if(n<=1)return null;const d=p=>m=>{i&&(o&&!j1(m)||(m.preventDefault(),i(p)))},c=(p,m,g)=>{if(g.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:m});const u={className:"bim-ct-pg","aria-current":g.current?"page":void 0,"aria-label":g.aria};return o?t.jsx("a",{...u,href:o(p),onClick:d(p),children:m}):t.jsx("button",{type:"button",...u,onClick:g.current?void 0:d(p),children:m})};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:Op(e,n).map((p,m)=>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${m}`))}),t.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[e," / ",n]}),c(e+1,a("catalogPage.nextPage"),{disabled:e>=n})]})}function Gp({works:e,workLink:n=Fp,emptyText:i,view:o="card",...s}){const{t:a,convert:l}=oe();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(Up,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(Dp,{work:d,href:n(d.id)},d.id))}),t.jsx(Vp,{...s})]})}const v1=()=>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 k1({tree:e,selectedId:n,page:i,pageCount:o,works:s,onSelect:a,onPage:l,searchSlot:d,workLink:c,pageHref:p,allLabel:m,allTitle:g,pageSize:u=Ps,className:f,view:x,onViewChange:j}){const{t:y,convert:S}=oe(),b=m===void 0?y("catalogPage.all"):m,v=g??y("catalogPage.allTitle"),k=`bim-ct-drawer-${h.useId().replace(/:/g,"")}`,[_,$]=h.useState(!1),[C,L]=h.useState("card"),E=x??C,T=Q=>{L(Q),j==null||j(Q)},N=Bn(e,n&&n!==nn?n:null),W=N.length?N[N.length-1]:null,F=W?W.label:v,R=W?W.count:Bs(e),G=h.useCallback(Q=>{$(!1),a(Q)},[a]);return t.jsxs("div",{className:f?`bim-ct ${f}`:"bim-ct","data-drawer":_?"open":"closed",children:[t.jsx("style",{children:Bp}),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:()=>$(Q=>!Q),children:[t.jsx("span",{children:y("catalogPage.drawerLabel",{path:S(N.length?N.map(Q=>Q.label).join(" › "):b??v)})}),t.jsx(v1,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:k,children:[t.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),t.jsx(Wp,{tree:e,selectedId:n,onSelect:G,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(F)}),N.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:S(N.slice(0,-1).map(Q=>Q.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:R.toLocaleString("en-US"),size:u}),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":E==="card",onClick:()=>T("card"),children:y("catalogPage.viewCard")}),t.jsx("button",{type:"button","aria-pressed":E==="list",onClick:()=>T("list"),children:y("catalogPage.viewList")})]})]}),d&&t.jsx("div",{className:"bim-ct-search",children:d}),t.jsx(Gp,{works:s,view:E,workLink:c,page:i,pageCount:o,onPage:l,pageHref:p})]})]})}const ki="(max-width: 719px)",w1="(max-width: 1079px)",S1=`${ki}, (pointer: coarse)`,$1=[8,18,30,42,88],Os=`
|
|
1684
1684
|
.bim-rh { color: ${r("ink")}; font-family: ${r("font-ui")}; font-size: 14px; line-height: 1.6; }
|
|
1685
1685
|
.bim-rh *, .bim-rh *::before, .bim-rh *::after { box-sizing: border-box; }
|
|
1686
1686
|
.bim-rh a { color: ${r("accent")}; text-decoration: none; }
|
|
@@ -1828,7 +1828,7 @@ ${U??""}`,[St,Lt]=f.useState({key:dt,data:ce,started:!!ce});if(St.key!==dt)Lt({k
|
|
|
1828
1828
|
flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 8px; overflow: hidden;
|
|
1829
1829
|
color: ${r("ink")} !important; font-size: 13px;
|
|
1830
1830
|
}
|
|
1831
|
-
${
|
|
1831
|
+
${$1.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb, ${r("accent")} ${e}%, ${r("card-bg")}); }`).join(`
|
|
1832
1832
|
`)}
|
|
1833
1833
|
.bim-rh-band a[data-k="4"] { color: ${r("page-bg")} !important; }
|
|
1834
1834
|
.bim-rh-band a:hover { outline: 2px solid ${r("ink")}; outline-offset: -2px; }
|
|
@@ -1856,13 +1856,13 @@ ${I1.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1856
1856
|
}
|
|
1857
1857
|
|
|
1858
1858
|
/* ── 中屏 ── */
|
|
1859
|
-
@media ${
|
|
1859
|
+
@media ${w1} {
|
|
1860
1860
|
.bim-rh-picks, .bim-rh-works, .bim-rh-groups, .bim-rh-bu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1861
1861
|
.bim-rh-authors { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
1862
1862
|
}
|
|
1863
1863
|
|
|
1864
1864
|
/* ── 手机 ── */
|
|
1865
|
-
@media ${
|
|
1865
|
+
@media ${ki} {
|
|
1866
1866
|
.bim-rh-main { padding-top: 24px; }
|
|
1867
1867
|
.bim-rh-stats { gap: 4px 18px; }
|
|
1868
1868
|
.bim-rh-stats b { font-size: 16px; }
|
|
@@ -1899,7 +1899,7 @@ ${I1.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1899
1899
|
}
|
|
1900
1900
|
|
|
1901
1901
|
/* 触屏或窄屏:点击目标放大到 44px */
|
|
1902
|
-
@media ${
|
|
1902
|
+
@media ${S1} {
|
|
1903
1903
|
.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; }
|
|
1904
1904
|
.bim-rh-chip { display: inline-flex; }
|
|
1905
1905
|
}
|
|
@@ -1910,7 +1910,7 @@ ${I1.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1910
1910
|
}
|
|
1911
1911
|
|
|
1912
1912
|
@media (prefers-reduced-motion: reduce) { .bim-rh * { scroll-behavior: auto !important; transition: none !important; } }
|
|
1913
|
-
`,L1=Mo["zh-Hant"].period,Hp={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function gn(e){return{...Hp,...e??{}}}function Ms(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 br(e){return(e.authors??[]).filter(i=>i==null?void 0:i.name).map(i=>i.dynasty?`〔${i.dynasty}〕${i.name}`:i.name).join(" ")}function Dp(e,n=Mo["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 Up(e){return Math.max(150,Array.from(e).length*18+44)}function Vp(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 Gp=.04;function ht(e){return e.toLocaleString("en-US")}function Yp({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,i)=>t.jsx("span",{children:n},i))})}function Rt({id:e,title:n,sub:i,more:o,children:s}){const{convert:a}=ae(),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 Kp({counts:e}){const{t:n}=ae();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:ht(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:ht(e.pieces)}),n("readHome.pieces")]})]})}function qp({picks:e,links:n}){const{t:i,convert:o}=ae(),s=gn(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=br(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(Yp,{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 Xp(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function Ps({topic:e,links:n,hint:i,legendCount:o,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=ae(),c=gn(n);if(!e.items.length)return null;const p=o===void 0?l("readHome.shelfLegendCount"):o,m=Dp(e.items,l("readHome.shelfOther")),g=u=>{const h=u.records?ht(u.records):Xp(u.text_count,l),x=Ms(u),j=[d(u.title),u.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",u.records?l("readHome.spineRecords",{n:h}):h?l("readHome.spineOnSite",{n:h}):""].filter(Boolean).join(",");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-spine",href:c.read(u.id),"data-orig":u.orig?"":void 0,"aria-label":j,title:j,style:{height:Up(u.title)},children:[t.jsx(Yp,{text:d(u.title)}),h&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":u.records?"":void 0,children:h})]})},u.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:m.map(u=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(u.label),children:u.items.map(g)}),t.jsx("span",{"aria-hidden":"true",children:d(u.label)})]},u.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(u=>t.jsx("span",{children:d(u)},u))]})]})}const A1=4,ui=e=>e>A1+1;function Zp({topic:e,links:n}){const{t:i,convert:o}=ae(),s=gn(n),[a,l]=f.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":ui(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:ht(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=Xp(c.text_count,i),m=Ms(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}),m&&t.jsx("small",{children:o(m)})]})},c.id)})}),ui(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 Jp({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(Ps,{topic:s,links:n},s.key)),o.length>0&&t.jsx("div",{className:"bim-rh-groups",children:o.map(s=>t.jsx(Zp,{topic:s,links:n},s.key))})]})}function Qp({famous:e,links:n}){const{t:i,convert:o}=ae(),s=gn(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 Bs({bu:e,unclassified:n,links:i,unclassifiedNote:o}){const{t:s,convert:a}=ae(),l=gn(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:ht(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(m=>t.jsx("li",{children:t.jsxs("a",{href:l.node(m.id),children:[t.jsx("span",{children:a(m.label)}),t.jsx("small",{className:"bim-rh-num",children:ht(m.count)}),t.jsx("span",{className:"bim-rh-bar","aria-hidden":"true",style:{"--bimrh-w":`${Math.round(m.count/c*100)}%`}})]})},m.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:ht(n)})}),t.jsx("span",{children:o?a(o):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function eu({periods:e,unknown:n,links:i}){const{t:o,convert:s,messages:a}=ae(),l=a.readHome.period,d=gn(i),c=e.filter(g=>g.count>0);if(!c.length)return null;const p=c.reduce((g,u)=>g+u.count,0),m=Math.max(...c.map(g=>g.count));return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-band",children:c.map(g=>{const u=g.label?s(g.label):l[g.key]??s(g.key),h=g.count/p,x=o("readHome.periodItem",{label:u,n:ht(g.count)});return t.jsx("li",{style:{flex:`0 0 ${(h*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(g.key),"data-k":Vp(g.count,m),"data-narrow":h<Gp?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:u}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(u)[0]}),t.jsx("small",{className:"bim-rh-num",children:ht(g.count)})]})},g.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:o("readHome.periodUnknown",{n:ht(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:o("readHome.hoverHint")})]})]})}function tu({authors:e,links:n}){const{t:i,convert:o}=ae(),s=gn(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:ht(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 nu={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function M1({sections:e,links:n,head:i,piecesMoreHref:o,className:s}){const{t:a}=ae(),l=e,d=nu,c=l.topics.filter(u=>!u.shelf),p={picks:l.picks.length>0,topics:c.some(u=>u.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(u=>u.count>0),pieces:l.pieces.authors.length>0},m=Object.keys(d).filter(u=>p[u]),g=u=>a(`readHome.nav.${u}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:As}),t.jsxs("div",{className:"bim-rh-head",children:[i,t.jsx(Kp,{counts:l.counts})]}),m.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":a("readHome.navLabel"),children:t.jsx("ul",{children:m.map(u=>t.jsx("li",{children:t.jsx("a",{href:`#${d[u]}`,children:g(u)})},u))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(Rt,{id:d.picks,title:g("picks"),sub:a("readHome.picksSub"),children:t.jsx(qp,{picks:l.picks,links:n})}),p.topics&&t.jsx(Rt,{id:d.topics,title:g("topics"),sub:a("readHome.topicsSub"),children:t.jsx(Jp,{topics:c,links:n})}),p.famous&&t.jsx(Rt,{id:d.famous,title:g("famous"),sub:a("readHome.famousSub"),children:t.jsx(Qp,{famous:l.famous,links:n})}),p.sibu&&t.jsx(Rt,{id:d.sibu,title:g("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(Bs,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(Rt,{id:d.period,title:g("period"),sub:a("readHome.periodSub"),children:t.jsx(eu,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(Rt,{id:d.pieces,title:g("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(tu,{authors:l.pieces.authors,links:n})})]})]})}const P1="(max-width: 1079px)",B1=`${yi}, (pointer: coarse)`,iu=`
|
|
1913
|
+
`,_1=Fo["zh-Hant"].period,Yp={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function mn(e){return{...Yp,...e??{}}}function Ws(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 vr(e){return(e.authors??[]).filter(i=>i==null?void 0:i.name).map(i=>i.dynasty?`〔${i.dynasty}〕${i.name}`:i.name).join(" ")}function Kp(e,n=Fo["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 qp(e){return Math.max(150,Array.from(e).length*18+44)}function Xp(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 Zp=.04;function bt(e){return e.toLocaleString("en-US")}function Jp({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,i)=>t.jsx("span",{children:n},i))})}function Rt({id:e,title:n,sub:i,more:o,children:s}){const{convert:a}=oe(),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 Qp({counts:e}){const{t:n}=oe();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:bt(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:bt(e.pieces)}),n("readHome.pieces")]})]})}function eu({picks:e,links:n}){const{t:i,convert:o}=oe(),s=mn(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=vr(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(Jp,{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 tu(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function Fs({topic:e,links:n,hint:i,legendCount:o,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=oe(),c=mn(n);if(!e.items.length)return null;const p=o===void 0?l("readHome.shelfLegendCount"):o,m=Kp(e.items,l("readHome.shelfOther")),g=u=>{const f=u.records?bt(u.records):tu(u.text_count,l),x=Ws(u),j=[d(u.title),u.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",u.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(u.id),"data-orig":u.orig?"":void 0,"aria-label":j,title:j,style:{height:qp(u.title)},children:[t.jsx(Jp,{text:d(u.title)}),f&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":u.records?"":void 0,children:f})]})},u.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:m.map(u=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(u.label),children:u.items.map(g)}),t.jsx("span",{"aria-hidden":"true",children:d(u.label)})]},u.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(u=>t.jsx("span",{children:d(u)},u))]})]})}const C1=4,hi=e=>e>C1+1;function nu({topic:e,links:n}){const{t:i,convert:o}=oe(),s=mn(n),[a,l]=h.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":hi(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:bt(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=tu(c.text_count,i),m=Ws(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}),m&&t.jsx("small",{children:o(m)})]})},c.id)})}),hi(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 iu({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(Fs,{topic:s,links:n},s.key)),o.length>0&&t.jsx("div",{className:"bim-rh-groups",children:o.map(s=>t.jsx(nu,{topic:s,links:n},s.key))})]})}function ru({famous:e,links:n}){const{t:i,convert:o}=oe(),s=mn(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 Hs({bu:e,unclassified:n,links:i,unclassifiedNote:o}){const{t:s,convert:a}=oe(),l=mn(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:bt(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(m=>t.jsx("li",{children:t.jsxs("a",{href:l.node(m.id),children:[t.jsx("span",{children:a(m.label)}),t.jsx("small",{className:"bim-rh-num",children:bt(m.count)}),t.jsx("span",{className:"bim-rh-bar","aria-hidden":"true",style:{"--bimrh-w":`${Math.round(m.count/c*100)}%`}})]})},m.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:bt(n)})}),t.jsx("span",{children:o?a(o):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function ou({periods:e,unknown:n,links:i}){const{t:o,convert:s,messages:a}=oe(),l=a.readHome.period,d=mn(i),c=e.filter(g=>g.count>0);if(!c.length)return null;const p=c.reduce((g,u)=>g+u.count,0),m=Math.max(...c.map(g=>g.count));return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-band",children:c.map(g=>{const u=g.label?s(g.label):l[g.key]??s(g.key),f=g.count/p,x=o("readHome.periodItem",{label:u,n:bt(g.count)});return t.jsx("li",{style:{flex:`0 0 ${(f*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(g.key),"data-k":Xp(g.count,m),"data-narrow":f<Zp?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:u}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(u)[0]}),t.jsx("small",{className:"bim-rh-num",children:bt(g.count)})]})},g.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:o("readHome.periodUnknown",{n:bt(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:o("readHome.hoverHint")})]})]})}function su({authors:e,links:n}){const{t:i,convert:o}=oe(),s=mn(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:bt(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 au={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function z1({sections:e,links:n,head:i,piecesMoreHref:o,className:s}){const{t:a}=oe(),l=e,d=au,c=l.topics.filter(u=>!u.shelf),p={picks:l.picks.length>0,topics:c.some(u=>u.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(u=>u.count>0),pieces:l.pieces.authors.length>0},m=Object.keys(d).filter(u=>p[u]),g=u=>a(`readHome.nav.${u}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:Os}),t.jsxs("div",{className:"bim-rh-head",children:[i,t.jsx(Qp,{counts:l.counts})]}),m.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":a("readHome.navLabel"),children:t.jsx("ul",{children:m.map(u=>t.jsx("li",{children:t.jsx("a",{href:`#${d[u]}`,children:g(u)})},u))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(Rt,{id:d.picks,title:g("picks"),sub:a("readHome.picksSub"),children:t.jsx(eu,{picks:l.picks,links:n})}),p.topics&&t.jsx(Rt,{id:d.topics,title:g("topics"),sub:a("readHome.topicsSub"),children:t.jsx(iu,{topics:c,links:n})}),p.famous&&t.jsx(Rt,{id:d.famous,title:g("famous"),sub:a("readHome.famousSub"),children:t.jsx(ru,{famous:l.famous,links:n})}),p.sibu&&t.jsx(Rt,{id:d.sibu,title:g("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(Hs,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(Rt,{id:d.period,title:g("period"),sub:a("readHome.periodSub"),children:t.jsx(ou,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(Rt,{id:d.pieces,title:g("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(su,{authors:l.pieces.authors,links:n})})]})]})}const N1="(max-width: 1079px)",T1=`${ki}, (pointer: coarse)`,lu=`
|
|
1914
1914
|
/* ── 页首:检索(宿主插槽)+类型签|最近浏览 ── */
|
|
1915
1915
|
.bim-mh-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 16px 48px; align-items: start; padding-top: 8px; }
|
|
1916
1916
|
.bim-mh-q { min-width: 0; }
|
|
@@ -2050,7 +2050,7 @@ ${I1.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
2050
2050
|
.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")}; }
|
|
2051
2051
|
|
|
2052
2052
|
/* ── 中屏 ── */
|
|
2053
|
-
@media ${
|
|
2053
|
+
@media ${N1} {
|
|
2054
2054
|
.bim-mh-head, .bim-mh-zhi { grid-template-columns: minmax(0, 1fr); }
|
|
2055
2055
|
.bim-mh-cg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
2056
2056
|
.bim-mh-lin { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
@@ -2060,7 +2060,7 @@ ${I1.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
2060
2060
|
}
|
|
2061
2061
|
|
|
2062
2062
|
/* ── 手机 ── */
|
|
2063
|
-
@media ${
|
|
2063
|
+
@media ${ki} {
|
|
2064
2064
|
.bim-mh-cg, .bim-mh-data { grid-template-columns: minmax(0, 1fr); }
|
|
2065
2065
|
.bim-mh-ge { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
|
2066
2066
|
.bim-mh-lin { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
@@ -2077,8 +2077,8 @@ ${I1.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
2077
2077
|
.bim-mh-tbl tr > :nth-child(2), .bim-mh-tbl tr > :nth-child(3) { display: none; }
|
|
2078
2078
|
}
|
|
2079
2079
|
|
|
2080
|
-
@media ${
|
|
2080
|
+
@media ${T1} {
|
|
2081
2081
|
.bim-mh-recent li a, .bim-mh-types a, .bim-mh-tl-list a { min-height: 44px; align-items: center; }
|
|
2082
2082
|
.bim-mh-recent-h button { min-height: 44px; }
|
|
2083
2083
|
}
|
|
2084
|
-
`,ru={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function fn(e){return{...ru,...e??{}}}function ou(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 Os(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function su(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 m=Number.isFinite(p.birth_year)?p.birth_year:p.death_year-50,g=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(m,g),Math.max(m,g)]},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,m)=>({p,from:s[m][0],to:s[m][1]})).sort((p,m)=>p.from-m.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 Ji(e,n=Vn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function O1(e){return{read:e.item,work:e.item,node:e.node}}function au({counts:e,links:n}){const{t:i}=ae(),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:ht(d)})]})},a))})}function lu(e,n=5){const[i,o]=f.useState(null);f.useEffect(()=>{let a=!1;const l=mn().slice(0,n);if(!l.length||!e){o([]);return}return Promise.all(l.map(d=>Yo(e,d))).then(d=>{a||o(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=f.useCallback(()=>{Go(),o([])},[]);return{entries:i,clear:s}}function W1(e,n,i){const o=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return o?i(o):cu(e.type,n)}function cu(e,n){return n(`metaHome.typeLabel.${e}`)}function du({entries:e,onClear:n,links:i}){const{t:o,convert:s}=ae(),a=fn(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?cu(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:W1(l,o,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:o("metaHome.recentEmpty")})]})}function pu(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 uu({rows:e,links:n}){const{t:i,convert:o}=ae(),s=fn(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=Os(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:ht(a.total)}),t.jsx("td",{className:"bim-mh-r",children:ht(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:pu(a.status,i,o)})})]},a.id||a.name)})})]})}):null}function mu({items:e,links:n,label:i}){const{convert:o}=ae();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 gu({works:e,links:n}){const{t:i}=ae(),[o,s]=f.useState(!1);if(!e.length)return null;const a=ui(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(mu,{items:e.map(l=>({id:l.id,title:l.title,sub:br(l)||void 0})),links:fn(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 fu="siku_qige";function F1({group:e,links:n}){const{t:i,convert:o}=ae(),[s,a]=f.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":ui(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(mu,{items:e.items,links:n,label:e.label}),ui(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 hu({groups:e,links:n}){const{t:i,convert:o}=ae(),s=fn(n);if(!e.length)return null;const a=e.find(c=>c.key===fu),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(F1,{group:c,links:s},c.key))})]})}const Vl=34,Gl=13;function Yl(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?Ji(e.birth_year,n):"?"}–${e.death_year!=null?Ji(e.death_year,n):"?"}`}function H1(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 xu({people:e,links:n}){const{t:i,convert:o}=ae(),s=fn(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=su(e),p=[],m=d.map(u=>{const h=u.left>70,x=h?Math.min(u.left,u.left+u.width-Gl):u.left;let j=0;for(;p[j]!=null&&p[j]>x;)j++;return p[j]=h?u.left+u.width:u.left+Math.max(u.width,Gl),{...u,lane:j,end:h}}),g=Math.max(1,l-a);return t.jsxs(t.Fragment,{children:[m.length>0&&t.jsxs("div",{className:"bim-mh-tl",children:[t.jsx("ul",{className:"bim-mh-tl-rows",style:{height:p.length*Vl+10},children:m.map(u=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":u.end?"":void 0,style:{left:`${u.left}%`,top:u.lane*Vl+4,width:`${Math.max(u.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(u.p.id),children:[o(u.p.name),t.jsx("small",{className:"bim-rh-num",children:Yl(u.p,i)})]})]},u.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:H1(a,l).map(u=>t.jsx("span",{style:{left:`${(u-a)/g*100}%`},children:Ji(u,i)},u))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":m.length?void 0:"",children:(m.length?e:c).map(u=>t.jsx("li",{children:t.jsxs("a",{href:s.item(u.id),children:[t.jsx("span",{children:o(u.name)}),t.jsx("small",{className:"bim-rh-num",children:[u.dynasty?o(u.dynasty):"",Yl(u,i)].filter(Boolean).join(" ")})]})},u.id))}),c.length>0&&m.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:i("metaHome.missingLife",{names:o(c.map(u=>u.name).join("、"))})})]})}const D1=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 bu({works:e,links:n}){const{t:i,convert:o}=ae(),s=fn(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=br(a);return t.jsx("li",{children:t.jsxs("a",{href:ou(s,a.id),children:[D1,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 yu({sites:e}){const{t:n,convert:i}=ae(),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=Os(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:[`${ht(a.imported)} / ${ht(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:pu(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 Kl=["extant","partially_extant","lost","unknown"];function ju({stats:e,links:n,version:i,repoUrl:o,downloadHref:s}){const{t:a}=ae(),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=Kl.some(p=>{var m;return(((m=e.loss)==null?void 0:m[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,m])=>t.jsxs("li",{children:[t.jsx("b",{className:"bim-rh-num",children:ht(p)}),t.jsx("span",{children:m})]},m))})]}),d&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.byLoss")}),t.jsx("ul",{className:"bim-mh-loss",children:Kl.map(p=>{var u;const m=((u=e.loss)==null?void 0:u[p])??0,g=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&&m>0?a("metaHome.lossCount",{n:ht(m),note:g}):g})]})},p)})})]}),t.jsxs("div",{className:"bim-mh-lic",children:[t.jsxs("p",{children:[t.jsx("span",{className:"bim-mh-cc0",children:"CC BY-SA 4.0"}),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 vu={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function U1({sections:e,links:n,head:i,transport:o,catalogHref:s,collectionsHref:a,entitiesHref:l,version:d,repoUrl:c,downloadHref:p,className:m}){var v,$;const{t:g}=ae(),u=e,h=fn(n),x=O1(h),j=vu,y=lu(o),S={zhi:!!((v=u.shelf)!=null&&v.items.length)||u.catalog_progress.length>0||u.related_catalogs.length>0,sibu:u.bu.length>0||u.unclassified>0,cong:u.collection_groups.length>0,people:u.bibliographers.length>0,lineage:u.lineage.length>0,sites:u.sites.length>0,data:!0},b=Object.keys(j).filter(_=>S[_]),k=_=>g(`metaHome.nav.${_}`),w=(_,C)=>_?t.jsx("a",{className:"bim-rh-more",href:_,children:C}):void 0;return t.jsxs("div",{className:m?`bim-rh bim-mh ${m}`:"bim-rh bim-mh",children:[t.jsx("style",{children:As+iu}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[i,t.jsx(au,{counts:u.counts,links:n})]}),o&&t.jsx(du,{entries:y.entries,onClear:y.clear,links:n})]}),b.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":g("metaHome.navLabel"),children:t.jsx("ul",{children:b.map(_=>t.jsx("li",{children:t.jsx("a",{href:`#${j[_]}`,children:k(_)})},_))})}),t.jsxs("div",{className:"bim-rh-main",children:[S.zhi&&t.jsxs(Rt,{id:j.zhi,title:k("zhi"),sub:g("metaHome.zhiSub"),children:[u.shelf&&u.shelf.items.length>0&&t.jsx(Ps,{topic:{key:"shelf",label:u.shelf.label,shelf:!0,items:u.shelf.items},links:x,showTitle:!1,legendCount:u.shelf.items.some(_=>_.records)?g("metaHome.shelfLegendCount"):null,legendExtra:[g("metaHome.shelfLegendClick")]}),(u.catalog_progress.length>0||u.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:($=u.shelf)!=null&&$.items.length?void 0:{marginTop:0},children:[t.jsx(uu,{rows:u.catalog_progress,links:n}),t.jsx(gu,{works:u.related_catalogs,links:n})]})]}),S.sibu&&t.jsx(Rt,{id:j.sibu,title:k("sibu"),sub:g("metaHome.sibuSub"),more:w(s,g("metaHome.toCatalog")),children:t.jsx(Bs,{bu:u.bu,unclassified:u.unclassified,links:x,unclassifiedNote:g("metaHome.unclassifiedNote")})}),S.cong&&t.jsx(Rt,{id:j.cong,title:k("cong"),sub:g("metaHome.congSub"),more:w(a,g("metaHome.allNKindsMore",{n:ht(u.counts.collections)})),children:t.jsx(hu,{groups:u.collection_groups,links:n})}),S.people&&t.jsx(Rt,{id:j.people,title:k("people"),sub:g("metaHome.peopleSub"),more:w(l,g("metaHome.allNPeopleMore",{n:ht(u.counts.entities)})),children:t.jsx(xu,{people:u.bibliographers,links:n})}),S.lineage&&t.jsx(Rt,{id:j.lineage,title:k("lineage"),sub:g("metaHome.lineageSub"),children:t.jsx(bu,{works:u.lineage,links:n})}),S.sites&&t.jsx(Rt,{id:j.sites,title:k("sites"),sub:g("metaHome.sitesSub"),children:t.jsx(yu,{sites:u.sites})}),t.jsx(Rt,{id:j.data,title:k("data"),sub:g("metaHome.dataSub"),children:t.jsx(ju,{stats:u.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const ku=["_related","_catalogs","_collections","_members","_children"],V1=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),zo=e=>V1(e)&&!!e.h;function G1(e){return e?ku.some(n=>{const i=e[n];return Array.isArray(i)&&i.some(zo)}):!1}function Y1(e,n){const i={...e};if(!n)return i;for(const o of ku){const s=e[o];!Array.isArray(s)||!s.some(zo)||(i[o]=s.map(a=>{var c;if(!zo(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 K1(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&&Y1(d,G1(d)?await i():null)};const a=Reflect.get(o,s,o);return typeof a=="function"?a.bind(o):a}})}const No=({style:e})=>{const n=f.useContext(qt),{t:i}=ae();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")})]})},To=({href:e,label:n,size:i=16,className:o,style:s})=>{const{t:a}=ae(),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 eo(e){const n=e.text_count;return typeof n=="number"&&n>0}function to(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function q1(e,n){if(!n)return!1;const i=n.id;return i===void 0||i===e}const X1=({id:e,transport:n,initialDetail:i,initialEntry:o,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:m,onLineageCollectionChange:g,initialPage:u=1,selectedLineageNodeId:h,onNavigate:x,onBack:j,backLabel:y,renderLink:S,assetBase:b,enrichDetail:k,getSourceLink:w,readLink:v,railTop:$,extraTabs:_=[],showFeedbackTab:C=!0,feedbackApiUrl:I,height:E,footerExtra:T,hideHeaderControls:N=!1,className:P,style:W})=>{const L=f.useMemo(()=>K1(n),[n]),K=Ae(),{t:Q,convert:Z}=ae(),[ue]=f.useState(()=>{if(!q1(e,i))return null;const X={...i},$e=o??to(e,X);return k&&k($e,X),{id:e,entry:$e,detail:X}}),[J,le]=f.useState((ue==null?void 0:ue.entry)??null),[H,oe]=f.useState((ue==null?void 0:ue.detail)??null),[be,ze]=f.useState(!ue),[Le,_e]=f.useState(!1),[re,xe]=f.useState([]),[R,se]=f.useState(!1),[de,O]=f.useState(null),[ee,ke]=f.useState(null),[ve,Ve]=f.useState(null),[F,fe]=f.useState(!1),te=f.useRef(null),U=f.useRef(0),[pe,Me]=f.useState(null),Ke=l!==void 0?l:pe,nt=f.useCallback(X=>{d?d(X):Me(X)},[d]),it=f.useCallback(async X=>{if(!L.getCollectionCatalogs&&!L.getCollectionCatalog){xe([]);return}se(!0);try{if(L.getCollectionCatalogs)xe(await L.getCollectionCatalogs(X)||[]);else if(L.getCollectionCatalog){const $e=await L.getCollectionCatalog(X);xe($e?[{resource_id:"",data:$e}]:[])}}catch{xe([])}finally{se(!1)}},[L]),at=f.useCallback(async X=>{var $e,je;if(!L.getTextManifest||!L.getTextIndex){O(null),ke(X);return}try{const De=Te.pickTextVersion(await L.getTextManifest(X)),ce=De?await L.getTextIndex(X,De.key):null;O(ce&&ce.chapters.length>0?{chapters:ce.chapters.map(He=>({n:He.n,title:He.title,file:He.file})),source:{name:(($e=ce.source)==null?void 0:$e.name)??(De==null?void 0:De.source_name),license:((je=ce.source)==null?void 0:je.license)??(De==null?void 0:De.license)??void 0}}:null)}catch{O(null)}finally{ke(X)}},[L]),lt=f.useCallback(async(X,$e)=>{const je=++U.current,De=()=>je!==U.current;fe(!0);try{if(L.getLineageGraph){const V=await L.getLineageGraph(X);if(De())return;V&&Ve(V)}const ce=$e.version_graph;if(!ce||!ce.enabled){ve||Ve(null),te.current=null;return}const He=Do($e),gt=(await hr(He,fr,async V=>{try{return await L.getItem(V)}catch{return null}},De)).filter(Boolean);if(De())return;te.current={work:$e,books:gt};const yt=m??ce.default_collection??(ce.core_books&&ce.core_books.length>0?"core":"all"),qe=yt==="core"&&Array.isArray(ce.core_books)&&ce.core_books.length>0?"core":yt??"all";Ve(Pi($e,gt,qe))}catch{if(De())return;Ve(null),te.current=null}finally{De()||fe(!1)}},[L]),rt=f.useRef({initialDetail:i,initialEntry:o});rt.current={initialDetail:i,initialEntry:o},f.useEffect(()=>{let X=!1;U.current++,fe(!1);const $e=He=>{He.type==="collection"?it(e):He.type==="work"?(He.version_graph||L.getLineageGraph)&<(e,He):He.type==="book"&&eo(He)&&at(e)},je=rt.current;let De=null;if(ue&&ue.id===e)De=ue;else if(je.initialDetail&&je.initialDetail.id===e){const He={...je.initialDetail},ft=je.initialEntry??to(e,He);k&&k(ft,He),De={entry:ft,detail:He}}return De?(_e(!1),xe(He=>He.length?[]:He),O(null),Ve(null),te.current=null,le(De.entry),oe(De.detail),ze(!1),$e(De.detail),()=>{X=!0}):((async()=>{ze(!0),_e(!1),le(null),oe(null),xe([]),O(null),Ve(null),te.current=null;try{const He=await L.getItem(e);if(X)return;if(!He){_e(!0);return}const ft=He;let gt=null;if(L.getEntry&&(gt=await L.getEntry(e),X))return;gt||(gt=to(e,ft)),k&&k(gt,ft),le(gt),oe(ft),$e(ft)}catch{X||_e(!0)}finally{X||ze(!1)}})(),()=>{X=!0})},[e,L,ue,k,it,lt,at]),f.useEffect(()=>{const X=te.current;!X||!m||Ve(Pi(X.work,X.books,m))},[m]);const Pe=[];if(H){if(Pe.push({key:"basic",label:K.detailTab.basicInfo}),H.type==="collection"){R&&re.length===0&&Pe.push({key:"catalog:loading",label:`${K.detailTab.catalog}…`});for(const X of re)Pe.push({key:`catalog:${X.resource_id}`,label:X.short_name?`${Z(X.short_name)}${K.detailTab.catalogSuffix}`:K.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&Pe.push({key:s,label:K.detailTab.fullText}),H.type==="work"&&(ve||F)&&Pe.push({key:"lineage",label:F?`${K.detailTab.lineage}…`:K.detailTab.lineage});for(const X of _)(X.position??"before-feedback")==="before-feedback"&&X.shouldShow(H)&&Pe.push({key:X.key,label:X.label});C&&s==="feedback"&&Pe.push({key:"feedback",label:K.detailTab.feedback});for(const X of _)X.position==="after-feedback"&&X.shouldShow(H)&&Pe.push({key:X.key,label:X.label})}f.useEffect(()=>{if(s!=="emendated"||!H)return;a("basic");const X=setTimeout(()=>{var $e;($e=document.getElementById("studies"))==null||$e.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(X)},[s,H,a]);const z=J&&H&&w?w({activeTab:s,activeJuan:Ke,entry:J,detail:H}):null,ne=f.useMemo(()=>{var ce,He,ft,gt,yt;if(!H)return null;const $e=(H.authors??[]).map(qe=>{const V=Ho(qe.role);return`${qe.dynasty?`〔${Z(qe.dynasty)}〕`:""}${Z(qe.name)}${V?` ${Z(V)}`:""}`}).join(" · ");let je=!1;try{je=Te.extractStatus(H.id)==="draft"}catch{}if(H.type==="book"){const qe=H;return{title:Z(qe.title),subtitle:qe.edition?Z(qe.edition):$e||void 0,aside:[je?K.status.draft:"",$e&&qe.edition?$e:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(H.type==="collection"){const qe=H;return{title:Z(qe.title),subtitle:Z(on(qe,K.unit.juan))||void 0,aside:[(ce=qe.publication_info)==null?void 0:ce.year,je?K.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:$e||void 0}}if(H.type==="entity"){const qe=H,V=Y=>Y==null?"":Y<0?Q("detail.bce",{n:-Y}):String(Y),D=((He=qe.dates)==null?void 0:He.birth)!=null||((ft=qe.dates)==null?void 0:ft.death)!=null?`${V(((gt=qe.dates)==null?void 0:gt.birth)??void 0)||"?"}—${V(((yt=qe.dates)==null?void 0:yt.death)??void 0)||"?"}`:"";return{title:Z(qe.primary_name||qe.title),subtitle:[qe.dynasty?`〔${Z(qe.dynasty)}〕`:"",D].filter(Boolean).join(" ")||void 0,aside:je?K.status.draft:void 0,secondLine:void 0}}const De=Z(on(H,K.unit.juan));return{title:Z(H.title),subtitle:[De,$e].filter(Boolean).join(" · ")||void 0,aside:[J1(K,H.subtype),je?K.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[H,Z,K,Q]),q=H&&eo(H)?"text":null,he=()=>{nt(null),a("fulltext")};let Ie=null;if(H&&v){const X=v({detail:H,kind:q});X&&(Ie=t.jsx(mo,{href:X}))}else q&&(Ie=t.jsx(mo,{onClick:he}));const M=X=>{if(!H)return null;const $e=X.replace(/\.[^.]+$/,"");if(v){const je=v({detail:H,kind:q,juan:$e});return je?{href:je}:null}return{onClick:()=>{nt($e),a("fulltext")}}},me=new Set(_.map(X=>X.key)),G=Pe.filter(X=>X.key.startsWith("catalog:")&&X.key!=="catalog:loading"||X.key==="lineage"&&!!ve&&!F||me.has(X.key)).map(X=>({key:X.key,label:X.label,onClick:()=>a(X.key)})),Se=()=>{var X;return H?H.type==="work"?t.jsx(_p,{data:H,transport:L,onNavigate:x,renderLink:S,readAction:Ie,railTop:$,railLinks:G}):H.type==="book"?t.jsx(zp,{data:H,transport:L,onNavigate:x,renderLink:S,readAction:Ie,fullText:de,fullTextPending:eo(H)&&!!L.getTextManifest&&ee!==H.id,chapterLink:M,railTop:$,railLinks:G}):H.type==="collection"?t.jsx(Np,{data:H,catalog:(X=re[0])==null?void 0:X.data,transport:L,onNavigate:x,renderLink:S,readAction:Ie,railTop:$,railLinks:G,catalogAction:re.length>0?t.jsxs("a",{href:"#catalog",onClick:$e=>{$e.preventDefault(),a(`catalog:${re[0].resource_id}`)},children:[Z(K.detailTab.collectionCatalog)," →"]}):null}):t.jsx(Rp,{data:H,transport:L,onNavigate:x,renderLink:S,railTop:$,railLinks:G,assetBase:b}):null},ye=()=>{var $e,je,De;if(!J||!H)return null;if(s==="basic"||s==="emendated")return Se();if(typeof s=="string"&&s.startsWith("catalog:")){const ce=($e=re.find(He=>`catalog:${He.resource_id}`===s))==null?void 0:$e.data;return t.jsx(qo,{data:ce,onNavigate:x,renderLink:S})}if(s==="collated"||s==="fulltext")return t.jsx(_s,{id:e,transport:L,chapter:Ke,onLocationChange:ce=>nt(ce.chapter),onNavigate:x});if(s==="lineage"){if(!ve)return t.jsx("div",{style:{color:r("label-fg"),padding:"24px 0"},children:Q(F?"detail.loading":"detail.noLineageGraph")});const ce=H.type==="work"?H:null;return t.jsx(Es,{graph:ve,renderLink:S,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:h,collection:m??((je=ce==null?void 0:ce.version_graph)==null?void 0:je.default_collection),onCollectionChange:g,collectionsAvailable:(De=ce==null?void 0:ce.version_graph)==null?void 0:De.collections,collectionCounts:(()=>{var yt,qe,V,D,Y,we,Ce;if(!ce)return;const He={},ft=((yt=te.current)==null?void 0:yt.books)??[];He.all=(((qe=ce._books)==null?void 0:qe.length)??0)-(((D=(V=ce.version_graph)==null?void 0:V.excluded_books)==null?void 0:D.length)??0);const gt=(Y=ce.version_graph)==null?void 0:Y.collections;if(gt)for(const Ne of Object.keys(gt))He[Ne]=Pi(ce,ft,Ne).nodes.filter(et=>et.kind==="book"&&!et.bridge).length;return He.core==null&&((Ce=(we=ce.version_graph)==null?void 0:we.core_books)!=null&&Ce.length)&&(He.core=ce.version_graph.core_books.length),He})()})}if(s==="feedback"&&C)return t.jsx(vp,{resourceId:e,apiUrl:I});const X=_.find(ce=>ce.key===s);return X?X.render({detail:H,entry:J,transport:L,onNavigate:x}):null};if(be)return t.jsx(oi,{style:{minHeight:E,...W},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((X,$e)=>t.jsx("div",{style:{height:$e===1?40:16,width:X,opacity:.35,background:r("rule")}},$e))})});if(Le||!H||!J||!ne)return t.jsx(oi,{style:{minHeight:E,...W},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:r("label-fg"),fontSize:14},children:Q("detail.notFound")})});const Ee=s==="basic"||s==="emendated",Xe=[{label:y??K.detailTab.backToIndex,onClick:j}];if(H.type==="book"&&H.work_id){const X=H.work_id;Xe.push({label:K.indexType.work,id:X,onClick:()=>x==null?void 0:x(X)})}Xe.push({label:K.indexType[H.type]});const Fe=s==="collated"||s==="fulltext",Qe=typeof T=="string"?K.status[T.trim()]??T:T,ut=t.jsx(vd,{left:t.jsxs(t.Fragment,{children:[Qe,Qe?" · ":"",t.jsx(Z1,{id:H.id,label:K.label.id,copied:K.action.copied,copyLabel:K.action.copy})]}),right:t.jsxs(t.Fragment,{children:[C&&!Ee&&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:K.detailTab.submitVersion}),z&&t.jsx("a",{href:z.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:r("meta-fg")},children:K.detailTab.dataLicense})]})});return Ee?t.jsx("div",{className:P,children:t.jsxs(oi,{grid:!0,style:{minHeight:E,...W},children:[t.jsx(go,{breadcrumb:t.jsx(fo,{items:Xe}),actions:t.jsxs(t.Fragment,{children:[!N&&t.jsx(No,{style:{border:"none",background:"transparent"}}),!N&&z&&t.jsx(To,{...z})]})}),Se(),ut]})}):t.jsx("div",{className:P,children:t.jsxs(oi,{wide:Fe,style:{minHeight:E,...W},children:[t.jsx(go,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(ts,{char:"籍"}),t.jsx(fo,{items:Xe})]}),actions:t.jsxs(t.Fragment,{children:[!N&&t.jsx(No,{}),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:K.detailTab.feedback}),!N&&z&&t.jsx(To,{...z})]})}),t.jsx(pd,{...ne,aside:Fe?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:[Q("detail.workInfo")," →"]}):ne.aside}),!Fe&&Pe.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:Pe.map(X=>t.jsx(ud,{label:X.label,active:X.key===s||Ee&&X.key==="basic",onClick:()=>a(X.key)},X.key))}),t.jsx("div",{style:{marginTop:!Fe&&Pe.length>1?8:0},children:ye()}),ut]})})};function Z1({id:e,label:n,copied:i,copyLabel:o}){const[s,a]=f.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 J1(e,n){return n?e.workSubtype[n]??n:""}const wu=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],yr="zhusha",jr="bim-theme";function Su(e){return e==="zhusha"||e==="indigo"||e==="ink"}function vr(e){return Su(e)?e:yr}function Q1(){try{return vr(window.localStorage.getItem(jr))}catch{return yr}}function _u(e){try{window.localStorage.setItem(jr,e)}catch{}}function $u(e){const n=vr(e);return document.documentElement.setAttribute("data-theme",n),n}function Cu(){return vr(document.documentElement.getAttribute("data-theme"))}const ej=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Ws="airy",kr="bim-layout";function zu(e){return e==="airy"||e==="boxed"}function wr(e){return zu(e)?e:Ws}function tj(){try{return wr(window.localStorage.getItem(kr))}catch{return Ws}}function nj(e){try{window.localStorage.setItem(kr,e)}catch{}}function ij(e){const n=wr(e);return document.documentElement.setAttribute("data-layout",n),n}function rj(){return wr(document.documentElement.getAttribute("data-layout"))}const oj=`try{var t=localStorage.getItem(${JSON.stringify(jr)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(kr)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,sj={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},aj=({onChange:e,style:n})=>{const{t:i}=ae(),[o,s]=f.useState(yr);f.useEffect(()=>{s(Cu())},[]);const a=l=>{s($u(l)),_u(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":i("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:wu.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(sj[l.name]),boxShadow:d?`0 0 0 2px ${r("page-bg")}, 0 0 0 3.5px ${r("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=Te.BidLink;exports.BookIndexError=Te.BookIndexError;exports.BookIndexManager=Te.BookIndexManager;exports.BookIndexStorage=Te.BookIndexStorage;exports.BundleStorage=Te.BundleStorage;exports.ConfigError=Te.ConfigError;exports.GithubStorage=Te.GithubStorage;exports.IdGenerationError=Te.IdGenerationError;exports.IdGenerator=Te.IdGenerator;exports.LocalStorage=Te.LocalStorage;exports.MigrationError=Te.MigrationError;exports.StorageError=Te.StorageError;exports.VARIANT_CHARS=Te.VARIANT_CHARS;exports.base36Decode=Te.base36Decode;exports.base36Encode=Te.base36Encode;exports.base58Decode=Te.base58Decode;exports.buildId=Te.buildId;exports.buildPromotionMap=Te.buildPromotionMap;exports.cleanName=Te.cleanName;exports.decodeId=Te.decodeId;exports.decodeIdString=Te.decodeIdString;exports.encodeId=Te.encodeId;exports.extractIdFromUrl=Te.extractIdFromUrl;exports.extractStatus=Te.extractStatus;exports.extractType=Te.extractType;exports.isChapterSegment=Te.isChapterSegment;exports.isTextKey=Te.isTextKey;exports.matchChapterAcrossVersions=Te.matchChapterAcrossVersions;exports.normalizeCatalog=Te.normalizeCatalog;exports.normalizeVariants=Te.normalizeVariants;exports.parseId=Te.parseId;exports.pickTextVersion=Te.pickTextVersion;exports.shardOf=Te.shardOf;exports.smartDecode=Te.smartDecode;exports.textVersionLabel=Te.textVersionLabel;exports.validateResource=Te.validateResource;exports.VARIANT_SUPPLEMENT=ql.VARIANT_SUPPLEMENT;exports.Badge=Zi;exports.BidUrlProvider=nm;exports.BookDetailLayout=X1;exports.BookPage=zp;exports.Breadcrumb=fo;exports.CATALOG_ALL_ID=tn;exports.CATALOG_CSS=Ip;exports.CATALOG_NARROW_QUERY=Rs;exports.CATALOG_PAGE_SIZE=Is;exports.CATALOG_UNCLASSIFIED_ID=jn;exports.CLASSIFICATIONS=cr;exports.COMMON_TRADITIONAL_CHARS=sc;exports.CardFoot=hi;exports.CatalogPage=T1;exports.CatalogPager=Wp;exports.CatalogTree=Ap;exports.CheckFilter=ld;exports.Chip=md;exports.ChipWall=fh;exports.CollectionCatalog=qo;exports.CollectionPage=Np;exports.CreateEntityDialog=mp;exports.DEFAULT_LAYOUT=Ws;exports.DEFAULT_META_HOME_LINKS=ru;exports.DEFAULT_READER_PREFS=Zo;exports.DEFAULT_READ_HOME_LINKS=Hp;exports.DEFAULT_THEME=yr;exports.DETAIL_CSS=dd;exports.DYNASTY_GROUPS=lr;exports.Dash=vh;exports.DataTable=xh;exports.DetailFooter=vd;exports.DetailGrid=gi;exports.DetailHeader=pd;exports.EMPTY_FILTERS=ar;exports.ENTITY_TEXT_CSS=xs;exports.EmendatedBySection=Wc;exports.EmptyNote=zh;exports.EntityDetail=Ac;exports.EntityMark=js;exports.EntityPage=Rp;exports.EntityPickerDialog=fp;exports.EntitySelector=up;exports.EntityText=Qx;exports.ExpandRow=kh;exports.ExtLink=Nh;exports.FEEDBACK_FAB_OFFSET_VAR=So;exports.FILTER_SUPPORT=$c;exports.FONT_SIZE_STEPS=en;exports.FactList=ph;exports.FeedbackButton=u0;exports.FeedbackDialog=yp;exports.FeedbackForm=jp;exports.FeedbackList=$s;exports.FeedbackTab=vp;exports.FilterChip=ud;exports.FormInput=Pt;exports.FormTextArea=kn;exports.GUJI_MARKDOWN_FIELD=Xf;exports.GUJI_TABLE_NOTATION=kd;exports.GlyphBadge=ts;exports.GujiInteractiveReader=iy;exports.GujiTable=rs;exports.GujiTextViewer=ks;exports.GujiWarpCanvas=hs;exports.HomePage=ko;exports.ImagePanel=lo;exports.IndexApp=ny;exports.IndexBrowser=oo;exports.IndexDetail=Ko;exports.IndexEditor=hp;exports.IndexView=Jy;exports.IntroGrid=dh;exports.LAYOUTS=ej;exports.LAYOUT_STORAGE_KEY=kr;exports.LOSS_OPTIONS=_c;exports.LocaleContext=qt;exports.LocaleProvider=Em;exports.LocaleToggle=No;exports.META_HOME_CSS=iu;exports.META_HOME_SECTION_IDS=vu;exports.MetaCatalogTable=uu;exports.MetaCollectionGroups=hu;exports.MetaDataLicense=ju;exports.MetaHomeView=U1;exports.MetaLine=vt;exports.MetaLineageCards=bu;exports.MetaOnlineSites=yu;exports.MetaPeopleTimeline=xu;exports.MetaRecentPanel=du;exports.MetaRelatedCatalogs=gu;exports.MetaTypeChips=au;exports.ModeIndicator=lc;exports.MoreButton=gh;exports.MoreLink=Qo;exports.PAGE_MAX_WIDTH=Fi;exports.PERIOD_NARROW_SHARE=Gp;exports.PageFrame=oi;exports.Quote=Sh;exports.READER_CSS=Vc;exports.READ_HOME_CSS=As;exports.READ_HOME_NARROW_QUERY=yi;exports.READ_HOME_SECTION_IDS=nu;exports.READ_PERIOD_LABELS=L1;exports.RECENT_IDS_STORAGE_KEY=Wn;exports.ROLE_CLASS_ORDER=yc;exports.ReadButton=mo;exports.ReadFamousWorks=Qp;exports.ReadHomeView=M1;exports.ReadPeriodBand=eu;exports.ReadPicks=qp;exports.ReadPieces=tu;exports.ReadSection=Rt;exports.ReadShelf=Ps;exports.ReadSibu=Bs;exports.ReadStats=Kp;exports.ReadTopicGroup=Zp;exports.ReadTopics=Jp;exports.ReaderMdText=ls;exports.ReaderShell=Qc;exports.ReaderToc=Gc;exports.RelationPanel=dp;exports.RepoSourceLink=To;exports.ResourceEditor=no;exports.ResourceGroup=_h;exports.ResourceLine=$h;exports.ResourceList=Po;exports.ResourceRow=bd;exports.SEARCH_VIEW_STORAGE_KEY=Vo;exports.SEVEN_PAVILIONS_KEY=fu;exports.SNIPPET_MARK_END=Jl;exports.SNIPPET_MARK_START=Zl;exports.SORTABLE_TYPES=Sc;exports.SearchInput=dc;exports.SearchResults=Rc;exports.Sec=wt;exports.Section=Dt;exports.SectionHead=uh;exports.SideList=vn;exports.SmartBidInput=Ui;exports.SourceEditor=ap;exports.StripWarpRenderer=ho;exports.SummaryCard=fi;exports.THEMES=wu;exports.THEME_INIT_SCRIPT=oj;exports.THEME_STORAGE_KEY=jr;exports.TRADITIONAL_ALLOWLIST=ac;exports.TabFilter=pr;exports.TableHead=bh;exports.TableRow=yh;exports.TagRow=yd;exports.TagRows=Ch;exports.TextButton=mh;exports.TextReader=_s;exports.ThemeToggle=aj;exports.TopStrip=go;exports.VersionLineageGraph=Cp;exports.VersionLineageList=$p;exports.VersionLineageView=Es;exports.VolumeChips=hh;exports.VolumeLinks=ns;exports.WorkCard=Bp;exports.WorkCardGrid=Fp;exports.WorkCatalog=xy;exports.WorkPage=_p;exports.WorkRow=Op;exports.adaptCharCord=gy;exports.adaptEntityJson=Ld;exports.adaptFig=hy;exports.adaptNorm=sp;exports.adaptNormDetailed=op;exports.adaptPunctJson=ay;exports.applyLayout=ij;exports.applyTheme=$u;exports.authorsLine=br;exports.bookIndexUriToId=_n;exports.bookMarkingOf=as;exports.bucketResources=Wo;exports.buildCatalogTree=v1;exports.buildCollectionTable=kc;exports.buildLineageGraph=Pi;exports.buildMeiliFilter=kg;exports.buildPageUrl=Ao;exports.buildParagraphBlocks=Nd;exports.buildVersionRow=xc;exports.buildVersionTable=bc;exports.canParagraphize=qi;exports.catalogNodeIdOf=y1;exports.catalogNodeIdsOf=j1;exports.catalogPageCount=_1;exports.catalogTotal=Ls;exports.classificationPath=bi;exports.clearAllRecentIds=Go;exports.compareCatalogCards=S1;exports.computeVersionPartition=mg;exports.countActiveFilters=dr;exports.createTextApi=Hc;exports.currentLayout=rj;exports.currentTheme=Cu;exports.defaultEntityHref=Ud;exports.defaultWorkLink=Mp;exports.deriveDating=sg;exports.deriveEditionType=wc;exports.deriveEra=mi;exports.deriveYear=rr;exports.deriveYearRange=Oo;exports.detailToEditor=bp;exports.detectGenre=mr;exports.displayAuthorRole=Ho;exports.editorToDetail=Zy;exports.eraRank=io;exports.filtersFromParams=wg;exports.filtersToParams=Ki;exports.findCatalogPath=Pn;exports.findTraditionalChars=Lm;exports.firstAuthorText=Ms;exports.flattenTitles=jd;exports.flattenToc=Jc;exports.fmtCount=ht;exports.formatHitCount=Bi;exports.formatTemplate=Bt;exports.formatVolumeRange=sr;exports.getDisplayNameFromUrl=Hn;exports.getMessages=Un;exports.getStartPage=Lo;exports.getT=Vn;exports.getTypeGroupKey=Ro;exports.groupRelatedWorks=ag;exports.gujiInlineToPlain=sd;exports.hasActiveFilters=Cc;exports.hasGujiMarkdownV02=Zf;exports.hasGujiTableNotation=Th;exports.hasSearchOptions=yg;exports.headingKey=Ss;exports.headingsFromPunct=Zd;exports.iiifVolumeOf=ly;exports.isCountedChar=cs;exports.isDuiduChapter=Di;exports.isLayoutName=zu;exports.isThemeName=Su;exports.lineageHref=ou;exports.loadRecentIds=mn;exports.measureText=on;exports.mergeVolumeResources=Io;exports.nestHeadings=Qd;exports.normalizeEra=It;exports.normalizeLayout=wr;exports.normalizeRole=Fo;exports.normalizeTheme=vr;exports.normalizeVolumeIndex=ai;exports.normalizeVolumes=tc;exports.numberToChinese=Sn;exports.paginationItems=Lp;exports.parseChineseNumber=Gi;exports.parseGujiInline=od;exports.parseGujiTable=Sd;exports.parseHeadingKey=Jd;exports.parseSourceString=lp;exports.pct=Os;exports.periodLevel=Vp;exports.pickReaderVersion=Zc;exports.readStoredLayout=tj;exports.readStoredTheme=Q1;exports.readerVersionOptionLabel=po;exports.remapPlainOffsets=Ad;exports.removeRecentId=Ic;exports.renderFullTextBody=Wh;exports.renderProperNames=Rd;exports.renderReaderInline=gr;exports.resolveRecentEntry=Yo;exports.resourceHref=Dn;exports.resourceNote=or;exports.resultTabFromParam=Ig;exports.resultTabToParam=Lg;exports.roleFacets=jc;exports.rowNo=jh;exports.sameFilters=Sg;exports.sanitizeHeadings=vo;exports.saveRecentId=ro;exports.segmentEntities=Md;exports.shelfColumns=Dp;exports.sortFor=jg;exports.sortYear=Yi;exports.spineHeight=Up;exports.splitFullTextTables=is;exports.splitHighlightSnippet=Eo;exports.splitTableRow=wd;exports.storeLayout=nj;exports.storeTheme=_u;exports.stringifySources=cp;exports.summaryFromEntry=Fd;exports.summaryFromItem=Wd;exports.timelineLayout=su;exports.toCatalogWorkCard=w1;exports.transportSummaryLoader=Hd;exports.typeSupportsFilters=zc;exports.useBidUrl=kt;exports.useChapterWarpData=Xd;exports.useConvert=Ge;exports.useEntitySummaryLoader=ys;exports.useI18n=ae;exports.useReaderPrefs=Xc;exports.useRecentEntries=lu;exports.useT=Ae;exports.validateLineageGraph=Xm;exports.volumeStats=Qi;exports.withDefaultLinks=gn;exports.withMetaLinks=fn;exports.yearText=Ji;
|
|
2084
|
+
`,cu={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function gn(e){return{...cu,...e??{}}}function du(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 Ds(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function pu(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 m=Number.isFinite(p.birth_year)?p.birth_year:p.death_year-50,g=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(m,g),Math.max(m,g)]},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,m)=>({p,from:s[m][0],to:s[m][1]})).sort((p,m)=>p.from-m.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 tr(e,n=Gn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function R1(e){return{read:e.item,work:e.item,node:e.node}}function uu({counts:e,links:n}){const{t:i}=oe(),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:bt(d)})]})},a))})}function mu(e,n=5){const[i,o]=h.useState(null);h.useEffect(()=>{let a=!1;const l=un().slice(0,n);if(!l.length||!e){o([]);return}return Promise.all(l.map(d=>Jo(e,d))).then(d=>{a||o(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=h.useCallback(()=>{Zo(),o([])},[]);return{entries:i,clear:s}}function E1(e,n,i){const o=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return o?i(o):gu(e.type,n)}function gu(e,n){return n(`metaHome.typeLabel.${e}`)}function hu({entries:e,onClear:n,links:i}){const{t:o,convert:s}=oe(),a=gn(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?gu(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:E1(l,o,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:o("metaHome.recentEmpty")})]})}function fu(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 xu({rows:e,links:n}){const{t:i,convert:o}=oe(),s=gn(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=Ds(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:bt(a.total)}),t.jsx("td",{className:"bim-mh-r",children:bt(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:fu(a.status,i,o)})})]},a.id||a.name)})})]})}):null}function bu({items:e,links:n,label:i}){const{convert:o}=oe();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 yu({works:e,links:n}){const{t:i}=oe(),[o,s]=h.useState(!1);if(!e.length)return null;const a=hi(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(bu,{items:e.map(l=>({id:l.id,title:l.title,sub:vr(l)||void 0})),links:gn(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 ju="siku_qige";function I1({group:e,links:n}){const{t:i,convert:o}=oe(),[s,a]=h.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":hi(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(bu,{items:e.items,links:n,label:e.label}),hi(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 vu({groups:e,links:n}){const{t:i,convert:o}=oe(),s=gn(n);if(!e.length)return null;const a=e.find(c=>c.key===ju),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(I1,{group:c,links:s},c.key))})]})}const Ql=34,ec=13;function tc(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?tr(e.birth_year,n):"?"}–${e.death_year!=null?tr(e.death_year,n):"?"}`}function L1(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 ku({people:e,links:n}){const{t:i,convert:o}=oe(),s=gn(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=pu(e),p=[],m=d.map(u=>{const f=u.left>70,x=f?Math.min(u.left,u.left+u.width-ec):u.left;let j=0;for(;p[j]!=null&&p[j]>x;)j++;return p[j]=f?u.left+u.width:u.left+Math.max(u.width,ec),{...u,lane:j,end:f}}),g=Math.max(1,l-a);return t.jsxs(t.Fragment,{children:[m.length>0&&t.jsxs("div",{className:"bim-mh-tl",children:[t.jsx("ul",{className:"bim-mh-tl-rows",style:{height:p.length*Ql+10},children:m.map(u=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":u.end?"":void 0,style:{left:`${u.left}%`,top:u.lane*Ql+4,width:`${Math.max(u.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(u.p.id),children:[o(u.p.name),t.jsx("small",{className:"bim-rh-num",children:tc(u.p,i)})]})]},u.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:L1(a,l).map(u=>t.jsx("span",{style:{left:`${(u-a)/g*100}%`},children:tr(u,i)},u))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":m.length?void 0:"",children:(m.length?e:c).map(u=>t.jsx("li",{children:t.jsxs("a",{href:s.item(u.id),children:[t.jsx("span",{children:o(u.name)}),t.jsx("small",{className:"bim-rh-num",children:[u.dynasty?o(u.dynasty):"",tc(u,i)].filter(Boolean).join(" ")})]})},u.id))}),c.length>0&&m.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:i("metaHome.missingLife",{names:o(c.map(u=>u.name).join("、"))})})]})}const M1=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 wu({works:e,links:n}){const{t:i,convert:o}=oe(),s=gn(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=vr(a);return t.jsx("li",{children:t.jsxs("a",{href:du(s,a.id),children:[M1,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 Su({sites:e}){const{t:n,convert:i}=oe(),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=Ds(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:[`${bt(a.imported)} / ${bt(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:fu(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 nc=["extant","partially_extant","lost","unknown"];function $u({stats:e,links:n,version:i,repoUrl:o,downloadHref:s}){const{t:a}=oe(),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=nc.some(p=>{var m;return(((m=e.loss)==null?void 0:m[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,m])=>t.jsxs("li",{children:[t.jsx("b",{className:"bim-rh-num",children:bt(p)}),t.jsx("span",{children:m})]},m))})]}),d&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.byLoss")}),t.jsx("ul",{className:"bim-mh-loss",children:nc.map(p=>{var u;const m=((u=e.loss)==null?void 0:u[p])??0,g=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&&m>0?a("metaHome.lossCount",{n:bt(m),note:g}):g})]})},p)})})]}),t.jsxs("div",{className:"bim-mh-lic",children:[t.jsxs("p",{children:[t.jsx("span",{className:"bim-mh-cc0",children:"CC BY-SA 4.0"}),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 _u={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function A1({sections:e,links:n,head:i,transport:o,catalogHref:s,collectionsHref:a,entitiesHref:l,version:d,repoUrl:c,downloadHref:p,className:m}){var k,_;const{t:g}=oe(),u=e,f=gn(n),x=R1(f),j=_u,y=mu(o),S={zhi:!!((k=u.shelf)!=null&&k.items.length)||u.catalog_progress.length>0||u.related_catalogs.length>0,sibu:u.bu.length>0||u.unclassified>0,cong:u.collection_groups.length>0,people:u.bibliographers.length>0,lineage:u.lineage.length>0,sites:u.sites.length>0,data:!0},b=Object.keys(j).filter($=>S[$]),v=$=>g(`metaHome.nav.${$}`),w=($,C)=>$?t.jsx("a",{className:"bim-rh-more",href:$,children:C}):void 0;return t.jsxs("div",{className:m?`bim-rh bim-mh ${m}`:"bim-rh bim-mh",children:[t.jsx("style",{children:Os+lu}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[i,t.jsx(uu,{counts:u.counts,links:n})]}),o&&t.jsx(hu,{entries:y.entries,onClear:y.clear,links:n})]}),b.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":g("metaHome.navLabel"),children:t.jsx("ul",{children:b.map($=>t.jsx("li",{children:t.jsx("a",{href:`#${j[$]}`,children:v($)})},$))})}),t.jsxs("div",{className:"bim-rh-main",children:[S.zhi&&t.jsxs(Rt,{id:j.zhi,title:v("zhi"),sub:g("metaHome.zhiSub"),children:[u.shelf&&u.shelf.items.length>0&&t.jsx(Fs,{topic:{key:"shelf",label:u.shelf.label,shelf:!0,items:u.shelf.items},links:x,showTitle:!1,legendCount:u.shelf.items.some($=>$.records)?g("metaHome.shelfLegendCount"):null,legendExtra:[g("metaHome.shelfLegendClick")]}),(u.catalog_progress.length>0||u.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:(_=u.shelf)!=null&&_.items.length?void 0:{marginTop:0},children:[t.jsx(xu,{rows:u.catalog_progress,links:n}),t.jsx(yu,{works:u.related_catalogs,links:n})]})]}),S.sibu&&t.jsx(Rt,{id:j.sibu,title:v("sibu"),sub:g("metaHome.sibuSub"),more:w(s,g("metaHome.toCatalog")),children:t.jsx(Hs,{bu:u.bu,unclassified:u.unclassified,links:x,unclassifiedNote:g("metaHome.unclassifiedNote")})}),S.cong&&t.jsx(Rt,{id:j.cong,title:v("cong"),sub:g("metaHome.congSub"),more:w(a,g("metaHome.allNKindsMore",{n:bt(u.counts.collections)})),children:t.jsx(vu,{groups:u.collection_groups,links:n})}),S.people&&t.jsx(Rt,{id:j.people,title:v("people"),sub:g("metaHome.peopleSub"),more:w(l,g("metaHome.allNPeopleMore",{n:bt(u.counts.entities)})),children:t.jsx(ku,{people:u.bibliographers,links:n})}),S.lineage&&t.jsx(Rt,{id:j.lineage,title:v("lineage"),sub:g("metaHome.lineageSub"),children:t.jsx(wu,{works:u.lineage,links:n})}),S.sites&&t.jsx(Rt,{id:j.sites,title:v("sites"),sub:g("metaHome.sitesSub"),children:t.jsx(Su,{sites:u.sites})}),t.jsx(Rt,{id:j.data,title:v("data"),sub:g("metaHome.dataSub"),children:t.jsx($u,{stats:u.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const Cu=["_related","_catalogs","_collections","_members","_children"],P1=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Io=e=>P1(e)&&!!e.h;function B1(e){return e?Cu.some(n=>{const i=e[n];return Array.isArray(i)&&i.some(Io)}):!1}function O1(e,n){const i={...e};if(!n)return i;for(const o of Cu){const s=e[o];!Array.isArray(s)||!s.some(Io)||(i[o]=s.map(a=>{var c;if(!Io(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 W1(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&&O1(d,B1(d)?await i():null)};const a=Reflect.get(o,s,o);return typeof a=="function"?a.bind(o):a}})}const Lo=({style:e})=>{const n=h.useContext(qt),{t:i}=oe();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")})]})},Mo=({href:e,label:n,size:i=16,className:o,style:s})=>{const{t:a}=oe(),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 oo(e){const n=e.text_count;return typeof n=="number"&&n>0}function so(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function F1(e,n){if(!n)return!1;const i=n.id;return i===void 0||i===e}const H1=({id:e,transport:n,initialDetail:i,initialEntry:o,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:m,onLineageCollectionChange:g,initialPage:u=1,selectedLineageNodeId:f,onNavigate:x,onBack:j,backLabel:y,renderLink:S,assetBase:b,enrichDetail:v,getSourceLink:w,readLink:k,railTop:_,extraTabs:$=[],showFeedbackTab:C=!0,feedbackApiUrl:L,height:E,footerExtra:T,hideHeaderControls:N=!1,className:W,style:F})=>{const R=h.useMemo(()=>W1(n),[n]),G=Be(),{t:Q,convert:ie}=oe(),[de]=h.useState(()=>{if(!F1(e,i))return null;const Z={...i},$e=o??so(e,Z);return v&&v($e,Z),{id:e,entry:$e,detail:Z}}),[q,ee]=h.useState((de==null?void 0:de.entry)??null),[U,se]=h.useState((de==null?void 0:de.detail)??null),[pe,_e]=h.useState(!de),[Le,Ee]=h.useState(!1),[ue,be]=h.useState([]),[A,K]=h.useState(!1),[le,M]=h.useState(null),[J,ye]=h.useState(null),[je,Ue]=h.useState(null),[H,me]=h.useState(!1),ge=h.useRef(null),ne=h.useRef(0),[Ne,he]=h.useState(null),Ce=l!==void 0?l:Ne,Ie=h.useCallback(Z=>{d?d(Z):he(Z)},[d]),Qe=h.useCallback(async Z=>{if(!R.getCollectionCatalogs&&!R.getCollectionCatalog){be([]);return}K(!0);try{if(R.getCollectionCatalogs)be(await R.getCollectionCatalogs(Z)||[]);else if(R.getCollectionCatalog){const $e=await R.getCollectionCatalog(Z);be($e?[{resource_id:"",data:$e}]:[])}}catch{be([])}finally{K(!1)}},[R]),gt=h.useCallback(async Z=>{var $e,ke;if(!R.getTextManifest||!R.getTextIndex){M(null),ye(Z);return}try{const Ye=xe.pickTextVersion(await R.getTextManifest(Z)),We=Ye?await R.getTextIndex(Z,Ye.key):null;M(We&&We.chapters.length>0?{chapters:We.chapters.map(De=>({n:De.n,title:De.title,file:De.file})),source:{name:(($e=We.source)==null?void 0:$e.name)??(Ye==null?void 0:Ye.source_name),license:((ke=We.source)==null?void 0:ke.license)??(Ye==null?void 0:Ye.license)??void 0}}:null)}catch{M(null)}finally{ye(Z)}},[R]),lt=h.useCallback(async(Z,$e)=>{const ke=++ne.current,Ye=()=>ke!==ne.current;me(!0);try{if(R.getLineageGraph){const V=await R.getLineageGraph(Z);if(Ye())return;V&&Ue(V)}const We=$e.version_graph;if(!We||!We.enabled){je||Ue(null),ge.current=null;return}const De=Ko($e),ct=(await yr(De,br,async V=>{try{return await R.getItem(V)}catch{return null}},Ye)).filter(Boolean);if(Ye())return;ge.current={work:$e,books:ct};const yt=m??We.default_collection??(We.core_books&&We.core_books.length>0?"core":"all"),Xe=yt==="core"&&Array.isArray(We.core_books)&&We.core_books.length>0?"core":yt??"all";Ue(Oi($e,ct,Xe))}catch{if(Ye())return;Ue(null),ge.current=null}finally{Ye()||me(!1)}},[R]),tt=h.useRef({initialDetail:i,initialEntry:o});tt.current={initialDetail:i,initialEntry:o},h.useEffect(()=>{let Z=!1;ne.current++,me(!1);const $e=De=>{De.type==="collection"?Qe(e):De.type==="work"?(De.version_graph||R.getLineageGraph)&<(e,De):De.type==="book"&&oo(De)&>(e)},ke=tt.current;let Ye=null;if(de&&de.id===e)Ye=de;else if(ke.initialDetail&&ke.initialDetail.id===e){const De={...ke.initialDetail},ht=ke.initialEntry??so(e,De);v&&v(ht,De),Ye={entry:ht,detail:De}}return Ye?(Ee(!1),be(De=>De.length?[]:De),M(null),Ue(null),ge.current=null,ee(Ye.entry),se(Ye.detail),_e(!1),$e(Ye.detail),()=>{Z=!0}):((async()=>{_e(!0),Ee(!1),ee(null),se(null),be([]),M(null),Ue(null),ge.current=null;try{const De=await R.getItem(e);if(Z)return;if(!De){Ee(!0);return}const ht=De;let ct=null;if(R.getEntry&&(ct=await R.getEntry(e),Z))return;ct||(ct=so(e,ht)),v&&v(ct,ht),ee(ct),se(ht),$e(ht)}catch{Z||Ee(!0)}finally{Z||_e(!1)}})(),()=>{Z=!0})},[e,R,de,v,Qe,lt,gt]),h.useEffect(()=>{const Z=ge.current;!Z||!m||Ue(Oi(Z.work,Z.books,m))},[m]);const Oe=[];if(U){if(Oe.push({key:"basic",label:G.detailTab.basicInfo}),U.type==="collection"){A&&ue.length===0&&Oe.push({key:"catalog:loading",label:`${G.detailTab.catalog}…`});for(const Z of ue)Oe.push({key:`catalog:${Z.resource_id}`,label:Z.short_name?`${ie(Z.short_name)}${G.detailTab.catalogSuffix}`:G.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&Oe.push({key:s,label:G.detailTab.fullText}),U.type==="work"&&(je||H)&&Oe.push({key:"lineage",label:H?`${G.detailTab.lineage}…`:G.detailTab.lineage});for(const Z of $)(Z.position??"before-feedback")==="before-feedback"&&Z.shouldShow(U)&&Oe.push({key:Z.key,label:Z.label});C&&s==="feedback"&&Oe.push({key:"feedback",label:G.detailTab.feedback});for(const Z of $)Z.position==="after-feedback"&&Z.shouldShow(U)&&Oe.push({key:Z.key,label:Z.label})}h.useEffect(()=>{if(s!=="emendated"||!U)return;a("basic");const Z=setTimeout(()=>{var $e;($e=document.getElementById("studies"))==null||$e.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(Z)},[s,U,a]);const z=q&&U&&w?w({activeTab:s,activeJuan:Ce,entry:q,detail:U}):null,re=h.useMemo(()=>{var We,De,ht,ct,yt;if(!U)return null;const $e=(U.authors??[]).map(Xe=>{const V=Yo(Xe.role);return`${Xe.dynasty?`〔${ie(Xe.dynasty)}〕`:""}${ie(Xe.name)}${V?` ${ie(V)}`:""}`}).join(" · ");let ke=!1;try{ke=xe.extractStatus(U.id)==="draft"}catch{}if(U.type==="book"){const Xe=U;return{title:ie(Xe.title),subtitle:Xe.edition?ie(Xe.edition):$e||void 0,aside:[ke?G.status.draft:"",$e&&Xe.edition?$e:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(U.type==="collection"){const Xe=U;return{title:ie(Xe.title),subtitle:ie(sn(Xe,G.unit.juan))||void 0,aside:[(We=Xe.publication_info)==null?void 0:We.year,ke?G.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:$e||void 0}}if(U.type==="entity"){const Xe=U,V=B=>B==null?"":B<0?Q("detail.bce",{n:-B}):String(B),D=((De=Xe.dates)==null?void 0:De.birth)!=null||((ht=Xe.dates)==null?void 0:ht.death)!=null?`${V(((ct=Xe.dates)==null?void 0:ct.birth)??void 0)||"?"}—${V(((yt=Xe.dates)==null?void 0:yt.death)??void 0)||"?"}`:"";return{title:ie(Xe.primary_name||Xe.title),subtitle:[Xe.dynasty?`〔${ie(Xe.dynasty)}〕`:"",D].filter(Boolean).join(" ")||void 0,aside:ke?G.status.draft:void 0,secondLine:void 0}}const Ye=ie(sn(U,G.unit.juan));return{title:ie(U.title),subtitle:[Ye,$e].filter(Boolean).join(" · ")||void 0,aside:[U1(G,U.subtype),ke?G.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[U,ie,G,Q]),te=U&&oo(U)?"text":null,fe=()=>{Ie(null),a("fulltext")};let Me=null;if(U&&k){const Z=k({detail:U,kind:te});Z&&(Me=t.jsx(bo,{href:Z}))}else te&&(Me=t.jsx(bo,{onClick:fe}));const P=Z=>{if(!U)return null;const $e=Z.replace(/\.[^.]+$/,"");if(k){const ke=k({detail:U,kind:te,juan:$e});return ke?{href:ke}:null}return{onClick:()=>{Ie($e),a("fulltext")}}},ce=new Set($.map(Z=>Z.key)),X=Oe.filter(Z=>Z.key.startsWith("catalog:")&&Z.key!=="catalog:loading"||Z.key==="lineage"&&!!je&&!H||ce.has(Z.key)).map(Z=>({key:Z.key,label:Z.label,onClick:()=>a(Z.key)})),Te=()=>{var Z;return U?U.type==="work"?t.jsx(Tp,{data:U,transport:R,onNavigate:x,renderLink:S,readAction:Me,railTop:_,railLinks:X}):U.type==="book"?t.jsx(Ip,{data:U,transport:R,onNavigate:x,renderLink:S,readAction:Me,fullText:le,fullTextPending:oo(U)&&!!R.getTextManifest&&J!==U.id,chapterLink:P,railTop:_,railLinks:X}):U.type==="collection"?t.jsx(Lp,{data:U,catalog:(Z=ue[0])==null?void 0:Z.data,transport:R,onNavigate:x,renderLink:S,readAction:Me,railTop:_,railLinks:X,catalogAction:ue.length>0?t.jsxs("a",{href:"#catalog",onClick:$e=>{$e.preventDefault(),a(`catalog:${ue[0].resource_id}`)},children:[ie(G.detailTab.collectionCatalog)," →"]}):null}):t.jsx(Pp,{data:U,transport:R,onNavigate:x,renderLink:S,railTop:_,railLinks:X,assetBase:b}):null},Se=()=>{var $e,ke,Ye;if(!q||!U)return null;if(s==="basic"||s==="emendated")return Te();if(typeof s=="string"&&s.startsWith("catalog:")){const We=($e=ue.find(De=>`catalog:${De.resource_id}`===s))==null?void 0:$e.data;return t.jsx(es,{data:We,onNavigate:x,renderLink:S})}if(s==="collated"||s==="fulltext")return t.jsx(Ts,{id:e,transport:R,chapter:Ce,onLocationChange:We=>Ie(We.chapter),onNavigate:x});if(s==="lineage"){if(!je)return t.jsx("div",{style:{color:r("label-fg"),padding:"24px 0"},children:Q(H?"detail.loading":"detail.noLineageGraph")});const We=U.type==="work"?U:null;return t.jsx(Ms,{graph:je,renderLink:S,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:f,collection:m??((ke=We==null?void 0:We.version_graph)==null?void 0:ke.default_collection),onCollectionChange:g,collectionsAvailable:(Ye=We==null?void 0:We.version_graph)==null?void 0:Ye.collections,collectionCounts:(()=>{var yt,Xe,V,D,B,ve,Re;if(!We)return;const De={},ht=((yt=ge.current)==null?void 0:yt.books)??[];De.all=(((Xe=We._books)==null?void 0:Xe.length)??0)-(((D=(V=We.version_graph)==null?void 0:V.excluded_books)==null?void 0:D.length)??0);const ct=(B=We.version_graph)==null?void 0:B.collections;if(ct)for(const Ae of Object.keys(ct))De[Ae]=Oi(We,ht,Ae).nodes.filter(Je=>Je.kind==="book"&&!Je.bridge).length;return De.core==null&&((Re=(ve=We.version_graph)==null?void 0:ve.core_books)!=null&&Re.length)&&(De.core=We.version_graph.core_books.length),De})()})}if(s==="feedback"&&C)return t.jsx(_p,{resourceId:e,apiUrl:L});const Z=$.find(We=>We.key===s);return Z?Z.render({detail:U,entry:q,transport:R,onNavigate:x}):null};if(pe)return t.jsx(li,{style:{minHeight:E,...F},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((Z,$e)=>t.jsx("div",{style:{height:$e===1?40:16,width:Z,opacity:.35,background:r("rule")}},$e))})});if(Le||!U||!q||!re)return t.jsx(li,{style:{minHeight:E,...F},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:r("label-fg"),fontSize:14},children:Q("detail.notFound")})});const ze=s==="basic"||s==="emendated",qe=[{label:y??G.detailTab.backToIndex,onClick:j}];if(U.type==="book"&&U.work_id){const Z=U.work_id;qe.push({label:G.indexType.work,id:Z,onClick:()=>x==null?void 0:x(Z)})}qe.push({label:G.indexType[U.type]});const Pe=s==="collated"||s==="fulltext",it=typeof T=="string"?G.status[T.trim()]??T:T,pt=t.jsx(Nd,{left:t.jsxs(t.Fragment,{children:[it,it?" · ":"",t.jsx(D1,{id:U.id,label:G.label.id,copied:G.action.copied,copyLabel:G.action.copy})]}),right:t.jsxs(t.Fragment,{children:[C&&!ze&&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:G.detailTab.submitVersion}),z&&t.jsx("a",{href:z.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:r("meta-fg")},children:G.detailTab.dataLicense})]})});return ze?t.jsx("div",{className:W,children:t.jsxs(li,{grid:!0,style:{minHeight:E,...F},children:[t.jsx(yo,{breadcrumb:t.jsx(jo,{items:qe}),actions:t.jsxs(t.Fragment,{children:[!N&&t.jsx(Lo,{style:{border:"none",background:"transparent"}}),!N&&z&&t.jsx(Mo,{...z})]})}),Te(),pt]})}):t.jsx("div",{className:W,children:t.jsxs(li,{wide:Pe,style:{minHeight:E,...F},children:[t.jsx(yo,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(ss,{char:"籍"}),t.jsx(jo,{items:qe})]}),actions:t.jsxs(t.Fragment,{children:[!N&&t.jsx(Lo,{}),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:G.detailTab.feedback}),!N&&z&&t.jsx(Mo,{...z})]})}),t.jsx(yd,{...re,aside:Pe?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:[Q("detail.workInfo")," →"]}):re.aside}),!Pe&&Oe.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:Oe.map(Z=>t.jsx(jd,{label:Z.label,active:Z.key===s||ze&&Z.key==="basic",onClick:()=>a(Z.key)},Z.key))}),t.jsx("div",{style:{marginTop:!Pe&&Oe.length>1?8:0},children:Se()}),pt]})})};function D1({id:e,label:n,copied:i,copyLabel:o}){const[s,a]=h.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 U1(e,n){return n?e.workSubtype[n]??n:""}const zu=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],kr="zhusha",wr="bim-theme";function Nu(e){return e==="zhusha"||e==="indigo"||e==="ink"}function Sr(e){return Nu(e)?e:kr}function V1(){try{return Sr(window.localStorage.getItem(wr))}catch{return kr}}function Tu(e){try{window.localStorage.setItem(wr,e)}catch{}}function Ru(e){const n=Sr(e);return document.documentElement.setAttribute("data-theme",n),n}function Eu(){return Sr(document.documentElement.getAttribute("data-theme"))}const G1=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Us="airy",$r="bim-layout";function Iu(e){return e==="airy"||e==="boxed"}function _r(e){return Iu(e)?e:Us}function Y1(){try{return _r(window.localStorage.getItem($r))}catch{return Us}}function K1(e){try{window.localStorage.setItem($r,e)}catch{}}function q1(e){const n=_r(e);return document.documentElement.setAttribute("data-layout",n),n}function X1(){return _r(document.documentElement.getAttribute("data-layout"))}const Z1=`try{var t=localStorage.getItem(${JSON.stringify(wr)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify($r)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,J1={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},Q1=({onChange:e,style:n})=>{const{t:i}=oe(),[o,s]=h.useState(kr);h.useEffect(()=>{s(Eu())},[]);const a=l=>{s(Ru(l)),Tu(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":i("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:zu.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(J1[l.name]),boxShadow:d?`0 0 0 2px ${r("page-bg")}, 0 0 0 3.5px ${r("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=xe.BidLink;exports.BookIndexError=xe.BookIndexError;exports.BookIndexManager=xe.BookIndexManager;exports.BookIndexStorage=xe.BookIndexStorage;exports.BundleStorage=xe.BundleStorage;exports.ConfigError=xe.ConfigError;exports.GithubStorage=xe.GithubStorage;exports.IdGenerationError=xe.IdGenerationError;exports.IdGenerator=xe.IdGenerator;exports.LocalStorage=xe.LocalStorage;exports.MigrationError=xe.MigrationError;exports.StorageError=xe.StorageError;exports.VARIANT_CHARS=xe.VARIANT_CHARS;exports.adaptCharCord=xe.adaptCharCord;exports.adaptFig=xe.adaptFig;exports.adaptNorm=xe.adaptNorm;exports.adaptNormDetailed=xe.adaptNormDetailed;exports.adaptPunctJson=xe.adaptPunctJson;exports.base36Decode=xe.base36Decode;exports.base36Encode=xe.base36Encode;exports.base58Decode=xe.base58Decode;exports.buildId=xe.buildId;exports.buildPromotionMap=xe.buildPromotionMap;exports.cleanName=xe.cleanName;exports.decodeId=xe.decodeId;exports.decodeIdString=xe.decodeIdString;exports.encodeId=xe.encodeId;exports.extractIdFromUrl=xe.extractIdFromUrl;exports.extractStatus=xe.extractStatus;exports.extractType=xe.extractType;exports.iiifVolumeOf=xe.iiifVolumeOf;exports.isChapterSegment=xe.isChapterSegment;exports.isTextKey=xe.isTextKey;exports.loadFigUrls=xe.loadFigUrls;exports.loadReaderChapter=xe.loadReaderChapter;exports.loadReaderFiles=xe.loadReaderFiles;exports.matchChapterAcrossVersions=xe.matchChapterAcrossVersions;exports.normalizeCatalog=xe.normalizeCatalog;exports.normalizeVariants=xe.normalizeVariants;exports.parseId=xe.parseId;exports.pickTextVersion=xe.pickTextVersion;exports.readerManifest=xe.readerManifest;exports.readerVersions=xe.readerVersions;exports.shardOf=xe.shardOf;exports.smartDecode=xe.smartDecode;exports.textVersionLabel=xe.textVersionLabel;exports.validateResource=xe.validateResource;exports.volumeFromChar=xe.volumeFromChar;exports.VARIANT_SUPPLEMENT=ic.VARIANT_SUPPLEMENT;exports.Badge=er;exports.BidUrlProvider=am;exports.BookDetailLayout=H1;exports.BookPage=Ip;exports.Breadcrumb=jo;exports.CATALOG_ALL_ID=nn;exports.CATALOG_CSS=Bp;exports.CATALOG_NARROW_QUERY=As;exports.CATALOG_PAGE_SIZE=Ps;exports.CATALOG_UNCLASSIFIED_ID=jn;exports.CLASSIFICATIONS=ur;exports.COMMON_TRADITIONAL_CHARS=gc;exports.CardFoot=yi;exports.CatalogPage=k1;exports.CatalogPager=Vp;exports.CatalogTree=Wp;exports.CheckFilter=fd;exports.Chip=vd;exports.ChipWall=jf;exports.CollectionCatalog=es;exports.CollectionPage=Lp;exports.CreateEntityDialog=bp;exports.DEFAULT_LAYOUT=Us;exports.DEFAULT_META_HOME_LINKS=cu;exports.DEFAULT_READER_PREFS=ns;exports.DEFAULT_READ_HOME_LINKS=Yp;exports.DEFAULT_THEME=kr;exports.DETAIL_CSS=bd;exports.DYNASTY_GROUPS=pr;exports.Dash=_f;exports.DataTable=kf;exports.DetailFooter=Nd;exports.DetailGrid=xi;exports.DetailHeader=yd;exports.EMPTY_FILTERS=dr;exports.ENTITY_TEXT_CSS=ks;exports.EmendatedBySection=Kc;exports.EmptyNote=If;exports.EntityDetail=Dc;exports.EntityMark=$s;exports.EntityPage=Pp;exports.EntityPickerDialog=jp;exports.EntitySelector=xp;exports.EntityText=ib;exports.ExpandRow=Cf;exports.ExtLink=Lf;exports.FEEDBACK_FAB_OFFSET_VAR=No;exports.FILTER_SUPPORT=Lc;exports.FONT_SIZE_STEPS=tn;exports.FactList=ff;exports.FeedbackButton=r0;exports.FeedbackDialog=Sp;exports.FeedbackForm=$p;exports.FeedbackList=Rs;exports.FeedbackTab=_p;exports.FilterChip=jd;exports.FormInput=At;exports.FormTextArea=kn;exports.GUJI_MARKDOWN_FIELD=ef;exports.GUJI_TABLE_NOTATION=Td;exports.GlyphBadge=ss;exports.GujiInteractiveReader=ly;exports.GujiTable=cs;exports.GujiTextViewer=Cs;exports.GujiWarpCanvas=vs;exports.HomePage=Co;exports.ImagePanel=go;exports.IndexApp=ay;exports.IndexBrowser=po;exports.IndexDetail=Qo;exports.IndexEditor=vp;exports.IndexView=Uy;exports.IntroGrid=hf;exports.LAYOUTS=G1;exports.LAYOUT_STORAGE_KEY=$r;exports.LOSS_OPTIONS=Ic;exports.LocaleContext=qt;exports.LocaleProvider=Am;exports.LocaleToggle=Lo;exports.META_HOME_CSS=lu;exports.META_HOME_SECTION_IDS=_u;exports.MetaCatalogTable=xu;exports.MetaCollectionGroups=vu;exports.MetaDataLicense=$u;exports.MetaHomeView=A1;exports.MetaLine=vt;exports.MetaLineageCards=wu;exports.MetaOnlineSites=Su;exports.MetaPeopleTimeline=ku;exports.MetaRecentPanel=hu;exports.MetaRelatedCatalogs=yu;exports.MetaTypeChips=uu;exports.ModeIndicator=fc;exports.MoreButton=yf;exports.MoreLink=rs;exports.PAGE_MAX_WIDTH=Di;exports.PERIOD_NARROW_SHARE=Zp;exports.PageFrame=li;exports.Quote=Nf;exports.READER_CSS=Qc;exports.READ_HOME_CSS=Os;exports.READ_HOME_NARROW_QUERY=ki;exports.READ_HOME_SECTION_IDS=au;exports.READ_PERIOD_LABELS=_1;exports.RECENT_IDS_STORAGE_KEY=Fn;exports.ROLE_CLASS_ORDER=Cc;exports.ReadButton=bo;exports.ReadFamousWorks=ru;exports.ReadHomeView=z1;exports.ReadPeriodBand=ou;exports.ReadPicks=eu;exports.ReadPieces=su;exports.ReadSection=Rt;exports.ReadShelf=Fs;exports.ReadSibu=Hs;exports.ReadStats=Qp;exports.ReadTopicGroup=nu;exports.ReadTopics=iu;exports.ReaderMdText=ms;exports.ReaderShell=ad;exports.ReaderToc=ed;exports.RelationPanel=hp;exports.RepoSourceLink=Mo;exports.ResourceEditor=ao;exports.ResourceGroup=Tf;exports.ResourceLine=Rf;exports.ResourceList=Ho;exports.ResourceRow=_d;exports.SEARCH_VIEW_STORAGE_KEY=Xo;exports.SEVEN_PAVILIONS_KEY=ju;exports.SNIPPET_MARK_END=sc;exports.SNIPPET_MARK_START=oc;exports.SORTABLE_TYPES=Ec;exports.SearchInput=bc;exports.SearchResults=Wc;exports.Sec=St;exports.Section=Dt;exports.SectionHead=xf;exports.SideList=vn;exports.SmartBidInput=Yi;exports.SourceEditor=up;exports.StripWarpRenderer=vo;exports.SummaryCard=bi;exports.THEMES=zu;exports.THEME_INIT_SCRIPT=Z1;exports.THEME_STORAGE_KEY=wr;exports.TRADITIONAL_ALLOWLIST=hc;exports.TabFilter=gr;exports.TableHead=wf;exports.TableRow=Sf;exports.TagRow=Cd;exports.TagRows=Ef;exports.TextButton=bf;exports.TextReader=Ts;exports.ThemeToggle=Q1;exports.TopStrip=yo;exports.VersionLineageGraph=Ep;exports.VersionLineageList=Rp;exports.VersionLineageView=Ms;exports.VolumeChips=vf;exports.VolumeLinks=as;exports.WorkCard=Dp;exports.WorkCardGrid=Gp;exports.WorkCatalog=cy;exports.WorkPage=Tp;exports.WorkRow=Up;exports.adaptEntityJson=Hd;exports.applyLayout=q1;exports.applyTheme=Ru;exports.authorsLine=vr;exports.bookIndexUriToId=$n;exports.bookMarkingOf=us;exports.bucketResources=Vo;exports.buildCatalogTree=m1;exports.buildCollectionTable=Tc;exports.buildLineageGraph=Oi;exports.buildMeiliFilter=Cg;exports.buildPageUrl=Wo;exports.buildParagraphBlocks=Pd;exports.buildVersionRow=$c;exports.buildVersionTable=_c;exports.canParagraphize=Ji;exports.catalogNodeIdOf=p1;exports.catalogNodeIdsOf=u1;exports.catalogPageCount=x1;exports.catalogTotal=Bs;exports.classificationPath=vi;exports.clearAllRecentIds=Zo;exports.compareCatalogCards=f1;exports.computeVersionPartition=bg;exports.countActiveFilters=mr;exports.createTextApi=Xc;exports.currentLayout=X1;exports.currentTheme=Eu;exports.defaultEntityHref=Jd;exports.defaultWorkLink=Fp;exports.deriveDating=pg;exports.deriveEditionType=Rc;exports.deriveEra=fi;exports.deriveYear=ar;exports.deriveYearRange=Uo;exports.detailToEditor=wp;exports.detectGenre=fr;exports.displayAuthorRole=Yo;exports.editorToDetail=Dy;exports.eraRank=lo;exports.filtersFromParams=zg;exports.filtersToParams=Zi;exports.findCatalogPath=Bn;exports.findTraditionalChars=Om;exports.firstAuthorText=Ws;exports.flattenTitles=zd;exports.flattenToc=sd;exports.fmtCount=bt;exports.formatHitCount=Wi;exports.formatTemplate=Pt;exports.formatVolumeRange=cr;exports.getDisplayNameFromUrl=Dn;exports.getMessages=Vn;exports.getStartPage=Oo;exports.getT=Gn;exports.getTypeGroupKey=Po;exports.groupRelatedWorks=ug;exports.gujiInlineToPlain=gd;exports.hasActiveFilters=Mc;exports.hasGujiMarkdownV02=tf;exports.hasGujiTableNotation=Mf;exports.hasSearchOptions=Sg;exports.headingKey=Ns;exports.headingsFromPunct=op;exports.isCountedChar=gs;exports.isDuiduChapter=Gi;exports.isLayoutName=Iu;exports.isThemeName=Nu;exports.lineageHref=du;exports.loadRecentIds=un;exports.measureText=sn;exports.mergeVolumeResources=Bo;exports.nestHeadings=ap;exports.normalizeEra=Et;exports.normalizeLayout=_r;exports.normalizeRole=Go;exports.normalizeTheme=Sr;exports.normalizeVolumeIndex=di;exports.normalizeVolumes=cc;exports.numberToChinese=Sn;exports.paginationItems=Op;exports.parseChineseNumber=qi;exports.parseGujiInline=md;exports.parseGujiTable=Ed;exports.parseHeadingKey=sp;exports.parseSourceString=mp;exports.pct=Ds;exports.periodLevel=Xp;exports.pickReaderVersion=od;exports.readStoredLayout=Y1;exports.readStoredTheme=V1;exports.readerVersionOptionLabel=fo;exports.remapPlainOffsets=Dd;exports.removeRecentId=Fc;exports.renderFullTextBody=Vf;exports.renderProperNames=Wd;exports.renderReaderInline=xr;exports.resolveRecentEntry=Jo;exports.resourceHref=Un;exports.resourceNote=lr;exports.resultTabFromParam=Bg;exports.resultTabToParam=Og;exports.roleFacets=zc;exports.rowNo=$f;exports.sameFilters=Ng;exports.sanitizeHeadings=_o;exports.saveRecentId=co;exports.segmentEntities=Ud;exports.setImageSourceResolver=Xx;exports.shelfColumns=Kp;exports.sortFor=$g;exports.sortYear=Xi;exports.spineHeight=qp;exports.splitFullTextTables=ls;exports.splitHighlightSnippet=Ao;exports.splitTableRow=Rd;exports.storeLayout=K1;exports.storeTheme=Tu;exports.stringifySources=gp;exports.summaryFromEntry=qd;exports.summaryFromItem=Kd;exports.timelineLayout=pu;exports.toCatalogWorkCard=h1;exports.transportSummaryLoader=Xd;exports.typeSupportsFilters=Ac;exports.useBidUrl=kt;exports.useChapterWarpData=rp;exports.useConvert=Ge;exports.useEntitySummaryLoader=Ss;exports.useI18n=oe;exports.useReaderPrefs=rd;exports.useRecentEntries=mu;exports.useT=Be;exports.validateLineageGraph=tg;exports.volumeStats=nr;exports.withDefaultLinks=mn;exports.withMetaLinks=gn;exports.yearText=tr;
|