book-index-ui 0.56.1 → 0.57.0

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 CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Wp=Object.create;var fs=Object.defineProperty;var Op=Object.getOwnPropertyDescriptor;var Fp=Object.getOwnPropertyNames;var Hp=Object.getPrototypeOf,Dp=Object.prototype.hasOwnProperty;var Up=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Fp(n))!Dp.call(e,s)&&s!==i&&fs(e,s,{get:()=>n[s],enumerable:!(o=Op(n,s))||o.enumerable});return e};var oi=(e,n,i)=>(i=e!=null?Wp(Hp(e)):{},Up(n||!e||!e.__esModule?fs(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ke=require("./storage-entry-Cx6j1zcJ.cjs"),t=require("react/jsx-runtime"),g=require("react"),Vp=require("opencc-js/t2cn"),Qa=require("./variant-supplement.cjs"),Gp=require("react-markdown"),Yp=require("remark-gfm"),qp=e=>`/item/${e}`,el=g.createContext(qp);function Kp({buildUrl:e,children:n}){const i=g.useMemo(()=>e,[e]);return t.jsx(el.Provider,{value:i,children:n})}function rt(){return g.useContext(el)}const tl="",nl="";function Yr(e){const n=[];let i=!1,o=e;for(;o.length;){const s=i?nl:tl,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 pt(e,n){return{title:e,tokens:n}}const xs='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',Xp=[pt("基础(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"}}),pt("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),pt("提示与警告",{"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)"}}),pt("遮罩与阴影",{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)"}}),pt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),pt("资源",{"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"}}),pt("整理本(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:"中性灰:占位"}}),pt("版本传承(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"}}),pt("编辑器视图(主要在 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")'}}),pt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --bim-primary 等控件色",{"page-bg":{value:"#fbf9f3",note:"纸"},"row-hover-bg":{value:"#f5f1e5"},"selection-bg":{value:"#ecdcbc",note:"选区"},"band-bg":{value:"#f0e4cb",note:"全文入口横幅(暖沙)"},"band-bg-hover":{value:"#e6d5b4"},ink:{value:"#2a231c",note:"文字层次:墨 → 正文 → 提要 → meta → 标签 → 提示"},"body-fg":{value:"#3b3228"},"quiet-fg":{value:"#5b4f40"},"meta-fg":{value:"#7b6a54"},"label-fg":{value:"#6f6457",note:"标签 / 提示:2026-09 N3a 调深,纸底与斑马底上对比度均 ≥4.5(原 #a3937b 2.8、#b3a385 2.3)"},"hint-fg":{value:"#756a5e"},accent:{value:"#9c3a2c",note:"朱"},"accent-deep":{value:"#6f2a20",note:"链接 hover"},"rule-strong":{value:"#2a231c",note:"分隔线:强 → 常规 → 虚线 → 提要左线"},rule:{value:"#e4dbc9"},"rule-dashed":{value:"#d6c9ae"},"rule-accent-soft":{value:"#e0d3b6"},"aux-fg":{value:"#6f6457",note:"辅助字(元数据、注记、「·」分隔的浅色小字)。须在 page-bg / zebra-bg 上对比度 ≥4.5(Q5 巡检)"},"card-bg":{value:"#fffdf9",note:"提要卡:抬起的面"},"zebra-bg":{value:"#f6f2eb",note:"表格斑马纹 / 左栏分组底(不画格线,靠这一阶底色分行)"},"tint-bg":{value:"#f3eee6",note:"检索框、悬停"},"shadow-summary":{value:"0 10px 32px rgba(60, 50, 40, 0.07)",note:"提要卡投影"},"flag-bg":{value:"rgba(158, 42, 43, 0.08)",note:"唯一的状态色块「有影印」"},"theme-dot-zhusha":{value:"#9c3a2c",note:"主题切换控件的色点:朱砂(不随主题变,两套主题下都要认得出)"},"theme-dot-indigo":{value:"#2e5266",note:"主题切换控件的色点:靛青"},"theme-dot-ink":{value:"#3b4a58",note:"主题切换控件的色点:墨"},"sect-jing":{value:"#2e5266",note:"四部分布条:經部(人物页提要卡;无别处使用)"},"sect-shi":{value:"#9a7a3b",note:"四部分布条:史部"},"sect-zi":{value:"#4f7a5c",note:"四部分布条:子部"},"sect-ji":{value:"#9fb3bc",note:"四部分布条:集部"},"table-border":{value:"color-mix(in srgb, currentColor 28%, transparent)",root:!1,note:"古籍表格(跟随当前文字色)"},"table-head-bg":{value:"color-mix(in srgb, currentColor 8%, transparent)",root:!1}}),pt('版式(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"}}),pt("阅读器(整理本 / 全文)",{"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:"版心外边线"}}),pt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),pt("字体(全站无衬线,2026-09-05 定)",{"font-ui":{value:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif'},"font-body":{value:"system-ui, sans-serif",css:"var(--bim-font-ui)"},"font-serif":{value:xs,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:xs,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],Zp=Object.assign({},...Xp.map(e=>e.tokens)),il={};for(const[e,n]of Object.entries(Zp))il[e]=`var(--bim-${e}, ${n.value})`;function r(e){const n=il[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function Ot(e){return e.types&&e.types.length>0?e.types:[]}function Jp(e,n){return Ot(e).includes(n)}const Qp={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 eu={"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 bn(e){try{return eu[new URL(e).hostname]}catch{return}}const bs={text:0,image:1,physical:2};function qr(e){return e.length===0?"physical":[...e].sort((n,i)=>(bs[n]??99)-(bs[i]??99)).join("+")}function tu(e){return e.includes("text")&&e.includes("image")?"text+image":e[0]||"physical"}function Kr(e){var l;const n=d=>{const c=d.match(/^(.+?)·第(\d+)[冊册]$/);if(c)return[c[1],parseInt(c[2])];const p=d.match(/^(.+?)[·(](\d+)[)]?$/);return p?[p[1],parseInt(p[2])]:null},i=new Map;for(let d=0;d<e.length;d++){const c=e[d];if(c.volumes&&c.volumes.length>0)continue;const p=n(c.name);if(!p)continue;const[h,u]=p,m=`${h}|${qr(Ot(c))}`;i.has(m)||i.set(m,{base:{...c,name:h,url:"",volumes:[]},volumes:[],indices:[]});const f=i.get(m);f.volumes.push({volume:u,url:c.url||void 0,status:"found"}),f.indices.push(d)}const o=[],s=new Set;for(const d of i.values())if(!(d.volumes.length<2)){d.volumes.sort((c,p)=>c.volume-p.volume),d.base.volumes=d.volumes,d.base.expected_volumes=d.volumes.length,d.base.url||(d.base.url=((l=d.volumes.find(c=>c.url))==null?void 0:l.url)??""),o.push(d.base);for(const c of d.indices)s.add(c)}const a=[...o];for(let d=0;d<e.length;d++)s.has(d)||a.push(e[d]);return a}function rl(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 ol(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||rl(n)}))}function Si(e){const n=ol(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 Xr(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 Zr(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 yn(e){if(!e.url)return;const n=Xr(e.metadata);return n?Zr(e.url,n):e.url}const It=g.createContext(null),sl=["曹霑"];function nu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function iu(e,n=sl){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(nu).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 _n=null;function al(){if(_n)return _n;try{const e=Vp.Converter({from:"t",to:"cn"});_n=iu(n=>e(ke.normalizeVariants(n)))}catch{_n=e=>e}return _n}const ru={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:"圖片資源"}},ou={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 ht(e,n,i){return{"zh-Hant":e,"zh-Hans":n}}const su=ht({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:"无数据"}),_i=ht({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:"作品信息"}),au=ht({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:"附记"}}),lu=ht({fact:{written:"成書",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考證",alias:"又名",attached:"附載",appendix:"附錄"},inferredFromEdition:"據版本題名推斷",loading:"載入中",emendationCount:"{n} 條",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著錄"},classifiedBy:"據《{source}》",sec:{versions:"版本",catalogs:"著錄",collected:"收入叢編",related:"相關書目",resources:"在線資源"},versionsTotal:"共 {n} 種",versionsWithImage:"{n} 種有影印",versionsCurrent:"當前 {n} 種",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著錄順序",col:{edition:"版本",era:"年代",holder:"館藏",image:"影印"},noVersionsFiltered:"當前篩選下沒有版本",noVersions:"暫無版本著錄",moreUnit:"種版本",inferredEraNote:"部分年代據版本題名推斷,非著錄原文",empty:"尚未著錄該作品的版本與書目收錄。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"歷代書目 {n} 家",tablist:"著錄書目",titleOnly:"僅著錄書名,無提要。",prev:"上一家:{name}",next:"下一家:{name}"}},{fact:{written:"成书",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考证",alias:"又名",attached:"附载",appendix:"附录"},inferredFromEdition:"据版本题名推断",loading:"载入中",emendationCount:"{n} 条",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著录"},classifiedBy:"据《{source}》",sec:{versions:"版本",catalogs:"著录",collected:"收入丛编",related:"相关书目",resources:"在线资源"},versionsTotal:"共 {n} 种",versionsWithImage:"{n} 种有影印",versionsCurrent:"当前 {n} 种",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著录顺序",col:{edition:"版本",era:"年代",holder:"馆藏",image:"影印"},noVersionsFiltered:"当前筛选下没有版本",noVersions:"暂无版本著录",moreUnit:"种版本",inferredEraNote:"部分年代据版本题名推断,非著录原文",empty:"尚未著录该作品的版本与书目收录。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"历代书目 {n} 家",tablist:"著录书目",titleOnly:"仅著录书名,无提要。",prev:"上一家:{name}",next:"下一家:{name}"}}),cu=ht({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:"上级丛编"}),du=ht({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:"来源"}),pu=ht({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",settingsShort:"設置",closeSettings:"收起設置",groupText:"文字",groupMark:"標註",groupLayout:"版面",font:"字體",fontSong:"宋體",fontKai:"楷體",fontSystem:"系統默認",script:"繁簡",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最後一{unit}",toc:"目錄",images:"書影",fontSmaller:"縮小字號",fontLarger:"放大字號",paragraphTitle:"條目分行 ↔ 自然段",paragraph:"自然段",workLinks:"標出作品鏈接",properNameTitle:"書名加波浪線",properName:"專名線",properNameOff:"不顯示",properNameLite:"精簡",properNameFull:"完整",properNameLiteTitle:"只標人名、地名、朝代",showWorks:"標註書名",bookTitleStyle:"書名樣式",bookTitleWavy:"波浪線",bookTitleBracket:"書名號",scriptOrig:"原字",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}",searchChapters:"搜索全部章節",searchChaptersPlaceholder:"搜索全部章節…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"來源",originalSource:"本站獨立整理",charGuess:"殘字(推測)",upstream:"上游",chapterFailed:"無法加載章節內容",references:"參考文獻",entityDetail:"查看詳情 →"},{imagesLoading:"加载书影…",noImages:"暂无书影",noImagesHint:"这一卷还没有配上影像;接入后在此与正文逐页对看",imageAlt:"书影 第 {label} 页",prevImage:"上一页书影",nextImage:"下一页书影",back:"阅读",backAria:"返回{label}首页",skipToText:"跳到正文",settings:"阅读设置",settingsShort:"设置",closeSettings:"收起设置",groupText:"文字",groupMark:"标注",groupLayout:"版面",font:"字体",fontSong:"宋体",fontKai:"楷体",fontSystem:"系统默认",script:"繁简",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最后一{unit}",toc:"目录",images:"书影",fontSmaller:"缩小字号",fontLarger:"放大字号",paragraphTitle:"条目分行 ↔ 自然段",paragraph:"自然段",workLinks:"标出作品链接",properNameTitle:"书名加波浪线",properName:"专名线",properNameOff:"不显示",properNameLite:"精简",properNameFull:"完整",properNameLiteTitle:"只标人名、地名、朝代",showWorks:"标注书名",bookTitleStyle:"书名样式",bookTitleWavy:"波浪线",bookTitleBracket:"书名号",scriptOrig:"原字",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}",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",originalSource:"本站独立整理",charGuess:"残字(推测)",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献",entityDetail:"查看详情 →"}),uu=ht({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:"本卷条目"}),mu=ht({typeShort:{work:"作",book:"版",collection:"叢",entity:"人"},typeLabel:{work:"作品",book:"版本",collection:"叢編",entity:"人物"},typeAll:"全部",typeChipsLabel:"按類型檢索",recentTitle:"最近瀏覽",recentClear:"清除",recentItemLabel:"{type} {title}",recentEmpty:"還沒有瀏覽記錄。打開任一條目後會出現在這裏。",status:{done:"已完成",in_progress:"進行中",todo:"計劃中"},siteStatus:{done:"已對接",in_progress:"進行中"},catalogTitle:"書目著錄進度",catalogNote:"每條著錄對到作品條目",colCatalog:"書目",colRecords:"著錄條目",colMatched:"已對上作品",colProgress:"進度",colStatus:"狀態",relatedTitle:"同類書目與考證",relatedNote:"不在書架上的",allNWorks:"全部 {n} 部",nKinds:"{n} 種",allNKinds:"全部 {n} 種",pavilion:"閣",yearBC:"前{n}",missingLife:"生卒年未錄、未上軸:{names}",viewLineage:"看版本譜系 →",plannedSites:"計劃接入:{names}",loss:{extant:"存",partially_extant:"殘",lost:"佚",unknown:"未詳"},lossNote:{extant:"今有傳本",partially_extant:"部分存世",lost:"僅見著錄",unknown:"尚未判定"},lossCount:"{n} 部 · {note}",stat:{works:"作品",books:"版本",collections:"叢編",entities:"人物",has_image:"有影印",has_text:"有文本",article:"單篇文",poem:"單篇詩"},dataScale:"數據規模",byLoss:"按存佚檢索",license:"古籍元數據以 CC0 公有領域發布,可自由複製、改編、再發布。",repo:"數據倉庫:",repoNote:"(GitHub,CC0)",version:"當前數據版本:",download:"引用方式與數據下載 →",navLabel:"元數據首頁分區",nav:{zhi:"歷代史志",sibu:"四部",cong:"叢編",people:"人物",lineage:"版本譜系",sites:"在線資源",data:"數據與授權"},zhiSub:"正史藝文志、經籍志與後人補志,按所志朝代排列;每部志的著錄逐條對到作品",shelfLegendCount:"脊下數字=著錄條目",shelfLegendClick:"點書脊進作品頁",sibuSub:"全部作品按經史子集分類;與「目錄」頁同一棵分類樹",toCatalog:"進入目錄 →",unclassifiedNote:"多為只見於史志著錄、尚未歸類的書",congSub:"大型叢書、影印彙編、出土文獻與館藏,逐種列到版本",allNKindsMore:"全部 {n} 種 →",peopleSub:"歷代目錄學家,按生卒年排在一條時間軸上",allNPeopleMore:"全部 {n} 人 →",lineageSub:"版本多的作品,看各本的源流與異同",sitesSub:"外部數字圖書館與本站條目的對接",dataSub:"規模、存佚、許可與版本"},{typeShort:{work:"作",book:"版",collection:"丛",entity:"人"},typeLabel:{work:"作品",book:"版本",collection:"丛编",entity:"人物"},typeAll:"全部",typeChipsLabel:"按类型检索",recentTitle:"最近浏览",recentClear:"清除",recentItemLabel:"{type} {title}",recentEmpty:"还没有浏览记录。打开任一条目后会出现在这里。",status:{done:"已完成",in_progress:"进行中",todo:"计划中"},siteStatus:{done:"已对接",in_progress:"进行中"},catalogTitle:"书目著录进度",catalogNote:"每条著录对到作品条目",colCatalog:"书目",colRecords:"著录条目",colMatched:"已对上作品",colProgress:"进度",colStatus:"状态",relatedTitle:"同类书目与考证",relatedNote:"不在书架上的",allNWorks:"全部 {n} 部",nKinds:"{n} 种",allNKinds:"全部 {n} 种",pavilion:"阁",yearBC:"前{n}",missingLife:"生卒年未录、未上轴:{names}",viewLineage:"看版本谱系 →",plannedSites:"计划接入:{names}",loss:{extant:"存",partially_extant:"残",lost:"佚",unknown:"未详"},lossNote:{extant:"今有传本",partially_extant:"部分存世",lost:"仅见著录",unknown:"尚未判定"},lossCount:"{n} 部 · {note}",stat:{works:"作品",books:"版本",collections:"丛编",entities:"人物",has_image:"有影印",has_text:"有文本",article:"单篇文",poem:"单篇诗"},dataScale:"数据规模",byLoss:"按存佚检索",license:"古籍元数据以 CC0 公有领域发布,可自由复制、改编、再发布。",repo:"数据仓库:",repoNote:"(GitHub,CC0)",version:"当前数据版本:",download:"引用方式与数据下载 →",navLabel:"元数据首页分区",nav:{zhi:"历代史志",sibu:"四部",cong:"丛编",people:"人物",lineage:"版本谱系",sites:"在线资源",data:"数据与授权"},zhiSub:"正史艺文志、经籍志与后人补志,按所志朝代排列;每部志的著录逐条对到作品",shelfLegendCount:"脊下数字=著录条目",shelfLegendClick:"点书脊进作品页",sibuSub:"全部作品按经史子集分类;与「目录」页同一棵分类树",toCatalog:"进入目录 →",unclassifiedNote:"多为只见于史志著录、尚未归类的书",congSub:"大型丛书、影印汇编、出土文献与馆藏,逐种列到版本",allNKindsMore:"全部 {n} 种 →",peopleSub:"历代目录学家,按生卒年排在一条时间轴上",allNPeopleMore:"全部 {n} 人 →",lineageSub:"版本多的作品,看各本的源流与异同",sitesSub:"外部数字图书馆与本站条目的对接",dataSub:"规模、存佚、许可与版本"}),Jr=ht({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:"按作者浏览全部 →"}),hu=ht({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} 条"}),gu=ht({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:"搜索"}),fu=ht({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:"回复"}),xu=ht({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:"有争议"}}),bu={common:su,detail:_i,bookPage:au,workPage:lu,collectionPage:cu,entityPage:du,reader:pu,collated:uu,metaHome:mu,readHome:Jr,catalogPage:hu,searchPage:gu,feedback:fu,lineage:xu};function yu(e){const n={};for(const[i,o]of Object.entries(bu))n[i]=o[e];return n}function bt(e,n){return e.replace(/\{(\w+)\}/g,(i,o)=>String(n[o]??""))}const ys=new Map;function jn(e){let n=ys.get(e);return n||(n={...e==="zh-Hans"?ou:ru,...yu(e)},ys.set(e,n)),n}function js(e,n){let i=e;for(const o of n.split(".")){if(i==null||typeof i!="object")return;i=i[o]}return typeof i=="string"?i:void 0}function ll(e){return(n,i)=>{const o=js(e,n)??js(jn("zh-Hant"),n)??n;return i?bt(o,i):o}}const vs=new Map;function vn(e){let n=vs.get(e);return n||(n=ll(jn(e)),vs.set(e,n)),n}const cl="bim-locale";function ju(){try{const e=localStorage.getItem(cl);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function vu(e){try{localStorage.setItem(cl,e)}catch{}}const ku="zh-Hans",wu=({locale:e,onLocaleChange:n,converter:i,children:o})=>{const[s,a]=g.useState(e??ku),l=e??s;g.useEffect(()=>{if(e)return;const h=ju();h&&h!==s&&a(h)},[]);const d=g.useMemo(()=>l==="zh-Hans"?i??al():null,[l,i]),c=g.useCallback(h=>{a(h),vu(h),n==null||n(h)},[n]),p=g.useMemo(()=>({locale:l,setLocale:c,messages:jn(l),converter:d}),[l,c,d]);return t.jsx(It.Provider,{value:p,children:o})};function Ie(){const e=g.useContext(It);return(e==null?void 0:e.messages)??jn("zh-Hant")}const Su=2e3;function Pe(){const e=g.useContext(It),n=(e==null?void 0:e.locale)??"zh-Hant",i=(e==null?void 0:e.converter)??null,o=g.useRef(new Map),s=g.useRef(n),a=g.useRef(i);(s.current!==n||a.current!==i)&&(o.current.clear(),s.current=n,a.current=i);const l=g.useCallback(d=>{if(!d)return"";if(!i)return d;const c=o.current.get(d);if(c!==void 0)return c;const p=i(d);if(o.current.size>=Su){const h=o.current.keys().next().value;h!==void 0&&o.current.delete(h)}return o.current.set(d,p),p},[i]);return g.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function te(){const e=g.useContext(It),{convert:n,locale:i,isSimplified:o}=Pe(),s=(e==null?void 0:e.messages)??jn("zh-Hant"),a=g.useMemo(()=>e?ll(s):vn("zh-Hant"),[e,s]);return g.useMemo(()=>({t:a,convert:n,locale:i,isSimplified:o,messages:s}),[a,n,i,o,s])}const dl=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),_u=new Set([...dl,...Object.keys(ke.VARIANT_CHARS),...Object.keys(Qa.VARIANT_SUPPLEMENT)]),pl=[...sl,"切換為繁體","漢籍リポジトリ"];function $u(e,n=pl){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)=>{_u.has(a)&&o.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),o}function Cu(e,n,i){return e?e==="orig"?null:n==="zh-Hans"?i??al():e==="hant"?ke.normalizeVariants:i:n==="zh-Hans"?i:ke.normalizeVariants}const zu=({mode:e,children:n})=>{const i=g.useContext(It),o=g.useMemo(()=>i&&{...i,converter:Cu(e,i.locale,i.converter)},[i,e]);return t.jsx(It.Provider,{value:o,children:n})};function Tu(e){if(!e)return"";try{const n=new URL(e).hostname,i={"zh.wikisource.org":"wikisource","www.shidianguji.com":"shidianguji","shidianguji.com":"shidianguji","archive.org":"archive","ctext.org":"ctext","read.nlc.cn":"nlc","www.digital.archives.go.jp":"japan_archives"};if(i[n])return i[n];const o=n.split(".");return o.length>=2?o[o.length-2]:n}catch{return""}}function ks(e){return e==="text+image"?["text","image"]:[e]}function ws(e){const n=Ot(e);return n.length===0?"text":tu(n)}function Nu(){return{id:"",name:"",url:"",types:["text"],details:""}}const kr=({items:e,onChange:n,onDownload:i,downloadStatuses:o,filterType:s})=>{const a=Ie(),[l,d]=g.useState(null),c=[{value:"text",label:a.resourceTypeShort.text},{value:"image",label:a.resourceTypeShort.image},{value:"text+image",label:a.resourceTypeShort.textImage},{value:"physical",label:a.resourceTypeShort.physical}],p=[{value:"catalog",label:a.rootType.catalog},{value:"search",label:a.rootType.search}],h=w=>{if(!s)return!0;const v=Ot(w);return s==="text"?v.includes("text"):s==="image"?v.includes("image")||v.includes("physical"):s==="physical"?v.includes("physical"):v.includes(s)},u=e.map((w,v)=>({item:w,originalIndex:v})).filter(({item:w})=>h(w)),m=()=>{const w=Nu();s&&(w.types=ks(s)),n([...e,w]),d(e.length)},f=w=>{n(e.filter((v,j)=>j!==w)),d(null)},x=(w,v,j)=>{const C=[...e];if(C[w]={...C[w],[v]:j},v==="url"&&!C[w].id){const S=Tu(j);S&&(C[w].id=S)}n(C)},k=(w,v)=>{const j=[...e],{type:C,...S}=j[w];j[w]={...S,types:ks(v)},n(j)},y=(w,v,j)=>{const S={...e[w].metadata||{}};j?S[v]=j:delete S[v],x(w,"metadata",Object.keys(S).length>0?S:void 0)},$=(w,v)=>{const j=v.trim()?v.split(/[,,、]/).map(C=>C.trim()).filter(Boolean):void 0;x(w,"structure",j)},b=(w,v,j)=>{const S=e[w].coverage||{level:1,ranges:""};v==="level"?S.level=parseInt(j)||1:S.ranges=j,x(w,"coverage",S.ranges?S:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[u.map(({item:w,originalIndex:v})=>{var j,C,S;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===v?null:v),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:l===v?"▼":"▶"}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:Iu(ws(w)),color:r("on-color-fg")},children:(()=>{var L,T;const _=Ot(w);return _.length===0?"text":_.length===1?((L=c.find(z=>z.value===_[0]))==null?void 0:L.label)??_[0]:_.includes("text")&&_.includes("image")?((T=c.find(z=>z.value==="text+image"))==null?void 0:T.label)??"text+image":_.join("+")})()}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:w.name||`${a.editor.resourcePlaceholder} ${v+1}`}),w.id&&t.jsx("span",{style:{fontSize:"11px",opacity:.5},children:w.id}),w.url&&t.jsx("a",{href:w.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),i&&w.url&&Eu(v,o==null?void 0:o[v],i,a),t.jsx("button",{onClick:_=>{_.stopPropagation(),f(v)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:a.editor.deleteThisResource,children:"✕"})]}),l===v&&t.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:[Jp(w,"image")&&w.url&&Ru(w,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:$n,children:[t.jsx("span",{style:Cn,children:a.label.type}),t.jsx("select",{value:ws(w),onChange:_=>k(v,_.target.value),style:{...Ct,flex:1},children:c.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]}),t.jsxs("label",{style:$n,children:[t.jsx("span",{style:Cn,children:a.label.rootType}),t.jsx("select",{value:w.root_type||"catalog",onChange:_=>x(v,"root_type",_.target.value),style:{...Ct,flex:1},children:p.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:w.id,onChange:_=>x(v,"id",_.target.value),placeholder:a.editor.idAutoExtract,style:{...Ct,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:w.name,onChange:_=>x(v,"name",_.target.value),placeholder:a.editor.resourceName,style:{...Ct,flex:1}})]}),t.jsx("input",{type:"text",value:w.url,onChange:_=>x(v,"url",_.target.value),placeholder:a.editor.resourceUrl,style:Ct}),t.jsx("input",{type:"text",value:((j=w.structure)==null?void 0:j.join("、"))||"",onChange:_=>$(v,_.target.value),placeholder:a.editor.structurePlaceholder,style:Ct}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:$n,children:[t.jsx("span",{style:Cn,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((C=w.coverage)==null?void 0:C.level)??"",onChange:_=>b(v,"level",_.target.value),placeholder:"1",style:{...Ct,width:"60px"}})]}),t.jsxs("label",{style:{...$n,flex:1},children:[t.jsx("span",{style:Cn,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:((S=w.coverage)==null?void 0:S.ranges)||"",onChange:_=>b(v,"ranges",_.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...Ct,flex:1}})]})]}),t.jsx("textarea",{value:w.details||"",onChange:_=>x(v,"details",_.target.value),placeholder:a.editor.detailsPlaceholder,style:{...Ct,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(([_,L])=>{var T;return t.jsxs("label",{style:{...$n,gap:"4px"},children:[t.jsx("span",{style:{...Cn,minWidth:"56px"},children:L}),t.jsx("input",{type:"text",value:((T=w.metadata)==null?void 0:T[_])||"",onChange:z=>y(v,_,z.target.value),placeholder:L,style:{...Ct,flex:1}})]},_)})})]})]})]})]},v)}),t.jsxs("button",{onClick:m,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:a.action.addResource})]})]})};function Iu(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 Eu(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 Ru(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 Ct={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"},$n={display:"flex",alignItems:"center",gap:"6px"},Cn={fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap"},Ss={text:r("restype-text"),image:r("restype-image"),"text+image":r("restype-text-image"),physical:r("restype-physical")};function Lu(e){return e.includes("text")&&e.includes("image")?Ss["text+image"]:Ss[e[0]||"physical"]}const Qr=({items:e,groupByType:n=!0,resourceGroups:i,onNavigate:o,renderLink:s})=>{const a=Ie(),{convert:l}=Pe(),d=g.useMemo(()=>Kr(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=g.useMemo(()=>{const y=new Map,$=[];for(const b of d){const w=b.group;w?(y.has(w)||y.set(w,[]),y.get(w).push(b)):$.push(b)}for(const b of y.values())b.sort((w,v)=>{const j=C=>C.group_role==="origin"?0:C.group_role==="mirror"?1:2;return j(w)-j(v)});return{mirrorGroups:y,ungroupedItems:$}},[d]),h={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},u=y=>h[y]?h[y]:y.split("+").map($=>h[$]||$).join("+");if(!d||d.length===0)return t.jsx("div",{style:{padding:"16px",color:r("desc-fg"),fontSize:"13px",textAlign:"center"},children:a.misc.noResources});if(!n)return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:d.map((y,$)=>t.jsx(ir,{item:y},y.id||$))});const m=(y,$)=>{const b=i==null?void 0:i[y],w=(b==null?void 0:b.label)||y,v=b==null?void 0:b.description;return t.jsxs("div",{style:{padding:"10px 12px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:r("input-bg"),display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(w)}),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:$.map((j,C)=>t.jsx(ir,{item:j,onNavigate:o,renderLink:s},j.id||C))})]},`group-${y}`)},f=new Map;for(const y of p){const $=qr(Ot(y));f.has($)||f.set($,[]),f.get($).push(y)}const x=["text","image","text+image","physical"],k=[...x.filter(y=>f.has(y)),...[...f.keys()].filter(y=>!x.includes(y)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,$])=>m(y,$)),k.map(y=>{const $=f.get(y),b=Lu(y.split("+"));return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:b,whiteSpace:"nowrap",flexShrink:0},children:u(y)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:$.map((w,v)=>t.jsx(ir,{item:w,onNavigate:o,renderLink:s},w.id||v))})]},y)})]})},Au={bw:{label:"",bg:r("colormode-bw-bg"),fg:r("colormode-bw-fg")},color:{label:"",bg:r("colormode-color-bg"),fg:r("colormode-color-fg")}},ir=({item:e})=>{const n=Ie(),{convert:i}=Pe(),[o,s]=g.useState(!1),a=g.useMemo(()=>(e.url?bn(e.url):void 0)||i(e.name),[e.url,e.name,i]),l=g.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||rl(x)})),[e.volumes]),d=l&&l.length>0,c=d?new Set(l.filter(x=>x.status!=="missing").map(x=>x.volume)).size:0,p=d?new Set(l.filter(x=>x.status==="missing").map(x=>x.volume)).size:0,h=e.expected_volumes??(d?c+p:0),u=e.color_mode?{...Au[e.color_mode],label:n.colorMode[e.color_mode]}:null,m=e.details&&!d?i(e.details):null,f={display:"inline-flex",alignItems:"center",gap:"5px",padding:"4px 10px",border:`1px solid ${r("widget-border")}`,borderRadius:"5px",background:r("input-bg"),fontSize:"12px",color:r("fg"),lineHeight:1.4,verticalAlign:"middle"};return t.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[t.jsxs("div",{style:f,children:[t.jsx("span",{style:{fontWeight:500},children:a}),u&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:u.bg,color:u.fg},children:u.label}),m&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:m}),d&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[c,"/",h,n.unit.volume,p>0&&t.jsx("span",{style:{color:r("missing-fg"),marginLeft:"3px"},children:bt(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=Xr(e.metadata);return x?Zr(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 k=x.status==="missing";return x.url&&!k?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(k?"missing-fg":"desc-fg"),textDecoration:k?"line-through":"none",opacity:k?.6:1},children:x.volume},x.volume)})})]})},ul=({indexSource:e,syncConfig:n,variant:i="index-browser",onSwitchMode:o,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=Ie(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,h=(n==null?void 0:n.repoPath)||"",u=h?h.split(/[/\\]/).pop()||h:"",m={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:r("primary-soft"),color:r("primary")},f={onMouseOver:k=>k.currentTarget.style.opacity="0.8",onMouseOut:k=>k.currentTarget.style.opacity="1"},x=t.jsxs("div",{onClick:s,title:p?d.mode.switchToOfficial:d.mode.switchToDraft,style:{...m,background:r(p?"warning":"success"),color:r("on-color-fg")},...f,children:[t.jsx("span",{children:p?"📝":"📚"}),t.jsx("span",{children:p?"draft":"official"})]});return i==="index-browser"?c?t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[x,t.jsxs("div",{onClick:o,title:d.mode.switchToSync,style:m,...f,children:[t.jsx("span",{children:"📁"}),t.jsx("span",{children:d.mode.localMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsxs("div",{onClick:l,title:h||d.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px"},...f,children:[t.jsx("span",{children:"📂"}),u&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:u})]})]}):t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.jsxs("div",{onClick:o,title:d.mode.switchToLocal,style:m,...f,children:[t.jsx("span",{children:"🌐"}),t.jsx("span",{children:d.mode.syncMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsx("div",{onClick:a,title:u||d.mode.configurePath,style:{...m,background:"transparent",padding:"6px",fontSize:"12px"},...f,children:t.jsx("span",{children:"⚙️"})})]})]}):t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[t.jsxs("div",{onClick:o,title:c?d.mode.switchToGithub:d.mode.switchToLocal,style:m,...f,children:[t.jsx("span",{children:c?"📁":"🌐"}),t.jsx("span",{children:c?d.mode.localMode:d.mode.githubSync}),t.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&t.jsxs("div",{onClick:l,title:h||d.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px",minWidth:h?"100px":"auto",justifyContent:"space-between"},...f,children:[t.jsx("span",{children:"📂"}),u&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:u})]}),!c&&u&&t.jsxs("div",{style:{...m,background:r("mode-active-bg"),color:r("on-color-fg"),cursor:"default"},title:h,children:[t.jsx("span",{children:"📂"}),t.jsx("span",{style:{fontSize:"11px"},children:u})]})]})},$i="bim-search-history",_s=10,$s=8;function Ln(){try{const e=localStorage.getItem($i);return e?JSON.parse(e):[]}catch{return[]}}function ml(e){try{const n=Ln().filter(i=>i!==e);n.unshift(e),n.length>_s&&(n.length=_s),localStorage.setItem($i,JSON.stringify(n))}catch{}}function Mu(e){try{const n=Ln().filter(i=>i!==e);localStorage.setItem($i,JSON.stringify(n))}catch{}}function Pu(){try{localStorage.removeItem($i)}catch{}}const hl=({transport:e,value:n,onChange:i,onSearch:o,onEntrySelect:s,placeholder:a})=>{const l=Ie(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,h]=g.useState(!1),[u,m]=g.useState([]),[f,x]=g.useState(-1),[k,y]=g.useState(Ln),$=g.useRef(null),b=g.useRef(null),w=g.useRef(null),v=g.useRef(!1);g.useEffect(()=>{x(-1);const z=n.trim();if(!z){m(k.map(N=>({type:"history",text:N})));return}if(!e.searchAll){m([]);return}let M=!1;const H=setTimeout(()=>{e.searchAll(z,$s).then(N=>{if(M)return;const R=[...N.works,...N.books,...N.collections,...N.entities??[]];m(R.slice(0,$s).map(A=>({type:"entry",text:A.title||A.id,entry:A})))}).catch(()=>{M||m([])})},80);return()=>{M=!0,clearTimeout(H)}},[n,k,e]),g.useEffect(()=>{const z=M=>{w.current&&!w.current.contains(M.target)&&h(!1)};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]),g.useEffect(()=>{const z=M=>{var H,N;if(M.key==="/"&&document.activeElement!==$.current){const R=(H=document.activeElement)==null?void 0:H.tagName;if(R==="INPUT"||R==="TEXTAREA"||R==="SELECT")return;M.preventDefault(),(N=$.current)==null||N.focus()}};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[]);const j=g.useCallback(z=>{z.trim()&&(ml(z.trim()),y(Ln())),o(z),h(!1)},[o]),C=g.useCallback(z=>{z.type==="history"?(i(z.text),j(z.text)):z.entry&&(s?(s(z.entry),h(!1)):(i(z.text),j(z.text)))},[i,j,s]),S=g.useCallback(z=>{if(!p||u.length===0){z.key==="Enter"&&j(n);return}switch(z.key){case"ArrowDown":z.preventDefault(),x(M=>(M+1)%u.length);break;case"ArrowUp":z.preventDefault(),x(M=>(M-1+u.length)%u.length);break;case"Enter":z.preventDefault(),f>=0&&f<u.length?C(u[f]):j(n);break;case"Escape":z.preventDefault(),h(!1);break}},[p,u,f,n,j,C]),_=g.useCallback((z,M)=>{M.stopPropagation(),Mu(z),y(Ln()),m(H=>H.filter(N=>!(N.type==="history"&&N.text===z)))},[]),L=g.useCallback(z=>{z.stopPropagation(),Pu(),y([]),m([])},[]);g.useEffect(()=>{if(f>=0&&b.current){const z=b.current.children;z[f]&&z[f].scrollIntoView({block:"nearest"})}},[f]);const T=!n.trim()&&k.length>0;return t.jsxs("div",{ref:w,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:$,type:"text",placeholder:d,value:n,onChange:z=>{i(z.target.value),h(!0)},onCompositionStart:()=>{v.current=!0},onCompositionEnd:()=>{v.current=!1},onFocus:()=>{h(!0)},onKeyDown:S,style:{width:"100%",padding:"8px 12px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),fontSize:"14px",boxSizing:"border-box"}}),p&&u.length>0&&t.jsxs("div",{ref:b,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:r("input-bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"6px",boxShadow:r("shadow-dropdown"),zIndex:100,maxHeight:"320px",overflow:"auto"},children:[T&&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})]}),u.map((z,M)=>t.jsxs("div",{onClick:()=>C(z),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:r("fg"),background:M===f?r("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:z.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.text}),z.entry&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:[c[z.entry.type],z.entry.edition&&` · ${z.entry.edition}`,z.entry.author&&` · ${z.entry.author}`]}),z.type==="history"&&t.jsx("button",{onClick:H=>_(z.text,H),style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:l.action.remove,children:"×"})]},`${z.type}-${z.text}-${M}`))]})]})},kn=({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"}}),Ci={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},gl=new Set(["work","book","entity"]);function Bu(e){return bl(e)||!!e.sort}function Wu(e,n){return n.sort&&gl.has(e)?n.sort:void 0}const zi=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],Ti=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],fl=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],xl={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function Ni(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 bl(e){return Ni(e)>0}function Ou(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 yl(e,n){const i=xl[e];return Ou(n).every(o=>i.has(o))}const zn=e=>JSON.stringify(e);function Fu(e,n){if(!yl(n,e))return null;const i=[];if(e.dynasty.length){const o=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=zi.find(l=>l.key===s))==null?void 0:a.values)??[]})));o.length===1?i.push(`dynasty = ${zn(o[0])}`):o.length>1&&i.push(`dynasty IN [${o.map(zn).join(", ")}]`)}return e.classification.length&&i.push(e.classification.length===1?`classification = ${zn(e.classification[0])}`:`classification IN [${e.classification.map(zn).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 = ${zn(e.loss)}`),i.join(" AND ")}const dt={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},jl="_";function xi(e,n=new URLSearchParams){for(const i of Object.values(dt))n.delete(i);return e.dynasty.length&&n.set(dt.dynasty,e.dynasty.join(",")),e.classification.length&&n.set(dt.classification,e.classification.map(i=>i||jl).join(",")),e.hasImage&&n.set(dt.hasImage,"1"),e.hasText&&n.set(dt.hasText,"1"),e.hasCollated&&n.set(dt.hasCollated,"1"),e.loss&&n.set(dt.loss,e.loss),e.sort&&n.set(dt.sort,e.sort),n}function Hu(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),i=new Set(zi.map(a=>a.key)),o=new Set(Ti.map(a=>a.value)),s=e.get(dt.loss);return{dynasty:Array.from(new Set(n(dt.dynasty).filter(a=>i.has(a)))),classification:Array.from(new Set(n(dt.classification).map(a=>a===jl?"":a).filter(a=>o.has(a)))),hasImage:e.get(dt.hasImage)==="1",hasText:e.get(dt.hasText)==="1"||e.get(dt.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(dt.sort))??""}}function Du(e,n){return JSON.stringify([e.dynasty.slice().sort(),e.classification.slice().sort(),e.hasImage,e.hasText,e.hasCollated,e.loss,e.sort])===JSON.stringify([n.dynasty.slice().sort(),n.classification.slice().sort(),n.hasImage,n.hasText,n.hasCollated,n.loss,n.sort])}function Cs(e,n){return e.includes(n)?e.filter(i=>i!==n):[...e,n]}const Uu=({filters:e,onChange:n})=>{const i=Ie(),o=i.searchV4,{convert:s}=Pe(),[a,l]=g.useState(!1),d=g.useId(),c=Ni(e),p=h=>n({...e,...h});return t.jsxs("aside",{className:"bim-sr-aside","aria-label":s(o.filterTitle),children:[t.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":a,"aria-controls":d,onClick:()=>l(h=>!h),children:[t.jsxs("span",{children:[s(o.filterButton),c>0&&t.jsx("span",{className:"bim-sr-fn",children:s(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:zi.map(h=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(h.key),onClick:()=>p({dynasty:Cs(e.dynasty,h.key)}),children:s(h.key)},h.key))})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.classification)}),Ti.map(h=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(h.value),onChange:()=>p({classification:Cs(e.classification,h.value)})}),h.value?s(h.label):i.searchPage.unclassified]},h.value||"_"))]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.resources)}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasImage,onChange:h=>p({hasImage:h.target.checked})}),s(o.hasImage)]}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasText,onChange:h=>p({hasText:h.target.checked})}),s(o.hasText)]})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{id:`${d}-loss`,children:s(o.extant)}),t.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${d}-loss`,children:fl.map(h=>t.jsx("button",{type:"button","aria-pressed":e.loss===h.value,onClick:()=>p({loss:h.value}),children:i.searchPage.loss[h.value||"all"]},h.value||"all"))})]}),c>0&&t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...Ci,sort:e.sort}),children:s(o.clearAllFilters)})]})]})};function vl({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 zs=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ie(),a=s.searchV4,{convert:l}=Pe(),d=rt();return t.jsx("div",{className:"bim-sr-tablewrap",children:t.jsxs("table",{className:"bim-sr-table",children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:"34%"}}),t.jsx("col",{style:{width:"8%"}}),t.jsx("col",{style:{width:"19%"}}),t.jsx("col",{style:{width:"13%"}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"14%"}})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:l(a.colTitle)}),t.jsx("th",{scope:"col",children:l(a.colType)}),t.jsx("th",{scope:"col",children:l(a.colAuthor)}),t.jsx("th",{scope:"col",children:l(a.colEra)}),t.jsx("th",{scope:"col",children:l(a.colClass)}),t.jsx("th",{scope:"col",style:{textAlign:"right"},children:l(a.colResource)})]})}),t.jsx("tbody",{children:e.map(c=>{const p=l(c.title||c.primary_name||c.id),h=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",u=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${l(c.author)}${c.role&&c.role!=="author"?` ${l(c.role)}`:""}`:"",m=c.type==="book"?c.era??c.dynasty:c.dynasty,f=m?l(m):"",x=c.classification?l(c.classification):"",k=[];c.has_image&&k.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&k.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&k.push({label:a.tagLost,cls:"bim-sr-tag--lost"});const y=[u,f,x].filter(Boolean).join(" · ");return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-sr-c-title",children:[t.jsxs("div",{className:"bim-sr-tl",children:[t.jsx("a",{href:d(c.id),onClick:$=>i(c,$),children:t.jsx(vl,{text:p,query:n?l(n):void 0})}),h&&t.jsx("span",{className:"bim-sr-measure",children:h})]}),y&&t.jsx("span",{className:"bim-sr-sub",children:y})]}),t.jsxs("td",{className:"bim-sr-c-type",children:[t.jsx(kn,{type:c.type,size:6})," ",o(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:u||"—"}),t.jsx("td",{className:"bim-sr-c-era",children:f||"—"}),t.jsx("td",{className:"bim-sr-c-cls",children:x||"—"}),t.jsx("td",{className:"bim-sr-c-res",children:k.map($=>t.jsx("span",{className:`bim-sr-tag ${$.cls}`,children:l($.label)},$.label))})]},c.id)})})]})})},Vu=`
1
+ "use strict";var Op=Object.create;var xs=Object.defineProperty;var Wp=Object.getOwnPropertyDescriptor;var Fp=Object.getOwnPropertyNames;var Hp=Object.getPrototypeOf,Dp=Object.prototype.hasOwnProperty;var Up=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Fp(n))!Dp.call(e,s)&&s!==i&&xs(e,s,{get:()=>n[s],enumerable:!(o=Wp(n,s))||o.enumerable});return e};var oi=(e,n,i)=>(i=e!=null?Op(Hp(e)):{},Up(n||!e||!e.__esModule?xs(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ke=require("./storage-entry-Cx6j1zcJ.cjs"),t=require("react/jsx-runtime"),g=require("react"),Vp=require("opencc-js/t2cn"),Qa=require("./variant-supplement.cjs"),Gp=require("react-markdown"),Yp=require("remark-gfm"),qp=e=>`/item/${e}`,el=g.createContext(qp);function Kp({buildUrl:e,children:n}){const i=g.useMemo(()=>e,[e]);return t.jsx(el.Provider,{value:i,children:n})}function rt(){return g.useContext(el)}const tl="",nl="";function qr(e){const n=[];let i=!1,o=e;for(;o.length;){const s=i?nl:tl,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 pt(e,n){return{title:e,tokens:n}}const bs='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',Xp=[pt("基础(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"}}),pt("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),pt("提示与警告",{"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)"}}),pt("遮罩与阴影",{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)"}}),pt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),pt("资源",{"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"}}),pt("整理本(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:"中性灰:占位"}}),pt("版本传承(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"}}),pt("编辑器视图(主要在 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")'}}),pt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --bim-primary 等控件色",{"page-bg":{value:"#fbf9f3",note:"纸"},"row-hover-bg":{value:"#f5f1e5"},"selection-bg":{value:"#ecdcbc",note:"选区"},"band-bg":{value:"#f0e4cb",note:"全文入口横幅(暖沙)"},"band-bg-hover":{value:"#e6d5b4"},ink:{value:"#2a231c",note:"文字层次:墨 → 正文 → 提要 → meta → 标签 → 提示"},"body-fg":{value:"#3b3228"},"quiet-fg":{value:"#5b4f40"},"meta-fg":{value:"#7b6a54"},"label-fg":{value:"#6f6457",note:"标签 / 提示:2026-09 N3a 调深,纸底与斑马底上对比度均 ≥4.5(原 #a3937b 2.8、#b3a385 2.3)"},"hint-fg":{value:"#756a5e"},accent:{value:"#9c3a2c",note:"朱"},"accent-deep":{value:"#6f2a20",note:"链接 hover"},"rule-strong":{value:"#2a231c",note:"分隔线:强 → 常规 → 虚线 → 提要左线"},rule:{value:"#e4dbc9"},"rule-dashed":{value:"#d6c9ae"},"rule-accent-soft":{value:"#e0d3b6"},"aux-fg":{value:"#6f6457",note:"辅助字(元数据、注记、「·」分隔的浅色小字)。须在 page-bg / zebra-bg 上对比度 ≥4.5(Q5 巡检)"},"card-bg":{value:"#fffdf9",note:"提要卡:抬起的面"},"zebra-bg":{value:"#f6f2eb",note:"表格斑马纹 / 左栏分组底(不画格线,靠这一阶底色分行)"},"tint-bg":{value:"#f3eee6",note:"检索框、悬停"},"shadow-summary":{value:"0 10px 32px rgba(60, 50, 40, 0.07)",note:"提要卡投影"},"flag-bg":{value:"rgba(158, 42, 43, 0.08)",note:"唯一的状态色块「有影印」"},"theme-dot-zhusha":{value:"#9c3a2c",note:"主题切换控件的色点:朱砂(不随主题变,两套主题下都要认得出)"},"theme-dot-indigo":{value:"#2e5266",note:"主题切换控件的色点:靛青"},"theme-dot-ink":{value:"#3b4a58",note:"主题切换控件的色点:墨"},"sect-jing":{value:"#2e5266",note:"四部分布条:經部(人物页提要卡;无别处使用)"},"sect-shi":{value:"#9a7a3b",note:"四部分布条:史部"},"sect-zi":{value:"#4f7a5c",note:"四部分布条:子部"},"sect-ji":{value:"#9fb3bc",note:"四部分布条:集部"},"table-border":{value:"color-mix(in srgb, currentColor 28%, transparent)",root:!1,note:"古籍表格(跟随当前文字色)"},"table-head-bg":{value:"color-mix(in srgb, currentColor 8%, transparent)",root:!1}}),pt('版式(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"}}),pt("阅读器(整理本 / 全文)",{"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:"版心外边线"}}),pt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),pt("字体(全站无衬线,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:bs,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:bs,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],Zp=Object.assign({},...Xp.map(e=>e.tokens)),il={};for(const[e,n]of Object.entries(Zp))il[e]=`var(--bim-${e}, ${n.value})`;function r(e){const n=il[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function Wt(e){return e.types&&e.types.length>0?e.types:[]}function Jp(e,n){return Wt(e).includes(n)}const Qp={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 eu={"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 bn(e){try{return eu[new URL(e).hostname]}catch{return}}const ys={text:0,image:1,physical:2};function Kr(e){return e.length===0?"physical":[...e].sort((n,i)=>(ys[n]??99)-(ys[i]??99)).join("+")}function tu(e){return e.includes("text")&&e.includes("image")?"text+image":e[0]||"physical"}function Xr(e){var l;const n=d=>{const c=d.match(/^(.+?)·第(\d+)[冊册]$/);if(c)return[c[1],parseInt(c[2])];const p=d.match(/^(.+?)[·(](\d+)[)]?$/);return p?[p[1],parseInt(p[2])]:null},i=new Map;for(let d=0;d<e.length;d++){const c=e[d];if(c.volumes&&c.volumes.length>0)continue;const p=n(c.name);if(!p)continue;const[h,u]=p,m=`${h}|${Kr(Wt(c))}`;i.has(m)||i.set(m,{base:{...c,name:h,url:"",volumes:[]},volumes:[],indices:[]});const f=i.get(m);f.volumes.push({volume:u,url:c.url||void 0,status:"found"}),f.indices.push(d)}const o=[],s=new Set;for(const d of i.values())if(!(d.volumes.length<2)){d.volumes.sort((c,p)=>c.volume-p.volume),d.base.volumes=d.volumes,d.base.expected_volumes=d.volumes.length,d.base.url||(d.base.url=((l=d.volumes.find(c=>c.url))==null?void 0:l.url)??""),o.push(d.base);for(const c of d.indices)s.add(c)}const a=[...o];for(let d=0;d<e.length;d++)s.has(d)||a.push(e[d]);return a}function rl(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 ol(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||rl(n)}))}function Si(e){const n=ol(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 Zr(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 Jr(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 yn(e){if(!e.url)return;const n=Zr(e.metadata);return n?Jr(e.url,n):e.url}const It=g.createContext(null),sl=["曹霑"];function nu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function iu(e,n=sl){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(nu).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 _n=null;function al(){if(_n)return _n;try{const e=Vp.Converter({from:"t",to:"cn"});_n=iu(n=>e(ke.normalizeVariants(n)))}catch{_n=e=>e}return _n}const ru={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:"圖片資源"}},ou={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 ht(e,n,i){return{"zh-Hant":e,"zh-Hans":n}}const su=ht({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:"无数据"}),_i=ht({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:"作品信息"}),au=ht({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:"附记"}}),lu=ht({fact:{written:"成書",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考證",alias:"又名",attached:"附載",appendix:"附錄"},inferredFromEdition:"據版本題名推斷",loading:"載入中",emendationCount:"{n} 條",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著錄"},classifiedBy:"據《{source}》",sec:{versions:"版本",catalogs:"著錄",collected:"收入叢編",related:"相關書目",resources:"在線資源"},versionsTotal:"共 {n} 種",versionsWithImage:"{n} 種有影印",versionsCurrent:"當前 {n} 種",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著錄順序",col:{edition:"版本",era:"年代",holder:"館藏",image:"影印"},noVersionsFiltered:"當前篩選下沒有版本",noVersions:"暫無版本著錄",moreUnit:"種版本",sameEditionCopies:"同版另藏 {n} 部:",inferredEraNote:"部分年代據版本題名推斷,非著錄原文",empty:"尚未著錄該作品的版本與書目收錄。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"歷代書目 {n} 家",tablist:"著錄書目",titleOnly:"僅著錄書名,無提要。",prev:"上一家:{name}",next:"下一家:{name}"}},{fact:{written:"成书",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考证",alias:"又名",attached:"附载",appendix:"附录"},inferredFromEdition:"据版本题名推断",loading:"载入中",emendationCount:"{n} 条",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著录"},classifiedBy:"据《{source}》",sec:{versions:"版本",catalogs:"著录",collected:"收入丛编",related:"相关书目",resources:"在线资源"},versionsTotal:"共 {n} 种",versionsWithImage:"{n} 种有影印",versionsCurrent:"当前 {n} 种",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著录顺序",col:{edition:"版本",era:"年代",holder:"馆藏",image:"影印"},noVersionsFiltered:"当前筛选下没有版本",noVersions:"暂无版本著录",moreUnit:"种版本",sameEditionCopies:"同版另藏 {n} 部:",inferredEraNote:"部分年代据版本题名推断,非著录原文",empty:"尚未著录该作品的版本与书目收录。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"历代书目 {n} 家",tablist:"著录书目",titleOnly:"仅著录书名,无提要。",prev:"上一家:{name}",next:"下一家:{name}"}}),cu=ht({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:"上级丛编"}),du=ht({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:"来源"}),pu=ht({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",settingsShort:"設置",closeSettings:"收起設置",groupText:"文字",groupMark:"標註",groupLayout:"版面",font:"字體",fontSong:"宋體",fontKai:"楷體",fontSystem:"系統默認",script:"繁簡",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最後一{unit}",toc:"目錄",images:"書影",fontSmaller:"縮小字號",fontLarger:"放大字號",paragraphTitle:"條目分行 ↔ 自然段",paragraph:"自然段",workLinks:"標出作品鏈接",properNameTitle:"書名加波浪線",properName:"專名線",properNameOff:"不顯示",properNameLite:"精簡",properNameFull:"完整",properNameLiteTitle:"只標人名、地名、朝代",showWorks:"標註書名",bookTitleStyle:"書名樣式",bookTitleWavy:"波浪線",bookTitleBracket:"書名號",scriptOrig:"原字",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}",searchChapters:"搜索全部章節",searchChaptersPlaceholder:"搜索全部章節…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"來源",originalSource:"本站獨立整理",charGuess:"殘字(推測)",upstream:"上游",chapterFailed:"無法加載章節內容",references:"參考文獻",entityDetail:"查看詳情 →"},{imagesLoading:"加载书影…",noImages:"暂无书影",noImagesHint:"这一卷还没有配上影像;接入后在此与正文逐页对看",imageAlt:"书影 第 {label} 页",prevImage:"上一页书影",nextImage:"下一页书影",back:"阅读",backAria:"返回{label}首页",skipToText:"跳到正文",settings:"阅读设置",settingsShort:"设置",closeSettings:"收起设置",groupText:"文字",groupMark:"标注",groupLayout:"版面",font:"字体",fontSong:"宋体",fontKai:"楷体",fontSystem:"系统默认",script:"繁简",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最后一{unit}",toc:"目录",images:"书影",fontSmaller:"缩小字号",fontLarger:"放大字号",paragraphTitle:"条目分行 ↔ 自然段",paragraph:"自然段",workLinks:"标出作品链接",properNameTitle:"书名加波浪线",properName:"专名线",properNameOff:"不显示",properNameLite:"精简",properNameFull:"完整",properNameLiteTitle:"只标人名、地名、朝代",showWorks:"标注书名",bookTitleStyle:"书名样式",bookTitleWavy:"波浪线",bookTitleBracket:"书名号",scriptOrig:"原字",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}",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",originalSource:"本站独立整理",charGuess:"残字(推测)",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献",entityDetail:"查看详情 →"}),uu=ht({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:"本卷条目"}),mu=ht({typeShort:{work:"作",book:"版",collection:"叢",entity:"人"},typeLabel:{work:"作品",book:"版本",collection:"叢編",entity:"人物"},typeAll:"全部",typeChipsLabel:"按類型檢索",recentTitle:"最近瀏覽",recentClear:"清除",recentItemLabel:"{type} {title}",recentEmpty:"還沒有瀏覽記錄。打開任一條目後會出現在這裏。",status:{done:"已完成",in_progress:"進行中",todo:"計劃中"},siteStatus:{done:"已對接",in_progress:"進行中"},catalogTitle:"書目著錄進度",catalogNote:"每條著錄對到作品條目",colCatalog:"書目",colRecords:"著錄條目",colMatched:"已對上作品",colProgress:"進度",colStatus:"狀態",relatedTitle:"同類書目與考證",relatedNote:"不在書架上的",allNWorks:"全部 {n} 部",nKinds:"{n} 種",allNKinds:"全部 {n} 種",pavilion:"閣",yearBC:"前{n}",missingLife:"生卒年未錄、未上軸:{names}",viewLineage:"看版本譜系 →",plannedSites:"計劃接入:{names}",loss:{extant:"存",partially_extant:"殘",lost:"佚",unknown:"未詳"},lossNote:{extant:"今有傳本",partially_extant:"部分存世",lost:"僅見著錄",unknown:"尚未判定"},lossCount:"{n} 部 · {note}",stat:{works:"作品",books:"版本",collections:"叢編",entities:"人物",has_image:"有影印",has_text:"有文本",article:"單篇文",poem:"單篇詩"},dataScale:"數據規模",byLoss:"按存佚檢索",license:"古籍元數據以 CC0 公有領域發布,可自由複製、改編、再發布。",repo:"數據倉庫:",repoNote:"(GitHub,CC0)",version:"當前數據版本:",download:"引用方式與數據下載 →",navLabel:"元數據首頁分區",nav:{zhi:"歷代史志",sibu:"四部",cong:"叢編",people:"人物",lineage:"版本譜系",sites:"在線資源",data:"數據與授權"},zhiSub:"正史藝文志、經籍志與後人補志,按所志朝代排列;每部志的著錄逐條對到作品",shelfLegendCount:"脊下數字=著錄條目",shelfLegendClick:"點書脊進作品頁",sibuSub:"全部作品按經史子集分類;與「目錄」頁同一棵分類樹",toCatalog:"進入目錄 →",unclassifiedNote:"多為只見於史志著錄、尚未歸類的書",congSub:"大型叢書、影印彙編、出土文獻與館藏,逐種列到版本",allNKindsMore:"全部 {n} 種 →",peopleSub:"歷代目錄學家,按生卒年排在一條時間軸上",allNPeopleMore:"全部 {n} 人 →",lineageSub:"版本多的作品,看各本的源流與異同",sitesSub:"外部數字圖書館與本站條目的對接",dataSub:"規模、存佚、許可與版本"},{typeShort:{work:"作",book:"版",collection:"丛",entity:"人"},typeLabel:{work:"作品",book:"版本",collection:"丛编",entity:"人物"},typeAll:"全部",typeChipsLabel:"按类型检索",recentTitle:"最近浏览",recentClear:"清除",recentItemLabel:"{type} {title}",recentEmpty:"还没有浏览记录。打开任一条目后会出现在这里。",status:{done:"已完成",in_progress:"进行中",todo:"计划中"},siteStatus:{done:"已对接",in_progress:"进行中"},catalogTitle:"书目著录进度",catalogNote:"每条著录对到作品条目",colCatalog:"书目",colRecords:"著录条目",colMatched:"已对上作品",colProgress:"进度",colStatus:"状态",relatedTitle:"同类书目与考证",relatedNote:"不在书架上的",allNWorks:"全部 {n} 部",nKinds:"{n} 种",allNKinds:"全部 {n} 种",pavilion:"阁",yearBC:"前{n}",missingLife:"生卒年未录、未上轴:{names}",viewLineage:"看版本谱系 →",plannedSites:"计划接入:{names}",loss:{extant:"存",partially_extant:"残",lost:"佚",unknown:"未详"},lossNote:{extant:"今有传本",partially_extant:"部分存世",lost:"仅见著录",unknown:"尚未判定"},lossCount:"{n} 部 · {note}",stat:{works:"作品",books:"版本",collections:"丛编",entities:"人物",has_image:"有影印",has_text:"有文本",article:"单篇文",poem:"单篇诗"},dataScale:"数据规模",byLoss:"按存佚检索",license:"古籍元数据以 CC0 公有领域发布,可自由复制、改编、再发布。",repo:"数据仓库:",repoNote:"(GitHub,CC0)",version:"当前数据版本:",download:"引用方式与数据下载 →",navLabel:"元数据首页分区",nav:{zhi:"历代史志",sibu:"四部",cong:"丛编",people:"人物",lineage:"版本谱系",sites:"在线资源",data:"数据与授权"},zhiSub:"正史艺文志、经籍志与后人补志,按所志朝代排列;每部志的著录逐条对到作品",shelfLegendCount:"脊下数字=著录条目",shelfLegendClick:"点书脊进作品页",sibuSub:"全部作品按经史子集分类;与「目录」页同一棵分类树",toCatalog:"进入目录 →",unclassifiedNote:"多为只见于史志著录、尚未归类的书",congSub:"大型丛书、影印汇编、出土文献与馆藏,逐种列到版本",allNKindsMore:"全部 {n} 种 →",peopleSub:"历代目录学家,按生卒年排在一条时间轴上",allNPeopleMore:"全部 {n} 人 →",lineageSub:"版本多的作品,看各本的源流与异同",sitesSub:"外部数字图书馆与本站条目的对接",dataSub:"规模、存佚、许可与版本"}),Qr=ht({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:"按作者浏览全部 →"}),hu=ht({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} 条"}),gu=ht({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:"搜索"}),fu=ht({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:"回复"}),xu=ht({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:"有争议"}}),bu={common:su,detail:_i,bookPage:au,workPage:lu,collectionPage:cu,entityPage:du,reader:pu,collated:uu,metaHome:mu,readHome:Qr,catalogPage:hu,searchPage:gu,feedback:fu,lineage:xu};function yu(e){const n={};for(const[i,o]of Object.entries(bu))n[i]=o[e];return n}function bt(e,n){return e.replace(/\{(\w+)\}/g,(i,o)=>String(n[o]??""))}const js=new Map;function jn(e){let n=js.get(e);return n||(n={...e==="zh-Hans"?ou:ru,...yu(e)},js.set(e,n)),n}function vs(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 ll(e){return(n,i)=>{const o=vs(e,n)??vs(jn("zh-Hant"),n)??n;return i?bt(o,i):o}}const ks=new Map;function vn(e){let n=ks.get(e);return n||(n=ll(jn(e)),ks.set(e,n)),n}const cl="bim-locale";function ju(){try{const e=localStorage.getItem(cl);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function vu(e){try{localStorage.setItem(cl,e)}catch{}}const ku="zh-Hans",wu=({locale:e,onLocaleChange:n,converter:i,children:o})=>{const[s,a]=g.useState(e??ku),l=e??s;g.useEffect(()=>{if(e)return;const h=ju();h&&h!==s&&a(h)},[]);const d=g.useMemo(()=>l==="zh-Hans"?i??al():null,[l,i]),c=g.useCallback(h=>{a(h),vu(h),n==null||n(h)},[n]),p=g.useMemo(()=>({locale:l,setLocale:c,messages:jn(l),converter:d}),[l,c,d]);return t.jsx(It.Provider,{value:p,children:o})};function Ie(){const e=g.useContext(It);return(e==null?void 0:e.messages)??jn("zh-Hant")}const Su=2e3;function Pe(){const e=g.useContext(It),n=(e==null?void 0:e.locale)??"zh-Hant",i=(e==null?void 0:e.converter)??null,o=g.useRef(new Map),s=g.useRef(n),a=g.useRef(i);(s.current!==n||a.current!==i)&&(o.current.clear(),s.current=n,a.current=i);const l=g.useCallback(d=>{if(!d)return"";if(!i)return d;const c=o.current.get(d);if(c!==void 0)return c;const p=i(d);if(o.current.size>=Su){const h=o.current.keys().next().value;h!==void 0&&o.current.delete(h)}return o.current.set(d,p),p},[i]);return g.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function ne(){const e=g.useContext(It),{convert:n,locale:i,isSimplified:o}=Pe(),s=(e==null?void 0:e.messages)??jn("zh-Hant"),a=g.useMemo(()=>e?ll(s):vn("zh-Hant"),[e,s]);return g.useMemo(()=>({t:a,convert:n,locale:i,isSimplified:o,messages:s}),[a,n,i,o,s])}const dl=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),_u=new Set([...dl,...Object.keys(ke.VARIANT_CHARS),...Object.keys(Qa.VARIANT_SUPPLEMENT)]),pl=[...sl,"切換為繁體","漢籍リポジトリ"];function $u(e,n=pl){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)=>{_u.has(a)&&o.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),o}function Cu(e,n,i){return e?e==="orig"?null:n==="zh-Hans"?i??al():e==="hant"?ke.normalizeVariants:i:n==="zh-Hans"?i:ke.normalizeVariants}const zu=({mode:e,children:n})=>{const i=g.useContext(It),o=g.useMemo(()=>i&&{...i,converter:Cu(e,i.locale,i.converter)},[i,e]);return t.jsx(It.Provider,{value:o,children:n})};function Tu(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 ws(e){return e==="text+image"?["text","image"]:[e]}function Ss(e){const n=Wt(e);return n.length===0?"text":tu(n)}function Nu(){return{id:"",name:"",url:"",types:["text"],details:""}}const kr=({items:e,onChange:n,onDownload:i,downloadStatuses:o,filterType:s})=>{const a=Ie(),[l,d]=g.useState(null),c=[{value:"text",label:a.resourceTypeShort.text},{value:"image",label:a.resourceTypeShort.image},{value:"text+image",label:a.resourceTypeShort.textImage},{value:"physical",label:a.resourceTypeShort.physical}],p=[{value:"catalog",label:a.rootType.catalog},{value:"search",label:a.rootType.search}],h=w=>{if(!s)return!0;const v=Wt(w);return s==="text"?v.includes("text"):s==="image"?v.includes("image")||v.includes("physical"):s==="physical"?v.includes("physical"):v.includes(s)},u=e.map((w,v)=>({item:w,originalIndex:v})).filter(({item:w})=>h(w)),m=()=>{const w=Nu();s&&(w.types=ws(s)),n([...e,w]),d(e.length)},f=w=>{n(e.filter((v,j)=>j!==w)),d(null)},x=(w,v,j)=>{const C=[...e];if(C[w]={...C[w],[v]:j},v==="url"&&!C[w].id){const S=Tu(j);S&&(C[w].id=S)}n(C)},k=(w,v)=>{const j=[...e],{type:C,...S}=j[w];j[w]={...S,types:ws(v)},n(j)},y=(w,v,j)=>{const S={...e[w].metadata||{}};j?S[v]=j:delete S[v],x(w,"metadata",Object.keys(S).length>0?S:void 0)},$=(w,v)=>{const j=v.trim()?v.split(/[,,、]/).map(C=>C.trim()).filter(Boolean):void 0;x(w,"structure",j)},b=(w,v,j)=>{const S=e[w].coverage||{level:1,ranges:""};v==="level"?S.level=parseInt(j)||1:S.ranges=j,x(w,"coverage",S.ranges?S:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[u.map(({item:w,originalIndex:v})=>{var j,C,S;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===v?null:v),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:l===v?"▼":"▶"}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:Iu(Ss(w)),color:r("on-color-fg")},children:(()=>{var A,T;const _=Wt(w);return _.length===0?"text":_.length===1?((A=c.find(z=>z.value===_[0]))==null?void 0:A.label)??_[0]:_.includes("text")&&_.includes("image")?((T=c.find(z=>z.value==="text+image"))==null?void 0:T.label)??"text+image":_.join("+")})()}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:w.name||`${a.editor.resourcePlaceholder} ${v+1}`}),w.id&&t.jsx("span",{style:{fontSize:"11px",opacity:.5},children:w.id}),w.url&&t.jsx("a",{href:w.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),i&&w.url&&Eu(v,o==null?void 0:o[v],i,a),t.jsx("button",{onClick:_=>{_.stopPropagation(),f(v)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:a.editor.deleteThisResource,children:"✕"})]}),l===v&&t.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:[Jp(w,"image")&&w.url&&Ru(w,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:$n,children:[t.jsx("span",{style:Cn,children:a.label.type}),t.jsx("select",{value:Ss(w),onChange:_=>k(v,_.target.value),style:{...Ct,flex:1},children:c.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]}),t.jsxs("label",{style:$n,children:[t.jsx("span",{style:Cn,children:a.label.rootType}),t.jsx("select",{value:w.root_type||"catalog",onChange:_=>x(v,"root_type",_.target.value),style:{...Ct,flex:1},children:p.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:w.id,onChange:_=>x(v,"id",_.target.value),placeholder:a.editor.idAutoExtract,style:{...Ct,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:w.name,onChange:_=>x(v,"name",_.target.value),placeholder:a.editor.resourceName,style:{...Ct,flex:1}})]}),t.jsx("input",{type:"text",value:w.url,onChange:_=>x(v,"url",_.target.value),placeholder:a.editor.resourceUrl,style:Ct}),t.jsx("input",{type:"text",value:((j=w.structure)==null?void 0:j.join("、"))||"",onChange:_=>$(v,_.target.value),placeholder:a.editor.structurePlaceholder,style:Ct}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:$n,children:[t.jsx("span",{style:Cn,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((C=w.coverage)==null?void 0:C.level)??"",onChange:_=>b(v,"level",_.target.value),placeholder:"1",style:{...Ct,width:"60px"}})]}),t.jsxs("label",{style:{...$n,flex:1},children:[t.jsx("span",{style:Cn,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:((S=w.coverage)==null?void 0:S.ranges)||"",onChange:_=>b(v,"ranges",_.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...Ct,flex:1}})]})]}),t.jsx("textarea",{value:w.details||"",onChange:_=>x(v,"details",_.target.value),placeholder:a.editor.detailsPlaceholder,style:{...Ct,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(([_,A])=>{var T;return t.jsxs("label",{style:{...$n,gap:"4px"},children:[t.jsx("span",{style:{...Cn,minWidth:"56px"},children:A}),t.jsx("input",{type:"text",value:((T=w.metadata)==null?void 0:T[_])||"",onChange:z=>y(v,_,z.target.value),placeholder:A,style:{...Ct,flex:1}})]},_)})})]})]})]})]},v)}),t.jsxs("button",{onClick:m,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:a.action.addResource})]})]})};function Iu(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 Eu(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 Ru(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 Ct={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"},$n={display:"flex",alignItems:"center",gap:"6px"},Cn={fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap"},_s={text:r("restype-text"),image:r("restype-image"),"text+image":r("restype-text-image"),physical:r("restype-physical")};function Lu(e){return e.includes("text")&&e.includes("image")?_s["text+image"]:_s[e[0]||"physical"]}const eo=({items:e,groupByType:n=!0,resourceGroups:i,onNavigate:o,renderLink:s})=>{const a=Ie(),{convert:l}=Pe(),d=g.useMemo(()=>Xr(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=g.useMemo(()=>{const y=new Map,$=[];for(const b of d){const w=b.group;w?(y.has(w)||y.set(w,[]),y.get(w).push(b)):$.push(b)}for(const b of y.values())b.sort((w,v)=>{const j=C=>C.group_role==="origin"?0:C.group_role==="mirror"?1:2;return j(w)-j(v)});return{mirrorGroups:y,ungroupedItems:$}},[d]),h={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},u=y=>h[y]?h[y]:y.split("+").map($=>h[$]||$).join("+");if(!d||d.length===0)return t.jsx("div",{style:{padding:"16px",color:r("desc-fg"),fontSize:"13px",textAlign:"center"},children:a.misc.noResources});if(!n)return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:d.map((y,$)=>t.jsx(ir,{item:y},y.id||$))});const m=(y,$)=>{const b=i==null?void 0:i[y],w=(b==null?void 0:b.label)||y,v=b==null?void 0:b.description;return t.jsxs("div",{style:{padding:"10px 12px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:r("input-bg"),display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(w)}),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:$.map((j,C)=>t.jsx(ir,{item:j,onNavigate:o,renderLink:s},j.id||C))})]},`group-${y}`)},f=new Map;for(const y of p){const $=Kr(Wt(y));f.has($)||f.set($,[]),f.get($).push(y)}const x=["text","image","text+image","physical"],k=[...x.filter(y=>f.has(y)),...[...f.keys()].filter(y=>!x.includes(y)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,$])=>m(y,$)),k.map(y=>{const $=f.get(y),b=Lu(y.split("+"));return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:b,whiteSpace:"nowrap",flexShrink:0},children:u(y)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:$.map((w,v)=>t.jsx(ir,{item:w,onNavigate:o,renderLink:s},w.id||v))})]},y)})]})},Au={bw:{label:"",bg:r("colormode-bw-bg"),fg:r("colormode-bw-fg")},color:{label:"",bg:r("colormode-color-bg"),fg:r("colormode-color-fg")}},ir=({item:e})=>{const n=Ie(),{convert:i}=Pe(),[o,s]=g.useState(!1),a=g.useMemo(()=>(e.url?bn(e.url):void 0)||i(e.name),[e.url,e.name,i]),l=g.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||rl(x)})),[e.volumes]),d=l&&l.length>0,c=d?new Set(l.filter(x=>x.status!=="missing").map(x=>x.volume)).size:0,p=d?new Set(l.filter(x=>x.status==="missing").map(x=>x.volume)).size:0,h=e.expected_volumes??(d?c+p:0),u=e.color_mode?{...Au[e.color_mode],label:n.colorMode[e.color_mode]}:null,m=e.details&&!d?i(e.details):null,f={display:"inline-flex",alignItems:"center",gap:"5px",padding:"4px 10px",border:`1px solid ${r("widget-border")}`,borderRadius:"5px",background:r("input-bg"),fontSize:"12px",color:r("fg"),lineHeight:1.4,verticalAlign:"middle"};return t.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[t.jsxs("div",{style:f,children:[t.jsx("span",{style:{fontWeight:500},children:a}),u&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:u.bg,color:u.fg},children:u.label}),m&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:m}),d&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[c,"/",h,n.unit.volume,p>0&&t.jsx("span",{style:{color:r("missing-fg"),marginLeft:"3px"},children:bt(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=Zr(e.metadata);return x?Jr(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 k=x.status==="missing";return x.url&&!k?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(k?"missing-fg":"desc-fg"),textDecoration:k?"line-through":"none",opacity:k?.6:1},children:x.volume},x.volume)})})]})},ul=({indexSource:e,syncConfig:n,variant:i="index-browser",onSwitchMode:o,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=Ie(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,h=(n==null?void 0:n.repoPath)||"",u=h?h.split(/[/\\]/).pop()||h:"",m={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:r("primary-soft"),color:r("primary")},f={onMouseOver:k=>k.currentTarget.style.opacity="0.8",onMouseOut:k=>k.currentTarget.style.opacity="1"},x=t.jsxs("div",{onClick:s,title:p?d.mode.switchToOfficial:d.mode.switchToDraft,style:{...m,background:r(p?"warning":"success"),color:r("on-color-fg")},...f,children:[t.jsx("span",{children:p?"📝":"📚"}),t.jsx("span",{children:p?"draft":"official"})]});return i==="index-browser"?c?t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[x,t.jsxs("div",{onClick:o,title:d.mode.switchToSync,style:m,...f,children:[t.jsx("span",{children:"📁"}),t.jsx("span",{children:d.mode.localMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsxs("div",{onClick:l,title:h||d.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px"},...f,children:[t.jsx("span",{children:"📂"}),u&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:u})]})]}):t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.jsxs("div",{onClick:o,title:d.mode.switchToLocal,style:m,...f,children:[t.jsx("span",{children:"🌐"}),t.jsx("span",{children:d.mode.syncMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsx("div",{onClick:a,title:u||d.mode.configurePath,style:{...m,background:"transparent",padding:"6px",fontSize:"12px"},...f,children:t.jsx("span",{children:"⚙️"})})]})]}):t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[t.jsxs("div",{onClick:o,title:c?d.mode.switchToGithub:d.mode.switchToLocal,style:m,...f,children:[t.jsx("span",{children:c?"📁":"🌐"}),t.jsx("span",{children:c?d.mode.localMode:d.mode.githubSync}),t.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&t.jsxs("div",{onClick:l,title:h||d.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px",minWidth:h?"100px":"auto",justifyContent:"space-between"},...f,children:[t.jsx("span",{children:"📂"}),u&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:u})]}),!c&&u&&t.jsxs("div",{style:{...m,background:r("mode-active-bg"),color:r("on-color-fg"),cursor:"default"},title:h,children:[t.jsx("span",{children:"📂"}),t.jsx("span",{style:{fontSize:"11px"},children:u})]})]})},$i="bim-search-history",$s=10,Cs=8;function Ln(){try{const e=localStorage.getItem($i);return e?JSON.parse(e):[]}catch{return[]}}function ml(e){try{const n=Ln().filter(i=>i!==e);n.unshift(e),n.length>$s&&(n.length=$s),localStorage.setItem($i,JSON.stringify(n))}catch{}}function Mu(e){try{const n=Ln().filter(i=>i!==e);localStorage.setItem($i,JSON.stringify(n))}catch{}}function Pu(){try{localStorage.removeItem($i)}catch{}}const hl=({transport:e,value:n,onChange:i,onSearch:o,onEntrySelect:s,placeholder:a})=>{const l=Ie(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,h]=g.useState(!1),[u,m]=g.useState([]),[f,x]=g.useState(-1),[k,y]=g.useState(Ln),$=g.useRef(null),b=g.useRef(null),w=g.useRef(null),v=g.useRef(!1);g.useEffect(()=>{x(-1);const z=n.trim();if(!z){m(k.map(I=>({type:"history",text:I})));return}if(!e.searchAll){m([]);return}let M=!1;const H=setTimeout(()=>{e.searchAll(z,Cs).then(I=>{if(M)return;const R=[...I.works,...I.books,...I.collections,...I.entities??[]];m(R.slice(0,Cs).map(P=>({type:"entry",text:P.title||P.id,entry:P})))}).catch(()=>{M||m([])})},80);return()=>{M=!0,clearTimeout(H)}},[n,k,e]),g.useEffect(()=>{const z=M=>{w.current&&!w.current.contains(M.target)&&h(!1)};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]),g.useEffect(()=>{const z=M=>{var H,I;if(M.key==="/"&&document.activeElement!==$.current){const R=(H=document.activeElement)==null?void 0:H.tagName;if(R==="INPUT"||R==="TEXTAREA"||R==="SELECT")return;M.preventDefault(),(I=$.current)==null||I.focus()}};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[]);const j=g.useCallback(z=>{z.trim()&&(ml(z.trim()),y(Ln())),o(z),h(!1)},[o]),C=g.useCallback(z=>{z.type==="history"?(i(z.text),j(z.text)):z.entry&&(s?(s(z.entry),h(!1)):(i(z.text),j(z.text)))},[i,j,s]),S=g.useCallback(z=>{if(!p||u.length===0){z.key==="Enter"&&j(n);return}switch(z.key){case"ArrowDown":z.preventDefault(),x(M=>(M+1)%u.length);break;case"ArrowUp":z.preventDefault(),x(M=>(M-1+u.length)%u.length);break;case"Enter":z.preventDefault(),f>=0&&f<u.length?C(u[f]):j(n);break;case"Escape":z.preventDefault(),h(!1);break}},[p,u,f,n,j,C]),_=g.useCallback((z,M)=>{M.stopPropagation(),Mu(z),y(Ln()),m(H=>H.filter(I=>!(I.type==="history"&&I.text===z)))},[]),A=g.useCallback(z=>{z.stopPropagation(),Pu(),y([]),m([])},[]);g.useEffect(()=>{if(f>=0&&b.current){const z=b.current.children;z[f]&&z[f].scrollIntoView({block:"nearest"})}},[f]);const T=!n.trim()&&k.length>0;return t.jsxs("div",{ref:w,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:$,type:"text",placeholder:d,value:n,onChange:z=>{i(z.target.value),h(!0)},onCompositionStart:()=>{v.current=!0},onCompositionEnd:()=>{v.current=!1},onFocus:()=>{h(!0)},onKeyDown:S,style:{width:"100%",padding:"8px 12px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),fontSize:"14px",boxSizing:"border-box"}}),p&&u.length>0&&t.jsxs("div",{ref:b,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:r("input-bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"6px",boxShadow:r("shadow-dropdown"),zIndex:100,maxHeight:"320px",overflow:"auto"},children:[T&&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:A,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),u.map((z,M)=>t.jsxs("div",{onClick:()=>C(z),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:r("fg"),background:M===f?r("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:z.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.text}),z.entry&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:[c[z.entry.type],z.entry.edition&&` · ${z.entry.edition}`,z.entry.author&&` · ${z.entry.author}`]}),z.type==="history"&&t.jsx("button",{onClick:H=>_(z.text,H),style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:l.action.remove,children:"×"})]},`${z.type}-${z.text}-${M}`))]})]})},kn=({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"}}),Ci={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},gl=new Set(["work","book","entity"]);function Bu(e){return bl(e)||!!e.sort}function Ou(e,n){return n.sort&&gl.has(e)?n.sort:void 0}const zi=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],Ti=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],fl=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],xl={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function Ni(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 bl(e){return Ni(e)>0}function Wu(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 yl(e,n){const i=xl[e];return Wu(n).every(o=>i.has(o))}const zn=e=>JSON.stringify(e);function Fu(e,n){if(!yl(n,e))return null;const i=[];if(e.dynasty.length){const o=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=zi.find(l=>l.key===s))==null?void 0:a.values)??[]})));o.length===1?i.push(`dynasty = ${zn(o[0])}`):o.length>1&&i.push(`dynasty IN [${o.map(zn).join(", ")}]`)}return e.classification.length&&i.push(e.classification.length===1?`classification = ${zn(e.classification[0])}`:`classification IN [${e.classification.map(zn).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 = ${zn(e.loss)}`),i.join(" AND ")}const dt={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},jl="_";function xi(e,n=new URLSearchParams){for(const i of Object.values(dt))n.delete(i);return e.dynasty.length&&n.set(dt.dynasty,e.dynasty.join(",")),e.classification.length&&n.set(dt.classification,e.classification.map(i=>i||jl).join(",")),e.hasImage&&n.set(dt.hasImage,"1"),e.hasText&&n.set(dt.hasText,"1"),e.hasCollated&&n.set(dt.hasCollated,"1"),e.loss&&n.set(dt.loss,e.loss),e.sort&&n.set(dt.sort,e.sort),n}function Hu(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),i=new Set(zi.map(a=>a.key)),o=new Set(Ti.map(a=>a.value)),s=e.get(dt.loss);return{dynasty:Array.from(new Set(n(dt.dynasty).filter(a=>i.has(a)))),classification:Array.from(new Set(n(dt.classification).map(a=>a===jl?"":a).filter(a=>o.has(a)))),hasImage:e.get(dt.hasImage)==="1",hasText:e.get(dt.hasText)==="1"||e.get(dt.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(dt.sort))??""}}function Du(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 zs(e,n){return e.includes(n)?e.filter(i=>i!==n):[...e,n]}const Uu=({filters:e,onChange:n})=>{const i=Ie(),o=i.searchV4,{convert:s}=Pe(),[a,l]=g.useState(!1),d=g.useId(),c=Ni(e),p=h=>n({...e,...h});return t.jsxs("aside",{className:"bim-sr-aside","aria-label":s(o.filterTitle),children:[t.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":a,"aria-controls":d,onClick:()=>l(h=>!h),children:[t.jsxs("span",{children:[s(o.filterButton),c>0&&t.jsx("span",{className:"bim-sr-fn",children:s(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:zi.map(h=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(h.key),onClick:()=>p({dynasty:zs(e.dynasty,h.key)}),children:s(h.key)},h.key))})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.classification)}),Ti.map(h=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(h.value),onChange:()=>p({classification:zs(e.classification,h.value)})}),h.value?s(h.label):i.searchPage.unclassified]},h.value||"_"))]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.resources)}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasImage,onChange:h=>p({hasImage:h.target.checked})}),s(o.hasImage)]}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasText,onChange:h=>p({hasText:h.target.checked})}),s(o.hasText)]})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{id:`${d}-loss`,children:s(o.extant)}),t.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${d}-loss`,children:fl.map(h=>t.jsx("button",{type:"button","aria-pressed":e.loss===h.value,onClick:()=>p({loss:h.value}),children:i.searchPage.loss[h.value||"all"]},h.value||"all"))})]}),c>0&&t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...Ci,sort:e.sort}),children:s(o.clearAllFilters)})]})]})};function vl({text:e,query:n}){const i=(n??"").trim();if(!i||!e)return t.jsx(t.Fragment,{children:e});const o=e.toLowerCase(),s=i.toLowerCase(),a=[];let l=0,d=0;for(;l<e.length;){const c=o.indexOf(s,l);if(c<0){a.push(e.slice(l));break}c>l&&a.push(e.slice(l,c)),a.push(t.jsx("mark",{className:"bim-sr-hl",children:e.slice(c,c+s.length)},d++)),l=c+s.length}return t.jsx(t.Fragment,{children:a})}const Ts=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ie(),a=s.searchV4,{convert:l}=Pe(),d=rt();return t.jsx("div",{className:"bim-sr-tablewrap",children:t.jsxs("table",{className:"bim-sr-table",children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:"34%"}}),t.jsx("col",{style:{width:"8%"}}),t.jsx("col",{style:{width:"19%"}}),t.jsx("col",{style:{width:"13%"}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"14%"}})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:l(a.colTitle)}),t.jsx("th",{scope:"col",children:l(a.colType)}),t.jsx("th",{scope:"col",children:l(a.colAuthor)}),t.jsx("th",{scope:"col",children:l(a.colEra)}),t.jsx("th",{scope:"col",children:l(a.colClass)}),t.jsx("th",{scope:"col",style:{textAlign:"right"},children:l(a.colResource)})]})}),t.jsx("tbody",{children:e.map(c=>{const p=l(c.title||c.primary_name||c.id),h=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",u=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${l(c.author)}${c.role&&c.role!=="author"?` ${l(c.role)}`:""}`:"",m=c.type==="book"?c.era??c.dynasty:c.dynasty,f=m?l(m):"",x=c.classification?l(c.classification):"",k=[];c.has_image&&k.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&k.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&k.push({label:a.tagLost,cls:"bim-sr-tag--lost"});const y=[u,f,x].filter(Boolean).join(" · ");return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-sr-c-title",children:[t.jsxs("div",{className:"bim-sr-tl",children:[t.jsx("a",{href:d(c.id),onClick:$=>i(c,$),children:t.jsx(vl,{text:p,query:n?l(n):void 0})}),h&&t.jsx("span",{className:"bim-sr-measure",children:h})]}),y&&t.jsx("span",{className:"bim-sr-sub",children:y})]}),t.jsxs("td",{className:"bim-sr-c-type",children:[t.jsx(kn,{type:c.type,size:6})," ",o(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:u||"—"}),t.jsx("td",{className:"bim-sr-c-era",children:f||"—"}),t.jsx("td",{className:"bim-sr-c-cls",children:x||"—"}),t.jsx("td",{className:"bim-sr-c-res",children:k.map($=>t.jsx("span",{className:`bim-sr-tag ${$.cls}`,children:l($.label)},$.label))})]},c.id)})})]})})},Vu=`
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
- `,Ts=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ie(),a=s.searchV4,{convert:l}=Pe(),d=rt();return t.jsxs("div",{className:"bim-sc-grid",children:[t.jsx("style",{children:Vu}),e.map(c=>{const p=l(c.title||c.primary_name||c.id),h=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",m=[c.type==="entity"?c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:"":`${c.dynasty?`〔${l(c.dynasty)}〕`:""}${c.author?l(c.author):""}`,c.type==="book"&&c.edition?l(c.edition):"",h].filter(Boolean).join(" · "),f=[o(c.type),c.classification?l(c.classification):""].filter(Boolean).join(" · "),x=[];return c.has_image&&x.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&x.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&x.push({label:a.tagLost,cls:"bim-sr-tag--lost"}),t.jsxs("a",{className:"bim-sc",href:d(c.id),onClick:k=>i(c,k),children:[t.jsx("span",{className:"bim-sc-t",children:t.jsx(vl,{text:p,query:n?l(n):void 0})}),m&&t.jsx("span",{className:"bim-sc-m",children:m}),c.descriptionSnippet&&t.jsx("p",{className:"bim-sc-s",children:Yr(c.descriptionSnippet).map((k,y)=>k.marked?t.jsx("mark",{children:l(k.text)},y):t.jsx(g.Fragment,{children:l(k.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(k=>t.jsx("span",{className:`bim-sr-tag ${k.cls}`,children:l(k.label)},k.label))})]})]},c.id)})]})};function Gu(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 Yu(e,n,i){const o=Math.max(1,Math.ceil(n/i));return Math.min(Math.max(1,e),o)}const qu=({page:e,pageSize:n,total:i,totalLabel:o,onPage:s})=>{const a=Ie().searchV4,{convert:l}=Pe(),d=Math.max(1,Math.ceil(i/n));return i<=0?null:t.jsxs("nav",{className:"bim-sr-pager","aria-label":l(a.pagerLabel),children:[t.jsx("span",{className:"bim-sr-info",children:l(bt(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)})}),Gu(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)})})]})]})},kl="(max-width: 719px)",Ku=`${kl}, (pointer: coarse)`,Xu=`
15
+ `,Ns=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ie(),a=s.searchV4,{convert:l}=Pe(),d=rt();return t.jsxs("div",{className:"bim-sc-grid",children:[t.jsx("style",{children:Vu}),e.map(c=>{const p=l(c.title||c.primary_name||c.id),h=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",m=[c.type==="entity"?c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:"":`${c.dynasty?`〔${l(c.dynasty)}〕`:""}${c.author?l(c.author):""}`,c.type==="book"&&c.edition?l(c.edition):"",h].filter(Boolean).join(" · "),f=[o(c.type),c.classification?l(c.classification):""].filter(Boolean).join(" · "),x=[];return c.has_image&&x.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&x.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&x.push({label:a.tagLost,cls:"bim-sr-tag--lost"}),t.jsxs("a",{className:"bim-sc",href:d(c.id),onClick:k=>i(c,k),children:[t.jsx("span",{className:"bim-sc-t",children:t.jsx(vl,{text:p,query:n?l(n):void 0})}),m&&t.jsx("span",{className:"bim-sc-m",children:m}),c.descriptionSnippet&&t.jsx("p",{className:"bim-sc-s",children:qr(c.descriptionSnippet).map((k,y)=>k.marked?t.jsx("mark",{children:l(k.text)},y):t.jsx(g.Fragment,{children:l(k.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(k=>t.jsx("span",{className:`bim-sr-tag ${k.cls}`,children:l(k.label)},k.label))})]})]},c.id)})]})};function Gu(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 Yu(e,n,i){const o=Math.max(1,Math.ceil(n/i));return Math.min(Math.max(1,e),o)}const qu=({page:e,pageSize:n,total:i,totalLabel:o,onPage:s})=>{const a=Ie().searchV4,{convert:l}=Pe(),d=Math.max(1,Math.ceil(i/n));return i<=0?null:t.jsxs("nav",{className:"bim-sr-pager","aria-label":l(a.pagerLabel),children:[t.jsx("span",{className:"bim-sr-info",children:l(bt(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)})}),Gu(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)})})]})]})},kl="(max-width: 719px)",Ku=`${kl}, (pointer: coarse)`,Xu=`
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; }
@@ -117,7 +117,7 @@
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
- `,eo="bim-search-view",rr=50,Ns=5,An=1e3;function pi(e){return e>=An?`${An.toLocaleString()}+`:e.toLocaleString()}const Zu={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function Ju(e){return e&&Zu[e.toLowerCase()]||"all"}function Qu(e){return e==="all"?null:e}const Is=["work","collection","book","entity"],em={work:"works",collection:"collections",book:"books",entity:"entities"},tm={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function nm(){try{return window.localStorage.getItem(eo)==="card"?"card":"table"}catch{return"table"}}function im(e){try{window.localStorage.setItem(eo,e)}catch{}}const cn=(e,n)=>(e==null?void 0:e[tm[n]])??0,or=(e,n)=>(e==null?void 0:e[em[n]])??[],wl=({transport:e,query:n,filters:i,onFiltersChange:o,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const h=Ie(),u=h.searchV4,{convert:m}=Pe(),f=!!e.supportsSearchFilters,x=g.useMemo(()=>f?i:Ci,[f,i]),[k,y]=g.useState("table");g.useEffect(()=>{y(nm())},[]);const $=W=>{y(W),im(W)},[b,w]=g.useState(l??"all"),v=g.useRef(b);v.current=b,g.useEffect(()=>{l!==void 0&&l!==v.current&&(w(l),C(1))},[l]);const[j,C]=g.useState(c&&c>0?c:1),S=g.useRef(j);S.current=j,g.useEffect(()=>{c!==void 0&&c>0&&c!==S.current&&C(c)},[c]);const _=g.useRef(null),L=g.useCallback(W=>{var he;C(W),p==null||p(W);const U=_.current;U&&U.getBoundingClientRect().top<0&&((he=U.scrollIntoView)==null||he.call(U,{block:"start",behavior:"instant"}))},[p]),[T,z]=g.useState(null),[M,H]=g.useState(null),[N,R]=g.useState(!1),[A,J]=g.useState(""),ee=xi(x).toString(),oe=Ni(x)>0,V=xi({...x,sort:""}).toString(),me=g.useRef({query:n,filterOnlyKey:V,sort:x.sort});g.useEffect(()=>{const W=me.current;W.query!==n||W.filterOnlyKey!==V?(w("all"),C(1)):W.sort!==x.sort&&C(1),me.current={query:n,filterOnlyKey:V,sort:x.sort}},[n,V,x.sort]),g.useEffect(()=>{let W=!1;return R(!0),J(""),(async()=>{try{let U;if(e.searchAll)U=await e.searchAll(n,Ns,x);else{const he=["work","book","collection","entity"],K=await Promise.all(he.map(B=>e.search(n,B,{page:1,pageSize:Ns,filters:x})));U={works:K[0].entries,books:K[1].entries,collections:K[2].entries,entities:K[3].entries,totalWorks:K[0].total,totalBooks:K[1].total,totalCollections:K[2].total,totalEntities:K[3].total}}W||z(U)}catch(U){W||(J(U instanceof Error?U.message:String(U)),z(null))}finally{W||R(!1)}})(),()=>{W=!0}},[e,n,ee]);const G=b;g.useEffect(()=>{if(b==="all"){H(null);return}let W=!1;return R(!0),(async()=>{try{const U=await e.search(n,b,{page:j,pageSize:rr,filters:x});W||H({key:G,entries:U.entries,total:U.total})}catch(U){W||(J(U instanceof Error?U.message:String(U)),H(null))}finally{W||R(!1)}})(),()=>{W=!0}},[e,n,ee,b,j]);const q=M&&M.key===G?M:null;g.useEffect(()=>{if(b==="all"||!q||N)return;const W=Math.min(q.total,An),U=Yu(j,W,rr);q.entries.length===0&&W>0&&U!==j&&(C(U),p==null||p(U))},[b,q,N,j]);const ce=g.useMemo(()=>Is.filter(W=>cn(T,W)>0),[T]),we=ce.reduce((W,U)=>W+cn(T,U),0),O=ce.some(W=>cn(T,W)>=An)?`${we.toLocaleString()}+`:we.toLocaleString(),ye=!N&&!A&&T!==null&&we===0,de=g.useCallback(W=>{w(W),C(1),d==null||d(W)},[d]),ze=g.useMemo(()=>{const W=[];return x.dynasty.forEach(U=>W.push({name:U,remove:()=>o({...x,dynasty:x.dynasty.filter(he=>he!==U)})})),x.classification.forEach(U=>{var he;return W.push({name:U?((he=Ti.find(K=>K.value===U))==null?void 0:he.label)??U:h.searchPage.unclassified,remove:()=>o({...x,classification:x.classification.filter(K=>K!==U)})})}),x.hasImage&&W.push({name:u.hasImage,remove:()=>o({...x,hasImage:!1})}),x.hasText&&W.push({name:u.hasText,remove:()=>o({...x,hasText:!1})}),x.hasCollated&&W.push({name:u.hasCollated,remove:()=>o({...x,hasCollated:!1})}),x.loss&&W.push({name:`${u.extant}:${h.searchPage.loss[x.loss]}`,remove:()=>o({...x,loss:""})}),W},[x,o,u,h]),Ce={query:n,onEntryLinkClick:s,typeName:a},Oe=W=>k==="table"?t.jsx(zs,{entries:W,...Ce}):t.jsx(Ts,{entries:W,...Ce}),ne=Is.flatMap(W=>or(T,W));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":f?void 0:"true",children:[t.jsx("style",{children:Xu}),f&&t.jsx(Uu,{filters:x,onChange:o}),t.jsxs("div",{className:"bim-sr-main","aria-busy":N,ref:_,children:[ce.length>0&&t.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":h.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${r("rule")}`},children:[t.jsxs(Es,{on:b==="all",onClick:()=>de("all"),children:[h.search.allTab," ",t.jsx("small",{children:O})]}),ce.map(W=>t.jsxs(Es,{on:b===W,onClick:()=>de(W),children:[a(W)," ",t.jsx("small",{children:pi(cn(T,W))})]},W))]}),t.jsxs("div",{className:"bim-sr-tools",children:[f&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":m(u.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>o({...x,sort:""}),children:m(u.sortRelevance)}),["era","title"].map(W=>{const U=x.sort.startsWith(`${W}:`)?x.sort.endsWith("desc")?"desc":"asc":null,he=W==="era"?u.sortEra:u.sortTitle,K=W==="era"?U==="desc"?u.sortEraDesc:u.sortEraAsc:U==="desc"?u.sortTitleDesc:u.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":U!==null,title:m(K),onClick:()=>o({...x,sort:`${W}:${U==="asc"?"desc":"asc"}`}),children:[m(he),U?t.jsxs("span",{"aria-hidden":"true",children:[" ",U==="asc"?"↑":"↓"]}):null]},W)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":m(u.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":k==="table",onClick:()=>$("table"),children:m(u.viewTable)}),t.jsx("button",{type:"button","aria-pressed":k==="card",onClick:()=>$("card"),children:m(u.viewCard)})]})]}),oe&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:m(bt(u.filteredCount,{n:O}))}),ze.map(W=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":m(bt(u.removeFilter,{name:W.name})),onClick:W.remove,children:[m(W.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},W.name))]}),A&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:A}),ye&&t.jsx("div",{className:"bim-sr-empty",children:m(oe?u.emptyFiltered:bt(h.search.noResultsFor,{query:n}))}),!A&&!ye&&b==="all"&&T&&(k==="table"?t.jsxs(t.Fragment,{children:[t.jsx(zs,{entries:ne,...Ce}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:m(u.limitedNote)})]}):t.jsx(t.Fragment,{children:ce.map(W=>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(kn,{type:W,size:8}),a(W),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:r("meta-fg")},children:[pi(cn(T,W))," ",h.unit.items]})]}),cn(T,W)>or(T,W).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>de(W),children:h.action.viewAll})]}),t.jsx(Ts,{entries:or(T,W),...Ce})]},W))})),!A&&b!=="all"&&!q&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:h.search.loading}),!A&&b!=="all"&&q&&q.entries.length>0&&t.jsxs(t.Fragment,{children:[Oe(q.entries),t.jsx(qu,{page:j,pageSize:rr,total:Math.min(q.total,An),totalLabel:pi(q.total),onPage:L})]}),!A&&b!=="all"&&q&&q.entries.length===0&&!N&&t.jsxs("div",{className:"bim-sr-empty",children:[m(oe?u.emptyFiltered:bt(h.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>de("all"),children:h.search.allTab})})]})]})]})};function Es({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 hn="bim-recent-ids",Rs="bim-recent-entries",Ls=50;function Yt(){try{const e=localStorage.getItem(hn);if(e)return JSON.parse(e);const n=localStorage.getItem(Rs);if(n){const i=JSON.parse(n).map(o=>o.id);return localStorage.setItem(hn,JSON.stringify(i)),localStorage.removeItem(Rs),i}return[]}catch{return[]}}function wr(e){try{const n=Yt().filter(i=>i!==e);n.unshift(e),n.length>Ls&&(n.length=Ls),localStorage.setItem(hn,JSON.stringify(n))}catch{}}function Sl(e){try{const n=Yt().filter(i=>i!==e);localStorage.setItem(hn,JSON.stringify(n))}catch{}}function to(){try{localStorage.removeItem(hn)}catch{}}async function no(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 sr=5,rm=50,om=200,As={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},Sr=({transport:e,indexSource:n="local",syncConfig:i,onEntryClick:o,onNewEntry:s,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c,hideModeIndicator:p,resultVariant:h="compact",renderEntry:u,initialQuery:m,onQueryChange:f,headerRight:x,reserveViewportHeight:k=!1,filtersEnabled:y=!1,filters:$=Ci,onFiltersChange:b,resultTab:w,onResultTabChange:v,resultPage:j,onResultPageChange:C})=>{const S=Ie(),_=[{type:"work",name:S.indexType.work,key:"works"},{type:"book",name:S.indexType.book,key:"books"},{type:"collection",name:S.indexType.collection,key:"collections"},{type:"entity",name:S.indexType.entity,key:"entities"}],L=["work","collection","book","entity"],[T,z]=g.useState(m??""),[M,H]=g.useState(null),[N,R]=g.useState(m??""),A=xi($).toString(),[J,ee]=g.useState($);g.useEffect(()=>{ee($)},[A]);const oe=I=>{ee(I),b==null||b(I)},[V,me]=g.useState(null),[G,q]=g.useState("all"),[ce,we]=g.useState(!1),[O,ye]=g.useState(null),[de,ze]=g.useState(""),[Ce,Oe]=g.useState(!(m!=null&&m.trim())),[ne,W]=g.useState(Yt),[U,he]=g.useState([]),[K,B]=g.useState(!1),[Q,le]=g.useState(!1),[ie,D]=g.useState(null),[se,Te]=g.useState(null),Me=g.useRef(void 0),Le=g.useRef(!1),F=g.useCallback(async(I,Y)=>{if(!I.trim()){Oe(!0),H(null),me(null);return}if(Oe(!1),y){R(I);return}we(!0),ze("");try{if(e.searchAll){const pe=await e.searchAll(I,Y??sr);H(pe)}else{const pe=["work","book","collection","entity"],ve=await Promise.all(pe.map(Ee=>e.search(I,Ee,{page:1,pageSize:Y??sr})));H({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})}}catch(pe){ze(pe instanceof Error?pe.message:String(pe)),H(null)}finally{we(!1)}},[e,y]);g.useEffect(()=>{let I=!1;const Y=()=>{var Ae,qe;const pe=["work","book","collection","entity"],ve=Promise.all(pe.map(X=>e.loadEntries(X,{page:1,pageSize:1}).catch(()=>({total:0})))),Ee=((Ae=e.getResourceCounts)==null?void 0:Ae.call(e).catch(()=>null))??Promise.resolve(null),ge=((qe=e.getSubtypeStats)==null?void 0:qe.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([ve,Ee,ge]).then(([X,$e,Fe])=>{I||(D({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}),Fe&&Te(Fe))})};return e.getCounts?e.getCounts().then(pe=>{var ve,Ee;I||(D({works:pe.works,books:pe.books,collections:pe.collections,entities:pe.entities,hasText:(ve=pe.resourceCounts)==null?void 0:ve.hasText,hasImage:(Ee=pe.resourceCounts)==null?void 0:Ee.hasImage}),pe.subtypeStats&&Te(pe.subtypeStats))}).catch(()=>{I||Y()}):Y(),()=>{I=!0}},[e]),g.useEffect(()=>{Le.current||!(m!=null&&m.trim())||(Le.current=!0,F(m))},[m,F]);const ae=g.useCallback(I=>{if(z(I),!I.trim()){f==null||f(I),Oe(!0),H(null),me(null),q("all");return}Me.current&&clearTimeout(Me.current),Me.current=setTimeout(()=>{me(null),q("all"),f==null||f(I),F(I)},om)},[F,f]),fe=g.useCallback(I=>{Me.current&&clearTimeout(Me.current),q("all"),f==null||f(I),F(I)},[F,f]),P=g.useCallback(I=>{me(I),F(T,rm)},[T,F]);g.useEffect(()=>{if(!ne.length){he([]);return}let I=!1;return B(!0),Promise.all(ne.slice(0,10).map(Y=>no(e,Y))).then(Y=>{I||(he(Y),B(!1))}),()=>{I=!0}},[ne,e]);const xe=I=>{ye(I.id),wr(I.id),W(Yt()),o==null||o(I)},re=(I,Y)=>{if(o&&am(Y)){Y.preventDefault(),xe(I);return}wr(I.id),W(Yt())},je=I=>{Sl(I),W(Yt())},Se=()=>{to(),W([])},Ve=I=>_.find(Y=>Y.type===I),Ye=!Ce&&!M&&!de,et=M&&(M.works.length>0||M.books.length>0||M.collections.length>0),Ze=t.jsxs(t.Fragment,{children:[t.jsx(hl,{transport:e,value:T,onChange:ae,onSearch:fe,onEntrySelect:xe}),y&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const I=T.trim();I&&ml(I),fe(T)},children:S.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:S.action.newEntry})]});return t.jsxs("div",{className:"bim-browser-container",style:k?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:lm+(y?cm:"")}),(!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:S.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!p&&t.jsx(ul,{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:Ze})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:Ze}),Ce&&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:ie&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:se?t.jsxs(t.Fragment,{children:[(se.book??0)>0&&t.jsxs(t.Fragment,{children:[S.searchPage.statBook," ",t.jsx("strong",{style:{color:r("fg")},children:se.book.toLocaleString()})," ",S.unit.bu,S.searchPage.statComma,t.jsx("strong",{style:{color:r("fg")},children:ie.books.toLocaleString()})," ",S.searchPage.statBookCopies]}),se.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.searchPage.statArticle," ",t.jsx("strong",{style:{color:r("fg")},children:se.article.toLocaleString()})," ",S.searchPage.statArticleUnit]}):null,se.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.searchPage.statPoem," ",t.jsx("strong",{style:{color:r("fg")},children:se.poem.toLocaleString()})," ",S.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.searchPage.statCollection," ",t.jsx("strong",{style:{color:r("fg")},children:ie.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[S.indexType.work," ",t.jsx("strong",{style:{color:r("fg")},children:ie.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.indexType.book," ",t.jsx("strong",{style:{color:r("fg")},children:ie.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.indexType.collection," ",t.jsx("strong",{style:{color:r("fg")},children:ie.collections.toLocaleString()}),ie.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.indexType.entity," ",t.jsx("strong",{style:{color:r("fg")},children:ie.entities.toLocaleString()})]})]})}),ie.hasImage!=null&&ie.hasText!=null&&t.jsxs("span",{children:[S.resourceType.image," ",t.jsx("strong",{style:{color:r("fg")},children:ie.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.resourceType.text," ",t.jsx("strong",{style:{color:r("fg")},children:ie.hasText.toLocaleString()})]})]})}),y&&!Ce&&t.jsx(wl,{transport:e,query:N,filters:J,onFiltersChange:oe,onEntryLinkClick:re,typeName:I=>Ve(I).name,tab:w,onTabChange:v,page:j,onPageChange:C}),!(y&&!Ce)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:ce||Ye?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg"),minHeight:sm,boxSizing:"border-box"},children:S.search.searching}):de?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:r("desc-fg")},children:de})}):Ce?t.jsx("div",{style:{flex:1},children:K?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg")},children:S.search.loading}):U.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:S.search.recentBrowse}),t.jsx("button",{onClick:Se,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:S.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:U.slice(0,Q?10:3).map(I=>I.notFound?t.jsx(mm,{id:I.id,onRemove:je,t:S},I.id):t.jsx(Ms,{entry:I,selected:O===I.id,onClick:re,getConfig:Ve,onRemove:je},I.id))}),!Q&&U.length>3&&t.jsx("button",{onClick:()=>le(!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:S.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:S.search.searchTitle}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:S.search.searchSubtitle})]})}):et?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:dm}),(()=>{const I=ge=>M[As[ge]]??0,Y=L.map(ge=>_.find(Ae=>Ae.type===ge)).filter(ge=>I(ge.key)>0);if(Y.length<2)return null;const pe=Y.reduce((ge,Ae)=>ge+I(Ae.key),0),ve=ge=>{if(q(ge),ge!=="all"&&V!==ge){const Ae=_.find(X=>X.type===ge),qe=(M[Ae.key]??[]).length;I(Ae.key)>qe&&P(ge)}},Ee=ge=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:r(ge?"fg":"desc-fg"),fontWeight:ge?700:400,boxShadow:ge?`inset 0 -2px 0 ${r("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":S.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":G==="all",style:Ee(G==="all"),onClick:()=>ve("all"),children:[S.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:pe.toLocaleString()})]}),Y.map(ge=>t.jsxs("button",{type:"button","aria-pressed":G===ge.type,style:Ee(G===ge.type),onClick:()=>ve(ge.type),children:[ge.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:I(ge.key).toLocaleString()})]},ge.type))]})})(),_.map(({type:I,name:Y,key:pe})=>{const ve=M[pe]??[],Ee=As[pe],ge=M[Ee]??0;if(ve.length===0||G!=="all"&&G!==I)return null;const qe=G==="all"&&!(V===I)&&ge>sr;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(kn,{type:I})," ",Y,t.jsxs("span",{style:{fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:[ge," ",S.unit.items]})]}),qe&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>P(I),style:{border:"none",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"12px"},children:S.action.viewAll})]}),t.jsx("div",{style:h==="list"?{display:"flex",flexDirection:"column",gap:0}:h==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:ve.map(X=>{if(u)return t.jsx(g.Fragment,{children:u(X)},X.id);const $e=h==="card"?um:Ms;return t.jsx($e,{entry:X,selected:O===X.id,onClick:re,getConfig:Ve,query:T},X.id)})})]},I)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:bt(S.search.noResultsFor,{query:T})}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:S.search.tryOther})]})})]})},sm=240;function am(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const lm=`
120
+ `,to="bim-search-view",rr=50,Is=5,An=1e3;function pi(e){return e>=An?`${An.toLocaleString()}+`:e.toLocaleString()}const Zu={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function Ju(e){return e&&Zu[e.toLowerCase()]||"all"}function Qu(e){return e==="all"?null:e}const Es=["work","collection","book","entity"],em={work:"works",collection:"collections",book:"books",entity:"entities"},tm={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function nm(){try{return window.localStorage.getItem(to)==="card"?"card":"table"}catch{return"table"}}function im(e){try{window.localStorage.setItem(to,e)}catch{}}const cn=(e,n)=>(e==null?void 0:e[tm[n]])??0,or=(e,n)=>(e==null?void 0:e[em[n]])??[],wl=({transport:e,query:n,filters:i,onFiltersChange:o,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const h=Ie(),u=h.searchV4,{convert:m}=Pe(),f=!!e.supportsSearchFilters,x=g.useMemo(()=>f?i:Ci,[f,i]),[k,y]=g.useState("table");g.useEffect(()=>{y(nm())},[]);const $=B=>{y(B),im(B)},[b,w]=g.useState(l??"all"),v=g.useRef(b);v.current=b,g.useEffect(()=>{l!==void 0&&l!==v.current&&(w(l),C(1))},[l]);const[j,C]=g.useState(c&&c>0?c:1),S=g.useRef(j);S.current=j,g.useEffect(()=>{c!==void 0&&c>0&&c!==S.current&&C(c)},[c]);const _=g.useRef(null),A=g.useCallback(B=>{var he;C(B),p==null||p(B);const V=_.current;V&&V.getBoundingClientRect().top<0&&((he=V.scrollIntoView)==null||he.call(V,{block:"start",behavior:"instant"}))},[p]),[T,z]=g.useState(null),[M,H]=g.useState(null),[I,R]=g.useState(!1),[P,K]=g.useState(""),te=xi(x).toString(),ie=Ni(x)>0,U=xi({...x,sort:""}).toString(),pe=g.useRef({query:n,filterOnlyKey:U,sort:x.sort});g.useEffect(()=>{const B=pe.current;B.query!==n||B.filterOnlyKey!==U?(w("all"),C(1)):B.sort!==x.sort&&C(1),pe.current={query:n,filterOnlyKey:U,sort:x.sort}},[n,U,x.sort]),g.useEffect(()=>{let B=!1;return R(!0),K(""),(async()=>{try{let V;if(e.searchAll)V=await e.searchAll(n,Is,x);else{const he=["work","book","collection","entity"],X=await Promise.all(he.map(ge=>e.search(n,ge,{page:1,pageSize:Is,filters:x})));V={works:X[0].entries,books:X[1].entries,collections:X[2].entries,entities:X[3].entries,totalWorks:X[0].total,totalBooks:X[1].total,totalCollections:X[2].total,totalEntities:X[3].total}}B||z(V)}catch(V){B||(K(V instanceof Error?V.message:String(V)),z(null))}finally{B||R(!1)}})(),()=>{B=!0}},[e,n,te]);const G=b;g.useEffect(()=>{if(b==="all"){H(null);return}let B=!1;return R(!0),(async()=>{try{const V=await e.search(n,b,{page:j,pageSize:rr,filters:x});B||H({key:G,entries:V.entries,total:V.total})}catch(V){B||(K(V instanceof Error?V.message:String(V)),H(null))}finally{B||R(!1)}})(),()=>{B=!0}},[e,n,te,b,j]);const ee=M&&M.key===G?M:null;g.useEffect(()=>{if(b==="all"||!ee||I)return;const B=Math.min(ee.total,An),V=Yu(j,B,rr);ee.entries.length===0&&B>0&&V!==j&&(C(V),p==null||p(V))},[b,ee,I,j]);const ae=g.useMemo(()=>Es.filter(B=>cn(T,B)>0),[T]),Se=ae.reduce((B,V)=>B+cn(T,V),0),O=ae.some(B=>cn(T,B)>=An)?`${Se.toLocaleString()}+`:Se.toLocaleString(),je=!I&&!P&&T!==null&&Se===0,de=g.useCallback(B=>{w(B),C(1),d==null||d(B)},[d]),we=g.useMemo(()=>{const B=[];return x.dynasty.forEach(V=>B.push({name:V,remove:()=>o({...x,dynasty:x.dynasty.filter(he=>he!==V)})})),x.classification.forEach(V=>{var he;return B.push({name:V?((he=Ti.find(X=>X.value===V))==null?void 0:he.label)??V:h.searchPage.unclassified,remove:()=>o({...x,classification:x.classification.filter(X=>X!==V)})})}),x.hasImage&&B.push({name:u.hasImage,remove:()=>o({...x,hasImage:!1})}),x.hasText&&B.push({name:u.hasText,remove:()=>o({...x,hasText:!1})}),x.hasCollated&&B.push({name:u.hasCollated,remove:()=>o({...x,hasCollated:!1})}),x.loss&&B.push({name:`${u.extant}:${h.searchPage.loss[x.loss]}`,remove:()=>o({...x,loss:""})}),B},[x,o,u,h]),Te={query:n,onEntryLinkClick:s,typeName:a},Fe=B=>k==="table"?t.jsx(Ts,{entries:B,...Te}):t.jsx(Ns,{entries:B,...Te}),re=Es.flatMap(B=>or(T,B));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":f?void 0:"true",children:[t.jsx("style",{children:Xu}),f&&t.jsx(Uu,{filters:x,onChange:o}),t.jsxs("div",{className:"bim-sr-main","aria-busy":I,ref:_,children:[ae.length>0&&t.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":h.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${r("rule")}`},children:[t.jsxs(Rs,{on:b==="all",onClick:()=>de("all"),children:[h.search.allTab," ",t.jsx("small",{children:O})]}),ae.map(B=>t.jsxs(Rs,{on:b===B,onClick:()=>de(B),children:[a(B)," ",t.jsx("small",{children:pi(cn(T,B))})]},B))]}),t.jsxs("div",{className:"bim-sr-tools",children:[f&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":m(u.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>o({...x,sort:""}),children:m(u.sortRelevance)}),["era","title"].map(B=>{const V=x.sort.startsWith(`${B}:`)?x.sort.endsWith("desc")?"desc":"asc":null,he=B==="era"?u.sortEra:u.sortTitle,X=B==="era"?V==="desc"?u.sortEraDesc:u.sortEraAsc:V==="desc"?u.sortTitleDesc:u.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":V!==null,title:m(X),onClick:()=>o({...x,sort:`${B}:${V==="asc"?"desc":"asc"}`}),children:[m(he),V?t.jsxs("span",{"aria-hidden":"true",children:[" ",V==="asc"?"↑":"↓"]}):null]},B)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":m(u.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":k==="table",onClick:()=>$("table"),children:m(u.viewTable)}),t.jsx("button",{type:"button","aria-pressed":k==="card",onClick:()=>$("card"),children:m(u.viewCard)})]})]}),ie&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:m(bt(u.filteredCount,{n:O}))}),we.map(B=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":m(bt(u.removeFilter,{name:B.name})),onClick:B.remove,children:[m(B.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},B.name))]}),P&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:P}),je&&t.jsx("div",{className:"bim-sr-empty",children:m(ie?u.emptyFiltered:bt(h.search.noResultsFor,{query:n}))}),!P&&!je&&b==="all"&&T&&(k==="table"?t.jsxs(t.Fragment,{children:[t.jsx(Ts,{entries:re,...Te}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:m(u.limitedNote)})]}):t.jsx(t.Fragment,{children:ae.map(B=>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(kn,{type:B,size:8}),a(B),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:r("meta-fg")},children:[pi(cn(T,B))," ",h.unit.items]})]}),cn(T,B)>or(T,B).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>de(B),children:h.action.viewAll})]}),t.jsx(Ns,{entries:or(T,B),...Te})]},B))})),!P&&b!=="all"&&!ee&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:h.search.loading}),!P&&b!=="all"&&ee&&ee.entries.length>0&&t.jsxs(t.Fragment,{children:[Fe(ee.entries),t.jsx(qu,{page:j,pageSize:rr,total:Math.min(ee.total,An),totalLabel:pi(ee.total),onPage:A})]}),!P&&b!=="all"&&ee&&ee.entries.length===0&&!I&&t.jsxs("div",{className:"bim-sr-empty",children:[m(ie?u.emptyFiltered:bt(h.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>de("all"),children:h.search.allTab})})]})]})]})};function Rs({on:e,onClick:n,children:i}){return t.jsx("button",{type:"button","aria-pressed":e,onClick:n,style:{border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:14.5,minHeight:44,padding:"8px 12px",letterSpacing:".06em",color:r(e?"ink":"meta-fg"),fontWeight:e?700:400,boxShadow:e?`inset 0 -2px 0 ${r("accent")}`:"none"},children:i})}const hn="bim-recent-ids",Ls="bim-recent-entries",As=50;function Yt(){try{const e=localStorage.getItem(hn);if(e)return JSON.parse(e);const n=localStorage.getItem(Ls);if(n){const i=JSON.parse(n).map(o=>o.id);return localStorage.setItem(hn,JSON.stringify(i)),localStorage.removeItem(Ls),i}return[]}catch{return[]}}function wr(e){try{const n=Yt().filter(i=>i!==e);n.unshift(e),n.length>As&&(n.length=As),localStorage.setItem(hn,JSON.stringify(n))}catch{}}function Sl(e){try{const n=Yt().filter(i=>i!==e);localStorage.setItem(hn,JSON.stringify(n))}catch{}}function no(){try{localStorage.removeItem(hn)}catch{}}async function io(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 sr=5,rm=50,om=200,Ms={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},Sr=({transport:e,indexSource:n="local",syncConfig:i,onEntryClick:o,onNewEntry:s,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c,hideModeIndicator:p,resultVariant:h="compact",renderEntry:u,initialQuery:m,onQueryChange:f,headerRight:x,reserveViewportHeight:k=!1,filtersEnabled:y=!1,filters:$=Ci,onFiltersChange:b,resultTab:w,onResultTabChange:v,resultPage:j,onResultPageChange:C})=>{const S=Ie(),_=[{type:"work",name:S.indexType.work,key:"works"},{type:"book",name:S.indexType.book,key:"books"},{type:"collection",name:S.indexType.collection,key:"collections"},{type:"entity",name:S.indexType.entity,key:"entities"}],A=["work","collection","book","entity"],[T,z]=g.useState(m??""),[M,H]=g.useState(null),[I,R]=g.useState(m??""),P=xi($).toString(),[K,te]=g.useState($);g.useEffect(()=>{te($)},[P]);const ie=N=>{te(N),b==null||b(N)},[U,pe]=g.useState(null),[G,ee]=g.useState("all"),[ae,Se]=g.useState(!1),[O,je]=g.useState(null),[de,we]=g.useState(""),[Te,Fe]=g.useState(!(m!=null&&m.trim())),[re,B]=g.useState(Yt),[V,he]=g.useState([]),[X,ge]=g.useState(!1),[W,le]=g.useState(!1),[q,D]=g.useState(null),[Q,Ce]=g.useState(null),Le=g.useRef(void 0),Ae=g.useRef(!1),F=g.useCallback(async(N,Y)=>{if(!N.trim()){Fe(!0),H(null),pe(null);return}if(Fe(!1),y){R(N);return}Se(!0),we("");try{if(e.searchAll){const ce=await e.searchAll(N,Y??sr);H(ce)}else{const ce=["work","book","collection","entity"],ye=await Promise.all(ce.map(Ee=>e.search(N,Ee,{page:1,pageSize:Y??sr})));H({works:ye[0].entries,books:ye[1].entries,collections:ye[2].entries,entities:ye[3].entries,totalWorks:ye[0].total,totalBooks:ye[1].total,totalCollections:ye[2].total,totalEntities:ye[3].total})}}catch(ce){we(ce instanceof Error?ce.message:String(ce)),H(null)}finally{Se(!1)}},[e,y]);g.useEffect(()=>{let N=!1;const Y=()=>{var Me,qe;const ce=["work","book","collection","entity"],ye=Promise.all(ce.map(Z=>e.loadEntries(Z,{page:1,pageSize:1}).catch(()=>({total:0})))),Ee=((Me=e.getResourceCounts)==null?void 0:Me.call(e).catch(()=>null))??Promise.resolve(null),fe=((qe=e.getSubtypeStats)==null?void 0:qe.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([ye,Ee,fe]).then(([Z,ze,We])=>{N||(D({works:Z[0].total,books:Z[1].total,collections:Z[2].total,entities:Z[3].total,hasText:ze==null?void 0:ze.hasText,hasImage:ze==null?void 0:ze.hasImage}),We&&Ce(We))})};return e.getCounts?e.getCounts().then(ce=>{var ye,Ee;N||(D({works:ce.works,books:ce.books,collections:ce.collections,entities:ce.entities,hasText:(ye=ce.resourceCounts)==null?void 0:ye.hasText,hasImage:(Ee=ce.resourceCounts)==null?void 0:Ee.hasImage}),ce.subtypeStats&&Ce(ce.subtypeStats))}).catch(()=>{N||Y()}):Y(),()=>{N=!0}},[e]),g.useEffect(()=>{Ae.current||!(m!=null&&m.trim())||(Ae.current=!0,F(m))},[m,F]);const se=g.useCallback(N=>{if(z(N),!N.trim()){f==null||f(N),Fe(!0),H(null),pe(null),ee("all");return}Le.current&&clearTimeout(Le.current),Le.current=setTimeout(()=>{pe(null),ee("all"),f==null||f(N),F(N)},om)},[F,f]),ve=g.useCallback(N=>{Le.current&&clearTimeout(Le.current),ee("all"),f==null||f(N),F(N)},[F,f]),L=g.useCallback(N=>{pe(N),F(T,rm)},[T,F]);g.useEffect(()=>{if(!re.length){he([]);return}let N=!1;return ge(!0),Promise.all(re.slice(0,10).map(Y=>io(e,Y))).then(Y=>{N||(he(Y),ge(!1))}),()=>{N=!0}},[re,e]);const me=N=>{je(N.id),wr(N.id),B(Yt()),o==null||o(N)},oe=(N,Y)=>{if(o&&am(Y)){Y.preventDefault(),me(N);return}wr(N.id),B(Yt())},be=N=>{Sl(N),B(Yt())},_e=()=>{no(),B([])},Ve=N=>_.find(Y=>Y.type===N),Ye=!Te&&!M&&!de,tt=M&&(M.works.length>0||M.books.length>0||M.collections.length>0),Ze=t.jsxs(t.Fragment,{children:[t.jsx(hl,{transport:e,value:T,onChange:se,onSearch:ve,onEntrySelect:me}),y&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const N=T.trim();N&&ml(N),ve(T)},children:S.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:S.action.newEntry})]});return t.jsxs("div",{className:"bim-browser-container",style:k?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:lm+(y?cm:"")}),(!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:S.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!p&&t.jsx(ul,{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:Ze})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:Ze}),Te&&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:q&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:Q?t.jsxs(t.Fragment,{children:[(Q.book??0)>0&&t.jsxs(t.Fragment,{children:[S.searchPage.statBook," ",t.jsx("strong",{style:{color:r("fg")},children:Q.book.toLocaleString()})," ",S.unit.bu,S.searchPage.statComma,t.jsx("strong",{style:{color:r("fg")},children:q.books.toLocaleString()})," ",S.searchPage.statBookCopies]}),Q.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.searchPage.statArticle," ",t.jsx("strong",{style:{color:r("fg")},children:Q.article.toLocaleString()})," ",S.searchPage.statArticleUnit]}):null,Q.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.searchPage.statPoem," ",t.jsx("strong",{style:{color:r("fg")},children:Q.poem.toLocaleString()})," ",S.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.searchPage.statCollection," ",t.jsx("strong",{style:{color:r("fg")},children:q.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[S.indexType.work," ",t.jsx("strong",{style:{color:r("fg")},children:q.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.indexType.book," ",t.jsx("strong",{style:{color:r("fg")},children:q.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.indexType.collection," ",t.jsx("strong",{style:{color:r("fg")},children:q.collections.toLocaleString()}),q.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.indexType.entity," ",t.jsx("strong",{style:{color:r("fg")},children:q.entities.toLocaleString()})]})]})}),q.hasImage!=null&&q.hasText!=null&&t.jsxs("span",{children:[S.resourceType.image," ",t.jsx("strong",{style:{color:r("fg")},children:q.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.resourceType.text," ",t.jsx("strong",{style:{color:r("fg")},children:q.hasText.toLocaleString()})]})]})}),y&&!Te&&t.jsx(wl,{transport:e,query:I,filters:K,onFiltersChange:ie,onEntryLinkClick:oe,typeName:N=>Ve(N).name,tab:w,onTabChange:v,page:j,onPageChange:C}),!(y&&!Te)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:ae||Ye?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg"),minHeight:sm,boxSizing:"border-box"},children:S.search.searching}):de?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:r("desc-fg")},children:de})}):Te?t.jsx("div",{style:{flex:1},children:X?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg")},children:S.search.loading}):V.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:S.search.recentBrowse}),t.jsx("button",{onClick:_e,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:S.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:V.slice(0,W?10:3).map(N=>N.notFound?t.jsx(mm,{id:N.id,onRemove:be,t:S},N.id):t.jsx(Ps,{entry:N,selected:O===N.id,onClick:oe,getConfig:Ve,onRemove:be},N.id))}),!W&&V.length>3&&t.jsx("button",{onClick:()=>le(!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:S.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:S.search.searchTitle}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:S.search.searchSubtitle})]})}):tt?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:dm}),(()=>{const N=fe=>M[Ms[fe]]??0,Y=A.map(fe=>_.find(Me=>Me.type===fe)).filter(fe=>N(fe.key)>0);if(Y.length<2)return null;const ce=Y.reduce((fe,Me)=>fe+N(Me.key),0),ye=fe=>{if(ee(fe),fe!=="all"&&U!==fe){const Me=_.find(Z=>Z.type===fe),qe=(M[Me.key]??[]).length;N(Me.key)>qe&&L(fe)}},Ee=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":S.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":G==="all",style:Ee(G==="all"),onClick:()=>ye("all"),children:[S.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:ce.toLocaleString()})]}),Y.map(fe=>t.jsxs("button",{type:"button","aria-pressed":G===fe.type,style:Ee(G===fe.type),onClick:()=>ye(fe.type),children:[fe.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:N(fe.key).toLocaleString()})]},fe.type))]})})(),_.map(({type:N,name:Y,key:ce})=>{const ye=M[ce]??[],Ee=Ms[ce],fe=M[Ee]??0;if(ye.length===0||G!=="all"&&G!==N)return null;const qe=G==="all"&&!(U===N)&&fe>sr;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(kn,{type:N})," ",Y,t.jsxs("span",{style:{fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:[fe," ",S.unit.items]})]}),qe&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>L(N),style:{border:"none",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"12px"},children:S.action.viewAll})]}),t.jsx("div",{style:h==="list"?{display:"flex",flexDirection:"column",gap:0}:h==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:ye.map(Z=>{if(u)return t.jsx(g.Fragment,{children:u(Z)},Z.id);const ze=h==="card"?um:Ps;return t.jsx(ze,{entry:Z,selected:O===Z.id,onClick:oe,getConfig:Ve,query:T},Z.id)})})]},N)})]}):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(S.search.noResultsFor,{query:T})}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:S.search.tryOther})]})})]})},sm=240;function am(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const lm=`
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
  `,cm=`
@@ -142,7 +142,7 @@
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
- }`,_l={color:"inherit",textDecoration:"none"},pm=({snippet:e})=>{const{convert:n}=Pe();return t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.6},children:Yr(e).map((i,o)=>i.marked?t.jsx("mark",{style:{background:r("highlight-bg"),color:r("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(i.text)},o):t.jsx(g.Fragment,{children:n(i.text)},o))})},um=({entry:e,selected:n,onClick:i,getConfig:o,query:s})=>{const a=Ie(),{convert:l}=Pe(),d=l(e.title||e.primary_name||e.id),c=e.measure_info?l(e.measure_info):e.juan_count!=null&&e.juan_count>0?`${e.juan_count}${a.unit.juan}`:"",p=[...e.additional_titles||[],...e.attached_texts||[]],h=s&&p.length?p.find(f=>{const x=typeof f=="string"?f:f==null?void 0:f.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,u=r("cover-accent"),m=rt();return t.jsxs("a",{href:m(e.id),onClick:f=>i(e,f),className:"bim-result-card",style:{..._l,display:"flex",gap:"1.2rem",alignItems:"stretch",padding:"1.1rem 1.3rem",borderRadius:"12px",cursor:"pointer",background:r("bg"),border:n?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,transition:"border-color .2s ease, transform .2s ease, box-shadow .2s ease"},children:[t.jsxs("div",{"aria-hidden":"true",style:{position:"relative",width:"92px",minHeight:"126px",flexShrink:0,borderRadius:"4px",border:`1px solid color-mix(in srgb, ${u} 50%, ${r("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${u} 14%, ${r("bg")}), color-mix(in srgb, ${u} 7%, ${r("bg")}))`,display:"flex",alignItems:"center",justifyContent:"center",padding:"0.6rem 0.3rem"},children:[t.jsx("span",{style:{position:"absolute",left:"6px",top:0,bottom:0,borderLeft:`1px dashed color-mix(in srgb, ${u} 45%, transparent)`}}),t.jsx("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",height:"108px",flexShrink:0,overflow:"hidden",fontSize:"1.05rem",fontWeight:700,lineHeight:1.25,color:u},children:Array.from(d).map((f,x)=>t.jsx("span",{children:f},x))})]}),t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"17px",fontWeight:600,color:r("fg")},children:d}),c&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg")},children:c})]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"13px",color:r("desc-fg")},children:[e.dynasty&&t.jsxs("span",{children:["〔",l(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:l(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",l(e.role)]})]}),(e.era||e.edition)&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg")},children:[e.era&&t.jsxs("span",{children:["〔",l(e.era),"〕"]}),e.edition&&t.jsx("span",{children:l(e.edition)})]}),h&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg")},children:[a.search.alias,":",l(typeof h=="string"?h:h.book_title||"")]}),e.descriptionSnippet&&t.jsx(pm,{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(kn,{type:e.type,size:8})," ",o(e.type).name]}),e.has_text&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:a.misc.textResource}),e.has_image&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:a.misc.imageResource})]})]})]})},Ms=({entry:e,selected:n,onClick:i,getConfig:o,query:s,onRemove:a})=>{const l=Ie(),{convert:d}=Pe(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(u=>{const m=typeof u=="string"?u:u==null?void 0:u.book_title;return m==null?void 0:m.toLowerCase().includes(s.toLowerCase())}):void 0,h=rt();return t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",borderRadius:"6px",border:n?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("a",{href:h(e.id),onClick:u=>i(e,u),className:"bim-result-card",style:{..._l,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(kn,{type:e.type,size:12}),t.jsx("span",{style:{fontSize:"9px",color:r("desc-fg"),lineHeight:1},children:o(e.type).name})]}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg")},children:d(e.title||e.primary_name||e.id)}),t.jsxs("span",{style:{display:"flex",gap:"2px",fontSize:"12px",opacity:.7},children:[e.has_text&&t.jsx("span",{children:l.misc.textResource}),e.has_image&&t.jsx("span",{children:l.misc.imageResource})]}),(e.era||e.edition)&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[e.era&&t.jsxs(t.Fragment,{children:["〔",d(e.era),"〕"]}),e.edition&&d(e.edition)]}),e.measure_info?t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:d(e.measure_info)}):e.juan_count!=null&&e.juan_count>0?t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[e.juan_count,l.unit.juan]}):null]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"2px"},children:[e.dynasty&&t.jsxs("span",{children:["〔",d(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:d(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",d(e.role)]}),e.type==="entity"&&(e.birth_year!=null||e.death_year!=null)&&t.jsxs("span",{style:{marginLeft:e.dynasty?"4px":0},children:[e.birth_year??"?","—",e.death_year??"?"]})]}),p&&t.jsxs("div",{style:{fontSize:"11px",color:r("desc-fg"),marginTop:"2px"},children:[l.search.alias,":",d(p)]})]}),!a&&t.jsx("span",{"aria-hidden":"true",style:{opacity:.4,marginTop:"2px"},children:"→"})]}),a&&t.jsx("button",{type:"button",onClick:()=>a(e.id),title:l.search.removeFromRecent,"aria-label":l.search.removeFromRecent,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"12px 12px 12px 8px",lineHeight:1,opacity:.5},children:"×"})]})},mm=({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 hm(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 gm({data:e}){var l,d;const{convert:n}=Pe(),{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 fm({alt_names:e}){const{convert:n}=Pe(),i=new Map;for(const a of e){const l=a.type||"別名";i.has(l)||i.set(l,[]),i.get(l).push(a.name)}const o=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...i.keys()].sort((a,l)=>{const d=o.indexOf(a),c=o.indexOf(l);return d===-1&&c===-1?0:d===-1?1:c===-1?-1:d-c});return t.jsx("div",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(a=>{const l=i.get(a);return t.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[t.jsx("span",{style:{color:r("desc-fg"),fontSize:"12px",minWidth:"36px",paddingTop:"2px"},children:n(a)}),t.jsx("span",{children:l.map((d,c)=>t.jsxs("span",{children:[c>0&&t.jsx("span",{style:{color:r("desc-fg"),margin:"0 4px"},children:"·"}),n(d)]},c))})]},a)})})}function xm({data:e}){const n=Ie(),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 bm({works:e,transport:n,onNavigate:i,renderLink:o}){const s=Ie(),{convert:a}=Pe(),l=rt(),[d,c]=g.useState(new Map);g.useEffect(()=>{if(!n)return;let m=!1;const f=e.map(k=>k.work_id);return(async()=>{const k=new Map;if(n.getEntriesByIds)try{const w=await n.getEntriesByIds(f);let v=!0;for(let j=0;j<f.length;j++){const C=w[j];C!=null&&C.title?k.set(f[j],C.title):C!=null&&C.primary_name?k.set(f[j],C.primary_name):v=!1}if(v)return k}catch{}const y=[...f],$=8,b=new Array($).fill(0).map(async()=>{for(;y.length;){const w=y.shift();if(!w)break;if(!k.has(w))try{if(n.getEntry){const C=await n.getEntry(w);if(C!=null&&C.title){k.set(w,C.title);continue}}const v=await n.getItem(w),j=v&&(v.title||v.primary_name)||w;k.set(w,j)}catch{k.set(w,w)}}});return await Promise.all(b),k})().then(k=>{m||c(k)}),()=>{m=!0}},[e,n]);const p=new Map;for(const m of e){const f=m.role||"";p.has(f)||p.set(f,[]),p.get(f).push(m)}const h=["撰","編","注","輯","集","校","評","譯","述","作",""],u=[...p.keys()].sort((m,f)=>{const x=h.indexOf(m),k=h.indexOf(f);return x===-1&&k===-1?m.localeCompare(f):x===-1?1:k===-1?-1:x-k});return t.jsxs("div",{style:{marginTop:"12px"},children:[t.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:r("fg"),margin:"0 0 8px",paddingBottom:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[s.label.relatedWorks," ",t.jsxs("span",{style:{color:r("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",e.length,")"]})]}),u.map(m=>{const f=p.get(m);return t.jsxs("div",{style:{marginBottom:"8px"},children:[m&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"2px"},children:[a(m)," ",t.jsxs("span",{style:{color:r("desc-fg")},children:["(",f.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:m?"16px":"0",listStyle:m?"disc":"none",fontSize:"14px",lineHeight:1.8},children:f.map((x,k)=>{const y=a(d.get(x.work_id)||x.work_id);return o?t.jsx("li",{children:o(x.work_id,y)},k):i?t.jsx("li",{children:t.jsx("a",{href:l(x.work_id),onClick:$=>{$.metaKey||$.ctrlKey||($.preventDefault(),i(x.work_id))},style:{color:r("link-fg"),textDecoration:"underline",cursor:"pointer"},children:y})},k):t.jsx("li",{children:y},k)})})]},m)})]})}const $l=({data:e,transport:n,onNavigate:i,renderLink:o,headerExtra:s,hideHeader:a})=>{var u;const l=Ie(),{convert:d}=Pe();let c=!1;try{c=ke.extractStatus(e.id)==="draft"}catch{}const p=hm(e),h=e.subtype&&e.subtype in l.common.entitySubtype?l.common.entitySubtype[e.subtype]:d(e.subtype);return t.jsxs("div",{children:[!a&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"4px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:600,margin:0,lineHeight:1.3,color:r("fg")},children:[d(e.primary_name),t.jsx(gm,{data:e})]}),s]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:r("type-entity"),border:`1px solid color-mix(in srgb, ${r("type-entity")} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${r("type-entity")} 3%, transparent)`},children:l.indexType.entity}),h&&e.subtype!=="people"&&t.jsx("span",{children:h}),c&&t.jsx("span",{style:{padding:"1px 6px",background:r("warn-bg"),border:`1px solid ${r("warn-border")}`,borderRadius:"2px",color:r("warn-fg")},children:l.status.draft}),t.jsx("span",{style:{fontFamily:"monospace",opacity:.6},children:e.id})]})]}),p&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),fontStyle:"italic",padding:"8px 12px",background:r("widget-bg"),border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",margin:"8px 0"},children:l.common.entityPlaceholderNote}),e.alt_names&&e.alt_names.length>0&&t.jsx(fm,{alt_names:e.alt_names}),t.jsx(xm,{data:e}),((u=e.description)==null?void 0:u.text)&&t.jsx("p",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:d(e.description.text)}),e.works&&e.works.length>0&&t.jsx(bm,{works:e.works,transport:n,onNavigate:i,renderLink:o})]})},ym=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function jm(e){const n=e.search(ym);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const Cl={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===vm(e))){const[a,l]=jm(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 vm(e){try{return decodeURI(e)}catch{return e}}const km={...Cl,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},Ft=({text:e,plainStrong:n,style:i,className:o})=>{const{convert:s}=Pe(),a=n?km:Cl;return t.jsx("div",{className:o,style:i,children:t.jsx(Gp,{remarkPlugins:[Yp],components:a,children:s(e)})})},wm=["〇","一","二","三","四","五","六","七","八","九"],Ps=["","十","百","千"];function zl(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),i=n.length;let o="",s=!1;for(let a=0;a<i;a++){const l=parseInt(n[a]),d=i-1-a;l===0?s=!0:(s&&o&&(o+="〇"),s=!1,l===1&&d===1&&a===0?o+=Ps[d]:o+=wm[l]+Ps[d])}return o}function Tl(e){return{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:e,border:`1px solid color-mix(in srgb, ${e} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${e} 3%, transparent)`}}const Sm={book:r("type-book"),work:r("type-work"),collection:r("type-collection"),entity:r("type-entity")};function _m({type:e}){const n=Ie();return t.jsx("span",{style:Tl(Sm[e]),children:n.indexType[e]})}function $m({isDraft:e}){const n=Ie(),i=r(e?"status-draft":"status-official");return t.jsx("span",{style:Tl(i),children:e?n.status.draft:n.status.official})}function Cm({id:e}){const n=Ie(),[i,o]=g.useState(!1),s=()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})};return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:r("desc-fg"),background:r("bg-subtle"),border:`1px solid ${r("widget-border")}`,borderRadius:"2px"},children:[t.jsx("span",{children:n.label.id}),t.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:r("fg")},children:e}),t.jsx("span",{onClick:s,title:i?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"11px",opacity:i?1:.5,transition:"opacity 0.15s"},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity=i?"1":"0.5",children:i?"✓":"⧉"})]})}function vt({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 Tt({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 Nl({authors:e,type:n,onNavigate:i,renderLink:o}){const{convert:s}=Pe();return t.jsx("span",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.6},children:e.map((a,l)=>{const d=s(a.name),c=a.entity_id?t.jsx(_t,{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 _t({id:e,label:n,onNavigate:i,renderLink:o}){const s=rt();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 zm({id:e,title:n,edition:i,type:o,isDraft:s,authors:a,volumeText:l,meta:d,headerExtra:c,onNavigate:p,renderLink:h}){return t.jsxs("div",{style:{marginBottom:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:700,color:r("fg"),margin:"0 0 6px",lineHeight:1.4,letterSpacing:"0.5px",wordBreak:"break-word",flex:1,minWidth:0},children:[n,i&&t.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:i}),l&&t.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:r("desc-fg"),marginLeft:"8px"},children:l})]}),c&&t.jsx("div",{style:{flexShrink:0,paddingTop:"2px"},children:c})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"4px"},children:[t.jsx(_m,{type:o}),t.jsx($m,{isDraft:s}),t.jsx(Cm,{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(Nl,{authors:a,type:o,onNavigate:p,renderLink:h}),d]})]})}function Il({items:e,label:n,showMeta:i,onNavigate:o,renderLink:s}){const a=Ie(),{convert:l}=Pe();if(!e.length)return null;const[d,c]=g.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(vt,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((p,h)=>{const u=d===h;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...u?{boxShadow:r("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(u?null:h),style:{padding:"8px 12px",background:r("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.15s",transform:u?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(p.source)}),!u&&i&&p.title_info&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l(p.title_info)}),p.source_bid&&t.jsx("span",{onClick:m=>m.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(_t,{id:p.source_bid,label:a.action.view,onNavigate:o,renderLink:s})})]}),u&&t.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${r("widget-border")}`},children:[i&&(p.title_info||p.author_info||p.edition)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[p.title_info&&t.jsx(Tt,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx(Tt,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx(Tt,{label:a.label.edition,children:l(p.edition)})]}),p.summary&&t.jsxs("div",{style:{marginTop:"6px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.summary}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:l(p.summary)})]}),p.comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.comment}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.comment)})]}),p.additional_comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.additionalComment}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.additional_comment)})]})]})]},h)})})]})}function Tm({items:e,onNavigate:n,renderLink:i}){const o=Ie();return t.jsx(Il,{items:e,label:o.section.indexed,showMeta:!0,onNavigate:n,renderLink:i})}function El({items:e,onNavigate:n,renderLink:i}){const o=Ie();return t.jsx(Il,{items:e,label:o.section.emendated,onNavigate:n,renderLink:i})}function Rl({label:e,items:n}){const{convert:i}=Pe();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(vt,{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 Nm({items:e}){const n=Ie();return t.jsx(Rl,{label:n.section.aliases,items:e})}function Im({items:e}){const n=Ie();return t.jsx(Rl,{label:n.section.attachedTexts,items:e})}function Em({items:e}){const n=Ie(),{convert:i}=Pe();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(vt,{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 Rm({items:e}){const n=Ie(),{convert:i}=Pe();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(vt,{children:n.section.locationHistory}),t.jsxs("div",{style:{position:"relative",paddingLeft:"18px"},children:[t.jsx("div",{style:{position:"absolute",left:"4px",top:"6px",bottom:"6px",width:"1px",background:r("widget-border")}}),e.map((o,s)=>t.jsxs("div",{style:{position:"relative",marginBottom:"10px"},children:[t.jsx("div",{style:{position:"absolute",left:"-16px",top:"5px",width:"7px",height:"7px",borderRadius:"50%",background:r("primary"),border:`1.5px solid ${r("input-bg")}`}}),t.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:r("fg")},children:i(o.name)}),o.description&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),marginLeft:"8px"},children:i(o.description)})]},s))]})]}):null}function Lm({items:e}){const n=Ie(),{convert:i}=Pe();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(vt,{children:n.section.historyOverview}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map((o,s)=>t.jsxs("div",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[t.jsx("span",{style:{position:"absolute",left:0,top:0,color:r("desc-fg")},children:"·"}),i(o)]},s))})]}):null}function Bs({title:e,ids:n,transport:i,onNavigate:o,renderLink:s}){const{convert:a}=Pe(),[l,d]=g.useState([]);return g.useEffect(()=>{if(!n.length){d([]);return}if(!i){d(n.map(p=>({id:p})));return}let c=!1;return Promise.all(n.map(p=>i.getItem(p).then(h=>({id:p,title:h?h.title:void 0,edition:h?h.edition:void 0,type:h?h.type:void 0})).catch(()=>({id:p})))).then(p=>{c||d(p)}),()=>{c=!0}},[n,i]),n.length?t.jsxs(t.Fragment,{children:[t.jsxs(vt,{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(_t,{id:c.id,label:p,onNavigate:o,renderLink:s})},c.id)})})]}):null}function ar({book:e,onNavigate:n,renderLink:i}){const o=Ie(),{convert:s}=Pe(),[a,l]=g.useState(!1),d=e.resources&&e.resources.length>0,c=e.edition?s(e.edition):s(e.title)||void 0;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:r("input-bg")},children:[t.jsxs("div",{style:{padding:"6px 12px",borderBottom:d&&!a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:t.jsx(_t,{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(Qr,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:i})})]})}function Am({ids:e,workData:n,transport:i,onNavigate:o,renderLink:s,footer:a}){const l=Ie(),{convert:d}=Pe(),[c,p]=g.useState([]);if(g.useEffect(()=>{if(!e.length){p([]);return}if(!i){p(e.map(k=>({id:k})));return}let x=!1;return Promise.all(e.map(k=>i.getItem(k).then(y=>({id:k,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:k})))).then(k=>{x||p(k)}),()=>{x=!0}},[e,i]),!e.length)return null;const h=c.length?c:e.map(x=>({id:x})),u=new Map(h.map(x=>[x.id,x])),m=n==null?void 0:n.version_graph,f=Mm(e,m,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(vt,{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 k=u.get(x);return k?t.jsx(ar,{book:k,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(k=>{const y=u.get(k);return y?t.jsx(ar,{book:y,onNavigate:o,renderLink:s},k):null})})]},x.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:h.map(x=>t.jsx(ar,{book:x,onNavigate:o,renderLink:s},x.id))})]})}function Mm(e,n,i){var $,b;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const o=($=n.collections)==null?void 0:$[n.default_collection],s=(o==null?void 0:o.groups)??[],a=(o==null?void 0:o.book_ids)??[],l=s.length>0||a.length>0,d=!l&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!l&&d.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const c=new Set(s),p=new Set([...a,...d]),h=w=>{if(p.has(w))return!0;const v=n.node_groups[w];return v!=null&&c.has(v)},u=[],m=new Map,f=[];for(const w of e)if(!((b=n.excluded_books)!=null&&b.includes(w)))if(h(w))u.push(w);else{const v=n.node_groups[w];v?(m.has(v)||m.set(v,[]),m.get(v).push(w)):f.push(w)}if(f.length+[...m.values()].reduce((w,v)=>w+v.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const k=new Map((n.groups??[]).map(w=>[w.id,w])),y=[...m.entries()].map(([w,v])=>{const j=k.get(w);return{id:w,label:(j==null?void 0:j.label)??w,description:j==null?void 0:j.description,ids:v}});return f.length>0&&y.push({id:"__other__",label:i,description:void 0,ids:f}),{useGrouping:!0,coreIds:u,groupedIds:y}}function Pm({workData:e,onNavigate:n,renderLink:i}){var l,d,c,p;const o=Ie(),{convert:s}=Pe(),a=!!((l=e.description)!=null&&l.text)||!!e.parent_work;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:r("input-bg"),marginTop:"4px"},children:[t.jsxs("div",{style:{padding:"6px 14px",borderBottom:a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`},children:[t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:r("fg")},children:t.jsx(_t,{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:[zl(e.juan_count.number),o.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(Nl,{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(Ft,{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(Tt,{label:o.label.parentWork,children:t.jsx(_t,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:i})})})]})]})}function Bm({items:e,onNavigate:n,renderLink:i}){const o=Ie(),{convert:s}=Pe();return e.length?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"6px"},children:e.map(a=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid color-mix(in srgb, ${r("type-collection")} 25%, transparent)`,borderRadius:"4px",background:`color-mix(in srgb, ${r("type-collection")} 3%, transparent)`},children:[t.jsx("span",{style:{fontSize:"11px",color:r("type-collection")},children:o.indexType.collection}),t.jsx(_t,{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 io=({data:e,id:n,transport:i,onNavigate:o,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var M,H,N,R,A,J,ee,oe;const p=Ie(),{convert:h}=Pe(),[u,m]=g.useState(null),[f,x]=g.useState(!1),[k,y]=g.useState(null),[$,b]=g.useState(null),[w,v]=g.useState([]),j=e||u;if(g.useEffect(()=>{if(e||!n||!i)return;let V=!1;return x(!0),y(null),i.getItem(n).then(me=>{V||(me?m(me):y(p.misc.notFoundEntry))}).catch(me=>{V||y(me instanceof Error?me.message:p.misc.loadFailed)}).finally(()=>{V||x(!1)}),()=>{V=!0}},[e,n,i]),g.useEffect(()=>{if(!j||!i){b(null),v([]);return}let V=!1;const me=j.type==="book"||j.type==="collection"?j.work_id:void 0;if(me?i.getItem(me).then(G=>{!V&&G&&G.type==="work"&&b(G)}).catch(()=>{}):b(null),j.type==="book"){const G=j;G.contained_in&&G.contained_in.length>0?Promise.all(G.contained_in.map(q=>{const ce=typeof q=="string"?q:q.id,we=typeof q=="string"?void 0:q.volume_index;return i.getItem(ce).then(O=>({id:ce,title:O&&O.title||ce,volume_index:we})).catch(()=>({id:ce,title:ce,volume_index:we}))})).then(q=>{V||v(q)}):v([])}else v([]);return()=>{V=!0}},[j,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((V,me)=>t.jsx("div",{style:{height:me===1?"32px":"16px",width:`${V}px`,background:r("widget-border"),borderRadius:"4px",opacity:.4}},me))})});if(k)return t.jsx("div",{className:d,style:{...c,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:k});if(!j)return null;if(j.type==="entity")return t.jsx("div",{className:d,style:c,children:t.jsx($l,{data:j,transport:i,onNavigate:o,renderLink:s,headerExtra:a})});const C=j.type==="book"?j:null,S=j.type==="collection"?j:null,_=j.type==="work"?j:null;let L=!1;try{L=ke.extractStatus(j.id)==="draft"}catch{}let T="";j.measure_info?T=h(j.measure_info):(M=j.juan_count)!=null&&M.number?T=zl(j.juan_count.number)+p.unit.juan:(H=j.juan_count)!=null&&H.description&&(T=h(j.juan_count.description));const z=[];return(N=j.publication_info)!=null&&N.year&&z.push(t.jsx(Tt,{label:p.label.year,children:j.publication_info.year},"year")),(R=j.current_location)!=null&&R.name&&z.push(t.jsx(Tt,{label:p.label.currentLocation,children:h(j.current_location.name)},"loc")),(A=j.page_count)!=null&&A.description&&z.push(t.jsx(Tt,{label:p.label.pageCount,children:j.page_count.description},"page")),C!=null&&C.edition&&z.push(t.jsx(Tt,{label:p.label.edition,children:h(C.edition)},"ver")),_!=null&&_.parent_work&&z.push(t.jsx(Tt,{label:p.label.parentWork,children:t.jsx(_t,{id:_.parent_work.id,label:h(_.parent_work.title),onNavigate:o,renderLink:s})},"pw")),_!=null&&_.parent_works&&_.parent_works.length>0&&!_.parent_work&&z.push(t.jsx(Tt,{label:p.label.parentWork,children:_.parent_works.map((V,me)=>t.jsxs("span",{children:[me>0&&"、",t.jsx(_t,{id:V,onNavigate:o,renderLink:s})]},V))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(zm,{id:j.id,title:h(j.title),edition:j.edition?h(j.edition):void 0,type:j.type,isDraft:L,authors:j.authors,volumeText:T,meta:z,headerExtra:a,onNavigate:o,renderLink:s}),((J=j.description)==null?void 0:J.text)&&t.jsx(Ft,{text:j.description.text,style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),j.appendix&&j.appendix.length>0&&t.jsx("div",{style:{marginTop:8,marginBottom:4},children:j.appendix.map((V,me)=>t.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:r("bg-subtle"),borderRadius:4,border:`1px solid ${r("widget-border")}`},children:[t.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:r("muted")},children:h(V.title)}),t.jsx(Ft,{text:V.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:r("fg")}})]},me))}),w.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(vt,{children:p.section.containedIn}),t.jsx(Bm,{items:w,onNavigate:o,renderLink:s})]}),$&&t.jsxs(t.Fragment,{children:[t.jsx(vt,{children:p.section.belongsToWork}),t.jsx(Pm,{workData:$,onNavigate:o,renderLink:s})]}),j.additional_works&&j.additional_works.length>0&&t.jsx(Em,{items:j.additional_works}),j.additional_titles&&j.additional_titles.length>0&&t.jsx(Nm,{items:j.additional_titles}),j.attached_texts&&j.attached_texts.length>0&&t.jsx(Im,{items:j.attached_texts}),j.indexed_by&&j.indexed_by.length>0&&t.jsx(Tm,{items:j.indexed_by,onNavigate:o,renderLink:s}),j.emendated_by&&j.emendated_by.length>0&&t.jsx(El,{items:j.emendated_by,onNavigate:o,renderLink:s}),j.resources&&j.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(vt,{children:p.section.resources}),t.jsx(Qr,{items:j.resources,resourceGroups:j.resource_groups,groupByType:!0,onNavigate:o,renderLink:s})]}),(C==null?void 0:C.location_history)&&C.location_history.length>0&&t.jsx(Rm,{items:C.location_history}),(S==null?void 0:S.history)&&S.history.length>0&&t.jsx(Lm,{items:S.history}),(C==null?void 0:C.related_books)&&C.related_books.length>0&&t.jsx(Bs,{title:p.section.relatedVersions,ids:C.related_books,transport:i,onNavigate:o,renderLink:s}),(S==null?void 0:S.books)&&S.books.length>0&&t.jsx(Bs,{title:p.section.containedBooks,ids:S.books,transport:i,onNavigate:o,renderLink:s}),(S==null?void 0:S.contained_works)&&S.contained_works.length>0&&t.jsxs("div",{children:[t.jsxs(vt,{children:[p.section.containedWorks,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",S.contained_works.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:S.contained_works.map(V=>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(_t,{id:V.id,label:h(V.title),onNavigate:o,renderLink:s})},V.id))})]}),(((ee=_==null?void 0:_.books)==null?void 0:ee.length)||0)+(((oe=_==null?void 0:_.collections)==null?void 0:oe.length)||0)>0&&t.jsx(Am,{ids:[...(_==null?void 0:_.books)||[],...(_==null?void 0:_.collections)||[]],workData:_??void 0,transport:i,onNavigate:o,renderLink:s,footer:l}),(_==null?void 0:_.related_works)&&_.related_works.length>0&&(()=>{const V=[],me=_.related_works.filter(ye=>ye.relation==="part_of"),G=_.related_works.filter(ye=>ye.relation==="has_part"),q=_.related_works.filter(ye=>ye.relation==="has_adaptation"),ce=_.related_works.filter(ye=>ye.relation==="text_carried_by"),we=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),O=_.related_works.filter(ye=>!ye.relation||!we.has(ye.relation));return me.length>0&&V.push({label:p.section.belongsToWork,items:me}),G.length>0&&V.push({label:p.section.containedWorks,items:G}),q.length>0&&V.push({label:p.section.adaptations,items:q}),ce.length>0&&V.push({label:p.section.derivativeWorks,items:ce}),O.length>0&&V.push({label:p.section.relatedWorks,items:O}),V.map(ye=>t.jsxs("div",{children:[t.jsxs(vt,{children:[ye.label,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",ye.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:ye.items.map(de=>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(_t,{id:de.id,label:h(de.title),onNavigate:o,renderLink:s})},de.id))})]},ye.label))})()]})};function Wm({data:e}){const n=Ie(),{convert:i}=Pe(),{stats:o}=e,s=o.processed_volumes??o.total_found_volumes,a=s!=null&&e.total_volumes>0?Math.round(s/e.total_volumes*100):null;return t.jsxs("div",{style:{marginBottom:"24px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:r("fg"),margin:"0 0 8px"},children:i(e.title)}),e.resource_name&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"6px"},children:i(e.resource_name)}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:r("desc-fg")},children:[t.jsxs("span",{children:[n.catalog.totalVolumes," ",t.jsx("strong",{style:{color:r("fg")},children:e.total_volumes})," ",n.unit.volume]}),a!=null&&t.jsxs("span",{children:[n.catalog.processed," ",t.jsx("strong",{style:{color:r("fg")},children:s})," ",n.unit.volume," (",a,"%)"]}),t.jsxs("span",{children:[n.catalog.contains," ",t.jsx("strong",{style:{color:r("fg")},children:o.total_books})," ",n.unit.bu]}),o.matched_works!=null&&o.matched_works>0&&t.jsxs("span",{children:[n.catalog.matched," ",t.jsx("strong",{style:{color:r("fg")},children:o.matched_works})," ",n.unit.bu]}),o.unmatched_works!=null&&o.unmatched_works>0&&t.jsxs("span",{children:[n.catalog.unmatched," ",t.jsx("strong",{style:{color:r("missing-fg")},children:o.unmatched_works})," ",n.unit.bu]})]}),e.source&&t.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:r("desc-fg")},children:[n.catalog.source," ",e.source]})]})}function Om({sections:e,activeSection:n,onSelect:i}){const o=Ie();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>i(null),style:Ws(n===null),children:o.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>i(s.name),style:Ws(n===s.name),children:[s.name,s.volume_range&&t.jsxs("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"4px"},children:[s.volume_range[0],"–",s.volume_range[1]]})]},s.name))]})}function Ws(e){return{padding:"4px 12px",border:e?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:e?`color-mix(in srgb, ${r("primary")} 8%, transparent)`:"transparent",color:r(e?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}function Fm({id:e,label:n,onNavigate:i,renderLink:o}){const s=rt();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 Hm(e,n){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const i=e[0],o=e[e.length-1];return o-i+1===e.length?`${i}–${o}`:e.length<=3?e.join(", "):`${i}–${o} (${e.length}${n})`}function Os({book:e,onNavigate:n,renderLink:i,showVolumes:o}){const s=Ie(),{convert:a}=Pe(),l=e.book_id||e.work_id,d=o&&e.volumes.length>0?Hm(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(Fm,{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 ro=({data:e,collectionId:n,transport:i,onNavigate:o,renderLink:s,className:a,style:l})=>{const d=Ie(),[c,p]=g.useState(null),[h,u]=g.useState(!1),[m,f]=g.useState(null),[x,k]=g.useState(null),[y,$]=g.useState(""),b=e||c;g.useEffect(()=>{if(e||!n||!(i!=null&&i.getCollectionCatalog))return;let S=!1;return u(!0),f(null),i.getCollectionCatalog(n).then(_=>{S||(_?p(_):f(d.catalog.notFound))}).catch(_=>{S||f(_ instanceof Error?_.message:d.catalog.loadFailed)}).finally(()=>{S||u(!1)}),()=>{S=!0}},[e,n,i,d]);const w=(b==null?void 0:b.sections)&&b.sections.length>0,v=g.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const S=b.books.map(L=>L.volumes[0]).filter(L=>L!=null);return new Set(S).size<S.length},[b]),j=g.useMemo(()=>{if(!b)return[];let S=b.books;if(x&&(S=S.filter(_=>_.section===x)),y.trim()){const _=y.trim().toLowerCase();S=S.filter(L=>L.title.toLowerCase().includes(_)||L.sub_items&&L.sub_items.some(T=>T.toLowerCase().includes(_))||L.edition&&L.edition.toLowerCase().includes(_))}return S},[b,x,y]),C=g.useMemo(()=>{if(!v)return null;const S=[],_=new Map;for(const T of j){if(!T.volumes||T.volumes.length===0)continue;const z=T.volumes[0];_.has(z)||_.set(z,[]),_.get(z).push(T)}const L=[..._.keys()].sort((T,z)=>T-z);for(const T of L)S.push({volume:T,books:_.get(T)});return S},[j,v]);return h?t.jsx("div",{className:a,style:{...l,padding:"24px"},children:t.jsx("div",{style:{color:r("desc-fg"),fontSize:"13px"},children:d.catalog.loading})}):m?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:m}):b?t.jsxs("div",{className:a,style:l,children:[t.jsx(Wm,{data:b}),w&&t.jsx(Om,{sections:b.sections,activeSection:x,onSelect:k}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:d.search.searchBookName,value:y,onChange:S=>$(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:[j.length," ",d.unit.bu]})]}),t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[C?C.map((S,_)=>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:S.volume})}),S.books.map((L,T)=>t.jsx(Os,{book:L,onNavigate:o,renderLink:s,showVolumes:L.volumes.length>1},`${S.volume}-${T}`))]},`${S.volume}-${_}`)):j.map((S,_)=>t.jsx(Os,{book:S,onNavigate:o,renderLink:s,showVolumes:!0},_)),j.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},lr=e=>e?e.catch(()=>null):Promise.resolve(null);function Ll(e){const n=new Map;function i(o){var a;let s=n.get(o);return s||(s=lr((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 ke.isSafeSegment(o)?i(o):Promise.resolve(null)},async getIndex(o,s){return!ke.isSafeSegment(o)||!ke.isSafeSegment(s)||!e.getTextIndex?null:lr(e.getTextIndex(o,s))},async getChapter(o,s,a,l){return!ke.isSafeSegment(o)||!ke.isSafeSegment(s)||!ke.isSafeSegment(a)||!e.getChapter?null:lr(e.getChapter(o,s,a,l))}}}const sn=()=>{const{t:e}=te(),[n,i]=g.useState(1);return g.useEffect(()=>{const o=setInterval(()=>i(s=>s>=3?1:s+1),500);return()=>clearInterval(o)},[]),t.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:r("desc-fg"),fontSize:"14px"},children:e("common.loading")+".".repeat(n)})},cr=String.raw`https?:\/\/[^\s()()<>"]+`,Dm=new RegExp(String.raw`\[([^\]\n]+)\]\((${cr})\)`+String.raw`|(《[^》\n]+》)\s?[((](${cr})[))]`+`|(${cr})`,"g");function Um(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function Vm(e){const n=[];let i=0;for(const o of e.matchAll(Dm)){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:Um(o[5]),url:o[5]}),i=s+o[0].length}return i<e.length&&n.push({text:e.slice(i)}),n}function Al({text:e,convert:n,className:i="bim-rd-link"}){return t.jsx(t.Fragment,{children:Vm(e).map((o,s)=>o.url?t.jsx("a",{className:i,href:o.url,target:"_blank",rel:"noopener noreferrer",children:n(o.text)},s):t.jsx(g.Fragment,{children:n(o.text)},s))})}const Ml="(min-width: 1100px)",Pl="(max-width: 719px)",Bl="(max-width: 859px)",Gm=`${Pl}, (pointer: coarse)`,zt=r("reader-top"),Ym="48px",Wl=`
145
+ }`,_l={color:"inherit",textDecoration:"none"},pm=({snippet:e})=>{const{convert:n}=Pe();return t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.6},children:qr(e).map((i,o)=>i.marked?t.jsx("mark",{style:{background:r("highlight-bg"),color:r("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(i.text)},o):t.jsx(g.Fragment,{children:n(i.text)},o))})},um=({entry:e,selected:n,onClick:i,getConfig:o,query:s})=>{const a=Ie(),{convert:l}=Pe(),d=l(e.title||e.primary_name||e.id),c=e.measure_info?l(e.measure_info):e.juan_count!=null&&e.juan_count>0?`${e.juan_count}${a.unit.juan}`:"",p=[...e.additional_titles||[],...e.attached_texts||[]],h=s&&p.length?p.find(f=>{const x=typeof f=="string"?f:f==null?void 0:f.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,u=r("cover-accent"),m=rt();return t.jsxs("a",{href:m(e.id),onClick:f=>i(e,f),className:"bim-result-card",style:{..._l,display:"flex",gap:"1.2rem",alignItems:"stretch",padding:"1.1rem 1.3rem",borderRadius:"12px",cursor:"pointer",background:r("bg"),border:n?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,transition:"border-color .2s ease, transform .2s ease, box-shadow .2s ease"},children:[t.jsxs("div",{"aria-hidden":"true",style:{position:"relative",width:"92px",minHeight:"126px",flexShrink:0,borderRadius:"4px",border:`1px solid color-mix(in srgb, ${u} 50%, ${r("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${u} 14%, ${r("bg")}), color-mix(in srgb, ${u} 7%, ${r("bg")}))`,display:"flex",alignItems:"center",justifyContent:"center",padding:"0.6rem 0.3rem"},children:[t.jsx("span",{style:{position:"absolute",left:"6px",top:0,bottom:0,borderLeft:`1px dashed color-mix(in srgb, ${u} 45%, transparent)`}}),t.jsx("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",height:"108px",flexShrink:0,overflow:"hidden",fontSize:"1.05rem",fontWeight:700,lineHeight:1.25,color:u},children:Array.from(d).map((f,x)=>t.jsx("span",{children:f},x))})]}),t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"17px",fontWeight:600,color:r("fg")},children:d}),c&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg")},children:c})]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"13px",color:r("desc-fg")},children:[e.dynasty&&t.jsxs("span",{children:["〔",l(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:l(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",l(e.role)]})]}),(e.era||e.edition)&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg")},children:[e.era&&t.jsxs("span",{children:["〔",l(e.era),"〕"]}),e.edition&&t.jsx("span",{children:l(e.edition)})]}),h&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg")},children:[a.search.alias,":",l(typeof h=="string"?h:h.book_title||"")]}),e.descriptionSnippet&&t.jsx(pm,{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(kn,{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})]})]})]})},Ps=({entry:e,selected:n,onClick:i,getConfig:o,query:s,onRemove:a})=>{const l=Ie(),{convert:d}=Pe(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(u=>{const m=typeof u=="string"?u:u==null?void 0:u.book_title;return m==null?void 0:m.toLowerCase().includes(s.toLowerCase())}):void 0,h=rt();return t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",borderRadius:"6px",border:n?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("a",{href:h(e.id),onClick:u=>i(e,u),className:"bim-result-card",style:{..._l,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(kn,{type:e.type,size:12}),t.jsx("span",{style:{fontSize:"9px",color:r("desc-fg"),lineHeight:1},children:o(e.type).name})]}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg")},children:d(e.title||e.primary_name||e.id)}),t.jsxs("span",{style:{display:"flex",gap:"2px",fontSize:"12px",opacity:.7},children:[e.has_text&&t.jsx("span",{children:l.misc.textResource}),e.has_image&&t.jsx("span",{children:l.misc.imageResource})]}),(e.era||e.edition)&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[e.era&&t.jsxs(t.Fragment,{children:["〔",d(e.era),"〕"]}),e.edition&&d(e.edition)]}),e.measure_info?t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:d(e.measure_info)}):e.juan_count!=null&&e.juan_count>0?t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[e.juan_count,l.unit.juan]}):null]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"2px"},children:[e.dynasty&&t.jsxs("span",{children:["〔",d(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:d(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",d(e.role)]}),e.type==="entity"&&(e.birth_year!=null||e.death_year!=null)&&t.jsxs("span",{style:{marginLeft:e.dynasty?"4px":0},children:[e.birth_year??"?","—",e.death_year??"?"]})]}),p&&t.jsxs("div",{style:{fontSize:"11px",color:r("desc-fg"),marginTop:"2px"},children:[l.search.alias,":",d(p)]})]}),!a&&t.jsx("span",{"aria-hidden":"true",style:{opacity:.4,marginTop:"2px"},children:"→"})]}),a&&t.jsx("button",{type:"button",onClick:()=>a(e.id),title:l.search.removeFromRecent,"aria-label":l.search.removeFromRecent,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"12px 12px 12px 8px",lineHeight:1,opacity:.5},children:"×"})]})},mm=({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 hm(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 gm({data:e}){var l,d;const{convert:n}=Pe(),{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 fm({alt_names:e}){const{convert:n}=Pe(),i=new Map;for(const a of e){const l=a.type||"別名";i.has(l)||i.set(l,[]),i.get(l).push(a.name)}const o=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...i.keys()].sort((a,l)=>{const d=o.indexOf(a),c=o.indexOf(l);return d===-1&&c===-1?0:d===-1?1:c===-1?-1:d-c});return t.jsx("div",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(a=>{const l=i.get(a);return t.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[t.jsx("span",{style:{color:r("desc-fg"),fontSize:"12px",minWidth:"36px",paddingTop:"2px"},children:n(a)}),t.jsx("span",{children:l.map((d,c)=>t.jsxs("span",{children:[c>0&&t.jsx("span",{style:{color:r("desc-fg"),margin:"0 4px"},children:"·"}),n(d)]},c))})]},a)})})}function xm({data:e}){const n=Ie(),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 bm({works:e,transport:n,onNavigate:i,renderLink:o}){const s=Ie(),{convert:a}=Pe(),l=rt(),[d,c]=g.useState(new Map);g.useEffect(()=>{if(!n)return;let m=!1;const f=e.map(k=>k.work_id);return(async()=>{const k=new Map;if(n.getEntriesByIds)try{const w=await n.getEntriesByIds(f);let v=!0;for(let j=0;j<f.length;j++){const C=w[j];C!=null&&C.title?k.set(f[j],C.title):C!=null&&C.primary_name?k.set(f[j],C.primary_name):v=!1}if(v)return k}catch{}const y=[...f],$=8,b=new Array($).fill(0).map(async()=>{for(;y.length;){const w=y.shift();if(!w)break;if(!k.has(w))try{if(n.getEntry){const C=await n.getEntry(w);if(C!=null&&C.title){k.set(w,C.title);continue}}const v=await n.getItem(w),j=v&&(v.title||v.primary_name)||w;k.set(w,j)}catch{k.set(w,w)}}});return await Promise.all(b),k})().then(k=>{m||c(k)}),()=>{m=!0}},[e,n]);const p=new Map;for(const m of e){const f=m.role||"";p.has(f)||p.set(f,[]),p.get(f).push(m)}const h=["撰","編","注","輯","集","校","評","譯","述","作",""],u=[...p.keys()].sort((m,f)=>{const x=h.indexOf(m),k=h.indexOf(f);return x===-1&&k===-1?m.localeCompare(f):x===-1?1:k===-1?-1:x-k});return t.jsxs("div",{style:{marginTop:"12px"},children:[t.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:r("fg"),margin:"0 0 8px",paddingBottom:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[s.label.relatedWorks," ",t.jsxs("span",{style:{color:r("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",e.length,")"]})]}),u.map(m=>{const f=p.get(m);return t.jsxs("div",{style:{marginBottom:"8px"},children:[m&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"2px"},children:[a(m)," ",t.jsxs("span",{style:{color:r("desc-fg")},children:["(",f.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:m?"16px":"0",listStyle:m?"disc":"none",fontSize:"14px",lineHeight:1.8},children:f.map((x,k)=>{const y=a(d.get(x.work_id)||x.work_id);return o?t.jsx("li",{children:o(x.work_id,y)},k):i?t.jsx("li",{children:t.jsx("a",{href:l(x.work_id),onClick:$=>{$.metaKey||$.ctrlKey||($.preventDefault(),i(x.work_id))},style:{color:r("link-fg"),textDecoration:"underline",cursor:"pointer"},children:y})},k):t.jsx("li",{children:y},k)})})]},m)})]})}const $l=({data:e,transport:n,onNavigate:i,renderLink:o,headerExtra:s,hideHeader:a})=>{var u;const l=Ie(),{convert:d}=Pe();let c=!1;try{c=ke.extractStatus(e.id)==="draft"}catch{}const p=hm(e),h=e.subtype&&e.subtype in l.common.entitySubtype?l.common.entitySubtype[e.subtype]:d(e.subtype);return t.jsxs("div",{children:[!a&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"4px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:600,margin:0,lineHeight:1.3,color:r("fg")},children:[d(e.primary_name),t.jsx(gm,{data:e})]}),s]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:r("type-entity"),border:`1px solid color-mix(in srgb, ${r("type-entity")} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${r("type-entity")} 3%, transparent)`},children:l.indexType.entity}),h&&e.subtype!=="people"&&t.jsx("span",{children:h}),c&&t.jsx("span",{style:{padding:"1px 6px",background:r("warn-bg"),border:`1px solid ${r("warn-border")}`,borderRadius:"2px",color:r("warn-fg")},children:l.status.draft}),t.jsx("span",{style:{fontFamily:"monospace",opacity:.6},children:e.id})]})]}),p&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),fontStyle:"italic",padding:"8px 12px",background:r("widget-bg"),border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",margin:"8px 0"},children:l.common.entityPlaceholderNote}),e.alt_names&&e.alt_names.length>0&&t.jsx(fm,{alt_names:e.alt_names}),t.jsx(xm,{data:e}),((u=e.description)==null?void 0:u.text)&&t.jsx("p",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:d(e.description.text)}),e.works&&e.works.length>0&&t.jsx(bm,{works:e.works,transport:n,onNavigate:i,renderLink:o})]})},ym=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function jm(e){const n=e.search(ym);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const Cl={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===vm(e))){const[a,l]=jm(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 vm(e){try{return decodeURI(e)}catch{return e}}const km={...Cl,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},Ft=({text:e,plainStrong:n,style:i,className:o})=>{const{convert:s}=Pe(),a=n?km:Cl;return t.jsx("div",{className:o,style:i,children:t.jsx(Gp,{remarkPlugins:[Yp],components:a,children:s(e)})})},wm=["〇","一","二","三","四","五","六","七","八","九"],Bs=["","十","百","千"];function zl(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),i=n.length;let o="",s=!1;for(let a=0;a<i;a++){const l=parseInt(n[a]),d=i-1-a;l===0?s=!0:(s&&o&&(o+="〇"),s=!1,l===1&&d===1&&a===0?o+=Bs[d]:o+=wm[l]+Bs[d])}return o}function Tl(e){return{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:e,border:`1px solid color-mix(in srgb, ${e} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${e} 3%, transparent)`}}const Sm={book:r("type-book"),work:r("type-work"),collection:r("type-collection"),entity:r("type-entity")};function _m({type:e}){const n=Ie();return t.jsx("span",{style:Tl(Sm[e]),children:n.indexType[e]})}function $m({isDraft:e}){const n=Ie(),i=r(e?"status-draft":"status-official");return t.jsx("span",{style:Tl(i),children:e?n.status.draft:n.status.official})}function Cm({id:e}){const n=Ie(),[i,o]=g.useState(!1),s=()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})};return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:r("desc-fg"),background:r("bg-subtle"),border:`1px solid ${r("widget-border")}`,borderRadius:"2px"},children:[t.jsx("span",{children:n.label.id}),t.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:r("fg")},children:e}),t.jsx("span",{onClick:s,title:i?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"11px",opacity:i?1:.5,transition:"opacity 0.15s"},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity=i?"1":"0.5",children:i?"✓":"⧉"})]})}function vt({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 Tt({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 Nl({authors:e,type:n,onNavigate:i,renderLink:o}){const{convert:s}=Pe();return t.jsx("span",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.6},children:e.map((a,l)=>{const d=s(a.name),c=a.entity_id?t.jsx(_t,{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 _t({id:e,label:n,onNavigate:i,renderLink:o}){const s=rt();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 zm({id:e,title:n,edition:i,type:o,isDraft:s,authors:a,volumeText:l,meta:d,headerExtra:c,onNavigate:p,renderLink:h}){return t.jsxs("div",{style:{marginBottom:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:700,color:r("fg"),margin:"0 0 6px",lineHeight:1.4,letterSpacing:"0.5px",wordBreak:"break-word",flex:1,minWidth:0},children:[n,i&&t.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:i}),l&&t.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:r("desc-fg"),marginLeft:"8px"},children:l})]}),c&&t.jsx("div",{style:{flexShrink:0,paddingTop:"2px"},children:c})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"4px"},children:[t.jsx(_m,{type:o}),t.jsx($m,{isDraft:s}),t.jsx(Cm,{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(Nl,{authors:a,type:o,onNavigate:p,renderLink:h}),d]})]})}function Il({items:e,label:n,showMeta:i,onNavigate:o,renderLink:s}){const a=Ie(),{convert:l}=Pe();if(!e.length)return null;const[d,c]=g.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(vt,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((p,h)=>{const u=d===h;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...u?{boxShadow:r("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(u?null:h),style:{padding:"8px 12px",background:r("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.15s",transform:u?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(p.source)}),!u&&i&&p.title_info&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l(p.title_info)}),p.source_bid&&t.jsx("span",{onClick:m=>m.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(_t,{id:p.source_bid,label:a.action.view,onNavigate:o,renderLink:s})})]}),u&&t.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${r("widget-border")}`},children:[i&&(p.title_info||p.author_info||p.edition)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[p.title_info&&t.jsx(Tt,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx(Tt,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx(Tt,{label:a.label.edition,children:l(p.edition)})]}),p.summary&&t.jsxs("div",{style:{marginTop:"6px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.summary}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:l(p.summary)})]}),p.comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.comment}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.comment)})]}),p.additional_comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.additionalComment}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.additional_comment)})]})]})]},h)})})]})}function Tm({items:e,onNavigate:n,renderLink:i}){const o=Ie();return t.jsx(Il,{items:e,label:o.section.indexed,showMeta:!0,onNavigate:n,renderLink:i})}function El({items:e,onNavigate:n,renderLink:i}){const o=Ie();return t.jsx(Il,{items:e,label:o.section.emendated,onNavigate:n,renderLink:i})}function Rl({label:e,items:n}){const{convert:i}=Pe();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(vt,{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 Nm({items:e}){const n=Ie();return t.jsx(Rl,{label:n.section.aliases,items:e})}function Im({items:e}){const n=Ie();return t.jsx(Rl,{label:n.section.attachedTexts,items:e})}function Em({items:e}){const n=Ie(),{convert:i}=Pe();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(vt,{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 Rm({items:e}){const n=Ie(),{convert:i}=Pe();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(vt,{children:n.section.locationHistory}),t.jsxs("div",{style:{position:"relative",paddingLeft:"18px"},children:[t.jsx("div",{style:{position:"absolute",left:"4px",top:"6px",bottom:"6px",width:"1px",background:r("widget-border")}}),e.map((o,s)=>t.jsxs("div",{style:{position:"relative",marginBottom:"10px"},children:[t.jsx("div",{style:{position:"absolute",left:"-16px",top:"5px",width:"7px",height:"7px",borderRadius:"50%",background:r("primary"),border:`1.5px solid ${r("input-bg")}`}}),t.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:r("fg")},children:i(o.name)}),o.description&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),marginLeft:"8px"},children:i(o.description)})]},s))]})]}):null}function Lm({items:e}){const n=Ie(),{convert:i}=Pe();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(vt,{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 Os({title:e,ids:n,transport:i,onNavigate:o,renderLink:s}){const{convert:a}=Pe(),[l,d]=g.useState([]);return g.useEffect(()=>{if(!n.length){d([]);return}if(!i){d(n.map(p=>({id:p})));return}let c=!1;return Promise.all(n.map(p=>i.getItem(p).then(h=>({id:p,title:h?h.title:void 0,edition:h?h.edition:void 0,type:h?h.type:void 0})).catch(()=>({id:p})))).then(p=>{c||d(p)}),()=>{c=!0}},[n,i]),n.length?t.jsxs(t.Fragment,{children:[t.jsxs(vt,{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(_t,{id:c.id,label:p,onNavigate:o,renderLink:s})},c.id)})})]}):null}function ar({book:e,onNavigate:n,renderLink:i}){const o=Ie(),{convert:s}=Pe(),[a,l]=g.useState(!1),d=e.resources&&e.resources.length>0,c=e.edition?s(e.edition):s(e.title)||void 0;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:r("input-bg")},children:[t.jsxs("div",{style:{padding:"6px 12px",borderBottom:d&&!a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:t.jsx(_t,{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(eo,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:i})})]})}function Am({ids:e,workData:n,transport:i,onNavigate:o,renderLink:s,footer:a}){const l=Ie(),{convert:d}=Pe(),[c,p]=g.useState([]);if(g.useEffect(()=>{if(!e.length){p([]);return}if(!i){p(e.map(k=>({id:k})));return}let x=!1;return Promise.all(e.map(k=>i.getItem(k).then(y=>({id:k,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:k})))).then(k=>{x||p(k)}),()=>{x=!0}},[e,i]),!e.length)return null;const h=c.length?c:e.map(x=>({id:x})),u=new Map(h.map(x=>[x.id,x])),m=n==null?void 0:n.version_graph,f=Mm(e,m,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(vt,{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 k=u.get(x);return k?t.jsx(ar,{book:k,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(k=>{const y=u.get(k);return y?t.jsx(ar,{book:y,onNavigate:o,renderLink:s},k):null})})]},x.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:h.map(x=>t.jsx(ar,{book:x,onNavigate:o,renderLink:s},x.id))})]})}function Mm(e,n,i){var $,b;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const o=($=n.collections)==null?void 0:$[n.default_collection],s=(o==null?void 0:o.groups)??[],a=(o==null?void 0:o.book_ids)??[],l=s.length>0||a.length>0,d=!l&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!l&&d.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const c=new Set(s),p=new Set([...a,...d]),h=w=>{if(p.has(w))return!0;const v=n.node_groups[w];return v!=null&&c.has(v)},u=[],m=new Map,f=[];for(const w of e)if(!((b=n.excluded_books)!=null&&b.includes(w)))if(h(w))u.push(w);else{const v=n.node_groups[w];v?(m.has(v)||m.set(v,[]),m.get(v).push(w)):f.push(w)}if(f.length+[...m.values()].reduce((w,v)=>w+v.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const k=new Map((n.groups??[]).map(w=>[w.id,w])),y=[...m.entries()].map(([w,v])=>{const j=k.get(w);return{id:w,label:(j==null?void 0:j.label)??w,description:j==null?void 0:j.description,ids:v}});return f.length>0&&y.push({id:"__other__",label:i,description:void 0,ids:f}),{useGrouping:!0,coreIds:u,groupedIds:y}}function Pm({workData:e,onNavigate:n,renderLink:i}){var l,d,c,p;const o=Ie(),{convert:s}=Pe(),a=!!((l=e.description)!=null&&l.text)||!!e.parent_work;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:r("input-bg"),marginTop:"4px"},children:[t.jsxs("div",{style:{padding:"6px 14px",borderBottom:a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`},children:[t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:r("fg")},children:t.jsx(_t,{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:[zl(e.juan_count.number),o.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(Nl,{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(Ft,{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(Tt,{label:o.label.parentWork,children:t.jsx(_t,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:i})})})]})]})}function Bm({items:e,onNavigate:n,renderLink:i}){const o=Ie(),{convert:s}=Pe();return e.length?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"6px"},children:e.map(a=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid color-mix(in srgb, ${r("type-collection")} 25%, transparent)`,borderRadius:"4px",background:`color-mix(in srgb, ${r("type-collection")} 3%, transparent)`},children:[t.jsx("span",{style:{fontSize:"11px",color:r("type-collection")},children:o.indexType.collection}),t.jsx(_t,{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 ro=({data:e,id:n,transport:i,onNavigate:o,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var M,H,I,R,P,K,te,ie;const p=Ie(),{convert:h}=Pe(),[u,m]=g.useState(null),[f,x]=g.useState(!1),[k,y]=g.useState(null),[$,b]=g.useState(null),[w,v]=g.useState([]),j=e||u;if(g.useEffect(()=>{if(e||!n||!i)return;let U=!1;return x(!0),y(null),i.getItem(n).then(pe=>{U||(pe?m(pe):y(p.misc.notFoundEntry))}).catch(pe=>{U||y(pe instanceof Error?pe.message:p.misc.loadFailed)}).finally(()=>{U||x(!1)}),()=>{U=!0}},[e,n,i]),g.useEffect(()=>{if(!j||!i){b(null),v([]);return}let U=!1;const pe=j.type==="book"||j.type==="collection"?j.work_id:void 0;if(pe?i.getItem(pe).then(G=>{!U&&G&&G.type==="work"&&b(G)}).catch(()=>{}):b(null),j.type==="book"){const G=j;G.contained_in&&G.contained_in.length>0?Promise.all(G.contained_in.map(ee=>{const ae=typeof ee=="string"?ee:ee.id,Se=typeof ee=="string"?void 0:ee.volume_index;return i.getItem(ae).then(O=>({id:ae,title:O&&O.title||ae,volume_index:Se})).catch(()=>({id:ae,title:ae,volume_index:Se}))})).then(ee=>{U||v(ee)}):v([])}else v([]);return()=>{U=!0}},[j,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,pe)=>t.jsx("div",{style:{height:pe===1?"32px":"16px",width:`${U}px`,background:r("widget-border"),borderRadius:"4px",opacity:.4}},pe))})});if(k)return t.jsx("div",{className:d,style:{...c,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:k});if(!j)return null;if(j.type==="entity")return t.jsx("div",{className:d,style:c,children:t.jsx($l,{data:j,transport:i,onNavigate:o,renderLink:s,headerExtra:a})});const C=j.type==="book"?j:null,S=j.type==="collection"?j:null,_=j.type==="work"?j:null;let A=!1;try{A=ke.extractStatus(j.id)==="draft"}catch{}let T="";j.measure_info?T=h(j.measure_info):(M=j.juan_count)!=null&&M.number?T=zl(j.juan_count.number)+p.unit.juan:(H=j.juan_count)!=null&&H.description&&(T=h(j.juan_count.description));const z=[];return(I=j.publication_info)!=null&&I.year&&z.push(t.jsx(Tt,{label:p.label.year,children:j.publication_info.year},"year")),(R=j.current_location)!=null&&R.name&&z.push(t.jsx(Tt,{label:p.label.currentLocation,children:h(j.current_location.name)},"loc")),(P=j.page_count)!=null&&P.description&&z.push(t.jsx(Tt,{label:p.label.pageCount,children:j.page_count.description},"page")),C!=null&&C.edition&&z.push(t.jsx(Tt,{label:p.label.edition,children:h(C.edition)},"ver")),_!=null&&_.parent_work&&z.push(t.jsx(Tt,{label:p.label.parentWork,children:t.jsx(_t,{id:_.parent_work.id,label:h(_.parent_work.title),onNavigate:o,renderLink:s})},"pw")),_!=null&&_.parent_works&&_.parent_works.length>0&&!_.parent_work&&z.push(t.jsx(Tt,{label:p.label.parentWork,children:_.parent_works.map((U,pe)=>t.jsxs("span",{children:[pe>0&&"、",t.jsx(_t,{id:U,onNavigate:o,renderLink:s})]},U))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(zm,{id:j.id,title:h(j.title),edition:j.edition?h(j.edition):void 0,type:j.type,isDraft:A,authors:j.authors,volumeText:T,meta:z,headerExtra:a,onNavigate:o,renderLink:s}),((K=j.description)==null?void 0:K.text)&&t.jsx(Ft,{text:j.description.text,style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),j.appendix&&j.appendix.length>0&&t.jsx("div",{style:{marginTop:8,marginBottom:4},children:j.appendix.map((U,pe)=>t.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:r("bg-subtle"),borderRadius:4,border:`1px solid ${r("widget-border")}`},children:[t.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:r("muted")},children:h(U.title)}),t.jsx(Ft,{text:U.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:r("fg")}})]},pe))}),w.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(vt,{children:p.section.containedIn}),t.jsx(Bm,{items:w,onNavigate:o,renderLink:s})]}),$&&t.jsxs(t.Fragment,{children:[t.jsx(vt,{children:p.section.belongsToWork}),t.jsx(Pm,{workData:$,onNavigate:o,renderLink:s})]}),j.additional_works&&j.additional_works.length>0&&t.jsx(Em,{items:j.additional_works}),j.additional_titles&&j.additional_titles.length>0&&t.jsx(Nm,{items:j.additional_titles}),j.attached_texts&&j.attached_texts.length>0&&t.jsx(Im,{items:j.attached_texts}),j.indexed_by&&j.indexed_by.length>0&&t.jsx(Tm,{items:j.indexed_by,onNavigate:o,renderLink:s}),j.emendated_by&&j.emendated_by.length>0&&t.jsx(El,{items:j.emendated_by,onNavigate:o,renderLink:s}),j.resources&&j.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(vt,{children:p.section.resources}),t.jsx(eo,{items:j.resources,resourceGroups:j.resource_groups,groupByType:!0,onNavigate:o,renderLink:s})]}),(C==null?void 0:C.location_history)&&C.location_history.length>0&&t.jsx(Rm,{items:C.location_history}),(S==null?void 0:S.history)&&S.history.length>0&&t.jsx(Lm,{items:S.history}),(C==null?void 0:C.related_books)&&C.related_books.length>0&&t.jsx(Os,{title:p.section.relatedVersions,ids:C.related_books,transport:i,onNavigate:o,renderLink:s}),(S==null?void 0:S.books)&&S.books.length>0&&t.jsx(Os,{title:p.section.containedBooks,ids:S.books,transport:i,onNavigate:o,renderLink:s}),(S==null?void 0:S.contained_works)&&S.contained_works.length>0&&t.jsxs("div",{children:[t.jsxs(vt,{children:[p.section.containedWorks,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",S.contained_works.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:S.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(_t,{id:U.id,label:h(U.title),onNavigate:o,renderLink:s})},U.id))})]}),(((te=_==null?void 0:_.books)==null?void 0:te.length)||0)+(((ie=_==null?void 0:_.collections)==null?void 0:ie.length)||0)>0&&t.jsx(Am,{ids:[...(_==null?void 0:_.books)||[],...(_==null?void 0:_.collections)||[]],workData:_??void 0,transport:i,onNavigate:o,renderLink:s,footer:l}),(_==null?void 0:_.related_works)&&_.related_works.length>0&&(()=>{const U=[],pe=_.related_works.filter(je=>je.relation==="part_of"),G=_.related_works.filter(je=>je.relation==="has_part"),ee=_.related_works.filter(je=>je.relation==="has_adaptation"),ae=_.related_works.filter(je=>je.relation==="text_carried_by"),Se=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),O=_.related_works.filter(je=>!je.relation||!Se.has(je.relation));return pe.length>0&&U.push({label:p.section.belongsToWork,items:pe}),G.length>0&&U.push({label:p.section.containedWorks,items:G}),ee.length>0&&U.push({label:p.section.adaptations,items:ee}),ae.length>0&&U.push({label:p.section.derivativeWorks,items:ae}),O.length>0&&U.push({label:p.section.relatedWorks,items:O}),U.map(je=>t.jsxs("div",{children:[t.jsxs(vt,{children:[je.label,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",je.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:je.items.map(de=>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(_t,{id:de.id,label:h(de.title),onNavigate:o,renderLink:s})},de.id))})]},je.label))})()]})};function Om({data:e}){const n=Ie(),{convert:i}=Pe(),{stats:o}=e,s=o.processed_volumes??o.total_found_volumes,a=s!=null&&e.total_volumes>0?Math.round(s/e.total_volumes*100):null;return t.jsxs("div",{style:{marginBottom:"24px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:r("fg"),margin:"0 0 8px"},children:i(e.title)}),e.resource_name&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"6px"},children:i(e.resource_name)}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:r("desc-fg")},children:[t.jsxs("span",{children:[n.catalog.totalVolumes," ",t.jsx("strong",{style:{color:r("fg")},children:e.total_volumes})," ",n.unit.volume]}),a!=null&&t.jsxs("span",{children:[n.catalog.processed," ",t.jsx("strong",{style:{color:r("fg")},children:s})," ",n.unit.volume," (",a,"%)"]}),t.jsxs("span",{children:[n.catalog.contains," ",t.jsx("strong",{style:{color:r("fg")},children:o.total_books})," ",n.unit.bu]}),o.matched_works!=null&&o.matched_works>0&&t.jsxs("span",{children:[n.catalog.matched," ",t.jsx("strong",{style:{color:r("fg")},children:o.matched_works})," ",n.unit.bu]}),o.unmatched_works!=null&&o.unmatched_works>0&&t.jsxs("span",{children:[n.catalog.unmatched," ",t.jsx("strong",{style:{color:r("missing-fg")},children:o.unmatched_works})," ",n.unit.bu]})]}),e.source&&t.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:r("desc-fg")},children:[n.catalog.source," ",e.source]})]})}function Wm({sections:e,activeSection:n,onSelect:i}){const o=Ie();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>i(null),style:Ws(n===null),children:o.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>i(s.name),style:Ws(n===s.name),children:[s.name,s.volume_range&&t.jsxs("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"4px"},children:[s.volume_range[0],"–",s.volume_range[1]]})]},s.name))]})}function Ws(e){return{padding:"4px 12px",border:e?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:e?`color-mix(in srgb, ${r("primary")} 8%, transparent)`:"transparent",color:r(e?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}function Fm({id:e,label:n,onNavigate:i,renderLink:o}){const s=rt();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 Hm(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 Fs({book:e,onNavigate:n,renderLink:i,showVolumes:o}){const s=Ie(),{convert:a}=Pe(),l=e.book_id||e.work_id,d=o&&e.volumes.length>0?Hm(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(Fm,{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 oo=({data:e,collectionId:n,transport:i,onNavigate:o,renderLink:s,className:a,style:l})=>{const d=Ie(),[c,p]=g.useState(null),[h,u]=g.useState(!1),[m,f]=g.useState(null),[x,k]=g.useState(null),[y,$]=g.useState(""),b=e||c;g.useEffect(()=>{if(e||!n||!(i!=null&&i.getCollectionCatalog))return;let S=!1;return u(!0),f(null),i.getCollectionCatalog(n).then(_=>{S||(_?p(_):f(d.catalog.notFound))}).catch(_=>{S||f(_ instanceof Error?_.message:d.catalog.loadFailed)}).finally(()=>{S||u(!1)}),()=>{S=!0}},[e,n,i,d]);const w=(b==null?void 0:b.sections)&&b.sections.length>0,v=g.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const S=b.books.map(A=>A.volumes[0]).filter(A=>A!=null);return new Set(S).size<S.length},[b]),j=g.useMemo(()=>{if(!b)return[];let S=b.books;if(x&&(S=S.filter(_=>_.section===x)),y.trim()){const _=y.trim().toLowerCase();S=S.filter(A=>A.title.toLowerCase().includes(_)||A.sub_items&&A.sub_items.some(T=>T.toLowerCase().includes(_))||A.edition&&A.edition.toLowerCase().includes(_))}return S},[b,x,y]),C=g.useMemo(()=>{if(!v)return null;const S=[],_=new Map;for(const T of j){if(!T.volumes||T.volumes.length===0)continue;const z=T.volumes[0];_.has(z)||_.set(z,[]),_.get(z).push(T)}const A=[..._.keys()].sort((T,z)=>T-z);for(const T of A)S.push({volume:T,books:_.get(T)});return S},[j,v]);return h?t.jsx("div",{className:a,style:{...l,padding:"24px"},children:t.jsx("div",{style:{color:r("desc-fg"),fontSize:"13px"},children:d.catalog.loading})}):m?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:m}):b?t.jsxs("div",{className:a,style:l,children:[t.jsx(Om,{data:b}),w&&t.jsx(Wm,{sections:b.sections,activeSection:x,onSelect:k}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:d.search.searchBookName,value:y,onChange:S=>$(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:[j.length," ",d.unit.bu]})]}),t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[C?C.map((S,_)=>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:S.volume})}),S.books.map((A,T)=>t.jsx(Fs,{book:A,onNavigate:o,renderLink:s,showVolumes:A.volumes.length>1},`${S.volume}-${T}`))]},`${S.volume}-${_}`)):j.map((S,_)=>t.jsx(Fs,{book:S,onNavigate:o,renderLink:s,showVolumes:!0},_)),j.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},lr=e=>e?e.catch(()=>null):Promise.resolve(null);function Ll(e){const n=new Map;function i(o){var a;let s=n.get(o);return s||(s=lr((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 ke.isSafeSegment(o)?i(o):Promise.resolve(null)},async getIndex(o,s){return!ke.isSafeSegment(o)||!ke.isSafeSegment(s)||!e.getTextIndex?null:lr(e.getTextIndex(o,s))},async getChapter(o,s,a,l){return!ke.isSafeSegment(o)||!ke.isSafeSegment(s)||!ke.isSafeSegment(a)||!e.getChapter?null:lr(e.getChapter(o,s,a,l))}}}const sn=()=>{const{t:e}=ne(),[n,i]=g.useState(1);return g.useEffect(()=>{const o=setInterval(()=>i(s=>s>=3?1:s+1),500);return()=>clearInterval(o)},[]),t.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:r("desc-fg"),fontSize:"14px"},children:e("common.loading")+".".repeat(n)})},cr=String.raw`https?:\/\/[^\s()()<>"]+`,Dm=new RegExp(String.raw`\[([^\]\n]+)\]\((${cr})\)`+String.raw`|(《[^》\n]+》)\s?[((](${cr})[))]`+`|(${cr})`,"g");function Um(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function Vm(e){const n=[];let i=0;for(const o of e.matchAll(Dm)){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:Um(o[5]),url:o[5]}),i=s+o[0].length}return i<e.length&&n.push({text:e.slice(i)}),n}function Al({text:e,convert:n,className:i="bim-rd-link"}){return t.jsx(t.Fragment,{children:Vm(e).map((o,s)=>o.url?t.jsx("a",{className:i,href:o.url,target:"_blank",rel:"noopener noreferrer",children:n(o.text)},s):t.jsx(g.Fragment,{children:n(o.text)},s))})}const Ml="(min-width: 1100px)",Pl="(max-width: 719px)",Bl="(max-width: 859px)",Gm=`${Pl}, (pointer: coarse)`,zt=r("reader-top"),Ym="48px",Ol=`
146
146
  .bim-rd {
147
147
  position: relative;
148
148
  background: ${r("page-bg")};
@@ -673,16 +673,16 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
673
673
  letter-spacing: 0.05em;
674
674
  margin-left: 6px;
675
675
  }
676
- `;function oo(e,n){var i;return n?e.key===n?!0:!!((i=e.children)!=null&&i.some(o=>oo(o,n))):!1}const qm=()=>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 Km({item:e,activeKey:n,onSelect:i,tabKey:o}){const s=oo(e,n),[a,l]=g.useState(s||!!e.defaultExpanded);return g.useEffect(()=>{s&&l(!0)},[s]),g.useEffect(()=>{e.defaultExpanded&&l(!0)},[e.defaultExpanded]),t.jsxs("li",{children:[t.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":a,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>l(d=>!d),children:[t.jsx(qm,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),a&&t.jsx(Ol,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]})}function Ol({items:e,activeKey:n,onSelect:i,tabKey:o}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(Km,{item:s,activeKey:n,onSelect:i,tabKey:o},s.key):t.jsx("li",{children:t.jsxs("button",{type:"button",className:"bim-rd-ti","aria-current":s.key===n?"true":void 0,disabled:s.disabled,"data-rd-toc-key":s.key,tabIndex:o===s.key?0:-1,onClick:()=>i(s.key),children:[t.jsx("span",{children:s.label}),s.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:s.hint})]})},s.key))})}function Fs(e,n){var i;for(const o of e)if(o.key===n||oo(o,n))return o.key;return((i=e[0])==null?void 0:i.key)??null}function Fl({items:e,activeKey:n,onSelect:i,label:o}){const{t:s}=te(),a=o??s("reader.toc"),l=g.useRef(null),[d,c]=g.useState(null);g.useEffect(()=>{c(null)},[n]);const p=g.useMemo(()=>d||(n??Fs(e,n)),[d,n,e]);g.useEffect(()=>{const u=l.current;if(!u)return;const m=Array.from(u.querySelectorAll("[data-rd-toc-key]"));if(m.length===0)return;const f=m.find(x=>x.dataset.rdTocKey===p)??m.find(x=>x.dataset.rdTocKey===Fs(e,n))??m.find(x=>!x.disabled)??m[0];for(const x of m)x.tabIndex=x===f?0:-1}),g.useEffect(()=>{const u=l.current,m=u==null?void 0:u.closest(".bim-rd-toc");if(!u||!m||!n)return;const f=Array.from(u.querySelectorAll("[data-rd-toc-key]")).find(k=>k.dataset.rdTocKey===n);if(!f)return;const x=f.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop;(x<m.scrollTop+80||x>m.scrollTop+m.clientHeight-40)&&(m.scrollTop=Math.max(0,x-m.clientHeight/3))},[n]);const h=g.useCallback(u=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(u.key))return;const f=l.current;if(!f)return;const x=Array.from(f.querySelectorAll("[data-rd-toc-key]")).filter(b=>!b.disabled),k=x.indexOf(document.activeElement);let y=k;if(u.key==="ArrowDown"?y=Math.min(x.length-1,k+1):u.key==="ArrowUp"?y=Math.max(0,k-1):u.key==="Home"?y=0:u.key==="End"&&(y=x.length-1),y<0||y===k)return;u.preventDefault();const $=x[y];for(const b of x)b.tabIndex=-1;$.tabIndex=0,$.focus(),c($.dataset.rdTocKey??null)},[]);return t.jsx("div",{ref:l,role:"navigation","aria-label":a,onKeyDown:h,children:t.jsx(Ol,{items:e,activeKey:n,onSelect:i,tabKey:p})})}function Hs({page:e,crop:n}){var i;return!((i=e.boxes)!=null&&i.length)||!e.width||!e.height||e.boxFormat&&e.boxFormat!=="bim-charbox-v0"?null:t.jsx("svg",{viewBox:n?`${n.x} ${n.y} ${n.w} ${n.h}`:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:e.boxes.map((o,s)=>t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:"none",stroke:r("accent"),strokeOpacity:.55,vectorEffect:"non-scaling-stroke",strokeWidth:1},s))})}function Xm(e){const{boxes:n,width:i,height:o}=e;if(!(n!=null&&n.length)||!i||!o||e.boxFormat&&e.boxFormat!=="bim-charbox-v0")return null;let s=1/0,a=1/0,l=-1/0,d=-1/0;for(const f of n)[f.x,f.y,f.w,f.h].every(Number.isFinite)&&(s=Math.min(s,f.x),a=Math.min(a,f.y),l=Math.max(l,f.x+f.w),d=Math.max(d,f.y+f.h));if(!(l>s)||!(d>a))return null;const c=Math.min(i,o)*.03,p=Math.min(i,Math.max(0,s-c)),h=Math.min(o,Math.max(0,a-c)),u=Math.min(i,Math.max(0,l+c))-p,m=Math.min(o,Math.max(0,d+c))-h;return!(u>0)||!(m>0)||u>=i*.98&&m>=o*.98?null:{x:p,y:h,w:u,h:m}}function _r({pages:e,loading:n,page:i,onPageChange:o,renderOverlay:s,preserveMargins:a=!0}){const{t:l}=te(),[d,c]=g.useState(0),p=i??d,h=k=>{o?o(k):c(k)};if(g.useEffect(()=>{i===void 0&&c(0)},[e,i]),n)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsx("div",{className:"bim-rd-img-empty",children:l("reader.imagesLoading")})});if(!e||e.length===0)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsxs("div",{className:"bim-rd-img-empty",children:[t.jsx("div",{className:"bim-rd-img-frame","aria-hidden":"true"}),t.jsx("b",{children:l("reader.noImages")}),t.jsx("span",{children:l("reader.noImagesHint")})]})});const u=Math.max(0,Math.min(e.length-1,p)),m=e[u],f=m.label??`${u+1}`,x=!a&&!s?Xm(m):null;return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-img-box",children:x?t.jsxs("figure",{className:"bim-rd-img-fig bim-rd-img-trimmed","data-trim":`${Math.round(x.x)},${Math.round(x.y)},${Math.round(x.w)},${Math.round(x.h)}`,style:{aspectRatio:`${x.w} / ${x.h}`,overflow:"hidden",width:"100%",maxWidth:`calc((100vh - 200px) * ${x.w/x.h})`},children:[t.jsx("img",{src:m.url,alt:m.alt??l("reader.imageAlt",{label:f}),decoding:"async",style:{position:"absolute",maxWidth:"none",maxHeight:"none",width:`${m.width/x.w*100}%`,left:`${-x.x/x.w*100}%`,top:`${-x.y/x.h*100}%`}}),t.jsx(Hs,{page:m,crop:x})]}):t.jsxs("figure",{className:"bim-rd-img-fig",children:[t.jsx("img",{src:m.url,alt:m.alt??l("reader.imageAlt",{label:f}),width:m.width,height:m.height,loading:"lazy",decoding:"async"}),t.jsx(Hs,{page:m}),s==null?void 0:s(m,u)]})}),e.length>1&&t.jsxs("div",{className:"bim-rd-img-pager",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.prevImage"),disabled:u===0,onClick:()=>h(u-1),children:"‹"}),t.jsx("span",{"aria-live":"polite",children:m.label??`${u+1} / ${e.length}`}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.nextImage"),disabled:u===e.length-1,onClick:()=>h(u+1),children:"›"})]})]})}function Zm(e){return e==="lite"||e==="full"}const Wn=[.1,.9],Hl=[{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 Jm(e){var n;return((n=Hl.find(i=>i.key===e))==null?void 0:n.stack)??null}const so={fontSize:null,readingMode:"line",properNameMode:null,writingMode:"horizontal",workLinks:!0,fontFamily:"song",pageBreaks:!0,pageIndicatorY:.33,bookTitleStyle:"wavy",showWorks:!0,quoteStyle:"original",scriptMode:null,preserveMargins:!0},Pt=[15,16,17,18,20,22,24],$r=18,Dl="bim-reader-prefs",Qm="bim-reading-mode";function eh(){const e={...so};try{const n=localStorage.getItem(Dl),i=n?JSON.parse(n):{};typeof i.fontSize=="number"&&Pt.includes(i.fontSize)&&(e.fontSize=i.fontSize),(i.readingMode??localStorage.getItem(Qm))==="paragraph"&&(e.readingMode="paragraph"),i.properNameMode==="off"||i.properNameMode==="lite"||i.properNameMode==="full"?e.properNameMode=i.properNameMode:i.properNames===!0?e.properNameMode="full":i.properNames===!1&&(e.properNameMode="off"),i.writingMode==="vertical"&&(e.writingMode="vertical"),i.workLinks===!1&&(e.workLinks=!1),(i.fontFamily==="kai"||i.fontFamily==="system")&&(e.fontFamily=i.fontFamily),i.pageBreaks===!1&&(e.pageBreaks=!1),typeof i.pageIndicatorY=="number"&&Number.isFinite(i.pageIndicatorY)&&i.pageIndicatorY>=Wn[0]&&i.pageIndicatorY<=Wn[1]&&(e.pageIndicatorY=i.pageIndicatorY),i.bookTitleStyle==="bracket"&&(e.bookTitleStyle="bracket"),i.showWorks===!1&&(e.showWorks=!1),(i.quoteStyle==="modern"||i.quoteStyle==="classic")&&(e.quoteStyle=i.quoteStyle),(i.scriptMode==="orig"||i.scriptMode==="hant"||i.scriptMode==="hans")&&(e.scriptMode=i.scriptMode),i.preserveMargins===!1&&(e.preserveMargins=!1)}catch{}return e}function th(e){try{localStorage.setItem(Dl,JSON.stringify(e))}catch{}}function si(e,n){const i=e??$r,o=Pt;let s=o.indexOf(i);return s<0&&(s=o.indexOf($r)),o[Math.max(0,Math.min(o.length-1,s+n))]}function Ul(){const[e,n]=g.useState(so);g.useEffect(()=>{n(eh())},[]);const i=g.useCallback(o=>{n(s=>{const a={...s,...o};return th(a),a})},[]);return[e,i]}function Cr(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 Vl(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 Gl(e){const n=[],i=o=>{for(const s of o)s.children&&s.children.length>0?i(s.children):n.push(s)};return i(e),n}const Ds=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:t.jsx("path",{d:"M4 6h16M4 12h10M4 18h16"})}),nh=()=>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"})}),ih=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M9 5l7 7-7 7"})}),Us=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M4 7h10M18 7h2M4 17h2M10 17h10"}),t.jsx("circle",{cx:"16",cy:"7",r:"2"}),t.jsx("circle",{cx:"8",cy:"17",r:"2"})]}),Vs=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"4",y:"3",width:"16",height:"18",rx:"1.5"}),t.jsx("path",{d:"M9 3v18M13 7v10M16.5 7v10"})]});function Gs(e,n){if(!n)return;const i=Array.from(n.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(l=>l.tabIndex>=0);if(i.length===0)return;const o=i[0],s=i[i.length-1],a=document.activeElement;e.shiftKey&&(a===o||!n.contains(a))?(e.preventDefault(),s.focus()):!e.shiftKey&&(a===s||!n.contains(a))&&(e.preventDefault(),o.focus())}function Ys(e,n){const[i,o]=g.useState(n);return g.useEffect(()=>{var l;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(e);o(s.matches);const a=()=>o(s.matches);return(l=s.addEventListener)==null||l.call(s,"change",a),()=>{var d;return(d=s.removeEventListener)==null?void 0:d.call(s,"change",a)}},[e]),i}function rh({prefs:e,onPrefsChange:n,origAvailable:i}){const o=g.useContext(It),{t:s}=te();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(g.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 ui({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 oh({prefs:e,onPrefsChange:n,origAvailable:i}){const o=g.useContext(It),{t:s}=te(),a=(o==null?void 0:o.locale)==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a;return t.jsx(ui,{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 sh(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 ah(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 Yl({title:e,subtitle:n,toc:i,activeKey:o,onSelect:s,tocHeader:a,tocCaption:l,images:d,imagesLoading:c,renderImageOverlay:p,imagePanel:h="auto",prefs:u,onPrefsChange:m,paragraphToggle:f,properNameToggle:x=!0,allowVertical:k,origScriptAvailable:y=!0,byline:$,current:b,workLinkToggle:w,rail:v,onReportError:j,revisedAt:C,backHref:S,backLabel:_,bottomBar:L=!0,pager:T=!0,contentLoading:z=!1,pagerUnit:M,versions:H,currentVersionKey:N,onVersionChange:R,versionSource:A=!0,keepChapterOnVersionChange:J=!1,customImagePanel:ee,toolbarExtra:oe,settingsAnnotate:V,settingsLayout:me,isWarpMode:G,children:q,className:ce,style:we}){const{t:O,convert:ye}=te(),de=_??O("reader.back"),ze=ye(M??O("reader.unitJuan")),Ce=g.useId().replace(/:/g,""),Oe=`bim-rd-toc-${Ce}`,ne=`bim-rd-text-${Ce}`,W=g.useRef(null),U=g.useRef(null),he=g.useRef(null),K=g.useRef(null),B=Ys(Ml,!0),Q=Ys(Bl,!1),le=L&&Q,[ie,D]=g.useState(null),[se,Te]=g.useState(!1),Me=g.useRef(null),Le=`bim-rd-set-${Ce}`,F=g.useRef(null),ae=g.useRef(null),fe=(Z,De)=>{ae.current=De,D(Qe=>Qe===Z?null:Z)},P=g.useCallback(()=>{var Z;D(null),(Z=ae.current)==null||Z.focus()},[]);g.useEffect(()=>{le||D(null)},[le]),g.useEffect(()=>{var Z,De;ie&&((De=(Z=F.current)==null?void 0:Z.querySelector("button:not([disabled])"))==null||De.focus())},[ie]);const[xe,re]=g.useState("auto"),je=xe==="auto"?B:xe==="open",Se=!B,Ve=!!ee||!!d&&d.length>0,[Ye,et]=g.useState(h);g.useEffect(()=>{et(h)},[h]);const Ze=Ye==="auto"?Ve||!!c:Ye==="open",I=g.useCallback(Z=>{var De;re("auto"),Z&&((De=K.current)==null||De.focus())},[]),Y=()=>re(je?"closed":"open");g.useEffect(()=>{if(!Se||xe!=="open")return;const Z=he.current,De=Z==null?void 0:Z.querySelector('input, [data-rd-toc-key][tabindex="0"]');De==null||De.focus()},[Se,xe]);const pe=g.useCallback(Z=>{s(Z),Se&&I(!1);const De=U.current,Qe=W.current;if(De&&Qe&&typeof window<"u"){const $t=De.getBoundingClientRect().top-Qe.getBoundingClientRect().bottom;$t<0&&window.scrollBy({top:$t})}},[s,Se,I]),ve=g.useMemo(()=>Gl(i),[i]),[Ee,ge]=g.useState(null),Ae=Vl(H,N!==void 0?N:Ee),qe=(Ae==null?void 0:Ae.key)??null,X=g.useMemo(()=>ve.map(Z=>Z.key).join(`
677
- `),[ve]),$e=g.useRef(null),Fe=Z=>{Z!==qe&&(J||($e.current={key:Z,sig:X,done:!1}),N===void 0&&ge(Z),R==null||R(Z))};g.useEffect(()=>{const Z=$e.current;if(!Z||Z.key!==qe)return;const De=ve.find($t=>!$t.disabled);if(!De)return;const Qe=X!==Z.sig;!Qe&&Z.done||(Qe?$e.current=null:Z.done=!0,De.key!==o&&pe(De.key))},[qe,X,ve,o,pe]);const We=ve.find(Z=>Z.key===o),Re=()=>{var Z;j==null||j({chapterKey:o,chapterLabel:typeof(We==null?void 0:We.label)=="string"?We.label:void 0,anchor:sh(U.current,((Z=W.current)==null?void 0:Z.getBoundingClientRect().bottom)??0),selectedText:ah(U.current)})},be=ve.findIndex(Z=>Z.key===o),Be=be>0?ve.slice(0,be).reverse().find(Z=>!Z.disabled):void 0,_e=be>=0?ve.slice(be+1).find(Z=>!Z.disabled):void 0,Je=u.fontSize??$r,He=Jm(u.fontFamily),ot={...we,...u.fontSize?{"--bimrd-fs":`${u.fontSize}px`}:null,...He?{"--bimrd-ff":He}:null},Et={song:O("reader.fontSong"),kai:O("reader.fontKai"),system:O("reader.fontSystem")},jt=x||!!V,Ge=t.jsxs("div",{className:"bim-rd-sp",children:[t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Le}-g1`,children:[t.jsx("h3",{id:`${Le}-g1`,className:"bim-rd-sp-h",children:O("reader.groupText")}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:O("reader.font")}),t.jsx("select",{className:"bim-rd-sp-sel","aria-label":O("reader.font"),value:u.fontFamily,onChange:Z=>m({fontFamily:Z.target.value}),children:Hl.map(Z=>t.jsx("option",{value:Z.key,children:Et[Z.key]},Z.key))})]}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:O("reader.fontSize")}),t.jsxs("span",{className:"bim-rd-sp-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":O("reader.fontSmaller"),disabled:Je<=Pt[0],onClick:()=>m({fontSize:si(u.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[Je,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":O("reader.fontLarger"),disabled:Je>=Pt[Pt.length-1],onClick:()=>m({fontSize:si(u.fontSize,1)}),children:"A+"})]})]}),t.jsx(oh,{prefs:u,onPrefsChange:m,origAvailable:y}),t.jsx(ui,{label:O("reader.quoteStyle"),value:u.quoteStyle,options:[{key:"modern",label:O("reader.quoteModern")},{key:"classic",label:O("reader.quoteClassic")},{key:"original",label:O("reader.quoteOriginal")}],onPick:Z=>m({quoteStyle:Z})})]}),jt&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Le}-g2`,children:[t.jsx("h3",{id:`${Le}-g2`,className:"bim-rd-sp-h",children:O("reader.groupMark")}),x&&t.jsxs(t.Fragment,{children:[t.jsx(ui,{label:O("reader.properName"),value:u.properNameMode,title:O("reader.properNameTitle"),options:[{key:"off",label:O("reader.properNameOff")},{key:"lite",label:O("reader.properNameLite"),title:O("reader.properNameLiteTitle")},{key:"full",label:O("reader.properNameFull")}],onPick:Z=>m({properNameMode:Z})}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.showWorks,onChange:Z=>m({showWorks:Z.target.checked})}),t.jsx("span",{children:O("reader.showWorks")})]}),t.jsx(ui,{label:O("reader.bookTitleStyle"),value:u.bookTitleStyle,options:[{key:"wavy",label:O("reader.bookTitleWavy")},{key:"bracket",label:O("reader.bookTitleBracket")}],onPick:Z=>m({bookTitleStyle:Z})})]}),V]}),t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Le}-g3`,children:[t.jsx("h3",{id:`${Le}-g3`,className:"bim-rd-sp-h",children:O("reader.groupLayout")}),f&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.readingMode==="paragraph",title:O("reader.paragraphTitle"),onClick:()=>m({readingMode:u.readingMode==="paragraph"?"line":"paragraph"}),children:O("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:Z=>m({workLinks:Z.target.checked})}),t.jsx("span",{children:O("reader.workLinks")})]}),k&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.writingMode==="vertical",onClick:()=>m({writingMode:u.writingMode==="vertical"?"horizontal":"vertical"}),children:O("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:Z=>m({pageBreaks:Z.target.checked})}),t.jsx("span",{children:O("reader.pageBreaks")})]}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.preserveMargins,onChange:Z=>m({preserveMargins:Z.target.checked})}),t.jsx("span",{children:O("reader.preserveMargins")})]}),me]})]});return t.jsxs("div",{className:["bim-rd",u.writingMode==="vertical"&&k?"bim-rd-vertical":"",ce].filter(Boolean).join(" "),"data-toc":xe,"data-img":Ze?"open":"closed","data-bb":le?"":void 0,"data-set":!le&&se?"open":void 0,"data-warp":G?"true":void 0,style:ot,children:[t.jsx("style",{children:Wl}),t.jsx("a",{className:"bim-rd-skip",href:`#${ne}`,onClick:Z=>{var De,Qe,$t;Z.preventDefault(),(De=U.current)==null||De.focus(),($t=(Qe=U.current)==null?void 0:Qe.scrollIntoView)==null||$t.call(Qe,{block:"start"})},children:O("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:W,children:[S&&t.jsxs("a",{className:"bim-rd-back",href:S,"aria-label":O("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)&&t.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[e&&t.jsx("b",{children:e}),$&&t.jsx("span",{className:"bim-rd-by",children:$}),b&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-rd-cur",children:b})]}),n&&t.jsx("span",{className:"bim-rd-ttl-src",children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":O("reader.settings"),children:[H&&H.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:Ae?ye(Cr(Ae)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:O("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:O("reader.versionShort")}),t.jsx("select",{"aria-label":O("reader.version"),value:qe??"",onChange:Z=>Fe(Z.target.value),children:H.map(Z=>t.jsx("option",{value:Z.key,children:ye(Cr(Z))},Z.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),T&&(Be||_e)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":O("reader.pagerGroup",{unit:ze}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":O("reader.prevUnit",{unit:ze}),title:Be?typeof Be.label=="string"&&Be.label?O("reader.prevUnitTitle",{unit:ze,label:Be.label}):O("reader.prevUnit",{unit:ze}):O("reader.firstUnit",{unit:ze}),disabled:!Be,onClick:()=>Be&&pe(Be.key),children:t.jsx(nh,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":O("reader.nextUnit",{unit:ze}),title:_e?typeof _e.label=="string"&&_e.label?O("reader.nextUnitTitle",{unit:ze,label:_e.label}):O("reader.nextUnit",{unit:ze}):O("reader.lastUnit",{unit:ze}),disabled:!_e,onClick:()=>_e&&pe(_e.key),children:t.jsx(ih,{})})]}),T&&(Be||_e)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:K,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":je,"aria-controls":Oe,onClick:Y,children:[t.jsx(Ds,{}),t.jsx("span",{className:"bim-rd-tlabel",children:O("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":Ze,onClick:()=>et(Ze?"closed":"open"),children:[t.jsx(Vs,{}),O("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(rh,{prefs:u,onPrefsChange:m,origAvailable:y}),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":O("reader.fontSmaller"),disabled:Je<=Pt[0],onClick:()=>m({fontSize:si(u.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":O("reader.fontLarger"),disabled:Je>=Pt[Pt.length-1],onClick:()=>m({fontSize:si(u.fontSize,1)}),children:"A+"}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsxs("button",{ref:Me,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":se,"aria-controls":Le,onClick:()=>Te(Z=>!Z),children:[t.jsx(Us,{}),t.jsx("span",{className:"bim-rd-tlabel",children:O("reader.settings")})]}),oe]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:Oe,ref:he,role:Se&&je?"dialog":void 0,"aria-modal":Se&&je?!0:void 0,"aria-label":Se&&je?O("reader.toc"):void 0,onKeyDown:Z=>{if(!(!Se||!je)){if(Z.key==="Escape"){Z.stopPropagation(),I(!0);return}Z.key==="Tab"&&Gs(Z,he.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:l??O("reader.toc")}),Se&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":O("reader.closeToc"),onClick:()=>I(!0),children:"✕"})]}),a]}),t.jsx(Fl,{items:i,activeKey:o,onSelect:pe})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>I(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":O("reader.images"),children:Ze&&(ee||t.jsx(_r,{pages:d??null,loading:c,renderOverlay:p,preserveMargins:u.preserveMargins}))}),!le&&se&&t.jsxs("aside",{className:"bim-rd-set",id:Le,"aria-label":O("reader.settings"),onKeyDown:Z=>{var De;Z.key==="Escape"&&(Z.stopPropagation(),Te(!1),(De=Me.current)==null||De.focus())},children:[t.jsxs("div",{className:"bim-rd-sp-top",children:[t.jsx("span",{children:O("reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":O("reader.closeSettings"),onClick:()=>{var Z;Te(!1),(Z=Me.current)==null||Z.focus()},children:"✕"})]}),Ge]}),t.jsxs("div",{className:"bim-rd-text",id:ne,ref:U,tabIndex:-1,"data-rail":(v||j)&&!G?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[q,A&&Ae&&(Ae.sourceName||Ae.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":Ae.key,children:[Ae.sourceName&&t.jsxs(t.Fragment,{children:[O("reader.sourceLabel")," ",Ae.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:Ae.sourceUrl,target:"_blank",rel:"noreferrer",children:ye(Ae.sourceName)}):ye(Ae.sourceName)]}),Ae.sourceName&&Ae.license&&t.jsx("span",{className:"bim-rd-dot"}),Ae.license&&t.jsx(t.Fragment,{children:O("reader.licenseOf",{license:Ae.license})})]}),C&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:O("reader.revisedAt",{date:C})}),j&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:Z=>Z.preventDefault(),onClick:Re,children:O("reader.reportError")})}),T&&!z&&(Be||_e)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":O("reader.pagerNav"),children:[Be?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>pe(Be.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),O("reader.prevUnit",{unit:ze})]}),t.jsx("span",{className:"bim-rd-pglabel",children:Be.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",O("reader.firstUnit",{unit:ze})]}),_e?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>pe(_e.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[O("reader.nextUnit",{unit:ze}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:_e.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[O("reader.lastUnit",{unit:ze})," →"]})]})]}),(v||j)&&!G&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":O("reader.rail"),children:[v,j&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:Z=>Z.preventDefault(),onClick:Re,children:O("reader.reportError")})})]})]})]}),le&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":O("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":je,"aria-controls":Oe,onClick:()=>{D(null),Y()},children:[t.jsx(Ds,{}),t.jsx("span",{children:O("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":ie==="img","aria-haspopup":"dialog",onClick:Z=>fe("img",Z.currentTarget),children:[t.jsx(Vs,{}),t.jsx("span",{children:O("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":ie==="set","aria-haspopup":"dialog",onClick:Z=>fe("set",Z.currentTarget),children:[t.jsx(Us,{}),t.jsx("span",{children:O("reader.settingsShort")})]}),j&&t.jsxs("button",{type:"button",onMouseDown:Z=>Z.preventDefault(),onClick:()=>{D(null),Re()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:O("reader.reportError")})]})]}),le&&ie&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:P}),t.jsxs("div",{className:"bim-rd-sheet",ref:F,role:"dialog","aria-modal":"true","aria-label":O(ie==="img"?"reader.images":"reader.settings"),onKeyDown:Z=>{if(Z.key==="Escape"){Z.stopPropagation(),P();return}Z.key==="Tab"&&Gs(Z,F.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:O(ie==="img"?"reader.images":"reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":O("reader.close"),onClick:P,children:"✕"})]}),ie==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(_r,{pages:d??null,loading:c,renderOverlay:p,preserveMargins:u.preserveMargins})}):Ge]})]})]})}function lh(e,n,i){return i?ql(e).includes("\r")?"lone-cr":Array.from(e).length!==Array.from(n).length?"convert-length":n.includes(":::")?"tables":null:"quoteStyle"}function ql(e){return e.replace(/\r\n/g,`
678
- `)}const qs=2,ch=400,dh=6,Kl=e=>e==="*"||e==="#"||e==="<"||e===">"||/\s/.test(e);function Xl(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 ph(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=Xl(e,o);if(a>=0){o=a+1;continue}if(Kl(e[o])){o++;continue}if(i[s]===" "){s++;continue}return-1}return o}function uh(e){const n=Array.from(ql(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>=dh;let l=0;for(let d=i;d<n.length&&d-i<=(a?ch:qs+64);d++){const c=Xl(n,d);if(c>=0){d=c;continue}if(!Kl(n[d])){const h=ph(n,d,s);if(h>=0)return i=h,d;if(l++,!a&&l>qs)return}}}}}const Zl=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],mh={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function st(e){return mh[e]??e}const gn=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],fn={熹平: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},Jl={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function Ii(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 hh(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 gh=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,Ks={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function ao(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(Ks))if(n.startsWith(s))return Ks[s];const i=st(n);if(en[i]!=null)return i;const o=Wt(n);if(o&&n.length<=o.length+1)return st(o)}function Qt(e,n){if(n){const i=Jl[`${n}|${e}`];if(i!=null)return i}return fn[e]}const fh=1911;function xh(e){const n=fn[e];if(n==null)return;const i=Nt[e];let o;for(const[s,a]of Object.entries(fn))Nt[s]===i&&a>n&&(o==null||a<o)&&(o=a);return o!=null?o-1:void 0}const bh={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function bi(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=bh[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 Wt(e){for(const n of Zl)if(e.startsWith(n))return n}const Nt={};{const e=(n,i)=>{for(const o of i)Nt[o]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function tn(e,n){const i=n==="北宋"||n==="南宋"?"宋":n;for(const o of Object.keys(fn))if(e.includes(o)&&!(i&&Nt[o]&&Nt[o]!==i&&Jl[`${i}|${o}`]==null))return o}function Fn(e){var l,d,c;const n={era:"",reign:"",source:"none"},i=e.dating;if(i!=null&&i.era||i!=null&&i.reign)return{era:i.era??"",reign:i.reign??"",source:i.certainty==="attested"?"catalog":"edition"};const o=(l=e.lineage)==null?void 0:l.year_text;if(o){const p=Wt(o)??"";return{era:st(p),reign:tn(o,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=Ii(s);if(p)return{era:hh(p.from),reign:"",source:"publication"};const h=Wt(s)??ao(s)??((c=gn.find(f=>f.pattern.test(s)))==null?void 0:c.era)??"",u=tn(s,h)??"",m=h||(u?Nt[u]??"":"");if(m||u)return{era:st(m),reign:u,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=Wt(a);if(p)return{era:st(p),reign:tn(a,p)??"",source:"edition"};const h=gn.find(u=>u.pattern.test(a));if(h)return{era:st(h.era),reign:tn(a,h.era)??h.reign??"",source:"edition"}}return n}function Ei(e){var o,s,a,l,d,c,p,h,u;if(((o=e.dating)==null?void 0:o.year)!=null)return e.dating.year;if(typeof((s=e.lineage)==null?void 0:s.year)=="number")return e.lineage.year;const n=(a=e.publication_info)==null?void 0:a.year;if(n){const m=Ii(n);if(m)return m.from}const i=[(l=e.lineage)==null?void 0:l.year_text,(d=e.publication_info)==null?void 0:d.year,e.edition,e.edition?void 0:e.title].filter(Boolean);for(const m of i){const f=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(f&&m!==f&&(Wt(f)||ao(f)))break;const x=m.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??m.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(x){const w=parseInt(x[1],10);if(w>=100&&w<=2100)return w}const k=m.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(k){const w=Wt(m);if(!w||st(w)==="民國"){const j=bi(k[1]);if(j!=null&&j>=1&&j<=120)return fh+j}}const y=Wt(m)??((h=gn.find(w=>w.pattern.test(m)))==null?void 0:h.era),$=y?st(y):void 0,b=tn(m,$)??(Wt(m)||(u=gn.find(w=>w.pattern.test(m)))==null?void 0:u.reign);if(b){const w=Qt(b,$);if(w==null)continue;const v=m.indexOf(b),j=v>=0?m.slice(v+b.length):"",C=j.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??j.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),S=C?bi(C[1]):void 0;return w+(S?S-1:0)}}}function lo(e){var l,d,c,p,h,u;const n=(l=e.dating)==null?void 0:l.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const i=(d=e.lineage)==null?void 0:d.year_range;if(i&&i.length===2)return{from:i[0],to:i[1]};const o=(c=e.lineage)==null?void 0:c.year_text;if(o){const m=o.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(m){const f=zr[st(m[1])],x=en[st(m[2])];if(f!=null&&x!=null)return{from:Math.min(f,x)-20,to:Math.max(f,x)+40}}}const s=(p=e.publication_info)==null?void 0:p.year;if(s){const m=Ii(s);if((m==null?void 0:m.to)!=null)return{from:m.from,to:m.to};const f=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(f){const x=zr[st(f[1])],k=en[st(f[2])];if(x!=null&&k!=null)return{from:Math.min(x,k)-20,to:Math.max(x,k)+40}}}const a=[(h=e.publication_info)==null?void 0:h.year,e.edition,e.title].filter(Boolean);for(const m of a){if(!/[間间]/.test(m))continue;const f=Wt(m)??ao(m)??((u=gn.find(y=>y.pattern.test(m)))==null?void 0:u.era),x=f?st(f):void 0,k=[];for(const y of Object.keys(fn))m.includes(y)&&(x&&Nt[y]&&Nt[y]!==x||Qt(y,x)!=null&&k.push(y));if(k.length===0){const y=m.match(/([一-鿿])([一-鿿])[間间]/);if(y&&x){for(const $ of[y[1],y[2]])for(const b of Object.keys(fn))if(Nt[b]===x&&!(b[0]!==$&&b[b.length-1]!==$)&&Qt(b,x)!=null){k.push(b);break}}}if(k.length>0){const y=k.map(v=>Qt(v,x)).filter(v=>v!=null),$=Math.min(...y),b=k.reduce((v,j)=>Qt(v,x)>=Qt(j,x)?v:j),w=xh(b)??dr(x??"")??Math.max(...y);return{from:$,to:w>$?w:dr(x??Nt[b]??"")??$}}if(x&&en[x]!=null)return{from:en[x],to:dr(x)??en[x]}}}const en={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},yh=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],jh=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,Xs=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function Zs(e,n){for(const i of Zl){const o=e.indexOf(i);if(o<0)continue;if(i.length===1){const c=e[o+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!tn(e.slice(o),st(i)))continue}const s=st(i);if(s===n)continue;const a=e.slice(o),l=tn(a,s)??"";let d;if(l){const c=Qt(l,s);if(c!=null){const h=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),u=h?bi(h[1]):void 0;d=c+(u?u-1:0)}}return{era:s,reign:l,year:d}}for(const i of gn)if(i.pattern.test(e))return{era:st(i.era),reign:i.reign??""}}function vh(e){var $,b,w,v,j;const n=Fn(e),i=(($=e.publication_info)==null?void 0:$.year)??"",o=i?Ii(i):void 0;if(!n.era&&!n.reign&&!o)return;const s=e.edition||e.title||"",a=/[間间]/.test(s),l=((b=e.lineage)==null?void 0:b.year_text)??"",d=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(l),c=n.source==="publication"&&gh.test(i),p=n.source==="publication"&&/[間间]/.test(i),h=l.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let u;a||d||c||p?u=void 0:h?u=parseInt(h[2],10):u=Ei(e);const m=u==null?lo(e):void 0;let f;n.source==="publication"&&(c||Xs.test(i))?f="uncertain":n.source==="lineage"||n.source==="publication"?f="attested":Xs.test(s)||!n.reign&&u==null?f="uncertain":f="inferred";const x=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((w=e.lineage)==null?void 0:w.year_text)??((v=e.lineage)==null?void 0:v.year)??""}」`:`出版著錄「${((j=e.publication_info)==null?void 0:j.year)??""}」`,k={era:n.era,reign:n.reign,year:u,yearRange:m,certainty:f,source:n.source==="edition"?"edition":"catalog",basis:x};if(h){const C=l.match(/[、,,]\s*([宋元明清])/);C&&C[1]!==k.era&&(k.laterRepair={era:C[1]})}if(!k.laterRepair&&jh.test(s)){const C=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);C&&C[1]!==n.era&&(k.laterRepair={era:C[1]})}const y=yh.find(C=>C.re.test(s));if(y){const C=s.search(y.re),S=s.slice(C),_=Zs(S,n.era)??Zs(s,n.era);_&&(k.basedOn={era:_.era,reign:_.reign,year:_.year,relation:y.relation})}return k}const zr={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function dr(e){return zr[e]}function yi(e){const n=Ei(e);if(n!=null)return n;const i=lo(e);if(i)return i.from;const o=Fn(e).era;return o?en[o]:void 0}const Js=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function Tr(e){const n=Js.indexOf(e);return n===-1?Js.length:n}function kh(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 co(e,n){const i=Kr(e||[]),o=new Map,s=[];for(const p of i)p.group?(o.has(p.group)||o.set(p.group,[]),o.get(p.group).push(p)):s.push(p);for(const p of o.values())p.sort((h,u)=>{const m=f=>f.group_role==="origin"?0:f.group_role==="mirror"?1:2;return m(h)-m(u)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const h=Ot(p),u=h.includes("text"),m=h.includes("image");u&&m?a.textImage.push(p):u?a.text.push(p):m?a.image.push(p):a.physical.push(p)}const d=["text","image","textImage","physical"].filter(p=>a[p].length>0).map(p=>({key:p,items:a[p]})),c=[...o.entries()].map(([p,h])=>{var u,m;return{key:p,label:((u=n==null?void 0:n[p])==null?void 0:u.label)||p,description:(m=n==null?void 0:n[p])==null?void 0:m.description,items:h}});return{buckets:d,mirrors:c,total:i.length}}function Ri(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=Si(e);return s&&s.expected>0&&i.push(s.missing>0?n("detail.volumeStatsMissing",{found:s.found,expected:s.expected,missing:s.missing}):n("detail.volumeStats",{found:s.found,expected:s.expected})),o.version&&i.push(String(o.version)),i.join(" · ")}function Ql(e,n){if(Ri(e)||n.filter(o=>o.name===e.name).length<2)return"";try{const o=new URL(e.url),s=o.searchParams.get("res")||o.searchParams.get("id");if(s)return s;const a=o.pathname.split("/").filter(Boolean).pop();if(a)return decodeURIComponent(a)}catch{}return""}function ec(e,n){var a,l;const i=e.resources||[],o=[],s=[];for(const d of i){const c=Ot(d);c.includes("image")&&o.push(d),c.includes("physical")&&s.push(d)}return{id:e.id,name:e.edition||e.title||e.id,era:Fn(e),year:Ei(e),sortYear:yi(e),images:o,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,important:wh(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:o.length>0}}function wh(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 tc(e,n,i={}){const o=new Set((n==null?void 0:n.excluded_books)??[]),s=e.filter(c=>!o.has(c.id)).map(c=>ec(c,n));let a=s;i.era&&(a=a.filter(c=>c.era.era===i.era)),i.scanOnly&&(a=a.filter(c=>c.hasImage)),i.sort==="year"?a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const h=c.r.sortYear,u=p.r.sortYear;return h!=null&&u!=null?h-u||c.i-p.i:h!=null?-1:u!=null?1:c.i-p.i}).map(c=>c.r):a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const h=u=>(u.important?0:1)*2+(u.hasImage?0:1);return h(c.r)-h(p.r)||c.i-p.i}).map(c=>c.r);const d=[...new Set(s.map(c=>c.era.era).filter(Boolean))].sort((c,p)=>Tr(c)-Tr(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function Sh(e,n){var y,$;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const i=(y=n.collections)==null?void 0:y[n.default_collection],o=(i==null?void 0:i.groups)??[],s=(i==null?void 0:i.book_ids)??[],a=o.length>0||s.length>0,l=!a&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!a&&l.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const d=new Set(o),c=new Set([...s,...l]),p=b=>{if(c.has(b))return!0;const w=n.node_groups[b];return w!=null&&d.has(w)},h=[],u=new Map,m=[];for(const b of e)if(!(($=n.excluded_books)!=null&&$.includes(b)))if(p(b))h.push(b);else{const w=n.node_groups[b];w?(u.has(w)||u.set(w,[]),u.get(w).push(b)):m.push(b)}if(m.length+[...u.values()].reduce((b,w)=>b+w.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const x=new Map((n.groups??[]).map(b=>[b.id,b])),k=[...u.entries()].map(([b,w])=>{const v=x.get(b);return{id:b,label:(v==null?void 0:v.label)??b,description:v==null?void 0:v.description,ids:w}});return m.length>0&&k.push({id:"__other__",label:"其他版本",description:void 0,ids:m}),{useGrouping:!0,coreIds:h,groupedIds:k}}const nc=["撰","編","注","校","譯","繪","其他"],_h=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function po(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n)return"撰";for(const{cls:i,re:o}of _h)if(o.test(n))return i;return"其他"}function uo(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function ic(e,n="全部"){const i=new Map;for(const s of e){const a=po(s);i.set(a,(i.get(a)??0)+1)}const o=[{cls:"全部",label:n,count:e.length}];for(const s of nc){const a=i.get(s);a&&o.push({cls:s,label:s,count:a})}return o.length>2?o:[]}function mo(e){return(e._books??[]).map(n=>n.id).filter(n=>typeof n=="string")}function ho(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 rc(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:Mn(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 $h(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 oc(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}=rc(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 Mn(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 Li(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 Ch=["〇","一","二","三","四","五","六","七","八","九"],Qs=["","十","百","千"];function sc(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),i=n.length;let o="",s=!1;for(let a=0;a<i;a++){const l=parseInt(n[a]),d=i-1-a;l===0?s=!0:(s&&o&&(o+="〇"),s=!1,l===1&&d===1&&a===0?o+=Qs[d]:o+=Ch[l]+Qs[d])}return o}function zh(e){return e==null?"":typeof e=="string"?e:"name"in e&&e.name?e.name:"title"in e&&e.title||""}function Th(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 Ht(e,n="卷"){var o,s;const i=e;return i.measure_info?i.measure_info:(o=i.juan_count)!=null&&o.number?sc(i.juan_count.number)+n:(s=i.juan_count)!=null&&s.description?i.juan_count.description:""}function ac(e){var o;if(e.edition_type)return e.edition_type;if((o=e.lineage)!=null&&o.category)return e.lineage.category;const n=e.edition||e.title||"",i=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/油印/,"油印本"],[/曬印|晒印/,"曬印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,a]of i)if(s.test(n))return a;return""}const Nh=65536,Ih="guji_markdown";function Eh(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 Rh=/^□\{guess=([^\s{}]+)\}/;function Lh(e,n){const i=e[n+1];return i!==void 0&&!/[A-Za-z/!?>\s]/.test(i)}function lc(e,n){let i=0;for(let o=n;o<e.length;o++){const s=e[o];if(s===`
679
- `)return-1;if(s==="\\"){o++;continue}if(s==="[")i++;else if(s==="]"&&(i--,i===0))return o}return-1}function Ah(e){return e.replace(/\\([\\[\]<>|{}])/g,"$1")}function Mh(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(`
680
- `)<0?{node:{type:"qw",label:e.slice(n+2,o)},end:o+2}:null}if(i===":"&&e.startsWith(":zi[",n)){const o=lc(e,n+3);return o>n+4?{node:{type:"zi",label:Ah(e.slice(n+4,o))},end:o+1}:null}if(i==="□"&&e[n+1]==="{"){const o=Rh.exec(e.slice(n,n+64));if(o)return{node:{type:"qz",guess:o[1]},end:n+o[0].length}}return null}function cc(e,n,i,o,s){const a=[];let l="",d=!1;const c=()=>{if(!l)return;let p=l;o&&(p=l.replace(/\\?\|/g,h=>d?"|":(d=!0,""))),p&&a.push({type:"text",text:p}),l=""};for(;n<e.length;){const p=e[n];if(p==="\\"&&(e[n+1]==="<"||e[n+1]===">")){l+=e[n+1],n+=2;continue}if(i!==null){if(p===i)return c(),{nodes:a,end:n};if(p===`
681
- `)return null}const h=Mh(e,n);if(h){c(),a.push(h.node),n=h.end;continue}let u=null;if(p==="<"&&Lh(e,n)&&(u=">"),u){const m=cc(e,n+1,u,!0,s);if(m&&!(m.end-(n+1)>s)){c(),a.push({type:"jz",children:m.nodes}),n=m.end+1;continue}}l+=p,n++}return i!==null?null:(c(),{nodes:a,end:n})}function dc(e,n){return cc(e,0,null,!1,(n==null?void 0:n.jzMaxLength)??Nh).nodes}function Ph(e){return/[<□]|\[\[|:zi\[/.test(e)}function pc(e){return e.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${pc(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const Bh=216,ea="clamp(280px, 23vw, 360px)",Wh=1440,Nr="(max-width: 719px)",Oh=`${Nr}, (pointer: coarse)`,Fh=`
682
- .bim-d-main.bim-d-main-grid { max-width: ${Wh}px; padding: 16px 32px 0; }
676
+ `;function so(e,n){var i;return n?e.key===n?!0:!!((i=e.children)!=null&&i.some(o=>so(o,n))):!1}const qm=()=>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 Km({item:e,activeKey:n,onSelect:i,tabKey:o}){const s=so(e,n),[a,l]=g.useState(s||!!e.defaultExpanded);return g.useEffect(()=>{s&&l(!0)},[s]),g.useEffect(()=>{e.defaultExpanded&&l(!0)},[e.defaultExpanded]),t.jsxs("li",{children:[t.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":a,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>l(d=>!d),children:[t.jsx(qm,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),a&&t.jsx(Wl,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]})}function Wl({items:e,activeKey:n,onSelect:i,tabKey:o}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(Km,{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 Hs(e,n){var i;for(const o of e)if(o.key===n||so(o,n))return o.key;return((i=e[0])==null?void 0:i.key)??null}function Fl({items:e,activeKey:n,onSelect:i,label:o}){const{t:s}=ne(),a=o??s("reader.toc"),l=g.useRef(null),[d,c]=g.useState(null);g.useEffect(()=>{c(null)},[n]);const p=g.useMemo(()=>d||(n??Hs(e,n)),[d,n,e]);g.useEffect(()=>{const u=l.current;if(!u)return;const m=Array.from(u.querySelectorAll("[data-rd-toc-key]"));if(m.length===0)return;const f=m.find(x=>x.dataset.rdTocKey===p)??m.find(x=>x.dataset.rdTocKey===Hs(e,n))??m.find(x=>!x.disabled)??m[0];for(const x of m)x.tabIndex=x===f?0:-1}),g.useEffect(()=>{const u=l.current,m=u==null?void 0:u.closest(".bim-rd-toc");if(!u||!m||!n)return;const f=Array.from(u.querySelectorAll("[data-rd-toc-key]")).find(k=>k.dataset.rdTocKey===n);if(!f)return;const x=f.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop;(x<m.scrollTop+80||x>m.scrollTop+m.clientHeight-40)&&(m.scrollTop=Math.max(0,x-m.clientHeight/3))},[n]);const h=g.useCallback(u=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(u.key))return;const f=l.current;if(!f)return;const x=Array.from(f.querySelectorAll("[data-rd-toc-key]")).filter(b=>!b.disabled),k=x.indexOf(document.activeElement);let y=k;if(u.key==="ArrowDown"?y=Math.min(x.length-1,k+1):u.key==="ArrowUp"?y=Math.max(0,k-1):u.key==="Home"?y=0:u.key==="End"&&(y=x.length-1),y<0||y===k)return;u.preventDefault();const $=x[y];for(const b of x)b.tabIndex=-1;$.tabIndex=0,$.focus(),c($.dataset.rdTocKey??null)},[]);return t.jsx("div",{ref:l,role:"navigation","aria-label":a,onKeyDown:h,children:t.jsx(Wl,{items:e,activeKey:n,onSelect:i,tabKey:p})})}function Ds({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 Xm(e){const{boxes:n,width:i,height:o}=e;if(!(n!=null&&n.length)||!i||!o||e.boxFormat&&e.boxFormat!=="bim-charbox-v0")return null;let s=1/0,a=1/0,l=-1/0,d=-1/0;for(const f of n)[f.x,f.y,f.w,f.h].every(Number.isFinite)&&(s=Math.min(s,f.x),a=Math.min(a,f.y),l=Math.max(l,f.x+f.w),d=Math.max(d,f.y+f.h));if(!(l>s)||!(d>a))return null;const c=Math.min(i,o)*.03,p=Math.min(i,Math.max(0,s-c)),h=Math.min(o,Math.max(0,a-c)),u=Math.min(i,Math.max(0,l+c))-p,m=Math.min(o,Math.max(0,d+c))-h;return!(u>0)||!(m>0)||u>=i*.98&&m>=o*.98?null:{x:p,y:h,w:u,h:m}}function _r({pages:e,loading:n,page:i,onPageChange:o,renderOverlay:s,preserveMargins:a=!0}){const{t:l}=ne(),[d,c]=g.useState(0),p=i??d,h=k=>{o?o(k):c(k)};if(g.useEffect(()=>{i===void 0&&c(0)},[e,i]),n)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsx("div",{className:"bim-rd-img-empty",children:l("reader.imagesLoading")})});if(!e||e.length===0)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsxs("div",{className:"bim-rd-img-empty",children:[t.jsx("div",{className:"bim-rd-img-frame","aria-hidden":"true"}),t.jsx("b",{children:l("reader.noImages")}),t.jsx("span",{children:l("reader.noImagesHint")})]})});const u=Math.max(0,Math.min(e.length-1,p)),m=e[u],f=m.label??`${u+1}`,x=!a&&!s?Xm(m):null;return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-img-box",children:x?t.jsxs("figure",{className:"bim-rd-img-fig bim-rd-img-trimmed","data-trim":`${Math.round(x.x)},${Math.round(x.y)},${Math.round(x.w)},${Math.round(x.h)}`,style:{aspectRatio:`${x.w} / ${x.h}`,overflow:"hidden",width:"100%",maxWidth:`calc((100vh - 200px) * ${x.w/x.h})`},children:[t.jsx("img",{src:m.url,alt:m.alt??l("reader.imageAlt",{label:f}),decoding:"async",style:{position:"absolute",maxWidth:"none",maxHeight:"none",width:`${m.width/x.w*100}%`,left:`${-x.x/x.w*100}%`,top:`${-x.y/x.h*100}%`}}),t.jsx(Ds,{page:m,crop:x})]}):t.jsxs("figure",{className:"bim-rd-img-fig",children:[t.jsx("img",{src:m.url,alt:m.alt??l("reader.imageAlt",{label:f}),width:m.width,height:m.height,loading:"lazy",decoding:"async"}),t.jsx(Ds,{page:m}),s==null?void 0:s(m,u)]})}),e.length>1&&t.jsxs("div",{className:"bim-rd-img-pager",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.prevImage"),disabled:u===0,onClick:()=>h(u-1),children:"‹"}),t.jsx("span",{"aria-live":"polite",children:m.label??`${u+1} / ${e.length}`}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.nextImage"),disabled:u===e.length-1,onClick:()=>h(u+1),children:"›"})]})]})}function Zm(e){return e==="lite"||e==="full"}const On=[.1,.9],Hl=[{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 Jm(e){var n;return((n=Hl.find(i=>i.key===e))==null?void 0:n.stack)??null}const ao={fontSize:null,readingMode:"line",properNameMode:null,writingMode:"horizontal",workLinks:!0,fontFamily:"song",pageBreaks:!0,pageIndicatorY:.33,bookTitleStyle:"wavy",showWorks:!0,quoteStyle:"original",scriptMode:null,preserveMargins:!0},Pt=[15,16,17,18,20,22,24],$r=18,Dl="bim-reader-prefs",Qm="bim-reading-mode";function eh(){const e={...ao};try{const n=localStorage.getItem(Dl),i=n?JSON.parse(n):{};typeof i.fontSize=="number"&&Pt.includes(i.fontSize)&&(e.fontSize=i.fontSize),(i.readingMode??localStorage.getItem(Qm))==="paragraph"&&(e.readingMode="paragraph"),i.properNameMode==="off"||i.properNameMode==="lite"||i.properNameMode==="full"?e.properNameMode=i.properNameMode:i.properNames===!0?e.properNameMode="full":i.properNames===!1&&(e.properNameMode="off"),i.writingMode==="vertical"&&(e.writingMode="vertical"),i.workLinks===!1&&(e.workLinks=!1),(i.fontFamily==="kai"||i.fontFamily==="system")&&(e.fontFamily=i.fontFamily),i.pageBreaks===!1&&(e.pageBreaks=!1),typeof i.pageIndicatorY=="number"&&Number.isFinite(i.pageIndicatorY)&&i.pageIndicatorY>=On[0]&&i.pageIndicatorY<=On[1]&&(e.pageIndicatorY=i.pageIndicatorY),i.bookTitleStyle==="bracket"&&(e.bookTitleStyle="bracket"),i.showWorks===!1&&(e.showWorks=!1),(i.quoteStyle==="modern"||i.quoteStyle==="classic")&&(e.quoteStyle=i.quoteStyle),(i.scriptMode==="orig"||i.scriptMode==="hant"||i.scriptMode==="hans")&&(e.scriptMode=i.scriptMode),i.preserveMargins===!1&&(e.preserveMargins=!1)}catch{}return e}function th(e){try{localStorage.setItem(Dl,JSON.stringify(e))}catch{}}function si(e,n){const i=e??$r,o=Pt;let s=o.indexOf(i);return s<0&&(s=o.indexOf($r)),o[Math.max(0,Math.min(o.length-1,s+n))]}function Ul(){const[e,n]=g.useState(ao);g.useEffect(()=>{n(eh())},[]);const i=g.useCallback(o=>{n(s=>{const a={...s,...o};return th(a),a})},[]);return[e,i]}function Cr(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 Vl(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 Gl(e){const n=[],i=o=>{for(const s of o)s.children&&s.children.length>0?i(s.children):n.push(s)};return i(e),n}const Us=()=>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"})}),nh=()=>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"})}),ih=()=>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"})}),Vs=()=>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"})]}),Gs=()=>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 Ys(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 qs(e,n){const[i,o]=g.useState(n);return g.useEffect(()=>{var l;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(e);o(s.matches);const a=()=>o(s.matches);return(l=s.addEventListener)==null||l.call(s,"change",a),()=>{var d;return(d=s.removeEventListener)==null?void 0:d.call(s,"change",a)}},[e]),i}function rh({prefs:e,onPrefsChange:n,origAvailable:i}){const o=g.useContext(It),{t:s}=ne();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(g.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 ui({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 oh({prefs:e,onPrefsChange:n,origAvailable:i}){const o=g.useContext(It),{t:s}=ne(),a=(o==null?void 0:o.locale)==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a;return t.jsx(ui,{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 sh(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 ah(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 Yl({title:e,subtitle:n,toc:i,activeKey:o,onSelect:s,tocHeader:a,tocCaption:l,images:d,imagesLoading:c,renderImageOverlay:p,imagePanel:h="auto",prefs:u,onPrefsChange:m,paragraphToggle:f,properNameToggle:x=!0,allowVertical:k,origScriptAvailable:y=!0,byline:$,current:b,workLinkToggle:w,rail:v,onReportError:j,revisedAt:C,backHref:S,backLabel:_,bottomBar:A=!0,pager:T=!0,contentLoading:z=!1,pagerUnit:M,versions:H,currentVersionKey:I,onVersionChange:R,versionSource:P=!0,keepChapterOnVersionChange:K=!1,customImagePanel:te,toolbarExtra:ie,settingsAnnotate:U,settingsLayout:pe,isWarpMode:G,children:ee,className:ae,style:Se}){const{t:O,convert:je}=ne(),de=_??O("reader.back"),we=je(M??O("reader.unitJuan")),Te=g.useId().replace(/:/g,""),Fe=`bim-rd-toc-${Te}`,re=`bim-rd-text-${Te}`,B=g.useRef(null),V=g.useRef(null),he=g.useRef(null),X=g.useRef(null),ge=qs(Ml,!0),W=qs(Bl,!1),le=A&&W,[q,D]=g.useState(null),[Q,Ce]=g.useState(!1),Le=g.useRef(null),Ae=`bim-rd-set-${Te}`,F=g.useRef(null),se=g.useRef(null),ve=(J,De)=>{se.current=De,D(Qe=>Qe===J?null:J)},L=g.useCallback(()=>{var J;D(null),(J=se.current)==null||J.focus()},[]);g.useEffect(()=>{le||D(null)},[le]),g.useEffect(()=>{var J,De;q&&((De=(J=F.current)==null?void 0:J.querySelector("button:not([disabled])"))==null||De.focus())},[q]);const[me,oe]=g.useState("auto"),be=me==="auto"?ge:me==="open",_e=!ge,Ve=!!te||!!d&&d.length>0,[Ye,tt]=g.useState(h);g.useEffect(()=>{tt(h)},[h]);const Ze=Ye==="auto"?Ve||!!c:Ye==="open",N=g.useCallback(J=>{var De;oe("auto"),J&&((De=X.current)==null||De.focus())},[]),Y=()=>oe(be?"closed":"open");g.useEffect(()=>{if(!_e||me!=="open")return;const J=he.current,De=J==null?void 0:J.querySelector('input, [data-rd-toc-key][tabindex="0"]');De==null||De.focus()},[_e,me]);const ce=g.useCallback(J=>{s(J),_e&&N(!1);const De=V.current,Qe=B.current;if(De&&Qe&&typeof window<"u"){const $t=De.getBoundingClientRect().top-Qe.getBoundingClientRect().bottom;$t<0&&window.scrollBy({top:$t})}},[s,_e,N]),ye=g.useMemo(()=>Gl(i),[i]),[Ee,fe]=g.useState(null),Me=Vl(H,I!==void 0?I:Ee),qe=(Me==null?void 0:Me.key)??null,Z=g.useMemo(()=>ye.map(J=>J.key).join(`
677
+ `),[ye]),ze=g.useRef(null),We=J=>{J!==qe&&(K||(ze.current={key:J,sig:Z,done:!1}),I===void 0&&fe(J),R==null||R(J))};g.useEffect(()=>{const J=ze.current;if(!J||J.key!==qe)return;const De=ye.find($t=>!$t.disabled);if(!De)return;const Qe=Z!==J.sig;!Qe&&J.done||(Qe?ze.current=null:J.done=!0,De.key!==o&&ce(De.key))},[qe,Z,ye,o,ce]);const Oe=ye.find(J=>J.key===o),Re=()=>{var J;j==null||j({chapterKey:o,chapterLabel:typeof(Oe==null?void 0:Oe.label)=="string"?Oe.label:void 0,anchor:sh(V.current,((J=B.current)==null?void 0:J.getBoundingClientRect().bottom)??0),selectedText:ah(V.current)})},xe=ye.findIndex(J=>J.key===o),Be=xe>0?ye.slice(0,xe).reverse().find(J=>!J.disabled):void 0,$e=xe>=0?ye.slice(xe+1).find(J=>!J.disabled):void 0,Je=u.fontSize??$r,He=Jm(u.fontFamily),ot={...Se,...u.fontSize?{"--bimrd-fs":`${u.fontSize}px`}:null,...He?{"--bimrd-ff":He}:null},Et={song:O("reader.fontSong"),kai:O("reader.fontKai"),system:O("reader.fontSystem")},jt=x||!!U,Ge=t.jsxs("div",{className:"bim-rd-sp",children:[t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Ae}-g1`,children:[t.jsx("h3",{id:`${Ae}-g1`,className:"bim-rd-sp-h",children:O("reader.groupText")}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:O("reader.font")}),t.jsx("select",{className:"bim-rd-sp-sel","aria-label":O("reader.font"),value:u.fontFamily,onChange:J=>m({fontFamily:J.target.value}),children:Hl.map(J=>t.jsx("option",{value:J.key,children:Et[J.key]},J.key))})]}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:O("reader.fontSize")}),t.jsxs("span",{className:"bim-rd-sp-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":O("reader.fontSmaller"),disabled:Je<=Pt[0],onClick:()=>m({fontSize:si(u.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[Je,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":O("reader.fontLarger"),disabled:Je>=Pt[Pt.length-1],onClick:()=>m({fontSize:si(u.fontSize,1)}),children:"A+"})]})]}),t.jsx(oh,{prefs:u,onPrefsChange:m,origAvailable:y}),t.jsx(ui,{label:O("reader.quoteStyle"),value:u.quoteStyle,options:[{key:"modern",label:O("reader.quoteModern")},{key:"classic",label:O("reader.quoteClassic")},{key:"original",label:O("reader.quoteOriginal")}],onPick:J=>m({quoteStyle:J})})]}),jt&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Ae}-g2`,children:[t.jsx("h3",{id:`${Ae}-g2`,className:"bim-rd-sp-h",children:O("reader.groupMark")}),x&&t.jsxs(t.Fragment,{children:[t.jsx(ui,{label:O("reader.properName"),value:u.properNameMode,title:O("reader.properNameTitle"),options:[{key:"off",label:O("reader.properNameOff")},{key:"lite",label:O("reader.properNameLite"),title:O("reader.properNameLiteTitle")},{key:"full",label:O("reader.properNameFull")}],onPick:J=>m({properNameMode:J})}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.showWorks,onChange:J=>m({showWorks:J.target.checked})}),t.jsx("span",{children:O("reader.showWorks")})]}),t.jsx(ui,{label:O("reader.bookTitleStyle"),value:u.bookTitleStyle,options:[{key:"wavy",label:O("reader.bookTitleWavy")},{key:"bracket",label:O("reader.bookTitleBracket")}],onPick:J=>m({bookTitleStyle:J})})]}),U]}),t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Ae}-g3`,children:[t.jsx("h3",{id:`${Ae}-g3`,className:"bim-rd-sp-h",children:O("reader.groupLayout")}),f&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.readingMode==="paragraph",title:O("reader.paragraphTitle"),onClick:()=>m({readingMode:u.readingMode==="paragraph"?"line":"paragraph"}),children:O("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:J=>m({workLinks:J.target.checked})}),t.jsx("span",{children:O("reader.workLinks")})]}),k&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.writingMode==="vertical",onClick:()=>m({writingMode:u.writingMode==="vertical"?"horizontal":"vertical"}),children:O("reader.vertical")}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.pageBreaks,onChange:J=>m({pageBreaks:J.target.checked})}),t.jsx("span",{children:O("reader.pageBreaks")})]}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.preserveMargins,onChange:J=>m({preserveMargins:J.target.checked})}),t.jsx("span",{children:O("reader.preserveMargins")})]}),pe]})]});return t.jsxs("div",{className:["bim-rd",u.writingMode==="vertical"&&k?"bim-rd-vertical":"",ae].filter(Boolean).join(" "),"data-toc":me,"data-img":Ze?"open":"closed","data-bb":le?"":void 0,"data-set":!le&&Q?"open":void 0,"data-warp":G?"true":void 0,style:ot,children:[t.jsx("style",{children:Ol}),t.jsx("a",{className:"bim-rd-skip",href:`#${re}`,onClick:J=>{var De,Qe,$t;J.preventDefault(),(De=V.current)==null||De.focus(),($t=(Qe=V.current)==null?void 0:Qe.scrollIntoView)==null||$t.call(Qe,{block:"start"})},children:O("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:B,children:[S&&t.jsxs("a",{className:"bim-rd-back",href:S,"aria-label":O("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)&&t.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[e&&t.jsx("b",{children:e}),$&&t.jsx("span",{className:"bim-rd-by",children:$}),b&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-rd-cur",children:b})]}),n&&t.jsx("span",{className:"bim-rd-ttl-src",children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":O("reader.settings"),children:[H&&H.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:Me?je(Cr(Me)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:O("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:O("reader.versionShort")}),t.jsx("select",{"aria-label":O("reader.version"),value:qe??"",onChange:J=>We(J.target.value),children:H.map(J=>t.jsx("option",{value:J.key,children:je(Cr(J))},J.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),T&&(Be||$e)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":O("reader.pagerGroup",{unit:we}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":O("reader.prevUnit",{unit:we}),title:Be?typeof Be.label=="string"&&Be.label?O("reader.prevUnitTitle",{unit:we,label:Be.label}):O("reader.prevUnit",{unit:we}):O("reader.firstUnit",{unit:we}),disabled:!Be,onClick:()=>Be&&ce(Be.key),children:t.jsx(nh,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":O("reader.nextUnit",{unit:we}),title:$e?typeof $e.label=="string"&&$e.label?O("reader.nextUnitTitle",{unit:we,label:$e.label}):O("reader.nextUnit",{unit:we}):O("reader.lastUnit",{unit:we}),disabled:!$e,onClick:()=>$e&&ce($e.key),children:t.jsx(ih,{})})]}),T&&(Be||$e)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:X,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":be,"aria-controls":Fe,onClick:Y,children:[t.jsx(Us,{}),t.jsx("span",{className:"bim-rd-tlabel",children:O("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":Ze,onClick:()=>tt(Ze?"closed":"open"),children:[t.jsx(Gs,{}),O("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(rh,{prefs:u,onPrefsChange:m,origAvailable:y}),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":O("reader.fontSmaller"),disabled:Je<=Pt[0],onClick:()=>m({fontSize:si(u.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":O("reader.fontLarger"),disabled:Je>=Pt[Pt.length-1],onClick:()=>m({fontSize:si(u.fontSize,1)}),children:"A+"}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsxs("button",{ref:Le,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":Q,"aria-controls":Ae,onClick:()=>Ce(J=>!J),children:[t.jsx(Vs,{}),t.jsx("span",{className:"bim-rd-tlabel",children:O("reader.settings")})]}),ie]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:Fe,ref:he,role:_e&&be?"dialog":void 0,"aria-modal":_e&&be?!0:void 0,"aria-label":_e&&be?O("reader.toc"):void 0,onKeyDown:J=>{if(!(!_e||!be)){if(J.key==="Escape"){J.stopPropagation(),N(!0);return}J.key==="Tab"&&Ys(J,he.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:l??O("reader.toc")}),_e&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":O("reader.closeToc"),onClick:()=>N(!0),children:"✕"})]}),a]}),t.jsx(Fl,{items:i,activeKey:o,onSelect:ce})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>N(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":O("reader.images"),children:Ze&&(te||t.jsx(_r,{pages:d??null,loading:c,renderOverlay:p,preserveMargins:u.preserveMargins}))}),!le&&Q&&t.jsxs("aside",{className:"bim-rd-set",id:Ae,"aria-label":O("reader.settings"),onKeyDown:J=>{var De;J.key==="Escape"&&(J.stopPropagation(),Ce(!1),(De=Le.current)==null||De.focus())},children:[t.jsxs("div",{className:"bim-rd-sp-top",children:[t.jsx("span",{children:O("reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":O("reader.closeSettings"),onClick:()=>{var J;Ce(!1),(J=Le.current)==null||J.focus()},children:"✕"})]}),Ge]}),t.jsxs("div",{className:"bim-rd-text",id:re,ref:V,tabIndex:-1,"data-rail":(v||j)&&!G?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[ee,P&&Me&&(Me.sourceName||Me.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":Me.key,children:[Me.sourceName&&t.jsxs(t.Fragment,{children:[O("reader.sourceLabel")," ",Me.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:Me.sourceUrl,target:"_blank",rel:"noreferrer",children:je(Me.sourceName)}):je(Me.sourceName)]}),Me.sourceName&&Me.license&&t.jsx("span",{className:"bim-rd-dot"}),Me.license&&t.jsx(t.Fragment,{children:O("reader.licenseOf",{license:Me.license})})]}),C&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:O("reader.revisedAt",{date:C})}),j&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:J=>J.preventDefault(),onClick:Re,children:O("reader.reportError")})}),T&&!z&&(Be||$e)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":O("reader.pagerNav"),children:[Be?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>ce(Be.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),O("reader.prevUnit",{unit:we})]}),t.jsx("span",{className:"bim-rd-pglabel",children:Be.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",O("reader.firstUnit",{unit:we})]}),$e?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>ce($e.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[O("reader.nextUnit",{unit:we}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:$e.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[O("reader.lastUnit",{unit:we})," →"]})]})]}),(v||j)&&!G&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":O("reader.rail"),children:[v,j&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:J=>J.preventDefault(),onClick:Re,children:O("reader.reportError")})})]})]})]}),le&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":O("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":be,"aria-controls":Fe,onClick:()=>{D(null),Y()},children:[t.jsx(Us,{}),t.jsx("span",{children:O("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":q==="img","aria-haspopup":"dialog",onClick:J=>ve("img",J.currentTarget),children:[t.jsx(Gs,{}),t.jsx("span",{children:O("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":q==="set","aria-haspopup":"dialog",onClick:J=>ve("set",J.currentTarget),children:[t.jsx(Vs,{}),t.jsx("span",{children:O("reader.settingsShort")})]}),j&&t.jsxs("button",{type:"button",onMouseDown:J=>J.preventDefault(),onClick:()=>{D(null),Re()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:O("reader.reportError")})]})]}),le&&q&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:L}),t.jsxs("div",{className:"bim-rd-sheet",ref:F,role:"dialog","aria-modal":"true","aria-label":O(q==="img"?"reader.images":"reader.settings"),onKeyDown:J=>{if(J.key==="Escape"){J.stopPropagation(),L();return}J.key==="Tab"&&Ys(J,F.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:O(q==="img"?"reader.images":"reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":O("reader.close"),onClick:L,children:"✕"})]}),q==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(_r,{pages:d??null,loading:c,renderOverlay:p,preserveMargins:u.preserveMargins})}):Ge]})]})]})}function lh(e,n,i){return i?ql(e).includes("\r")?"lone-cr":Array.from(e).length!==Array.from(n).length?"convert-length":n.includes(":::")?"tables":null:"quoteStyle"}function ql(e){return e.replace(/\r\n/g,`
678
+ `)}const Ks=2,ch=400,dh=6,Kl=e=>e==="*"||e==="#"||e==="<"||e===">"||/\s/.test(e);function Xl(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 ph(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=Xl(e,o);if(a>=0){o=a+1;continue}if(Kl(e[o])){o++;continue}if(i[s]===" "){s++;continue}return-1}return o}function uh(e){const n=Array.from(ql(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>=dh;let l=0;for(let d=i;d<n.length&&d-i<=(a?ch:Ks+64);d++){const c=Xl(n,d);if(c>=0){d=c;continue}if(!Kl(n[d])){const h=ph(n,d,s);if(h>=0)return i=h,d;if(l++,!a&&l>Ks)return}}}}}const Zl=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],mh={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function st(e){return mh[e]??e}const gn=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],fn={熹平: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},Jl={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function Ii(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 hh(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 gh=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,Xs={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function lo(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(Xs))if(n.startsWith(s))return Xs[s];const i=st(n);if(en[i]!=null)return i;const o=Ot(n);if(o&&n.length<=o.length+1)return st(o)}function Qt(e,n){if(n){const i=Jl[`${n}|${e}`];if(i!=null)return i}return fn[e]}const fh=1911;function xh(e){const n=fn[e];if(n==null)return;const i=Nt[e];let o;for(const[s,a]of Object.entries(fn))Nt[s]===i&&a>n&&(o==null||a<o)&&(o=a);return o!=null?o-1:void 0}const bh={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function bi(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=bh[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 Ot(e){for(const n of Zl)if(e.startsWith(n))return n}const Nt={};{const e=(n,i)=>{for(const o of i)Nt[o]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function tn(e,n){const i=n==="北宋"||n==="南宋"?"宋":n;for(const o of Object.keys(fn))if(e.includes(o)&&!(i&&Nt[o]&&Nt[o]!==i&&Jl[`${i}|${o}`]==null))return o}function Fn(e){var l,d,c;const n={era:"",reign:"",source:"none"},i=e.dating;if(i!=null&&i.era||i!=null&&i.reign)return{era:i.era??"",reign:i.reign??"",source:i.certainty==="attested"?"catalog":"edition"};const o=(l=e.lineage)==null?void 0:l.year_text;if(o){const p=Ot(o)??"";return{era:st(p),reign:tn(o,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=Ii(s);if(p)return{era:hh(p.from),reign:"",source:"publication"};const h=Ot(s)??lo(s)??((c=gn.find(f=>f.pattern.test(s)))==null?void 0:c.era)??"",u=tn(s,h)??"",m=h||(u?Nt[u]??"":"");if(m||u)return{era:st(m),reign:u,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=Ot(a);if(p)return{era:st(p),reign:tn(a,p)??"",source:"edition"};const h=gn.find(u=>u.pattern.test(a));if(h)return{era:st(h.era),reign:tn(a,h.era)??h.reign??"",source:"edition"}}return n}function Ei(e){var o,s,a,l,d,c,p,h,u;if(((o=e.dating)==null?void 0:o.year)!=null)return e.dating.year;if(typeof((s=e.lineage)==null?void 0:s.year)=="number")return e.lineage.year;const n=(a=e.publication_info)==null?void 0:a.year;if(n){const m=Ii(n);if(m)return m.from}const i=[(l=e.lineage)==null?void 0:l.year_text,(d=e.publication_info)==null?void 0:d.year,e.edition,e.edition?void 0:e.title].filter(Boolean);for(const m of i){const f=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(f&&m!==f&&(Ot(f)||lo(f)))break;const x=m.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??m.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(x){const w=parseInt(x[1],10);if(w>=100&&w<=2100)return w}const k=m.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(k){const w=Ot(m);if(!w||st(w)==="民國"){const j=bi(k[1]);if(j!=null&&j>=1&&j<=120)return fh+j}}const y=Ot(m)??((h=gn.find(w=>w.pattern.test(m)))==null?void 0:h.era),$=y?st(y):void 0,b=tn(m,$)??(Ot(m)||(u=gn.find(w=>w.pattern.test(m)))==null?void 0:u.reign);if(b){const w=Qt(b,$);if(w==null)continue;const v=m.indexOf(b),j=v>=0?m.slice(v+b.length):"",C=j.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??j.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),S=C?bi(C[1]):void 0;return w+(S?S-1:0)}}}function co(e){var l,d,c,p,h,u;const n=(l=e.dating)==null?void 0:l.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const i=(d=e.lineage)==null?void 0:d.year_range;if(i&&i.length===2)return{from:i[0],to:i[1]};const o=(c=e.lineage)==null?void 0:c.year_text;if(o){const m=o.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(m){const f=zr[st(m[1])],x=en[st(m[2])];if(f!=null&&x!=null)return{from:Math.min(f,x)-20,to:Math.max(f,x)+40}}}const s=(p=e.publication_info)==null?void 0:p.year;if(s){const m=Ii(s);if((m==null?void 0:m.to)!=null)return{from:m.from,to:m.to};const f=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(f){const x=zr[st(f[1])],k=en[st(f[2])];if(x!=null&&k!=null)return{from:Math.min(x,k)-20,to:Math.max(x,k)+40}}}const a=[(h=e.publication_info)==null?void 0:h.year,e.edition,e.title].filter(Boolean);for(const m of a){if(!/[間间]/.test(m))continue;const f=Ot(m)??lo(m)??((u=gn.find(y=>y.pattern.test(m)))==null?void 0:u.era),x=f?st(f):void 0,k=[];for(const y of Object.keys(fn))m.includes(y)&&(x&&Nt[y]&&Nt[y]!==x||Qt(y,x)!=null&&k.push(y));if(k.length===0){const y=m.match(/([一-鿿])([一-鿿])[間间]/);if(y&&x){for(const $ of[y[1],y[2]])for(const b of Object.keys(fn))if(Nt[b]===x&&!(b[0]!==$&&b[b.length-1]!==$)&&Qt(b,x)!=null){k.push(b);break}}}if(k.length>0){const y=k.map(v=>Qt(v,x)).filter(v=>v!=null),$=Math.min(...y),b=k.reduce((v,j)=>Qt(v,x)>=Qt(j,x)?v:j),w=xh(b)??dr(x??"")??Math.max(...y);return{from:$,to:w>$?w:dr(x??Nt[b]??"")??$}}if(x&&en[x]!=null)return{from:en[x],to:dr(x)??en[x]}}}const en={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},yh=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],jh=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,Zs=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function Js(e,n){for(const i of Zl){const o=e.indexOf(i);if(o<0)continue;if(i.length===1){const c=e[o+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!tn(e.slice(o),st(i)))continue}const s=st(i);if(s===n)continue;const a=e.slice(o),l=tn(a,s)??"";let d;if(l){const c=Qt(l,s);if(c!=null){const h=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),u=h?bi(h[1]):void 0;d=c+(u?u-1:0)}}return{era:s,reign:l,year:d}}for(const i of gn)if(i.pattern.test(e))return{era:st(i.era),reign:i.reign??""}}function vh(e){var $,b,w,v,j;const n=Fn(e),i=(($=e.publication_info)==null?void 0:$.year)??"",o=i?Ii(i):void 0;if(!n.era&&!n.reign&&!o)return;const s=e.edition||e.title||"",a=/[間间]/.test(s),l=((b=e.lineage)==null?void 0:b.year_text)??"",d=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(l),c=n.source==="publication"&&gh.test(i),p=n.source==="publication"&&/[間间]/.test(i),h=l.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let u;a||d||c||p?u=void 0:h?u=parseInt(h[2],10):u=Ei(e);const m=u==null?co(e):void 0;let f;n.source==="publication"&&(c||Zs.test(i))?f="uncertain":n.source==="lineage"||n.source==="publication"?f="attested":Zs.test(s)||!n.reign&&u==null?f="uncertain":f="inferred";const x=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((w=e.lineage)==null?void 0:w.year_text)??((v=e.lineage)==null?void 0:v.year)??""}」`:`出版著錄「${((j=e.publication_info)==null?void 0:j.year)??""}」`,k={era:n.era,reign:n.reign,year:u,yearRange:m,certainty:f,source:n.source==="edition"?"edition":"catalog",basis:x};if(h){const C=l.match(/[、,,]\s*([宋元明清])/);C&&C[1]!==k.era&&(k.laterRepair={era:C[1]})}if(!k.laterRepair&&jh.test(s)){const C=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);C&&C[1]!==n.era&&(k.laterRepair={era:C[1]})}const y=yh.find(C=>C.re.test(s));if(y){const C=s.search(y.re),S=s.slice(C),_=Js(S,n.era)??Js(s,n.era);_&&(k.basedOn={era:_.era,reign:_.reign,year:_.year,relation:y.relation})}return k}const zr={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function dr(e){return zr[e]}function yi(e){const n=Ei(e);if(n!=null)return n;const i=co(e);if(i)return i.from;const o=Fn(e).era;return o?en[o]:void 0}const Qs=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function Tr(e){const n=Qs.indexOf(e);return n===-1?Qs.length:n}function kh(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 po(e,n){const i=Xr(e||[]),o=new Map,s=[];for(const p of i)p.group?(o.has(p.group)||o.set(p.group,[]),o.get(p.group).push(p)):s.push(p);for(const p of o.values())p.sort((h,u)=>{const m=f=>f.group_role==="origin"?0:f.group_role==="mirror"?1:2;return m(h)-m(u)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const h=Wt(p),u=h.includes("text"),m=h.includes("image");u&&m?a.textImage.push(p):u?a.text.push(p):m?a.image.push(p):a.physical.push(p)}const d=["text","image","textImage","physical"].filter(p=>a[p].length>0).map(p=>({key:p,items:a[p]})),c=[...o.entries()].map(([p,h])=>{var u,m;return{key:p,label:((u=n==null?void 0:n[p])==null?void 0:u.label)||p,description:(m=n==null?void 0:n[p])==null?void 0:m.description,items:h}});return{buckets:d,mirrors:c,total:i.length}}function Ri(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=Si(e);return s&&s.expected>0&&i.push(s.missing>0?n("detail.volumeStatsMissing",{found:s.found,expected:s.expected,missing:s.missing}):n("detail.volumeStats",{found:s.found,expected:s.expected})),o.version&&i.push(String(o.version)),i.join(" · ")}function Ql(e,n){if(Ri(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 wh="同版";function Sh(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 _h(e){var n;for(const i of((n=e.lineage)==null?void 0:n.related_to)??[]){const o=i.ref??i.book_id;if(i.relation===wh&&o&&o!==e.id)return o}}function $h(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 ec(e,n){var a,l;const i=e.resources||[],o=[],s=[];for(const d of i){const c=Wt(d);c.includes("image")&&o.push(d),c.includes("physical")&&s.push(d)}return{id:e.id,name:e.edition||e.title||e.id,era:Fn(e),year:Ei(e),sortYear:yi(e),images:o,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,callNumber:Sh(s[0]),copyOf:_h(e),summary:e.summary,important:Ch(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:o.length>0}}function Ch(e,n){var d,c;if(!n)return!1;const i=n.default_collection;if(!i)return!1;const o=(d=n.collections)==null?void 0:d[i];if(((o==null?void 0:o.book_ids)??(i==="core"?n.core_books??[]:[])).includes(e))return!0;const a=(o==null?void 0:o.groups)??[],l=(c=n.node_groups)==null?void 0:c[e];return!!l&&a.includes(l)}function tc(e,n,i={}){const o=new Set((n==null?void 0:n.excluded_books)??[]),s=$h(e.filter(c=>!o.has(c.id)).map(c=>ec(c,n)));let a=s;i.era&&(a=a.filter(c=>c.era.era===i.era)),i.scanOnly&&(a=a.filter(c=>c.hasImage)),i.sort==="year"?a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const h=c.r.sortYear,u=p.r.sortYear;return h!=null&&u!=null?h-u||c.i-p.i:h!=null?-1:u!=null?1:c.i-p.i}).map(c=>c.r):a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const h=u=>(u.important?0:1)*2+(u.hasImage?0:1);return h(c.r)-h(p.r)||c.i-p.i}).map(c=>c.r);const d=[...new Set(s.map(c=>c.era.era).filter(Boolean))].sort((c,p)=>Tr(c)-Tr(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function zh(e,n){var y,$;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const i=(y=n.collections)==null?void 0:y[n.default_collection],o=(i==null?void 0:i.groups)??[],s=(i==null?void 0:i.book_ids)??[],a=o.length>0||s.length>0,l=!a&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!a&&l.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const d=new Set(o),c=new Set([...s,...l]),p=b=>{if(c.has(b))return!0;const w=n.node_groups[b];return w!=null&&d.has(w)},h=[],u=new Map,m=[];for(const b of e)if(!(($=n.excluded_books)!=null&&$.includes(b)))if(p(b))h.push(b);else{const w=n.node_groups[b];w?(u.has(w)||u.set(w,[]),u.get(w).push(b)):m.push(b)}if(m.length+[...u.values()].reduce((b,w)=>b+w.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const x=new Map((n.groups??[]).map(b=>[b.id,b])),k=[...u.entries()].map(([b,w])=>{const v=x.get(b);return{id:b,label:(v==null?void 0:v.label)??b,description:v==null?void 0:v.description,ids:w}});return m.length>0&&k.push({id:"__other__",label:"其他版本",description:void 0,ids:m}),{useGrouping:!0,coreIds:h,groupedIds:k}}const nc=["撰","編","注","校","譯","繪","其他"],Th=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function uo(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n)return"撰";for(const{cls:i,re:o}of Th)if(o.test(n))return i;return"其他"}function mo(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function ic(e,n="全部"){const i=new Map;for(const s of e){const a=uo(s);i.set(a,(i.get(a)??0)+1)}const o=[{cls:"全部",label:n,count:e.length}];for(const s of nc){const a=i.get(s);a&&o.push({cls:s,label:s,count:a})}return o.length>2?o:[]}function ho(e){return(e._books??[]).map(n=>n.id).filter(n=>typeof n=="string")}function go(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 rc(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:Mn(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 Nh(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 oc(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}=rc(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 Mn(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 Li(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 Ih=["〇","一","二","三","四","五","六","七","八","九"],ea=["","十","百","千"];function sc(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),i=n.length;let o="",s=!1;for(let a=0;a<i;a++){const l=parseInt(n[a]),d=i-1-a;l===0?s=!0:(s&&o&&(o+="〇"),s=!1,l===1&&d===1&&a===0?o+=ea[d]:o+=Ih[l]+ea[d])}return o}function Eh(e){return e==null?"":typeof e=="string"?e:"name"in e&&e.name?e.name:"title"in e&&e.title||""}function Rh(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 Ht(e,n="卷"){var o,s;const i=e;return i.measure_info?i.measure_info:(o=i.juan_count)!=null&&o.number?sc(i.juan_count.number)+n:(s=i.juan_count)!=null&&s.description?i.juan_count.description:""}function ac(e){var o;if(e.edition_type)return e.edition_type;if((o=e.lineage)!=null&&o.category)return e.lineage.category;const n=e.edition||e.title||"",i=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/油印/,"油印本"],[/曬印|晒印/,"曬印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,a]of i)if(s.test(n))return a;return""}const Lh=65536,Ah="guji_markdown";function Mh(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 Ph=/^□\{guess=([^\s{}]+)\}/;function Bh(e,n){const i=e[n+1];return i!==void 0&&!/[A-Za-z/!?>\s]/.test(i)}function lc(e,n){let i=0;for(let o=n;o<e.length;o++){const s=e[o];if(s===`
679
+ `)return-1;if(s==="\\"){o++;continue}if(s==="[")i++;else if(s==="]"&&(i--,i===0))return o}return-1}function Oh(e){return e.replace(/\\([\\[\]<>|{}])/g,"$1")}function Wh(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(`
680
+ `)<0?{node:{type:"qw",label:e.slice(n+2,o)},end:o+2}:null}if(i===":"&&e.startsWith(":zi[",n)){const o=lc(e,n+3);return o>n+4?{node:{type:"zi",label:Oh(e.slice(n+4,o))},end:o+1}:null}if(i==="□"&&e[n+1]==="{"){const o=Ph.exec(e.slice(n,n+64));if(o)return{node:{type:"qz",guess:o[1]},end:n+o[0].length}}return null}function cc(e,n,i,o,s){const a=[];let l="",d=!1;const c=()=>{if(!l)return;let p=l;o&&(p=l.replace(/\\?\|/g,h=>d?"|":(d=!0,""))),p&&a.push({type:"text",text:p}),l=""};for(;n<e.length;){const p=e[n];if(p==="\\"&&(e[n+1]==="<"||e[n+1]===">")){l+=e[n+1],n+=2;continue}if(i!==null){if(p===i)return c(),{nodes:a,end:n};if(p===`
681
+ `)return null}const h=Wh(e,n);if(h){c(),a.push(h.node),n=h.end;continue}let u=null;if(p==="<"&&Bh(e,n)&&(u=">"),u){const m=cc(e,n+1,u,!0,s);if(m&&!(m.end-(n+1)>s)){c(),a.push({type:"jz",children:m.nodes}),n=m.end+1;continue}}l+=p,n++}return i!==null?null:(c(),{nodes:a,end:n})}function dc(e,n){return cc(e,0,null,!1,(n==null?void 0:n.jzMaxLength)??Lh).nodes}function Fh(e){return/[<□]|\[\[|:zi\[/.test(e)}function pc(e){return e.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${pc(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const Hh=216,ta="clamp(280px, 23vw, 360px)",Dh=1440,Nr="(max-width: 719px)",Uh=`${Nr}, (pointer: coarse)`,Vh=`
682
+ .bim-d-main.bim-d-main-grid { max-width: ${Dh}px; padding: 16px 32px 0; }
683
683
  .bim-d-grid {
684
684
  display: grid;
685
- grid-template-columns: ${Bh}px minmax(0, 1fr) ${ea};
685
+ grid-template-columns: ${Hh}px minmax(0, 1fr) ${ta};
686
686
  grid-template-rows: auto 1fr;
687
687
  grid-template-areas: "rail main card" "rail main side";
688
688
  column-gap: 32px; row-gap: 28px; align-items: start;
@@ -751,6 +751,13 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
751
751
  .bim-d-zt td.bim-d-zt-main > a:hover { color: ${r("accent")}; }
752
752
  .bim-d-zt td.bim-d-zt-main .bim-d-meta { display: block; margin: -8px 12px 0; padding-bottom: 10px; font-size: 12px; font-weight: 400; }
753
753
  .bim-d-zt .bim-d-zt-sub { color: ${r("quiet-fg")}; font-size: 13px; }
754
+ /* 同版组:代表行左缘一道色条;下附描述首句与「同版另藏」各部的简链(每部仍是独立 Book) */
755
+ .bim-d-zt td.bim-d-zt-main.bim-d-zt-rep { box-shadow: inset 3px 0 0 ${r("accent")}; }
756
+ .bim-d-zt td.bim-d-zt-main .bim-d-zt-summary { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0 12px 6px; color: ${r("quiet-fg")}; font-size: 13px; line-height: 1.6; }
757
+ .bim-d-zt td.bim-d-zt-main .bim-d-zt-copies { display: block; margin: 0 12px; padding-bottom: 10px; font-size: 12px; color: ${r("aux-fg")}; }
758
+ .bim-d-zt td.bim-d-zt-main .bim-d-zt-copies a { color: ${r("quiet-fg")}; text-decoration: underline; text-decoration-color: ${r("aux-fg")}; text-underline-offset: 2px; }
759
+ .bim-d-zt td.bim-d-zt-main .bim-d-zt-copies a:hover { color: ${r("accent")}; }
760
+ .bim-d-zt-ver tbody tr.bim-d-zt-group { height: auto; }
754
761
  .bim-d-zt .bim-d-zt-nowrap { white-space: nowrap; }
755
762
  .bim-d-zt .bim-d-zt-empty { color: ${r("aux-fg")}; }
756
763
  /* 版本表:行高先按「有影印」色块那一行的高度占好,解析到的年代、馆藏、色块进来时行不再长高(INT Q3) */
@@ -1028,7 +1035,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1028
1035
  .bim-d-side li .bim-d-meta { font-size: 12px; flex: none; }
1029
1036
 
1030
1037
  /* 点击目标 ≥44px(Q5):触屏与窄屏 */
1031
- @media ${Oh} {
1038
+ @media ${Uh} {
1032
1039
  .bim-d-tab, .bim-d-check, .bim-d-more, .bim-d-rail-back,
1033
1040
  .bim-d-card-foot summary, .bim-d-card-toggle, .bim-d-card details.bim-d-more-names summary,
1034
1041
  .bim-d-tl summary, .bim-d-chap a { min-height: 44px; }
@@ -1066,7 +1073,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1066
1073
  /* 中等宽度:左栏折到顶部一行 */
1067
1074
  @media (max-width: 1100px) {
1068
1075
  .bim-d-grid {
1069
- grid-template-columns: minmax(0, 1fr) ${ea};
1076
+ grid-template-columns: minmax(0, 1fr) ${ta};
1070
1077
  grid-template-rows: auto auto 1fr;
1071
1078
  grid-template-areas: "rail rail" "main card" "main side";
1072
1079
  }
@@ -1170,7 +1177,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1170
1177
  :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 {
1171
1178
  text-decoration-color: currentColor; text-decoration-thickness: 2px;
1172
1179
  }
1173
- `;function Hn({railTop:e,back:n,up:i,nav:o,railLinks:s,main:a,card:l,side:d}){const{t:c,convert:p}=te(),h=(o||[]).filter(Boolean);return t.jsxs("div",{className:"bim-d-grid",children:[t.jsxs("aside",{className:"bim-d-g-rail bim-d-ui",children:[e,n&&t.jsx("div",{style:{marginTop:e?12:0},children:n}),i,h.length>1&&t.jsxs("nav",{className:"bim-d-rail-navwrap","aria-label":c("detail.pageNav"),style:{marginTop:20},children:[t.jsx("p",{className:"bim-d-rail-cap",style:{marginTop:0},children:c("detail.thisPage")}),t.jsx("ul",{className:"bim-d-rail-nav",children:h.map(u=>t.jsx("li",{children:t.jsxs("a",{href:`#${u.id}`,children:[t.jsx("span",{children:p(u.label)}),u.count!=null&&t.jsx("span",{className:"bim-d-meta",children:u.count})]})},u.id))})]}),s&&s.length>0&&t.jsxs("nav",{className:"bim-d-rail-links","aria-label":c("detail.more"),children:[t.jsx("p",{className:"bim-d-rail-cap",children:c("detail.more")}),t.jsx("ul",{className:"bim-d-rail-nav",children:s.map(u=>t.jsx("li",{children:t.jsxs("a",{href:u.href??"#",onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),u.onClick())},children:[t.jsx("span",{children:p(u.label)}),t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:"→"})]})},u.key))})]})]}),t.jsx("div",{className:"bim-d-g-main",children:a}),t.jsx("div",{className:"bim-d-g-card",children:l}),t.jsx("div",{className:"bim-d-g-side",children:d})]})}function uc({caption:e,children:n}){const{convert:i}=te();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 lt({id:e,title:n,meta:i,action:o,children:s}){const{convert:a}=te();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 at({items:e,className:n,style:i}){const o=e.filter(s=>s!=null&&s!==""&&s!==!1);return o.length?t.jsx("span",{className:`bim-d-meta${n?` ${n}`:""}`,style:i,children:o.map((s,a)=>t.jsxs(g.Fragment,{children:[a>0&&t.jsx("span",{className:"bim-d-dot"}),t.jsx("span",{children:s})]},a))}):null}function Ai({items:e,value:n,onChange:i}){const{convert:o}=te();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 mc({label:e,checked:n,onChange:i}){const{convert:o}=te();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 hc=6,Mi=e=>e>hc+1;function go({total:e,shown:n,unit:i,onClick:o}){const{t:s,convert:a}=te(),l=e-n,d=Mi(e)?e-Math.min(n,hc):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 fo({label:e,onClick:n}){const{convert:i}=te();return t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:i(e)})}function Dn({kind:e,title:n,subtitle:i,byline:o,meta:s,description:a,clampDescription:l,facts:d,stats:c,readAction:p,secondaryAction:h,children:u,foot:m}){const{t:f,convert:x}=te(),k=(d||[]).filter(v=>v.value!=null&&v.value!==""),y=(c||[]).filter(v=>v.value!=null&&v.value!==""&&v.value!==0),[$,b]=g.useState(!1),w=!!l&&!$;return t.jsxs("div",{className:"bim-d-card",children:[e&&t.jsx("div",{className:"bim-d-card-kind bim-d-ui",children:x(e)}),t.jsx("h1",{className:typeof n=="string"&&[...n].length>7?"bim-d-card-long":void 0,children:n}),i&&t.jsx("div",{className:"bim-d-card-sub",children:i}),o&&t.jsx("p",{className:"bim-d-card-byline",style:{marginBottom:0},children:o}),s&&t.jsx("div",{className:"bim-d-card-cls bim-d-ui",children:s}),a&&t.jsx("div",{className:w?"bim-d-card-desc bim-d-clamp":"bim-d-card-desc",style:w?{"--detail-clamp":l}:void 0,children:a}),a&&!!l&&t.jsx("button",{type:"button",className:"bim-d-card-toggle bim-d-ui","aria-expanded":$,onClick:()=>b(v=>!v),children:f($?"action.collapse":"action.expand")}),y.length>0&&t.jsx("div",{className:"bim-d-stats bim-d-ui",children:y.map((v,j)=>t.jsxs("div",{children:[t.jsx("b",{children:v.value}),t.jsx("span",{children:x(v.label)})]},j))}),k.length>0&&t.jsx("dl",{className:"bim-d-ui",children:k.map((v,j)=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:x(v.label)}),t.jsx("dd",{title:v.title,children:v.value})]},j))}),u,p,h,m&&t.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:m})]})}function xo(e){return!!e&&[...e.replace(/\s+/g,"")].length>110}function Ir({href:e,onClick:n,label:i}){const{t:o,convert:s}=te(),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 rn({id:e,title:n,meta:i,items:o,metas:s,currentIndex:a,cap:l=8,moreLabel:d,foot:c,sub:p,timeline:h}){const{t:u,convert:m}=te(),[f,x]=g.useState(!1);if(!o.length)return null;const k=f?o:o.slice(0,l),y=o.length-k.length;return t.jsxs("div",{id:e,className:h?"bim-d-side bim-d-side-tl":"bim-d-side",style:{scrollMarginTop:16},children:[t.jsxs("h2",{className:"bim-d-ui bim-d-side-h",children:[m(n),i!=null&&i!==""&&t.jsx("span",{className:"bim-d-meta",children:i})]}),p&&t.jsx("p",{className:"bim-d-side-sub bim-d-ui",children:p}),t.jsx("ul",{children:k.map(($,b)=>t.jsxs("li",{className:b===a?"bim-d-side-cur":void 0,"aria-current":b===a?"page":void 0,children:[$,s!=null&&s[b]?t.jsx("span",{className:"bim-d-meta",style:{marginLeft:"auto"},children:s[b]}):null]},b))}),y>0&&t.jsx(fo,{label:d?d(y):u("detail.showMore",{n:y}),onClick:()=>x(!0)}),c&&t.jsx("p",{className:"bim-d-side-note bim-d-ui",children:c})]})}const Hh=new Set(["reviewed","disputed","unreviewed","draft"]);function Un({revision:e,revisedAt:n,review:i,todo:o}){const{t:s,convert:a}=te(),l=i&&Hh.has(i.status)?s(`detail.review.${i.status}`):void 0,d=i&&i.status!=="unreviewed"&&l?[l,i.by,i.date].filter(Boolean).join(" "):"",c=[e!=null&&e!==""?`${s("detail.dataVersion")} ${e}`:"",n??"",a(d)].filter(Boolean),p=(o||[]).filter(h=>h&&h.what);return!c.length&&!p.length?null:t.jsxs(t.Fragment,{children:[c.length>0&&t.jsx(at,{items:c,style:{fontSize:12}}),p.length>0&&t.jsxs("details",{children:[t.jsx("summary",{children:s("detail.todoCount",{n:p.length})}),t.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:18,lineHeight:1.7},children:p.map((h,u)=>t.jsxs("li",{children:[a(h.what),(h.by||h.date)&&t.jsxs("span",{style:{marginLeft:6},children:["(",[h.by&&a(h.by),h.date].filter(Boolean).join(" · "),")"]})]},u))})]})]})}const mi=1e3,ta=208,Dh=1440,Uh="(max-width: 719px)",gc=`
1180
+ `;function Hn({railTop:e,back:n,up:i,nav:o,railLinks:s,main:a,card:l,side:d}){const{t:c,convert:p}=ne(),h=(o||[]).filter(Boolean);return t.jsxs("div",{className:"bim-d-grid",children:[t.jsxs("aside",{className:"bim-d-g-rail bim-d-ui",children:[e,n&&t.jsx("div",{style:{marginTop:e?12:0},children:n}),i,h.length>1&&t.jsxs("nav",{className:"bim-d-rail-navwrap","aria-label":c("detail.pageNav"),style:{marginTop:20},children:[t.jsx("p",{className:"bim-d-rail-cap",style:{marginTop:0},children:c("detail.thisPage")}),t.jsx("ul",{className:"bim-d-rail-nav",children:h.map(u=>t.jsx("li",{children:t.jsxs("a",{href:`#${u.id}`,children:[t.jsx("span",{children:p(u.label)}),u.count!=null&&t.jsx("span",{className:"bim-d-meta",children:u.count})]})},u.id))})]}),s&&s.length>0&&t.jsxs("nav",{className:"bim-d-rail-links","aria-label":c("detail.more"),children:[t.jsx("p",{className:"bim-d-rail-cap",children:c("detail.more")}),t.jsx("ul",{className:"bim-d-rail-nav",children:s.map(u=>t.jsx("li",{children:t.jsxs("a",{href:u.href??"#",onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),u.onClick())},children:[t.jsx("span",{children:p(u.label)}),t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:"→"})]})},u.key))})]})]}),t.jsx("div",{className:"bim-d-g-main",children:a}),t.jsx("div",{className:"bim-d-g-card",children:l}),t.jsx("div",{className:"bim-d-g-side",children:d})]})}function uc({caption:e,children:n}){const{convert:i}=ne();return t.jsxs("div",{className:"bim-d-up bim-d-ui",children:[t.jsx("span",{className:"bim-d-up-cap",children:i(e)}),n]})}function lt({id:e,title:n,meta:i,action:o,children:s}){const{convert:a}=ne();return t.jsxs("section",{id:e,className:"bim-d-sec",children:[t.jsxs("div",{className:"bim-d-sec-head bim-d-ui",children:[t.jsx("h2",{children:a(n)}),i!=null&&i!==""&&t.jsx("span",{className:"bim-d-meta",children:i}),o&&t.jsx("span",{className:"bim-d-sec-act",children:o})]}),t.jsx("div",{className:"bim-d-sec-body",children:s})]})}function at({items:e,className:n,style:i}){const o=e.filter(s=>s!=null&&s!==""&&s!==!1);return o.length?t.jsx("span",{className:`bim-d-meta${n?` ${n}`:""}`,style:i,children:o.map((s,a)=>t.jsxs(g.Fragment,{children:[a>0&&t.jsx("span",{className:"bim-d-dot"}),t.jsx("span",{children:s})]},a))}):null}function Ai({items:e,value:n,onChange:i}){const{convert:o}=ne();return t.jsx(t.Fragment,{children:e.map(s=>t.jsx("button",{type:"button",className:[...o(s.label)].length===1?"bim-d-tab bim-d-tab-1":"bim-d-tab","aria-pressed":s.key===n,onClick:()=>i(s.key),children:o(s.label)},s.key))})}function mc({label:e,checked:n,onChange:i}){const{convert:o}=ne();return t.jsxs("label",{className:"bim-d-check",children:[t.jsx("input",{type:"checkbox",checked:n,onChange:s=>i(s.target.checked)}),o(e)]})}const hc=6,Mi=e=>e>hc+1;function fo({total:e,shown:n,unit:i,onClick:o}){const{t:s,convert:a}=ne(),l=e-n,d=Mi(e)?e-Math.min(n,hc):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 xo({label:e,onClick:n}){const{convert:i}=ne();return t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:i(e)})}function Dn({kind:e,title:n,subtitle:i,byline:o,meta:s,description:a,clampDescription:l,facts:d,stats:c,readAction:p,secondaryAction:h,children:u,foot:m}){const{t:f,convert:x}=ne(),k=(d||[]).filter(v=>v.value!=null&&v.value!==""),y=(c||[]).filter(v=>v.value!=null&&v.value!==""&&v.value!==0),[$,b]=g.useState(!1),w=!!l&&!$;return t.jsxs("div",{className:"bim-d-card",children:[e&&t.jsx("div",{className:"bim-d-card-kind bim-d-ui",children:x(e)}),t.jsx("h1",{className:typeof n=="string"&&[...n].length>7?"bim-d-card-long":void 0,children:n}),i&&t.jsx("div",{className:"bim-d-card-sub",children:i}),o&&t.jsx("p",{className:"bim-d-card-byline",style:{marginBottom:0},children:o}),s&&t.jsx("div",{className:"bim-d-card-cls bim-d-ui",children:s}),a&&t.jsx("div",{className:w?"bim-d-card-desc bim-d-clamp":"bim-d-card-desc",style:w?{"--detail-clamp":l}:void 0,children:a}),a&&!!l&&t.jsx("button",{type:"button",className:"bim-d-card-toggle bim-d-ui","aria-expanded":$,onClick:()=>b(v=>!v),children:f($?"action.collapse":"action.expand")}),y.length>0&&t.jsx("div",{className:"bim-d-stats bim-d-ui",children:y.map((v,j)=>t.jsxs("div",{children:[t.jsx("b",{children:v.value}),t.jsx("span",{children:x(v.label)})]},j))}),k.length>0&&t.jsx("dl",{className:"bim-d-ui",children:k.map((v,j)=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:x(v.label)}),t.jsx("dd",{title:v.title,children:v.value})]},j))}),u,p,h,m&&t.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:m})]})}function bo(e){return!!e&&[...e.replace(/\s+/g,"")].length>110}function Ir({href:e,onClick:n,label:i}){const{t:o,convert:s}=ne(),a=i??o("detail.read");return e?t.jsx("a",{className:"bim-d-btn",href:e,onClick:n?l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),n())}:void 0,children:s(a)}):t.jsx("button",{type:"button",className:"bim-d-btn",onClick:n,children:s(a)})}function rn({id:e,title:n,meta:i,items:o,metas:s,currentIndex:a,cap:l=8,moreLabel:d,foot:c,sub:p,timeline:h}){const{t:u,convert:m}=ne(),[f,x]=g.useState(!1);if(!o.length)return null;const k=f?o:o.slice(0,l),y=o.length-k.length;return t.jsxs("div",{id:e,className:h?"bim-d-side bim-d-side-tl":"bim-d-side",style:{scrollMarginTop:16},children:[t.jsxs("h2",{className:"bim-d-ui bim-d-side-h",children:[m(n),i!=null&&i!==""&&t.jsx("span",{className:"bim-d-meta",children:i})]}),p&&t.jsx("p",{className:"bim-d-side-sub bim-d-ui",children:p}),t.jsx("ul",{children:k.map(($,b)=>t.jsxs("li",{className:b===a?"bim-d-side-cur":void 0,"aria-current":b===a?"page":void 0,children:[$,s!=null&&s[b]?t.jsx("span",{className:"bim-d-meta",style:{marginLeft:"auto"},children:s[b]}):null]},b))}),y>0&&t.jsx(xo,{label:d?d(y):u("detail.showMore",{n:y}),onClick:()=>x(!0)}),c&&t.jsx("p",{className:"bim-d-side-note bim-d-ui",children:c})]})}const Gh=new Set(["reviewed","disputed","unreviewed","draft"]);function Un({revision:e,revisedAt:n,review:i,todo:o}){const{t:s,convert:a}=ne(),l=i&&Gh.has(i.status)?s(`detail.review.${i.status}`):void 0,d=i&&i.status!=="unreviewed"&&l?[l,i.by,i.date].filter(Boolean).join(" "):"",c=[e!=null&&e!==""?`${s("detail.dataVersion")} ${e}`:"",n??"",a(d)].filter(Boolean),p=(o||[]).filter(h=>h&&h.what);return!c.length&&!p.length?null:t.jsxs(t.Fragment,{children:[c.length>0&&t.jsx(at,{items:c,style:{fontSize:12}}),p.length>0&&t.jsxs("details",{children:[t.jsx("summary",{children:s("detail.todoCount",{n:p.length})}),t.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:18,lineHeight:1.7},children:p.map((h,u)=>t.jsxs("li",{children:[a(h.what),(h.by||h.date)&&t.jsxs("span",{style:{marginLeft:6},children:["(",[h.by&&a(h.by),h.date].filter(Boolean).join(" · "),")"]})]},u))})]})]})}const mi=1e3,na=208,Yh=1440,qh="(max-width: 719px)",gc=`
1174
1181
  .bim-d-page {
1175
1182
  background: ${r("page-bg")};
1176
1183
  color: ${r("ink")};
@@ -1190,7 +1197,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1190
1197
  * PAGE_MAX_WIDTH,读者的行宽体验不变。
1191
1198
  */
1192
1199
  .bim-d-main.bim-d-main-wide {
1193
- max-width: ${Dh}px;
1200
+ max-width: ${Yh}px;
1194
1201
  }
1195
1202
  .bim-d-ui { font-family: var(--bim-font-ui, system-ui, sans-serif); }
1196
1203
 
@@ -1222,9 +1229,9 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1222
1229
  */
1223
1230
  .bim-d-reader {
1224
1231
  display: grid;
1225
- grid-template-columns: ${ta}px minmax(0, ${mi}px);
1232
+ grid-template-columns: ${na}px minmax(0, ${mi}px);
1226
1233
  gap: 32px;
1227
- max-width: ${ta+mi+32}px;
1234
+ max-width: ${na+mi+32}px;
1228
1235
  margin: 0 auto;
1229
1236
  align-items: start;
1230
1237
  }
@@ -1247,7 +1254,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1247
1254
  align-items: start; margin-bottom: 48px; }
1248
1255
  .bim-d-pair-wide { grid-template-columns: 1fr 1.2fr; }
1249
1256
 
1250
- @media ${Uh} {
1257
+ @media ${qh} {
1251
1258
  .bim-d-intro { grid-template-columns: 1fr; gap: 20px; margin-bottom: 32px; }
1252
1259
  .bim-d-pair, .bim-d-pair-wide { grid-template-columns: 1fr; gap: 40px; }
1253
1260
  /* 表格:meta 列折到第二行,表头隐藏 */
@@ -1265,20 +1272,20 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1265
1272
  padding-right: 0; padding-bottom: 12px;
1266
1273
  }
1267
1274
  }
1268
- ${Fh}`;function Rn({children:e,style:n,wide:i,grid:o}){return t.jsxs("div",{className:"bim-d-page",style:n,children:[t.jsx("style",{children:gc}),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 Er({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 bo({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 Rr({items:e}){const n=rt();return t.jsx(t.Fragment,{children:e.map((i,o)=>{const s=o===e.length-1,a=o>0&&t.jsx("span",{style:{color:r("hint-fg")},children:"/"},`s${o}`),l=i.id?n(i.id):i.href,d=s||!i.onClick&&!l?t.jsx("span",{style:{color:r("ink")},children:i.label},o):t.jsx("a",{href:l??"#",onClick:i.onClick?c=>{c.metaKey||c.ctrlKey||(c.preventDefault(),i.onClick())}:void 0,style:{color:r("meta-fg")},children:i.label},o);return t.jsxs(g.Fragment,{children:[a,d]},o)})})}function fc({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 Vh({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 Gh({items:e,horizontal:n}){const{convert:i}=Pe();return e.length?t.jsx("div",{style:{borderLeft:`2px solid ${r("accent")}`,paddingLeft:16,display:n?"grid":"flex",gridTemplateColumns:n?"repeat(auto-fit, minmax(150px, max-content))":void 0,flexDirection:n?void 0:"column",gap:n?"14px 40px":10,fontSize:13},children:e.map((o,s)=>t.jsxs("div",{title:o.title,style:n?{display:"flex",flexDirection:"column",gap:3}:{display:"flex",justifyContent:"space-between",gap:10},children:[t.jsx("span",{className:"bim-d-ui",style:{color:r("label-fg"),letterSpacing:".08em",flex:"none"},children:i(o.label)}),t.jsx("span",{style:{color:r("body-fg"),textAlign:n?"left":"right",minWidth:0},children:o.value})]},s))}):null}function Yh({glyph:e,tone:n,title:i,count:o,actions:s,id:a}){const{convert:l}=Pe();return t.jsxs("div",{id:a,style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",justifyContent:"space-between",gap:"10px 16px",marginBottom:14,scrollMarginTop:16},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx(bo,{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 xc({label:e,active:n,onClick:i,dashed:o}){const{convert:s}=Pe();return t.jsx("button",{type:"button",onClick:i,"aria-pressed":n,className:"bim-d-ui",style:{padding:"5px 13px",border:`1px ${o&&!n?"dashed":"solid"} ${r(n?"accent":"rule")}`,background:n?r("accent"):"transparent",color:r(n?"page-bg":"meta-fg"),fontSize:12,cursor:"pointer",letterSpacing:".04em",lineHeight:1.4},children:s(e)})}function qh({label:e,onClick:n}){const{convert:i}=Pe();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg"),borderBottom:`1px solid ${r("rule")}`},children:i(e)})}function Kh({label:e,onClick:n,inline:i}){const{convert:o}=Pe();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{marginTop:i?0:12,width:i?void 0:"100%",padding:i?"4px 12px":9,background:"none",border:`1px dashed ${r("rule-dashed")}`,cursor:"pointer",fontSize:12,color:r("meta-fg"),letterSpacing:i?void 0:".08em"},children:o(e)})}function bc({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 Xh({children:e}){return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e})}function Zh({volumes:e,unit:n,max:i=60}){const{t:o}=te(),s=n??o("unit.volume"),[a,l]=g.useState(!1);if(!e.length)return null;const d=a?e:e.slice(0,i);return t.jsxs("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,fontSize:11.5},children:[d.map(c=>t.jsx("span",{style:{minWidth:30,textAlign:"center",padding:"2px 5px",border:`1px solid ${r("rule")}`,color:r("meta-fg")},children:c},c)),!a&&e.length>i&&t.jsxs("button",{type:"button",onClick:()=>l(!0),style:{padding:"2px 8px",background:"none",cursor:"pointer",border:`1px dashed ${r("rule-dashed")}`,fontFamily:"inherit",fontSize:11.5,color:r("meta-fg")},children:["+",e.length-i]}),t.jsx("span",{style:{padding:"2px 6px",color:r("hint-fg")},children:s})]})}function Jh({children:e}){return t.jsx("div",{style:{borderTop:`1px solid ${r("rule-strong")}`},children:e})}function Qh({spec:e}){const{convert:n}=Pe();return t.jsxs("div",{className:"bim-d-thead bim-d-ui",style:{display:"grid",gridTemplateColumns:`${e.leadWidth}px 1fr ${e.metaWidth}px`,gap:12,padding:"7px 4px",borderBottom:`1px solid ${r("rule-strong")}`,fontSize:11,color:r("label-fg"),letterSpacing:".1em"},children:[t.jsx("span",{}),t.jsx("span",{children:n(e.mainLabel)}),t.jsx("span",{style:{display:"grid",gridTemplateColumns:e.columns.map(i=>i.width).join(" "),gap:12},children:e.columns.map(i=>t.jsx("span",{children:n(i.label)},i.label))})]})}function eg({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 tg(e){return String(e+1).padStart(2,"0")}function ng(){return t.jsx("span",{style:{color:r("hint-fg")},children:"—"})}function ig({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 yc(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(`
1269
- `)||(n.push({start:i,end:l+1,inner:d}),i=l)}return n}function jc(e,n){if(e.length<=n)return e;let i=n;for(const o of yc(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 vc={fontSize:".78em",color:r("meta-fg"),lineHeight:1.55},rg={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 kc(e,n,i,o){return e.map((s,a)=>{switch(s.type){case"text":return t.jsx(g.Fragment,{children:n(s.text)},a);case"jz":return t.jsx("span",{className:"bim-jiazhu",style:i===0?vc:void 0,children:kc(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:rg,children:s.label},a)}})}function yt(e,n=o=>o,i){if(!e)return"";if(i!=null&&i.gujiMarkdown)return Ph(e)?kc(dc(e,{jzMaxLength:i.jzMaxLength}),n,0,i.t??vn("zh-Hant")):n(e);if(e.indexOf("<")<0)return n(e);const o=[];let s=0,a=0;for(const l of yc(e))l.start>s&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s,l.start))},a++)),o.push(t.jsx("span",{className:"bim-jiazhu",style:vc,children:n(l.inner)},a++)),s=l.end;return s<e.length&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s))},a++)),o}function og({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 sg({title:e,tag:n,children:i}){const{convert:o}=Pe();return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,paddingBottom:7,borderBottom:`1px solid ${r("rule-strong")}`,marginBottom:2},children:[t.jsx("span",{style:{fontSize:14.5,letterSpacing:".08em"},children:o(e)}),n&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:r("accent"),letterSpacing:".06em"},children:o(n)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column"},children:i})]})}function wc({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 ag({item:e,siblings:n,showVolumes:i=!0,fallbackNote:o}){const{t:s,convert:a}=te(),[l,d]=g.useState(!1),c=Si(e),p=i&&!!c&&c.expected>0,h=(e.url?bn(e.url):void 0)||a(e.name),u=n?Ql(e,n):"",m=u?`${h}(${u})`:h;return t.jsx(wc,{name:m,note:Ri(e,s)||o,href:yn(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(yo,{item:e})]}):void 0})}function yo({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 Sc({label:e,items:n}){const{convert:i}=Pe();return n.length?t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg"),letterSpacing:".08em"},children:e}),n.map((o,s)=>t.jsx(bc,{children:i(o)},s))]}):null}function lg({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(Sc,{label:i.label,items:i.items},i.label))}):null}function Lr(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function _c({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 cg({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 it({id:e,label:n,onNavigate:i,renderLink:o,style:s,dense:a}){const l=rt();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 dg({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 $c="guji-table-v1";function pg(e){return!!e&&e.table_notation===$c}const ug=/^:::table(?:\{[^}]*\})?[ \t]*$/,mg=/^:::[ \t]*$/;function Cc(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=lc(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 hg=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function gg(e){if(e==="^")return{cont:!0};const n=hg.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 zc(e,n=1){const i=[],o=[],s=[];let a=[];e.forEach((d,c)=>{const p=c+n+1;let h=d.trim();if(!h)return;let u=!1;h.startsWith("!")&&(u=!0,h=h.slice(1));const m=Cc(h).map(gg),f=a.map($=>$>0),x=a.map($=>$>0?$-1:0),k=[];let y=0;for(const $ of m){if($.cont){f[y]||i.push(`第 ${p} 行第 ${y+1} 列:续格 ^ 上方没有跨行格`),y+=1;continue}const{cell:b}=$;for(let w=y;w<y+b.colspan;w++)if(f[w]){i.push(`第 ${p} 行第 ${w+1} 列:此处被上方跨行格占住,应写 ^`);break}if(b.rowspan>1)for(let w=y;w<y+b.colspan;w++)x[w]=b.rowspan-1;k.push(b),y+=b.colspan}for(let $=y;$<f.length;$++)f[$]&&i.push(`第 ${p} 行第 ${$+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let $=0;$<x.length;$++)x[$]===void 0&&(x[$]=0);a=x,o.push({header:u,cells:k}),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 jo(e){const n=e.split(`
1275
+ ${Vh}`;function Rn({children:e,style:n,wide:i,grid:o}){return t.jsxs("div",{className:"bim-d-page",style:n,children:[t.jsx("style",{children:gc}),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 Er({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 yo({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 Rr({items:e}){const n=rt();return t.jsx(t.Fragment,{children:e.map((i,o)=>{const s=o===e.length-1,a=o>0&&t.jsx("span",{style:{color:r("hint-fg")},children:"/"},`s${o}`),l=i.id?n(i.id):i.href,d=s||!i.onClick&&!l?t.jsx("span",{style:{color:r("ink")},children:i.label},o):t.jsx("a",{href:l??"#",onClick:i.onClick?c=>{c.metaKey||c.ctrlKey||(c.preventDefault(),i.onClick())}:void 0,style:{color:r("meta-fg")},children:i.label},o);return t.jsxs(g.Fragment,{children:[a,d]},o)})})}function fc({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 Kh({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 Xh({items:e,horizontal:n}){const{convert:i}=Pe();return e.length?t.jsx("div",{style:{borderLeft:`2px solid ${r("accent")}`,paddingLeft:16,display:n?"grid":"flex",gridTemplateColumns:n?"repeat(auto-fit, minmax(150px, max-content))":void 0,flexDirection:n?void 0:"column",gap:n?"14px 40px":10,fontSize:13},children:e.map((o,s)=>t.jsxs("div",{title:o.title,style:n?{display:"flex",flexDirection:"column",gap:3}:{display:"flex",justifyContent:"space-between",gap:10},children:[t.jsx("span",{className:"bim-d-ui",style:{color:r("label-fg"),letterSpacing:".08em",flex:"none"},children:i(o.label)}),t.jsx("span",{style:{color:r("body-fg"),textAlign:n?"left":"right",minWidth:0},children:o.value})]},s))}):null}function Zh({glyph:e,tone:n,title:i,count:o,actions:s,id:a}){const{convert:l}=Pe();return t.jsxs("div",{id:a,style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",justifyContent:"space-between",gap:"10px 16px",marginBottom:14,scrollMarginTop:16},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx(yo,{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 xc({label:e,active:n,onClick:i,dashed:o}){const{convert:s}=Pe();return t.jsx("button",{type:"button",onClick:i,"aria-pressed":n,className:"bim-d-ui",style:{padding:"5px 13px",border:`1px ${o&&!n?"dashed":"solid"} ${r(n?"accent":"rule")}`,background:n?r("accent"):"transparent",color:r(n?"page-bg":"meta-fg"),fontSize:12,cursor:"pointer",letterSpacing:".04em",lineHeight:1.4},children:s(e)})}function Jh({label:e,onClick:n}){const{convert:i}=Pe();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg"),borderBottom:`1px solid ${r("rule")}`},children:i(e)})}function Qh({label:e,onClick:n,inline:i}){const{convert:o}=Pe();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{marginTop:i?0:12,width:i?void 0:"100%",padding:i?"4px 12px":9,background:"none",border:`1px dashed ${r("rule-dashed")}`,cursor:"pointer",fontSize:12,color:r("meta-fg"),letterSpacing:i?void 0:".08em"},children:o(e)})}function bc({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 eg({children:e}){return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e})}function tg({volumes:e,unit:n,max:i=60}){const{t:o}=ne(),s=n??o("unit.volume"),[a,l]=g.useState(!1);if(!e.length)return null;const d=a?e:e.slice(0,i);return t.jsxs("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,fontSize:11.5},children:[d.map(c=>t.jsx("span",{style:{minWidth:30,textAlign:"center",padding:"2px 5px",border:`1px solid ${r("rule")}`,color:r("meta-fg")},children:c},c)),!a&&e.length>i&&t.jsxs("button",{type:"button",onClick:()=>l(!0),style:{padding:"2px 8px",background:"none",cursor:"pointer",border:`1px dashed ${r("rule-dashed")}`,fontFamily:"inherit",fontSize:11.5,color:r("meta-fg")},children:["+",e.length-i]}),t.jsx("span",{style:{padding:"2px 6px",color:r("hint-fg")},children:s})]})}function ng({children:e}){return t.jsx("div",{style:{borderTop:`1px solid ${r("rule-strong")}`},children:e})}function ig({spec:e}){const{convert:n}=Pe();return t.jsxs("div",{className:"bim-d-thead bim-d-ui",style:{display:"grid",gridTemplateColumns:`${e.leadWidth}px 1fr ${e.metaWidth}px`,gap:12,padding:"7px 4px",borderBottom:`1px solid ${r("rule-strong")}`,fontSize:11,color:r("label-fg"),letterSpacing:".1em"},children:[t.jsx("span",{}),t.jsx("span",{children:n(e.mainLabel)}),t.jsx("span",{style:{display:"grid",gridTemplateColumns:e.columns.map(i=>i.width).join(" "),gap:12},children:e.columns.map(i=>t.jsx("span",{children:n(i.label)},i.label))})]})}function rg({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 og(e){return String(e+1).padStart(2,"0")}function sg(){return t.jsx("span",{style:{color:r("hint-fg")},children:"—"})}function ag({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 yc(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(`
1276
+ `)||(n.push({start:i,end:l+1,inner:d}),i=l)}return n}function jc(e,n){if(e.length<=n)return e;let i=n;for(const o of yc(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 vc={fontSize:".78em",color:r("meta-fg"),lineHeight:1.55},lg={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 kc(e,n,i,o){return e.map((s,a)=>{switch(s.type){case"text":return t.jsx(g.Fragment,{children:n(s.text)},a);case"jz":return t.jsx("span",{className:"bim-jiazhu",style:i===0?vc:void 0,children:kc(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:lg,children:s.label},a)}})}function yt(e,n=o=>o,i){if(!e)return"";if(i!=null&&i.gujiMarkdown)return Fh(e)?kc(dc(e,{jzMaxLength:i.jzMaxLength}),n,0,i.t??vn("zh-Hant")):n(e);if(e.indexOf("<")<0)return n(e);const o=[];let s=0,a=0;for(const l of yc(e))l.start>s&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s,l.start))},a++)),o.push(t.jsx("span",{className:"bim-jiazhu",style:vc,children:n(l.inner)},a++)),s=l.end;return s<e.length&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s))},a++)),o}function cg({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 dg({title:e,tag:n,children:i}){const{convert:o}=Pe();return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,paddingBottom:7,borderBottom:`1px solid ${r("rule-strong")}`,marginBottom:2},children:[t.jsx("span",{style:{fontSize:14.5,letterSpacing:".08em"},children:o(e)}),n&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:r("accent"),letterSpacing:".06em"},children:o(n)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column"},children:i})]})}function wc({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 pg({item:e,siblings:n,showVolumes:i=!0,fallbackNote:o}){const{t:s,convert:a}=ne(),[l,d]=g.useState(!1),c=Si(e),p=i&&!!c&&c.expected>0,h=(e.url?bn(e.url):void 0)||a(e.name),u=n?Ql(e,n):"",m=u?`${h}(${u})`:h;return t.jsx(wc,{name:m,note:Ri(e,s)||o,href:yn(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(jo,{item:e})]}):void 0})}function jo({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 Sc({label:e,items:n}){const{convert:i}=Pe();return n.length?t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg"),letterSpacing:".08em"},children:e}),n.map((o,s)=>t.jsx(bc,{children:i(o)},s))]}):null}function ug({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(Sc,{label:i.label,items:i.items},i.label))}):null}function Lr(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function _c({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 mg({children:e,action:n}){return t.jsxs("div",{className:"bim-d-ui",style:{padding:"18px 4px",fontSize:12.5,color:r("aux-fg"),borderBottom:`1px solid ${r("rule")}`,display:"flex",flexWrap:"wrap",alignItems:"center",gap:12},children:[t.jsx("span",{children:e}),n]})}function et({id:e,label:n,onNavigate:i,renderLink:o,style:s,dense:a}){const l=rt();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 hg({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 $c="guji-table-v1";function gg(e){return!!e&&e.table_notation===$c}const fg=/^:::table(?:\{[^}]*\})?[ \t]*$/,xg=/^:::[ \t]*$/;function Cc(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=lc(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 bg=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function yg(e){if(e==="^")return{cont:!0};const n=bg.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 zc(e,n=1){const i=[],o=[],s=[];let a=[];e.forEach((d,c)=>{const p=c+n+1;let h=d.trim();if(!h)return;let u=!1;h.startsWith("!")&&(u=!0,h=h.slice(1));const m=Cc(h).map(yg),f=a.map($=>$>0),x=a.map($=>$>0?$-1:0),k=[];let y=0;for(const $ of m){if($.cont){f[y]||i.push(`第 ${p} 行第 ${y+1} 列:续格 ^ 上方没有跨行格`),y+=1;continue}const{cell:b}=$;for(let w=y;w<y+b.colspan;w++)if(f[w]){i.push(`第 ${p} 行第 ${w+1} 列:此处被上方跨行格占住,应写 ^`);break}if(b.rowspan>1)for(let w=y;w<y+b.colspan;w++)x[w]=b.rowspan-1;k.push(b),y+=b.colspan}for(let $=y;$<f.length;$++)f[$]&&i.push(`第 ${p} 行第 ${$+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let $=0;$<x.length;$++)x[$]===void 0&&(x[$]=0);a=x,o.push({header:u,cells:k}),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 vo(e){const n=e.split(`
1270
1277
  `),i=[];let o=[];const s=()=>{if(o.length===0)return;const l=o.join(`
1271
- `);o=[],i.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(ug.test(n[a].trim())){let l=a+1;for(;l<n.length&&!mg.test(n[l].trim());)l++;if(l<n.length){s();const d=n.slice(a+1,l);i.push({type:"table",table:zc(d,a+1),source:n.slice(a,l+1).join(`
1272
- `)}),a=l+1;continue}}o.push(n[a]),a++}return s(),i.map((l,d)=>{var p,h;if(l.type!=="text")return l;let c=l.text;return((p=i[d-1])==null?void 0:p.type)==="table"&&(c=c.replace(/^\n+/,"")),((h=i[d+1])==null?void 0:h.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(l=>l.type!=="text"||l.text!=="")}const fg={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},xg={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},bg=`1px solid ${r("table-border")}`,Tc={border:bg,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},yg={...Tc,background:r("table-head-bg"),fontWeight:600};function vo({table:e,opts:n}){return t.jsx("div",{className:"bim-guji-table-wrap",style:fg,children:t.jsx("table",{className:"bim-guji-table",style:xg,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?yg:Tc,children:s.empty?null:yt(s.text,void 0,n)},a)})},o))})})})}function jg(e,n){return e.indexOf("**")<0?yt(e,void 0,n):e.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((o,s)=>s%2===1?t.jsx("strong",{children:yt(o.trim().slice(2,-2),void 0,n)},s):t.jsx(g.Fragment,{children:yt(o,void 0,n)},s))}function vg(e,n,i=!1){const o=i?{gujiMarkdown:!0}:void 0;return n?jo(e).map((s,a)=>s.type==="table"?t.jsx(vo,{table:s.table,opts:o},a):t.jsx(g.Fragment,{children:jg(s.text,o)},a)):yt(e,void 0,o)}const kg=/^(#{1,6})\s+(.*)$/,wg=/^\*\*([^*\n]+)\*\*\s*$/;function ko(e){const n=e.match(kg);if(n)return{level:n[1].length,text:n[2].trim()};const i=e.trim().match(wg);return i?{level:3,text:i[1].trim()}:null}const wo=/^<!--.*-->$/;function Nc(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function Ic(e){return e.split(`
1273
- `).map(n=>n.trim()).filter(n=>n&&!wo.test(n))}const Sg=60;function Ec(e){let n=0,i=0;for(const o of e.split(`
1274
- `)){const s=o.trim();if(!s||wo.test(s)||ko(s))continue;const a=s.replace(/<[^<>\n]*>/g,"").replace(/\s/g,"").length;n+=a,a>Sg&&(i+=a)}return n>0&&i*2>=n}function _g(e){return e.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function Pi(e){if(e=_g(e),Ec(e))return"unknown";const n=Nc(e);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const i=n.map(s=>Ic(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 $g(e){const n=e.split(`
1278
+ `);o=[],i.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(fg.test(n[a].trim())){let l=a+1;for(;l<n.length&&!xg.test(n[l].trim());)l++;if(l<n.length){s();const d=n.slice(a+1,l);i.push({type:"table",table:zc(d,a+1),source:n.slice(a,l+1).join(`
1279
+ `)}),a=l+1;continue}}o.push(n[a]),a++}return s(),i.map((l,d)=>{var p,h;if(l.type!=="text")return l;let c=l.text;return((p=i[d-1])==null?void 0:p.type)==="table"&&(c=c.replace(/^\n+/,"")),((h=i[d+1])==null?void 0:h.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(l=>l.type!=="text"||l.text!=="")}const jg={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},vg={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},kg=`1px solid ${r("table-border")}`,Tc={border:kg,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},wg={...Tc,background:r("table-head-bg"),fontWeight:600};function ko({table:e,opts:n}){return t.jsx("div",{className:"bim-guji-table-wrap",style:jg,children:t.jsx("table",{className:"bim-guji-table",style:vg,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?wg:Tc,children:s.empty?null:yt(s.text,void 0,n)},a)})},o))})})})}function Sg(e,n){return e.indexOf("**")<0?yt(e,void 0,n):e.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((o,s)=>s%2===1?t.jsx("strong",{children:yt(o.trim().slice(2,-2),void 0,n)},s):t.jsx(g.Fragment,{children:yt(o,void 0,n)},s))}function _g(e,n,i=!1){const o=i?{gujiMarkdown:!0}:void 0;return n?vo(e).map((s,a)=>s.type==="table"?t.jsx(ko,{table:s.table,opts:o},a):t.jsx(g.Fragment,{children:Sg(s.text,o)},a)):yt(e,void 0,o)}const $g=/^(#{1,6})\s+(.*)$/,Cg=/^\*\*([^*\n]+)\*\*\s*$/;function wo(e){const n=e.match($g);if(n)return{level:n[1].length,text:n[2].trim()};const i=e.trim().match(Cg);return i?{level:3,text:i[1].trim()}:null}const So=/^<!--.*-->$/;function Nc(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function Ic(e){return e.split(`
1280
+ `).map(n=>n.trim()).filter(n=>n&&!So.test(n))}const zg=60;function Ec(e){let n=0,i=0;for(const o of e.split(`
1281
+ `)){const s=o.trim();if(!s||So.test(s)||wo(s))continue;const a=s.replace(/<[^<>\n]*>/g,"").replace(/\s/g,"").length;n+=a,a>zg&&(i+=a)}return n>0&&i*2>=n}function Tg(e){return e.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function Pi(e){if(e=Tg(e),Ec(e))return"unknown";const n=Nc(e);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const i=n.map(s=>Ic(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 Ng(e){const n=e.split(`
1275
1282
  `),i=[];let o=null,s=[];const a=()=>{i.push({heading:o,body:s.join(`
1276
- `)}),s=[]};for(const l of n){const d=ko(l);if(d){a(),o={kind:"heading",level:d.level,text:d.text};continue}s.push(l)}return a(),i}function na(e){const n=[];for(const i of e.split(`
1277
- `)){const o=ko(i);if(o){n.push({kind:"heading",level:o.level,text:o.text});continue}const s=i.trim();!s||wo.test(s)||n.push({kind:"body",text:i})}return n}function Rc(e){if(!e)return[];const n=Pi(e);if(n==="unknown")return na(e);const i=[];for(const{heading:o,body:s}of $g(e)){o&&i.push(o);const a=Nc(s);if(a.length!==0){if(Ec(s)){i.push(...na(s));continue}if(n==="record"){const l=a.join(" ");l&&i.push({kind:"body",text:l})}else for(const l of a){const d=Ic(l);d.length&&i.push({kind:"body",text:d.join(" ")})}}}return i}const Cg={"「":"“","」":"”","『":"‘","』":"’"},zg={"“":"「","”":"」","‘":"『","’":"』"},Tg=new Set(["《","》","〈","〉"]);function Lc(e,n){const i=n.quoteStyle==="modern"?Cg:n.quoteStyle==="classic"?zg:null;let o="";for(const s of e)n.hideBookBrackets&&Tg.has(s)||(o+=(i==null?void 0:i[s])??s);return o}const Ac=e=>e;function So(e){return e.showWorks?e.bookTitleStyle==="bracket"?"bracket":Zm(e.properNameMode)?"wavy":"bracket":"none"}function Mc(e,n=Ac,i="wavy"){if(e.indexOf("《")<0)return n(e);const o=[],s=/《([^《》\n]+)》/g;let a=0,l=0,d;for(;d=s.exec(e);){d.index>a&&o.push(t.jsx(g.Fragment,{children:n(e.slice(a,d.index))},l++));const c=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-sr",children:"《"}),n(d[1]),t.jsx("span",{className:"bim-rd-sr",children:"》"})]});o.push(i==="wavy"?t.jsx("span",{className:"bim-rd-pn",children:c},l++):t.jsx(g.Fragment,{children:c},l++)),a=d.index+d[0].length}return a===0?n(e):(a<e.length&&o.push(t.jsx(g.Fragment,{children:n(e.slice(a))},l++)),o)}function Bi(e,n={}){let i=n.renderText??Ac;const o=n.quoteStyle;if(o&&o!=="original"){const d=i;i=c=>d(Lc(c,{quoteStyle:o}))}const s=n.bookMarking??(n.properNames?"wavy":"bracket"),a=s==="bracket"?i:d=>Mc(d,i,s),l=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return yt(e,a,l)}function ia(e,n,i){return e.indexOf("**")<0?n(e):e.split(/(\*\*[^*]+\*\*)/g).map((s,a)=>s.startsWith("**")&&s.endsWith("**")&&s.length>4?t.jsx("strong",{children:n(s.slice(2,-2))},`${i}-${a}`):t.jsx(g.Fragment,{children:n(s)},`${i}-${a}`))}const pr=/^(#{1,6})\s+(.*)$/,Ng=/^\s*<!--.*-->\s*$/;function Pc(e){return e.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
1278
- `)?"":n)}function Ig(e){return e<=1?2:e===2?3:4}function Eg(){let e=1;return n=>{const i=Ig(n),o=Math.min(i,e+1);return e=o,{Tag:`h${o}`,className:`bim-rd-hl${i}`}}}function ji(e){return e?Pi(Pc(e))!=="unknown":!1}function Rg(e){return/^\u3000{2}/.test(e)}const ra=e=>Rg(e)?"bim-rd-noindent":void 0;function oa({text:e,mode:n,inline:i,dropTitle:o,onStart:s}){s==null||s();const a=Pc(e),l=(h,u,m)=>!!o&&m<=1&&h<=2&&u.trim()===o.trim(),d=Eg();if(n==="paragraph"&&Pi(a)!=="unknown"){const h=Rc(a);return t.jsx(t.Fragment,{children:h.map((u,m)=>{if(u.kind==="heading"){if(l(u.level??1,u.text,m))return null;const{Tag:f,className:x}=d(u.level??1);return t.jsx(f,{className:x,children:i(u.text)},m)}return t.jsx("p",{className:ra(u.text),children:ia(u.text,i,m)},m)})})}const c=a.split(`
1279
- `);let p=0;return t.jsx(t.Fragment,{children:c.map((h,u)=>{const m=h.match(pr);if(m){const x=p++;if(l(m[1].length,m[2],x))return null;const{Tag:k,className:y}=d(m[1].length);return t.jsx(k,{className:y,children:i(m[2])},u)}if(!h.trim())return u>=2&&!!c[u-1].trim()&&!!c[u-2].trim()&&!pr.test(c[u-1])&&!pr.test(c[u-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},u):null;if(Ng.test(h))return null;if(p++,/^\*\*[^*]+\*\*\s*$/.test(h.trim())){const{Tag:x,className:k}=d(3);return t.jsx(x,{className:k,children:i(h.trim().slice(2,-2))},u)}return t.jsx("p",{className:ra(h),children:ia(h,i,u)},u)})})}function Lg(e){const{convert:n}=Pe();return g.useMemo(()=>e?n(e):"",[e,n])}function _o({text:e,mode:n,tables:i=!1,gujiMarkdown:o=!1,properNames:s=!1,bookMarking:a,quoteStyle:l,renderText:d,dropTitle:c}){const p=Lg(e),{t:h,convert:u}=te();let m=null;const f=!!d&&!lh(e,p,!l||l==="original"),x=d&&f?w=>d(w,{mdStart:m==null?void 0:m.align(w)}):d,k=f?()=>{m=uh(e)}:void 0,y=w=>Bi(w,{renderText:x,properNames:s,bookMarking:a,quoteStyle:l,gujiMarkdown:o,t:h}),$=o?{gujiMarkdown:!0,t:h}:void 0,b=c?u(c):void 0;return!i||p.indexOf(":::")<0?t.jsx(oa,{text:p,mode:n,inline:y,dropTitle:b,onStart:k}):t.jsx(t.Fragment,{children:jo(p).map((w,v)=>w.type==="table"?t.jsx(vo,{table:w.table,opts:$},v):t.jsx(oa,{text:w.text,mode:n,inline:y,dropTitle:v===0?b:void 0},v))})}const sa={work:"work",book:"work",people:"people",person:"people",place:"place",office:"office",dynasty:"dynasty",reign:"reign"};function Ag(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(sa,e)&&sa[e]||"other"}function Ar(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 Gt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function nt(e){return typeof e=="string"&&e?e:void 0}function Mg(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={};nt(s.entity_id)!==void 0&&(a.entity_id=nt(s.entity_id)),nt(s.canonical_name)!==void 0&&(a.canonical_name=nt(s.canonical_name)),Gt(s.confidence)!==void 0&&(a.confidence=Gt(s.confidence)),i.push(a)}return i}const un=e=>e.start!==void 0&&e.end!==void 0;function Bc(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=Gt(l.start_offset)??Gt(a.start_offset),p=Gt(l.end_offset)??Gt(a.end_offset),h=c!==void 0&&p!==void 0&&c>=0&&p>c,u=a.anchor??{},m=nt(u.start),f=nt(u.end);if(!h&&!!!(m&&f))return;const k=nt(d.status),y=k===void 0||k==="matched"?Ar(nt(d.entity_id))??Ar(nt(d.href))??void 0:void 0,$=Gt(d.confidence),b=Mg(a.ambiguous);i.push({...m&&f?{anchor:{start:m,end:f}}:{},key:nt(a.id)??`e${s}`,kind:Ag(a.type),...h?{start:c,end:p}:{},text:nt(a.text),targetId:y,canonicalName:nt(d.canonical_name),confidence:Gt(a.confidence)??$,...$!==void 0?{targetConfidence:$}:{},...nt(d.level)!==void 0?{targetLevel:nt(d.level)}:{},...nt(d.note)!==void 0?{targetNote:nt(d.note)}:{},...nt(a.group)!==void 0?{group:nt(a.group)}:{},...b!==void 0?{candidates:b}:{}})}),i.sort((o,s)=>!un(o)||!un(s)?+!un(o)-+!un(s):o.start-s.start||s.end-o.end)}const Pg=new Set(Array.from(`《》/<>\r
1280
-  ,。、;:?!「」『』()…—·`));function $o(e){return!Pg.has(e)}function Wc(e,n,i=0){const o=[],s=Array.from(e);let a=0;for(const d of s)$o(d)&&o.push(a),a+=d.length;const l=[];for(const d of n){if(!un(d))continue;const c=d.start-i,p=d.end-i;if(c<0||p>o.length||p<=c)continue;const h=o[p-1],u=e.codePointAt(h)>65535?2:1;l.push({...d,start:o[c],end:h+u})}return l}function Bg(e,n){return n.text?Array.from(e.slice(n.start,n.end)).filter($o).join("")===n.text:!0}function Wg(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 Oc(e,n,i=16){const o=[];for(const l of n){if(!un(l))continue;let d={...l,start:Math.max(0,l.start),end:Math.min(e.length,l.end)};(d.end<=d.start||!Bg(e,d))&&(d=Wg(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 Og={off:[],lite:["people","place","dynasty"],full:["people","place","dynasty","office","reign","other"]};function Fg(e,n,i){const o=(i==null?void 0:i.showWorks)!==!1,s=new Set(Og[n]);return e.filter(a=>a.kind==="work"?o:s.has(a.kind))}function Hg(e,n,i){const[o,s]=g.useState(null),[a,l]=g.useState(!1),d=g.useRef(0);return g.useEffect(()=>{const c=++d.current;if(!e||!n){s(null),l(!1);return}let p;try{p=e(n,i)}catch{s(null),l(!1);return}if(!p||typeof p.then!="function"){s(p??null),l(!1);return}l(!0),p.then(h=>{c===d.current&&s(h??null)}).catch(()=>{c===d.current&&s(null)}).finally(()=>{c===d.current&&l(!1)})},[e,n,i]),{images:o,loading:a}}function Dg(e){return typeof e!="string"?null:e==="published"?"source":Object.prototype.hasOwnProperty.call(Qp,e)?e:null}function Ug(e){if(e==="none")return{color:r("quality-none"),fontWeight:400};if(e==="placeholder")return{color:r("quality-placeholder"),fontWeight:400}}const Vg={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释",tally:"小计"},Fc="\0";function Gg(e,n,i){const[o,s=""]=e.split(Fc);return t.jsxs(t.Fragment,{children:[o,t.jsx(Al,{text:n,convert:i}),s]})}function kt(e){return typeof e!="string"?"":Vg[e]??e}const Yg=["〇","一","二","三","四","五","六","七","八","九"],aa=["","十","百","千"],qg=["","萬","億"];function Co(e){if(e===0)return"〇";if(e<0)return`負${Co(-e)}`;const n=[];let i=e,o=0;for(;i>0;){const s=i%1e4;s>0?n.unshift(Kg(s,o>0)+qg[o]):n.length>0&&n.unshift("〇"),i=Math.floor(i/1e4),o++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Kg(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+=aa[d]:s+=Yg[l]+aa[d]}return s.replace(/〇$/,"")}let Pn=null,ai=null;const vi=new Set;function Xg(){return Pn?Promise.resolve():ai||(ai=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});Pn=i=>n(ke.normalizeVariants(i)),vi.forEach(i=>i())}).catch(()=>{Pn=e=>e,vi.forEach(e=>e())}),ai)}const Zg=e=>e;function an(){const[,e]=g.useState(0);return g.useEffect(()=>{if(Pn)return;const n=()=>e(i=>i+1);return vi.add(n),Xg(),()=>{vi.delete(n)}},[]),Pn??Zg}function xn(e,n){return n(e).toLowerCase()}const Jg=r("highlight-bg");function Vn(e,n,i){if(!n)return e;const o=xn(n,i);if(!o)return e;const s=xn(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,k)=>{d.set(c,k),c+=x.length});const p=Array.from(o).length,h=[];let u=0,m=0,f=0;for(;u<a.length;){const x=s.indexOf(o,m),k=x===-1?void 0:d.get(x);if(x===-1){h.push(a.slice(u).join(""));break}if(k===void 0){m=x+1;continue}k>u&&h.push(a.slice(u,k).join("")),h.push(t.jsx("mark",{style:{background:Jg,padding:0,color:"inherit"},children:a.slice(k,k+p).join("")},f++)),u=k+p,m=x+o.length}return t.jsx(t.Fragment,{children:h})}function zo(e,n,i,o){if(!n)return!0;const s=xn(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"&&xn(l,o).includes(s))}function Qg(e,n,i){return n?xn(e,i).includes(xn(n,i)):!0}const To={类:r("section-lei"),书:r("section-shu"),序:r("section-xu"),结语:r("section-jieyu"),注释:r("section-zhushi")},ef={考证:r("section-kaozhen")};function No(e,n,i){return e.collated.sectionType[n]??i(n)}function Hc(e){var o;const n=e.files.length,i=((o=e.children)==null?void 0:o.reduce((s,a)=>s+Hc(a),0))||0;return n+i}function tf(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 nf={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function Io({enabled:e,expanded:n,onClick:i,style:o,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:i,style:{...nf,...o},children:s}):t.jsx("span",{style:o,children:s})}function rf({type:e}){const{convert:n,messages:i}=te(),o=kt(e),s=To[o]||r("desc-fg");return t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:s,border:`1px solid ${s}40`,borderRadius:"2px",background:`${s}08`,flexShrink:0},children:No(i,o,n)})}function of({section:e,onNavigate:n,highlightQuery:i="",no:o,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=te(),c=rt(),p=an(),h=w=>w?yt(d(w),v=>i?Vn(v,i,p):v,{t:l}):"",[u,m]=g.useState(!1),f=!!e.summary,x=!!e.comment,k=!!e.additional_comment,y=!!(e.content&&e.content.length>60),$=f||x||k||y;g.useEffect(()=>{i&&m(!0)},[i]);const b=!u&&y?jc(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:()=>$&&m(!u),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:$?"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(Io,{enabled:$,expanded:u,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[$&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),transition:"transform 0.15s",transform:u?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1,minWidth:0},children:[t.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg")},children:[e.book_title?t.jsxs(t.Fragment,{children:["《",h(e.book_title),"》"]}):h(e.title),e.n_juan!=null&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:l("collated.nJuan",{n:d(Co(e.n_juan))})}),(e.author_info||e.author)&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"8px"},children:h(e.author_info||e.author)})]}),!u&&b&&t.jsx("span",{style:{display:"block",fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:h(b)})]})]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:h(e.edition)}),e.tag&&t.jsx("span",{style:{fontSize:"11px",color:r("section-tag-fg")},children:e.tag==="triangle"?"△":e.tag}),e.work_id&&n&&t.jsx("a",{href:c(e.work_id),onClick:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),w.stopPropagation(),n(e.work_id))},style:{fontSize:"11px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:l("collated.viewWork"),"aria-label":l("collated.viewWorkOf",{title:d(e.book_title||e.title)}),children:l("collated.workArrow")}),s&&!e.work_id&&t.jsx("span",{style:{fontSize:"11px",color:r("label-fg"),flexShrink:0},children:l("collated.unlinked")})]}),u&&$&&t.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${r("widget-border")}`,background:r("bg")},children:[e.author_info&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"8px"},children:h(e.author_info)}),e.summary&&t.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.summary")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:h(e.summary)})]}),e.comment&&t.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.comment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:h(e.comment)})]}),e.additional_comment&&t.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.additionalComment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:h(e.additional_comment)})]}),y&&!f&&!x&&!k&&t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:h(e.content)})]})]})}function sf({section:e,highlightQuery:n=""}){const{t:i,convert:o}=te(),s=an(),a=p=>p?yt(o(p),h=>n?Vn(h,n,s):h,{t:i}):"",[l,d]=g.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(Io,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(rf,{type:e.type}),t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:r("fg")},children:a(e.title)}),c&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),transition:"transform 0.15s",transform:l?"rotate(90deg)":"none",display:"inline-block"},children:"▶"})]}),l&&c&&t.jsx("div",{style:{marginTop:"8px",padding:"10px 14px",borderLeft:`3px solid color-mix(in srgb, ${To[kt(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 af=100;function Eo(e){return kt(e.type)!=="page_header"?!1:(e.content||"").length>=af}function lf({section:e,highlightQuery:n=""}){const{t:i,convert:o,messages:s}=te(),a=an();if(kt(e.type)==="page_header"&&!Eo(e)||!e.content&&!e.title)return null;const l=o((e.content||e.title||"").replace(/\n{2,}/g,`
1281
- `)),d=yt(l,u=>n?Vn(u,n,a):u,{t:i}),c=kt(e.type),p=To[c]||r("desc-fg"),h=c==="序"||c==="结语"||c==="注释";return t.jsxs("div",{style:{padding:h?"10px 12px":"6px 0",margin:h?"8px 0":void 0,fontSize:"13px",color:r("desc-fg"),lineHeight:1.8,whiteSpace:"pre-line",borderLeft:h?`3px solid ${p}40`:void 0,background:h?r("bg"):void 0,borderRadius:h?"0 4px 4px 0":void 0,position:"relative"},children:[h&&t.jsx("span",{style:{display:"inline-block",fontSize:"10px",fontWeight:500,color:p,marginRight:"8px",padding:"1px 5px",border:`1px solid ${p}40`,borderRadius:"2px",background:`${p}08`,verticalAlign:"middle"},children:No(s,c,o)}),d]})}function cf(e,n,i){const[o,s]=g.useState({});return g.useEffect(()=>{var p;if(!n||e.length===0)return;let a=!1;const l=e.filter(h=>{var u;return!((u=i==null?void 0:i.current)!=null&&u.has(h))}),d={};for(const h of e)(p=i==null?void 0:i.current)!=null&&p.has(h)&&(d[h]=i.current.get(h));if(Object.keys(d).length>0&&s(d),l.length===0)return;const c=async h=>{var u;try{if(n.getEntry){const y=await n.getEntry(h);if(y)return{title:y.title,author:y.author}}const m=await n.getItem(h);if(!m)return null;const f=m.title||h,x=m.authors,k=(u=x==null?void 0:x[0])==null?void 0:u.name;return{title:f,author:k}}catch{return null}};return Promise.all(l.map(async h=>{var m;const u=await c(h);return(m=i==null?void 0:i.current)==null||m.set(h,u),[h,u]})).then(h=>{a||s(u=>{const m={...u};for(const[f,x]of h)m[f]=x;return m})}),()=>{a=!0}},[e.join(","),n]),o}function df({section:e,onNavigate:n,transport:i,workLabelCache:o,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=te(),c=rt(),p=an(),h=v=>v?yt(l(v),j=>s?Vn(j,s,p):j,{t:a}):"",[u,m]=g.useState(!1);g.useEffect(()=>{s&&m(!0)},[s]);const f=kt(e.type),x=ef[f]||r("desc-fg"),k=!!e.content,y=e.work_ids||[],$=y.length>1,b=cf($?y:[],i,o),w=k&&!u&&e.content.length>80?jc(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${r("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>k&&m(!u),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:k?"pointer":"default",userSelect:"none"},children:[t.jsxs(Io,{enabled:k,expanded:u,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[k&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:u?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg"),lineHeight:1.6},children:e.header_line?h(e.header_line):h(e.title)}),!u&&w&&t.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:r("desc-fg"),lineHeight:1.7},children:h(w)})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[y.length===1&&n&&t.jsx("a",{href:c(y[0]),onClick:v=>{v.metaKey||v.ctrlKey||(v.preventDefault(),v.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")}),$&&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:No(d,f,l)})]})]}),$&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:y.map(v=>{const j=b[v],C=j?`${l(j.title)}${j.author?`(${l(j.author)})`:""}`:v.slice(0,8)+"…";return t.jsxs("a",{href:c(v),onClick:S=>{S.metaKey||S.ctrlKey||(S.preventDefault(),S.stopPropagation(),n(v))},style:{fontSize:"12px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:v,children:["→",C]},v)})}),u&&k&&t.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${x}40`,borderRadius:"0 4px 4px 0",background:r("bg")},children:[t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:h(e.content)}),e.comment&&t.jsx("div",{style:{marginTop:"10px",paddingTop:"8px",borderTop:`1px solid ${r("widget-border")}`,fontSize:"12px",color:r("desc-fg"),lineHeight:1.8,fontStyle:"italic"},children:h(e.comment)})]})]})}function pf({juan:e,searchQuery:n,onNavigate:i,transport:o,workLabelCache:s}){const{t:a}=te(),l=an(),d=n.trim(),c=g.useMemo(()=>d?e.sections.filter(p=>zo(p,d,!0,l)):e.sections,[e.sections,d,l]);return t.jsxs("div",{children:[t.jsx("div",{children:c.map((p,h)=>t.jsx(df,{section:p,onNavigate:i,transport:o,workLabelCache:s,highlightQuery:d},h))}),c.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:a("collated.noMatch")})]})}function uf(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function mf({sections:e,onNavigate:n,inline:i,workLinks:o=!0}){const s=rt(),{t:a,convert:l}=te(),d=uf();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const h=kt(c.type);if(h==="page_header"&&!Eo(c))return null;if(h==="类")return t.jsxs(g.Fragment,{children:[g.createElement(d("类"),null,i(l(c.title))),c.content&&t.jsx("p",{children:i(l(c.content))})]},p);if(h==="书"||h==="诗"||h==="考证"||h==="注释"){const u=c.book_title?`《${c.book_title}》${c.n_juan!=null?a("collated.nJuan",{n:Co(c.n_juan)}):""}`:c.title,m=i(l(u));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[g.createElement(d("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&o?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},title:a("collated.viewWork"),children:m}),t.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},"aria-label":a("collated.viewWorkOf",{title:l(u)}),children:a("collated.workArrow")})]}):m),c.author_info&&t.jsx("p",{className:"bim-rd-sub",children:i(l(c.author_info))}),c.content&&c.content.split(/\n+/).map((f,x)=>t.jsx("p",{children:i(l(f))},x)),c.summary&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.summary")}),i(l(c.summary))]}),c.comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.comment")}),i(l(c.comment))]}),c.additional_comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.additionalComment")}),i(l(c.additional_comment))]})]},p)}return h==="小计"&&c.title?t.jsx("p",{children:i(l(c.title))},p):c.content?t.jsx("p",{children:i(l(c.content))},p):null})})}function Dc(e){return e.some(n=>{const i=kt(n.type);return i==="书"||i==="诗"||i==="考证"||i==="注释"||i==="类"||(i==="序"||i==="结语")&&!!n.content||i==="page_header"&&Eo(n)})}function hf({juan:e,rawText:n,positionLabel:i,groupLabel:o,index:s,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c,prefs:p,view:h,onViewChange:u}){var G;const{t:m,convert:f,messages:x}=te(),k=an(),[y,$]=g.useState("text"),b=h??y,w=q=>{$(q),u==null||u(q)},v=a.trim(),j=(s==null?void 0:s.type)==="kaozhen",C=g.useCallback(q=>v?Vn(q,v,k):q,[v,k]),S=So(p),_=q=>Bi(q,{renderText:C,bookMarking:S,quoteStyle:p.quoteStyle,t:m}),L=g.useMemo(()=>v?e.sections.filter(q=>zo(q,v,j,k)):e.sections,[e.sections,v,j,k]),T=(q,ce)=>ce.filter(we=>kt(we.type)===q).length,z=T("书",e.sections),M=T("诗",e.sections),H=T("考证",e.sections);let N="";j?N=v?m("collated.countTiaoOf",{m:T("考证",L),n:H}):m("collated.countTiao",{n:H}):M>0?N=v?m("collated.countPoemsOf",{m:T("诗",L),n:M}):m("collated.countPoems",{n:M}):z>0&&(N=v?m("collated.countBooksOf",{m:T("书",L),n:z}):m("collated.countBooks",{n:z}));const R=s!=null&&s.text_quality?Dg(s.text_quality.grade):null,A=[];if(N&&A.push(N),j&&(s!=null&&s.target_source)&&A.push(t.jsx(t.Fragment,{children:m("collated.kaozhenTarget",{target:f(s.target_source)})})),R){const q=t.jsx("span",{className:"bim-rd-grade",style:Ug(R),children:x.collated.qualityLabel[R]});A.push(t.jsx("span",{title:x.collated.qualityCriteria[R],children:(G=s==null?void 0:s.text_quality)!=null&&G.source_note?t.jsxs(t.Fragment,{children:[Gg(m("collated.baseText",{note:Fc}),s.text_quality.source_note,f),q]}):t.jsxs(t.Fragment,{children:[m("collated.textQuality"),q]})}))}e.source_url&&A.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:m("collated.originalSource")}));const J=!j&&Dc(e.sections),ee=!!n&&(!J||p.readingMode==="paragraph"&&ji(n)),oe=!j&&(J||!!n),V=j||!oe?"entries":b;let me=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)}),A.length>0&&t.jsx("p",{className:"bim-rd-meta",children:A.map((q,ce)=>t.jsxs(g.Fragment,{children:[ce>0&&t.jsx("span",{className:"bim-rd-dot"}),q]},ce))}),oe&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":m("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":V==="text",onClick:()=>w("text"),children:m("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":V==="entries",onClick:()=>w("entries"),children:m("collated.viewEntries")})]})]}),V==="text"&&t.jsx("article",{className:"bim-rd-prose",children:ee?t.jsx(_o,{text:n,mode:p.readingMode,bookMarking:S,quoteStyle:p.quoteStyle,renderText:C,dropTitle:e.title}):t.jsx(mf,{sections:e.sections,onNavigate:l,inline:_,workLinks:p.workLinks})}),V==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:j?t.jsx(pf,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[L.some(q=>["书","诗","考证"].includes(kt(q.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:m("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:m("collated.rowHeadTitle")}),t.jsx("span",{children:m("collated.rowHeadWork")})]}),L.map((q,ce)=>{const we=kt(q.type);return we==="书"||we==="诗"||we==="考证"?(me+=1,t.jsx(of,{domId:`rd-e-${e.sections.indexOf(q)}`,section:q,onNavigate:p.workLinks?l:void 0,highlightQuery:v,no:me,showUnlinked:p.workLinks&&!!l},ce)):we==="类"?t.jsx(sf,{section:q,highlightQuery:v},ce):t.jsx(lf,{section:q,highlightQuery:v},ce)}),L.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:m("collated.noMatch")})]})})]})}function gf(e){const{resetKey:n,load:i,files:o,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=an(),h=g.useRef(new Map),[u,m]=g.useState({}),[f,x]=g.useState({}),k=g.useCallback(($,b)=>{const w=b==null?void 0:b.title;w&&x(v=>v[$]===w?v:{...v,[$]:w})},[]);g.useEffect(()=>{s&&a&&(h.current.set(s,{juan:a,rawText:l}),k(s,a))},[s,a,l,k]),g.useEffect(()=>{h.current.clear(),m({}),x({})},[n]);const y=g.useCallback(($,b)=>{let w=0;if($.juan)for(const v of $.juan.sections)zo(v,b,c,p)&&w++;return w===0&&$.rawText&&Qg($.rawText,b,p)&&(w=1),w},[c,p]);return g.useEffect(()=>{const $=d.trim();if(!$){m({});return}if(!i||o.length===0)return;let b=!1;const w={},v=[];for(const L of o){const T=h.current.get(L);T?w[L]=y(T,$):(w[L]="loading",v.push(L))}m(w);const j=8;let C=0;const S=async()=>{for(;C<v.length;){if(b)return;const L=C++,T=v[L];try{const z=await i(T),M=z.juan;if(h.current.set(T,z),k(T,M),b)return;m(H=>({...H,[T]:y(z,$)}))}catch{if(b)return;m(z=>({...z,[T]:0}))}}},_=Array.from({length:Math.min(j,v.length)},()=>S());return Promise.all(_),()=>{b=!0}},[d,n,i,o.join(","),y,p,k]),{matchStates:u,titles:f}}function ff({juan:e,view:n,onView:i,textHasEntries:o}){const{t:s,convert:a}=te(),l=e.sections.map((h,u)=>({s:h,i:u,t:kt(h.type)})).filter(h=>h.t==="书"||h.t==="诗");if(l.length===0)return null;const d=l.filter(h=>!!h.s.work_id).length,c=l.every(h=>h.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),p=h=>{const u=()=>{var m,f;return(f=(m=document.getElementById(`rd-e-${h}`))==null?void 0:m.scrollIntoView)==null?void 0:f.call(m,{block:"start",behavior:"smooth"})};n==="text"&&!o&&i("entries"),n==="text"&&!o?setTimeout(u,0):u()};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-rd-rail-card",children:[t.jsx("div",{className:"bim-rd-rail-cap",children:s("collated.railCap")}),t.jsxs("div",{className:"bim-rd-rail-n",children:[t.jsx("b",{children:l.length}),t.jsx("span",{children:c}),t.jsx("span",{className:"bim-rd-rail-linked",children:s("collated.linkedN",{n:d})})]}),t.jsx("div",{className:"bim-rd-rail-bar",role:"img","aria-label":s("collated.linkedOf",{n:d,total:l.length}),children:t.jsx("span",{style:{width:`${Math.round(d/l.length*100)}%`}})})]}),t.jsxs("nav",{"aria-label":s("collated.railEntriesNav"),children:[t.jsx("div",{className:"bim-rd-rail-cap",style:{margin:"20px 0 6px 12px"},children:s("collated.viewEntries")}),t.jsx("ul",{className:"bim-rd-rail-list",children:l.map(({s:h,i:u})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${u}`,onClick:m=>{m.preventDefault(),p(u)},children:[t.jsx("span",{className:`bim-rd-rail-dot${h.work_id?" on":""}`,"aria-hidden":"true"}),t.jsx("span",{children:Bi(a(h.book_title||h.title),{t:s})})]})},u))})]})]})}const xf=`
1283
+ `)}),s=[]};for(const l of n){const d=wo(l);if(d){a(),o={kind:"heading",level:d.level,text:d.text};continue}s.push(l)}return a(),i}function ia(e){const n=[];for(const i of e.split(`
1284
+ `)){const o=wo(i);if(o){n.push({kind:"heading",level:o.level,text:o.text});continue}const s=i.trim();!s||So.test(s)||n.push({kind:"body",text:i})}return n}function Rc(e){if(!e)return[];const n=Pi(e);if(n==="unknown")return ia(e);const i=[];for(const{heading:o,body:s}of Ng(e)){o&&i.push(o);const a=Nc(s);if(a.length!==0){if(Ec(s)){i.push(...ia(s));continue}if(n==="record"){const l=a.join(" ");l&&i.push({kind:"body",text:l})}else for(const l of a){const d=Ic(l);d.length&&i.push({kind:"body",text:d.join(" ")})}}}return i}const Ig={"「":"“","」":"”","『":"‘","』":"’"},Eg={"“":"「","”":"」","‘":"『","’":"』"},Rg=new Set(["《","》","〈","〉"]);function Lc(e,n){const i=n.quoteStyle==="modern"?Ig:n.quoteStyle==="classic"?Eg:null;let o="";for(const s of e)n.hideBookBrackets&&Rg.has(s)||(o+=(i==null?void 0:i[s])??s);return o}const Ac=e=>e;function _o(e){return e.showWorks?e.bookTitleStyle==="bracket"?"bracket":Zm(e.properNameMode)?"wavy":"bracket":"none"}function Mc(e,n=Ac,i="wavy"){if(e.indexOf("《")<0)return n(e);const o=[],s=/《([^《》\n]+)》/g;let a=0,l=0,d;for(;d=s.exec(e);){d.index>a&&o.push(t.jsx(g.Fragment,{children:n(e.slice(a,d.index))},l++));const c=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-sr",children:"《"}),n(d[1]),t.jsx("span",{className:"bim-rd-sr",children:"》"})]});o.push(i==="wavy"?t.jsx("span",{className:"bim-rd-pn",children:c},l++):t.jsx(g.Fragment,{children:c},l++)),a=d.index+d[0].length}return a===0?n(e):(a<e.length&&o.push(t.jsx(g.Fragment,{children:n(e.slice(a))},l++)),o)}function Bi(e,n={}){let i=n.renderText??Ac;const o=n.quoteStyle;if(o&&o!=="original"){const d=i;i=c=>d(Lc(c,{quoteStyle:o}))}const s=n.bookMarking??(n.properNames?"wavy":"bracket"),a=s==="bracket"?i:d=>Mc(d,i,s),l=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return yt(e,a,l)}function ra(e,n,i){return e.indexOf("**")<0?n(e):e.split(/(\*\*[^*]+\*\*)/g).map((s,a)=>s.startsWith("**")&&s.endsWith("**")&&s.length>4?t.jsx("strong",{children:n(s.slice(2,-2))},`${i}-${a}`):t.jsx(g.Fragment,{children:n(s)},`${i}-${a}`))}const pr=/^(#{1,6})\s+(.*)$/,Lg=/^\s*<!--.*-->\s*$/;function Pc(e){return e.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
1285
+ `)?"":n)}function Ag(e){return e<=1?2:e===2?3:4}function Mg(){let e=1;return n=>{const i=Ag(n),o=Math.min(i,e+1);return e=o,{Tag:`h${o}`,className:`bim-rd-hl${i}`}}}function ji(e){return e?Pi(Pc(e))!=="unknown":!1}function Pg(e){return/^\u3000{2}/.test(e)}const oa=e=>Pg(e)?"bim-rd-noindent":void 0;function sa({text:e,mode:n,inline:i,dropTitle:o,onStart:s}){s==null||s();const a=Pc(e),l=(h,u,m)=>!!o&&m<=1&&h<=2&&u.trim()===o.trim(),d=Mg();if(n==="paragraph"&&Pi(a)!=="unknown"){const h=Rc(a);return t.jsx(t.Fragment,{children:h.map((u,m)=>{if(u.kind==="heading"){if(l(u.level??1,u.text,m))return null;const{Tag:f,className:x}=d(u.level??1);return t.jsx(f,{className:x,children:i(u.text)},m)}return t.jsx("p",{className:oa(u.text),children:ra(u.text,i,m)},m)})})}const c=a.split(`
1286
+ `);let p=0;return t.jsx(t.Fragment,{children:c.map((h,u)=>{const m=h.match(pr);if(m){const x=p++;if(l(m[1].length,m[2],x))return null;const{Tag:k,className:y}=d(m[1].length);return t.jsx(k,{className:y,children:i(m[2])},u)}if(!h.trim())return u>=2&&!!c[u-1].trim()&&!!c[u-2].trim()&&!pr.test(c[u-1])&&!pr.test(c[u-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},u):null;if(Lg.test(h))return null;if(p++,/^\*\*[^*]+\*\*\s*$/.test(h.trim())){const{Tag:x,className:k}=d(3);return t.jsx(x,{className:k,children:i(h.trim().slice(2,-2))},u)}return t.jsx("p",{className:oa(h),children:ra(h,i,u)},u)})})}function Bg(e){const{convert:n}=Pe();return g.useMemo(()=>e?n(e):"",[e,n])}function $o({text:e,mode:n,tables:i=!1,gujiMarkdown:o=!1,properNames:s=!1,bookMarking:a,quoteStyle:l,renderText:d,dropTitle:c}){const p=Bg(e),{t:h,convert:u}=ne();let m=null;const f=!!d&&!lh(e,p,!l||l==="original"),x=d&&f?w=>d(w,{mdStart:m==null?void 0:m.align(w)}):d,k=f?()=>{m=uh(e)}:void 0,y=w=>Bi(w,{renderText:x,properNames:s,bookMarking:a,quoteStyle:l,gujiMarkdown:o,t:h}),$=o?{gujiMarkdown:!0,t:h}:void 0,b=c?u(c):void 0;return!i||p.indexOf(":::")<0?t.jsx(sa,{text:p,mode:n,inline:y,dropTitle:b,onStart:k}):t.jsx(t.Fragment,{children:vo(p).map((w,v)=>w.type==="table"?t.jsx(ko,{table:w.table,opts:$},v):t.jsx(sa,{text:w.text,mode:n,inline:y,dropTitle:v===0?b:void 0},v))})}const aa={work:"work",book:"work",people:"people",person:"people",place:"place",office:"office",dynasty:"dynasty",reign:"reign"};function Og(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(aa,e)&&aa[e]||"other"}function Ar(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 Gt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function it(e){return typeof e=="string"&&e?e:void 0}function Wg(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={};it(s.entity_id)!==void 0&&(a.entity_id=it(s.entity_id)),it(s.canonical_name)!==void 0&&(a.canonical_name=it(s.canonical_name)),Gt(s.confidence)!==void 0&&(a.confidence=Gt(s.confidence)),i.push(a)}return i}const un=e=>e.start!==void 0&&e.end!==void 0;function Bc(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=Gt(l.start_offset)??Gt(a.start_offset),p=Gt(l.end_offset)??Gt(a.end_offset),h=c!==void 0&&p!==void 0&&c>=0&&p>c,u=a.anchor??{},m=it(u.start),f=it(u.end);if(!h&&!!!(m&&f))return;const k=it(d.status),y=k===void 0||k==="matched"?Ar(it(d.entity_id))??Ar(it(d.href))??void 0:void 0,$=Gt(d.confidence),b=Wg(a.ambiguous);i.push({...m&&f?{anchor:{start:m,end:f}}:{},key:it(a.id)??`e${s}`,kind:Og(a.type),...h?{start:c,end:p}:{},text:it(a.text),targetId:y,canonicalName:it(d.canonical_name),confidence:Gt(a.confidence)??$,...$!==void 0?{targetConfidence:$}:{},...it(d.level)!==void 0?{targetLevel:it(d.level)}:{},...it(d.note)!==void 0?{targetNote:it(d.note)}:{},...it(a.group)!==void 0?{group:it(a.group)}:{},...b!==void 0?{candidates:b}:{}})}),i.sort((o,s)=>!un(o)||!un(s)?+!un(o)-+!un(s):o.start-s.start||s.end-o.end)}const Fg=new Set(Array.from(`《》/<>\r
1287
+  ,。、;:?!「」『』()…—·`));function Co(e){return!Fg.has(e)}function Oc(e,n,i=0){const o=[],s=Array.from(e);let a=0;for(const d of s)Co(d)&&o.push(a),a+=d.length;const l=[];for(const d of n){if(!un(d))continue;const c=d.start-i,p=d.end-i;if(c<0||p>o.length||p<=c)continue;const h=o[p-1],u=e.codePointAt(h)>65535?2:1;l.push({...d,start:o[c],end:h+u})}return l}function Hg(e,n){return n.text?Array.from(e.slice(n.start,n.end)).filter(Co).join("")===n.text:!0}function Dg(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 Wc(e,n,i=16){const o=[];for(const l of n){if(!un(l))continue;let d={...l,start:Math.max(0,l.start),end:Math.min(e.length,l.end)};(d.end<=d.start||!Hg(e,d))&&(d=Dg(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 Ug={off:[],lite:["people","place","dynasty"],full:["people","place","dynasty","office","reign","other"]};function Vg(e,n,i){const o=(i==null?void 0:i.showWorks)!==!1,s=new Set(Ug[n]);return e.filter(a=>a.kind==="work"?o:s.has(a.kind))}function Gg(e,n,i){const[o,s]=g.useState(null),[a,l]=g.useState(!1),d=g.useRef(0);return g.useEffect(()=>{const c=++d.current;if(!e||!n){s(null),l(!1);return}let p;try{p=e(n,i)}catch{s(null),l(!1);return}if(!p||typeof p.then!="function"){s(p??null),l(!1);return}l(!0),p.then(h=>{c===d.current&&s(h??null)}).catch(()=>{c===d.current&&s(null)}).finally(()=>{c===d.current&&l(!1)})},[e,n,i]),{images:o,loading:a}}function Yg(e){return typeof e!="string"?null:e==="published"?"source":Object.prototype.hasOwnProperty.call(Qp,e)?e:null}function qg(e){if(e==="none")return{color:r("quality-none"),fontWeight:400};if(e==="placeholder")return{color:r("quality-placeholder"),fontWeight:400}}const Kg={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释",tally:"小计"},Fc="\0";function Xg(e,n,i){const[o,s=""]=e.split(Fc);return t.jsxs(t.Fragment,{children:[o,t.jsx(Al,{text:n,convert:i}),s]})}function kt(e){return typeof e!="string"?"":Kg[e]??e}const Zg=["〇","一","二","三","四","五","六","七","八","九"],la=["","十","百","千"],Jg=["","萬","億"];function zo(e){if(e===0)return"〇";if(e<0)return`負${zo(-e)}`;const n=[];let i=e,o=0;for(;i>0;){const s=i%1e4;s>0?n.unshift(Qg(s,o>0)+Jg[o]):n.length>0&&n.unshift("〇"),i=Math.floor(i/1e4),o++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Qg(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+=la[d]:s+=Zg[l]+la[d]}return s.replace(/〇$/,"")}let Pn=null,ai=null;const vi=new Set;function ef(){return Pn?Promise.resolve():ai||(ai=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});Pn=i=>n(ke.normalizeVariants(i)),vi.forEach(i=>i())}).catch(()=>{Pn=e=>e,vi.forEach(e=>e())}),ai)}const tf=e=>e;function an(){const[,e]=g.useState(0);return g.useEffect(()=>{if(Pn)return;const n=()=>e(i=>i+1);return vi.add(n),ef(),()=>{vi.delete(n)}},[]),Pn??tf}function xn(e,n){return n(e).toLowerCase()}const nf=r("highlight-bg");function Vn(e,n,i){if(!n)return e;const o=xn(n,i);if(!o)return e;const s=xn(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,k)=>{d.set(c,k),c+=x.length});const p=Array.from(o).length,h=[];let u=0,m=0,f=0;for(;u<a.length;){const x=s.indexOf(o,m),k=x===-1?void 0:d.get(x);if(x===-1){h.push(a.slice(u).join(""));break}if(k===void 0){m=x+1;continue}k>u&&h.push(a.slice(u,k).join("")),h.push(t.jsx("mark",{style:{background:nf,padding:0,color:"inherit"},children:a.slice(k,k+p).join("")},f++)),u=k+p,m=x+o.length}return t.jsx(t.Fragment,{children:h})}function To(e,n,i,o){if(!n)return!0;const s=xn(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"&&xn(l,o).includes(s))}function rf(e,n,i){return n?xn(e,i).includes(xn(n,i)):!0}const No={类:r("section-lei"),书:r("section-shu"),序:r("section-xu"),结语:r("section-jieyu"),注释:r("section-zhushi")},of={考证:r("section-kaozhen")};function Io(e,n,i){return e.collated.sectionType[n]??i(n)}function Hc(e){var o;const n=e.files.length,i=((o=e.children)==null?void 0:o.reduce((s,a)=>s+Hc(a),0))||0;return n+i}function sf(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 af={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function Eo({enabled:e,expanded:n,onClick:i,style:o,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:i,style:{...af,...o},children:s}):t.jsx("span",{style:o,children:s})}function lf({type:e}){const{convert:n,messages:i}=ne(),o=kt(e),s=No[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:Io(i,o,n)})}function cf({section:e,onNavigate:n,highlightQuery:i="",no:o,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=ne(),c=rt(),p=an(),h=w=>w?yt(d(w),v=>i?Vn(v,i,p):v,{t:l}):"",[u,m]=g.useState(!1),f=!!e.summary,x=!!e.comment,k=!!e.additional_comment,y=!!(e.content&&e.content.length>60),$=f||x||k||y;g.useEffect(()=>{i&&m(!0)},[i]);const b=!u&&y?jc(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:()=>$&&m(!u),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:$?"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(Eo,{enabled:$,expanded:u,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[$&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),transition:"transform 0.15s",transform:u?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1,minWidth:0},children:[t.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg")},children:[e.book_title?t.jsxs(t.Fragment,{children:["《",h(e.book_title),"》"]}):h(e.title),e.n_juan!=null&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:l("collated.nJuan",{n:d(zo(e.n_juan))})}),(e.author_info||e.author)&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"8px"},children:h(e.author_info||e.author)})]}),!u&&b&&t.jsx("span",{style:{display:"block",fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:h(b)})]})]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:h(e.edition)}),e.tag&&t.jsx("span",{style:{fontSize:"11px",color:r("section-tag-fg")},children:e.tag==="triangle"?"△":e.tag}),e.work_id&&n&&t.jsx("a",{href:c(e.work_id),onClick:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),w.stopPropagation(),n(e.work_id))},style:{fontSize:"11px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:l("collated.viewWork"),"aria-label":l("collated.viewWorkOf",{title:d(e.book_title||e.title)}),children:l("collated.workArrow")}),s&&!e.work_id&&t.jsx("span",{style:{fontSize:"11px",color:r("label-fg"),flexShrink:0},children:l("collated.unlinked")})]}),u&&$&&t.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${r("widget-border")}`,background:r("bg")},children:[e.author_info&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"8px"},children:h(e.author_info)}),e.summary&&t.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.summary")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:h(e.summary)})]}),e.comment&&t.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.comment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:h(e.comment)})]}),e.additional_comment&&t.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.additionalComment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:h(e.additional_comment)})]}),y&&!f&&!x&&!k&&t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:h(e.content)})]})]})}function df({section:e,highlightQuery:n=""}){const{t:i,convert:o}=ne(),s=an(),a=p=>p?yt(o(p),h=>n?Vn(h,n,s):h,{t:i}):"",[l,d]=g.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(Eo,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(lf,{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, ${No[kt(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 pf=100;function Ro(e){return kt(e.type)!=="page_header"?!1:(e.content||"").length>=pf}function uf({section:e,highlightQuery:n=""}){const{t:i,convert:o,messages:s}=ne(),a=an();if(kt(e.type)==="page_header"&&!Ro(e)||!e.content&&!e.title)return null;const l=o((e.content||e.title||"").replace(/\n{2,}/g,`
1288
+ `)),d=yt(l,u=>n?Vn(u,n,a):u,{t:i}),c=kt(e.type),p=No[c]||r("desc-fg"),h=c==="序"||c==="结语"||c==="注释";return t.jsxs("div",{style:{padding:h?"10px 12px":"6px 0",margin:h?"8px 0":void 0,fontSize:"13px",color:r("desc-fg"),lineHeight:1.8,whiteSpace:"pre-line",borderLeft:h?`3px solid ${p}40`:void 0,background:h?r("bg"):void 0,borderRadius:h?"0 4px 4px 0":void 0,position:"relative"},children:[h&&t.jsx("span",{style:{display:"inline-block",fontSize:"10px",fontWeight:500,color:p,marginRight:"8px",padding:"1px 5px",border:`1px solid ${p}40`,borderRadius:"2px",background:`${p}08`,verticalAlign:"middle"},children:Io(s,c,o)}),d]})}function mf(e,n,i){const[o,s]=g.useState({});return g.useEffect(()=>{var p;if(!n||e.length===0)return;let a=!1;const l=e.filter(h=>{var u;return!((u=i==null?void 0:i.current)!=null&&u.has(h))}),d={};for(const h of e)(p=i==null?void 0:i.current)!=null&&p.has(h)&&(d[h]=i.current.get(h));if(Object.keys(d).length>0&&s(d),l.length===0)return;const c=async h=>{var u;try{if(n.getEntry){const y=await n.getEntry(h);if(y)return{title:y.title,author:y.author}}const m=await n.getItem(h);if(!m)return null;const f=m.title||h,x=m.authors,k=(u=x==null?void 0:x[0])==null?void 0:u.name;return{title:f,author:k}}catch{return null}};return Promise.all(l.map(async h=>{var m;const u=await c(h);return(m=i==null?void 0:i.current)==null||m.set(h,u),[h,u]})).then(h=>{a||s(u=>{const m={...u};for(const[f,x]of h)m[f]=x;return m})}),()=>{a=!0}},[e.join(","),n]),o}function hf({section:e,onNavigate:n,transport:i,workLabelCache:o,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=ne(),c=rt(),p=an(),h=v=>v?yt(l(v),j=>s?Vn(j,s,p):j,{t:a}):"",[u,m]=g.useState(!1);g.useEffect(()=>{s&&m(!0)},[s]);const f=kt(e.type),x=of[f]||r("desc-fg"),k=!!e.content,y=e.work_ids||[],$=y.length>1,b=mf($?y:[],i,o),w=k&&!u&&e.content.length>80?jc(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${r("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>k&&m(!u),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:k?"pointer":"default",userSelect:"none"},children:[t.jsxs(Eo,{enabled:k,expanded:u,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[k&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:u?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg"),lineHeight:1.6},children:e.header_line?h(e.header_line):h(e.title)}),!u&&w&&t.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:r("desc-fg"),lineHeight:1.7},children:h(w)})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[y.length===1&&n&&t.jsx("a",{href:c(y[0]),onClick:v=>{v.metaKey||v.ctrlKey||(v.preventDefault(),v.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")}),$&&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:Io(d,f,l)})]})]}),$&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:y.map(v=>{const j=b[v],C=j?`${l(j.title)}${j.author?`(${l(j.author)})`:""}`:v.slice(0,8)+"…";return t.jsxs("a",{href:c(v),onClick:S=>{S.metaKey||S.ctrlKey||(S.preventDefault(),S.stopPropagation(),n(v))},style:{fontSize:"12px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:v,children:["→",C]},v)})}),u&&k&&t.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${x}40`,borderRadius:"0 4px 4px 0",background:r("bg")},children:[t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:h(e.content)}),e.comment&&t.jsx("div",{style:{marginTop:"10px",paddingTop:"8px",borderTop:`1px solid ${r("widget-border")}`,fontSize:"12px",color:r("desc-fg"),lineHeight:1.8,fontStyle:"italic"},children:h(e.comment)})]})]})}function gf({juan:e,searchQuery:n,onNavigate:i,transport:o,workLabelCache:s}){const{t:a}=ne(),l=an(),d=n.trim(),c=g.useMemo(()=>d?e.sections.filter(p=>To(p,d,!0,l)):e.sections,[e.sections,d,l]);return t.jsxs("div",{children:[t.jsx("div",{children:c.map((p,h)=>t.jsx(hf,{section:p,onNavigate:i,transport:o,workLabelCache:s,highlightQuery:d},h))}),c.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:a("collated.noMatch")})]})}function ff(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function xf({sections:e,onNavigate:n,inline:i,workLinks:o=!0}){const s=rt(),{t:a,convert:l}=ne(),d=ff();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const h=kt(c.type);if(h==="page_header"&&!Ro(c))return null;if(h==="类")return t.jsxs(g.Fragment,{children:[g.createElement(d("类"),null,i(l(c.title))),c.content&&t.jsx("p",{children:i(l(c.content))})]},p);if(h==="书"||h==="诗"||h==="考证"||h==="注释"){const u=c.book_title?`《${c.book_title}》${c.n_juan!=null?a("collated.nJuan",{n:zo(c.n_juan)}):""}`:c.title,m=i(l(u));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[g.createElement(d("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&o?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},title:a("collated.viewWork"),children:m}),t.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},"aria-label":a("collated.viewWorkOf",{title:l(u)}),children:a("collated.workArrow")})]}):m),c.author_info&&t.jsx("p",{className:"bim-rd-sub",children:i(l(c.author_info))}),c.content&&c.content.split(/\n+/).map((f,x)=>t.jsx("p",{children:i(l(f))},x)),c.summary&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.summary")}),i(l(c.summary))]}),c.comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.comment")}),i(l(c.comment))]}),c.additional_comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.additionalComment")}),i(l(c.additional_comment))]})]},p)}return h==="小计"&&c.title?t.jsx("p",{children:i(l(c.title))},p):c.content?t.jsx("p",{children:i(l(c.content))},p):null})})}function Dc(e){return e.some(n=>{const i=kt(n.type);return i==="书"||i==="诗"||i==="考证"||i==="注释"||i==="类"||(i==="序"||i==="结语")&&!!n.content||i==="page_header"&&Ro(n)})}function bf({juan:e,rawText:n,positionLabel:i,groupLabel:o,index:s,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c,prefs:p,view:h,onViewChange:u}){var G;const{t:m,convert:f,messages:x}=ne(),k=an(),[y,$]=g.useState("text"),b=h??y,w=ee=>{$(ee),u==null||u(ee)},v=a.trim(),j=(s==null?void 0:s.type)==="kaozhen",C=g.useCallback(ee=>v?Vn(ee,v,k):ee,[v,k]),S=_o(p),_=ee=>Bi(ee,{renderText:C,bookMarking:S,quoteStyle:p.quoteStyle,t:m}),A=g.useMemo(()=>v?e.sections.filter(ee=>To(ee,v,j,k)):e.sections,[e.sections,v,j,k]),T=(ee,ae)=>ae.filter(Se=>kt(Se.type)===ee).length,z=T("书",e.sections),M=T("诗",e.sections),H=T("考证",e.sections);let I="";j?I=v?m("collated.countTiaoOf",{m:T("考证",A),n:H}):m("collated.countTiao",{n:H}):M>0?I=v?m("collated.countPoemsOf",{m:T("诗",A),n:M}):m("collated.countPoems",{n:M}):z>0&&(I=v?m("collated.countBooksOf",{m:T("书",A),n:z}):m("collated.countBooks",{n:z}));const R=s!=null&&s.text_quality?Yg(s.text_quality.grade):null,P=[];if(I&&P.push(I),j&&(s!=null&&s.target_source)&&P.push(t.jsx(t.Fragment,{children:m("collated.kaozhenTarget",{target:f(s.target_source)})})),R){const ee=t.jsx("span",{className:"bim-rd-grade",style:qg(R),children:x.collated.qualityLabel[R]});P.push(t.jsx("span",{title:x.collated.qualityCriteria[R],children:(G=s==null?void 0:s.text_quality)!=null&&G.source_note?t.jsxs(t.Fragment,{children:[Xg(m("collated.baseText",{note:Fc}),s.text_quality.source_note,f),ee]}):t.jsxs(t.Fragment,{children:[m("collated.textQuality"),ee]})}))}e.source_url&&P.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:m("collated.originalSource")}));const K=!j&&Dc(e.sections),te=!!n&&(!K||p.readingMode==="paragraph"&&ji(n)),ie=!j&&(K||!!n),U=j||!ie?"entries":b;let pe=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)}),P.length>0&&t.jsx("p",{className:"bim-rd-meta",children:P.map((ee,ae)=>t.jsxs(g.Fragment,{children:[ae>0&&t.jsx("span",{className:"bim-rd-dot"}),ee]},ae))}),ie&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":m("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":U==="text",onClick:()=>w("text"),children:m("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":U==="entries",onClick:()=>w("entries"),children:m("collated.viewEntries")})]})]}),U==="text"&&t.jsx("article",{className:"bim-rd-prose",children:te?t.jsx($o,{text:n,mode:p.readingMode,bookMarking:S,quoteStyle:p.quoteStyle,renderText:C,dropTitle:e.title}):t.jsx(xf,{sections:e.sections,onNavigate:l,inline:_,workLinks:p.workLinks})}),U==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:j?t.jsx(gf,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[A.some(ee=>["书","诗","考证"].includes(kt(ee.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:m("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:m("collated.rowHeadTitle")}),t.jsx("span",{children:m("collated.rowHeadWork")})]}),A.map((ee,ae)=>{const Se=kt(ee.type);return Se==="书"||Se==="诗"||Se==="考证"?(pe+=1,t.jsx(cf,{domId:`rd-e-${e.sections.indexOf(ee)}`,section:ee,onNavigate:p.workLinks?l:void 0,highlightQuery:v,no:pe,showUnlinked:p.workLinks&&!!l},ae)):Se==="类"?t.jsx(df,{section:ee,highlightQuery:v},ae):t.jsx(uf,{section:ee,highlightQuery:v},ae)}),A.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:m("collated.noMatch")})]})})]})}function yf(e){const{resetKey:n,load:i,files:o,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=an(),h=g.useRef(new Map),[u,m]=g.useState({}),[f,x]=g.useState({}),k=g.useCallback(($,b)=>{const w=b==null?void 0:b.title;w&&x(v=>v[$]===w?v:{...v,[$]:w})},[]);g.useEffect(()=>{s&&a&&(h.current.set(s,{juan:a,rawText:l}),k(s,a))},[s,a,l,k]),g.useEffect(()=>{h.current.clear(),m({}),x({})},[n]);const y=g.useCallback(($,b)=>{let w=0;if($.juan)for(const v of $.juan.sections)To(v,b,c,p)&&w++;return w===0&&$.rawText&&rf($.rawText,b,p)&&(w=1),w},[c,p]);return g.useEffect(()=>{const $=d.trim();if(!$){m({});return}if(!i||o.length===0)return;let b=!1;const w={},v=[];for(const A of o){const T=h.current.get(A);T?w[A]=y(T,$):(w[A]="loading",v.push(A))}m(w);const j=8;let C=0;const S=async()=>{for(;C<v.length;){if(b)return;const A=C++,T=v[A];try{const z=await i(T),M=z.juan;if(h.current.set(T,z),k(T,M),b)return;m(H=>({...H,[T]:y(z,$)}))}catch{if(b)return;m(z=>({...z,[T]:0}))}}},_=Array.from({length:Math.min(j,v.length)},()=>S());return Promise.all(_),()=>{b=!0}},[d,n,i,o.join(","),y,p,k]),{matchStates:u,titles:f}}function jf({juan:e,view:n,onView:i,textHasEntries:o}){const{t:s,convert:a}=ne(),l=e.sections.map((h,u)=>({s:h,i:u,t:kt(h.type)})).filter(h=>h.t==="书"||h.t==="诗");if(l.length===0)return null;const d=l.filter(h=>!!h.s.work_id).length,c=l.every(h=>h.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),p=h=>{const u=()=>{var m,f;return(f=(m=document.getElementById(`rd-e-${h}`))==null?void 0:m.scrollIntoView)==null?void 0:f.call(m,{block:"start",behavior:"smooth"})};n==="text"&&!o&&i("entries"),n==="text"&&!o?setTimeout(u,0):u()};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-rd-rail-card",children:[t.jsx("div",{className:"bim-rd-rail-cap",children:s("collated.railCap")}),t.jsxs("div",{className:"bim-rd-rail-n",children:[t.jsx("b",{children:l.length}),t.jsx("span",{children:c}),t.jsx("span",{className:"bim-rd-rail-linked",children:s("collated.linkedN",{n:d})})]}),t.jsx("div",{className:"bim-rd-rail-bar",role:"img","aria-label":s("collated.linkedOf",{n:d,total:l.length}),children:t.jsx("span",{style:{width:`${Math.round(d/l.length*100)}%`}})})]}),t.jsxs("nav",{"aria-label":s("collated.railEntriesNav"),children:[t.jsx("div",{className:"bim-rd-rail-cap",style:{margin:"20px 0 6px 12px"},children:s("collated.viewEntries")}),t.jsx("ul",{className:"bim-rd-rail-list",children:l.map(({s:h,i:u})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${u}`,onClick:m=>{m.preventDefault(),p(u)},children:[t.jsx("span",{className:`bim-rd-rail-dot${h.work_id?" on":""}`,"aria-hidden":"true"}),t.jsx("span",{children:Bi(a(h.book_title||h.title),{t:s})})]})},u))})]})]})}const vf=`
1282
1289
  attribute vec2 a_position; // 目标画布像素坐标 [0, canvasWidth] x [0, canvasHeight]
1283
1290
  attribute vec2 a_texCoord; // 原图像素坐标 [0, imgWidth] x [0, imgHeight]
1284
1291
 
@@ -1296,7 +1303,7 @@ ${Fh}`;function Rn({children:e,style:n,wide:i,grid:o}){return t.jsxs("div",{clas
1296
1303
  // 纹理坐标归一化 [0, 1]
1297
1304
  v_texCoord = a_texCoord / u_imgResolution;
1298
1305
  }
1299
- `,bf=`
1306
+ `,kf=`
1300
1307
  precision mediump float;
1301
1308
  uniform sampler2D u_image;
1302
1309
  uniform float u_alpha;
@@ -1306,7 +1313,7 @@ ${Fh}`;function Rn({children:e,style:n,wide:i,grid:o}){return t.jsxs("div",{clas
1306
1313
  vec4 tex = texture2D(u_image, v_texCoord);
1307
1314
  gl_FragColor = vec4(tex.rgb, tex.a * u_alpha);
1308
1315
  }
1309
- `;function la(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 Mr{constructor(n){const i=n.getContext("webgl",{alpha:!0,antialias:!0,preserveDrawingBuffer:!0,premultipliedAlpha:!1});if(!i)throw new Error("WebGL not supported");this.gl=i;const o=la(i,i.VERTEX_SHADER,xf),s=la(i,i.FRAGMENT_SHADER,bf);if(!o||!s)throw new Error("Failed to create shaders");const a=i.createProgram();if(!a)throw new Error("Failed to create program");if(i.attachShader(a,o),i.attachShader(a,s),i.linkProgram(a),!i.getProgramParameter(a,i.LINK_STATUS))throw new Error("Program link error: "+i.getProgramInfoLog(a));this.program=a,this.positionBuffer=i.createBuffer(),this.texCoordBuffer=i.createBuffer(),this.uResolutionLoc=i.getUniformLocation(a,"u_resolution"),this.uImgResolutionLoc=i.getUniformLocation(a,"u_imgResolution"),this.uAlphaLoc=i.getUniformLocation(a,"u_alpha"),this.aPositionLoc=i.getAttribLocation(a,"a_position"),this.aTexCoordLoc=i.getAttribLocation(a,"a_texCoord"),i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.clear(n.width,n.height)}clear(n,i){const o=this.gl;o.viewport(0,0,n,i),o.clearColor(.98,.97,.95,1),o.clear(o.COLOR_BUFFER_BIT)}createTexture(n){const i=this.gl,o=i.createTexture();return i.bindTexture(i.TEXTURE_2D,o),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,n),o}renderStripsWithTexture(n,i,o,s,a,l,d=1){if(l.length===0)return;const c=this.gl;c.viewport(0,0,i,o),c.useProgram(this.program),c.uniform2f(this.uResolutionLoc,i,o),c.uniform2f(this.uImgResolutionLoc,s,a),c.uniform1f(this.uAlphaLoc,d);const p=[],h=[],u=8;for(const m of l){const f=m.colOffsetX||0,x=m.colOffsetY||0,{srcQuad:k,dstRect:y}=m.strip,[$,b,w,v]=y,j=f+$,C=x+b,[S,_,L,T]=k;for(let z=0;z<u;z++){const M=z/u,H=(z+1)/u,N=C+v*M,R=C+v*H,A=[S[0]+(T[0]-S[0])*M,S[1]+(T[1]-S[1])*M],J=[S[0]+(T[0]-S[0])*H,S[1]+(T[1]-S[1])*H],ee=[_[0]+(L[0]-_[0])*M,_[1]+(L[1]-_[1])*M],oe=[_[0]+(L[0]-_[0])*H,_[1]+(L[1]-_[1])*H],V=[j,N],me=[j+w,N],G=[j,R],q=[j+w,R];p.push(V[0],V[1],me[0],me[1],G[0],G[1]),h.push(A[0],A[1],ee[0],ee[1],J[0],J[1]),p.push(me[0],me[1],q[0],q[1],G[0],G[1]),h.push(ee[0],ee[1],oe[0],oe[1],J[0],J[1])}}c.bindBuffer(c.ARRAY_BUFFER,this.positionBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(p),c.STATIC_DRAW),c.enableVertexAttribArray(this.aPositionLoc),c.vertexAttribPointer(this.aPositionLoc,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,this.texCoordBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(h),c.STATIC_DRAW),c.enableVertexAttribArray(this.aTexCoordLoc),c.vertexAttribPointer(this.aTexCoordLoc,2,c.FLOAT,!1,0,0),c.bindTexture(c.TEXTURE_2D,n),c.drawArrays(c.TRIANGLES,0,p.length/2)}deleteTexture(n){n&&this.gl.deleteTexture(n)}destroy(){const n=this.gl;n.deleteProgram(this.program),n.deleteBuffer(this.positionBuffer),n.deleteBuffer(this.texCoordBuffer)}}function yf(e){const[n,i]=e.image_size||[0,0];if(!(n>0)||!(i>0)||e.columns.some(m=>{var f;return(((f=m.strips)==null?void 0:f.length)??0)>0}))return null;let o=1/0,s=1/0,a=-1/0,l=-1/0;for(const m of e.columns)for(const f of m.chars){const[x,k,y,$]=f.bbox_col;![x,k,y,$].every(Number.isFinite)||!(y>x)||!($>k)||(o=Math.min(o,m.offset_x+x),s=Math.min(s,k),a=Math.max(a,m.offset_x+y),l=Math.max(l,$))}if(!(a>o)||!(l>s))return null;const d=Math.min(n,i)*.03,c=Math.min(n,Math.max(0,o-d)),p=Math.min(i,Math.max(0,s-d)),h=Math.min(n,Math.max(0,a+d))-c,u=Math.min(i,Math.max(0,l+d))-p;return!(h>0)||!(u>0)||h>=n*.98&&u>=i*.98?null:{x:c,y:p,w:h,h:u}}const Ut=new Map,jf=24;function Pr(e){let n=Ut.get(e);if(n)return Ut.delete(e),Ut.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=()=>{Ut.delete(e),i(null)},o.src=e}),Ut.set(e,n);Ut.size>jf;)Ut.delete(Ut.keys().next().value);return n}const Ro=({imageUrl:e,pageData:n,selectedCharIds:i,hoveredCharId:o,preserveMargins:s=!1,onCharClick:a,onCharHover:l})=>{const d=g.useRef(null),c=g.useRef(null),p=g.useRef(null),h=g.useRef(null),u=g.useRef(null),m=g.useRef(null),[f,x]=g.useState(0),[k,y]=g.useState(0),$=g.useRef(""),b=g.useMemo(()=>Math.max(...n.columns.map(N=>N.warped_h),2440),[n]),w=n.total_warped_w,v=n.banxin,j=g.useMemo(()=>{var V;if(!s)return{top:0,bottom:0,left:0,right:0};const[N,R]=n.image_size||[2386,3082];let A=1/0,J=-1/0,ee=1/0,oe=-1/0;for(const me of n.columns)for(const G of me.strips||[])for(const q of G.srcQuad)q[0]<A&&(A=q[0]),q[0]>J&&(J=q[0]),q[1]<ee&&(ee=q[1]),q[1]>oe&&(oe=q[1]);if((V=n.banxin)!=null&&V.current_page_strips)for(const me of n.banxin.current_page_strips)for(const G of me.srcQuad)G[0]<A&&(A=G[0]),G[0]>J&&(J=G[0]),G[1]<ee&&(ee=G[1]),G[1]>oe&&(oe=G[1]);return isFinite(A)||(A=0),isFinite(J)||(J=N),isFinite(ee)||(ee=0),isFinite(oe)||(oe=R),{top:Math.max(0,Math.round(ee)),bottom:Math.max(0,Math.round(R-oe)),left:Math.max(0,Math.round(A)),right:Math.max(0,Math.round(N-J)),rawMinX:A,rawMaxX:J,rawMinY:ee,rawMaxY:oe,imgW:N,imgH:R}},[n,s]),C=g.useMemo(()=>s?null:yf(n),[n,s]),S=w+(v?v.total_w:0),_=C?C.w:S+j.left+j.right,L=C?C.h:b+j.top+j.bottom,T=g.useCallback(()=>{const N=c.current;if(!(!N||!d.current)&&!(e&&$.current!==e)){if(N.clear(_,L),s&&j.rawMinX!==void 0&&u.current&&p.current){const{rawMinX:R,rawMaxX:A,rawMinY:J,rawMaxY:ee,imgW:oe,imgH:V,top:me,bottom:G,left:q,right:ce}=j,we=[];q>0&&we.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[R,0],[R,V],[0,V]],dstRect:[0,0,q,L]}}),me>0&&we.push({colOffsetX:q,colOffsetY:0,strip:{srcQuad:[[R,0],[A,0],[A,J],[R,J]],dstRect:[0,0,S,me]}}),G>0&&we.push({colOffsetX:q,colOffsetY:me+b,strip:{srcQuad:[[R,ee],[A,ee],[A,V],[R,V]],dstRect:[0,0,S,G]}}),ce>0&&we.push({colOffsetX:q+S,colOffsetY:0,strip:{srcQuad:[[A,0],[oe,0],[oe,V],[A,V]],dstRect:[0,0,ce,L]}}),N.renderStripsWithTexture(u.current,_,L,n.image_size[0],n.image_size[1],we,1)}if(u.current&&p.current){const R=n.columns.flatMap(A=>(A.strips||[]).map(J=>({colOffsetX:j.left+A.offset_x,colOffsetY:j.top,strip:J})));if(R.length>0?N.renderStripsWithTexture(u.current,_,L,n.image_size[0],n.image_size[1],R,1):N.renderStripsWithTexture(u.current,_,L,n.image_size[0],n.image_size[1],[{colOffsetX:0,colOffsetY:0,strip:{srcQuad:C?[[C.x,C.y],[C.x+C.w,C.y],[C.x+C.w,C.y+C.h],[C.x,C.y+C.h]]:[[0,0],[n.image_size[0],0],[n.image_size[0],n.image_size[1]],[0,n.image_size[1]]],dstRect:[0,0,_,L]}}],1),v&&v.current_page_strips.length>0){const A=v.current_page_strips.map(J=>({colOffsetX:j.left+w,colOffsetY:j.top,strip:J}));N.renderStripsWithTexture(u.current,_,L,n.image_size[0],n.image_size[1],A,1)}}if(v&&m.current&&h.current&&v.mate_page_strips.length>0){const R=v.mate_page_strips.map(A=>({colOffsetX:j.left+w+v.half_w,colOffsetY:j.top,strip:A}));N.renderStripsWithTexture(m.current,_,L,v.mate_img_size[0],v.mate_img_size[1],R,.65)}}},[e,n,v,_,L,w,b,S,j,s,C]),z=g.useRef(T);z.current=T,g.useEffect(()=>{const N=d.current;if(!N)return;const R=ee=>{u.current=p.current?ee.createTexture(p.current):null,m.current=h.current?ee.createTexture(h.current):null,z.current()};try{const ee=new Mr(N);c.current=ee,R(ee)}catch(ee){console.error("Failed to init WebGL renderer:",ee)}const A=ee=>{ee.preventDefault(),console.warn("WebGL context lost")},J=()=>{console.info("WebGL context restored, re-initializing..."),d.current&&(c.current=new Mr(d.current),R(c.current))};return N.addEventListener("webglcontextlost",A,!1),N.addEventListener("webglcontextrestored",J,!1),()=>{N.removeEventListener("webglcontextlost",A),N.removeEventListener("webglcontextrestored",J),c.current&&(c.current.deleteTexture(u.current),c.current.deleteTexture(m.current),c.current.destroy(),c.current=null)}},[]),g.useEffect(()=>{if(!e)return;let N=!0;return Pr(e).then(R=>{if(!N||!R)return;p.current=R,$.current=e;const A=c.current;A&&(A.deleteTexture(u.current),u.current=A.createTexture(R)),x(J=>J+1)}),()=>{N=!1}},[e]);const M=v==null?void 0:v.mate_image_url;g.useEffect(()=>{if(!M)return;let N=!0;return Pr(M).then(R=>{if(!N||!R)return;h.current=R;const A=c.current;A&&(A.deleteTexture(m.current),m.current=A.createTexture(R)),y(J=>J+1)}),()=>{N=!1}},[M]),g.useEffect(()=>{T()},[T,f,k]);const H=g.useMemo(()=>{const N=[];for(const R of n.columns)for(const A of R.chars){const[J,ee,oe,V]=A.bbox_col;N.push({id:A.id,char:A.char,x:j.left+R.offset_x+J-((C==null?void 0:C.x)??0),y:j.top+ee-((C==null?void 0:C.y)??0),w:Math.max(oe-J,1),h:Math.max(V-ee,1)})}return N},[n,j,C]);return t.jsxs("div",{className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${_} / ${L}`,backgroundColor:r("warp-bg"),boxShadow:r("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("canvas",{ref:d,width:_,height:L,style:{width:"100%",height:"100%",display:"block",backgroundColor:r("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${_} ${L}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[H.map(N=>{const R=i.has(N.id),A=o===N.id;return t.jsx("rect",{"data-selected":R?"true":void 0,x:N.x,y:N.y,width:N.w,height:N.h,fill:R?r("warp-sel-bg"):A?r("warp-hover-bg"):"transparent",stroke:R?r("warp-sel-stroke"):A?r("warp-hover-stroke"):"transparent",strokeWidth:R?3.5:A?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>a==null?void 0:a(N.id),onMouseEnter:()=>l==null?void 0:l(N.id),onMouseLeave:()=>l==null?void 0:l(null),children:t.jsx("title",{children:N.char})},N.id)}),v&&t.jsxs("g",{children:[t.jsx("line",{x1:j.left+w,y1:j.top,x2:j.left+w,y2:j.top+b,stroke:r("warp-banxin-border"),strokeWidth:1.5}),t.jsx("line",{x1:j.left+w+v.half_w,y1:j.top,x2:j.left+w+v.half_w,y2:j.top+b,stroke:r("warp-banxin-fold"),strokeWidth:1.5,strokeDasharray:"8 6"}),t.jsx("line",{x1:j.left+S,y1:j.top,x2:j.left+S,y2:j.top+b,stroke:r("warp-banxin-outer"),strokeWidth:1})]})]})]})},Lo=`
1316
+ `;function ca(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 Mr{constructor(n){const i=n.getContext("webgl",{alpha:!0,antialias:!0,preserveDrawingBuffer:!0,premultipliedAlpha:!1});if(!i)throw new Error("WebGL not supported");this.gl=i;const o=ca(i,i.VERTEX_SHADER,vf),s=ca(i,i.FRAGMENT_SHADER,kf);if(!o||!s)throw new Error("Failed to create shaders");const a=i.createProgram();if(!a)throw new Error("Failed to create program");if(i.attachShader(a,o),i.attachShader(a,s),i.linkProgram(a),!i.getProgramParameter(a,i.LINK_STATUS))throw new Error("Program link error: "+i.getProgramInfoLog(a));this.program=a,this.positionBuffer=i.createBuffer(),this.texCoordBuffer=i.createBuffer(),this.uResolutionLoc=i.getUniformLocation(a,"u_resolution"),this.uImgResolutionLoc=i.getUniformLocation(a,"u_imgResolution"),this.uAlphaLoc=i.getUniformLocation(a,"u_alpha"),this.aPositionLoc=i.getAttribLocation(a,"a_position"),this.aTexCoordLoc=i.getAttribLocation(a,"a_texCoord"),i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.clear(n.width,n.height)}clear(n,i){const o=this.gl;o.viewport(0,0,n,i),o.clearColor(.98,.97,.95,1),o.clear(o.COLOR_BUFFER_BIT)}createTexture(n){const i=this.gl,o=i.createTexture();return i.bindTexture(i.TEXTURE_2D,o),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,n),o}renderStripsWithTexture(n,i,o,s,a,l,d=1){if(l.length===0)return;const c=this.gl;c.viewport(0,0,i,o),c.useProgram(this.program),c.uniform2f(this.uResolutionLoc,i,o),c.uniform2f(this.uImgResolutionLoc,s,a),c.uniform1f(this.uAlphaLoc,d);const p=[],h=[],u=8;for(const m of l){const f=m.colOffsetX||0,x=m.colOffsetY||0,{srcQuad:k,dstRect:y}=m.strip,[$,b,w,v]=y,j=f+$,C=x+b,[S,_,A,T]=k;for(let z=0;z<u;z++){const M=z/u,H=(z+1)/u,I=C+v*M,R=C+v*H,P=[S[0]+(T[0]-S[0])*M,S[1]+(T[1]-S[1])*M],K=[S[0]+(T[0]-S[0])*H,S[1]+(T[1]-S[1])*H],te=[_[0]+(A[0]-_[0])*M,_[1]+(A[1]-_[1])*M],ie=[_[0]+(A[0]-_[0])*H,_[1]+(A[1]-_[1])*H],U=[j,I],pe=[j+w,I],G=[j,R],ee=[j+w,R];p.push(U[0],U[1],pe[0],pe[1],G[0],G[1]),h.push(P[0],P[1],te[0],te[1],K[0],K[1]),p.push(pe[0],pe[1],ee[0],ee[1],G[0],G[1]),h.push(te[0],te[1],ie[0],ie[1],K[0],K[1])}}c.bindBuffer(c.ARRAY_BUFFER,this.positionBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(p),c.STATIC_DRAW),c.enableVertexAttribArray(this.aPositionLoc),c.vertexAttribPointer(this.aPositionLoc,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,this.texCoordBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(h),c.STATIC_DRAW),c.enableVertexAttribArray(this.aTexCoordLoc),c.vertexAttribPointer(this.aTexCoordLoc,2,c.FLOAT,!1,0,0),c.bindTexture(c.TEXTURE_2D,n),c.drawArrays(c.TRIANGLES,0,p.length/2)}deleteTexture(n){n&&this.gl.deleteTexture(n)}destroy(){const n=this.gl;n.deleteProgram(this.program),n.deleteBuffer(this.positionBuffer),n.deleteBuffer(this.texCoordBuffer)}}function wf(e){const[n,i]=e.image_size||[0,0];if(!(n>0)||!(i>0)||e.columns.some(m=>{var f;return(((f=m.strips)==null?void 0:f.length)??0)>0}))return null;let o=1/0,s=1/0,a=-1/0,l=-1/0;for(const m of e.columns)for(const f of m.chars){const[x,k,y,$]=f.bbox_col;![x,k,y,$].every(Number.isFinite)||!(y>x)||!($>k)||(o=Math.min(o,m.offset_x+x),s=Math.min(s,k),a=Math.max(a,m.offset_x+y),l=Math.max(l,$))}if(!(a>o)||!(l>s))return null;const d=Math.min(n,i)*.03,c=Math.min(n,Math.max(0,o-d)),p=Math.min(i,Math.max(0,s-d)),h=Math.min(n,Math.max(0,a+d))-c,u=Math.min(i,Math.max(0,l+d))-p;return!(h>0)||!(u>0)||h>=n*.98&&u>=i*.98?null:{x:c,y:p,w:h,h:u}}const Ut=new Map,Sf=24;function Pr(e){let n=Ut.get(e);if(n)return Ut.delete(e),Ut.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=()=>{Ut.delete(e),i(null)},o.src=e}),Ut.set(e,n);Ut.size>Sf;)Ut.delete(Ut.keys().next().value);return n}const Lo=({imageUrl:e,pageData:n,selectedCharIds:i,hoveredCharId:o,preserveMargins:s=!1,onCharClick:a,onCharHover:l})=>{const d=g.useRef(null),c=g.useRef(null),p=g.useRef(null),h=g.useRef(null),u=g.useRef(null),m=g.useRef(null),[f,x]=g.useState(0),[k,y]=g.useState(0),$=g.useRef(""),b=g.useMemo(()=>Math.max(...n.columns.map(I=>I.warped_h),2440),[n]),w=n.total_warped_w,v=n.banxin,j=g.useMemo(()=>{var U;if(!s)return{top:0,bottom:0,left:0,right:0};const[I,R]=n.image_size||[2386,3082];let P=1/0,K=-1/0,te=1/0,ie=-1/0;for(const pe of n.columns)for(const G of pe.strips||[])for(const ee of G.srcQuad)ee[0]<P&&(P=ee[0]),ee[0]>K&&(K=ee[0]),ee[1]<te&&(te=ee[1]),ee[1]>ie&&(ie=ee[1]);if((U=n.banxin)!=null&&U.current_page_strips)for(const pe of n.banxin.current_page_strips)for(const G of pe.srcQuad)G[0]<P&&(P=G[0]),G[0]>K&&(K=G[0]),G[1]<te&&(te=G[1]),G[1]>ie&&(ie=G[1]);return isFinite(P)||(P=0),isFinite(K)||(K=I),isFinite(te)||(te=0),isFinite(ie)||(ie=R),{top:Math.max(0,Math.round(te)),bottom:Math.max(0,Math.round(R-ie)),left:Math.max(0,Math.round(P)),right:Math.max(0,Math.round(I-K)),rawMinX:P,rawMaxX:K,rawMinY:te,rawMaxY:ie,imgW:I,imgH:R}},[n,s]),C=g.useMemo(()=>s?null:wf(n),[n,s]),S=w+(v?v.total_w:0),_=C?C.w:S+j.left+j.right,A=C?C.h:b+j.top+j.bottom,T=g.useCallback(()=>{const I=c.current;if(!(!I||!d.current)&&!(e&&$.current!==e)){if(I.clear(_,A),s&&j.rawMinX!==void 0&&u.current&&p.current){const{rawMinX:R,rawMaxX:P,rawMinY:K,rawMaxY:te,imgW:ie,imgH:U,top:pe,bottom:G,left:ee,right:ae}=j,Se=[];ee>0&&Se.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[R,0],[R,U],[0,U]],dstRect:[0,0,ee,A]}}),pe>0&&Se.push({colOffsetX:ee,colOffsetY:0,strip:{srcQuad:[[R,0],[P,0],[P,K],[R,K]],dstRect:[0,0,S,pe]}}),G>0&&Se.push({colOffsetX:ee,colOffsetY:pe+b,strip:{srcQuad:[[R,te],[P,te],[P,U],[R,U]],dstRect:[0,0,S,G]}}),ae>0&&Se.push({colOffsetX:ee+S,colOffsetY:0,strip:{srcQuad:[[P,0],[ie,0],[ie,U],[P,U]],dstRect:[0,0,ae,A]}}),I.renderStripsWithTexture(u.current,_,A,n.image_size[0],n.image_size[1],Se,1)}if(u.current&&p.current){const R=n.columns.flatMap(P=>(P.strips||[]).map(K=>({colOffsetX:j.left+P.offset_x,colOffsetY:j.top,strip:K})));if(R.length>0?I.renderStripsWithTexture(u.current,_,A,n.image_size[0],n.image_size[1],R,1):I.renderStripsWithTexture(u.current,_,A,n.image_size[0],n.image_size[1],[{colOffsetX:0,colOffsetY:0,strip:{srcQuad:C?[[C.x,C.y],[C.x+C.w,C.y],[C.x+C.w,C.y+C.h],[C.x,C.y+C.h]]:[[0,0],[n.image_size[0],0],[n.image_size[0],n.image_size[1]],[0,n.image_size[1]]],dstRect:[0,0,_,A]}}],1),v&&v.current_page_strips.length>0){const P=v.current_page_strips.map(K=>({colOffsetX:j.left+w,colOffsetY:j.top,strip:K}));I.renderStripsWithTexture(u.current,_,A,n.image_size[0],n.image_size[1],P,1)}}if(v&&m.current&&h.current&&v.mate_page_strips.length>0){const R=v.mate_page_strips.map(P=>({colOffsetX:j.left+w+v.half_w,colOffsetY:j.top,strip:P}));I.renderStripsWithTexture(m.current,_,A,v.mate_img_size[0],v.mate_img_size[1],R,.65)}}},[e,n,v,_,A,w,b,S,j,s,C]),z=g.useRef(T);z.current=T,g.useEffect(()=>{const I=d.current;if(!I)return;const R=te=>{u.current=p.current?te.createTexture(p.current):null,m.current=h.current?te.createTexture(h.current):null,z.current()};try{const te=new Mr(I);c.current=te,R(te)}catch(te){console.error("Failed to init WebGL renderer:",te)}const P=te=>{te.preventDefault(),console.warn("WebGL context lost")},K=()=>{console.info("WebGL context restored, re-initializing..."),d.current&&(c.current=new Mr(d.current),R(c.current))};return I.addEventListener("webglcontextlost",P,!1),I.addEventListener("webglcontextrestored",K,!1),()=>{I.removeEventListener("webglcontextlost",P),I.removeEventListener("webglcontextrestored",K),c.current&&(c.current.deleteTexture(u.current),c.current.deleteTexture(m.current),c.current.destroy(),c.current=null)}},[]),g.useEffect(()=>{if(!e)return;let I=!0;return Pr(e).then(R=>{if(!I||!R)return;p.current=R,$.current=e;const P=c.current;P&&(P.deleteTexture(u.current),u.current=P.createTexture(R)),x(K=>K+1)}),()=>{I=!1}},[e]);const M=v==null?void 0:v.mate_image_url;g.useEffect(()=>{if(!M)return;let I=!0;return Pr(M).then(R=>{if(!I||!R)return;h.current=R;const P=c.current;P&&(P.deleteTexture(m.current),m.current=P.createTexture(R)),y(K=>K+1)}),()=>{I=!1}},[M]),g.useEffect(()=>{T()},[T,f,k]);const H=g.useMemo(()=>{const I=[];for(const R of n.columns)for(const P of R.chars){const[K,te,ie,U]=P.bbox_col;I.push({id:P.id,char:P.char,x:j.left+R.offset_x+K-((C==null?void 0:C.x)??0),y:j.top+te-((C==null?void 0:C.y)??0),w:Math.max(ie-K,1),h:Math.max(U-te,1)})}return I},[n,j,C]);return t.jsxs("div",{className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${_} / ${A}`,backgroundColor:r("warp-bg"),boxShadow:r("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("canvas",{ref:d,width:_,height:A,style:{width:"100%",height:"100%",display:"block",backgroundColor:r("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${_} ${A}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[H.map(I=>{const R=i.has(I.id),P=o===I.id;return t.jsx("rect",{"data-selected":R?"true":void 0,x:I.x,y:I.y,width:I.w,height:I.h,fill:R?r("warp-sel-bg"):P?r("warp-hover-bg"):"transparent",stroke:R?r("warp-sel-stroke"):P?r("warp-hover-stroke"):"transparent",strokeWidth:R?3.5:P?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>a==null?void 0:a(I.id),onMouseEnter:()=>l==null?void 0:l(I.id),onMouseLeave:()=>l==null?void 0:l(null),children:t.jsx("title",{children:I.char})},I.id)}),v&&t.jsxs("g",{children:[t.jsx("line",{x1:j.left+w,y1:j.top,x2:j.left+w,y2:j.top+b,stroke:r("warp-banxin-border"),strokeWidth:1.5}),t.jsx("line",{x1:j.left+w+v.half_w,y1:j.top,x2:j.left+w+v.half_w,y2:j.top+b,stroke:r("warp-banxin-fold"),strokeWidth:1.5,strokeDasharray:"8 6"}),t.jsx("line",{x1:j.left+S,y1:j.top,x2:j.left+S,y2:j.top+b,stroke:r("warp-banxin-outer"),strokeWidth:1})]})]})]})},Ao=`
1310
1317
  .bim-et-w { position: relative; display: inline; }
1311
1318
  .bim-et {
1312
1319
  color: inherit; text-decoration-line: underline;
@@ -1348,17 +1355,17 @@ a.bim-et:focus-visible { outline: 2px solid ${r("accent")}; outline-offset: 2px;
1348
1355
  .bim-et-card { animation: bim-et-in 120ms ease-out; }
1349
1356
  @keyframes bim-et-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
1350
1357
  }
1351
- `,vf=120;function ut(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function kf(e,n=vf){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 wf(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 Sf(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(i=>{if(!i||typeof i!="object")return"";const o=i,s=ut(o.name);return s?[ut(o.dynasty)&&`〔${ut(o.dynasty)}〕`,s,ut(o.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function Uc(e,n){const i=ut(n.type),o=ut(n.primary_name)??ut(n.title)??e,s=i==="entity"?[ut(n.dynasty),wf(n),ut(n.native_place)].filter(Boolean).join(" · "):[Sf(n),ut(n.edition),ut(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?ut(n.description.text):ut(n.description);return{id:ut(n.id)??e,type:i,title:o,meta:s||void 0,description:kf(a)}}function Vc(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 Gc(e){return async n=>{const i=await e.getItem(n);if(i)return Uc(n,i);if(e.getEntry){const o=await e.getEntry(n);if(o)return Vc(o)}return null}}const ca=new WeakMap;function _f(e,n,i){let o=ca.get(e);o||(o=new Map,ca.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 Yc=e=>`/item/${encodeURIComponent(e)}`,da={work:"書名",people:"人名",place:"地名",office:"官職",dynasty:"朝代",reign:"年號",other:"專名"},$f=typeof window>"u"?g.useEffect:g.useLayoutEffect;function Ao(e,n){return g.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:Gc(e)}:null,[n,e])}const Cf=e=>e,zf=({text:e,entities:n,offsets:i="text",plainBase:o=0,transport:s,loadSummary:a,buildHref:l=Yc,onNavigate:d,renderText:c=Cf,hoverDelayMs:p=250,closeDelayMs:h,injectStyles:u=!0,className:m})=>{const f=g.useMemo(()=>{const k=i==="plain"?Wc(e,n,o):n;return Oc(e,k)},[e,n,i,o]),x=Ao(s,a);return t.jsxs("span",{className:m?`bim-et-root ${m}`:"bim-et-root",children:[u&&t.jsx("style",{children:Lo}),f.map(k=>k.type==="text"?t.jsx(g.Fragment,{children:c(k.text)},`t${k.start}`):t.jsx(Mo,{span:k.span,label:k.text,hasBrackets:e[k.start-1]==="《"&&e[k.start+k.text.length]==="》",loader:x,buildHref:l,onNavigate:d,renderText:c,hoverDelayMs:p,closeDelayMs:h},`${k.span.key}@${k.start}`))]})};let Vt=null;const Mo=({span:e,label:n,hasBrackets:i,plain:o,loader:s,buildHref:a,onNavigate:l,onCardNavigate:d=l,renderText:c,hoverDelayMs:p,closeDelayMs:h=280})=>{const u=g.useId(),[m,f]=g.useState(!1),[x,k]=g.useState(!1),y=g.useRef(null),$=g.useRef(null),b=`bim-et bim-et-${e.kind}${o?" bim-et-nu":""}`,w=e.kind==="work"&&!i,v=t.jsxs(t.Fragment,{children:[w&&t.jsx("span",{className:"bim-et-sr",children:"《"}),c(n),w&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),j=()=>{y.current&&(clearTimeout(y.current),y.current=null)},C=()=>{$.current&&(clearTimeout($.current),$.current=null)},S=g.useCallback(()=>{j(),C(),f(!1),k(!1),Vt===S&&(Vt=null)},[]);g.useEffect(()=>()=>{j(),C(),Vt===S&&(Vt=null)},[S]);const _=g.useCallback(()=>{Vt&&Vt!==S&&Vt(),Vt=S,f(!0)},[S]),L=g.useCallback(N=>{C(),k(!0),!m&&(j(),N<=0?_():y.current=setTimeout(_,N))},[m,_]),T=g.useCallback(()=>{j(),C(),$.current=setTimeout(S,h)},[S,h]),z=!!e.targetId,M=e.targetId,H={className:"bim-et-w","data-active":x?"":void 0,onMouseEnter:()=>L(p),onMouseLeave:T,onBlur:N=>{N.currentTarget.contains(N.relatedTarget)||S()},onKeyDown:N=>{N.key==="Escape"&&m&&(N.stopPropagation(),S())}};return!z||!M?t.jsxs("span",{...H,children:[t.jsx("span",{className:b,children:v}),m&&t.jsx(pa,{id:u,entityId:null,span:e,loader:null,buildHref:a,onNavigate:l})]}):t.jsxs("span",{...H,children:[t.jsx("a",{className:b,href:a(M),"data-entity-id":M,"aria-describedby":m?u:void 0,onFocus:()=>L(0),onClick:l?N=>l(M,N):void 0,children:v}),m&&t.jsx(pa,{id:u,entityId:M,span:e,loader:s,buildHref:a,onNavigate:d})]})},pa=({id:e,entityId:n,span:i,loader:o,buildHref:s,onNavigate:a})=>{const{convert:l,t:d}=te(),c=g.useRef(null),[p,h]=g.useState("start"),[u,m]=g.useState(o&&n?{status:"loading"}:{status:"ready",summary:null});g.useEffect(()=>{if(!o||!n)return;let k=!1;return m({status:"loading"}),_f(o.owner,o.load,n).then(y=>{k||m({status:"ready",summary:y})}).catch(()=>{k||m({status:"error"})}),()=>{k=!0}},[o,n]),$f(()=>{const k=c.current;if(!k||typeof window>"u")return;const y=k.getBoundingClientRect(),$=document.documentElement.clientWidth||window.innerWidth;y.right>$-8&&p==="start"&&h("end")},[u,p]);const f=u.status==="ready"?u.summary:null,x=(f==null?void 0:f.title)??i.canonicalName??i.text;return n?t.jsxs("span",{ref:c,id:e,role:"tooltip",className:"bim-et-card","data-align":p,children:[t.jsx("span",{className:"bim-et-card-k",children:l(da[i.kind])}),x&&t.jsx("span",{className:"bim-et-card-t",children:l(x)}),(f==null?void 0:f.meta)&&t.jsx("span",{className:"bim-et-card-m",children:l(f.meta)}),(f==null?void 0:f.description)&&t.jsx("span",{className:"bim-et-card-d",children:l(f.description)}),u.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:l("載入中…")}),u.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:l("摘要載入失敗")}),f&&t.jsx("a",{className:"bim-et-card-a",href:s(f.id||n),onClick:a?k=>a(f.id||n,k):void 0,children:d("reader.entityDetail")})]}):t.jsx("span",{ref:c,id:e,role:"tooltip",className:"bim-et-card","data-align":p,children:t.jsx("span",{className:"bim-et-card-k",children:l(da[i.kind])})})},Tf=e=>`/item/${encodeURIComponent(e)}`;function Nf(e){const n=e.filter(i=>i.kind!=="break");return{before:n.filter(i=>i.pos==="before"),after:n.filter(i=>i.pos!=="before")}}function If(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 Po=({pageData:e,pages:n,punctuations:i=Rf,selectedCharIds:o,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:h,convert:u,scrollToPage:m,entities:f,entityTransport:x,loadEntitySummary:k,buildEntityHref:y,onEntityNavigate:$,pageBreaks:b=!0,pageIndicatorY:w,onPageIndicatorYChange:v,quoteStyle:j,bookTitleStyle:C,showWorks:S})=>{const _=g.useRef(null),L=g.useRef(0),T=g.useMemo(()=>{const ne=new Map;return p&&i.forEach((W,U)=>{const he=W.id?W:{...W,id:`${W.anchor}#${U}`},K=ne.get(he.anchor)||[];K.push(he),ne.set(he.anchor,K)}),ne},[i,p]),z=g.useMemo(()=>j===void 0&&C===void 0&&S===void 0?null:{quoteStyle:j??"original",hideBookBrackets:C==="wavy"||S===!1},[j,C,S]),M=C==="bracket",H=g.useMemo(()=>{var he;const ne=n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}],W=ne.filter(K=>K.columns.some(B=>B.chars.length>0)).map(K=>{const B=[...K.columns].sort((se,Te)=>se.col-Te.col),Q=[];let le=[],ie=0;for(const se of B){if(se.chars.length===0){se.kind==="blank"&&ie++;continue}const Te=se.raised||se.lead_blank||ie?{raised:se.raised,leadBlank:se.lead_blank,blankBefore:ie}:void 0;ie=0;let Me=!0;for(const Le of se.chars){const{before:F,after:ae}=Nf(T.get(Le.id)||[]),fe=(T.get(Le.id)||[]).some(P=>P.kind==="break");le.push({charData:Le,col:se.col,beforePuncts:F,afterPuncts:ae,...Me&&Te?{start:Te}:{}}),Me=!1,fe&&(Q.push({id:`para-p${K.page}-${Q.length}`,chars:le}),le=[])}}const D=le.length>0;return D&&Q.push({id:`para-p${K.page}-${Q.length}`,chars:le}),{page:K.page,paragraphs:Q,endsOpen:D,...K.label?{label:K.label}:{},...ie>0?{trailingBlank:ie}:{}}}),U=new Map;if(!b){const K=new Map;for(const ie of ne)for(const D of ie.columns)D.chars.length>0&&K.set(D.lead_blank||0,(K.get(D.lead_blank||0)||0)+1);let B=0,Q=-1;for(const[ie,D]of K)(D>Q||D===Q&&ie<B)&&(B=ie,Q=D);let le=null;for(const ie of W){const D=ie.paragraphs[0],se=(he=D==null?void 0:D.chars[0])==null?void 0:he.start,Te=!!se&&!!(se.raised||(se.leadBlank||0)>B||se.blankBefore),Me=ie.paragraphs.length===1&&!!ie.trailingBlank;if(le&&D&&!Te&&!Me){for(const Le of D.chars)U.set(Le.charData.id,le.owner);le.para.chars=le.para.chars.concat(D.chars),ie.leadFirstId=D.chars[0].charData.id,ie.paragraphs=ie.paragraphs.slice(1)}if(ie.endsOpen&&!ie.trailingBlank){const Le=ie.paragraphs[ie.paragraphs.length-1];Le&&(le={para:Le,owner:ie.page})}else le=null}}return{pages:W,mergedOwner:U}},[n,e,T,b]),N=H.pages,R=g.useMemo(()=>{const ne=[];for(const W of N)for(const U of W.paragraphs)for(const he of U.chars)ne.push(he.charData.id);return ne},[N]),A=g.useMemo(()=>{const ne=new Map;if(!f||f.length===0)return ne;const W=new Map(R.map((U,he)=>[U,he]));for(const U of f){if(!U.anchor)continue;const he=W.get(U.anchor.start),K=W.get(U.anchor.end);if(!(he===void 0||K===void 0||K<he))for(let B=he;B<=K;B++)ne.has(R[B])||ne.set(R[B],U)}return ne},[f,R]),J=Ao(x,k),ee=A.size>0,oe=g.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:$});oe.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:$};const V=g.useMemo(()=>({click:ne=>{var W,U;L.current=Date.now()+1200,(U=(W=oe.current).onCharClick)==null||U.call(W,ne)},enter:ne=>{var W,U;return(U=(W=oe.current).onCharHover)==null?void 0:U.call(W,ne)},leave:()=>{var ne,W;return(W=(ne=oe.current).onCharHover)==null?void 0:W.call(ne,null)},navigate:(ne,W)=>{var he,K;if(!(W.detail===0||W.ctrlKey||W.metaKey||W.shiftKey)){W.preventDefault();return}(K=(he=oe.current).onEntityNavigate)==null||K.call(he,ne,W)},detail:(ne,W)=>{var U,he;return(he=(U=oe.current).onEntityNavigate)==null?void 0:he.call(U,ne,W)}}),[]),me=Lf(o,H.mergedOwner),G=g.useRef(null);g.useEffect(()=>{var W,U;if((W=G.current)==null||W.classList.remove("is-hovered"),G.current=null,!s)return;const ne=(U=_.current)==null?void 0:U.querySelector(`span[data-char-id="${s}"]`);ne&&(ne.classList.add("is-hovered"),G.current=ne)},[s]),g.useEffect(()=>{let ne=null;const W=()=>{var ae,fe;ne=null;const he=window.getSelection(),K=_.current;if(!he||he.isCollapsed||he.rangeCount===0||!K)return;const B=he.getRangeAt(0),Q=B.commonAncestorContainer,le=Q.nodeType===3?Q.parentElement:Q;if(!le||!K.contains(le))return;const ie=K.querySelectorAll("span[data-char-id]"),D=P=>P.firstChild??P;let se=0,Te=ie.length;for(;se<Te;){const P=se+Te>>1;B.comparePoint(D(ie[P]),0)<0?se=P+1:Te=P}const Me=se;for(Te=ie.length;se<Te;){const P=se+Te>>1;B.comparePoint(D(ie[P]),0)<=0?se=P+1:Te=P}let Le=se-1;if(Le>=Me&&B.endOffset===0&&B.endContainer===D(ie[Le])&&Le--,Le<Me)return;const F=[];for(let P=Me;P<=Le;P++)F.push(ie[P].getAttribute("data-char-id"));F.length>0&&(L.current=Date.now()+1200,(fe=(ae=oe.current).onSelectionChange)==null||fe.call(ae,F))},U=()=>{ne&&clearTimeout(ne),ne=setTimeout(W,120)};return document.addEventListener("selectionchange",U),()=>{document.removeEventListener("selectionchange",U),ne&&clearTimeout(ne)}},[]),g.useEffect(()=>{var ne;if(o.size===1){const W=Array.from(o)[0],U=(ne=_.current)==null?void 0:ne.querySelector(`span[data-char-id="${W}"]`);U&&U.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[o]);const q=ne=>{var he;const W=_.current;if(!W)return null;const U=(he=N.find(K=>K.page===ne))==null?void 0:he.leadFirstId;return U?W.querySelector(`span[data-char-id="${U}"]`):W.querySelector(`[data-page-section="${ne}"]`)},ce=m==null?void 0:m.nonce;g.useEffect(()=>{if(!m)return;const ne=q(m.page);ne&&(L.current=Date.now()+800,ne.scrollIntoView({behavior:"auto",block:"start"}))},[ce]);const we=!!h,O=we&&typeof w=="number",[ye,de]=g.useState(null),ze=Br(ye??w??0),Ce=g.useRef(null);Ce.current=O?ze:null;const Oe=g.useRef(()=>{});return g.useEffect(()=>{if(!we)return;const ne=[],W=[];for(const B of N){const Q=q(B.page);Q&&(ne.push(Q),W.push(B.page))}if(ne.length===0)return;let U=0;const he=()=>{var ie,D;if(U=0,Date.now()<L.current||ne.length>1&&ne[0].getBoundingClientRect().top===ne[ne.length-1].getBoundingClientRect().top)return;const B=Ce.current===null?120:Ce.current*window.innerHeight;let Q=0,le=ne.length-1;for(;Q<le;){const se=Q+le+1>>1;ne[se].getBoundingClientRect().top<=B?Q=se:le=se-1}(D=(ie=oe.current).onVisiblePageChange)==null||D.call(ie,W[Q])},K=()=>{U||(U=requestAnimationFrame(he))};return Oe.current=()=>{U||(U=requestAnimationFrame(he))},window.addEventListener("scroll",K,{passive:!0}),he(),()=>{window.removeEventListener("scroll",K),U&&cancelAnimationFrame(U),Oe.current=()=>{}}},[we,N]),g.useEffect(()=>{O&&Oe.current()},[O,ze]),t.jsxs("div",{ref:_,className:"guji-text-pane-content",children:[ee&&t.jsx("style",{children:Lo}),O&&t.jsx(Bf,{y:ze,containerRef:_,onDrag:de,onCommit:ne=>{de(null),v==null||v(ne)}}),t.jsx("div",{className:"guji-text-reflow-view",children:N.map((ne,W)=>t.jsx(Mf,{pGroup:ne,first:W===0,pageBreaks:b,markOpts:z,plainBooks:M,selected:me.get(ne.page)??Ef,entityOfChar:A,entityLoader:J,convert:u,buildHref:y??Tf,handlers:V},`page-sec-${ne.page}`))})]})},Ef=new Set,Rf=[];function Lf(e,n){const i=g.useRef(new Map);return g.useMemo(()=>{const o=new Map;e.forEach(a=>{const l=n.get(a)??parseInt(a.split(":")[0],10);let d=o.get(l);d||o.set(l,d=new Set),d.add(a)});const s=new Map;return o.forEach((a,l)=>{const d=i.current.get(l),c=d&&d.size===a.size&&Array.from(a).every(p=>d.has(p));s.set(l,c?d:a)}),i.current=s,s},[e,n])}function ua({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 Af(e,n){const i=Array.from(n(e.join("")));return i.length===e.length&&e.every(o=>Array.from(o).length===1)?i:e.map(o=>n(o))}const Mf=g.memo(function({pGroup:n,first:i,pageBreaks:o,markOpts:s,plainBooks:a,selected:l,entityOfChar:d,entityLoader:c,convert:p,buildHref:h,handlers:u}){const m=g.useMemo(()=>{const y=new Map;if(!p)return y;for(const $ of n.paragraphs){const b=Af($.chars.map(w=>w.charData.norm??w.charData.char),p);$.chars.forEach((w,v)=>y.set(w.charData.id,b[v]))}return y},[n,p]),f=y=>m.get(y.id)??y.char,{t:x}=te(),k=y=>{const $=s?Lc(y.mark,s):y.mark;return $?t.jsx("span",{className:"guji-text-punct","data-punct-id":y.id,children:$},y.id):null};return t.jsxs("section",{"data-page-section":n.page,className:"guji-page-section",style:{position:"relative",scrollMarginTop:96},children:[!i&&o&&t.jsxs("div",{className:"guji-page-divider",style:{display:"flex",alignItems:"center",margin:"2rem 0 1.2rem",color:r("meta-fg"),fontSize:"0.82rem",letterSpacing:"0.08em",userSelect:"none"},children:[t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}}),t.jsxs("span",{style:{padding:"0 12px",fontWeight:500},"data-page-label":n.label,title:n.label?`${n.page}`:void 0,children:["第 ",n.label??n.page," 葉"]}),t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}})]}),n.paragraphs.map((y,$)=>t.jsxs("p",{className:"guji-reflow-paragraph",children:[If(y.chars,d).map((b,w)=>{const v=b.chars.map(({charData:S,beforePuncts:_,afterPuncts:L,start:T},z)=>{const M=!!b.entity&&z===0,H=!!b.entity&&z===b.chars.length-1,N=M?[]:_,R=H?[]:L;return t.jsxs(g.Fragment,{children:[T&&T.blankBefore>0&&t.jsx(ua,{n:T.blankBefore}),N.map(k),t.jsx("span",{"data-char-id":S.id,onClick:()=>u.click(S.id),onMouseEnter:()=>u.enter(S.id),onMouseLeave:u.leave,className:`guji-text-char${l.has(S.id)?" is-selected":""}${S.sub?" is-sub":""}${S.lane==="solo"?" is-solo":""}${S.lacuna?" is-lacuna":""}${S.guess?" is-guess":""}${S.zi?" is-zi":""}${T!=null&&T.raised?" is-raised":""}`,"data-raised":(T==null?void 0:T.raised)||void 0,title:S.lacuna?x("detail.lacuna"):S.zi?x("detail.composedChar",{label:S.zi}):S.guess?x("reader.charGuess"):void 0,children:f(S)}),R.map(k)]},S.id)});if(!b.entity)return t.jsx(g.Fragment,{children:v},`r${w}`);const j=b.chars[0].beforePuncts.map(k),C=b.chars[b.chars.length-1].afterPuncts.map(k);return t.jsxs(g.Fragment,{children:[j,t.jsx(Mo,{span:b.entity,label:b.chars.map(S=>f(S.charData)).join(""),hasBrackets:!0,plain:a&&b.entity.kind==="work",loader:c,buildHref:h,onNavigate:u.navigate,onCardNavigate:u.detail,renderText:()=>v,hoverDelayMs:250}),C]},`${b.entity.key}@${w}`)}),$===n.paragraphs.length-1&&n.trailingBlank?t.jsx(ua,{n:n.trailingBlank}):null]},y.id))]})});function Br(e){const[n,i]=Wn,o=Number.isFinite(e)?e:.33;return Math.round(Math.min(i,Math.max(n,o))*1e3)/1e3}const Pf=.02,li=16;function Bf({y:e,containerRef:n,onDrag:i,onCommit:o}){const{t:s}=te(),[a,l]=g.useState(0),d=g.useRef(!1),c=g.useRef(e);c.current=e;const p=g.useCallback(()=>{var f,x;const m=(x=((f=n.current)==null?void 0:f.querySelector(".guji-text-reflow-view"))??n.current)==null?void 0:x.getBoundingClientRect();l(Math.max(0,((m==null?void 0:m.left)??0)-li-2))},[n]);g.useLayoutEffect(()=>(p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)),[p]);const h=u=>Br(u/Math.max(1,window.innerHeight));return t.jsx("div",{role:"slider",tabIndex:0,className:"guji-page-indicator","aria-label":s("reader.pageIndicator"),"aria-orientation":"vertical","aria-valuemin":Math.round(Wn[0]*100),"aria-valuemax":Math.round(Wn[1]*100),"aria-valuenow":Math.round(e*100),"data-indicator-y":e,style:{position:"fixed",left:a,top:`calc(${e*100}vh - ${li/2}px)`,width:li,height:li,zIndex:20,cursor:"ns-resize",touchAction:"none",background:r("accent"),clipPath:"polygon(0 0, 100% 50%, 0 100%)",outline:"none"},onPointerDown:u=>{d.current=!0;try{u.currentTarget.setPointerCapture(u.pointerId)}catch{}u.preventDefault()},onPointerMove:u=>{if(!d.current)return;const m=h(u.clientY);c.current=m,i(m)},onPointerUp:u=>{if(d.current){d.current=!1;try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}o(h(u.clientY))}},onPointerCancel:()=>{d.current&&(d.current=!1,o(c.current))},onKeyDown:u=>{const m=u.key==="ArrowUp"?-1:u.key==="ArrowDown"?1:0;m&&(u.preventDefault(),o(Br(e+m*(u.shiftKey?5:1)*Pf)))}})}const qc=1,Kc=6,ci={s:1,x:0,y:0},hi=(e,n,i)=>Math.min(i,Math.max(n,e));function Bo(e,n,i){const o=hi(e.s,qc,Kc);return{s:o,x:hi(e.x,n*(1-o),0),y:hi(e.y,i*(1-o),0)}}function ur(e,n,i,o,s,a){const l=hi(e.s*o,qc,Kc),d=l/e.s;return Bo({s:l,x:n-(n-e.x)*d,y:i-(i-e.y)*d},s,a)}function Wf(e,n,i,o,s){return Bo({s:e.s,x:e.x+n,y:e.y+i},o,s)}function Of(e,n,i){const o=n===1?e*16:n===2?e*400:e;return Math.exp(-o*(i?.01:.0015))}const ma=4,Ff=g.forwardRef(function({children:n,onScaleChange:i,resetKey:o,style:s},a){const l=g.useRef(null),[d,c]=g.useState(ci),p=g.useRef(d),h=g.useRef(i);h.current=i;const u=b=>{var v;const w=p.current;p.current=b,c(b),b.s!==w.s&&((v=h.current)==null||v.call(h,b.s))},m=()=>{var w;const b=(w=l.current)==null?void 0:w.getBoundingClientRect();return{w:(b==null?void 0:b.width)??0,h:(b==null?void 0:b.height)??0,left:(b==null?void 0:b.left)??0,top:(b==null?void 0:b.top)??0}};g.useImperativeHandle(a,()=>({zoomBy(b){const{w,h:v}=m();u(ur(p.current,w/2,v/2,b,w,v))},reset(){u(ci)}})),g.useEffect(()=>{u(ci)},[o]),g.useEffect(()=>{const b=l.current;if(!b||typeof ResizeObserver>"u")return;const w=new ResizeObserver(()=>{const{w:v,h:j}=m(),C=Bo(p.current,v,j);(C.x!==p.current.x||C.y!==p.current.y)&&u(C)});return w.observe(b),()=>w.disconnect()},[]),g.useEffect(()=>{const b=l.current;if(!b)return;const w=v=>{const j=Of(v.deltaY,v.deltaMode,v.ctrlKey);if(p.current.s<=1&&j<1)return;v.preventDefault();const{w:C,h:S,left:_,top:L}=m();u(ur(p.current,v.clientX-_,v.clientY-L,j,C,S))};return b.addEventListener("wheel",w,{passive:!1}),()=>b.removeEventListener("wheel",w)},[]);const f=g.useRef(new Map),x=g.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),k=b=>{if(b.pointerType==="mouse"&&b.button!==0)return;f.current.set(b.pointerId,{x:b.clientX,y:b.clientY});const w=x.current;if(w.swallowClick=!1,f.current.size===1&&(w.moved=0,w.dragging=!1),f.current.size===2){const[v,j]=[...f.current.values()];w.pinchDist=Math.hypot(v.x-j.x,v.y-j.y),w.moved=ma+1}},y=b=>{var M;const w=f.current.get(b.pointerId);if(!w)return;const v={x:b.clientX,y:b.clientY};f.current.set(b.pointerId,v);const j=x.current,{w:C,h:S,left:_,top:L}=m();if(f.current.size>=2){const[H,N]=[...f.current.values()],R=Math.hypot(H.x-N.x,H.y-N.y);if(j.pinchDist>0&&R>0){const A=(H.x+N.x)/2-_,J=(H.y+N.y)/2-L;u(ur(p.current,A,J,R/j.pinchDist,C,S))}j.pinchDist=R,j.swallowClick=!0;return}const T=v.x-w.x,z=v.y-w.y;if(j.moved+=Math.abs(T)+Math.abs(z),!(j.moved<=ma)){if(!j.dragging){j.dragging=!0;try{(M=l.current)==null||M.setPointerCapture(b.pointerId)}catch{}}j.swallowClick=!0,p.current.s>1&&u(Wf(p.current,T,z,C,S))}},$=b=>{f.current.delete(b.pointerId);const w=x.current;w.pinchDist=0,f.current.size===0&&(w.dragging=!1)};return t.jsx("div",{ref:l,className:"bim-zp","data-zoom":d.s.toFixed(2),onPointerDown:k,onPointerMove:y,onPointerUp:$,onPointerCancel:$,onClickCapture:b=>{x.current.swallowClick&&(x.current.swallowClick=!1,b.stopPropagation(),b.preventDefault())},onDoubleClick:()=>u(ci),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 Xc(e,n,i,o){const[s,a]=g.useState(n??null),[l,d]=g.useState(!1),c=g.useRef(0);return g.useEffect(()=>{if(n!==void 0){a(n);return}const p=++c.current;if(!i){a(null),d(!1);return}if(e){let h;try{h=e(i,o)}catch{a(null),d(!1);return}if(!h||typeof h.then!="function"){a(h??null),d(!1);return}d(!0),h.then(u=>{p===c.current&&a(u??null)}).catch(()=>{p===c.current&&a(null)}).finally(()=>{p===c.current&&d(!1)});return}a(null),d(!1)},[e,n,i,o]),{warpData:s,loading:l}}function Hf(e,n,i){const[o,s]=g.useState([]),a=g.useRef(0);return g.useEffect(()=>{const l=++a.current;if(!e||!n){s([]);return}let d;try{d=e(n,i)}catch{s([]);return}Promise.resolve(d).then(c=>{l===a.current&&s(c?Bc(c):[])}).catch(()=>{l===a.current&&s([])})},[e,n,i]),o}const ha={padding:24,color:r("desc-fg"),fontSize:14};function ga({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 fa=/^https?:\/\//i,Df=[];function Uf(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&&fa.test(i)?i:void 0,license:n(e.license),license_url:o&&fa.test(o)?o:void 0,note:n(e.note)};return s.name||s.license||s.note?s:null}function Vf(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 Gf(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)?"冊":ke.isCollatedKind(e==null?void 0:e.kind)?"卷":"章"}function Zc(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 Yf(e,n,i,o,s){var p;const a=new Map(e.chapters.map(h=>[h.file,h])),l=h=>h==="loading"?"…":typeof h=="number"&&h>0?h:void 0,d=(h,u)=>{const m=a.get(h);return{key:h,label:u??(m?Zc(m,i,o,s):h),hint:l(n[h]),disabled:n[h]===0}},c=(p=e.juan_groups)==null?void 0:p.filter(h=>{var u;return h.files.some(m=>a.has(m))||((u=h.children)==null?void 0:u.length)});if(c&&c.length>0){const h=(u,m)=>{var x;if(u.files.length===1&&!((x=u.children)!=null&&x.length))return d(u.files[0],o(u.label));const f=tf(u,n);return{key:`group:${m}`,label:o(u.label),hint:f==="loading"?"…":typeof f=="number"&&f>0?`${f}`:Hc(u),defaultExpanded:typeof f=="number"&&f>0,children:[...u.files.filter(k=>a.has(k)).map(k=>d(k)),...(u.children??[]).map((k,y)=>h(k,`${m}.${y}`))]}};return c.map((u,m)=>h(u,`${m}`))}return e.chapters.map(h=>d(h.file))}const Wo=e=>{const n=Ul();return t.jsx(zu,{mode:n[0].scriptMode,children:t.jsx(qf,{...e,prefsState:n})})},qf=({prefsState:e,id:n,transport:i,versionKey:o,chapter:s,onLocationChange:a,onNavigate:l,title:d,subtitle:c,resolveImages:p,renderImageOverlay:h,imagePanel:u,allowVertical:m,onReportError:f,revisedAt:x,backHref:k,backLabel:y,resolveWarpData:$,warpData:b,resolveEntities:w,onEntityNavigate:v,className:j,style:C})=>{var cs,ds,ps;const{t:S,convert:_}=te(),L=g.useMemo(()=>Ll(i),[i]),[T,z]=e,M=rt(),H=g.useRef(a);H.current=a;const[N,R]=g.useState(null),[A,J]=g.useState("loading");g.useEffect(()=>{let E=!1;return R(null),J("loading"),L.getManifest(n).then(ue=>{E||(ue?(R(ue),J("ready")):J("missing"))}).catch(()=>{E||J("missing")}),()=>{E=!0}},[L,n]);const ee=o!==void 0,oe=s!==void 0,[V,me]=g.useState(null),[G,q]=g.useState(null);g.useEffect(()=>{me(null),q(null)},[n]);const ce=ke.pickTextVersion(N,ee?o:V),we=((cs=N==null?void 0:N.versions.find(E=>E.key==="default"))==null?void 0:cs.key)??((ds=N==null?void 0:N.versions[0])==null?void 0:ds.key)??"default",O=(ce==null?void 0:ce.key)??null,ye=oe?s:G,de=g.useCallback((E,ue,Ne)=>{var Ue;(Ue=H.current)==null||Ue.call(H,{key:E,chapter:ue,isDefault:E===we},Ne)},[we]);g.useEffect(()=>{!N||!ee||o==null||N.versions.some(E=>E.key===o)||de(we,null,"auto")},[N,ee,o,we,de]);const ze=g.useRef(new Map);g.useEffect(()=>{ze.current.clear()},[L,n]);const Ce=g.useCallback(async E=>{const ue=`${n}
1352
- ${E}`;if(ze.current.has(ue))return ze.current.get(ue)??null;const Ne=await L.getIndex(n,E).catch(()=>null);return Ne&&ze.current.set(ue,Ne),Ne},[L,n]),[Oe,ne]=g.useState(null),[W,U]=g.useState("loading"),he=O?`${n}
1353
- ${O}`:null,K=Oe&&Oe.owner===he?Oe.idx:null;g.useEffect(()=>{if(!O)return;let E=!1;const ue=`${n}
1354
- ${O}`;return ne(null),U("loading"),Ce(O).then(Ne=>{E||(Ne&&Ne.chapters.length>0?(ne({owner:ue,idx:Ne}),U("ready")):U("failed"))}),()=>{E=!0}},[n,O,Ce]),g.useEffect(()=>{if(!K||!O||ye!=null&&K.chapters.some(Ne=>Ne.file===ye))return;const ue=K.chapters[0].file;oe||q(ue),de(O,ue,"auto")},[K,O,ye,oe,de]);const B=K?ye!=null&&K.chapters.some(E=>E.file===ye)?ye:K.chapters[0].file:ye,Q=g.useMemo(()=>K&&B?K.chapters.find(E=>E.file===B)??null:null,[K,B]),le=g.useRef(0),ie=g.useCallback(async E=>{if(!N||E===O||!N.versions.some(wt=>wt.key===E))return;const ue=++le.current,Ne=await Ce(E);if(ue!==le.current)return;const Ue=Q??(B?{file:B}:null),tt=ke.matchChapterAcrossVersions(Ue,Ne);ee||me(E),oe||q(tt),de(E,tt,"version")},[N,O,Ce,Q,B,ee,oe,de]),D=g.useCallback(E=>{O&&(oe||q(E),de(O,E,"chapter"))},[O,oe,de]),[se,Te]=g.useState(null),Me=O&&Q?`${n}
1358
+ `,_f=120;function ut(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function $f(e,n=_f){if(!e)return;const i=e.replace(/\s+/g," ").trim(),o=Array.from(i);return o.length>n?o.slice(0,n).join("")+"…":i}function Cf(e){const n=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 zf(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(i=>{if(!i||typeof i!="object")return"";const o=i,s=ut(o.name);return s?[ut(o.dynasty)&&`〔${ut(o.dynasty)}〕`,s,ut(o.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function Uc(e,n){const i=ut(n.type),o=ut(n.primary_name)??ut(n.title)??e,s=i==="entity"?[ut(n.dynasty),Cf(n),ut(n.native_place)].filter(Boolean).join(" · "):[zf(n),ut(n.edition),ut(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?ut(n.description.text):ut(n.description);return{id:ut(n.id)??e,type:i,title:o,meta:s||void 0,description:$f(a)}}function Vc(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 Gc(e){return async n=>{const i=await e.getItem(n);if(i)return Uc(n,i);if(e.getEntry){const o=await e.getEntry(n);if(o)return Vc(o)}return null}}const da=new WeakMap;function Tf(e,n,i){let o=da.get(e);o||(o=new Map,da.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 Yc=e=>`/item/${encodeURIComponent(e)}`,pa={work:"書名",people:"人名",place:"地名",office:"官職",dynasty:"朝代",reign:"年號",other:"專名"},Nf=typeof window>"u"?g.useEffect:g.useLayoutEffect;function Mo(e,n){return g.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:Gc(e)}:null,[n,e])}const If=e=>e,Ef=({text:e,entities:n,offsets:i="text",plainBase:o=0,transport:s,loadSummary:a,buildHref:l=Yc,onNavigate:d,renderText:c=If,hoverDelayMs:p=250,closeDelayMs:h,injectStyles:u=!0,className:m})=>{const f=g.useMemo(()=>{const k=i==="plain"?Oc(e,n,o):n;return Wc(e,k)},[e,n,i,o]),x=Mo(s,a);return t.jsxs("span",{className:m?`bim-et-root ${m}`:"bim-et-root",children:[u&&t.jsx("style",{children:Ao}),f.map(k=>k.type==="text"?t.jsx(g.Fragment,{children:c(k.text)},`t${k.start}`):t.jsx(Po,{span:k.span,label:k.text,hasBrackets:e[k.start-1]==="《"&&e[k.start+k.text.length]==="》",loader:x,buildHref:l,onNavigate:d,renderText:c,hoverDelayMs:p,closeDelayMs:h},`${k.span.key}@${k.start}`))]})};let Vt=null;const Po=({span:e,label:n,hasBrackets:i,plain:o,loader:s,buildHref:a,onNavigate:l,onCardNavigate:d=l,renderText:c,hoverDelayMs:p,closeDelayMs:h=280})=>{const u=g.useId(),[m,f]=g.useState(!1),[x,k]=g.useState(!1),y=g.useRef(null),$=g.useRef(null),b=`bim-et bim-et-${e.kind}${o?" bim-et-nu":""}`,w=e.kind==="work"&&!i,v=t.jsxs(t.Fragment,{children:[w&&t.jsx("span",{className:"bim-et-sr",children:"《"}),c(n),w&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),j=()=>{y.current&&(clearTimeout(y.current),y.current=null)},C=()=>{$.current&&(clearTimeout($.current),$.current=null)},S=g.useCallback(()=>{j(),C(),f(!1),k(!1),Vt===S&&(Vt=null)},[]);g.useEffect(()=>()=>{j(),C(),Vt===S&&(Vt=null)},[S]);const _=g.useCallback(()=>{Vt&&Vt!==S&&Vt(),Vt=S,f(!0)},[S]),A=g.useCallback(I=>{C(),k(!0),!m&&(j(),I<=0?_():y.current=setTimeout(_,I))},[m,_]),T=g.useCallback(()=>{j(),C(),$.current=setTimeout(S,h)},[S,h]),z=!!e.targetId,M=e.targetId,H={className:"bim-et-w","data-active":x?"":void 0,onMouseEnter:()=>A(p),onMouseLeave:T,onBlur:I=>{I.currentTarget.contains(I.relatedTarget)||S()},onKeyDown:I=>{I.key==="Escape"&&m&&(I.stopPropagation(),S())}};return!z||!M?t.jsxs("span",{...H,children:[t.jsx("span",{className:b,children:v}),m&&t.jsx(ua,{id:u,entityId:null,span:e,loader:null,buildHref:a,onNavigate:l})]}):t.jsxs("span",{...H,children:[t.jsx("a",{className:b,href:a(M),"data-entity-id":M,"aria-describedby":m?u:void 0,onFocus:()=>A(0),onClick:l?I=>l(M,I):void 0,children:v}),m&&t.jsx(ua,{id:u,entityId:M,span:e,loader:s,buildHref:a,onNavigate:d})]})},ua=({id:e,entityId:n,span:i,loader:o,buildHref:s,onNavigate:a})=>{const{convert:l,t:d}=ne(),c=g.useRef(null),[p,h]=g.useState("start"),[u,m]=g.useState(o&&n?{status:"loading"}:{status:"ready",summary:null});g.useEffect(()=>{if(!o||!n)return;let k=!1;return m({status:"loading"}),Tf(o.owner,o.load,n).then(y=>{k||m({status:"ready",summary:y})}).catch(()=>{k||m({status:"error"})}),()=>{k=!0}},[o,n]),Nf(()=>{const k=c.current;if(!k||typeof window>"u")return;const y=k.getBoundingClientRect(),$=document.documentElement.clientWidth||window.innerWidth;y.right>$-8&&p==="start"&&h("end")},[u,p]);const f=u.status==="ready"?u.summary:null,x=(f==null?void 0:f.title)??i.canonicalName??i.text;return n?t.jsxs("span",{ref:c,id:e,role:"tooltip",className:"bim-et-card","data-align":p,children:[t.jsx("span",{className:"bim-et-card-k",children:l(pa[i.kind])}),x&&t.jsx("span",{className:"bim-et-card-t",children:l(x)}),(f==null?void 0:f.meta)&&t.jsx("span",{className:"bim-et-card-m",children:l(f.meta)}),(f==null?void 0:f.description)&&t.jsx("span",{className:"bim-et-card-d",children:l(f.description)}),u.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:l("載入中…")}),u.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:l("摘要載入失敗")}),f&&t.jsx("a",{className:"bim-et-card-a",href:s(f.id||n),onClick:a?k=>a(f.id||n,k):void 0,children:d("reader.entityDetail")})]}):t.jsx("span",{ref:c,id:e,role:"tooltip",className:"bim-et-card","data-align":p,children:t.jsx("span",{className:"bim-et-card-k",children:l(pa[i.kind])})})},Rf=e=>`/item/${encodeURIComponent(e)}`;function Lf(e){const n=e.filter(i=>i.kind!=="break");return{before:n.filter(i=>i.pos==="before"),after:n.filter(i=>i.pos!=="before")}}function Af(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 Bo=({pageData:e,pages:n,punctuations:i=Pf,selectedCharIds:o,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:h,convert:u,scrollToPage:m,entities:f,entityTransport:x,loadEntitySummary:k,buildEntityHref:y,onEntityNavigate:$,pageBreaks:b=!0,pageIndicatorY:w,onPageIndicatorYChange:v,quoteStyle:j,bookTitleStyle:C,showWorks:S})=>{const _=g.useRef(null),A=g.useRef(0),T=g.useMemo(()=>{const re=new Map;return p&&i.forEach((B,V)=>{const he=B.id?B:{...B,id:`${B.anchor}#${V}`},X=re.get(he.anchor)||[];X.push(he),re.set(he.anchor,X)}),re},[i,p]),z=g.useMemo(()=>j===void 0&&C===void 0&&S===void 0?null:{quoteStyle:j??"original",hideBookBrackets:C==="wavy"||S===!1},[j,C,S]),M=C==="bracket",H=g.useMemo(()=>{var he;const re=n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}],B=re.filter(X=>X.columns.some(ge=>ge.chars.length>0)).map(X=>{const ge=[...X.columns].sort((Q,Ce)=>Q.col-Ce.col),W=[];let le=[],q=0;for(const Q of ge){if(Q.chars.length===0){Q.kind==="blank"&&q++;continue}const Ce=Q.raised||Q.lead_blank||q?{raised:Q.raised,leadBlank:Q.lead_blank,blankBefore:q}:void 0;q=0;let Le=!0;for(const Ae of Q.chars){const{before:F,after:se}=Lf(T.get(Ae.id)||[]),ve=(T.get(Ae.id)||[]).some(L=>L.kind==="break");le.push({charData:Ae,col:Q.col,beforePuncts:F,afterPuncts:se,...Le&&Ce?{start:Ce}:{}}),Le=!1,ve&&(W.push({id:`para-p${X.page}-${W.length}`,chars:le}),le=[])}}const D=le.length>0;return D&&W.push({id:`para-p${X.page}-${W.length}`,chars:le}),{page:X.page,paragraphs:W,endsOpen:D,...X.label?{label:X.label}:{},...q>0?{trailingBlank:q}:{}}}),V=new Map;if(!b){const X=new Map;for(const q of re)for(const D of q.columns)D.chars.length>0&&X.set(D.lead_blank||0,(X.get(D.lead_blank||0)||0)+1);let ge=0,W=-1;for(const[q,D]of X)(D>W||D===W&&q<ge)&&(ge=q,W=D);let le=null;for(const q of B){const D=q.paragraphs[0],Q=(he=D==null?void 0:D.chars[0])==null?void 0:he.start,Ce=!!Q&&!!(Q.raised||(Q.leadBlank||0)>ge||Q.blankBefore),Le=q.paragraphs.length===1&&!!q.trailingBlank;if(le&&D&&!Ce&&!Le){for(const Ae of D.chars)V.set(Ae.charData.id,le.owner);le.para.chars=le.para.chars.concat(D.chars),q.leadFirstId=D.chars[0].charData.id,q.paragraphs=q.paragraphs.slice(1)}if(q.endsOpen&&!q.trailingBlank){const Ae=q.paragraphs[q.paragraphs.length-1];Ae&&(le={para:Ae,owner:q.page})}else le=null}}return{pages:B,mergedOwner:V}},[n,e,T,b]),I=H.pages,R=g.useMemo(()=>{const re=[];for(const B of I)for(const V of B.paragraphs)for(const he of V.chars)re.push(he.charData.id);return re},[I]),P=g.useMemo(()=>{const re=new Map;if(!f||f.length===0)return re;const B=new Map(R.map((V,he)=>[V,he]));for(const V of f){if(!V.anchor)continue;const he=B.get(V.anchor.start),X=B.get(V.anchor.end);if(!(he===void 0||X===void 0||X<he))for(let ge=he;ge<=X;ge++)re.has(R[ge])||re.set(R[ge],V)}return re},[f,R]),K=Mo(x,k),te=P.size>0,ie=g.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:$});ie.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:$};const U=g.useMemo(()=>({click:re=>{var B,V;A.current=Date.now()+1200,(V=(B=ie.current).onCharClick)==null||V.call(B,re)},enter:re=>{var B,V;return(V=(B=ie.current).onCharHover)==null?void 0:V.call(B,re)},leave:()=>{var re,B;return(B=(re=ie.current).onCharHover)==null?void 0:B.call(re,null)},navigate:(re,B)=>{var he,X;if(!(B.detail===0||B.ctrlKey||B.metaKey||B.shiftKey)){B.preventDefault();return}(X=(he=ie.current).onEntityNavigate)==null||X.call(he,re,B)},detail:(re,B)=>{var V,he;return(he=(V=ie.current).onEntityNavigate)==null?void 0:he.call(V,re,B)}}),[]),pe=Bf(o,H.mergedOwner),G=g.useRef(null);g.useEffect(()=>{var B,V;if((B=G.current)==null||B.classList.remove("is-hovered"),G.current=null,!s)return;const re=(V=_.current)==null?void 0:V.querySelector(`span[data-char-id="${s}"]`);re&&(re.classList.add("is-hovered"),G.current=re)},[s]),g.useEffect(()=>{let re=null;const B=()=>{var se,ve;re=null;const he=window.getSelection(),X=_.current;if(!he||he.isCollapsed||he.rangeCount===0||!X)return;const ge=he.getRangeAt(0),W=ge.commonAncestorContainer,le=W.nodeType===3?W.parentElement:W;if(!le||!X.contains(le))return;const q=X.querySelectorAll("span[data-char-id]"),D=L=>L.firstChild??L;let Q=0,Ce=q.length;for(;Q<Ce;){const L=Q+Ce>>1;ge.comparePoint(D(q[L]),0)<0?Q=L+1:Ce=L}const Le=Q;for(Ce=q.length;Q<Ce;){const L=Q+Ce>>1;ge.comparePoint(D(q[L]),0)<=0?Q=L+1:Ce=L}let Ae=Q-1;if(Ae>=Le&&ge.endOffset===0&&ge.endContainer===D(q[Ae])&&Ae--,Ae<Le)return;const F=[];for(let L=Le;L<=Ae;L++)F.push(q[L].getAttribute("data-char-id"));F.length>0&&(A.current=Date.now()+1200,(ve=(se=ie.current).onSelectionChange)==null||ve.call(se,F))},V=()=>{re&&clearTimeout(re),re=setTimeout(B,120)};return document.addEventListener("selectionchange",V),()=>{document.removeEventListener("selectionchange",V),re&&clearTimeout(re)}},[]),g.useEffect(()=>{var re;if(o.size===1){const B=Array.from(o)[0],V=(re=_.current)==null?void 0:re.querySelector(`span[data-char-id="${B}"]`);V&&V.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[o]);const ee=re=>{var he;const B=_.current;if(!B)return null;const V=(he=I.find(X=>X.page===re))==null?void 0:he.leadFirstId;return V?B.querySelector(`span[data-char-id="${V}"]`):B.querySelector(`[data-page-section="${re}"]`)},ae=m==null?void 0:m.nonce;g.useEffect(()=>{if(!m)return;const re=ee(m.page);re&&(A.current=Date.now()+800,re.scrollIntoView({behavior:"auto",block:"start"}))},[ae]);const Se=!!h,O=Se&&typeof w=="number",[je,de]=g.useState(null),we=Br(je??w??0),Te=g.useRef(null);Te.current=O?we:null;const Fe=g.useRef(()=>{});return g.useEffect(()=>{if(!Se)return;const re=[],B=[];for(const ge of I){const W=ee(ge.page);W&&(re.push(W),B.push(ge.page))}if(re.length===0)return;let V=0;const he=()=>{var q,D;if(V=0,Date.now()<A.current||re.length>1&&re[0].getBoundingClientRect().top===re[re.length-1].getBoundingClientRect().top)return;const ge=Te.current===null?120:Te.current*window.innerHeight;let W=0,le=re.length-1;for(;W<le;){const Q=W+le+1>>1;re[Q].getBoundingClientRect().top<=ge?W=Q:le=Q-1}(D=(q=ie.current).onVisiblePageChange)==null||D.call(q,B[W])},X=()=>{V||(V=requestAnimationFrame(he))};return Fe.current=()=>{V||(V=requestAnimationFrame(he))},window.addEventListener("scroll",X,{passive:!0}),he(),()=>{window.removeEventListener("scroll",X),V&&cancelAnimationFrame(V),Fe.current=()=>{}}},[Se,I]),g.useEffect(()=>{O&&Fe.current()},[O,we]),t.jsxs("div",{ref:_,className:"guji-text-pane-content",children:[te&&t.jsx("style",{children:Ao}),O&&t.jsx(Hf,{y:we,containerRef:_,onDrag:de,onCommit:re=>{de(null),v==null||v(re)}}),t.jsx("div",{className:"guji-text-reflow-view",children:I.map((re,B)=>t.jsx(Wf,{pGroup:re,first:B===0,pageBreaks:b,markOpts:z,plainBooks:M,selected:pe.get(re.page)??Mf,entityOfChar:P,entityLoader:K,convert:u,buildHref:y??Rf,handlers:U},`page-sec-${re.page}`))})]})},Mf=new Set,Pf=[];function Bf(e,n){const i=g.useRef(new Map);return g.useMemo(()=>{const o=new Map;e.forEach(a=>{const l=n.get(a)??parseInt(a.split(":")[0],10);let d=o.get(l);d||o.set(l,d=new Set),d.add(a)});const s=new Map;return o.forEach((a,l)=>{const d=i.current.get(l),c=d&&d.size===a.size&&Array.from(a).every(p=>d.has(p));s.set(l,c?d:a)}),i.current=s,s},[e,n])}function ma({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 Of(e,n){const i=Array.from(n(e.join("")));return i.length===e.length&&e.every(o=>Array.from(o).length===1)?i:e.map(o=>n(o))}const Wf=g.memo(function({pGroup:n,first:i,pageBreaks:o,markOpts:s,plainBooks:a,selected:l,entityOfChar:d,entityLoader:c,convert:p,buildHref:h,handlers:u}){const m=g.useMemo(()=>{const y=new Map;if(!p)return y;for(const $ of n.paragraphs){const b=Of($.chars.map(w=>w.charData.norm??w.charData.char),p);$.chars.forEach((w,v)=>y.set(w.charData.id,b[v]))}return y},[n,p]),f=y=>m.get(y.id)??y.char,{t:x}=ne(),k=y=>{const $=s?Lc(y.mark,s):y.mark;return $?t.jsx("span",{className:"guji-text-punct","data-punct-id":y.id,children:$},y.id):null};return t.jsxs("section",{"data-page-section":n.page,className:"guji-page-section",style:{position:"relative",scrollMarginTop:96},children:[!i&&o&&t.jsxs("div",{className:"guji-page-divider",style:{display:"flex",alignItems:"center",margin:"2rem 0 1.2rem",color:r("meta-fg"),fontSize:"0.82rem",letterSpacing:"0.08em",userSelect:"none"},children:[t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}}),t.jsxs("span",{style:{padding:"0 12px",fontWeight:500},"data-page-label":n.label,title:n.label?`${n.page}`:void 0,children:["第 ",n.label??n.page," 葉"]}),t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}})]}),n.paragraphs.map((y,$)=>t.jsxs("p",{className:"guji-reflow-paragraph",children:[Af(y.chars,d).map((b,w)=>{const v=b.chars.map(({charData:S,beforePuncts:_,afterPuncts:A,start:T},z)=>{const M=!!b.entity&&z===0,H=!!b.entity&&z===b.chars.length-1,I=M?[]:_,R=H?[]:A;return t.jsxs(g.Fragment,{children:[T&&T.blankBefore>0&&t.jsx(ma,{n:T.blankBefore}),I.map(k),t.jsx("span",{"data-char-id":S.id,onClick:()=>u.click(S.id),onMouseEnter:()=>u.enter(S.id),onMouseLeave:u.leave,className:`guji-text-char${l.has(S.id)?" is-selected":""}${S.sub?" is-sub":""}${S.lane==="solo"?" is-solo":""}${S.lacuna?" is-lacuna":""}${S.guess?" is-guess":""}${S.zi?" is-zi":""}${T!=null&&T.raised?" is-raised":""}`,"data-raised":(T==null?void 0:T.raised)||void 0,title:S.lacuna?x("detail.lacuna"):S.zi?x("detail.composedChar",{label:S.zi}):S.guess?x("reader.charGuess"):void 0,children:f(S)}),R.map(k)]},S.id)});if(!b.entity)return t.jsx(g.Fragment,{children:v},`r${w}`);const j=b.chars[0].beforePuncts.map(k),C=b.chars[b.chars.length-1].afterPuncts.map(k);return t.jsxs(g.Fragment,{children:[j,t.jsx(Po,{span:b.entity,label:b.chars.map(S=>f(S.charData)).join(""),hasBrackets:!0,plain:a&&b.entity.kind==="work",loader:c,buildHref:h,onNavigate:u.navigate,onCardNavigate:u.detail,renderText:()=>v,hoverDelayMs:250}),C]},`${b.entity.key}@${w}`)}),$===n.paragraphs.length-1&&n.trailingBlank?t.jsx(ma,{n:n.trailingBlank}):null]},y.id))]})});function Br(e){const[n,i]=On,o=Number.isFinite(e)?e:.33;return Math.round(Math.min(i,Math.max(n,o))*1e3)/1e3}const Ff=.02,li=16;function Hf({y:e,containerRef:n,onDrag:i,onCommit:o}){const{t:s}=ne(),[a,l]=g.useState(0),d=g.useRef(!1),c=g.useRef(e);c.current=e;const p=g.useCallback(()=>{var f,x;const m=(x=((f=n.current)==null?void 0:f.querySelector(".guji-text-reflow-view"))??n.current)==null?void 0:x.getBoundingClientRect();l(Math.max(0,((m==null?void 0:m.left)??0)-li-2))},[n]);g.useLayoutEffect(()=>(p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)),[p]);const h=u=>Br(u/Math.max(1,window.innerHeight));return t.jsx("div",{role:"slider",tabIndex:0,className:"guji-page-indicator","aria-label":s("reader.pageIndicator"),"aria-orientation":"vertical","aria-valuemin":Math.round(On[0]*100),"aria-valuemax":Math.round(On[1]*100),"aria-valuenow":Math.round(e*100),"data-indicator-y":e,style:{position:"fixed",left:a,top:`calc(${e*100}vh - ${li/2}px)`,width:li,height:li,zIndex:20,cursor:"ns-resize",touchAction:"none",background:r("accent"),clipPath:"polygon(0 0, 100% 50%, 0 100%)",outline:"none"},onPointerDown:u=>{d.current=!0;try{u.currentTarget.setPointerCapture(u.pointerId)}catch{}u.preventDefault()},onPointerMove:u=>{if(!d.current)return;const m=h(u.clientY);c.current=m,i(m)},onPointerUp:u=>{if(d.current){d.current=!1;try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}o(h(u.clientY))}},onPointerCancel:()=>{d.current&&(d.current=!1,o(c.current))},onKeyDown:u=>{const m=u.key==="ArrowUp"?-1:u.key==="ArrowDown"?1:0;m&&(u.preventDefault(),o(Br(e+m*(u.shiftKey?5:1)*Ff)))}})}const qc=1,Kc=6,ci={s:1,x:0,y:0},hi=(e,n,i)=>Math.min(i,Math.max(n,e));function Oo(e,n,i){const o=hi(e.s,qc,Kc);return{s:o,x:hi(e.x,n*(1-o),0),y:hi(e.y,i*(1-o),0)}}function ur(e,n,i,o,s,a){const l=hi(e.s*o,qc,Kc),d=l/e.s;return Oo({s:l,x:n-(n-e.x)*d,y:i-(i-e.y)*d},s,a)}function Df(e,n,i,o,s){return Oo({s:e.s,x:e.x+n,y:e.y+i},o,s)}function Uf(e,n,i){const o=n===1?e*16:n===2?e*400:e;return Math.exp(-o*(i?.01:.0015))}const ha=4,Vf=g.forwardRef(function({children:n,onScaleChange:i,resetKey:o,style:s},a){const l=g.useRef(null),[d,c]=g.useState(ci),p=g.useRef(d),h=g.useRef(i);h.current=i;const u=b=>{var v;const w=p.current;p.current=b,c(b),b.s!==w.s&&((v=h.current)==null||v.call(h,b.s))},m=()=>{var w;const b=(w=l.current)==null?void 0:w.getBoundingClientRect();return{w:(b==null?void 0:b.width)??0,h:(b==null?void 0:b.height)??0,left:(b==null?void 0:b.left)??0,top:(b==null?void 0:b.top)??0}};g.useImperativeHandle(a,()=>({zoomBy(b){const{w,h:v}=m();u(ur(p.current,w/2,v/2,b,w,v))},reset(){u(ci)}})),g.useEffect(()=>{u(ci)},[o]),g.useEffect(()=>{const b=l.current;if(!b||typeof ResizeObserver>"u")return;const w=new ResizeObserver(()=>{const{w:v,h:j}=m(),C=Oo(p.current,v,j);(C.x!==p.current.x||C.y!==p.current.y)&&u(C)});return w.observe(b),()=>w.disconnect()},[]),g.useEffect(()=>{const b=l.current;if(!b)return;const w=v=>{const j=Uf(v.deltaY,v.deltaMode,v.ctrlKey);if(p.current.s<=1&&j<1)return;v.preventDefault();const{w:C,h:S,left:_,top:A}=m();u(ur(p.current,v.clientX-_,v.clientY-A,j,C,S))};return b.addEventListener("wheel",w,{passive:!1}),()=>b.removeEventListener("wheel",w)},[]);const f=g.useRef(new Map),x=g.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),k=b=>{if(b.pointerType==="mouse"&&b.button!==0)return;f.current.set(b.pointerId,{x:b.clientX,y:b.clientY});const w=x.current;if(w.swallowClick=!1,f.current.size===1&&(w.moved=0,w.dragging=!1),f.current.size===2){const[v,j]=[...f.current.values()];w.pinchDist=Math.hypot(v.x-j.x,v.y-j.y),w.moved=ha+1}},y=b=>{var M;const w=f.current.get(b.pointerId);if(!w)return;const v={x:b.clientX,y:b.clientY};f.current.set(b.pointerId,v);const j=x.current,{w:C,h:S,left:_,top:A}=m();if(f.current.size>=2){const[H,I]=[...f.current.values()],R=Math.hypot(H.x-I.x,H.y-I.y);if(j.pinchDist>0&&R>0){const P=(H.x+I.x)/2-_,K=(H.y+I.y)/2-A;u(ur(p.current,P,K,R/j.pinchDist,C,S))}j.pinchDist=R,j.swallowClick=!0;return}const T=v.x-w.x,z=v.y-w.y;if(j.moved+=Math.abs(T)+Math.abs(z),!(j.moved<=ha)){if(!j.dragging){j.dragging=!0;try{(M=l.current)==null||M.setPointerCapture(b.pointerId)}catch{}}j.swallowClick=!0,p.current.s>1&&u(Df(p.current,T,z,C,S))}},$=b=>{f.current.delete(b.pointerId);const w=x.current;w.pinchDist=0,f.current.size===0&&(w.dragging=!1)};return t.jsx("div",{ref:l,className:"bim-zp","data-zoom":d.s.toFixed(2),onPointerDown:k,onPointerMove:y,onPointerUp:$,onPointerCancel:$,onClickCapture:b=>{x.current.swallowClick&&(x.current.swallowClick=!1,b.stopPropagation(),b.preventDefault())},onDoubleClick:()=>u(ci),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 Xc(e,n,i,o){const[s,a]=g.useState(n??null),[l,d]=g.useState(!1),c=g.useRef(0);return g.useEffect(()=>{if(n!==void 0){a(n);return}const p=++c.current;if(!i){a(null),d(!1);return}if(e){let h;try{h=e(i,o)}catch{a(null),d(!1);return}if(!h||typeof h.then!="function"){a(h??null),d(!1);return}d(!0),h.then(u=>{p===c.current&&a(u??null)}).catch(()=>{p===c.current&&a(null)}).finally(()=>{p===c.current&&d(!1)});return}a(null),d(!1)},[e,n,i,o]),{warpData:s,loading:l}}function Gf(e,n,i){const[o,s]=g.useState([]),a=g.useRef(0);return g.useEffect(()=>{const l=++a.current;if(!e||!n){s([]);return}let d;try{d=e(n,i)}catch{s([]);return}Promise.resolve(d).then(c=>{l===a.current&&s(c?Bc(c):[])}).catch(()=>{l===a.current&&s([])})},[e,n,i]),o}const ga={padding:24,color:r("desc-fg"),fontSize:14};function fa({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 xa=/^https?:\/\//i,Yf=[];function qf(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&&xa.test(i)?i:void 0,license:n(e.license),license_url:o&&xa.test(o)?o:void 0,note:n(e.note)};return s.name||s.license||s.note?s:null}function Kf(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 Xf(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)?"冊":ke.isCollatedKind(e==null?void 0:e.kind)?"卷":"章"}function Zc(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 Zf(e,n,i,o,s){var p;const a=new Map(e.chapters.map(h=>[h.file,h])),l=h=>h==="loading"?"…":typeof h=="number"&&h>0?h:void 0,d=(h,u)=>{const m=a.get(h);return{key:h,label:u??(m?Zc(m,i,o,s):h),hint:l(n[h]),disabled:n[h]===0}},c=(p=e.juan_groups)==null?void 0:p.filter(h=>{var u;return h.files.some(m=>a.has(m))||((u=h.children)==null?void 0:u.length)});if(c&&c.length>0){const h=(u,m)=>{var x;if(u.files.length===1&&!((x=u.children)!=null&&x.length))return d(u.files[0],o(u.label));const f=sf(u,n);return{key:`group:${m}`,label:o(u.label),hint:f==="loading"?"…":typeof f=="number"&&f>0?`${f}`:Hc(u),defaultExpanded:typeof f=="number"&&f>0,children:[...u.files.filter(k=>a.has(k)).map(k=>d(k)),...(u.children??[]).map((k,y)=>h(k,`${m}.${y}`))]}};return c.map((u,m)=>h(u,`${m}`))}return e.chapters.map(h=>d(h.file))}const Wo=e=>{const n=Ul();return t.jsx(zu,{mode:n[0].scriptMode,children:t.jsx(Jf,{...e,prefsState:n})})},Jf=({prefsState:e,id:n,transport:i,versionKey:o,chapter:s,onLocationChange:a,onNavigate:l,title:d,subtitle:c,resolveImages:p,renderImageOverlay:h,imagePanel:u,allowVertical:m,onReportError:f,revisedAt:x,backHref:k,backLabel:y,resolveWarpData:$,warpData:b,resolveEntities:w,onEntityNavigate:v,className:j,style:C})=>{var ds,ps,us;const{t:S,convert:_}=ne(),A=g.useMemo(()=>Ll(i),[i]),[T,z]=e,M=rt(),H=g.useRef(a);H.current=a;const[I,R]=g.useState(null),[P,K]=g.useState("loading");g.useEffect(()=>{let E=!1;return R(null),K("loading"),A.getManifest(n).then(ue=>{E||(ue?(R(ue),K("ready")):K("missing"))}).catch(()=>{E||K("missing")}),()=>{E=!0}},[A,n]);const te=o!==void 0,ie=s!==void 0,[U,pe]=g.useState(null),[G,ee]=g.useState(null);g.useEffect(()=>{pe(null),ee(null)},[n]);const ae=ke.pickTextVersion(I,te?o:U),Se=((ds=I==null?void 0:I.versions.find(E=>E.key==="default"))==null?void 0:ds.key)??((ps=I==null?void 0:I.versions[0])==null?void 0:ps.key)??"default",O=(ae==null?void 0:ae.key)??null,je=ie?s:G,de=g.useCallback((E,ue,Ne)=>{var Ue;(Ue=H.current)==null||Ue.call(H,{key:E,chapter:ue,isDefault:E===Se},Ne)},[Se]);g.useEffect(()=>{!I||!te||o==null||I.versions.some(E=>E.key===o)||de(Se,null,"auto")},[I,te,o,Se,de]);const we=g.useRef(new Map);g.useEffect(()=>{we.current.clear()},[A,n]);const Te=g.useCallback(async E=>{const ue=`${n}
1359
+ ${E}`;if(we.current.has(ue))return we.current.get(ue)??null;const Ne=await A.getIndex(n,E).catch(()=>null);return Ne&&we.current.set(ue,Ne),Ne},[A,n]),[Fe,re]=g.useState(null),[B,V]=g.useState("loading"),he=O?`${n}
1360
+ ${O}`:null,X=Fe&&Fe.owner===he?Fe.idx:null;g.useEffect(()=>{if(!O)return;let E=!1;const ue=`${n}
1361
+ ${O}`;return re(null),V("loading"),Te(O).then(Ne=>{E||(Ne&&Ne.chapters.length>0?(re({owner:ue,idx:Ne}),V("ready")):V("failed"))}),()=>{E=!0}},[n,O,Te]),g.useEffect(()=>{if(!X||!O||je!=null&&X.chapters.some(Ne=>Ne.file===je))return;const ue=X.chapters[0].file;ie||ee(ue),de(O,ue,"auto")},[X,O,je,ie,de]);const ge=X?je!=null&&X.chapters.some(E=>E.file===je)?je:X.chapters[0].file:je,W=g.useMemo(()=>X&&ge?X.chapters.find(E=>E.file===ge)??null:null,[X,ge]),le=g.useRef(0),q=g.useCallback(async E=>{if(!I||E===O||!I.versions.some(wt=>wt.key===E))return;const ue=++le.current,Ne=await Te(E);if(ue!==le.current)return;const Ue=W??(ge?{file:ge}:null),nt=ke.matchChapterAcrossVersions(Ue,Ne);te||pe(E),ie||ee(nt),de(E,nt,"version")},[I,O,Te,W,ge,te,ie,de]),D=g.useCallback(E=>{O&&(ie||ee(E),de(O,E,"chapter"))},[O,ie,de]),[Q,Ce]=g.useState(null),Le=O&&W?`${n}
1355
1362
  ${O}
1356
- ${Q.file}`:null,[Le,F]=g.useState(null),ae=Me!==null&&Le!==Me,fe=g.useRef(0);g.useEffect(()=>{if(!O||!Q)return;const E=++fe.current,ue=`${n}
1363
+ ${W.file}`:null,[Ae,F]=g.useState(null),se=Le!==null&&Ae!==Le,ve=g.useRef(0);g.useEffect(()=>{if(!O||!W)return;const E=++ve.current,ue=`${n}
1357
1364
  ${O}
1358
- ${Q.file}`;Te(null),L.getChapter(n,O,Q.file,{json:!!Q.has_json}).then(Ne=>{E===fe.current&&Te(Ne)}).catch(()=>{E===fe.current&&Te(null)}).finally(()=>{E===fe.current&&F(ue)})},[L,n,O,Q]);const P=ke.isCollatedKind(ce==null?void 0:ce.kind),[xe,re]=g.useState("");g.useEffect(()=>{re("")},[n,O]);const je=g.useMemo(()=>O&&P?async E=>{const ue=await L.getChapter(n,O,E,{json:!0});return{juan:(ue==null?void 0:ue.json)??null,rawText:(ue==null?void 0:ue.md)??null}}:null,[L,n,O,P]),Se=(K==null?void 0:K.type)==="kaozhen",Ve=g.useMemo(()=>(K==null?void 0:K.chapters.map(E=>E.file))??[],[K]),{matchStates:Ye}=gf({resetKey:`${n}
1359
- ${O??""}`,load:je,files:Ve,activeFile:B??null,activeJuan:(se==null?void 0:se.json)??null,activeRawText:(se==null?void 0:se.md)??null,query:xe,isKaozhen:Se}),et=g.useRef(new Map);g.useEffect(()=>{et.current.clear()},[n]);const Ze=g.useMemo(()=>({versionKey:O,chapter:Q??null}),[O,Q]),I=Hg(p,B??null,Ze),{warpData:Y,loading:pe}=Xc($,b,B??null,Ze),ve=Hf(w,B??null,Ze),Ee=T.properNameMode??(ve.length>0?"full":"off"),ge=g.useMemo(()=>({...T,properNameMode:Ee}),[T,Ee]),Ae=g.useMemo(()=>Fg(ve,Ee,{showWorks:ge.showWorks}),[ve,Ee,ge.showWorks]),[qe,X]=g.useState(new Set),[$e,Fe]=g.useState(null),[We,Re]=g.useState(!0),be=T.preserveMargins;g.useCallback(E=>z({preserveMargins:E}),[z]);const Be=g.useRef(null),[_e,Je]=g.useState(1),[He,ot]=g.useState(null),Et=E=>{var Ne;const ue=parseInt(((Ne=E==null?void 0:E.page_id)==null?void 0:Ne.split(":")[1])??"",10);return isNaN(ue)?null:ue},jt=E=>{var Ne,Ue;const ue=(E==null?void 0:E.pages)??[];return Et(E)??((Ne=ue.find(tt=>tt.columns.some(wt=>wt.chars.length>0)))==null?void 0:Ne.page)??((Ue=ue[0])==null?void 0:Ue.page)??1},[Ge,Z]=g.useState(()=>jt(Y)),De=`${n}
1365
+ ${W.file}`;Ce(null),A.getChapter(n,O,W.file,{json:!!W.has_json}).then(Ne=>{E===ve.current&&Ce(Ne)}).catch(()=>{E===ve.current&&Ce(null)}).finally(()=>{E===ve.current&&F(ue)})},[A,n,O,W]);const L=ke.isCollatedKind(ae==null?void 0:ae.kind),[me,oe]=g.useState("");g.useEffect(()=>{oe("")},[n,O]);const be=g.useMemo(()=>O&&L?async E=>{const ue=await A.getChapter(n,O,E,{json:!0});return{juan:(ue==null?void 0:ue.json)??null,rawText:(ue==null?void 0:ue.md)??null}}:null,[A,n,O,L]),_e=(X==null?void 0:X.type)==="kaozhen",Ve=g.useMemo(()=>(X==null?void 0:X.chapters.map(E=>E.file))??[],[X]),{matchStates:Ye}=yf({resetKey:`${n}
1366
+ ${O??""}`,load:be,files:Ve,activeFile:ge??null,activeJuan:(Q==null?void 0:Q.json)??null,activeRawText:(Q==null?void 0:Q.md)??null,query:me,isKaozhen:_e}),tt=g.useRef(new Map);g.useEffect(()=>{tt.current.clear()},[n]);const Ze=g.useMemo(()=>({versionKey:O,chapter:W??null}),[O,W]),N=Gg(p,ge??null,Ze),{warpData:Y,loading:ce}=Xc($,b,ge??null,Ze),ye=Gf(w,ge??null,Ze),Ee=T.properNameMode??(ye.length>0?"full":"off"),fe=g.useMemo(()=>({...T,properNameMode:Ee}),[T,Ee]),Me=g.useMemo(()=>Vg(ye,Ee,{showWorks:fe.showWorks}),[ye,Ee,fe.showWorks]),[qe,Z]=g.useState(new Set),[ze,We]=g.useState(null),[Oe,Re]=g.useState(!0),xe=T.preserveMargins;g.useCallback(E=>z({preserveMargins:E}),[z]);const Be=g.useRef(null),[$e,Je]=g.useState(1),[He,ot]=g.useState(null),Et=E=>{var Ne;const ue=parseInt(((Ne=E==null?void 0:E.page_id)==null?void 0:Ne.split(":")[1])??"",10);return isNaN(ue)?null:ue},jt=E=>{var Ne,Ue;const ue=(E==null?void 0:E.pages)??[];return Et(E)??((Ne=ue.find(nt=>nt.columns.some(wt=>wt.chars.length>0)))==null?void 0:Ne.page)??((Ue=ue[0])==null?void 0:Ue.page)??1},[Ge,J]=g.useState(()=>jt(Y)),De=`${n}
1360
1367
  ${O}
1361
- ${B??""}`,[Qe,$t]=g.useState({key:De,data:Y,started:!!Y});if(Qe.key!==De)$t({key:De,data:Y,started:!1});else if(Y!==Qe.data&&($t({key:De,data:Y,started:!!Y}),Y)){const E=Y.pages??[];(!Qe.started||!E.some(ue=>ue.page===Ge))&&Z(jt(Y))}g.useEffect(()=>{X(new Set),Fe(null)},[B,O]);const _p=g.useCallback(E=>{if(X(new Set(E)),E.length>0){const ue=E[0],Ne=parseInt(ue.split(":")[0],10);isNaN(Ne)||Z(Ne)}},[]),Rt=g.useMemo(()=>{const E=new Map;for(const ue of(Y==null?void 0:Y.pages)??[])E.set(ue.page,ue);return E},[Y]),wn=Et(Y),qn=g.useCallback(E=>{var Ue;const ue=I.images;if(!ue||ue.length===0)return;const Ne=(Ue=Rt.get(E))==null?void 0:Ue.seq;return(Ne?ue.find(tt=>tt.seq===Ne):void 0)??ue.find(tt=>tt.pageNo===E)??ue[E-1]},[I.images,Rt]),es=_e>1.5,Kn=g.useCallback((E,ue=!1)=>{const Ne=qn(E);return Ne?E===wn||ue?Ne.hiresUrl??Ne.url:Ne.url:E===wn?(Y==null?void 0:Y.imageUrl)??"":""},[qn,Y,wn]),$p=g.useMemo(()=>Kn(Ge,es),[Kn,Ge,es]),Lt=g.useMemo(()=>[...Rt.keys()].sort((E,ue)=>E-ue),[Rt]),Xn=g.useRef(Ge);Xn.current=Ge;const ts=g.useRef(0),Zn=g.useCallback(E=>{var ue;Xn.current===E||!Rt.has(E)||(ts.current=Date.now()+1e3,Xn.current=E,Z(E),(ue=Rt.get(E))!=null&&ue.columns.some(Ne=>Ne.chars.length>0)&&ot(Ne=>({page:E,nonce:((Ne==null?void 0:Ne.nonce)??0)+1})))},[Rt]),Sn=g.useCallback(E=>{const ue=Xn.current,Ne=Lt.indexOf(ue),Ue=Lt[Ne<0?0:Ne+E];Ue===void 0||Ue===ue||Zn(Ue)},[Lt,Zn]),ns=g.useCallback(E=>{if(!E.trim().match(/^\d+$/)||Lt.length===0)return null;const Ne=parseInt(E.trim(),10),Ue=Number.isFinite(Ne)?Ne:Number.MAX_SAFE_INTEGER;return Lt.reduce((tt,wt)=>Math.abs(wt-Ue)<Math.abs(tt-Ue)?wt:tt,Lt[0])},[Lt]),[qi,Ki]=g.useState(null),Jn=g.useRef(null),Cp=g.useCallback(E=>{Jn.current=E,Ki(E)},[]),is=g.useCallback(()=>{const E=Jn.current;if(Jn.current=null,Ki(null),E===null)return;const ue=ns(E);ue!==null&&Zn(ue)},[ns,Zn]),Xi=Lt.indexOf(Ge),zp=g.useCallback(E=>{if(E.altKey||E.ctrlKey||E.metaKey)return;const ue=E.target.tagName;ue==="INPUT"||ue==="TEXTAREA"||ue==="SELECT"||(E.key==="ArrowLeft"||E.key==="PageUp"?(E.preventDefault(),Sn(-1)):(E.key==="ArrowRight"||E.key==="PageDown")&&(E.preventDefault(),Sn(1)))},[Sn]);g.useEffect(()=>{if(Y)for(const E of[1,-1,2,3]){const ue=Kn(Ge+E);ue&&Pr(ue)}},[Y,Ge,Kn]);const rs=g.useMemo(()=>{var gs;if(!Y)return null;if(Ge===wn)return Y;const E=Rt.get(Ge);if(E&&E.width>0&&E.height>0)return{page_id:`p:${Ge}`,title:`第${Ge}葉`,image_size:[E.width,E.height],total_warped_w:E.width,columns:[{col:1,warped_w:E.width,warped_h:E.height,offset_x:0,strips:[],chars:E.columns.flatMap(Xe=>Xe.chars).map(Xe=>({id:Xe.id,char:Xe.char,slot:Xe.slot,pos:Xe.pos,sub:Xe.sub,bbox_col:Xe.bbox??[0,0,0,0]}))}]};const ue=(gs=Y.pages)==null?void 0:gs.find(Xe=>Xe.page===Ge),[Ne,Ue]=Y.image_size||[2386,3082],tt=qn(Ge),wt=(tt==null?void 0:tt.width)??Ne,tr=(tt==null?void 0:tt.height)??Ue,us=wt/Ne,ms=tr/Ue,hs=new Map;for(const Xe of Y.columns){const ft=(Xe.strips||[]).flatMap(ii=>ii.srcQuad.map(ri=>ri[0]));if(ft.length===0)continue;const At=Xe.top_y??0,nr=Xe.bottom_y??At+Xe.warped_h;hs.set(Xe.col,{x0:Math.min(...ft),x1:Math.max(...ft),top:At,slotH:(nr-At)/21})}return{page_id:`p:${Ge}`,title:`第${Ge}葉`,image_size:[wt,tr],total_warped_w:wt,columns:ue?ue.columns.map(Xe=>{const ft=hs.get(Xe.col)??{x0:0,x1:0,top:0,slotH:118};return{col:Xe.col,warped_w:wt,warped_h:tr,offset_x:0,strips:[],chars:Xe.chars.map(At=>{const nr=At.slot??At.pos??0,ii=(ft.top+(nr-1)*ft.slotH)*ms,ri=(ft.x0+ft.x1)/2,[Pp,Bp]=At.sub==="a"?[ri,ft.x1]:At.sub==="b"?[ft.x0,ri]:[ft.x0,ft.x1];return{...At,bbox_col:[Pp*us,ii,Bp*us,ii+ft.slotH*ms]}})}}):[]}},[Y,Ge,wn,Rt,qn]),{entryTitle:Qn,authors:os}=Zf(n,i,d===void 0),[ss,Zi]=g.useState("text");if(g.useEffect(()=>{Zi("text")},[B,O]),A==="loading")return t.jsx(ga,{className:j,style:C,title:d??Qn,label:S("reader.loading")});if(A==="missing"||!N||!ce)return t.jsx("div",{className:j,style:{...C,...ha},children:S("reader.noText")});if(W==="failed")return t.jsx("div",{className:j,style:{...C,...ha},children:S("reader.tocFailed")});if(!K)return t.jsx(ga,{className:j,style:C,title:d??Qn,label:S("reader.tocLoading")});const Xt=Gf(ce,K),Tp=Yf(K,Ye,Xt,_,P),Ji=N.versions.map(E=>({key:E.key,label:ke.textVersionLabel(E),optionLabel:_(ke.textVersionLabel(E)),sourceName:xa(E)?S("reader.originalSource"):E.source_name?_(E.source_name):void 0,license:E.license??void 0,sourceUrl:E.source_url??void 0,primary:E.key===we})),gt=Uf((ps=K.source)==null?void 0:ps.upstream),ei=(typeof d=="string"?_(d):d)??(K.title?_(K.title):Qn?_(Qn):void 0),as=ce.edition_label?_(ce.edition_label):void 0,Qi=ei?t.jsx("a",{href:M(n),title:S("reader.viewEntry"),onClick:l?E=>{E.metaKey||E.ctrlKey||(E.preventDefault(),l(n))}:void 0,children:ei}):void 0,Np=Qi&&as?t.jsxs(t.Fragment,{children:[Qi,t.jsxs("span",{className:"bim-rd-ed",children:["·",as]})]}):Qi,Ip=os.length>0?_(os.slice(0,2).map(E=>`${E.dynasty?`〔${E.dynasty}〕`:""}${E.name}${` ${E.role||S("reader.defaultRole")}`}`).join("、")):void 0,er=Q?Zc(Q,Xt,_,P):void 0,Zt=P&&!!(se!=null&&se.json),Jt=(se==null?void 0:se.json)??null,ln=(se==null?void 0:se.md)??null,ls=Zt&&!Se&&Dc(Jt.sections),Ep=ls&&!(ln&&ge.readingMode==="paragraph"&&ji(ln)),Rp=Zt&&ls?t.jsx(ff,{juan:Jt,view:ss,onView:Zi,textHasEntries:Ep}):void 0,Lp=!0,ti=ln?ln.replace(/^##\s+[^\n]+\n+/,""):null,ni=xa(ce),Dt=ni?S("reader.originalSource"):ce.source_name?_(ce.source_name):void 0,Ap=(typeof c=="string"?_(c):c)??(ni?void 0:Dt??_(ke.textVersionLabel(ce))),Mp=(Y==null?void 0:Y.hasNorm)===!0;return t.jsxs(Yl,{className:j,style:C,title:Np,subtitle:Ap,byline:Ip,current:er,pagerUnit:Xt,rail:Rp,revisedAt:x,backHref:k,backLabel:y,onReportError:f?E=>f({...E,bookTitle:typeof ei=="string"?ei:void 0,entryId:n}):void 0,workLinkToggle:Zt&&!Se&&!!l&&!!(Jt!=null&&Jt.sections.some(E=>E.work_id)),toc:Tp,tocCaption:S("reader.tocCaption",{n:K.chapters.length,unit:_(Xt)}),tocHeader:P&&K.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:Se?S("reader.searchChaptersPlaceholder"):S("reader.searchUnitPlaceholder",{unit:_(Xt)}),"aria-label":Se?S("reader.searchChapters"):S("reader.searchUnit",{unit:_(Xt)}),value:xe,onChange:E=>re(E.target.value)}):void 0,activeKey:B??null,onSelect:D,images:I.images,renderImageOverlay:h,imagePanel:Y?"open":u,isWarpMode:!!Y,customImagePanel:Y&&rs?t.jsxs("div",{className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:zp,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:[qe.size>0&&t.jsxs("button",{type:"button",onClick:()=>X(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${r("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",qe.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:_e<=1,onClick:()=>{var E;return(E=Be.current)==null?void 0:E.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(_e*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:_e>=6,onClick:()=>{var E;return(E=Be.current)==null?void 0:E.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:_e===1,onClick:()=>{var E;return(E=Be.current)==null?void 0:E.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(Ff,{ref:Be,resetKey:Ge,onScaleChange:Je,style:{flex:1,minHeight:0},children:t.jsx(Ro,{imageUrl:$p,pageData:rs,selectedCharIds:qe,hoveredCharId:$e,preserveMargins:be,onCharClick:E=>{X(Ne=>{const Ue=new Set(Ne);return Ue.has(E)?Ue.delete(E):(Ue.clear(),Ue.add(E)),Ue});const ue=document.querySelector(`[data-char-id="${E}"]`);ue&&ue.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:Fe})}),t.jsxs("div",{"data-testid":"facsimile-pager",role:"group","aria-label":S("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:Xi<=0,onClick:()=>Sn(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":Ge,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":S("reader.facsimilePageInput"),size:Math.max(2,String(qi??Ge).length),value:qi??String(Ge),onFocus:E=>E.currentTarget.select(),onChange:E=>Cp(E.target.value),onKeyDown:E=>{E.key==="Enter"?(E.preventDefault(),is()):E.key==="Escape"&&(Jn.current=null,Ki(null)),E.stopPropagation()},onBlur:is,style:{width:`${Math.max(2,String(qi??Ge).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:Xi<0||Xi>=Lt.length-1,onClick:()=>Sn(1),children:"›"})]})]}):void 0,settingsAnnotate:Y?t.jsx("button",{type:"button",className:`bim-rd-t bim-rd-sp-tg ${We?"bim-rd-on":""}`,"aria-pressed":We,title:"切换外挂现代断句标点",onClick:()=>Re(E=>!E),children:We?"标点":"无标点"}):void 0,prefs:ge,onPrefsChange:z,versions:Ji.length>1?Ji:void 0,currentVersionKey:Ji.length>1?ce.key:void 0,onVersionChange:ie,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:ji(ln),allowVertical:m,origScriptAvailable:Mp,contentLoading:ae,children:[(ae||pe&&!Y&&!Zt&&ti==null)&&t.jsx(sn,{}),!ae&&Y&&t.jsxs("article",{className:"bim-rd-prose",style:{marginTop:0},children:[t.jsxs("header",{style:{marginBottom:16},children:[t.jsx("h1",{className:"bim-rd-h1",children:Q!=null&&Q.title?_(Q.title):er}),(Dt||ce.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[Dt,ce.license&&t.jsxs(t.Fragment,{children:[Dt&&t.jsx("span",{className:"bim-rd-dot"}),ce.license]})]})]}),t.jsx(Po,{pageData:Y,pages:Y.pages,punctuations:Y.punctuations||Df,selectedCharIds:qe,hoveredCharId:$e,onSelectionChange:_p,onCharClick:E=>{X(Ne=>{const Ue=new Set(Ne);return Ue.has(E)?Ue.delete(E):(Ue.clear(),Ue.add(E)),Ue});const ue=parseInt(E.split(":")[0],10);isNaN(ue)||Z(ue)},onCharHover:Fe,mode:"horizontal",showPunctuation:We,entities:Ae,entityTransport:i,onEntityNavigate:v,onVisiblePageChange:E=>{Date.now()>=ts.current&&Z(E)},convert:_,scrollToPage:He,pageBreaks:ge.pageBreaks,pageIndicatorY:ge.pageIndicatorY,onPageIndicatorYChange:E=>z({pageIndicatorY:E}),quoteStyle:ge.quoteStyle,bookTitleStyle:ge.bookTitleStyle,showWorks:ge.showWorks})]}),!ae&&!Y&&Zt&&Jt&&t.jsx(hf,{juan:Jt,rawText:ln,positionLabel:Kf(Q,K,Xt,_),groupLabel:Xf(K,B??null),index:Vf(n,K),searchQuery:xe,onNavigate:l,transport:i,workLabelCache:et,prefs:ge,view:ss,onViewChange:Zi},`${O}/${B}`),!ae&&!Y&&!Zt&&ti!=null&&Q&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:Q.title?_(Q.title):er}),(Dt||ce.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[ni&&Dt&&t.jsx(t.Fragment,{children:Dt}),!ni&&ce.source_name&&t.jsxs(t.Fragment,{children:[S("reader.textSource")," ",ce.source_url?t.jsx("a",{className:"bim-rd-link",href:ce.source_url,target:"_blank",rel:"noreferrer",children:_(ce.source_name)}):_(ce.source_name)]}),Dt&&ce.license&&t.jsx("span",{className:"bim-rd-dot"}),ce.license]}),gt&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[S("reader.upstream")," ",gt.url?t.jsx("a",{className:"bim-rd-link",href:gt.url,target:"_blank",rel:"noreferrer",children:_(gt.name??gt.url)}):_(gt.name??""),gt.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),gt.license_url?t.jsx("a",{className:"bim-rd-link",href:gt.license_url,target:"_blank",rel:"noreferrer",children:gt.license}):gt.license]}),gt.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(Al,{text:gt.note,convert:_})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(_o,{text:ti,mode:ge.readingMode,tables:Lp,gujiMarkdown:!0,bookMarking:So(ge),quoteStyle:ge.quoteStyle})})]}),!ae&&!pe&&!Y&&!Zt&&ti==null&&Q&&t.jsx("div",{className:"bim-rd-state",children:S("reader.chapterFailed")}),!ae&&K.references&&K.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:S("reader.references")}),t.jsx("ol",{children:K.references.map((E,ue)=>t.jsxs("li",{children:[E.url?t.jsx("a",{className:"bim-rd-link",href:E.url,target:"_blank",rel:"noopener noreferrer",children:_(E.title)}):t.jsx("span",{children:_(E.title)}),E.author&&t.jsxs("span",{children:[",",_(E.author)]}),E.note&&t.jsxs("span",{children:["。",_(E.note)]})]},ue))})]})]})};function xa(e){return e.is_original===!0||e.source==="original"}function Kf(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 Xf(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 Zf(e,n,i){const[o,s]=g.useState({entryTitle:void 0,authors:[]});return g.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let a=!1;return Promise.resolve(n.getItem(e)).then(l=>{if(a||!l)return;const d=(l.authors??[]).filter(c=>c&&c.name);s({entryTitle:i&&typeof l.title=="string"?l.title:void 0,authors:d})}).catch(()=>{}),()=>{a=!0}},[e,n,i]),o}const Jc={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")}},Jf=Jc.other,Qc={pending:{key:"pending",color:r("warning")},in_progress:{key:"in_progress",color:r("primary")},resolved:{key:"resolved",color:r("success")},wontfix:{key:"wontfix",color:r("desc-fg")},duplicate:{key:"duplicate",color:r("desc-fg")}},Qf=Qc.pending;function ex(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 tx(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 Oo=({items:e,loading:n})=>{const i=rt(),{t:o,convert:s}=te();return n?t.jsx(sn,{}):e.length===0?t.jsx("div",{style:nx,children:o("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=Jc[a.type]||Jf,d=Qc[a.status]||Qf,c=typeof window<"u"&&tx(a.pageUrl,window.location.href);return t.jsxs("div",{style:ix,children:[t.jsxs("div",{style:rx,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...ba,background:l.color},children:o(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...ba,background:d.color},children:o(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:ox,children:ex(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:sx,children:[a.resourceId&&t.jsx("a",{href:i(a.resourceId),style:mr,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:mr,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:mr,children:a.pageUrl}))]}),t.jsx("div",{style:ax,children:s(a.content)}),a.reply&&t.jsxs("div",{style:lx,children:[t.jsx("div",{style:cx,children:o("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},nx={textAlign:"center",padding:"40px 0",color:r("desc-fg"),fontSize:"14px"},ix={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"16px"},rx={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},ba={fontSize:"12px",color:r("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},ox={fontSize:"12px",color:r("desc-fg")},sx={fontSize:"12px",marginBottom:"6px"},mr={color:r("primary"),textDecoration:"none",borderBottom:`1px dashed ${r("primary")}`},ax={fontSize:"14px",lineHeight:"1.6",color:r("fg"),whiteSpace:"pre-wrap"},lx={marginTop:"12px",padding:"10px 12px",background:r("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:r("fg")},cx={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:r("primary")},Wr=({transport:e,onNavigate:n,recommendedIds:i,activeTab:o,onTabChange:s,feedbackApiUrl:a})=>{const l=Ie(),[d,c]=g.useState(null),[p,h]=g.useState([]),[u,m]=g.useState("recommend"),[f,x]=g.useState([]),[k,y]=g.useState(!1),$=o??u,b=R=>{m(R),s==null||s(R)},[w,v]=g.useState(!0),[j,C]=g.useState(null),[S,_]=g.useState(null),[L,T]=g.useState(null);g.useEffect(()=>{let R=!1;if(e.getCounts)return e.getCounts().then(A=>{R||c({works:A.works,books:A.books,collections:A.collections})}).catch(()=>{}),()=>{R=!0}},[e]),g.useEffect(()=>{let R=!1;return(async()=>{if(i)return i;if(e.getRecommended)try{const J=await e.getRecommended();if(J!=null&&J.groups)return J.groups.flatMap(ee=>ee.items.map(oe=>({...oe,group:ee.name})))}catch{}return[]})().then(async J=>{if(R)return;const ee=J.filter(V=>V.id);if(ee.length===0){v(!1);return}const oe=await Promise.all(ee.map(async V=>{if(V.type)return{id:V.id,title:V.title,type:V.type,author:V.author,dynasty:V.dynasty,role:V.role,edition:V.edition,has_text:V.has_text,has_image:V.has_image,has_collated:V.has_collated,subtype:V.subtype,primary_name:V.primary_name,group:V.group,fallbackDescription:V.description};try{let me=null;if(e.getEntry)me=await e.getEntry(V.id);else{const G=await e.getItem(V.id);G&&(me={id:V.id,title:G.title||V.id,type:G.type||"work"})}if(me)return{...me,group:V.group,fallbackDescription:V.description}}catch{}return{id:V.id,title:V.title,type:ke.extractType(V.id),group:V.group,fallbackDescription:V.description}}));R||(h(oe.filter(V=>V!==null)),v(!1))}),()=>{R=!0}},[e,i]);const z=g.useRef(!1),M=g.useRef(!1),H=g.useRef(!1);g.useEffect(()=>{if($!=="catalog"||z.current)return;const R=e.getCatalogProgress??e.getResourceProgress;if(!R)return;z.current=!0;let A=!1;return R.call(e).then(J=>{A||C(J)}).catch(()=>{z.current=!1}),()=>{A=!0}},[e,$]),g.useEffect(()=>{if($!=="collection"||M.current||!e.getCollectionProgress)return;M.current=!0;let R=!1;return e.getCollectionProgress().then(A=>{R||_(A)}).catch(()=>{M.current=!1}),()=>{R=!0}},[e,$]),g.useEffect(()=>{if($!=="site"||H.current||!e.getSiteProgress)return;H.current=!0;let R=!1;return e.getSiteProgress().then(A=>{R||T(A)}).catch(()=>{H.current=!1}),()=>{R=!0}},[e,$]),g.useEffect(()=>{if(!a||$!=="feedback")return;let R=!1;return y(!0),fetch(a).then(A=>A.json()).then(A=>{!R&&A.success&&x(A.items||[])}).catch(()=>{}).finally(()=>{R||y(!1)}),()=>{R=!0}},[a,$]);const N=R=>t.jsx(kn,{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(Tn,{label:l.home.recommendTab,active:$==="recommend",onClick:()=>b("recommend")}),t.jsx(Tn,{label:l.home.catalogTab,active:$==="catalog",onClick:()=>b("catalog")}),t.jsx(Tn,{label:l.home.collectionTab,active:$==="collection",onClick:()=>b("collection")}),t.jsx(Tn,{label:l.home.siteTab,active:$==="site",onClick:()=>b("site")}),a&&t.jsx(Tn,{label:l.home.feedbackTab,active:$==="feedback",onClick:()=>b("feedback")})]}),$==="recommend"&&t.jsx(dx,{recommended:p,loading:w,onNavigate:n,getIcon:N,t:l}),$==="catalog"&&t.jsx(ya,{progress:j,t:l,onNavigate:n}),$==="collection"&&t.jsx(ya,{progress:S,t:l,onNavigate:n}),$==="site"&&t.jsx(ux,{progress:L,t:l,totalWorks:(d==null?void 0:d.works)??0}),$==="feedback"&&a&&t.jsx(Oo,{items:f,loading:k})]})})},Tn=({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}),dx=({recommended:e,loading:n,onNavigate:i,getIcon:o,t:s})=>{const a=rt();if(n)return t.jsx(sn,{});if(e.length===0)return null;const l=new Map;for(const d of e){const c=d.group||s.home.recommendedBrowse;l.has(c)||l.set(c,[]),l.get(c).push(d)}return t.jsx(t.Fragment,{children:Array.from(l.entries()).map(([d,c])=>t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:d}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"8px"},children:c.map(p=>{const h=p.dynasty||p.author?`${p.dynasty?`〔${p.dynasty}〕`:""}${p.author||""}`:p.fallbackDescription;return t.jsxs("a",{href:a(p.id),onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),i==null||i(p.id))},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,cursor:"pointer",background:r("input-bg"),textDecoration:"none",color:"inherit"},children:[t.jsx("span",{style:{fontSize:"20px"},children:o(p.type)}),t.jsxs("div",{style:{minWidth:0},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[p.title,p.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:r("desc-fg"),marginLeft:"4px"},children:p.edition})]}),h&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h})]})]},p.id)})})]},d))})},ya=({progress:e,t:n,onNavigate:i})=>{if(!e)return t.jsx(sn,{});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(px,{item:p,t:n,statusColor:l[d],onNavigate:i},p.id))})]},d)})})},px=({item:e,t:n,statusColor:i,onNavigate:o})=>{const s=rt(),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})]})},ux=({progress:e,t:n,totalWorks:i})=>{if(!e)return t.jsx(sn,{});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(ja,{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(ja,{item:c,t:n,totalWorks:i},c.id))})]})]})},ja=({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})]})},va="(max-width: 768px)";function mx(){const[e,n]=g.useState(()=>typeof window>"u"?!1:window.matchMedia(va).matches);return g.useEffect(()=>{const i=window.matchMedia(va),o=s=>n(s.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),e}const hx=({transport:e,hideModeIndicator:n=!0,onEntryClick:i,recommendedIds:o,headerRight:s})=>{var M;const a=Ie(),{convert:l}=Pe(),d=mx(),[c,p]=g.useState(null),[h,u]=g.useState(null),[m,f]=g.useState(!1),[x,k]=g.useState("detail"),[y,$]=g.useState([]),[b,w]=g.useState(!1),v=g.useCallback(async H=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){$([]);return}w(!0);try{if(e.getCollectionCatalogs){const N=await e.getCollectionCatalogs(H);$(N||[])}else if(e.getCollectionCatalog){const N=await e.getCollectionCatalog(H);$(N?[{resource_id:"",data:N}]:[])}}catch{$([])}finally{w(!1)}},[e]),j=g.useCallback(async H=>{if(i){i(H);return}p(H),u(null),$([]),k("detail"),f(!0);try{const N=await e.getItem(H.id);N&&(u(N),N.type==="collection"&&v(H.id))}catch(N){console.error("加载详情失败:",N)}finally{f(!1)}},[e,i,v]),C=g.useCallback(async H=>{u(null),$([]),k("detail"),f(!0);try{const N=await e.getItem(H);N&&(u(N),p({id:H,title:N.title||H,type:N.type||"book"}),N.type==="collection"&&v(H))}catch(N){console.error("导航失败:",N)}finally{f(!1)}},[e,v]),S=typeof(h==null?void 0:h.text_count)=="number"&&h.text_count>0,_=(h==null?void 0:h.type)==="collection"&&(y.length>0||b)||(h==null?void 0:h.type)==="work"&&S,L=d&&(m||h),T=g.useCallback(()=>{p(null),u(null),$([]),k("detail")},[]),z=t.jsx(t.Fragment,{children:m?t.jsx(sn,{}):h?t.jsxs(t.Fragment,{children:[(_||s)&&t.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${r("widget-border")}`,padding:d?"0 12px":"0 48px",background:r("input-bg"),flexShrink:0,overflowX:d?"auto":void 0},children:[_&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>k("detail"),style:di(x==="detail"),children:a.detailTab.basicInfo}),h.type==="collection"&&b&&y.length===0&&t.jsxs("button",{onClick:()=>{},style:di(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),h.type==="collection"&&y.map(H=>t.jsx("button",{onClick:()=>k(`catalog:${H.resource_id}`),style:di(x===`catalog:${H.resource_id}`),children:H.short_name?`${l(H.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},H.resource_id)),h.type==="work"&&S&&t.jsx("button",{onClick:()=>k("collated"),style:di(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(io,{data:h,transport:e,onNavigate:C}):x.startsWith("catalog:")?t.jsx(ro,{data:(M=y.find(H=>`catalog:${H.resource_id}`===x))==null?void 0:M.data,onNavigate:C}):x==="collated"?t.jsx(Wo,{id:h.id,transport:e,onNavigate:C}):null})]}):t.jsx(Wr,{transport:e,onNavigate:C,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:T,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:z})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(Sr,{transport:e,onEntryClick:j,hideModeIndicator:n}),!h&&t.jsx(Wr,{transport:e,onNavigate:C,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(Sr,{transport:e,onEntryClick:j,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:r("bg"),display:"flex",flexDirection:"column"},children:z})]})};function di(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 gx=({pageData:e,rawImageUrl:n="",punctuations:i=[],title:o,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=g.useState(new Set),[h,u]=g.useState(null),[m,f]=g.useState("horizontal"),[x,k]=g.useState(!0),y=g.useRef(null),$=g.useCallback(j=>{p(new Set(j))},[]),b=g.useCallback(j=>{if(p(C=>{const S=new Set(C);return S.has(j)?S.delete(j):(S.clear(),S.add(j)),S}),y.current){const C=y.current.querySelector(`[data-char-id="${j}"]`);C&&C.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),w=()=>{var j;p(new Set),window.getSelection&&((j=window.getSelection())==null||j.removeAllRanges())},v=i.length>0?i:e.punctuations||[];return t.jsxs("div",{className:`guji-reader-container ${l}`,style:d,children:[t.jsxs("header",{className:"guji-reader-header",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a&&t.jsx("button",{type:"button",onClick:a,className:"guji-reader-btn",style:{marginRight:6},children:"‹ 返回"}),t.jsx("span",{className:"guji-reader-title",children:o||e.title}),s&&t.jsx("span",{style:{fontSize:"0.85rem",color:r("meta-fg")},children:s}),t.jsx("span",{className:"guji-reader-tag",children:"WebGL 客户端透视矫正对读"})]}),t.jsxs("div",{className:"guji-reader-actions",children:[t.jsxs("span",{style:{fontSize:"0.85rem",color:r("body-fg")},children:["已选字数: ",t.jsx("strong",{style:{color:r("accent")},children:c.size})]}),c.size>0&&t.jsx("button",{type:"button",onClick:w,className:"guji-reader-btn",children:"清除选中"}),t.jsx("button",{type:"button",onClick:()=>k(j=>!j),className:`guji-reader-btn ${x?"active":""}`,title:"独立外挂标点 (guji-punct v0.1)",children:x?"✓ 标点":"底本文本"}),t.jsx("button",{type:"button",onClick:()=>f(j=>j==="horizontal"?"vertical":"horizontal"),className:"guji-reader-btn primary",children:m==="horizontal"?"切换竖排":"切换横排"})]})]}),t.jsxs("div",{className:"guji-reader-body",children:[t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%",position:"sticky",top:0},children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:"底本书影 (WebGL 分带透视矫正 + 完整版心)"}),t.jsx("span",{className:"guji-pane-hint",children:"点击字框可联动文本定位"})]}),t.jsx("div",{className:"guji-pane-content",children:t.jsx(Ro,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:h,onCharClick:b,onCharHover:u})})]}),t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%"},ref:y,children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:m==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(Po,{pageData:e,punctuations:v,selectedCharIds:c,hoveredCharId:h,onSelectionChange:$,onCharClick:b,onCharHover:u,mode:m,showPunctuation:x})]})]})]})},fx=e=>typeof e=="string"&&Array.from(e).length===1;function xx(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.punctuations)?e.punctuations:[],i=[];for(const o of n){if(!o||typeof o!="object")continue;const s=o;typeof s.anchor!="string"||typeof s.mark!="string"||s.pre_char!=null&&!fx(s.pre_char)||i.push({id:typeof s.id=="string"?s.id:void 0,anchor:s.anchor,mark:s.mark,kind:s.kind,pos:s.pos,pre_char:s.pre_char??void 0})}return i}function bx(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 ed=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function ct(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}const yx=new Set(["main","solo","jz_r","jz_l"]),jx=new Set(["body","banxin","blank"]);function vx(e){const n={};return typeof e.lane=="string"&&yx.has(e.lane)&&e.lane!=="main"&&(n.lane=e.lane),e.lacuna===!0&&(n.lacuna=!0),e.guess===!0&&(n.guess=!0),typeof e.zi=="string"&&e.zi&&(n.zi=e.zi),n}function kx(e){const n={};typeof e.kind=="string"&&jx.has(e.kind)&&e.kind!=="body"&&(n.kind=e.kind);const i=ct(e.raised);i!==void 0&&Number.isInteger(i)&&i>0&&(n.raised=i);const o=ct(e.lead_blank);return o!==void 0&&Number.isInteger(o)&&o>0&&(n.lead_blank=o),n}function hr(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(i=>!!i&&typeof i=="object"):[]}function wx(e){return typeof e=="string"&&Array.from(e).length===1}function td(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"||!ed.test(a)){i.badAnchor++;continue}if(!wx(l)){i.badChar++;continue}if(d!==void 0&&d!=="异体"){i.badWhy++;continue}n.set(a,l)}return{map:n,dropped:i}}function nd(e){return td(e).map}function Sx(e,n,i){var h,u,m,f,x,k,y,$,b,w;const o=i==null?null:nd(i),s=new Map,a=new Map;for(const v of hr(n)){const j=ct(v.page);if(j!==void 0){s.set(j,v);for(const C of Array.isArray(v.cells)?v.cells:[]){const S=C==null?void 0:C.box;typeof(C==null?void 0:C.a)=="string"&&Array.isArray(S)&&S.length===4&&S.every(_=>ct(_)!==void 0)&&a.set(C.a,[S[0],S[1],S[0]+S[2],S[1]+S[3]])}}}const l=[],d=new Map,c=new Map;for(const v of hr(e)){const j=ct(v.page);j!==void 0&&typeof v.label=="string"&&v.label&&d.set(j,v.label)}for(const v of hr(e)){const j=ct(v.page);if(j===void 0)continue;const C=[];for(const _ of Array.isArray(v.columns)?v.columns:[]){const L=ct(_==null?void 0:_.col);if(L===void 0)continue;const T=[];for(const M of Array.isArray(_.cells)?_.cells:[]){const H=ed.exec(String((M==null?void 0:M.a)??""));if(!H||typeof M.c!="string")continue;const N=parseInt(H[3],10),R=o==null?void 0:o.get(M.a);T.push({id:M.a,char:M.c,slot:N,pos:N,sub:H[4]||null,bbox:a.get(M.a)??null,...vx(M),...R!==void 0&&R!==M.c?{norm:R}:{}})}const z=kx(_);(T.length>0||z.kind==="blank")&&C.push({col:L,chars:T,...z})}if(!C.some(_=>_.chars.length>0)){C.length>0&&c.set(j,C);continue}C.sort((_,L)=>_.col-L.col);const S=s.get(j);l.push({page:j,seq:String(((h=S==null?void 0:S.canvas)==null?void 0:h.seq)??""),width:ct((u=S==null?void 0:S.canvas)==null?void 0:u.width)??ct((m=S==null?void 0:S.image)==null?void 0:m.width)??0,height:ct((f=S==null?void 0:S.canvas)==null?void 0:f.height)??ct((x=S==null?void 0:S.image)==null?void 0:x.height)??0,...typeof v.label=="string"&&v.label?{label:v.label}:{},columns:C})}const p=new Set(l.map(v=>v.page));for(const[v,j]of s){const C=(k=j==null?void 0:j.canvas)==null?void 0:k.seq;p.has(v)||typeof C!="string"&&typeof C!="number"||String(C)===""||l.push({page:v,seq:String(C),width:ct((y=j.canvas)==null?void 0:y.width)??ct(($=j.image)==null?void 0:$.width)??0,height:ct((b=j.canvas)==null?void 0:b.height)??ct((w=j.image)==null?void 0:w.height)??0,...d.has(v)?{label:d.get(v)}:{},columns:c.get(v)??[]})}return l.sort((v,j)=>v.page-j.page)}const _x=({data:e,onNavigate:n,className:i,style:o})=>{var h;const{t:s,convert:a}=te(),[l,d]=g.useState(((h=e.divisions[0])==null?void 0:h.name)??null),[c,p]=g.useState(null);return t.jsxs("div",{className:i,style:o,children:[t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:r("fg"),margin:"0 0 8px"},children:a(e.title)}),e.stats&&t.jsxs("div",{style:{fontSize:"13px",color:r("desc-fg"),display:"flex",gap:"16px"},children:[e.total_volumes!=null&&t.jsxs("span",{children:[s("catalog.totalVolumes")," ",t.jsx("strong",{children:e.total_volumes})," ",s("unit.juan")]}),e.stats.zhulu!=null&&t.jsxs("span",{children:[s("catalogPage.zhulu")," ",t.jsx("strong",{children:e.stats.zhulu})," ",s("unit.bu")]}),e.stats.cunmu!=null&&t.jsxs("span",{children:[s("catalogPage.cunmu")," ",t.jsx("strong",{children:e.stats.cunmu})," ",s("unit.bu")]}),e.stats.categories!=null&&t.jsx("span",{children:s("catalogPage.categoriesN",{n:e.stats.categories})})]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.divisions.map(u=>t.jsx($x,{division:u,expanded:l===u.name,onToggle:()=>d(l===u.name?null:u.name),expandedCat:c,onCatToggle:m=>p(c===m?null:m),onNavigate:n},u.name))})]})},$x=({division:e,expanded:n,onToggle:i,expandedCat:o,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=te(),c=e.categories.reduce((p,h)=>{const u=h.stats||{zhulu:0,cunmu:0};return p+(u.zhulu||0)+(u.cunmu||0)},0);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:"none",background:n?`color-mix(in srgb, ${r("primary")} 6%, transparent)`:r("bg"),cursor:"pointer",fontSize:"15px",fontWeight:600,color:r("fg"),textAlign:"left"},children:[t.jsx("span",{children:d(e.name)}),t.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg")},children:[l("catalogPage.divisionStat",{cats:e.categories.length,books:c}),t.jsx("span",{style:{marginLeft:"8px"},children:n?"▲":"▼"})]})]}),n&&t.jsx("div",{style:{padding:"4px 0"},children:e.categories.map(p=>{const h=`${e.name}/${p.name}`;return t.jsx(Cx,{category:p,expanded:o===h,onToggle:()=>s(h),onNavigate:a},p.name)})})]})},Cx=({category:e,expanded:n,onToggle:i,onNavigate:o})=>{var p,h,u,m;const{t:s,convert:a}=te(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((h=e.books)==null?void 0:h.cunmu)||[],c=(((u=e.stats)==null?void 0:u.zhulu)||l.length)+(((m=e.stats)==null?void 0:m.cunmu)||d.length);return t.jsxs("div",{children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px 6px 28px",border:"none",background:n?r("input-bg"):"transparent",cursor:"pointer",fontSize:"13px",color:r("fg"),textAlign:"left"},children:[t.jsxs("span",{style:{fontWeight:500},children:[a(e.name),e.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:a(e.volumes)})})]}),t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[s("catalogPage.booksN",{n:c})," ",n?"▲":"▼"]})]}),n&&(l.length>0||d.length>0)&&t.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[l.length>0&&t.jsx(ka,{label:s("catalogPage.zhulu"),books:l,onNavigate:o}),d.length>0&&t.jsx(ka,{label:s("catalogPage.cunmu"),books:d,onNavigate:o})]})]})},ka=({label:e,books:n,onNavigate:i})=>{const{t:o,convert:s}=te(),a=rt(),[l,d]=g.useState(n.length<=20),c=l?n:n.slice(0,10);return t.jsxs("div",{style:{marginBottom:"8px"},children:[t.jsxs("div",{style:{fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},children:[e," (",n.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((p,h)=>t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[t.jsx("span",{style:{fontWeight:500,color:r("fg")},children:p.work_id&&i?t.jsx("a",{href:a(p.work_id),onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),i(p.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`},children:s(p.title)}):s(p.title)}),p.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:s(p.volumes)}),p.author&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:s(p.author).slice(0,20)})]},h))}),!l&&t.jsx("button",{onClick:()=>d(!0),style:{marginTop:"4px",padding:"2px 12px",fontSize:"11px",color:r("primary"),background:"transparent",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:o("catalogPage.expandAllN",{n:n.length})})]})},St=({title:e,onSave:n,onAskAI:i,extraButtons:o,children:s})=>{const a=Ie();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:Tx,children:"AI"}),n&&t.jsx("button",{onClick:n,style:zx,children:a.action.save})]})]}),s]})},zx={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Tx={padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},xt=({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"}})]}),on=({value:e,onChange:n,placeholder:i})=>{const o=g.useRef(null);return g.useEffect(()=>{o.current&&(o.current.style.height="auto",o.current.style.height=`${o.current.scrollHeight}px`)},[e]),t.jsx("textarea",{ref:o,value:e||"",onChange:s=>n(s.target.value),placeholder:i,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},ki=({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 Nx(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const gi=({value:e,onChange:n,label:i})=>{const[o,s]=g.useState(!1),a=g.useRef(null),l=Nx(e||"");return g.useEffect(()=>{o&&a.current&&a.current.focus()},[o]),!o&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:wa,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(ki,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:wa,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"}})]})},wa={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500};function Ix(e){switch(e){case"url":return r("source-url");case"bookID":return r("source-bookid");default:return r("desc-fg")}}function Ex(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const id=({items:e,onChange:n,onOpenEntityPicker:i})=>{const o=Ie(),[s,a]=g.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=u=>{n(e.filter((m,f)=>f!==u)),s===u&&a(null)},c=(u,m,f)=>{const x=[...e];x[u]={...x[u],[m]:f},n(x)},p=(u,m)=>{const f=[...e];f[u]={...f[u],type:m,id:"",name:""},n(f),m==="bookID"&&i&&i(x=>{const k=[...e];k[u]={...k[u],id:x.id,name:x.title,type:"bookID"},n(k)})},h=u=>{i&&i(m=>{const f=[...e];f[u]={...f[u],id:m.id,name:m.title,type:"bookID"},n(f)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((u,m)=>t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>a(s===m?null:m),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===m?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:r("fg")},children:u.name||`${o.editor.sourcePlaceholder} ${m+1}`}),u.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:Ix(u.type),color:r("on-color-fg"),borderRadius:"3px",fontWeight:500},children:Ex(u.type)}),t.jsx("button",{onClick:f=>{f.stopPropagation(),d(m)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:o.editor.deleteThisSource,children:"✕"})]}),s===m&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!u.type&&t.jsxs("div",{children:[t.jsx("label",{style:Mt,children:o.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(m,"bookID"),style:{...Sa,borderColor:r("source-bookid"),color:r("source-bookid")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"📚"}),t.jsx("span",{children:"Book ID"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.fromExistingBook})]}),t.jsxs("button",{onClick:()=>p(m,"url"),style:{...Sa,borderColor:r("source-url"),color:r("source-url")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),t.jsx("span",{children:"URL"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.enterUrl})]})]})]}),u.type==="bookID"&&t.jsx(t.Fragment,{children:t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:Mt,children:o.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const f=[...e];f[m]={...f[m],type:"",id:"",name:""},n(f)},style:_a,children:o.action.changeType})]}),u.id&&u.name?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:r("bg"),border:`1px solid ${r("source-bookid")}`,borderRadius:"6px"},children:[t.jsx("span",{style:{color:r("source-bookid"),fontSize:"16px"},children:"✓"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:u.name}),t.jsx("code",{style:{fontSize:"11px",background:r("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:u.id})]}),t.jsx("button",{onClick:()=>h(m),style:{background:"transparent",border:`1px solid ${r("widget-border")}`,color:r("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:o.action.reselect})]}):t.jsxs("button",{onClick:()=>h(m),style:{width:"100%",padding:"14px",border:`2px dashed ${r("widget-border")}`,borderRadius:"6px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[t.jsx("span",{children:"🔍"}),t.jsx("span",{children:o.action.clickToSelectBookOrWork})]})]})}),u.type==="url"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:Mt,children:o.label.sourceName}),t.jsx("button",{onClick:()=>{const f=[...e];f[m]={...f[m],type:"",id:"",name:""},n(f)},style:_a,children:o.action.changeType})]}),t.jsx("input",{type:"text",value:u.name,onChange:f=>c(m,"name",f.target.value),placeholder:o.editor.sourceNamePlaceholder,style:dn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Mt,children:o.label.urlAddress}),t.jsx("input",{type:"text",value:u.id,onChange:f=>c(m,"id",f.target.value),placeholder:"https://...",style:dn})]})]}),u.type&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{borderTop:`1px dashed ${r("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:t.jsx("label",{style:{...Mt,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:Mt,children:o.label.detailsOptional}),t.jsx("input",{type:"text",value:u.details,onChange:f=>c(m,"details",f.target.value),placeholder:o.editor.detailsPlaceholder,style:dn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Mt,children:o.label.positionOptional}),t.jsx("input",{type:"text",value:u.position,onChange:f=>c(m,"position",f.target.value),placeholder:"如: 卷三, p.52",style:dn})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Mt,children:o.label.dataVersionOptional}),t.jsx("input",{type:"text",value:u.version,onChange:f=>c(m,"version",f.target.value),placeholder:"如: v1.0, 2024-01",style:dn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Mt,children:o.label.processorVersionOptional}),t.jsx("input",{type:"text",value:u.processor_version,onChange:f=>c(m,"processor_version",f.target.value),placeholder:"如: v0.1",style:dn})]})]})]})]})})]},m)),t.jsxs("button",{onClick:l,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:o.action.addSource})]})]})},Mt={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},dn={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"},Sa={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"},_a={background:"transparent",border:"none",color:r("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function rd(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 od(e){return!e||e.length===0?"":JSON.stringify(e)}const sd=({entityType:e,entityId:n,entityTitle:i,parentWork:o,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:h,onLinkEntity:u,onUnlinkEntity:m,onViewEntity:f,onCreateAndLink:x,onSaveRelations:k})=>{const y=Ie();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})]}),k&&t.jsx("button",{onClick:k,style:Rx,children:y.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(Nn,{direction:"up",title:y.relation.belongsToWork,entity:a,onView:f,onUnlink:()=>m("workId"),onLink:()=>u("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(Nn,{direction:"up",title:y.relation.containedInCollection,entity:l,onView:f,onUnlink:()=>m("collectionId"),onLink:()=>u("collectionId","collection"),onCreate:()=>x("collectionId","collection",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),a&&h&&h.length>0&&t.jsx(pn,{direction:"horizontal",title:`${y.relation.siblingVersions} (${h.length})`,entities:h,onView:f,onAdd:()=>x("siblingBook","book",{workId:a.id}),addLabel:y.relation.addVersionForWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="work"&&t.jsxs(t.Fragment,{children:[t.jsx(Nn,{direction:"up",title:y.relation.parentWork,entity:o,onView:f,onUnlink:()=>m("parentWorkId"),onLink:()=>u("parentWorkId","work"),onCreate:()=>x("parentWorkId","work"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),d&&d.length>0&&t.jsx(pn,{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(pn,{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(pn,{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(Nn,{direction:"up",title:y.relation.correspondingWork,entity:a,onView:f,onUnlink:()=>m("workId"),onLink:()=>u("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(Nn,{direction:"up",title:y.relation.parentCollection,entity:s,onView:f,onUnlink:()=>m("parentCollectionId"),onLink:()=>u("parentCollectionId","collection"),onCreate:()=>x("parentCollectionId","collection"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(pn,{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(pn,{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})]})]})]})},Nn=({direction:e,title:n,entity:i,onView:o,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:h,unlinkLabel:u})=>{const m=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),f=e==="up"?"⬆️":e==="down"?"⬇️":"↔️";return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:m,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:f}),t.jsx("span",{children:n})]}),i?t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:r("bg"),borderRadius:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:ad(i.type)}),t.jsx("span",{style:{fontWeight:500},children:i.title}),t.jsx("span",{style:{fontSize:"11px",opacity:.6},children:i.id})]}),t.jsxs("div",{style:{display:"flex",gap:"4px"},children:[t.jsx($a,{onClick:()=>o(i),title:h,children:"👁️"}),t.jsx($a,{onClick:s,title:u,danger:!0,children:"✕"})]})]}):t.jsx("div",{style:{padding:"8px",background:r("bg"),borderRadius:"4px",color:r("desc-fg"),fontSize:"12px",textAlign:"center"},children:p}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsx(Or,{onClick:a,children:d}),t.jsx(Or,{onClick:l,primary:!0,children:c})]})]})},pn=({direction:e,title:n,entities:i,onView:o,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=g.useState(!1),h=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),u=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",m=c?i:i.slice(0,5);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:h,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:u}),t.jsx("span",{children:n})]}),i.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[m.map(f=>t.jsxs("div",{onClick:()=>o(f),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:r("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[t.jsx("span",{children:ad(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(Or,{onClick:s,primary:!0,children:["+ ",a]})})]})},$a=({onClick:e,title:n,danger:i,children:o})=>t.jsx("button",{onClick:s=>{s.stopPropagation(),e()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:i?r("danger"):"inherit",opacity:.7},children:o}),Or=({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 ad(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const Rx={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},ld=({isOpen:e,entityType:n,title:i,onSelect:o,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[h,u]=g.useState(""),m=p?l.filter(y=>y.id!==p):l;g.useEffect(()=>{e&&(u(""),d(""))},[e]);const f=y=>{u(y),d(y)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",k=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:Lx,children:t.jsxs("div",{style:Ax,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:Mx,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:h,onChange:y=>f(y.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:Px})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:gr,children:"搜索中..."}):m.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:m.map(y=>t.jsxs("div",{onClick:()=>o(y),style:Bx,children:[t.jsx("span",{style:{fontSize:"16px"},children:k}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[y.title,y.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:y.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[y.id,y.author&&` · ${y.author}`,y.dynasty&&` · ${y.dynasty}`]})]})]},y.id))}):h?t.jsxs("div",{style:gr,children:["未找到匹配的",x]}):t.jsxs("div",{style:gr,children:["输入关键词搜索",x]})}),t.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsxs("button",{onClick:a,style:Wx,children:["创建新",x,"并关联"]})]})]})})},Lx={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Ax={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")},Mx={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},Px={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"},Bx={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:r("primary-soft")},gr={padding:"20px",textAlign:"center",color:r("desc-fg")},Wx={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Ca={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},Ox={work:"📜",book:"📖",collection:"📚",entity:"👤"},cd=({isOpen:e,entityType:n,relationField:i,inheritData:o,onConfirm:s,onCancel:a})=>{const[l,d]=g.useState(""),c=g.useRef(null);g.useEffect(()=>{e&&(d((o==null?void 0:o.title)||""),setTimeout(()=>{var m,f;(m=c.current)==null||m.focus(),(f=c.current)==null||f.select()},100))},[e,o==null?void 0:o.title]);const p=m=>{m.key==="Enter"&&l.trim()?h():m.key==="Escape"&&a()},h=()=>{l.trim()&&s(l.trim(),{...o,title:l.trim()})};if(!e)return null;const u=()=>{switch(i){case"parentWorkId":return"创建父作品";case"workId":return"创建所属作品";case"collectionId":return"创建所属丛编";case"parentCollectionId":return"创建父丛编";case"childWork":return"创建子作品";case"childBook":case"siblingBook":return"创建书籍";case"childCollection":return"创建子丛编";default:return`创建新${Ca[n]}`}};return t.jsx("div",{style:Fx,onClick:m=>{m.target===m.currentTarget&&a()},children:t.jsxs("div",{style:Hx,onClick:m=>m.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Ox[n]}),t.jsx("span",{children:u()})]}),t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:r("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",t.jsx("span",{style:{color:r("danger"),marginLeft:"4px"},children:"*"})]}),t.jsx("input",{ref:c,type:"text",value:l,onChange:m=>d(m.target.value),onKeyDown:p,placeholder:`请输入${Ca[n]}名称...`,style:Dx})]}),((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:Ux,children:"取消"}),t.jsx("button",{onClick:h,disabled:!l.trim(),style:{...Vx,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},Fx={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Hx={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")},Dx={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"},Ux={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},Vx={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg")};function Gx(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function dd(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Yx(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 pd=({isOpen:e,title:n,filterType:i="all",recentEntities:o=[],excludeId:s,showCreateButton:a=!1,createButtonText:l,onSelect:d,onCancel:c,onCreate:p,onSearch:h})=>{const[u,m]=g.useState(""),[f,x]=g.useState([]),[k,y]=g.useState(!1),[$,b]=g.useState("recent");g.useEffect(()=>{e&&(m(""),x([]),b(o.length>0?"recent":"search"))},[e,o.length]),g.useEffect(()=>{if(!u.trim()){x([]);return}const _=setTimeout(async()=>{y(!0);try{x(await h(u,i))}catch{x([])}finally{y(!1)}},300);return()=>clearTimeout(_)},[u,i,h]);const w=g.useCallback(_=>{m(_.target.value),_.target.value.trim()&&b("search")},[]),v=g.useCallback(_=>s?_.filter(L=>L.id!==s):_,[s]);if(!e)return null;const j=n||(i==="all"?"选择实体":`选择${dd(i)}`),C=v(o),S=v(f);return t.jsx("div",{style:Kx,children:t.jsxs("div",{style:Xx,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:j}),t.jsx("button",{onClick:c,style:Zx,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:u,onChange:w,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Jx}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),k&&t.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),C.length>0&&t.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs(za,{active:$==="recent",onClick:()=>b("recent"),children:["最近使用 (",C.length,")"]}),t.jsxs(za,{active:$==="search",onClick:()=>b("search"),children:["搜索结果 ",S.length>0&&`(${S.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:$==="recent"&&C.length>0?t.jsx(Ta,{entities:C,onSelect:d}):u.trim()?k?t.jsx(fr,{message:"搜索中..."}):S.length>0?t.jsx(Ta,{entities:S,onSelect:d}):t.jsx(fr,{message:"未找到匹配的结果"}):t.jsx(fr,{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:Qx,children:l||"创建新实体"})]})]})})},za=({active:e,onClick:n,children:i})=>t.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${r("primary")}`:"2px solid transparent",background:"transparent",color:r(e?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:e?600:400,marginBottom:"-1px"},children:i}),Ta=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(i=>t.jsx(qx,{entity:i,onClick:()=>n(i)},i.id))}),qx=({entity:e,onClick:n})=>{const[i,o]=g.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:r("primary-soft"),transition:"background 0.1s"},children:[t.jsx("span",{style:{fontSize:"18px"},children:Gx(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:Yx(e.type),color:r("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:dd(e.type)})]})},fr=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:e}),Kx={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Xx={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")},Zx={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Jx={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"},Qx={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},eb={work:r("editor-type-work"),collection:r("editor-type-collection"),book:r("editor-type-book"),entity:r("editor-type-entity")},tb={work:"📜",collection:"📚",book:"📖",entity:"👤"},ud=({data:e,onChange:n,onSave:i,transport:o,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:h,relations:u,onRelationsChange:m})=>{var ie;const f=Ie(),[x,k]=g.useState(!1),[y,$]=g.useState("work"),[b,w]=g.useState(""),[v,j]=g.useState(""),[C,S]=g.useState([]),[_,L]=g.useState(!1),[T,z]=g.useState(!1),[M,H]=g.useState("work"),[N,R]=g.useState(""),[A,J]=g.useState(),[ee,oe]=g.useState(!1),[V,me]=g.useState(null),[G,q]=g.useState([]);g.useRef(null);const ce=e.type,we=ce==="work",O=ce==="collection",ye=ce==="book",de=g.useCallback((D,se)=>{n({...e,[D]:se})},[e,n]),ze=g.useCallback((D,se)=>{w(D),$(se),j(f.editor.selectToLink+f.indexType[se]),S([]),k(!0)},[f]),Ce=g.useCallback(D=>{o!=null&&o.unlinkEntity&&o.unlinkEntity(e.id,D)},[o,e.id]),Oe=g.useCallback(D=>{s==null||s(D.id,D.type)},[s]),ne=g.useCallback((D,se,Te)=>{const Me={...Te,author:(Te==null?void 0:Te.author)||e.author,dynasty:Te==null?void 0:Te.dynasty};H(se),R(D),J(Me),z(!0)},[e.author]),W=g.useCallback((D,se)=>{o!=null&&o.createAndLink&&o.createAndLink(e.id,N,{type:M,title:D,inheritData:se}),z(!1)},[o,e.id,N,M]),U=g.useCallback(D=>{if(!D.trim()){S([]);return}L(!0),o!=null&&o.searchEntities&&o.searchEntities(D,y).then(se=>{S(se),L(!1)}).catch(()=>{S([]),L(!1)})},[o,y]),he=g.useCallback(D=>{o!=null&&o.linkEntity&&o.linkEntity(e.id,b,D.id),k(!1)},[o,e.id,b]),K=g.useCallback(()=>{i()},[i]),B=g.useCallback(D=>{me(()=>D),oe(!0),o!=null&&o.getRecentEntities&&o.getRecentEntities().then(q).catch(()=>{})},[o]),Q=g.useCallback((D,se)=>o!=null&&o.searchEntities?o.searchEntities(D,se==="all"?void 0:se):Promise.resolve([]),[o]),le=g.useCallback(D=>{o!=null&&o.addRecentEntity&&o.addRecentEntity(D),q(se=>[D,...se.filter(Te=>Te.id!==D.id)].slice(0,10)),V==null||V(D),oe(!1),me(null)},[o,V]);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:tb[ce]}),t.jsx("span",{children:e.title||f.editor.untitled}),t.jsx(ki,{children:e.id}),t.jsx(ki,{color:eb[ce],children:f.indexType[ce]})]})}),t.jsx(St,{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(gi,{label:we?f.editor.workTitle:O?f.editor.collectionTitle:f.editor.bookTitle,value:e.title,onChange:D=>de("title",D)}),ye&&t.jsx(gi,{label:f.editor.belongsToWork,value:e.workName||"",onChange:D=>de("workName",D)}),t.jsx(xt,{label:f.editor.authorLabel,value:e.author||"",onChange:D=>de("author",D)}),t.jsx(xt,{label:f.editor.publicationYearLabel,value:e.publicationYear||"",onChange:D=>de("publicationYear",D)}),(ye||O)&&t.jsx(gi,{label:f.editor.containedIn,value:e.collection||"",onChange:D=>de("collection",D)}),(ye||O)&&t.jsx(xt,{label:f.editor.holderLabel,value:e.holder||"",onChange:D=>de("holder",D)}),(ye||O)&&t.jsx(xt,{label:ye?f.editor.pageLabel:f.editor.volumeLabel,value:e.pages||"",onChange:D=>de("pages",D)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(xt,{label:f.editor.firstImageLabel,value:e.firstImage||"",onChange:D=>de("firstImage",D)})})]})}),t.jsx(St,{title:f.section.description,onSave:i,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(on,{value:e.description||"",onChange:D=>de("description",D),placeholder:f.editor.descriptionPlaceholder})}),(((ie=e.additional_works)==null?void 0:ie.length)||0)>0&&t.jsx(St,{title:f.section.additionalWorks,onSave:i,children:t.jsx(nb,{items:e.additional_works||[],onChange:D=>de("additional_works",D)})}),t.jsx(St,{title:f.section.indexedBy,onSave:i,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(ib,{items:e.indexed_by||[],onChange:D=>de("indexed_by",D)})}),t.jsx(St,{title:f.section.emendatedBy,onSave:i,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(rb,{items:e.emendated_by||[],onChange:D=>de("emendated_by",D)})}),t.jsx(St,{title:f.section.textResources,onSave:i,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(kr,{items:e.resources||[],onChange:D=>de("resources",D),onDownload:p,downloadStatuses:h,filterType:"text"})}),t.jsx(St,{title:f.section.imageResources,onSave:i,children:t.jsx(kr,{items:e.resources||[],onChange:D=>de("resources",D),onDownload:p,downloadStatuses:h,filterType:"image"})}),t.jsx(St,{title:f.section.sources,onSave:i,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(id,{items:rd(e.sources||""),onChange:D=>de("sources",od(D)),onOpenEntityPicker:B})}),(ye||O)&&t.jsx(St,{title:f.section.provenance,onSave:i,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(on,{value:e.provenance||"",onChange:D=>de("provenance",D),placeholder:f.editor.provenancePlaceholder})}),ye&&t.jsx(St,{title:f.section.otherEditions,onSave:i,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(on,{value:e.otherEditions||"",onChange:D=>de("otherEditions",D),placeholder:f.editor.otherEditionsPlaceholder})}),t.jsx(sd,{entityType:ce,entityId:e.id,entityTitle:e.title,parentWork:u==null?void 0:u.parentWork,parentCollection:u==null?void 0:u.parentCollection,belongsToWork:u==null?void 0:u.belongsToWork,belongsToCollection:u==null?void 0:u.belongsToCollection,childWorks:u==null?void 0:u.childWorks,childCollections:u==null?void 0:u.childCollections,containedBooks:u==null?void 0:u.containedBooks,siblingBooks:u==null?void 0:u.siblingBooks,onLinkEntity:ze,onUnlinkEntity:Ce,onViewEntity:Oe,onCreateAndLink:ne,onSaveRelations:K}),a&&l&&t.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${r("danger-soft-border")}`,background:r("danger-soft-bg"),borderRadius:"4px"},children:[t.jsx("div",{style:{color:r("danger"),fontWeight:600,marginBottom:"8px"},children:f.section.dangerZone}),t.jsx("p",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"12px"},children:f.editor.dangerZoneDesc}),t.jsx("button",{onClick:l,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("danger")}`,borderRadius:"4px",background:"transparent",color:r("danger"),cursor:"pointer"},children:f.editor.deleteEntity})]}),t.jsx(ld,{isOpen:x,entityType:y,title:v,onSelect:he,onCancel:()=>k(!1),onCreate:()=>{k(!1),ne(b,y)},searchResults:C,onSearch:U,isLoading:_,excludeId:e.id}),t.jsx(cd,{isOpen:T,entityType:M,relationField:N,inheritData:A,onConfirm:W,onCancel:()=>z(!1)}),t.jsx(pd,{isOpen:ee,title:f.action.selectBookOrWork,filterType:"all",recentEntities:G,excludeId:e.id,onSelect:le,onCancel:()=>{oe(!1),me(null)},onSearch:Q})]})};function nb({items:e,onChange:n}){const i=Ie(),o=(l,d,c)=>{const p=e.map((h,u)=>u===l?{...h,[d]:c}:h);n(p)},s=l=>n(e.filter((d,c)=>c!==l)),a=()=>n([...e,{book_title:""}]);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((l,d)=>t.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[t.jsx(xt,{label:i.editor.bookNameLabel,value:l.book_title,onChange:c=>o(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(xt,{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 md({items:e,onChange:n,showMeta:i,addLabel:o}){const s=Ie(),[a,l]=g.useState(null),d=(h,u,m)=>{const f=e.map((x,k)=>k===h?{...x,[u]:m||void 0}:x);n(f)},c=h=>{n(e.filter((u,m)=>m!==h)),a===h&&l(null)},p=()=>{n([...e,{source:""}]),l(e.length)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((h,u)=>{const m=a===u;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:m?`color-mix(in srgb, ${r("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(m?null:u),children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.2s",transform:m?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:h.source||s.editor.unnamedSource}),h.source_bid&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:h.source_bid}),t.jsx("button",{onClick:f=>{f.stopPropagation(),c(u)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${r("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:r("muted")},children:"✕"})]}),!m&&i&&(h.title_info||h.author_info)&&t.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:r("desc-fg")},children:[h.title_info,h.title_info&&h.author_info&&" — ",h.author_info]}),m&&t.jsxs("div",{style:{padding:"8px 12px 12px",display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(xt,{label:s.label.sourceName,value:h.source,onChange:f=>d(u,"source",f)}),t.jsx(xt,{label:s.label.sourceBid,value:h.source_bid||"",onChange:f=>d(u,"source_bid",f)})]}),i&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(xt,{label:s.label.titleInfo,value:h.title_info||"",onChange:f=>d(u,"title_info",f)}),t.jsx(xt,{label:s.label.authorInfo,value:h.author_info||"",onChange:f=>d(u,"author_info",f)})]}),t.jsx(xt,{label:s.label.edition,value:h.edition||"",onChange:f=>d(u,"edition",f)})]}),t.jsx(on,{value:h.summary||"",onChange:f=>d(u,"summary",f),placeholder:s.editor.summaryPlaceholder}),t.jsx(on,{value:h.comment||"",onChange:f=>d(u,"comment",f),placeholder:s.editor.commentPlaceholder}),t.jsx(on,{value:h.additional_comment||"",onChange:f=>d(u,"additional_comment",f),placeholder:s.editor.additionalCommentPlaceholder})]})]},u)}),t.jsx("button",{onClick:p,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${r("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("desc-fg"),alignSelf:"flex-start"},children:o})]})}function ib({items:e,onChange:n}){const i=Ie();return t.jsx(md,{items:e,onChange:n,showMeta:!0,addLabel:i.action.addIndexedBy})}function rb({items:e,onChange:n}){const i=Ie();return t.jsx(md,{items:e,onChange:n,addLabel:i.action.addEmendatedBy})}function hd(e){var d,c,p,h,u,m,f;const n=((c=(d=e.authors)==null?void 0:d[0])==null?void 0:c.name)||"",i=((p=e.publication_info)==null?void 0:p.year)||"",o=((h=e.current_location)==null?void 0:h.name)||"",s=(u=e.page_count)!=null&&u.number?String(e.page_count.number):((m=e.page_count)==null?void 0:m.description)||"",a=typeof e.description=="object"&&e.description!==null&&e.description.text||"",l={id:e.id,title:e.title,type:e.type,author:n,publicationYear:i,holder:o,pages:s,description:a,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};if(e.type==="work"){const x=e;if(Array.isArray(x.related_works)){const k=x.related_works.find(y=>y.relation==="part_of");k&&(l.parentWorkId=k.id,l.parentWorkName=k.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 ob(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 sb=e=>{const{data:n,id:i,transport:o,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:h,onAskAI:u,renderSectionActions:m,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y,headerExtra:$,className:b,style:w}=e,v=Ie(),[j,C]=g.useState(s),S=a?s:j;g.useEffect(()=>{s!==j&&C(s)},[s]);const _=g.useCallback(()=>{const R=S==="view"?"edit":"view";a?a(R):C(R)},[S,a]),[L,T]=g.useState(null);g.useEffect(()=>{i&&o&&o.getItem(i).then(R=>{R&&T(R)})},[i,o]);const z=n||L,M=g.useMemo(()=>z?hd(z):null,[z]),H=a||!n?t.jsx("button",{onClick:_,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:S==="edit"?r("accent-bg"):"transparent",color:r(S==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:S==="view"?v.common.switchToEdit:v.common.switchToView,children:S==="view"?v.common.modeEdit:v.common.modeView}):null,N=t.jsxs(t.Fragment,{children:[H,$]});return!z&&!M?t.jsx(sn,{}):S==="view"?t.jsx(io,{data:z,transport:o,onNavigate:p?R=>p(R):void 0,renderLink:h,headerExtra:N,className:b,style:w}):M?t.jsxs("div",{className:b,style:w,children:[N&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:N}),t.jsx(ud,{data:M,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:o,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:u,renderSectionActions:m,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:r("muted")},children:v.common.noData})},ab=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],gd=({isOpen:e,onClose:n,onSubmit:i,feedbackListUrl:o})=>{const{t:s}=te(),[a,l]=g.useState(null),[d,c]=g.useState(""),[p,h]=g.useState(""),[u,m]=g.useState("idle"),[f,x]=g.useState(""),k=g.useRef(null);g.useEffect(()=>{e&&(l(null),c(""),h(""),m("idle"),x(""))},[e]),g.useEffect(()=>{a&&setTimeout(()=>{var b;return(b=k.current)==null?void 0:b.focus()},100)},[a]),g.useEffect(()=>{if(u==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[u,n]),g.useEffect(()=>{if(!e)return;const b=w=>{w.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,n]);const y=async()=>{if(!(!a||!d.trim())){m("submitting"),x("");try{await i({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),m("success")}catch(b){m("error"),x(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const $=a&&d.trim()&&u!=="submitting";return t.jsx("div",{style:lb,onClick:b=>{b.target===b.currentTarget&&n()},children:t.jsxs("div",{style:cb,onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{style:db,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:pb,"aria-label":s("feedback.close"),children:"✕"})]}),u==="success"?t.jsxs("div",{style:fb,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:ab.map(b=>t.jsxs("button",{onClick:()=>l(b.value),style:{...ub,...a===b.value?mb:{}},children:[t.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),t.jsx("textarea",{ref:k,value:d,onChange:b=>c(b.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||u==="submitting",style:{...hb,opacity:a?1:.6}}),t.jsx("input",{type:"text",value:p,onChange:b=>h(b.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!a||u==="submitting","aria-label":s("feedback.contactLabel"),style:bb}),t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),u==="error"&&t.jsx("div",{style:xb,children:f}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:y,disabled:!$,style:{...gb,opacity:$?1:.6,cursor:$?"pointer":"not-allowed"},children:s(u==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},lb={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},cb={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:r("shadow-dialog")},db={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},pb={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:r("desc-fg"),padding:"4px 8px",borderRadius:"4px"},ub={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"},mb={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},hb={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"},gb={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},fb={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:r("success")},xb={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginBottom:"12px"},bb={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"},Fr="--bim-feedback-fab-offset",Hr=48,yb=16,jb=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:i,hidden:o=!1,zIndex:s})=>{const{t:a}=te(),[l,d]=g.useState(!1),c=n.bottom??24;return g.useEffect(()=>{if(o||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(Fr,`calc(${c+Hr+yb}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(Fr)}},[o,c]),t.jsxs(t.Fragment,{children:[!o&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...vb,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(gd,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:i})]})},vb={position:"fixed",width:`${Hr}px`,height:`${Hr}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"},kb=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],fd=({onSubmit:e})=>{const{t:n}=te(),[i,o]=g.useState("bug"),[s,a]=g.useState(""),[l,d]=g.useState(""),[c,p]=g.useState("idle"),[h,u]=g.useState(""),m=g.useRef(null);g.useEffect(()=>{i&&setTimeout(()=>{var k;return(k=m.current)==null?void 0:k.focus()},100)},[i]);const f=async()=>{if(!(!i||!s.trim())){p("submitting"),u("");try{await e({type:i,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),o("bug")}catch(k){p("error"),u(k instanceof Error?k.message:n("feedback.submitFailedRetry"))}}},x=i&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:Na,children:t.jsxs("div",{style:Cb,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:zb,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:Na,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:kb.map(k=>t.jsxs("button",{onClick:()=>o(k.value),style:{...wb,...i===k.value?Sb:{}},children:[t.jsx("span",{children:k.icon})," ",n(`feedback.submitType.${k.value}`)]},k.value))}),t.jsx("textarea",{ref:m,value:s,onChange:k=>a(k.target.value),placeholder:n(i?`feedback.placeholder.${i}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{..._b}}),t.jsx("input",{type:"text",value:l,onChange:k=>d(k.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:Nb}),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:{...$b,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:Tb,children:h})]})},Na={padding:"16px",border:`1px solid ${r("widget-border")}`,borderRadius:"8px",background:r("input-bg")},wb={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"},Sb={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},_b={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"},$b={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},Cb={display:"flex",alignItems:"center",gap:"12px",color:r("success"),fontSize:"14px"},zb={background:"none",border:"none",color:r("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},Tb={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginTop:"8px"},Nb={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"};function Ia(e){return typeof e=="function"?e():e??"/api/feedback"}const xd=({resourceId:e,apiUrl:n})=>{const{t:i}=te(),[o,s]=g.useState([]),[a,l]=g.useState(!0),d=g.useCallback(async()=>{const p=Ia(n);l(!0);try{const u=await(await fetch(`${p}?resourceId=${encodeURIComponent(e)}`)).json();u.success&&s(u.items)}catch{}finally{l(!1)}},[e,n]);g.useEffect(()=>{d()},[d]);const c=async p=>{const h=Ia(n),u=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!u.ok){const m=await u.json().catch(()=>null);throw new Error((m==null?void 0:m.error)||i("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(Oo,{items:o,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(fd,{onSubmit:c})})]})},Wi=8;async function Oi(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 Ib=_i["zh-Hant"].relation,Eb=_i["zh-Hant"].lossStatus,Rb=_i["zh-Hant"].resourceKind,Fi=vn("zh-Hant"),Fo=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function Ea(e,n=Fi){return e?Fo(Ib,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function Lb(e,n=Fi){return Fo(Eb,e)?n(`detail.lossStatus.${e}`):e}function Ab(e,n=Fi){return Fo(Rb,e)?n(`detail.resourceKind.${e}`):""}function Ho({authors:e,onNavigate:n,renderLink:i}){const{convert:o}=te(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=uo(a.role);return t.jsxs(g.Fragment,{children:[l>0&&" ",a.dynasty&&t.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",o(a.dynasty),"〕"]}),a.entity_id?t.jsx(it,{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 bd(e,n,i=Fi){var c,p;const o=co(e,n),s=o.mirrors.map(h=>({key:h.key,label:h.label,description:h.description,rows:h.items.filter(u=>u.group_role!=="mirror"),mirrors:h.items.filter(u=>u.group_role==="mirror")})),a=o.buckets.filter(h=>h.key==="image"||h.key==="textImage").flatMap(h=>h.items);a.length&&s.push({key:"_images",label:s.length?i("detail.otherImages"):void 0,rows:a,mirrors:[]});const l=((c=o.buckets.find(h=>h.key==="physical"))==null?void 0:c.items)??[];return l.length&&s.push({key:"_physical",label:i("detail.resourceKind.physical"),rows:l,mirrors:[]}),{text:((p=o.buckets.find(h=>h.key==="text"))==null?void 0:p.items)??[],groups:s}}function yd(e,n){const i=(e.url?bn(e.url):void 0)||e.name,o=Ql(e,n);return o?`${i}(${o})`:i}function Do({item:e,siblings:n,listedVolumeCounts:i}){const{t:o,convert:s}=te(),[a,l]=g.useState(!1),d=Si(e),c=!!d&&d.expected>0&&!(i!=null&&i.has(d.expected)),p=s(yd(e,n)),h=yn(e),u=Ri(e,o)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var f,x;const m=(f=e.metadata)!=null&&f.fragment||e.color_mode?t.jsxs("span",{className:"bim-d-tags bim-d-ui",style:{display:"inline-flex",margin:"0 0 0 8px",verticalAlign:"middle"},children:[((x=e.metadata)==null?void 0:x.fragment)&&t.jsx("span",{className:"bim-d-tag",children:o("detail.fragmentTag")}),e.color_mode&&t.jsx("span",{className:"bim-d-tag",children:e.color_mode==="color"?o("colorMode.color"):o("colorMode.bw")})]}):null;return h?t.jsxs("a",{href:h,target:"_blank",rel:"noopener noreferrer",children:[p," ",t.jsx("span",{"aria-hidden":"true",children:"↗"}),m]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,m]})})(),u&&t.jsx("span",{className:"bim-d-meta",children:s(u)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(yo,{item:e})})]}),t.jsx("td",{className:c?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:c&&t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":a,onClick:()=>l(m=>!m),children:a?o("detail.collapseVolumes"):o("detail.expandVolumes",{n:d.expected})})})]})}function jd({groups:e,listedVolumeCounts:n}){const{t:i,convert:o}=te();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(Do,{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=yn(a),c=o(yd(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 Bn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function Dr(e){var i;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(i=Bn.find(o=>n.startsWith(o.key[0])))==null?void 0:i.key}const Ra=12,Mb=60,vd=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,railTop:a,back:l,railLinks:d})=>{var U,he,K;const{t:c,convert:p,messages:h}=te(),u=g.useMemo(()=>mo({_books:e._books}),[e._books]),[m,f]=g.useState(new Map),[x,k]=g.useState(!1),[y,$]=g.useState(""),[b,w]=g.useState(!1),v=u.length<=Mb,j=v||x||!!y||b,C=g.useMemo(()=>j?u:u.slice(0,Ra),[u,j]);g.useEffect(()=>{if(!n||C.length===0)return;const B=C.filter(le=>!m.has(le));if(B.length===0)return;let Q=!1;return Oi(B,Wi,le=>n.getItem(le).then(ie=>{const D=ie??{};return[le,{id:le,title:D.title,edition:D.edition,resources:D.resources,publication_info:D.publication_info,current_location:D.current_location,lineage:D.lineage,measure_info:D.measure_info}]}).catch(()=>[le,{id:le}]),()=>Q).then(le=>{Q||f(ie=>{const D=new Map(ie);for(const[se,Te]of le)D.set(se,Te);return D})}),()=>{Q=!0}},[n,C,m]);const S=g.useMemo(()=>u.map(B=>m.get(B)??{id:B}),[u,m]),_=u.length>0&&u.every(B=>m.has(B)),L=!!n&&C.some(B=>!m.has(B)),T=v||j,z=g.useMemo(()=>tc(S,e.version_graph,{era:y,scanOnly:b,sort:T?"year":"default"}),[S,e.version_graph,y,b,T]),M=x?z.rows:z.rows.slice(0,Ra),H=z.allRows.filter(B=>B.hasImage).length,N=g.useMemo(()=>(e._related||[]).map(B=>({...B,title:B.title??""})),[e._related]),R=N.filter(B=>B.relation==="collected_in"),A=g.useMemo(()=>{const B=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],Q=le=>{const ie=B.indexOf(le??"");return ie<0?B.length:ie};return N.filter(le=>le.relation!=="collected_in").map((le,ie)=>({r:le,i:ie})).sort((le,ie)=>Q(le.r.relation)-Q(ie.r.relation)||le.i-ie.i).map(le=>le.r)},[N]),J=g.useMemo(()=>{const B=co(e.resources,e.resource_groups);return[...B.mirrors.flatMap(Q=>Q.items.map(le=>({r:le,kind:p(Q.label)}))),...B.buckets.flatMap(Q=>Q.items.map(le=>({r:le,kind:p(Ab(Q.key,c))})))]},[e.resources,e.resource_groups,p,c]),ee=e.indexed_by||[],oe=e.emendated_by||[],V=g.useMemo(()=>{var Le,F,ae;const B=[],Q=(F=(Le=e.authors)==null?void 0:Le[0])==null?void 0:F.dynasty;Q&&B.push({label:c("workPage.fact.written"),value:p(Q)});const le=Ht(e,h.unit.juan);if(le){const fe=(ae=e.juan_count)==null?void 0:ae.description;B.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(le),fe&&fe!==le?t.jsxs("span",{className:"bim-d-meta",children:["(",p(fe),")"]}):null]})})}e.loss_status&&B.push({label:c("workPage.fact.loss"),value:p(Lb(e.loss_status,c))});const ie=z.allRows.filter(fe=>fe.sortYear!=null),D=ie.length>0?ie.reduce((fe,P)=>fe.sortYear<=P.sortYear?fe:P):null;D!=null&&D.era.era?B.push({label:c("workPage.fact.earliest"),value:p([D.era.era,D.era.reign].filter(Boolean).join(" ")),title:D.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):L&&B.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),oe.length&&B.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:oe.length})});const se=La(e.additional_titles);se.length&&B.push({label:c("workPage.fact.alias"),value:se.map(p).join("、")});const Te=La(e.attached_texts);Te.length&&B.push({label:c("workPage.fact.attached"),value:Te.map(p).join("、")});const Me=(e.additional_works||[]).map(fe=>p(fe.book_title)+(fe.n_juan!=null?` ${fe.n_juan}${h.unit.juan}`:""));return Me.length&&B.push({label:c("workPage.fact.appendix"),value:Me.join("、")}),B},[e,p,c,h,L,z.allRows,oe.length]),G=[{value:e._edition_count??u.length,label:c("workPage.stat.editions")},{value:_?H:0,label:c("workPage.stat.hasImage")},{value:ee.length,label:c("workPage.stat.catalogs")}],q=ho(e),ce=q?[q.l1,q.l2,q.l3,q.l4].filter(Boolean).map(B=>p(B)):[],we=e.subtype?h.workSubtype[e.subtype]??p(e.subtype):"",O=t.jsx(Dn,{title:p(e.title),byline:t.jsx(Ho,{authors:e.authors,onNavigate:i,renderLink:o}),meta:t.jsx(at,{items:[...ce,q!=null&&q.source?c("workPage.classifiedBy",{source:p(q.source.split("/")[0])}):"",we]}),description:(U=e.description)!=null&&U.text?t.jsxs(t.Fragment,{children:[t.jsx(Ft,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(he=e.description.sources)!=null&&he.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(B=>({text:p(zh(B)),href:Th(B)})).filter(B=>B.text).map((B,Q)=>t.jsxs(g.Fragment,{children:[Q>0?" · ":null,B.href?t.jsx("a",{href:B.href,target:"_blank",rel:"noopener noreferrer",children:B.text}):B.text]},Q))}):null]}):void 0,stats:G,facts:V,readAction:s,foot:t.jsx(Un,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(K=e.appendix)==null?void 0:K.map((B,Q)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(B.title)}),t.jsx(Ft,{text:B.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},Q))}),ye=z.eras.length>=2?[{key:"",label:c("catalog.all")},...z.eras.map(B=>({key:B,label:`${B} ${z.allRows.filter(Q=>Q.era.era===B).length}`}))]:[],de=[];u.length&&de.push({id:"versions",label:c("workPage.sec.versions"),count:u.length}),ee.length&&de.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:ee.length}),R.length&&de.push({id:"collected",label:c("workPage.sec.collected"),count:R.length}),A.length&&de.push({id:"related",label:c("workPage.sec.related"),count:A.length}),J.length&&de.push({id:"resources",label:c("workPage.sec.resources"),count:J.length});const ze=u.length===0&&ee.length===0,Ce=t.jsxs(t.Fragment,{children:[u.length>0&&t.jsxs(lt,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(at,{items:[c("workPage.versionsTotal",{n:u.length}),_&&H?c("workPage.versionsWithImage",{n:H}):"",z.rows.length!==z.allRows.length?c("workPage.versionsCurrent",{n:z.rows.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":L&&ye.length===0&&u.length>1?"":void 0,children:[ye.length>0&&t.jsx(Ai,{items:ye,value:y,onChange:B=>{$(B),k(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(mc,{label:c("workPage.scanOnly"),checked:b,onChange:B=>{w(B),k(!1)}}),t.jsx("span",{className:"bim-d-meta",children:c(T?"workPage.sortByYear":"workPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&Mi(z.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:M.map(B=>{var Q;return t.jsx(Pb,{row:B,measure:(Q=m.get(B.id))==null?void 0:Q.measure_info,loaded:m.has(B.id),onNavigate:i,renderLink:o},`${B.id}:${m.has(B.id)?"r":"p"}`)})})]}),M.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(go,{total:z.rows.length,shown:M.length,unit:c("workPage.moreUnit"),onClick:()=>k(!0)}),z.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),ee.length>0&&t.jsx(Bb,{items:ee,transport:n,onNavigate:i,renderLink:o}),ze&&t.jsx(lt,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),Oe=(B,Q)=>t.jsx(it,{id:B,label:p(Q),onNavigate:i,renderLink:o,dense:!0}),ne=g.useMemo(()=>{const B=new Map;for(const Q of A){const le=Ea(Q.relation,c);B.set(le,(B.get(le)??0)+1)}return B.size>1?[...B.entries()].sort((Q,le)=>le[1]-Q[1]).slice(0,4).map(([Q,le])=>`${p(Q)} ${le}`).join(" · "):void 0},[A,p,c]),W=t.jsxs(t.Fragment,{children:[t.jsx(rn,{id:"collected",title:c("workPage.sec.collected"),items:R.map(B=>Oe(B.id,B.title))}),t.jsx(rn,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:A.length}),sub:ne,items:A.map(B=>t.jsxs(t.Fragment,{children:[Oe(B.id,B.title),t.jsx("span",{className:"bim-d-meta",title:B.note?p(B.note):void 0,children:p(Ea(B.relation,c))})]}))}),t.jsx(rn,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:J.map(({r:B,kind:Q})=>{const le=p((B.url?bn(B.url):void 0)||B.name),ie=yn(B);return t.jsxs(t.Fragment,{children:[ie?t.jsxs("a",{href:ie,target:"_blank",rel:"noopener noreferrer",children:[le," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:le}),Q&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:Q})]})})})]});return t.jsx(Hn,{railTop:a,back:l,nav:de,railLinks:d,main:Ce,card:O,side:W})};function La(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Aa(e,n){return n((e.url?bn(e.url):void 0)||e.name)}function Pb({row:e,measure:n,loaded:i,onNavigate:o,renderLink:s}){const{t:a,convert:l}=te(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],h=p?Aa(p,l):e.locationName?l(e.locationName):"",u=e.images[0],m=u?yn(u):void 0,f=e.images.map(x=>Aa(x,l)).join("、");return t.jsxs("tr",{"data-loading":i?void 0:"",children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(it,{id:e.id,label:l(e.name),onNavigate:o,renderLink:s,dense:!0}),n?t.jsx("span",{className:"bim-d-meta",children:l(n)}):t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${d?"":" bim-d-zt-blank"}`,title:c?a("workPage.inferredFromEdition"):void 0,children:d?l(d):i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),t.jsxs("td",{className:`bim-d-zt-sub${h?"":" bim-d-zt-blank"}`,children:[h||(i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),e.holders.length>1&&t.jsxs("span",{className:"bim-d-meta",children:[" +",e.holders.length-1]})]}),t.jsx("td",{className:e.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:e.hasImage&&(m?t.jsx("a",{className:"bim-d-flag",href:m,target:"_blank",rel:"noopener noreferrer",title:f,children:a("workPage.hasImage")}):t.jsx("span",{className:"bim-d-flag",title:f,children:a("workPage.hasImage")}))})]})}function Bb({items:e,transport:n,onNavigate:i,renderLink:o}){const{t:s,convert:a}=te(),[l,d]=g.useState(0),c=Math.min(l,e.length-1),p=e[c],[h,u]=g.useState(new Map);return g.useEffect(()=>{if(!n)return;const m=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(m.length===0)return;let f=!1;return Promise.all(m.map(x=>n.getItem(x).then(k=>{var y,$;return[x,(($=(y=k==null?void 0:k.authors)==null?void 0:y[0])==null?void 0:$.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{f||u(new Map(x.filter(([,k])=>k)))}),()=>{f=!0}},[n,e]),t.jsx(lt,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(at,{items:[s("workPage.catalog.meta",{n:e.length}),s("workPage.sortByCatalog")]}),children:t.jsxs("div",{className:"bim-d-lu",children:[t.jsx("ul",{className:"bim-d-tl2 bim-d-ui",role:"tablist","aria-label":s("workPage.catalog.tablist"),children:e.map((m,f)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":f===c,"aria-label":a(m.source),onClick:()=>d(f),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:h.get(m.source_bid??"")?a(h.get(m.source_bid??"")):" "}),t.jsx("i",{className:"bim-d-tl2-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-d-tl2-name","aria-hidden":"true",children:[...a(m.source)].slice(0,9).map((x,k)=>t.jsx("span",{children:x},k))})]})},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(at,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(it,{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:yt(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:yt(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:yt(a(p.additional_comment),void 0,{t:s})})]}),!p.summary&&!p.comment&&!p.additional_comment&&!p.title_info&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{marginTop:12},children:s("workPage.catalog.titleOnly")}),e.length>1&&t.jsxs("div",{className:"bim-d-lu-pager bim-d-ui",children:[c>0?t.jsx("button",{type:"button","aria-label":s("workPage.catalog.prev",{name:a(e[c-1].source)}),onClick:()=>d(c-1),children:t.jsxs("span",{"aria-hidden":"true",children:["← ",a(e[c-1].source)]})}):t.jsx("span",{"aria-hidden":"true"}),t.jsxs("span",{className:"bim-d-meta",children:[c+1," / ",e.length]}),c<e.length-1?t.jsx("button",{type:"button","aria-label":s("workPage.catalog.next",{name:a(e[c+1].source)}),onClick:()=>d(c+1),children:t.jsxs("span",{"aria-hidden":"true",children:[a(e[c+1].source)," →"]})}):t.jsx("span",{"aria-hidden":"true"})]})]})]})})}function Wb(e){var n;return{id:e.id,kind:"hypothetical",label:e.label,year:e.year??((n=e.year_range)==null?void 0:n[0]),year_range:e.year_range,year_uncertain:e.year_uncertain,group:e.group,note:e.note,description:e.description}}function Ob(e,n){if(!e.lineage)return null;const i=e.lineage;return{id:e.id,kind:"book",label:e.title,year:i.year,year_text:i.year_text,year_uncertain:i.year_uncertain,category:i.category,status:i.status,extant_juan:i.extant_juan,group:n[e.id],note:i.note}}function Ma(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 Fb(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 Hb(e,n){var p;if(n==="all")return null;const i=(p=e.collections)==null?void 0:p[n],o=Array.isArray(i==null?void 0:i.groups)&&i.groups.length>0,s=Array.isArray(i==null?void 0:i.book_ids)&&i.book_ids.length>0,a=o||s||!!(i!=null&&i.hypothetical_ids);if(!a&&n==="core"&&Array.isArray(e.core_books)&&e.core_books.length>0)return{books:new Set(e.core_books),hypos:e.core_hypotheticals?new Set(e.core_hypotheticals):null};if(!i||!a)return null;const l=o?new Set(i.groups):null,d=new Set(i.book_ids??[]);if(l&&e.node_groups)for(const[h,u]of Object.entries(e.node_groups))l.has(u)&&d.add(h);let c=null;if(i.hypothetical_ids&&(c=new Set(i.hypothetical_ids)),l){c||(c=new Set);for(const h of e.hypothetical_nodes??[])h.group&&l.has(h.group)&&c.add(h.id)}return{books:d,hypos:c}}function fi(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=Hb(o,i??o.default_collection??"all"),c=d!==null,p=(d==null?void 0:d.books)??null,h=(d==null?void 0:d.hypos)??null,u=new Set,m=new Set;if(c){const v=new Map(n.map(T=>[T.id,T])),j=new Map((o.hypothetical_nodes??[]).map(T=>[T.id,T])),C=T=>{const z=v.get(T);if(z&&z.lineage)return(z.lineage.derived_from??[]).map(H=>H.ref);const M=j.get(T);return M?(M.derived_from??[]).map(H=>H.ref):[]},S=T=>j.has(T)?!h||h.has(T):!p||p.has(T),_=new Set,L=T=>{if(!_.has(T)){_.add(T);for(const z of C(T))a.has(z)||(S(z)||(j.has(z)?m.add(z):v.has(z)&&u.add(z)),L(z))}};for(const T of n)p&&p.has(T.id)&&!a.has(T.id)&&L(T.id);for(const T of o.hypothetical_nodes??[])h&&h.has(T.id)&&L(T.id)}const f=n.filter(v=>!a.has(v.id)).filter(v=>!p||p.has(v.id)||u.has(v.id)).map(v=>{const j=Ob(v,l);return j&&u.has(v.id)&&(j.bridge=!0),j}).filter(v=>v!==null),x=(o.hypothetical_nodes??[]).filter(v=>!h||h.has(v.id)||m.has(v.id)).map(v=>{const j=Wb(v);return m.has(v.id)&&(j.bridge=!0),j}),k=[...f,...x],y=new Set(k.map(v=>v.id)),$=new Set,b=[],w=v=>{$.has(v.id)||!y.has(v.source)||!y.has(v.target)||($.add(v.id),b.push(v))};for(const v of n)a.has(v.id)||!v.lineage||p&&!p.has(v.id)&&!u.has(v.id)||((v.lineage.derived_from??[]).forEach((j,C)=>{w(Ma(v.id,j,C))}),(v.lineage.related_to??[]).forEach((j,C)=>{w(Fb(v.id,j,C))}));for(const v of o.hypothetical_nodes??[])h&&!h.has(v.id)&&!m.has(v.id)||(v.derived_from??[]).forEach((j,C)=>{w(Ma(v.id,j,C))});return{nodes:k,edges:b,groups:o.groups??[],title:o.title,description:o.description,layout:o.layout??"LR",excluded:Array.from(a)}}function kd(e,n,i){const o=(e??(n!=null?String(n):"")).trim();return o?!i||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(o)?o:`约 ${o}`:""}function Db(e,n){const i=[],o=e.version_graph;if(!o)return i;const s=new Set(n.map(c=>c.id)),a=new Set((o.hypothetical_nodes??[]).map(c=>c.id)),l=new Set([...s,...a]),d=(c,p)=>{l.has(p.ref)||i.push(`${c}: derived_from.ref "${p.ref}" 未在 books 或 hypothetical_nodes 中找到`),p.ref_type==="book"&&!s.has(p.ref)&&i.push(`${c}: derived_from.ref "${p.ref}" 标记为 book 但不在 books 列表中`),p.ref_type==="hypothetical"&&!a.has(p.ref)&&i.push(`${c}: derived_from.ref "${p.ref}" 标记为 hypothetical 但不在 hypothetical_nodes 中`)};for(const c of n){if(!c.lineage)continue;const p=`Book ${c.id} (${c.title})`;(c.lineage.derived_from??[]).forEach(h=>d(p,h)),(c.lineage.related_to??[]).forEach(h=>{s.has(h.book_id)||i.push(`${p}: related_to.book_id "${h.book_id}" 不在 books 列表中`)})}for(const c of o.hypothetical_nodes??[]){const p=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(h=>d(p,h))}return i}const wd=({graph:e,renderLink:n,className:i,style:o})=>{const{t:s,convert:a}=te();if(!e.nodes.length)return t.jsx("div",{style:{...iy,...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 k=d.get(x)??[];k.push(f),d.set(x,k)}const c=new Map(e.nodes.map(f=>[f.id,f])),p=new Map,h=[];for(const f of e.nodes)if(f.group){const x=p.get(f.group)??[];x.push(f),p.set(f.group,x)}else h.push(f);const u=(f,x)=>(f.year??9999)-(x.year??9999);p.forEach(f=>f.sort(u)),h.sort(u);const m=e.groups.filter(f=>p.has(f.id));return t.jsxs("div",{className:i,style:{...Vb,...o},children:[e.title&&t.jsx("div",{style:Gb,children:a(e.title)}),e.description&&t.jsx("div",{style:Yb,children:a(e.description)}),m.map(f=>t.jsx(Pa,{label:f.label,color:f.color,nodes:p.get(f.id),incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n},f.id)),h.length>0&&t.jsx(Pa,{label:s("lineage.otherGroup"),nodes:h,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},Pa=({label:e,color:n,nodes:i,incomingMap:o,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=te();return t.jsxs("div",{style:qb,children:[t.jsx("div",{style:{...Kb,borderLeftColor:n??r("widget-border")},children:d(e)}),i.map(c=>t.jsx(Ub,{node:c,incoming:o.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},Ub=({node:e,incoming:n,siblings:i,nodeMap:o,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=te();return t.jsxs("div",{style:{...Xb,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:Zb,children:[t.jsx("span",{style:Jb,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:Qb,children:kd(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:ey,children:[e.category&&t.jsx(In,{children:c(e.category)}),e.status==="lost"&&t.jsx(In,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(In,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(In,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(In,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:ty,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:ny,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:Wa,children:[t.jsx("div",{style:Oa,children:d("lineage.sources")}),n.map(p=>{const h=o.get(p.source);return t.jsxs("div",{style:Fa(p.confidence),children:[t.jsx("span",{style:Ha,children:c(p.relation)}),t.jsx("span",{children:(h==null?void 0:h.kind)==="book"&&s?s(h.id,c(h.label)):c((h==null?void 0:h.label)??p.source)}),p.confidence!=="consensus"&&p.confidence!=="certain"&&t.jsx(Ba,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Da,children:["· ",c(p.evidence)]})]},p.id)})]}),i.length>0&&t.jsxs("div",{style:Wa,children:[t.jsx("div",{style:Oa,children:d("lineage.related")}),i.map(p=>{const h=p.source===e.id?p.target:p.source,u=o.get(h);return t.jsxs("div",{style:Fa(p.confidence),children:[t.jsx("span",{style:Ha,children:c(p.relation)}),t.jsx("span",{children:(u==null?void 0:u.kind)==="book"&&s?s(u.id,c(u.label)):c((u==null?void 0:u.label)??h)}),t.jsx(Ba,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Da,children:["· ",c(p.evidence)]})]},p.id)})]})]})},In=({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})},Ba=({level:e})=>{const{t:n}=te(),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},Vb={fontSize:"14px",color:r("fg")},Gb={fontSize:"16px",fontWeight:600,marginBottom:"8px"},Yb={fontSize:"13px",color:r("muted"),marginBottom:"16px",lineHeight:1.6},qb={marginBottom:"16px"},Kb={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:r("fg")},Xb={border:`1px solid ${r("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:r("bg")},Zb={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Jb={fontSize:"15px",fontWeight:600},Qb={fontSize:"12px",color:r("muted")},ey={marginBottom:"6px"},ty={fontSize:"12px",color:r("muted"),margin:"2px 0"},ny={fontSize:"12px",color:r("muted"),fontStyle:"italic",margin:"4px 0"},Wa={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${r("widget-border")}`},Oa={fontSize:"11px",color:r("muted"),marginBottom:"2px"},Fa=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),Ha={display:"inline-block",padding:"0 6px",fontSize:"11px",background:r("tag-bg"),color:r("fg"),borderRadius:"3px",marginRight:"6px"},Da={fontSize:"11px",color:r("muted")},iy={padding:"20px",textAlign:"center",color:r("muted"),fontSize:"13px"},Sd=({selectedNodeId:e,...n})=>{const{t:i}=te(),[o,s]=g.useState("loading"),[a,l]=g.useState(null);return g.useEffect(()=>{let d=!1;return ry().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),o==="loading"?t.jsx("div",{style:Va,children:i("lineage.graphLoading")}):o==="missing"||!a?t.jsxs("div",{style:Va,children:[t.jsx("div",{children:Ua(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:Ua(i("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(oy,{modules:a,selectedNodeId:e,...n})};function Ua(e,n){return e.split(/(\{\w+\})/).map((i,o)=>{const s=/^\{(\w+)\}$/.exec(i);return t.jsx(g.Fragment,{children:s&&s[1]in n?n[s[1]]:i},o)})}async function ry(){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 oy=({graph:e,renderLink:n,height:i=600,className:o,style:s,selectedNodeId:a,modules:l})=>{const{ReactFlow:d,Background:c,Controls:p,Handle:h,Position:u,BaseEdge:m,EdgeLabelRenderer:f,getSmoothStepPath:x,dagre:k}=l,y=g.useMemo(()=>({lineage:C=>{var A,J,ee,oe;const S=((A=C.data)==null?void 0:A.stepPosition)??.85,[_,L,T]=x({sourceX:C.sourceX,sourceY:C.sourceY,sourcePosition:C.sourcePosition,targetX:C.targetX,targetY:C.targetY,targetPosition:C.targetPosition,stepPosition:S,borderRadius:5}),z=!!((J=C.data)!=null&&J.isSibling),M=z?L:C.targetX-18,H=z?T:C.targetY-12,N=(ee=C.data)==null?void 0:ee.labelStyle,R=(oe=C.data)==null?void 0:oe.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(m,{id:C.id,path:_,style:C.style,markerStart:C.markerStart,markerEnd:C.markerEnd}),C.label&&t.jsx(f,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${M}px,${H}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,...N},children:C.label})})]})}}),[m,f,x]),$=g.useMemo(()=>({version:C=>{const{t:S}=te(),_=C.data,L=_.kind==="hypothetical",T=_.status==="lost",z=_.isSelected,M=_.bridge,H=_.borderColor??r("muted"),N=M||L?"dashed":"solid",R=M?.5:T?.6:1;return t.jsxs("div",{style:{background:r(M?"bg-subtle":"bg"),border:`2px ${N} ${z?r("primary"):H}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:R,boxShadow:z?r("shadow-node-selected"):L||M?"none":r("shadow-node")},title:M?S("lineage.bridgeTitle"):void 0,children:[t.jsx(h,{type:"target",position:u.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:L||!_.renderLink?_.label:_.renderLink(_.bookId,_.label)}),_.description&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.25,marginTop:1},children:_.description}),_.yearText&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.2},children:kd(_.yearText,void 0,_.uncertain)}),T&&t.jsx("div",{style:{fontSize:9,color:r("lost-fg"),marginTop:1},children:S("lineage.lost")}),t.jsx(h,{type:"source",position:u.Right,style:{visibility:"hidden"}})]})}}),[h,u]),{convert:b}=te(),{rfNodes:w,rfEdges:v}=g.useMemo(()=>sy(e,k,n,a,b),[e,k,n,a,b]);return t.jsx("div",{style:{width:"100%",height:i,...s},className:o,children:t.jsxs(d,{nodes:w,edges:v,nodeTypes:$,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 sy(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($=>[$.id,$.color??r("muted")]));for(const $ of e.nodes)c.setNode($.id,{width:160,height:90});const h=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const $ of e.edges)$.kind==="derive"&&(h.has($.relation)||c.setEdge($.source,$.target));n.layout(c);const u=e.nodes.map($=>{const b=c.node($.id),w=o?$.id===o:void 0,v={kind:$.kind,label:s($.label),bookId:$.kind==="book"?$.id:void 0,yearText:s($.year_text??ly($)),uncertain:$.year_uncertain,category:$.category,status:$.status,borderColor:$.group?p.get($.group):void 0,renderLink:i,isSelected:w,description:s($.description),bridge:$.bridge};return{id:$.id,type:"version",position:{x:b.x-160/2,y:b.y-90/2},data:v,draggable:!1,selected:w}}),m=.78,f=.06,x=new Map;for(const $ of e.edges)$.kind==="derive"&&(x.has($.source)||x.set($.source,[]),x.get($.source).push($));const k=new Map;for(const[$,b]of x){if(b.length<=1)continue;const w=[...b].sort((j,C)=>{var L,T;const S=((L=c.node(j.target))==null?void 0:L.y)??0,_=((T=c.node(C.target))==null?void 0:T.y)??0;return S-_}),v=w.length;w.forEach((j,C)=>{const S=(C-(v-1)/2)*f;k.set(j.id,m+S)})}const y=e.edges.map($=>ay($,k.get($.id),s));return{rfNodes:u,rfEdges:y}}function ay(e,n,i=o=>o??""){const o=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=cy(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 ly(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function cy(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 Va={padding:"40px 20px",textAlign:"center",color:r("muted"),fontSize:"13px",border:`1px dashed ${r("widget-border")}`,borderRadius:8,background:r("bg")},Uo=({graph:e,defaultMode:n="list",renderLink:i,graphHeight:o=600,selectedNodeId:s,onModeChange:a,collection:l,onCollectionChange:d,collectionsAvailable:c,collectionCounts:p,className:h,style:u})=>{var v;const{t:m,convert:f}=te(),[x,k]=g.useState(n),y=j=>{k(j),a==null||a(j)},$=(()=>{if(!c)return[];const j=Object.entries(c);return j.length===0||c.all?j:[...j,["all",{label:m("lineage.collectionAll"),description:m("lineage.collectionAllDesc")}]]})(),b=!!(d&&$.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:r("muted"),textAlign:"center"},children:m("lineage.empty")});const w=l?(v=c==null?void 0:c[l])==null?void 0:v.description:void 0;return t.jsxs("div",{className:h,style:u,children:[t.jsxs("div",{style:dy,children:[t.jsx("button",{onClick:()=>y("list"),style:xr(x==="list"),children:m("lineage.modeList")}),t.jsx("button",{onClick:()=>y("graph"),style:xr(x==="graph"),children:m("lineage.modeGraph")}),b&&t.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:12,color:r("muted"),marginRight:4},children:m("lineage.collectionLabel")}),$.map(([j,C])=>{const S=p==null?void 0:p[j];return t.jsxs("button",{onClick:()=>d==null?void 0:d(j),style:xr(l===j),title:C.description?f(C.description):void 0,children:[f(C.label),S!=null?` ${S}`:""]},j)})]})]}),b&&w&&t.jsx("div",{style:{fontSize:12,color:r("muted"),marginBottom:8,padding:"4px 8px",background:r("bg-subtle"),borderRadius:4},children:f(w)}),x==="list"?t.jsx(wd,{graph:e,renderLink:i}):t.jsx(Sd,{graph:e,renderLink:i,height:o,selectedNodeId:s})]})},dy={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},xr=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"}),Ga=40,Ya=2,py=9,uy=new Set(["certain","consensus","probable","disputed"]);function br(e){if(!e)return["",""];const n=e.split(/[  ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const _d=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:h})=>{var ae,fe,P,xe,re,je,Se,Ve,Ye,et,Ze;const u=Ie(),{t:m,convert:f}=te(),[x,k]=g.useState(null),[y,$]=g.useState(new Map),[b,w]=g.useState([]),[v,j]=g.useState(new Map),[C,S]=g.useState(!1),[_,L]=g.useState("flow"),[T,z]=g.useState(null);g.useEffect(()=>{if(!n||!e.work_id){k(null);return}let I=!1;return n.getItem(e.work_id).then(Y=>{!I&&Y&&Y.type==="work"&&k(Y)}).catch(()=>{}),()=>{I=!0}},[n,e.work_id]),g.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){z(null);return}let I=!1;return n.getLineageGraph(e.work_id).then(Y=>{I||z(Y&&Y.nodes.length>1?Y:null)}).catch(()=>{I||z(null)}),()=>{I=!0}},[n,e.work_id]),g.useEffect(()=>{const I=e._collections||[];if(!n||I.length===0){$(new Map);return}let Y=!1;return Promise.all(I.map(pe=>{const ve=pe.id;return n.getItem(ve).then(Ee=>[ve,Ee]).catch(()=>[ve,null])})).then(pe=>{if(Y)return;const ve=new Map;for(const[Ee,ge]of pe)ge&&ve.set(Ee,ge);$(ve)}),()=>{Y=!0}},[n,e._collections]);const M=g.useMemo(()=>{const I=new Set([...x?mo(x):[],...e.related_books||[]]);return I.add(e.id),[...I]},[x,e.related_books,e.id]),H=M.length-1;g.useEffect(()=>{if(!n||H<=0){w([]);return}const I=M.length<=Ga,Y=I?M:M.slice(0,8);let pe=!1;return Promise.all(Y.map(ve=>ve===e.id?Promise.resolve({id:ve,title:e.title,edition:e.edition,year:yi(e)}):n.getItem(ve).then(Ee=>{const ge=Ee??{};return{id:ve,title:ge.title,edition:ge.edition,year:Ee?yi(ge):void 0}}).catch(()=>({id:ve})))).then(ve=>{if(pe)return;const Ee=ve.filter(ge=>ge.id===e.id||ge.title||ge.edition);I&&Ee.sort((ge,Ae)=>(ge.year??1/0)-(Ae.year??1/0)),w(Ee)}),()=>{pe=!0}},[n,M,H,e]);const N=e.lineage,R=g.useMemo(()=>[...((N==null?void 0:N.derived_from)||[]).filter(I=>I.ref_type==="book").map(I=>I.ref),...((N==null?void 0:N.related_to)||[]).map(I=>I.book_id)].filter(Boolean),[N]);g.useEffect(()=>{if(!n||R.length===0){j(new Map);return}let I=!1;return Promise.all(R.map(Y=>n.getItem(Y).then(pe=>[Y,{id:Y,title:pe==null?void 0:pe.title,edition:pe==null?void 0:pe.edition}]).catch(()=>[Y,{id:Y}]))).then(Y=>{I||j(new Map(Y))}),()=>{I=!0}},[n,R]);const A=g.useMemo(()=>bd(e.resources,e.resource_groups,m),[e.resources,e.resource_groups,m]),J=A.groups.reduce((I,Y)=>I+Y.rows.length+Y.mirrors.length,0),ee=A.groups.length>0&&A.groups.every(I=>I.key==="_physical"),oe=Fn(e),V=ac(e),me=Ht(e,u.unit.juan),G=new Set((e._collections||[]).map(I=>Mn(I.vol).length).filter(I=>I>0)),q=I=>{var ve;const Y=(ve=e.base_edition)==null?void 0:ve.find(Ee=>Ee.book_id===I&&Ee.name);if(Y!=null&&Y.name)return Y.name;const pe=v.get(I);return(pe==null?void 0:pe.edition)||(pe==null?void 0:pe.title)||""},ce=g.useMemo(()=>{var X,$e,Fe,We,Re;const I=[];V&&I.push({label:m("bookPage.fact.editionType"),value:f(V),title:e.edition_type||(X=e.lineage)!=null&&X.category?void 0:m("bookPage.inferredFromEdition")}),($e=e.publication_info)!=null&&$e.details?I.push({label:m("bookPage.fact.publication"),value:f(e.publication_info.details)}):(oe.era||oe.reign)&&I.push({label:m("bookPage.fact.era"),value:f([oe.era,oe.reign].filter(Boolean).join(" ")),title:oe.source==="edition"?m("bookPage.inferredFromEdition"):void 0}),me&&I.push({label:m("bookPage.fact.measure"),value:f(me)});const Y=(e._collections||[]).flatMap(be=>Mn(be.vol));Y.length&&I.push({label:m("bookPage.fact.volumes"),value:m("bookPage.volumesValue",{range:Li(Y,u.unit.volume),unit:u.unit.volume,n:Y.length})});const pe=(((Fe=e.lineage)==null?void 0:Fe.derived_from)||[]).find(be=>be.relation==="底本"&&be.ref_type==="book");pe&&q(pe.ref)&&I.push({label:m("bookPage.fact.baseEdition"),value:t.jsx(it,{id:pe.ref,label:f(q(pe.ref)),onNavigate:i,renderLink:o,dense:!0})});const ve=(e.base_edition||[]).filter(be=>be&&be.name);for(const be of["底本","配補","參校"]){if(be==="底本"&&pe&&q(pe.ref))continue;const Be=ve.filter(_e=>_e.role===be);Be.length&&I.push({label:f(be),value:Be.map((_e,Je)=>t.jsxs(g.Fragment,{children:[Je>0&&"、",_e.book_id?t.jsx(it,{id:_e.book_id,label:f(_e.name),onNavigate:i,renderLink:o,dense:!0}):f(_e.name)]},Je))})}const Ee=(e.provenance||[]).filter(be=>be&&be.institution),ge=(e.resources||[]).filter(be=>Ot(be).includes("physical"));if(Ee.length){I.push({label:m("bookPage.fact.holdings"),value:Ee.slice(0,2).map(_e=>f(_e.institution)).join("、")+(Ee.length>2?m("bookPage.andMorePlaces",{n:Ee.length}):"")});const be=Ee.filter(_e=>_e.call_number).slice(0,2).map(_e=>`${f(_e.institution)} ${_e.call_number}`);be.length&&I.push({label:m("bookPage.fact.callNumber"),value:be.join(";")+(Ee.filter(_e=>_e.call_number).length>2?"…":"")});const Be=Ee.flatMap(_e=>_e.seals||[]).filter(Boolean);Be.length&&I.push({label:m("bookPage.fact.seals"),value:f(Be.join("、"))})}else ge.length?I.push({label:m("bookPage.fact.holdings"),value:ge.slice(0,2).map(be=>f(be.name)).join("、")+(ge.length>2?m("bookPage.andMorePlaces",{n:ge.length}):"")}):(We=e.current_location)!=null&&We.name&&I.push({label:m("bookPage.fact.holdings"),value:f(e.current_location.name)});const Ae=e.physical_description;if(Ae){const be=[[m("bookPage.fact.leafStyle"),Ae.leaf_style],[m("bookPage.fact.binding"),Ae.binding],[m("bookPage.fact.dimensions"),Ae.dimensions],[m("bookPage.fact.condition"),Ae.condition]];for(const[Be,_e]of be)_e&&_e.trim()&&I.push({label:Be,value:f(_e)})}(Re=e.page_count)!=null&&Re.description&&I.push({label:u.label.pageCount,value:f(e.page_count.description)});const qe=[...Lr(e.additional_titles),...Lr(e.attached_texts)];return qe.length&&I.push({label:m("bookPage.fact.aliases"),value:qe.map(f).join("、")}),I},[e,f,u,m,oe,V,me,v,i,o]),we=f(e.title),O=e.edition?f(e.edition):void 0,ye=((ae=e.lineage)==null?void 0:ae.year_text)||"",de=t.jsx(Dn,{kind:m("bookPage.kind"),title:we,subtitle:O,byline:t.jsx(Ho,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:i,renderLink:o}),meta:(()=>{const I=[V?f(V):"",oe.era?f([oe.era,oe.reign].filter(Boolean).join("")):"",me?f(me):""].filter(Boolean);return I.length?t.jsx("span",{className:"bim-d-tags",children:I.map((Y,pe)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(pe,2)}`,children:Y},pe))}):null})(),description:(fe=e.description)!=null&&fe.text?t.jsx(Ft,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:xo((P=e.description)==null?void 0:P.text)?6:void 0,facts:ce,readAction:s,secondaryAction:s&&J>0&&!ee?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:m("bookPage.viewImages")}):void 0,foot:t.jsx(Un,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),ze=e._collections||[],Ce=(a==null?void 0:a.chapters)||[],Oe=f(Ce[0]&&br(Ce[0].title)[0].slice(-1)||"")||m("bookPage.chapterUnit"),ne=m("bookPage.chapterCount",{n:Ce.length,unit:Oe}),W=!!((xe=N==null?void 0:N.derived_from)!=null&&xe.length||(re=N==null?void 0:N.related_to)!=null&&re.length||(je=e.appendix)!=null&&je.length),U=[],he=m(ee?"bookPage.sec.physical":"bookPage.sec.images");(Ce.length||A.text.length||l)&&U.push({id:"fulltext",label:m("bookPage.sec.fulltext"),count:Ce.length?ne:void 0}),A.groups.length&&U.push({id:"images",label:he,count:J}),W&&U.push({id:"lineage",label:m("bookPage.sec.lineage")}),ze.length&&U.push({id:"collections",label:m("section.containedIn"),count:ze.length}),(Se=e.location_history)!=null&&Se.length&&U.push({id:"provenance",label:m("section.locationHistory")});const K=I=>(d==null?void 0:d(I))??null,B=Ce[0],Q=B?K(B.file):null,le=C?Ce:Ce.slice(0,py),ie=(I,Y,pe)=>I?t.jsx("a",{className:pe,href:I.href??"#",onClick:I.onClick?ve=>{ve.metaKey||ve.ctrlKey||(ve.preventDefault(),I.onClick())}:void 0,children:Y}):t.jsx("span",{className:pe,children:Y}),D=t.jsxs(t.Fragment,{children:[(Ce.length>0||A.text.length>0||l)&&t.jsxs(lt,{id:"fulltext",title:m("bookPage.sec.fulltext"),meta:Ce.length>0?t.jsx(at,{items:[ne,(Ve=a==null?void 0:a.source)!=null&&Ve.name?m("bookPage.sourceBy",{src:f(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!B&&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"})]}),B&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:m("bookPage.readFrom",{ch:f(br(B.title)[0])||m("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:f((B.title||"").replace(/^第.+?[回章卷篇節节][  ]*/,""))}),ie(Q,t.jsxs(t.Fragment,{children:[m("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),Ce.length>1&&t.jsx("ul",{className:"bim-d-chap",children:le.map(I=>{const[Y,pe]=br(I.title);return t.jsx("li",{children:ie(K(I.file),t.jsxs(t.Fragment,{children:[Y&&t.jsx("b",{children:f(Y)}),f(pe||I.file)]}))},I.file)})}),Ce.length>le.length&&t.jsx(fo,{label:m("detail.expandRest",{n:Ce.length-le.length,unit:Oe}),onClick:()=>S(!0)}),A.text.length>0&&t.jsxs(t.Fragment,{children:[(Ce.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:m("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:A.text.map((I,Y)=>t.jsx(Do,{item:I,siblings:A.text,listedVolumeCounts:G},`${I.id||I.url||I.name}-${Y}`))})})]})]}),A.groups.length>0&&t.jsx(lt,{id:"images",title:he,meta:t.jsx(at,{items:[A.groups.length>1?m("bookPage.groupCount",{n:A.groups.length}):"",m("bookPage.placeCount",{n:J})]}),children:t.jsx(jd,{groups:A.groups,listedVolumeCounts:G})}),W&&t.jsx(lt,{id:"lineage",title:m("bookPage.sec.lineage"),meta:(Ye=N==null?void 0:N.derived_from)!=null&&Ye.length?m("bookPage.lineageMeta"):void 0,action:T?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":m("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":_==="flow",onClick:()=>L("flow"),children:m("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":_==="graph",onClick:()=>L("graph"),children:m("bookPage.viewGraph")})]}):void 0,children:_==="graph"&&T?t.jsx(Uo,{graph:T,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(I,Y)=>t.jsx(it,{id:I,label:f(Y),onNavigate:i,renderLink:o,dense:!0})}):t.jsx(hy,{data:e,heading:O||we,yearText:ye,refName:q,onNavigate:i,renderLink:o})}),ze.length>0&&t.jsx(lt,{id:"collections",title:m("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:ze.map((I,Y)=>{const pe=I.id,ve=Mn(I.vol),Ee=y.get(pe),ge=$h(Ee);return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(it,{id:pe,label:Ee?f(Ee.title):pe,onNavigate:i,renderLink:o,dense:!0}),ve.length>0&&t.jsx(my,{volumes:ve,unit:u.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${ge?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:ge>0&&m("bookPage.totalOf",{n:ge,unit:u.unit.bu})})]},`${pe}-${Y}`)})})})}),(et=e.location_history)!=null&&et.length?t.jsx(lt,{id:"provenance",title:m("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((I,Y)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:f(I.name)}),([I.start_date,I.end_date].filter(Boolean).join("—")||I.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(at,{items:[[I.start_date,I.end_date].filter(Boolean).join("—"),I.description?f(I.description):""]})})]},Y))})}):null,U.length===0&&t.jsx(lt,{title:m("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:m("bookPage.emptyText")})})]}),se=b.findIndex(I=>I.id===e.id),Te=M.length<=Ga,Me=Te&&se>=0?b.slice(Math.max(0,se-Ya),se+Ya+1):b.filter(I=>I.id!==e.id),Le=t.jsxs(t.Fragment,{children:[x&&t.jsxs("div",{id:"work",className:"bim-d-side",style:{scrollMarginTop:16},children:[t.jsx("h2",{className:"bim-d-ui bim-d-side-h",children:f(u.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(it,{id:x.id,label:f(x.title),onNavigate:i,renderLink:o})}),t.jsx(at,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(I=>`${I.dynasty?`〔${f(I.dynasty)}〕`:""}${f(I.name)}`),f(Ht(x,u.unit.juan)),x._edition_count?m("bookPage.editionCount",{n:x._edition_count}):""]}),((Ze=x.description)==null?void 0:Ze.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,""))})]}),H>0&&Me.length>0&&t.jsxs("div",{children:[t.jsx(rn,{id:"siblings",timeline:!0,title:Te?m("bookPage.siblings"):u.relation.siblingVersions,meta:Te?m("bookPage.byEra"):m("bookPage.kindCount",{n:H}),cap:Me.length,items:Me.map(I=>I.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:f(I.edition||I.title||I.id)}):t.jsx(it,{id:I.id,label:f(I.edition||I.title||I.id),onNavigate:i,renderLink:o,dense:!0})),metas:Me.map(I=>[I.year!=null?I.year<0?m("detail.bce",{n:-I.year}):String(I.year):"",I.id===e.id?m("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:Me.findIndex(I=>I.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(it,{id:x.id,label:m("bookPage.viewAllInWork",{n:M.length}),onNavigate:i,renderLink:o,dense:!0})})]})]}),F=e.work_id?t.jsx(uc,{caption:u.section.belongsToWork,children:t.jsx(it,{id:e.work_id,label:x?f(x.title):" ",onNavigate:i,renderLink:o,dense:!0})}):void 0;return t.jsx(Hn,{railTop:c,back:p,up:F,nav:U,railLinks:h,main:D,card:de,side:Le})};function my({volumes:e,unit:n}){const{t:i}=te();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[i("bookPage.volumeRange",{range:Li(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 hy({data:e,heading:n,yearText:i,refName:o,onNavigate:s,renderLink:a}){var $;const{t:l,convert:d}=te(),c=e.lineage,p=(c==null?void 0:c.derived_from)||[],h=p.filter(b=>b.ref_type!=="book"),u=p.filter(b=>b.ref_type==="book"&&b.relation==="底本"),m=p.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),f=(c==null?void 0:c.related_to)||[],x=p.length>0||f.length>0,k=b=>b&&uy.has(b)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${b}`)}):"",y=(b,w)=>t.jsx(it,{id:b,label:d(w||b),onNavigate:s,renderLink:a,dense:!0});return t.jsxs("div",{className:"bim-d-lf",children:[x&&t.jsxs("ol",{className:"bim-d-lf-list",children:[h.map((b,w)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:b.relation?d(b.relation):l("bookPage.lineage.ancestor")}),t.jsx("span",{className:"bim-d-lf-name",children:l("bookPage.lineage.reconstructed")}),b.evidence&&t.jsxs("span",{className:"bim-d-meta",children:[d(b.evidence),k(b.confidence)]})]})},`a-${w}`)),u.map((b,w)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-card",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,o(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),k(b.confidence)]})]})},`b-${w}`)),t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-cur",children:[t.jsxs("div",{className:"bim-d-lf-here",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:l("bookPage.lineage.thisEdition")}),t.jsx("span",{className:"bim-d-lf-name",children:n}),i&&t.jsx("span",{className:"bim-d-lf-yr",children:d(i)})]}),m.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:m.map((b,w)=>t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,o(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),k(b.confidence)]})]},w))})]}),f.length>0&&t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-out",children:[t.jsx("span",{className:"bim-d-lf-out-h bim-d-ui",children:l("bookPage.lineage.derivatives")}),t.jsx("span",{className:"bim-d-lf-chips",children:f.map((b,w)=>t.jsxs("span",{className:"bim-d-lf-chip",title:b.evidence?d(b.evidence):void 0,children:[y(b.book_id,o(b.book_id)),t.jsx("span",{className:"bim-d-meta",children:d(b.relation)})]},w))})]})]}),($=e.appendix)==null?void 0:$.map((b,w)=>t.jsxs("details",{className:"bim-d-lf-app",children:[t.jsxs("summary",{className:"bim-d-ui",children:[t.jsx("span",{className:"bim-d-meta",children:l("bookPage.lineage.appendix")})," ",d(b.title)]}),t.jsx(Ft,{text:b.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${w}`)),(c==null?void 0:c.note)&&t.jsx("p",{className:"bim-d-meta",style:{margin:"12px 0 0",maxWidth:"46em"},children:d(c.note)})]})}const En=16,gy=200,fy=16,$d=({data:e,catalog:n,transport:i,onNavigate:o,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var se,Te,Me,Le,F,ae,fe;const{t:p,convert:h,messages:u}=te(),[m,f]=g.useState(""),[x,k]=g.useState(!1),[y,$]=g.useState(null),[b,w]=g.useState(""),[v,j]=g.useState(!1),C=g.useMemo(()=>oc(e,n),[e,n]),S=g.useMemo(()=>rc(e),[e]),[_,L]=g.useState(new Map),T=!!i&&C.rows.length>0&&C.rows.length<=gy,z=T&&(C.rows.length<=En||v),M=z&&C.rows.every(P=>!P.id||_.has(P.id)),H=P=>{var xe;return Dr(P?(xe=_.get(P))==null?void 0:xe.l1:void 0)},N=g.useMemo(()=>{const P=m.trim(),xe=P?h(P):"";return C.rows.filter(re=>{var Se,Ve;if(b&&Dr(re.id?(Se=_.get(re.id))==null?void 0:Se.l1:void 0)!==b)return!1;if(!xe)return!0;const je=re.id&&((Ve=_.get(re.id))==null?void 0:Ve.title)||re.title;return h(je).includes(xe)||(re.subItems||[]).some(Ye=>h(Ye).includes(xe))})},[C.rows,m,b,_,h]),R=x?N:N.slice(0,En),A=g.useMemo(()=>(z?C.rows:R).filter(P=>P.id&&!_.has(P.id)).map(P=>P.id),[z,C.rows,R,_]);g.useEffect(()=>{if(!i||A.length===0)return;let P=!1;const xe=A.slice(0,fy);return Oi(xe,Wi,re=>i.getItem(re).then(je=>{var Ye,et;const Se=je??{},Ve={title:Se.title,edition:Se.edition,authors:Se.authors,measure:je?Ht(je,u.unit.juan):void 0,versionCount:Se._edition_count??((Ye=Se._books)==null?void 0:Ye.length),l1:((et=ho(Se))==null?void 0:et.l1)||void 0};return[re,Ve]}).catch(()=>[re,{}]),()=>P).then(re=>{P||L(je=>{const Se=new Map(je);for(const[Ve,Ye]of re)Se.set(Ve,Ye);return Se})}),()=>{P=!0}},[i,A,u.unit.juan]);const J=(se=(e.contained_in||[])[0])==null?void 0:se.id;g.useEffect(()=>{if(!J){$(null);return}if($({id:J}),!i)return;let P=!1;return i.getItem(J).then(xe=>{P||$({id:J,title:xe==null?void 0:xe.title})}).catch(()=>{}),()=>{P=!0}},[i,J]);const ee=g.useMemo(()=>bd(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),oe=ee.text.length+ee.groups.reduce((P,xe)=>P+xe.rows.length+xe.mirrors.length,0),V=S.works,me=new Set(C.rows.map(P=>P.id).filter(Boolean)),G=V.length>0&&!V.every(P=>me.has(P.id)),q=(()=>{const P=C.rows.map(xe=>xe.edition).filter(Boolean);return P.length>1&&new Set(P).size===1})(),ce=C.rows.some(P=>P.volumes.length>0||P.expected!=null),we=S.total,O=S.truncated?we:C.rows.length,ye=Ht(e,u.unit.juan),de=e.count,ze=P=>typeof P=="number"&&Number.isFinite(P)?P:null,Ce=ze(de==null?void 0:de.juan)??ze((Te=e.juan_count)==null?void 0:Te.number),Oe=ze(de==null?void 0:de.ce)??(C.totalVolumes||null),ne=[{value:O,label:p("collectionPage.stat.titles")},{value:Ce??0,label:u.unit.juan},{value:Oe??0,label:u.unit.volume}],W=g.useMemo(()=>{var re,je;const P=[];if((re=e.publication_info)!=null&&re.details&&P.push({label:p("collectionPage.fact.publication"),value:h(e.publication_info.details)}),we&&(we!==C.rows.length||S.truncated)){const Se=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");P.push({label:Se,value:`${we} ${u.unit.bu}`,title:p("collectionPage.memberNote")})}const xe=[ze(de==null?void 0:de.zhong)!=null?p("collectionPage.nZhong",{n:de.zhong}):"",ze(de==null?void 0:de.han)!=null?p("collectionPage.nHan",{n:de.han}):""].filter(Boolean);return xe.length&&P.push({label:p("collectionPage.fact.expected"),value:xe.join(" ")}),Ce==null&&ye&&P.push({label:p("collectionPage.fact.measure"),value:h(ye),title:(je=e.juan_count)!=null&&je.description?h(e.juan_count.description):void 0}),P},[e,we,S.truncated,C.rows.length,Ce,ye,de,h,p,u]),U=g.useMemo(()=>{if(!M)return[];const P=new Map;for(const re of C.rows){const je=H(re.id);je&&P.set(je,(P.get(je)??0)+1)}const xe=Bn.filter(re=>(P.get(re.key)??0)>0);return xe.length<2?[]:[{key:"",label:`${u.catalog.all} ${O}`},...xe.map(re=>({key:re.key,label:`${re.label} ${P.get(re.key)}`}))]},[M,C.rows,_,u]),he=g.useMemo(()=>{if(!M||!C.rows.some(je=>je.volumes.length>0))return null;const P=[],xe=C.rows.filter(je=>je.volumes.length>0).map(je=>({k:H(je.id)??"",from:Math.min(...je.volumes),to:Math.max(...je.volumes)})).sort((je,Se)=>je.from-Se.from);for(const je of xe){const Se=je.to-je.from+1,Ve=P[P.length-1];Ve&&Ve.key===je.k?(Ve.to=Math.max(Ve.to,je.to),Ve.n+=Se):P.push({key:je.k,from:je.from,to:je.to,n:Se})}const re=xe.reduce((je,Se)=>Math.max(je,Se.to),0);return P.length>1&&P.some(je=>je.key)?{segs:P,last:re}:null},[M,C.rows,_]),K=(Me=e.description)==null?void 0:Me.text,B=t.jsx(Dn,{kind:p("collectionPage.kind"),title:h(e.title),byline:t.jsx(Ho,{authors:e.authors,onNavigate:o,renderLink:s}),meta:t.jsx(at,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(Le=e.publication_info)!=null&&Le.year?h(e.publication_info.year):""]}),description:K||(F=e.history)!=null&&F.length?t.jsxs(t.Fragment,{children:[K&&t.jsx(Ft,{text:K,style:{fontSize:15,lineHeight:1.85}}),(ae=e.history)!=null&&ae.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((P,xe)=>t.jsx("li",{children:h(P)},xe))}):null]}):void 0,clampDescription:xo(K)||(((fe=e.history)==null?void 0:fe.length)??0)>2?6:void 0,stats:ne,facts:W,foot:t.jsx(Un,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:he&&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:he.segs.map((P,xe)=>{const re=Bn.find(je=>je.key===P.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!re,title:re?p("collectionPage.dist.segTitle",{section:h(re.label),from:P.from,to:P.to}):void 0,"aria-label":re?p("collectionPage.dist.only",{section:h(re.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!re&&b===P.key,style:{flexGrow:P.n,background:r(re?re.token:"rule")},onClick:()=>{re&&(w(b===P.key?"":P.key),k(!1))}},xe)})}),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:he.last})})]})]})}),Q=[];C.rows.length&&Q.push({id:"titles",label:p("collectionPage.sec.titles"),count:O}),oe&&Q.push({id:"resources",label:p("collectionPage.sec.resources"),count:oe}),G&&Q.push({id:"works",label:u.section.containedWorks,count:V.length});const le=t.jsxs(t.Fragment,{children:[C.rows.length>0&&t.jsxs(lt,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(at,{items:[`${O} ${u.unit.items}`,C.totalVolumes?p("collectionPage.totalVolumes",{n:C.totalVolumes,unit:u.unit.volume}):"",N.length!==O?p("collectionPage.currentN",{n:N.length,unit:u.unit.items}):""]}),action:a,children:[(C.rows.length>En||U.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[U.length>0&&t.jsx(Ai,{items:U,value:b,onChange:P=>{w(P),k(!1)}}),T&&C.rows.length>En&&!M&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:v,onClick:()=>j(!0),title:p("collectionPage.loadAllTitle",{n:C.rows.length,unit:u.unit.items}),children:p(v?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),C.rows.length>En&&t.jsx("input",{type:"search",className:"bim-d-find",value:m,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:P=>{f(P.target.value),k(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Mi(N.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[ce&&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((P,xe)=>{var Ze;const re=P.id?_.get(P.id):void 0,je=re!=null&&re.title&&P.title===P.id?re.title:P.title,Se=((re==null?void 0:re.authors)||[]).find(I=>I&&I.name),Ve=[Se?`${Se.dynasty?`〔${h(Se.dynasty)}〕`:""}${h(Se.name)}${Se.role?` ${h(Se.role)}`:""}`:"",re!=null&&re.measure?h(re.measure):"",(Ze=P.subItems)!=null&&Ze.length?P.subItems.map(I=>h(I)).join("、"):"",(re!=null&&re.edition||P.edition)&&!q?h((re==null?void 0:re.edition)||P.edition||""):""].filter(Boolean),Ye=Bn.find(I=>I.key===H(P.id)),et=P.volumes.length>0?p("collectionPage.volumeRange",{range:Li(P.volumes,u.unit.volume),unit:u.unit.volume}):P.expected!=null?`${P.found??0}/${P.expected} ${u.unit.volume}`:"";return t.jsxs("tr",{children:[ce&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${et?"":" bim-d-zt-blank"}`,children:[Ye&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:r(Ye.token)}}),et||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[P.id?t.jsx(it,{id:P.id,label:h(je),onNavigate:o,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:h(je)}),Ve.length>0?t.jsx(at,{items:Ve}):P.id&&!re&&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${re!=null&&re.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:re!=null&&re.versionCount?p("collectionPage.nZhong",{n:re.versionCount}):""})]},`${P.id??P.title}-${xe}`)})})]}),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(go,{total:N.length,shown:R.length,unit:u.unit.items,onClick:()=>k(!0)})]}),oe>0&&t.jsxs(lt,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:oe}),children:[ee.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[ee.groups.length>0&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:p("collectionPage.text")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:ee.text.map((P,xe)=>t.jsx(Do,{item:P,siblings:ee.text},`${P.id||P.url||P.name}-${xe}`))})})]}),t.jsx(jd,{groups:ee.groups})]}),C.rows.length===0&&oe===0&&t.jsx(lt,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),ie=G?t.jsx(rn,{id:"works",title:u.section.containedWorks,meta:p("collectionPage.nZhong",{n:V.length}),cap:12,items:V.map(P=>t.jsx(it,{id:P.id,label:h(P.title),onNavigate:o,renderLink:s,dense:!0}))}):null,D=y?t.jsx(uc,{caption:p("collectionPage.parent"),children:t.jsx(it,{id:y.id,label:h(y.title||y.id),onNavigate:o,renderLink:s,dense:!0})}):void 0;return t.jsx(Hn,{railTop:l,back:d,up:D,nav:Q,railLinks:c,main:le,card:B,side:ie})},xy=8;function Cd(e){return typeof e!="string"||!e||e.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.split("/").some(n=>n==="..")?null:e}function by(e){return(e||[]).filter(n=>{var i,o;return Cd(n==null?void 0:n.file)&&((i=n.credit)==null?void 0:i.trim())&&((o=n.license)==null?void 0:o.trim())}).slice(0,xy)}function yy({images:e,assetBase:n,name:i}){const{t:o,convert:s}=te(),[a,l]=g.useState(0),[d,c]=g.useState(!1),p=n?by(e):[];if(!n||d||p.length===0)return null;const h=n.endsWith("/")?n:n+"/",u=p[Math.min(a,p.length-1)],m=u.width&&u.height&&u.width>0&&u.height>0?`${u.width} / ${u.height}`:void 0,f=x=>h+Cd(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(u),alt:o("entityPage.sealAlt",{name:i})+(p.length>1?` ${a+1}`:""),style:m?{"--seal-ar":m}:void 0,width:u.width,height:u.height,decoding:"async",fetchPriority:"high",onError:()=>c(!0)},u.file),p.length>1&&t.jsx("div",{className:"bim-d-seal-thumbs",children:p.map((x,k)=>t.jsx("button",{type:"button","aria-pressed":k===a,"aria-label":`${o("entityPage.sealAlt",{name:i})} ${k+1}`,onClick:()=>l(k),children:t.jsx("img",{src:f(x),alt:"",loading:"lazy",decoding:"async"})},x.file))}),t.jsxs("figcaption",{children:[o("entityPage.imgCredit",{credit:s(u.credit)})," · ",o("entityPage.imgLicense",{license:s(u.license)}),u.source_url&&/^https?:\/\//i.test(u.source_url)&&t.jsxs(t.Fragment,{children:[" · ",t.jsx("a",{href:u.source_url,target:"_blank",rel:"noopener noreferrer nofollow",children:o("entityPage.imgSource")})]}),u.note&&t.jsxs(t.Fragment,{children:[" · ",s(u.note)]})]})]})}const jy=16,yr=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function qa(e){if(!e)return yr.length;const n=yr.indexOf(e);return n===-1?yr.length:n}function vy(e,n,i){if(n)return e[n]??i(n)}function ky(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const wy={秦:[-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]},zd=({data:e,transport:n,onNavigate:i,renderLink:o,railTop:s,back:a,railLinks:l,assetBase:d})=>{var D,se,Te,Me,Le;const{t:c,convert:p,messages:h}=te(),u=F=>ky(F,c),[m,f]=g.useState("全部"),[x,k]=g.useState(!1),[y,$]=g.useState("default"),[b,w]=g.useState(new Map),v=g.useMemo(()=>e._works||[],[e._works]),j=g.useMemo(()=>v.map(F=>{const ae=b.get(F.work_id);return{id:F.work_id,title:(ae==null?void 0:ae.title)??F.title??F.work_id,role:F.role||"",cls:po(F.role),versionCount:ae==null?void 0:ae.versionCount,section:ae==null?void 0:ae.cls,l1:ae==null?void 0:ae.l1,measure:ae==null?void 0:ae.measure,hasImage:ae==null?void 0:ae.hasImage,loaded:!!(ae!=null&&ae.loaded)}}),[v,b]),C=g.useMemo(()=>ic(v.map(F=>F.role),c("detail.roleAll")),[v,c]),S=g.useMemo(()=>{const F=m==="全部"?j:j.filter(ae=>ae.cls===m);return y==="versions"?[...F].sort((ae,fe)=>(fe.versionCount??-1)-(ae.versionCount??-1)):F},[j,m,y]),_=x?S:S.slice(0,jy),L=g.useMemo(()=>_.filter(F=>!b.has(F.id)).map(F=>F.id),[_,b]);g.useEffect(()=>{if(!n||L.length===0)return;let F=!1;return Oi(L,Wi,ae=>n.getItem(ae).then(fe=>{var Se;const P=fe??{},xe=P._edition_count??((Se=P._books)==null?void 0:Se.length)??0,re=ho(P),je=[re==null?void 0:re.l1,re==null?void 0:re.l2].filter(Boolean).join(" ");return[ae,{id:ae,title:P.title,versionCount:xe,loaded:!0,cls:je||void 0,l1:(re==null?void 0:re.l1)||void 0,measure:fe&&Ht(fe,h.unit.juan)||void 0,hasImage:!!P._has_image}]}).catch(()=>[ae,{id:ae,loaded:!0}]),()=>F).then(ae=>{F||w(fe=>{const P=new Map(fe);for(const[xe,re]of ae)P.set(xe,re);return P})}),()=>{F=!0}},[n,L,h.unit.juan]);const T=g.useMemo(()=>{const F=new Map;for(const ae of e.alt_names||[]){const fe=ae.type||h.section.aliases;F.has(fe)||F.set(fe,[]),F.get(fe).push(ae.name)}return[...F.entries()].sort((ae,fe)=>qa(ae[0])-qa(fe[0])).map(([ae,fe])=>({label:ae,names:fe}))},[e.alt_names,h]),z=((D=e.dates)==null?void 0:D.birth)??void 0,M=((se=e.dates)==null?void 0:se.death)??void 0,H=(Te=e.dates)==null?void 0:Te.floruit,N=z!=null||M!=null?`${u(z)||"?"}—${u(M)||"?"}`:Array.isArray(H)&&H.length===2&&H.every(F=>Number.isFinite(F))?c("entityPage.floruit",{from:u(H[0]),to:u(H[1])}):"",R=new Set(["本名","字","號","号"]),A=T.filter(F=>R.has(F.label)),J=T.filter(F=>!R.has(F.label)),ee=J.reduce((F,ae)=>F+ae.names.length,0),oe=g.useMemo(()=>{const F=[];for(const fe of A)F.push({label:fe.label,value:fe.names.map(P=>p(P)).join("、")});const ae=v.length;return ae&&F.push({label:c("entityPage.fact.works"),value:c("entityPage.nZhong",{n:ae})}),F},[v,A,p,c]),V=F=>{var ae;return(ae=T.find(fe=>F.includes(fe.label)))==null?void 0:ae.names[0]},me=V(["字"]),G=V(["號","号"]),q=[me?c("entityPage.zi",{name:p(me)}):"",G?c("entityPage.hao",{name:p(G)}):""].filter(Boolean).join(","),ce=e.native_place,we=e.dynasty?wy[e.dynasty]:void 0,O=(()=>{if(!we||z==null||M==null||M<z)return null;const[F,ae]=we,fe=Math.max(z,F),P=Math.min(M,ae);if(P<=fe)return null;const xe=ae-F;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:u(z),death:u(M),years:M-z+1}),children:t.jsx("i",{style:{left:`${(fe-F)/xe*100}%`,width:`${(P-fe)/xe*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${u(F)} ${p(e.dynasty)}`}),t.jsx("span",{children:c("entityPage.lifeYears",{years:M-z+1})}),t.jsx("span",{children:u(ae)})]})]})})(),ye=g.useMemo(()=>{if(!n||j.length===0||j.some(fe=>!fe.loaded))return null;const F=new Map;for(const fe of j){const P=Dr(fe.l1);P&&F.set(P,(F.get(P)??0)+1)}const ae=Bn.map(fe=>({...fe,n:F.get(fe.key)??0})).filter(fe=>fe.n>0);return ae.length?ae:null},[j,n]),de=t.jsxs(Dn,{kind:vy(h.entityPage.subtype,e.subtype,p),title:p(e.primary_name||e.title),subtitle:q||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(at,{items:[e.dynasty?p(e.dynasty):"",N,ce?c("entityPage.nativePlace",{place:p(ce)}):""]}),O,t.jsx(yy,{images:e.images,assetBase:d,name:p(e.primary_name||e.title)})]}),description:(Me=e.description)!=null&&Me.text?t.jsx(Ft,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:xo((Le=e.description)==null?void 0:Le.text)?6:void 0,facts:oe,foot:t.jsx(Un,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[ee>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:c("entityPage.moreNames",{n:ee})}),t.jsx("dl",{children:J.map(F=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:p(F.label)}),t.jsx("dd",{children:F.names.map(ae=>p(ae)).join("、")})]},F.label))})]}),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:c("entityPage.dist")})}),t.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:ye.map(F=>t.jsx("i",{style:{flexGrow:F.n,background:r(F.token)}},F.key))}),t.jsx("div",{className:"bim-d-dist-key",children:ye.map(F=>t.jsxs("span",{children:[t.jsx("i",{style:{background:r(F.token)}}),p(F.label)," ",F.n]},F.key))})]})]}),ze=g.useMemo(()=>j.filter(F=>F.loaded&&(F.versionCount??0)>0).sort((F,ae)=>(ae.versionCount??0)-(F.versionCount??0)).slice(0,3),[j]),Ce=!!n&&j.length>=3&&_.some(F=>!F.loaded),Oe=m==="全部"&&(Ce||ze.length>=2),ne=e.external_ids||{},W=[];ne.cbdb_id!=null&&W.push({label:"CBDB",id:String(ne.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${ne.cbdb_id}`,note:ne.cbdb_match==="auto"?c("entityPage.autoMatch"):void 0});const U=ne.wikidata_id;U&&W.push({label:"Wikidata",id:U,href:`https://www.wikidata.org/wiki/${U}`});const he=ne.viaf_id;he&&W.push({label:"VIAF",id:he,href:`https://viaf.org/viaf/${he}`});const K=C.map(F=>({key:F.cls,label:`${F.label} ${F.count}`})),B=[...Oe&&!Ce?[{id:"featured",label:c("entityPage.sec.featured"),count:ze.length}]:[],...j.length?[{id:"works",label:c("entityPage.sec.allWorks"),count:j.length}]:[],...W.length?[{id:"external",label:c("entityPage.sec.external"),count:W.length}]:[]],Q=Oe?t.jsxs(lt,{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":Ce||void 0,children:[Ce&&[0,1,2].map(F=>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:" "})]},F)),!Ce&&ze.map(F=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(it,{id:F.id,label:p(F.title),onNavigate:i,renderLink:o,dense:!0})}),t.jsx(at,{items:[F.section?p(F.section):"",F.measure?p(F.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:F.versionCount}),t.jsx("span",{children:c("entityPage.versionsUnit")}),F.hasImage&&t.jsx("span",{className:"bim-d-flag",children:c("entityPage.hasImage")})]})]},F.id))]})]}):null,le=j.length===0?t.jsx(lt,{title:c("entityPage.sec.works"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("entityPage.empty")})}):t.jsxs(t.Fragment,{children:[Q,t.jsxs(lt,{id:"works",title:c("entityPage.sec.works"),meta:t.jsx(at,{items:[c("entityPage.total",{n:j.length}),S.length!==j.length?c("entityPage.current",{n:S.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[K.length>1&&t.jsx(Ai,{items:K,value:m,onChange:F=>{f(F),k(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":y==="versions",onClick:()=>{y==="default"&&k(!0),$(F=>F==="default"?"versions":"default")},children:c(y==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Mi(S.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:_.map(F=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(it,{id:F.id,label:p(F.title),onNavigate:i,renderLink:o,dense:!0}),F.measure?t.jsx(at,{items:[p(F.measure)]}):!F.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${F.section||F.loaded?"":" bim-d-zt-blank"}`,children:F.section?p(F.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${F.role?"":" bim-d-zt-blank"}`,children:F.role?p(F.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${F.loaded?"":" bim-d-zt-blank"}`,children:F.loaded?F.versionCount?c("entityPage.nZhong",{n:F.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:c("entityPage.notRecorded")}):""}),t.jsx("td",{className:F.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:F.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:c("entityPage.hasImage")})})]},F.id))})]}),_.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c("entityPage.emptyRole")}),!x&&t.jsx(go,{total:S.length,shown:_.length,unit:c("entityPage.moreUnit"),onClick:()=>k(!0)})]})]}),ie=W.length>0?t.jsx(rn,{id:"external",title:c("entityPage.sec.external"),items:W.map(F=>t.jsxs("a",{href:F.href,target:"_blank",rel:"noopener noreferrer",children:[F.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:W.map(F=>F.id),foot:ne.cbdb_id!=null&&ne.cbdb_match==="auto"?c("entityPage.cbdbAuto"):void 0}):null;return t.jsx(Hn,{railTop:s,back:a,nav:B,railLinks:l,main:le,card:de,side:ie})},Vo="(max-width: 719px)",Sy=`${Vo}, (pointer: coarse)`,Td=`
1368
+ ${ge??""}`,[Qe,$t]=g.useState({key:De,data:Y,started:!!Y});if(Qe.key!==De)$t({key:De,data:Y,started:!1});else if(Y!==Qe.data&&($t({key:De,data:Y,started:!!Y}),Y)){const E=Y.pages??[];(!Qe.started||!E.some(ue=>ue.page===Ge))&&J(jt(Y))}g.useEffect(()=>{Z(new Set),We(null)},[ge,O]);const _p=g.useCallback(E=>{if(Z(new Set(E)),E.length>0){const ue=E[0],Ne=parseInt(ue.split(":")[0],10);isNaN(Ne)||J(Ne)}},[]),Rt=g.useMemo(()=>{const E=new Map;for(const ue of(Y==null?void 0:Y.pages)??[])E.set(ue.page,ue);return E},[Y]),wn=Et(Y),qn=g.useCallback(E=>{var Ue;const ue=N.images;if(!ue||ue.length===0)return;const Ne=(Ue=Rt.get(E))==null?void 0:Ue.seq;return(Ne?ue.find(nt=>nt.seq===Ne):void 0)??ue.find(nt=>nt.pageNo===E)??ue[E-1]},[N.images,Rt]),ts=$e>1.5,Kn=g.useCallback((E,ue=!1)=>{const Ne=qn(E);return Ne?E===wn||ue?Ne.hiresUrl??Ne.url:Ne.url:E===wn?(Y==null?void 0:Y.imageUrl)??"":""},[qn,Y,wn]),$p=g.useMemo(()=>Kn(Ge,ts),[Kn,Ge,ts]),Lt=g.useMemo(()=>[...Rt.keys()].sort((E,ue)=>E-ue),[Rt]),Xn=g.useRef(Ge);Xn.current=Ge;const ns=g.useRef(0),Zn=g.useCallback(E=>{var ue;Xn.current===E||!Rt.has(E)||(ns.current=Date.now()+1e3,Xn.current=E,J(E),(ue=Rt.get(E))!=null&&ue.columns.some(Ne=>Ne.chars.length>0)&&ot(Ne=>({page:E,nonce:((Ne==null?void 0:Ne.nonce)??0)+1})))},[Rt]),Sn=g.useCallback(E=>{const ue=Xn.current,Ne=Lt.indexOf(ue),Ue=Lt[Ne<0?0:Ne+E];Ue===void 0||Ue===ue||Zn(Ue)},[Lt,Zn]),is=g.useCallback(E=>{if(!E.trim().match(/^\d+$/)||Lt.length===0)return null;const Ne=parseInt(E.trim(),10),Ue=Number.isFinite(Ne)?Ne:Number.MAX_SAFE_INTEGER;return Lt.reduce((nt,wt)=>Math.abs(wt-Ue)<Math.abs(nt-Ue)?wt:nt,Lt[0])},[Lt]),[qi,Ki]=g.useState(null),Jn=g.useRef(null),Cp=g.useCallback(E=>{Jn.current=E,Ki(E)},[]),rs=g.useCallback(()=>{const E=Jn.current;if(Jn.current=null,Ki(null),E===null)return;const ue=is(E);ue!==null&&Zn(ue)},[is,Zn]),Xi=Lt.indexOf(Ge),zp=g.useCallback(E=>{if(E.altKey||E.ctrlKey||E.metaKey)return;const ue=E.target.tagName;ue==="INPUT"||ue==="TEXTAREA"||ue==="SELECT"||(E.key==="ArrowLeft"||E.key==="PageUp"?(E.preventDefault(),Sn(-1)):(E.key==="ArrowRight"||E.key==="PageDown")&&(E.preventDefault(),Sn(1)))},[Sn]);g.useEffect(()=>{if(Y)for(const E of[1,-1,2,3]){const ue=Kn(Ge+E);ue&&Pr(ue)}},[Y,Ge,Kn]);const os=g.useMemo(()=>{var fs;if(!Y)return null;if(Ge===wn)return Y;const E=Rt.get(Ge);if(E&&E.width>0&&E.height>0)return{page_id:`p:${Ge}`,title:`第${Ge}葉`,image_size:[E.width,E.height],total_warped_w:E.width,columns:[{col:1,warped_w:E.width,warped_h:E.height,offset_x:0,strips:[],chars:E.columns.flatMap(Xe=>Xe.chars).map(Xe=>({id:Xe.id,char:Xe.char,slot:Xe.slot,pos:Xe.pos,sub:Xe.sub,bbox_col:Xe.bbox??[0,0,0,0]}))}]};const ue=(fs=Y.pages)==null?void 0:fs.find(Xe=>Xe.page===Ge),[Ne,Ue]=Y.image_size||[2386,3082],nt=qn(Ge),wt=(nt==null?void 0:nt.width)??Ne,tr=(nt==null?void 0:nt.height)??Ue,ms=wt/Ne,hs=tr/Ue,gs=new Map;for(const Xe of Y.columns){const ft=(Xe.strips||[]).flatMap(ii=>ii.srcQuad.map(ri=>ri[0]));if(ft.length===0)continue;const At=Xe.top_y??0,nr=Xe.bottom_y??At+Xe.warped_h;gs.set(Xe.col,{x0:Math.min(...ft),x1:Math.max(...ft),top:At,slotH:(nr-At)/21})}return{page_id:`p:${Ge}`,title:`第${Ge}葉`,image_size:[wt,tr],total_warped_w:wt,columns:ue?ue.columns.map(Xe=>{const ft=gs.get(Xe.col)??{x0:0,x1:0,top:0,slotH:118};return{col:Xe.col,warped_w:wt,warped_h:tr,offset_x:0,strips:[],chars:Xe.chars.map(At=>{const nr=At.slot??At.pos??0,ii=(ft.top+(nr-1)*ft.slotH)*hs,ri=(ft.x0+ft.x1)/2,[Pp,Bp]=At.sub==="a"?[ri,ft.x1]:At.sub==="b"?[ft.x0,ri]:[ft.x0,ft.x1];return{...At,bbox_col:[Pp*ms,ii,Bp*ms,ii+ft.slotH*hs]}})}}):[]}},[Y,Ge,wn,Rt,qn]),{entryTitle:Qn,authors:ss}=tx(n,i,d===void 0),[as,Zi]=g.useState("text");if(g.useEffect(()=>{Zi("text")},[ge,O]),P==="loading")return t.jsx(fa,{className:j,style:C,title:d??Qn,label:S("reader.loading")});if(P==="missing"||!I||!ae)return t.jsx("div",{className:j,style:{...C,...ga},children:S("reader.noText")});if(B==="failed")return t.jsx("div",{className:j,style:{...C,...ga},children:S("reader.tocFailed")});if(!X)return t.jsx(fa,{className:j,style:C,title:d??Qn,label:S("reader.tocLoading")});const Xt=Xf(ae,X),Tp=Zf(X,Ye,Xt,_,L),Ji=I.versions.map(E=>({key:E.key,label:ke.textVersionLabel(E),optionLabel:_(ke.textVersionLabel(E)),sourceName:ba(E)?S("reader.originalSource"):E.source_name?_(E.source_name):void 0,license:E.license??void 0,sourceUrl:E.source_url??void 0,primary:E.key===Se})),gt=qf((us=X.source)==null?void 0:us.upstream),ei=(typeof d=="string"?_(d):d)??(X.title?_(X.title):Qn?_(Qn):void 0),ls=ae.edition_label?_(ae.edition_label):void 0,Qi=ei?t.jsx("a",{href:M(n),title:S("reader.viewEntry"),onClick:l?E=>{E.metaKey||E.ctrlKey||(E.preventDefault(),l(n))}:void 0,children:ei}):void 0,Np=Qi&&ls?t.jsxs(t.Fragment,{children:[Qi,t.jsxs("span",{className:"bim-rd-ed",children:["·",ls]})]}):Qi,Ip=ss.length>0?_(ss.slice(0,2).map(E=>`${E.dynasty?`〔${E.dynasty}〕`:""}${E.name}${` ${E.role||S("reader.defaultRole")}`}`).join("、")):void 0,er=W?Zc(W,Xt,_,L):void 0,Zt=L&&!!(Q!=null&&Q.json),Jt=(Q==null?void 0:Q.json)??null,ln=(Q==null?void 0:Q.md)??null,cs=Zt&&!_e&&Dc(Jt.sections),Ep=cs&&!(ln&&fe.readingMode==="paragraph"&&ji(ln)),Rp=Zt&&cs?t.jsx(jf,{juan:Jt,view:as,onView:Zi,textHasEntries:Ep}):void 0,Lp=!0,ti=ln?ln.replace(/^##\s+[^\n]+\n+/,""):null,ni=ba(ae),Dt=ni?S("reader.originalSource"):ae.source_name?_(ae.source_name):void 0,Ap=(typeof c=="string"?_(c):c)??(ni?void 0:Dt??_(ke.textVersionLabel(ae))),Mp=(Y==null?void 0:Y.hasNorm)===!0;return t.jsxs(Yl,{className:j,style:C,title:Np,subtitle:Ap,byline:Ip,current:er,pagerUnit:Xt,rail:Rp,revisedAt:x,backHref:k,backLabel:y,onReportError:f?E=>f({...E,bookTitle:typeof ei=="string"?ei:void 0,entryId:n}):void 0,workLinkToggle:Zt&&!_e&&!!l&&!!(Jt!=null&&Jt.sections.some(E=>E.work_id)),toc:Tp,tocCaption:S("reader.tocCaption",{n:X.chapters.length,unit:_(Xt)}),tocHeader:L&&X.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:_e?S("reader.searchChaptersPlaceholder"):S("reader.searchUnitPlaceholder",{unit:_(Xt)}),"aria-label":_e?S("reader.searchChapters"):S("reader.searchUnit",{unit:_(Xt)}),value:me,onChange:E=>oe(E.target.value)}):void 0,activeKey:ge??null,onSelect:D,images:N.images,renderImageOverlay:h,imagePanel:Y?"open":u,isWarpMode:!!Y,customImagePanel:Y&&os?t.jsxs("div",{className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:zp,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:[qe.size>0&&t.jsxs("button",{type:"button",onClick:()=>Z(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${r("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",qe.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:$e<=1,onClick:()=>{var E;return(E=Be.current)==null?void 0:E.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round($e*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:$e>=6,onClick:()=>{var E;return(E=Be.current)==null?void 0:E.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:$e===1,onClick:()=>{var E;return(E=Be.current)==null?void 0:E.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(Vf,{ref:Be,resetKey:Ge,onScaleChange:Je,style:{flex:1,minHeight:0},children:t.jsx(Lo,{imageUrl:$p,pageData:os,selectedCharIds:qe,hoveredCharId:ze,preserveMargins:xe,onCharClick:E=>{Z(Ne=>{const Ue=new Set(Ne);return Ue.has(E)?Ue.delete(E):(Ue.clear(),Ue.add(E)),Ue});const ue=document.querySelector(`[data-char-id="${E}"]`);ue&&ue.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:We})}),t.jsxs("div",{"data-testid":"facsimile-pager",role:"group","aria-label":S("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:Xi<=0,onClick:()=>Sn(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":Ge,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":S("reader.facsimilePageInput"),size:Math.max(2,String(qi??Ge).length),value:qi??String(Ge),onFocus:E=>E.currentTarget.select(),onChange:E=>Cp(E.target.value),onKeyDown:E=>{E.key==="Enter"?(E.preventDefault(),rs()):E.key==="Escape"&&(Jn.current=null,Ki(null)),E.stopPropagation()},onBlur:rs,style:{width:`${Math.max(2,String(qi??Ge).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:Xi<0||Xi>=Lt.length-1,onClick:()=>Sn(1),children:"›"})]})]}):void 0,settingsAnnotate:Y?t.jsx("button",{type:"button",className:`bim-rd-t bim-rd-sp-tg ${Oe?"bim-rd-on":""}`,"aria-pressed":Oe,title:"切换外挂现代断句标点",onClick:()=>Re(E=>!E),children:Oe?"标点":"无标点"}):void 0,prefs:fe,onPrefsChange:z,versions:Ji.length>1?Ji:void 0,currentVersionKey:Ji.length>1?ae.key:void 0,onVersionChange:q,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:ji(ln),allowVertical:m,origScriptAvailable:Mp,contentLoading:se,children:[(se||ce&&!Y&&!Zt&&ti==null)&&t.jsx(sn,{}),!se&&Y&&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:W!=null&&W.title?_(W.title):er}),(Dt||ae.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[Dt,ae.license&&t.jsxs(t.Fragment,{children:[Dt&&t.jsx("span",{className:"bim-rd-dot"}),ae.license]})]})]}),t.jsx(Bo,{pageData:Y,pages:Y.pages,punctuations:Y.punctuations||Yf,selectedCharIds:qe,hoveredCharId:ze,onSelectionChange:_p,onCharClick:E=>{Z(Ne=>{const Ue=new Set(Ne);return Ue.has(E)?Ue.delete(E):(Ue.clear(),Ue.add(E)),Ue});const ue=parseInt(E.split(":")[0],10);isNaN(ue)||J(ue)},onCharHover:We,mode:"horizontal",showPunctuation:Oe,entities:Me,entityTransport:i,onEntityNavigate:v,onVisiblePageChange:E=>{Date.now()>=ns.current&&J(E)},convert:_,scrollToPage:He,pageBreaks:fe.pageBreaks,pageIndicatorY:fe.pageIndicatorY,onPageIndicatorYChange:E=>z({pageIndicatorY:E}),quoteStyle:fe.quoteStyle,bookTitleStyle:fe.bookTitleStyle,showWorks:fe.showWorks})]}),!se&&!Y&&Zt&&Jt&&t.jsx(bf,{juan:Jt,rawText:ln,positionLabel:Qf(W,X,Xt,_),groupLabel:ex(X,ge??null),index:Kf(n,X),searchQuery:me,onNavigate:l,transport:i,workLabelCache:tt,prefs:fe,view:as,onViewChange:Zi},`${O}/${ge}`),!se&&!Y&&!Zt&&ti!=null&&W&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:W.title?_(W.title):er}),(Dt||ae.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[ni&&Dt&&t.jsx(t.Fragment,{children:Dt}),!ni&&ae.source_name&&t.jsxs(t.Fragment,{children:[S("reader.textSource")," ",ae.source_url?t.jsx("a",{className:"bim-rd-link",href:ae.source_url,target:"_blank",rel:"noreferrer",children:_(ae.source_name)}):_(ae.source_name)]}),Dt&&ae.license&&t.jsx("span",{className:"bim-rd-dot"}),ae.license]}),gt&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[S("reader.upstream")," ",gt.url?t.jsx("a",{className:"bim-rd-link",href:gt.url,target:"_blank",rel:"noreferrer",children:_(gt.name??gt.url)}):_(gt.name??""),gt.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),gt.license_url?t.jsx("a",{className:"bim-rd-link",href:gt.license_url,target:"_blank",rel:"noreferrer",children:gt.license}):gt.license]}),gt.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(Al,{text:gt.note,convert:_})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx($o,{text:ti,mode:fe.readingMode,tables:Lp,gujiMarkdown:!0,bookMarking:_o(fe),quoteStyle:fe.quoteStyle})})]}),!se&&!ce&&!Y&&!Zt&&ti==null&&W&&t.jsx("div",{className:"bim-rd-state",children:S("reader.chapterFailed")}),!se&&X.references&&X.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:S("reader.references")}),t.jsx("ol",{children:X.references.map((E,ue)=>t.jsxs("li",{children:[E.url?t.jsx("a",{className:"bim-rd-link",href:E.url,target:"_blank",rel:"noopener noreferrer",children:_(E.title)}):t.jsx("span",{children:_(E.title)}),E.author&&t.jsxs("span",{children:[",",_(E.author)]}),E.note&&t.jsxs("span",{children:["。",_(E.note)]})]},ue))})]})]})};function ba(e){return e.is_original===!0||e.source==="original"}function Qf(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 ex(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 tx(e,n,i){const[o,s]=g.useState({entryTitle:void 0,authors:[]});return g.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let a=!1;return Promise.resolve(n.getItem(e)).then(l=>{if(a||!l)return;const d=(l.authors??[]).filter(c=>c&&c.name);s({entryTitle:i&&typeof l.title=="string"?l.title:void 0,authors:d})}).catch(()=>{}),()=>{a=!0}},[e,n,i]),o}const Jc={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")}},nx=Jc.other,Qc={pending:{key:"pending",color:r("warning")},in_progress:{key:"in_progress",color:r("primary")},resolved:{key:"resolved",color:r("success")},wontfix:{key:"wontfix",color:r("desc-fg")},duplicate:{key:"duplicate",color:r("desc-fg")}},ix=Qc.pending;function rx(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 ox(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 Fo=({items:e,loading:n})=>{const i=rt(),{t:o,convert:s}=ne();return n?t.jsx(sn,{}):e.length===0?t.jsx("div",{style:sx,children:o("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=Jc[a.type]||nx,d=Qc[a.status]||ix,c=typeof window<"u"&&ox(a.pageUrl,window.location.href);return t.jsxs("div",{style:ax,children:[t.jsxs("div",{style:lx,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...ya,background:l.color},children:o(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...ya,background:d.color},children:o(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:cx,children:rx(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:dx,children:[a.resourceId&&t.jsx("a",{href:i(a.resourceId),style:mr,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:mr,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:mr,children:a.pageUrl}))]}),t.jsx("div",{style:px,children:s(a.content)}),a.reply&&t.jsxs("div",{style:ux,children:[t.jsx("div",{style:mx,children:o("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},sx={textAlign:"center",padding:"40px 0",color:r("desc-fg"),fontSize:"14px"},ax={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"16px"},lx={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},ya={fontSize:"12px",color:r("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},cx={fontSize:"12px",color:r("desc-fg")},dx={fontSize:"12px",marginBottom:"6px"},mr={color:r("primary"),textDecoration:"none",borderBottom:`1px dashed ${r("primary")}`},px={fontSize:"14px",lineHeight:"1.6",color:r("fg"),whiteSpace:"pre-wrap"},ux={marginTop:"12px",padding:"10px 12px",background:r("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:r("fg")},mx={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:r("primary")},Or=({transport:e,onNavigate:n,recommendedIds:i,activeTab:o,onTabChange:s,feedbackApiUrl:a})=>{const l=Ie(),[d,c]=g.useState(null),[p,h]=g.useState([]),[u,m]=g.useState("recommend"),[f,x]=g.useState([]),[k,y]=g.useState(!1),$=o??u,b=R=>{m(R),s==null||s(R)},[w,v]=g.useState(!0),[j,C]=g.useState(null),[S,_]=g.useState(null),[A,T]=g.useState(null);g.useEffect(()=>{let R=!1;if(e.getCounts)return e.getCounts().then(P=>{R||c({works:P.works,books:P.books,collections:P.collections})}).catch(()=>{}),()=>{R=!0}},[e]),g.useEffect(()=>{let R=!1;return(async()=>{if(i)return i;if(e.getRecommended)try{const K=await e.getRecommended();if(K!=null&&K.groups)return K.groups.flatMap(te=>te.items.map(ie=>({...ie,group:te.name})))}catch{}return[]})().then(async K=>{if(R)return;const te=K.filter(U=>U.id);if(te.length===0){v(!1);return}const ie=await Promise.all(te.map(async U=>{if(U.type)return{id:U.id,title:U.title,type:U.type,author:U.author,dynasty:U.dynasty,role:U.role,edition:U.edition,has_text:U.has_text,has_image:U.has_image,has_collated:U.has_collated,subtype:U.subtype,primary_name:U.primary_name,group:U.group,fallbackDescription:U.description};try{let pe=null;if(e.getEntry)pe=await e.getEntry(U.id);else{const G=await e.getItem(U.id);G&&(pe={id:U.id,title:G.title||U.id,type:G.type||"work"})}if(pe)return{...pe,group:U.group,fallbackDescription:U.description}}catch{}return{id:U.id,title:U.title,type:ke.extractType(U.id),group:U.group,fallbackDescription:U.description}}));R||(h(ie.filter(U=>U!==null)),v(!1))}),()=>{R=!0}},[e,i]);const z=g.useRef(!1),M=g.useRef(!1),H=g.useRef(!1);g.useEffect(()=>{if($!=="catalog"||z.current)return;const R=e.getCatalogProgress??e.getResourceProgress;if(!R)return;z.current=!0;let P=!1;return R.call(e).then(K=>{P||C(K)}).catch(()=>{z.current=!1}),()=>{P=!0}},[e,$]),g.useEffect(()=>{if($!=="collection"||M.current||!e.getCollectionProgress)return;M.current=!0;let R=!1;return e.getCollectionProgress().then(P=>{R||_(P)}).catch(()=>{M.current=!1}),()=>{R=!0}},[e,$]),g.useEffect(()=>{if($!=="site"||H.current||!e.getSiteProgress)return;H.current=!0;let R=!1;return e.getSiteProgress().then(P=>{R||T(P)}).catch(()=>{H.current=!1}),()=>{R=!0}},[e,$]),g.useEffect(()=>{if(!a||$!=="feedback")return;let R=!1;return y(!0),fetch(a).then(P=>P.json()).then(P=>{!R&&P.success&&x(P.items||[])}).catch(()=>{}).finally(()=>{R||y(!1)}),()=>{R=!0}},[a,$]);const I=R=>t.jsx(kn,{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(Tn,{label:l.home.recommendTab,active:$==="recommend",onClick:()=>b("recommend")}),t.jsx(Tn,{label:l.home.catalogTab,active:$==="catalog",onClick:()=>b("catalog")}),t.jsx(Tn,{label:l.home.collectionTab,active:$==="collection",onClick:()=>b("collection")}),t.jsx(Tn,{label:l.home.siteTab,active:$==="site",onClick:()=>b("site")}),a&&t.jsx(Tn,{label:l.home.feedbackTab,active:$==="feedback",onClick:()=>b("feedback")})]}),$==="recommend"&&t.jsx(hx,{recommended:p,loading:w,onNavigate:n,getIcon:I,t:l}),$==="catalog"&&t.jsx(ja,{progress:j,t:l,onNavigate:n}),$==="collection"&&t.jsx(ja,{progress:S,t:l,onNavigate:n}),$==="site"&&t.jsx(fx,{progress:A,t:l,totalWorks:(d==null?void 0:d.works)??0}),$==="feedback"&&a&&t.jsx(Fo,{items:f,loading:k})]})})},Tn=({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}),hx=({recommended:e,loading:n,onNavigate:i,getIcon:o,t:s})=>{const a=rt();if(n)return t.jsx(sn,{});if(e.length===0)return null;const l=new Map;for(const d of e){const c=d.group||s.home.recommendedBrowse;l.has(c)||l.set(c,[]),l.get(c).push(d)}return t.jsx(t.Fragment,{children:Array.from(l.entries()).map(([d,c])=>t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:d}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"8px"},children:c.map(p=>{const h=p.dynasty||p.author?`${p.dynasty?`〔${p.dynasty}〕`:""}${p.author||""}`:p.fallbackDescription;return t.jsxs("a",{href:a(p.id),onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),i==null||i(p.id))},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,cursor:"pointer",background:r("input-bg"),textDecoration:"none",color:"inherit"},children:[t.jsx("span",{style:{fontSize:"20px"},children:o(p.type)}),t.jsxs("div",{style:{minWidth:0},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[p.title,p.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:r("desc-fg"),marginLeft:"4px"},children:p.edition})]}),h&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h})]})]},p.id)})})]},d))})},ja=({progress:e,t:n,onNavigate:i})=>{if(!e)return t.jsx(sn,{});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(gx,{item:p,t:n,statusColor:l[d],onNavigate:i},p.id))})]},d)})})},gx=({item:e,t:n,statusColor:i,onNavigate:o})=>{const s=rt(),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})]})},fx=({progress:e,t:n,totalWorks:i})=>{if(!e)return t.jsx(sn,{});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(va,{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(va,{item:c,t:n,totalWorks:i},c.id))})]})]})},va=({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})]})},ka="(max-width: 768px)";function xx(){const[e,n]=g.useState(()=>typeof window>"u"?!1:window.matchMedia(ka).matches);return g.useEffect(()=>{const i=window.matchMedia(ka),o=s=>n(s.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),e}const bx=({transport:e,hideModeIndicator:n=!0,onEntryClick:i,recommendedIds:o,headerRight:s})=>{var M;const a=Ie(),{convert:l}=Pe(),d=xx(),[c,p]=g.useState(null),[h,u]=g.useState(null),[m,f]=g.useState(!1),[x,k]=g.useState("detail"),[y,$]=g.useState([]),[b,w]=g.useState(!1),v=g.useCallback(async H=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){$([]);return}w(!0);try{if(e.getCollectionCatalogs){const I=await e.getCollectionCatalogs(H);$(I||[])}else if(e.getCollectionCatalog){const I=await e.getCollectionCatalog(H);$(I?[{resource_id:"",data:I}]:[])}}catch{$([])}finally{w(!1)}},[e]),j=g.useCallback(async H=>{if(i){i(H);return}p(H),u(null),$([]),k("detail"),f(!0);try{const I=await e.getItem(H.id);I&&(u(I),I.type==="collection"&&v(H.id))}catch(I){console.error("加载详情失败:",I)}finally{f(!1)}},[e,i,v]),C=g.useCallback(async H=>{u(null),$([]),k("detail"),f(!0);try{const I=await e.getItem(H);I&&(u(I),p({id:H,title:I.title||H,type:I.type||"book"}),I.type==="collection"&&v(H))}catch(I){console.error("导航失败:",I)}finally{f(!1)}},[e,v]),S=typeof(h==null?void 0:h.text_count)=="number"&&h.text_count>0,_=(h==null?void 0:h.type)==="collection"&&(y.length>0||b)||(h==null?void 0:h.type)==="work"&&S,A=d&&(m||h),T=g.useCallback(()=>{p(null),u(null),$([]),k("detail")},[]),z=t.jsx(t.Fragment,{children:m?t.jsx(sn,{}):h?t.jsxs(t.Fragment,{children:[(_||s)&&t.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${r("widget-border")}`,padding:d?"0 12px":"0 48px",background:r("input-bg"),flexShrink:0,overflowX:d?"auto":void 0},children:[_&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>k("detail"),style:di(x==="detail"),children:a.detailTab.basicInfo}),h.type==="collection"&&b&&y.length===0&&t.jsxs("button",{onClick:()=>{},style:di(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),h.type==="collection"&&y.map(H=>t.jsx("button",{onClick:()=>k(`catalog:${H.resource_id}`),style:di(x===`catalog:${H.resource_id}`),children:H.short_name?`${l(H.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},H.resource_id)),h.type==="work"&&S&&t.jsx("button",{onClick:()=>k("collated"),style:di(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(ro,{data:h,transport:e,onNavigate:C}):x.startsWith("catalog:")?t.jsx(oo,{data:(M=y.find(H=>`catalog:${H.resource_id}`===x))==null?void 0:M.data,onNavigate:C}):x==="collated"?t.jsx(Wo,{id:h.id,transport:e,onNavigate:C}):null})]}):t.jsx(Or,{transport:e,onNavigate:C,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:A?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:T,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:z})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(Sr,{transport:e,onEntryClick:j,hideModeIndicator:n}),!h&&t.jsx(Or,{transport:e,onNavigate:C,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(Sr,{transport:e,onEntryClick:j,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:r("bg"),display:"flex",flexDirection:"column"},children:z})]})};function di(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 yx=({pageData:e,rawImageUrl:n="",punctuations:i=[],title:o,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=g.useState(new Set),[h,u]=g.useState(null),[m,f]=g.useState("horizontal"),[x,k]=g.useState(!0),y=g.useRef(null),$=g.useCallback(j=>{p(new Set(j))},[]),b=g.useCallback(j=>{if(p(C=>{const S=new Set(C);return S.has(j)?S.delete(j):(S.clear(),S.add(j)),S}),y.current){const C=y.current.querySelector(`[data-char-id="${j}"]`);C&&C.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),w=()=>{var j;p(new Set),window.getSelection&&((j=window.getSelection())==null||j.removeAllRanges())},v=i.length>0?i:e.punctuations||[];return t.jsxs("div",{className:`guji-reader-container ${l}`,style:d,children:[t.jsxs("header",{className:"guji-reader-header",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a&&t.jsx("button",{type:"button",onClick:a,className:"guji-reader-btn",style:{marginRight:6},children:"‹ 返回"}),t.jsx("span",{className:"guji-reader-title",children:o||e.title}),s&&t.jsx("span",{style:{fontSize:"0.85rem",color:r("meta-fg")},children:s}),t.jsx("span",{className:"guji-reader-tag",children:"WebGL 客户端透视矫正对读"})]}),t.jsxs("div",{className:"guji-reader-actions",children:[t.jsxs("span",{style:{fontSize:"0.85rem",color:r("body-fg")},children:["已选字数: ",t.jsx("strong",{style:{color:r("accent")},children:c.size})]}),c.size>0&&t.jsx("button",{type:"button",onClick:w,className:"guji-reader-btn",children:"清除选中"}),t.jsx("button",{type:"button",onClick:()=>k(j=>!j),className:`guji-reader-btn ${x?"active":""}`,title:"独立外挂标点 (guji-punct v0.1)",children:x?"✓ 标点":"底本文本"}),t.jsx("button",{type:"button",onClick:()=>f(j=>j==="horizontal"?"vertical":"horizontal"),className:"guji-reader-btn primary",children:m==="horizontal"?"切换竖排":"切换横排"})]})]}),t.jsxs("div",{className:"guji-reader-body",children:[t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%",position:"sticky",top:0},children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:"底本书影 (WebGL 分带透视矫正 + 完整版心)"}),t.jsx("span",{className:"guji-pane-hint",children:"点击字框可联动文本定位"})]}),t.jsx("div",{className:"guji-pane-content",children:t.jsx(Lo,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:h,onCharClick:b,onCharHover:u})})]}),t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%"},ref:y,children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:m==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(Bo,{pageData:e,punctuations:v,selectedCharIds:c,hoveredCharId:h,onSelectionChange:$,onCharClick:b,onCharHover:u,mode:m,showPunctuation:x})]})]})]})},jx=e=>typeof e=="string"&&Array.from(e).length===1;function vx(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.punctuations)?e.punctuations:[],i=[];for(const o of n){if(!o||typeof o!="object")continue;const s=o;typeof s.anchor!="string"||typeof s.mark!="string"||s.pre_char!=null&&!jx(s.pre_char)||i.push({id:typeof s.id=="string"?s.id:void 0,anchor:s.anchor,mark:s.mark,kind:s.kind,pos:s.pos,pre_char:s.pre_char??void 0})}return i}function kx(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 ed=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function ct(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}const wx=new Set(["main","solo","jz_r","jz_l"]),Sx=new Set(["body","banxin","blank"]);function _x(e){const n={};return typeof e.lane=="string"&&wx.has(e.lane)&&e.lane!=="main"&&(n.lane=e.lane),e.lacuna===!0&&(n.lacuna=!0),e.guess===!0&&(n.guess=!0),typeof e.zi=="string"&&e.zi&&(n.zi=e.zi),n}function $x(e){const n={};typeof e.kind=="string"&&Sx.has(e.kind)&&e.kind!=="body"&&(n.kind=e.kind);const i=ct(e.raised);i!==void 0&&Number.isInteger(i)&&i>0&&(n.raised=i);const o=ct(e.lead_blank);return o!==void 0&&Number.isInteger(o)&&o>0&&(n.lead_blank=o),n}function hr(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(i=>!!i&&typeof i=="object"):[]}function Cx(e){return typeof e=="string"&&Array.from(e).length===1}function td(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"||!ed.test(a)){i.badAnchor++;continue}if(!Cx(l)){i.badChar++;continue}if(d!==void 0&&d!=="异体"){i.badWhy++;continue}n.set(a,l)}return{map:n,dropped:i}}function nd(e){return td(e).map}function zx(e,n,i){var h,u,m,f,x,k,y,$,b,w;const o=i==null?null:nd(i),s=new Map,a=new Map;for(const v of hr(n)){const j=ct(v.page);if(j!==void 0){s.set(j,v);for(const C of Array.isArray(v.cells)?v.cells:[]){const S=C==null?void 0:C.box;typeof(C==null?void 0:C.a)=="string"&&Array.isArray(S)&&S.length===4&&S.every(_=>ct(_)!==void 0)&&a.set(C.a,[S[0],S[1],S[0]+S[2],S[1]+S[3]])}}}const l=[],d=new Map,c=new Map;for(const v of hr(e)){const j=ct(v.page);j!==void 0&&typeof v.label=="string"&&v.label&&d.set(j,v.label)}for(const v of hr(e)){const j=ct(v.page);if(j===void 0)continue;const C=[];for(const _ of Array.isArray(v.columns)?v.columns:[]){const A=ct(_==null?void 0:_.col);if(A===void 0)continue;const T=[];for(const M of Array.isArray(_.cells)?_.cells:[]){const H=ed.exec(String((M==null?void 0:M.a)??""));if(!H||typeof M.c!="string")continue;const I=parseInt(H[3],10),R=o==null?void 0:o.get(M.a);T.push({id:M.a,char:M.c,slot:I,pos:I,sub:H[4]||null,bbox:a.get(M.a)??null,..._x(M),...R!==void 0&&R!==M.c?{norm:R}:{}})}const z=$x(_);(T.length>0||z.kind==="blank")&&C.push({col:A,chars:T,...z})}if(!C.some(_=>_.chars.length>0)){C.length>0&&c.set(j,C);continue}C.sort((_,A)=>_.col-A.col);const S=s.get(j);l.push({page:j,seq:String(((h=S==null?void 0:S.canvas)==null?void 0:h.seq)??""),width:ct((u=S==null?void 0:S.canvas)==null?void 0:u.width)??ct((m=S==null?void 0:S.image)==null?void 0:m.width)??0,height:ct((f=S==null?void 0:S.canvas)==null?void 0:f.height)??ct((x=S==null?void 0:S.image)==null?void 0:x.height)??0,...typeof v.label=="string"&&v.label?{label:v.label}:{},columns:C})}const p=new Set(l.map(v=>v.page));for(const[v,j]of s){const C=(k=j==null?void 0:j.canvas)==null?void 0:k.seq;p.has(v)||typeof C!="string"&&typeof C!="number"||String(C)===""||l.push({page:v,seq:String(C),width:ct((y=j.canvas)==null?void 0:y.width)??ct(($=j.image)==null?void 0:$.width)??0,height:ct((b=j.canvas)==null?void 0:b.height)??ct((w=j.image)==null?void 0:w.height)??0,...d.has(v)?{label:d.get(v)}:{},columns:c.get(v)??[]})}return l.sort((v,j)=>v.page-j.page)}const Tx=({data:e,onNavigate:n,className:i,style:o})=>{var h;const{t:s,convert:a}=ne(),[l,d]=g.useState(((h=e.divisions[0])==null?void 0:h.name)??null),[c,p]=g.useState(null);return t.jsxs("div",{className:i,style:o,children:[t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:r("fg"),margin:"0 0 8px"},children:a(e.title)}),e.stats&&t.jsxs("div",{style:{fontSize:"13px",color:r("desc-fg"),display:"flex",gap:"16px"},children:[e.total_volumes!=null&&t.jsxs("span",{children:[s("catalog.totalVolumes")," ",t.jsx("strong",{children:e.total_volumes})," ",s("unit.juan")]}),e.stats.zhulu!=null&&t.jsxs("span",{children:[s("catalogPage.zhulu")," ",t.jsx("strong",{children:e.stats.zhulu})," ",s("unit.bu")]}),e.stats.cunmu!=null&&t.jsxs("span",{children:[s("catalogPage.cunmu")," ",t.jsx("strong",{children:e.stats.cunmu})," ",s("unit.bu")]}),e.stats.categories!=null&&t.jsx("span",{children:s("catalogPage.categoriesN",{n:e.stats.categories})})]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.divisions.map(u=>t.jsx(Nx,{division:u,expanded:l===u.name,onToggle:()=>d(l===u.name?null:u.name),expandedCat:c,onCatToggle:m=>p(c===m?null:m),onNavigate:n},u.name))})]})},Nx=({division:e,expanded:n,onToggle:i,expandedCat:o,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=ne(),c=e.categories.reduce((p,h)=>{const u=h.stats||{zhulu:0,cunmu:0};return p+(u.zhulu||0)+(u.cunmu||0)},0);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:"none",background:n?`color-mix(in srgb, ${r("primary")} 6%, transparent)`:r("bg"),cursor:"pointer",fontSize:"15px",fontWeight:600,color:r("fg"),textAlign:"left"},children:[t.jsx("span",{children:d(e.name)}),t.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg")},children:[l("catalogPage.divisionStat",{cats:e.categories.length,books:c}),t.jsx("span",{style:{marginLeft:"8px"},children:n?"▲":"▼"})]})]}),n&&t.jsx("div",{style:{padding:"4px 0"},children:e.categories.map(p=>{const h=`${e.name}/${p.name}`;return t.jsx(Ix,{category:p,expanded:o===h,onToggle:()=>s(h),onNavigate:a},p.name)})})]})},Ix=({category:e,expanded:n,onToggle:i,onNavigate:o})=>{var p,h,u,m;const{t:s,convert:a}=ne(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((h=e.books)==null?void 0:h.cunmu)||[],c=(((u=e.stats)==null?void 0:u.zhulu)||l.length)+(((m=e.stats)==null?void 0:m.cunmu)||d.length);return t.jsxs("div",{children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px 6px 28px",border:"none",background:n?r("input-bg"):"transparent",cursor:"pointer",fontSize:"13px",color:r("fg"),textAlign:"left"},children:[t.jsxs("span",{style:{fontWeight:500},children:[a(e.name),e.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:a(e.volumes)})})]}),t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[s("catalogPage.booksN",{n:c})," ",n?"▲":"▼"]})]}),n&&(l.length>0||d.length>0)&&t.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[l.length>0&&t.jsx(wa,{label:s("catalogPage.zhulu"),books:l,onNavigate:o}),d.length>0&&t.jsx(wa,{label:s("catalogPage.cunmu"),books:d,onNavigate:o})]})]})},wa=({label:e,books:n,onNavigate:i})=>{const{t:o,convert:s}=ne(),a=rt(),[l,d]=g.useState(n.length<=20),c=l?n:n.slice(0,10);return t.jsxs("div",{style:{marginBottom:"8px"},children:[t.jsxs("div",{style:{fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},children:[e," (",n.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((p,h)=>t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[t.jsx("span",{style:{fontWeight:500,color:r("fg")},children:p.work_id&&i?t.jsx("a",{href:a(p.work_id),onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),i(p.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`},children:s(p.title)}):s(p.title)}),p.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:s(p.volumes)}),p.author&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:s(p.author).slice(0,20)})]},h))}),!l&&t.jsx("button",{onClick:()=>d(!0),style:{marginTop:"4px",padding:"2px 12px",fontSize:"11px",color:r("primary"),background:"transparent",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:o("catalogPage.expandAllN",{n:n.length})})]})},St=({title:e,onSave:n,onAskAI:i,extraButtons:o,children:s})=>{const a=Ie();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:Rx,children:"AI"}),n&&t.jsx("button",{onClick:n,style:Ex,children:a.action.save})]})]}),s]})},Ex={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Rx={padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},xt=({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"}})]}),on=({value:e,onChange:n,placeholder:i})=>{const o=g.useRef(null);return g.useEffect(()=>{o.current&&(o.current.style.height="auto",o.current.style.height=`${o.current.scrollHeight}px`)},[e]),t.jsx("textarea",{ref:o,value:e||"",onChange:s=>n(s.target.value),placeholder:i,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},ki=({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 Lx(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const gi=({value:e,onChange:n,label:i})=>{const[o,s]=g.useState(!1),a=g.useRef(null),l=Lx(e||"");return g.useEffect(()=>{o&&a.current&&a.current.focus()},[o]),!o&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Sa,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(ki,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Sa,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"}})]})},Sa={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500};function Ax(e){switch(e){case"url":return r("source-url");case"bookID":return r("source-bookid");default:return r("desc-fg")}}function Mx(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const id=({items:e,onChange:n,onOpenEntityPicker:i})=>{const o=Ie(),[s,a]=g.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=u=>{n(e.filter((m,f)=>f!==u)),s===u&&a(null)},c=(u,m,f)=>{const x=[...e];x[u]={...x[u],[m]:f},n(x)},p=(u,m)=>{const f=[...e];f[u]={...f[u],type:m,id:"",name:""},n(f),m==="bookID"&&i&&i(x=>{const k=[...e];k[u]={...k[u],id:x.id,name:x.title,type:"bookID"},n(k)})},h=u=>{i&&i(m=>{const f=[...e];f[u]={...f[u],id:m.id,name:m.title,type:"bookID"},n(f)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((u,m)=>t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>a(s===m?null:m),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===m?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:r("fg")},children:u.name||`${o.editor.sourcePlaceholder} ${m+1}`}),u.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:Ax(u.type),color:r("on-color-fg"),borderRadius:"3px",fontWeight:500},children:Mx(u.type)}),t.jsx("button",{onClick:f=>{f.stopPropagation(),d(m)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:o.editor.deleteThisSource,children:"✕"})]}),s===m&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!u.type&&t.jsxs("div",{children:[t.jsx("label",{style:Mt,children:o.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(m,"bookID"),style:{..._a,borderColor:r("source-bookid"),color:r("source-bookid")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"📚"}),t.jsx("span",{children:"Book ID"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.fromExistingBook})]}),t.jsxs("button",{onClick:()=>p(m,"url"),style:{..._a,borderColor:r("source-url"),color:r("source-url")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),t.jsx("span",{children:"URL"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.enterUrl})]})]})]}),u.type==="bookID"&&t.jsx(t.Fragment,{children:t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:Mt,children:o.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const f=[...e];f[m]={...f[m],type:"",id:"",name:""},n(f)},style:$a,children:o.action.changeType})]}),u.id&&u.name?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:r("bg"),border:`1px solid ${r("source-bookid")}`,borderRadius:"6px"},children:[t.jsx("span",{style:{color:r("source-bookid"),fontSize:"16px"},children:"✓"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:u.name}),t.jsx("code",{style:{fontSize:"11px",background:r("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:u.id})]}),t.jsx("button",{onClick:()=>h(m),style:{background:"transparent",border:`1px solid ${r("widget-border")}`,color:r("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:o.action.reselect})]}):t.jsxs("button",{onClick:()=>h(m),style:{width:"100%",padding:"14px",border:`2px dashed ${r("widget-border")}`,borderRadius:"6px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[t.jsx("span",{children:"🔍"}),t.jsx("span",{children:o.action.clickToSelectBookOrWork})]})]})}),u.type==="url"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:Mt,children:o.label.sourceName}),t.jsx("button",{onClick:()=>{const f=[...e];f[m]={...f[m],type:"",id:"",name:""},n(f)},style:$a,children:o.action.changeType})]}),t.jsx("input",{type:"text",value:u.name,onChange:f=>c(m,"name",f.target.value),placeholder:o.editor.sourceNamePlaceholder,style:dn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Mt,children:o.label.urlAddress}),t.jsx("input",{type:"text",value:u.id,onChange:f=>c(m,"id",f.target.value),placeholder:"https://...",style:dn})]})]}),u.type&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{borderTop:`1px dashed ${r("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:t.jsx("label",{style:{...Mt,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:Mt,children:o.label.detailsOptional}),t.jsx("input",{type:"text",value:u.details,onChange:f=>c(m,"details",f.target.value),placeholder:o.editor.detailsPlaceholder,style:dn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Mt,children:o.label.positionOptional}),t.jsx("input",{type:"text",value:u.position,onChange:f=>c(m,"position",f.target.value),placeholder:"如: 卷三, p.52",style:dn})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Mt,children:o.label.dataVersionOptional}),t.jsx("input",{type:"text",value:u.version,onChange:f=>c(m,"version",f.target.value),placeholder:"如: v1.0, 2024-01",style:dn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Mt,children:o.label.processorVersionOptional}),t.jsx("input",{type:"text",value:u.processor_version,onChange:f=>c(m,"processor_version",f.target.value),placeholder:"如: v0.1",style:dn})]})]})]})]})})]},m)),t.jsxs("button",{onClick:l,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:o.action.addSource})]})]})},Mt={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},dn={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"},_a={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"},$a={background:"transparent",border:"none",color:r("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function rd(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 od(e){return!e||e.length===0?"":JSON.stringify(e)}const sd=({entityType:e,entityId:n,entityTitle:i,parentWork:o,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:h,onLinkEntity:u,onUnlinkEntity:m,onViewEntity:f,onCreateAndLink:x,onSaveRelations:k})=>{const y=Ie();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})]}),k&&t.jsx("button",{onClick:k,style:Px,children:y.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(Nn,{direction:"up",title:y.relation.belongsToWork,entity:a,onView:f,onUnlink:()=>m("workId"),onLink:()=>u("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(Nn,{direction:"up",title:y.relation.containedInCollection,entity:l,onView:f,onUnlink:()=>m("collectionId"),onLink:()=>u("collectionId","collection"),onCreate:()=>x("collectionId","collection",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),a&&h&&h.length>0&&t.jsx(pn,{direction:"horizontal",title:`${y.relation.siblingVersions} (${h.length})`,entities:h,onView:f,onAdd:()=>x("siblingBook","book",{workId:a.id}),addLabel:y.relation.addVersionForWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="work"&&t.jsxs(t.Fragment,{children:[t.jsx(Nn,{direction:"up",title:y.relation.parentWork,entity:o,onView:f,onUnlink:()=>m("parentWorkId"),onLink:()=>u("parentWorkId","work"),onCreate:()=>x("parentWorkId","work"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),d&&d.length>0&&t.jsx(pn,{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(pn,{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(pn,{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(Nn,{direction:"up",title:y.relation.correspondingWork,entity:a,onView:f,onUnlink:()=>m("workId"),onLink:()=>u("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(Nn,{direction:"up",title:y.relation.parentCollection,entity:s,onView:f,onUnlink:()=>m("parentCollectionId"),onLink:()=>u("parentCollectionId","collection"),onCreate:()=>x("parentCollectionId","collection"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(pn,{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(pn,{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})]})]})]})},Nn=({direction:e,title:n,entity:i,onView:o,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:h,unlinkLabel:u})=>{const m=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),f=e==="up"?"⬆️":e==="down"?"⬇️":"↔️";return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:m,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:f}),t.jsx("span",{children:n})]}),i?t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:r("bg"),borderRadius:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:ad(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(Ca,{onClick:()=>o(i),title:h,children:"👁️"}),t.jsx(Ca,{onClick:s,title:u,danger:!0,children:"✕"})]})]}):t.jsx("div",{style:{padding:"8px",background:r("bg"),borderRadius:"4px",color:r("desc-fg"),fontSize:"12px",textAlign:"center"},children:p}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsx(Wr,{onClick:a,children:d}),t.jsx(Wr,{onClick:l,primary:!0,children:c})]})]})},pn=({direction:e,title:n,entities:i,onView:o,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=g.useState(!1),h=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),u=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",m=c?i:i.slice(0,5);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:h,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:u}),t.jsx("span",{children:n})]}),i.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[m.map(f=>t.jsxs("div",{onClick:()=>o(f),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:r("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[t.jsx("span",{children:ad(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(Wr,{onClick:s,primary:!0,children:["+ ",a]})})]})},Ca=({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}),Wr=({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 ad(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const Px={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},ld=({isOpen:e,entityType:n,title:i,onSelect:o,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[h,u]=g.useState(""),m=p?l.filter(y=>y.id!==p):l;g.useEffect(()=>{e&&(u(""),d(""))},[e]);const f=y=>{u(y),d(y)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",k=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:Bx,children:t.jsxs("div",{style:Ox,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:Wx,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:h,onChange:y=>f(y.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:Fx})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:gr,children:"搜索中..."}):m.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:m.map(y=>t.jsxs("div",{onClick:()=>o(y),style:Hx,children:[t.jsx("span",{style:{fontSize:"16px"},children:k}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[y.title,y.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:y.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[y.id,y.author&&` · ${y.author}`,y.dynasty&&` · ${y.dynasty}`]})]})]},y.id))}):h?t.jsxs("div",{style:gr,children:["未找到匹配的",x]}):t.jsxs("div",{style:gr,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:Dx,children:["创建新",x,"并关联"]})]})]})})},Bx={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Ox={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")},Wx={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},Fx={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"},Hx={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:r("primary-soft")},gr={padding:"20px",textAlign:"center",color:r("desc-fg")},Dx={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},za={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},Ux={work:"📜",book:"📖",collection:"📚",entity:"👤"},cd=({isOpen:e,entityType:n,relationField:i,inheritData:o,onConfirm:s,onCancel:a})=>{const[l,d]=g.useState(""),c=g.useRef(null);g.useEffect(()=>{e&&(d((o==null?void 0:o.title)||""),setTimeout(()=>{var m,f;(m=c.current)==null||m.focus(),(f=c.current)==null||f.select()},100))},[e,o==null?void 0:o.title]);const p=m=>{m.key==="Enter"&&l.trim()?h():m.key==="Escape"&&a()},h=()=>{l.trim()&&s(l.trim(),{...o,title:l.trim()})};if(!e)return null;const u=()=>{switch(i){case"parentWorkId":return"创建父作品";case"workId":return"创建所属作品";case"collectionId":return"创建所属丛编";case"parentCollectionId":return"创建父丛编";case"childWork":return"创建子作品";case"childBook":case"siblingBook":return"创建书籍";case"childCollection":return"创建子丛编";default:return`创建新${za[n]}`}};return t.jsx("div",{style:Vx,onClick:m=>{m.target===m.currentTarget&&a()},children:t.jsxs("div",{style:Gx,onClick:m=>m.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Ux[n]}),t.jsx("span",{children:u()})]}),t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:r("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",t.jsx("span",{style:{color:r("danger"),marginLeft:"4px"},children:"*"})]}),t.jsx("input",{ref:c,type:"text",value:l,onChange:m=>d(m.target.value),onKeyDown:p,placeholder:`请输入${za[n]}名称...`,style:Yx})]}),((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:qx,children:"取消"}),t.jsx("button",{onClick:h,disabled:!l.trim(),style:{...Kx,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},Vx={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Gx={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")},Yx={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"},qx={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},Kx={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg")};function Xx(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function dd(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Zx(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 pd=({isOpen:e,title:n,filterType:i="all",recentEntities:o=[],excludeId:s,showCreateButton:a=!1,createButtonText:l,onSelect:d,onCancel:c,onCreate:p,onSearch:h})=>{const[u,m]=g.useState(""),[f,x]=g.useState([]),[k,y]=g.useState(!1),[$,b]=g.useState("recent");g.useEffect(()=>{e&&(m(""),x([]),b(o.length>0?"recent":"search"))},[e,o.length]),g.useEffect(()=>{if(!u.trim()){x([]);return}const _=setTimeout(async()=>{y(!0);try{x(await h(u,i))}catch{x([])}finally{y(!1)}},300);return()=>clearTimeout(_)},[u,i,h]);const w=g.useCallback(_=>{m(_.target.value),_.target.value.trim()&&b("search")},[]),v=g.useCallback(_=>s?_.filter(A=>A.id!==s):_,[s]);if(!e)return null;const j=n||(i==="all"?"选择实体":`选择${dd(i)}`),C=v(o),S=v(f);return t.jsx("div",{style:Qx,children:t.jsxs("div",{style:eb,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:j}),t.jsx("button",{onClick:c,style:tb,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:u,onChange:w,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:nb}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),k&&t.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),C.length>0&&t.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs(Ta,{active:$==="recent",onClick:()=>b("recent"),children:["最近使用 (",C.length,")"]}),t.jsxs(Ta,{active:$==="search",onClick:()=>b("search"),children:["搜索结果 ",S.length>0&&`(${S.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:$==="recent"&&C.length>0?t.jsx(Na,{entities:C,onSelect:d}):u.trim()?k?t.jsx(fr,{message:"搜索中..."}):S.length>0?t.jsx(Na,{entities:S,onSelect:d}):t.jsx(fr,{message:"未找到匹配的结果"}):t.jsx(fr,{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:ib,children:l||"创建新实体"})]})]})})},Ta=({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}),Na=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(i=>t.jsx(Jx,{entity:i,onClick:()=>n(i)},i.id))}),Jx=({entity:e,onClick:n})=>{const[i,o]=g.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:r("primary-soft"),transition:"background 0.1s"},children:[t.jsx("span",{style:{fontSize:"18px"},children:Xx(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:Zx(e.type),color:r("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:dd(e.type)})]})},fr=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:e}),Qx={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},eb={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")},tb={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},nb={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"},ib={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},rb={work:r("editor-type-work"),collection:r("editor-type-collection"),book:r("editor-type-book"),entity:r("editor-type-entity")},ob={work:"📜",collection:"📚",book:"📖",entity:"👤"},ud=({data:e,onChange:n,onSave:i,transport:o,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:h,relations:u,onRelationsChange:m})=>{var q;const f=Ie(),[x,k]=g.useState(!1),[y,$]=g.useState("work"),[b,w]=g.useState(""),[v,j]=g.useState(""),[C,S]=g.useState([]),[_,A]=g.useState(!1),[T,z]=g.useState(!1),[M,H]=g.useState("work"),[I,R]=g.useState(""),[P,K]=g.useState(),[te,ie]=g.useState(!1),[U,pe]=g.useState(null),[G,ee]=g.useState([]);g.useRef(null);const ae=e.type,Se=ae==="work",O=ae==="collection",je=ae==="book",de=g.useCallback((D,Q)=>{n({...e,[D]:Q})},[e,n]),we=g.useCallback((D,Q)=>{w(D),$(Q),j(f.editor.selectToLink+f.indexType[Q]),S([]),k(!0)},[f]),Te=g.useCallback(D=>{o!=null&&o.unlinkEntity&&o.unlinkEntity(e.id,D)},[o,e.id]),Fe=g.useCallback(D=>{s==null||s(D.id,D.type)},[s]),re=g.useCallback((D,Q,Ce)=>{const Le={...Ce,author:(Ce==null?void 0:Ce.author)||e.author,dynasty:Ce==null?void 0:Ce.dynasty};H(Q),R(D),K(Le),z(!0)},[e.author]),B=g.useCallback((D,Q)=>{o!=null&&o.createAndLink&&o.createAndLink(e.id,I,{type:M,title:D,inheritData:Q}),z(!1)},[o,e.id,I,M]),V=g.useCallback(D=>{if(!D.trim()){S([]);return}A(!0),o!=null&&o.searchEntities&&o.searchEntities(D,y).then(Q=>{S(Q),A(!1)}).catch(()=>{S([]),A(!1)})},[o,y]),he=g.useCallback(D=>{o!=null&&o.linkEntity&&o.linkEntity(e.id,b,D.id),k(!1)},[o,e.id,b]),X=g.useCallback(()=>{i()},[i]),ge=g.useCallback(D=>{pe(()=>D),ie(!0),o!=null&&o.getRecentEntities&&o.getRecentEntities().then(ee).catch(()=>{})},[o]),W=g.useCallback((D,Q)=>o!=null&&o.searchEntities?o.searchEntities(D,Q==="all"?void 0:Q):Promise.resolve([]),[o]),le=g.useCallback(D=>{o!=null&&o.addRecentEntity&&o.addRecentEntity(D),ee(Q=>[D,...Q.filter(Ce=>Ce.id!==D.id)].slice(0,10)),U==null||U(D),ie(!1),pe(null)},[o,U]);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:ob[ae]}),t.jsx("span",{children:e.title||f.editor.untitled}),t.jsx(ki,{children:e.id}),t.jsx(ki,{color:rb[ae],children:f.indexType[ae]})]})}),t.jsx(St,{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(gi,{label:Se?f.editor.workTitle:O?f.editor.collectionTitle:f.editor.bookTitle,value:e.title,onChange:D=>de("title",D)}),je&&t.jsx(gi,{label:f.editor.belongsToWork,value:e.workName||"",onChange:D=>de("workName",D)}),t.jsx(xt,{label:f.editor.authorLabel,value:e.author||"",onChange:D=>de("author",D)}),t.jsx(xt,{label:f.editor.publicationYearLabel,value:e.publicationYear||"",onChange:D=>de("publicationYear",D)}),(je||O)&&t.jsx(gi,{label:f.editor.containedIn,value:e.collection||"",onChange:D=>de("collection",D)}),(je||O)&&t.jsx(xt,{label:f.editor.holderLabel,value:e.holder||"",onChange:D=>de("holder",D)}),(je||O)&&t.jsx(xt,{label:je?f.editor.pageLabel:f.editor.volumeLabel,value:e.pages||"",onChange:D=>de("pages",D)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(xt,{label:f.editor.firstImageLabel,value:e.firstImage||"",onChange:D=>de("firstImage",D)})})]})}),t.jsx(St,{title:f.section.description,onSave:i,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(on,{value:e.description||"",onChange:D=>de("description",D),placeholder:f.editor.descriptionPlaceholder})}),(((q=e.additional_works)==null?void 0:q.length)||0)>0&&t.jsx(St,{title:f.section.additionalWorks,onSave:i,children:t.jsx(sb,{items:e.additional_works||[],onChange:D=>de("additional_works",D)})}),t.jsx(St,{title:f.section.indexedBy,onSave:i,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(ab,{items:e.indexed_by||[],onChange:D=>de("indexed_by",D)})}),t.jsx(St,{title:f.section.emendatedBy,onSave:i,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(lb,{items:e.emendated_by||[],onChange:D=>de("emendated_by",D)})}),t.jsx(St,{title:f.section.textResources,onSave:i,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(kr,{items:e.resources||[],onChange:D=>de("resources",D),onDownload:p,downloadStatuses:h,filterType:"text"})}),t.jsx(St,{title:f.section.imageResources,onSave:i,children:t.jsx(kr,{items:e.resources||[],onChange:D=>de("resources",D),onDownload:p,downloadStatuses:h,filterType:"image"})}),t.jsx(St,{title:f.section.sources,onSave:i,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(id,{items:rd(e.sources||""),onChange:D=>de("sources",od(D)),onOpenEntityPicker:ge})}),(je||O)&&t.jsx(St,{title:f.section.provenance,onSave:i,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(on,{value:e.provenance||"",onChange:D=>de("provenance",D),placeholder:f.editor.provenancePlaceholder})}),je&&t.jsx(St,{title:f.section.otherEditions,onSave:i,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(on,{value:e.otherEditions||"",onChange:D=>de("otherEditions",D),placeholder:f.editor.otherEditionsPlaceholder})}),t.jsx(sd,{entityType:ae,entityId:e.id,entityTitle:e.title,parentWork:u==null?void 0:u.parentWork,parentCollection:u==null?void 0:u.parentCollection,belongsToWork:u==null?void 0:u.belongsToWork,belongsToCollection:u==null?void 0:u.belongsToCollection,childWorks:u==null?void 0:u.childWorks,childCollections:u==null?void 0:u.childCollections,containedBooks:u==null?void 0:u.containedBooks,siblingBooks:u==null?void 0:u.siblingBooks,onLinkEntity:we,onUnlinkEntity:Te,onViewEntity:Fe,onCreateAndLink:re,onSaveRelations:X}),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(ld,{isOpen:x,entityType:y,title:v,onSelect:he,onCancel:()=>k(!1),onCreate:()=>{k(!1),re(b,y)},searchResults:C,onSearch:V,isLoading:_,excludeId:e.id}),t.jsx(cd,{isOpen:T,entityType:M,relationField:I,inheritData:P,onConfirm:B,onCancel:()=>z(!1)}),t.jsx(pd,{isOpen:te,title:f.action.selectBookOrWork,filterType:"all",recentEntities:G,excludeId:e.id,onSelect:le,onCancel:()=>{ie(!1),pe(null)},onSearch:W})]})};function sb({items:e,onChange:n}){const i=Ie(),o=(l,d,c)=>{const p=e.map((h,u)=>u===l?{...h,[d]:c}:h);n(p)},s=l=>n(e.filter((d,c)=>c!==l)),a=()=>n([...e,{book_title:""}]);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((l,d)=>t.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[t.jsx(xt,{label:i.editor.bookNameLabel,value:l.book_title,onChange:c=>o(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(xt,{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 md({items:e,onChange:n,showMeta:i,addLabel:o}){const s=Ie(),[a,l]=g.useState(null),d=(h,u,m)=>{const f=e.map((x,k)=>k===h?{...x,[u]:m||void 0}:x);n(f)},c=h=>{n(e.filter((u,m)=>m!==h)),a===h&&l(null)},p=()=>{n([...e,{source:""}]),l(e.length)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((h,u)=>{const m=a===u;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:m?`color-mix(in srgb, ${r("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(m?null:u),children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.2s",transform:m?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:h.source||s.editor.unnamedSource}),h.source_bid&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:h.source_bid}),t.jsx("button",{onClick:f=>{f.stopPropagation(),c(u)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${r("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:r("muted")},children:"✕"})]}),!m&&i&&(h.title_info||h.author_info)&&t.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:r("desc-fg")},children:[h.title_info,h.title_info&&h.author_info&&" — ",h.author_info]}),m&&t.jsxs("div",{style:{padding:"8px 12px 12px",display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(xt,{label:s.label.sourceName,value:h.source,onChange:f=>d(u,"source",f)}),t.jsx(xt,{label:s.label.sourceBid,value:h.source_bid||"",onChange:f=>d(u,"source_bid",f)})]}),i&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(xt,{label:s.label.titleInfo,value:h.title_info||"",onChange:f=>d(u,"title_info",f)}),t.jsx(xt,{label:s.label.authorInfo,value:h.author_info||"",onChange:f=>d(u,"author_info",f)})]}),t.jsx(xt,{label:s.label.edition,value:h.edition||"",onChange:f=>d(u,"edition",f)})]}),t.jsx(on,{value:h.summary||"",onChange:f=>d(u,"summary",f),placeholder:s.editor.summaryPlaceholder}),t.jsx(on,{value:h.comment||"",onChange:f=>d(u,"comment",f),placeholder:s.editor.commentPlaceholder}),t.jsx(on,{value:h.additional_comment||"",onChange:f=>d(u,"additional_comment",f),placeholder:s.editor.additionalCommentPlaceholder})]})]},u)}),t.jsx("button",{onClick:p,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${r("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("desc-fg"),alignSelf:"flex-start"},children:o})]})}function ab({items:e,onChange:n}){const i=Ie();return t.jsx(md,{items:e,onChange:n,showMeta:!0,addLabel:i.action.addIndexedBy})}function lb({items:e,onChange:n}){const i=Ie();return t.jsx(md,{items:e,onChange:n,addLabel:i.action.addEmendatedBy})}function hd(e){var d,c,p,h,u,m,f;const n=((c=(d=e.authors)==null?void 0:d[0])==null?void 0:c.name)||"",i=((p=e.publication_info)==null?void 0:p.year)||"",o=((h=e.current_location)==null?void 0:h.name)||"",s=(u=e.page_count)!=null&&u.number?String(e.page_count.number):((m=e.page_count)==null?void 0:m.description)||"",a=typeof e.description=="object"&&e.description!==null&&e.description.text||"",l={id:e.id,title:e.title,type:e.type,author:n,publicationYear:i,holder:o,pages:s,description:a,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};if(e.type==="work"){const x=e;if(Array.isArray(x.related_works)){const k=x.related_works.find(y=>y.relation==="part_of");k&&(l.parentWorkId=k.id,l.parentWorkName=k.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 cb(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 db=e=>{const{data:n,id:i,transport:o,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:h,onAskAI:u,renderSectionActions:m,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y,headerExtra:$,className:b,style:w}=e,v=Ie(),[j,C]=g.useState(s),S=a?s:j;g.useEffect(()=>{s!==j&&C(s)},[s]);const _=g.useCallback(()=>{const R=S==="view"?"edit":"view";a?a(R):C(R)},[S,a]),[A,T]=g.useState(null);g.useEffect(()=>{i&&o&&o.getItem(i).then(R=>{R&&T(R)})},[i,o]);const z=n||A,M=g.useMemo(()=>z?hd(z):null,[z]),H=a||!n?t.jsx("button",{onClick:_,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:S==="edit"?r("accent-bg"):"transparent",color:r(S==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:S==="view"?v.common.switchToEdit:v.common.switchToView,children:S==="view"?v.common.modeEdit:v.common.modeView}):null,I=t.jsxs(t.Fragment,{children:[H,$]});return!z&&!M?t.jsx(sn,{}):S==="view"?t.jsx(ro,{data:z,transport:o,onNavigate:p?R=>p(R):void 0,renderLink:h,headerExtra:I,className:b,style:w}):M?t.jsxs("div",{className:b,style:w,children:[I&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:I}),t.jsx(ud,{data:M,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:o,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:u,renderSectionActions:m,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:r("muted")},children:v.common.noData})},pb=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],gd=({isOpen:e,onClose:n,onSubmit:i,feedbackListUrl:o})=>{const{t:s}=ne(),[a,l]=g.useState(null),[d,c]=g.useState(""),[p,h]=g.useState(""),[u,m]=g.useState("idle"),[f,x]=g.useState(""),k=g.useRef(null);g.useEffect(()=>{e&&(l(null),c(""),h(""),m("idle"),x(""))},[e]),g.useEffect(()=>{a&&setTimeout(()=>{var b;return(b=k.current)==null?void 0:b.focus()},100)},[a]),g.useEffect(()=>{if(u==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[u,n]),g.useEffect(()=>{if(!e)return;const b=w=>{w.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,n]);const y=async()=>{if(!(!a||!d.trim())){m("submitting"),x("");try{await i({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),m("success")}catch(b){m("error"),x(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const $=a&&d.trim()&&u!=="submitting";return t.jsx("div",{style:ub,onClick:b=>{b.target===b.currentTarget&&n()},children:t.jsxs("div",{style:mb,onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{style:hb,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:gb,"aria-label":s("feedback.close"),children:"✕"})]}),u==="success"?t.jsxs("div",{style:jb,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:pb.map(b=>t.jsxs("button",{onClick:()=>l(b.value),style:{...fb,...a===b.value?xb:{}},children:[t.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),t.jsx("textarea",{ref:k,value:d,onChange:b=>c(b.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||u==="submitting",style:{...bb,opacity:a?1:.6}}),t.jsx("input",{type:"text",value:p,onChange:b=>h(b.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!a||u==="submitting","aria-label":s("feedback.contactLabel"),style:kb}),t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),u==="error"&&t.jsx("div",{style:vb,children:f}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:y,disabled:!$,style:{...yb,opacity:$?1:.6,cursor:$?"pointer":"not-allowed"},children:s(u==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},ub={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},mb={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:r("shadow-dialog")},hb={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},gb={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:r("desc-fg"),padding:"4px 8px",borderRadius:"4px"},fb={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"},xb={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},bb={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"},yb={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},jb={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:r("success")},vb={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginBottom:"12px"},kb={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"},Fr="--bim-feedback-fab-offset",Hr=48,wb=16,Sb=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:i,hidden:o=!1,zIndex:s})=>{const{t:a}=ne(),[l,d]=g.useState(!1),c=n.bottom??24;return g.useEffect(()=>{if(o||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(Fr,`calc(${c+Hr+wb}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(Fr)}},[o,c]),t.jsxs(t.Fragment,{children:[!o&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{..._b,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(gd,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:i})]})},_b={position:"fixed",width:`${Hr}px`,height:`${Hr}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"},$b=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],fd=({onSubmit:e})=>{const{t:n}=ne(),[i,o]=g.useState("bug"),[s,a]=g.useState(""),[l,d]=g.useState(""),[c,p]=g.useState("idle"),[h,u]=g.useState(""),m=g.useRef(null);g.useEffect(()=>{i&&setTimeout(()=>{var k;return(k=m.current)==null?void 0:k.focus()},100)},[i]);const f=async()=>{if(!(!i||!s.trim())){p("submitting"),u("");try{await e({type:i,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),o("bug")}catch(k){p("error"),u(k instanceof Error?k.message:n("feedback.submitFailedRetry"))}}},x=i&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:Ia,children:t.jsxs("div",{style:Ib,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:Eb,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:Ia,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:$b.map(k=>t.jsxs("button",{onClick:()=>o(k.value),style:{...Cb,...i===k.value?zb:{}},children:[t.jsx("span",{children:k.icon})," ",n(`feedback.submitType.${k.value}`)]},k.value))}),t.jsx("textarea",{ref:m,value:s,onChange:k=>a(k.target.value),placeholder:n(i?`feedback.placeholder.${i}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...Tb}}),t.jsx("input",{type:"text",value:l,onChange:k=>d(k.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:Lb}),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:{...Nb,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:Rb,children:h})]})},Ia={padding:"16px",border:`1px solid ${r("widget-border")}`,borderRadius:"8px",background:r("input-bg")},Cb={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:"transparent",color:r("fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},zb={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},Tb={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"},Nb={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},Ib={display:"flex",alignItems:"center",gap:"12px",color:r("success"),fontSize:"14px"},Eb={background:"none",border:"none",color:r("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},Rb={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginTop:"8px"},Lb={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 Ea(e){return typeof e=="function"?e():e??"/api/feedback"}const xd=({resourceId:e,apiUrl:n})=>{const{t:i}=ne(),[o,s]=g.useState([]),[a,l]=g.useState(!0),d=g.useCallback(async()=>{const p=Ea(n);l(!0);try{const u=await(await fetch(`${p}?resourceId=${encodeURIComponent(e)}`)).json();u.success&&s(u.items)}catch{}finally{l(!1)}},[e,n]);g.useEffect(()=>{d()},[d]);const c=async p=>{const h=Ea(n),u=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!u.ok){const m=await u.json().catch(()=>null);throw new Error((m==null?void 0:m.error)||i("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(Fo,{items:o,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(fd,{onSubmit:c})})]})},Oi=8;async function Wi(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 Ab=_i["zh-Hant"].relation,Mb=_i["zh-Hant"].lossStatus,Pb=_i["zh-Hant"].resourceKind,Fi=vn("zh-Hant"),Ho=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function Ra(e,n=Fi){return e?Ho(Ab,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function Bb(e,n=Fi){return Ho(Mb,e)?n(`detail.lossStatus.${e}`):e}function Ob(e,n=Fi){return Ho(Pb,e)?n(`detail.resourceKind.${e}`):""}function Do({authors:e,onNavigate:n,renderLink:i}){const{convert:o}=ne(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=mo(a.role);return t.jsxs(g.Fragment,{children:[l>0&&" ",a.dynasty&&t.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",o(a.dynasty),"〕"]}),a.entity_id?t.jsx(et,{id:a.entity_id,label:o(a.name),onNavigate:n,renderLink:i,dense:!0}):o(a.name),d&&t.jsx("span",{style:{marginLeft:4},children:o(d)})]},l)})}):null}function bd(e,n,i=Fi){var c,p;const o=po(e,n),s=o.mirrors.map(h=>({key:h.key,label:h.label,description:h.description,rows:h.items.filter(u=>u.group_role!=="mirror"),mirrors:h.items.filter(u=>u.group_role==="mirror")})),a=o.buckets.filter(h=>h.key==="image"||h.key==="textImage").flatMap(h=>h.items);a.length&&s.push({key:"_images",label:s.length?i("detail.otherImages"):void 0,rows:a,mirrors:[]});const l=((c=o.buckets.find(h=>h.key==="physical"))==null?void 0:c.items)??[];return l.length&&s.push({key:"_physical",label:i("detail.resourceKind.physical"),rows:l,mirrors:[]}),{text:((p=o.buckets.find(h=>h.key==="text"))==null?void 0:p.items)??[],groups:s}}function yd(e,n){const i=(e.url?bn(e.url):void 0)||e.name,o=Ql(e,n);return o?`${i}(${o})`:i}function Uo({item:e,siblings:n,listedVolumeCounts:i}){const{t:o,convert:s}=ne(),[a,l]=g.useState(!1),d=Si(e),c=!!d&&d.expected>0&&!(i!=null&&i.has(d.expected)),p=s(yd(e,n)),h=yn(e),u=Ri(e,o)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var f,x;const m=(f=e.metadata)!=null&&f.fragment||e.color_mode?t.jsxs("span",{className:"bim-d-tags bim-d-ui",style:{display:"inline-flex",margin:"0 0 0 8px",verticalAlign:"middle"},children:[((x=e.metadata)==null?void 0:x.fragment)&&t.jsx("span",{className:"bim-d-tag",children:o("detail.fragmentTag")}),e.color_mode&&t.jsx("span",{className:"bim-d-tag",children:e.color_mode==="color"?o("colorMode.color"):o("colorMode.bw")})]}):null;return h?t.jsxs("a",{href:h,target:"_blank",rel:"noopener noreferrer",children:[p," ",t.jsx("span",{"aria-hidden":"true",children:"↗"}),m]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,m]})})(),u&&t.jsx("span",{className:"bim-d-meta",children:s(u)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(jo,{item:e})})]}),t.jsx("td",{className:c?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:c&&t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":a,onClick:()=>l(m=>!m),children:a?o("detail.collapseVolumes"):o("detail.expandVolumes",{n:d.expected})})})]})}function jd({groups:e,listedVolumeCounts:n}){const{t:i,convert:o}=ne();return t.jsx(t.Fragment,{children:e.map(s=>t.jsxs("div",{className:"bim-d-rg",children:[s.label&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:o(s.label)}),s.description&&t.jsx("p",{className:"bim-d-rg-d",children:o(s.description)}),s.rows.length>0&&t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:s.rows.map((a,l)=>t.jsx(Uo,{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=yn(a),c=o(yd(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 Bn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function Dr(e){var i;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(i=Bn.find(o=>n.startsWith(o.key[0])))==null?void 0:i.key}const La=12,Wb=60,vd=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,railTop:a,back:l,railLinks:d})=>{var he,X,ge;const{t:c,convert:p,messages:h}=ne(),u=g.useMemo(()=>ho({_books:e._books}),[e._books]),[m,f]=g.useState(new Map),[x,k]=g.useState(!1),[y,$]=g.useState(""),[b,w]=g.useState(!1),v=u.length<=Wb,j=v||x||!!y||b,C=g.useMemo(()=>j?u:u.slice(0,La),[u,j]);g.useEffect(()=>{if(!n||C.length===0)return;const W=C.filter(q=>!m.has(q));if(W.length===0)return;let le=!1;return Wi(W,Oi,q=>n.getItem(q).then(D=>{var Ce;const Q=D??{};return[q,{id:q,title:Q.title,edition:Q.edition,resources:Q.resources,publication_info:Q.publication_info,current_location:Q.current_location,lineage:Q.lineage,measure_info:Q.measure_info,summary:Fb((Ce=D==null?void 0:D.description)==null?void 0:Ce.text)}]}).catch(()=>[q,{id:q}]),()=>le).then(q=>{le||f(D=>{const Q=new Map(D);for(const[Ce,Le]of q)Q.set(Ce,Le);return Q})}),()=>{le=!0}},[n,C,m]);const S=g.useMemo(()=>u.map(W=>m.get(W)??{id:W}),[u,m]),_=u.length>0&&u.every(W=>m.has(W)),A=!!n&&C.some(W=>!m.has(W)),T=v||j,z=g.useMemo(()=>tc(S,e.version_graph,{era:y,scanOnly:b,sort:T?"year":"default"}),[S,e.version_graph,y,b,T]),M=x?z.rows:z.rows.slice(0,La),H=z.allRows.filter(W=>W.hasImage).length,I=z.allRows.reduce((W,le)=>{var q;return W+(((q=le.copies)==null?void 0:q.length)??0)},0),R=g.useMemo(()=>(e._related||[]).map(W=>({...W,title:W.title??""})),[e._related]),P=R.filter(W=>W.relation==="collected_in"),K=g.useMemo(()=>{const W=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],le=q=>{const D=W.indexOf(q??"");return D<0?W.length:D};return R.filter(q=>q.relation!=="collected_in").map((q,D)=>({r:q,i:D})).sort((q,D)=>le(q.r.relation)-le(D.r.relation)||q.i-D.i).map(q=>q.r)},[R]),te=g.useMemo(()=>{const W=po(e.resources,e.resource_groups);return[...W.mirrors.flatMap(le=>le.items.map(q=>({r:q,kind:p(le.label)}))),...W.buckets.flatMap(le=>le.items.map(q=>({r:q,kind:p(Ob(le.key,c))})))]},[e.resources,e.resource_groups,p,c]),ie=e.indexed_by||[],U=e.emendated_by||[],pe=g.useMemo(()=>{var F,se,ve;const W=[],le=(se=(F=e.authors)==null?void 0:F[0])==null?void 0:se.dynasty;le&&W.push({label:c("workPage.fact.written"),value:p(le)});const q=Ht(e,h.unit.juan);if(q){const L=(ve=e.juan_count)==null?void 0:ve.description;W.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(q),L&&L!==q?t.jsxs("span",{className:"bim-d-meta",children:["(",p(L),")"]}):null]})})}e.loss_status&&W.push({label:c("workPage.fact.loss"),value:p(Bb(e.loss_status,c))});const D=z.allRows.filter(L=>L.sortYear!=null),Q=D.length>0?D.reduce((L,me)=>L.sortYear<=me.sortYear?L:me):null;Q!=null&&Q.era.era?W.push({label:c("workPage.fact.earliest"),value:p([Q.era.era,Q.era.reign].filter(Boolean).join(" ")),title:Q.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):A&&W.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),U.length&&W.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:U.length})});const Ce=Aa(e.additional_titles);Ce.length&&W.push({label:c("workPage.fact.alias"),value:Ce.map(p).join("、")});const Le=Aa(e.attached_texts);Le.length&&W.push({label:c("workPage.fact.attached"),value:Le.map(p).join("、")});const Ae=(e.additional_works||[]).map(L=>p(L.book_title)+(L.n_juan!=null?` ${L.n_juan}${h.unit.juan}`:""));return Ae.length&&W.push({label:c("workPage.fact.appendix"),value:Ae.join("、")}),W},[e,p,c,h,A,z.allRows,U.length]),ee=[{value:e._edition_count??u.length,label:c("workPage.stat.editions")},{value:_?H:0,label:c("workPage.stat.hasImage")},{value:ie.length,label:c("workPage.stat.catalogs")}],ae=go(e),Se=ae?[ae.l1,ae.l2,ae.l3,ae.l4].filter(Boolean).map(W=>p(W)):[],O=e.subtype?h.workSubtype[e.subtype]??p(e.subtype):"",je=t.jsx(Dn,{title:p(e.title),byline:t.jsx(Do,{authors:e.authors,onNavigate:i,renderLink:o}),meta:t.jsx(at,{items:[...Se,ae!=null&&ae.source?c("workPage.classifiedBy",{source:p(ae.source.split("/")[0])}):"",O]}),description:(he=e.description)!=null&&he.text?t.jsxs(t.Fragment,{children:[t.jsx(Ft,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(X=e.description.sources)!=null&&X.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(W=>({text:p(Eh(W)),href:Rh(W)})).filter(W=>W.text).map((W,le)=>t.jsxs(g.Fragment,{children:[le>0?" · ":null,W.href?t.jsx("a",{href:W.href,target:"_blank",rel:"noopener noreferrer",children:W.text}):W.text]},le))}):null]}):void 0,stats:ee,facts:pe,readAction:s,foot:t.jsx(Un,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(ge=e.appendix)==null?void 0:ge.map((W,le)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(W.title)}),t.jsx(Ft,{text:W.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},le))}),de=z.eras.length>=2?[{key:"",label:c("catalog.all")},...z.eras.map(W=>({key:W,label:`${W} ${z.allRows.filter(le=>le.era.era===W).length}`}))]:[],we=[];u.length&&we.push({id:"versions",label:c("workPage.sec.versions"),count:u.length}),ie.length&&we.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:ie.length}),P.length&&we.push({id:"collected",label:c("workPage.sec.collected"),count:P.length}),K.length&&we.push({id:"related",label:c("workPage.sec.related"),count:K.length}),te.length&&we.push({id:"resources",label:c("workPage.sec.resources"),count:te.length});const Te=u.length===0&&ie.length===0,Fe=t.jsxs(t.Fragment,{children:[u.length>0&&t.jsxs(lt,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(at,{items:[c("workPage.versionsTotal",{n:u.length-I}),_&&H?c("workPage.versionsWithImage",{n:H}):"",z.rows.length!==z.allRows.length?c("workPage.versionsCurrent",{n:z.rows.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":A&&de.length===0&&u.length>1?"":void 0,children:[de.length>0&&t.jsx(Ai,{items:de,value:y,onChange:W=>{$(W),k(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(mc,{label:c("workPage.scanOnly"),checked:b,onChange:W=>{w(W),k(!1)}}),t.jsx("span",{className:"bim-d-meta",children:c(T?"workPage.sortByYear":"workPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&Mi(z.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:M.map(W=>{var le;return t.jsx(Db,{row:W,measure:(le=m.get(W.id))==null?void 0:le.measure_info,loaded:m.has(W.id),onNavigate:i,renderLink:o},`${W.id}:${m.has(W.id)?"r":"p"}`)})})]}),M.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(fo,{total:z.rows.length,shown:M.length,unit:c("workPage.moreUnit"),onClick:()=>k(!0)}),z.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),ie.length>0&&t.jsx(Ub,{items:ie,transport:n,onNavigate:i,renderLink:o}),Te&&t.jsx(lt,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),re=(W,le)=>t.jsx(et,{id:W,label:p(le),onNavigate:i,renderLink:o,dense:!0}),B=g.useMemo(()=>{const W=new Map;for(const le of K){const q=Ra(le.relation,c);W.set(q,(W.get(q)??0)+1)}return W.size>1?[...W.entries()].sort((le,q)=>q[1]-le[1]).slice(0,4).map(([le,q])=>`${p(le)} ${q}`).join(" · "):void 0},[K,p,c]),V=t.jsxs(t.Fragment,{children:[t.jsx(rn,{id:"collected",title:c("workPage.sec.collected"),items:P.map(W=>re(W.id,W.title))}),t.jsx(rn,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:K.length}),sub:B,items:K.map(W=>t.jsxs(t.Fragment,{children:[re(W.id,W.title),t.jsx("span",{className:"bim-d-meta",title:W.note?p(W.note):void 0,children:p(Ra(W.relation,c))})]}))}),t.jsx(rn,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:te.map(({r:W,kind:le})=>{const q=p((W.url?bn(W.url):void 0)||W.name),D=yn(W);return t.jsxs(t.Fragment,{children:[D?t.jsxs("a",{href:D,target:"_blank",rel:"noopener noreferrer",children:[q," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:q}),le&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:le})]})})})]});return t.jsx(Hn,{railTop:a,back:l,nav:we,railLinks:d,main:Fe,card:je,side:V})};function Aa(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Ur(e,n){return n((e.url?bn(e.url):void 0)||e.name)}function Fb(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 Hb({copies:e,onNavigate:n,renderLink:i}){const{t:o,convert:s}=ne(),a=new Map;for(const l of e){const d=l.locationName||(l.holders[0]?Ur(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(g.Fragment,{children:[c>0?";":"",l?`${s(l)} `:"",d.map((p,h)=>t.jsxs(g.Fragment,{children:[h>0?" · ":"",t.jsx(et,{id:p.id,label:p.callNumber||p.id,onNavigate:n,renderLink:i,dense:!0})]},p.id))]},l||c))]})}function Db({row:e,measure:n,loaded:i,onNavigate:o,renderLink:s}){const{t:a,convert:l}=ne(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],h=e.copies??[],u=h.length&&e.locationName?l(e.locationName):p?Ur(p,l):e.locationName?l(e.locationName):"",m=e.images[0],f=m?yn(m):void 0,x=e.images.map(k=>Ur(k,l)).join("、");return t.jsxs("tr",{"data-loading":i?void 0:"",className:h.length?"bim-d-zt-group":void 0,children:[t.jsxs("td",{className:h.length?"bim-d-zt-main bim-d-zt-rep":"bim-d-zt-main",children:[t.jsx(et,{id:e.id,label:l(e.name),onNavigate:o,renderLink:s,dense:!0}),n?t.jsx("span",{className:"bim-d-meta",children:l(n)}):t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}),h.length>0&&e.summary&&t.jsx("span",{className:"bim-d-zt-summary",children:l(e.summary)}),h.length>0&&t.jsx(Hb,{copies:h,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${u?"":" bim-d-zt-blank"}`,children:[u||(i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),h.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 Ub({items:e,transport:n,onNavigate:i,renderLink:o}){const{t:s,convert:a}=ne(),[l,d]=g.useState(0),c=Math.min(l,e.length-1),p=e[c],[h,u]=g.useState(new Map);return g.useEffect(()=>{if(!n)return;const m=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(m.length===0)return;let f=!1;return Promise.all(m.map(x=>n.getItem(x).then(k=>{var y,$;return[x,(($=(y=k==null?void 0:k.authors)==null?void 0:y[0])==null?void 0:$.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{f||u(new Map(x.filter(([,k])=>k)))}),()=>{f=!0}},[n,e]),t.jsx(lt,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(at,{items:[s("workPage.catalog.meta",{n:e.length}),s("workPage.sortByCatalog")]}),children:t.jsxs("div",{className:"bim-d-lu",children:[t.jsx("ul",{className:"bim-d-tl2 bim-d-ui",role:"tablist","aria-label":s("workPage.catalog.tablist"),children:e.map((m,f)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":f===c,"aria-label":a(m.source),onClick:()=>d(f),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:h.get(m.source_bid??"")?a(h.get(m.source_bid??"")):" "}),t.jsx("i",{className:"bim-d-tl2-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-d-tl2-name","aria-hidden":"true",children:[...a(m.source)].slice(0,9).map((x,k)=>t.jsx("span",{children:x},k))})]})},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(at,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(et,{id:p.source_bid,label:a(p.source),onNavigate:i,renderLink:o,dense:!0}):a(p.source),p.section?a(p.section):"",p.author_info?`${s("label.authorInfo")} ${a(p.author_info)}`:"",p.edition?`${s("label.edition")} ${a(p.edition)}`:"",p.page??""]}),p.summary&&t.jsx("p",{className:"bim-d-quote",children:yt(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:yt(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:yt(a(p.additional_comment),void 0,{t:s})})]}),!p.summary&&!p.comment&&!p.additional_comment&&!p.title_info&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{marginTop:12},children:s("workPage.catalog.titleOnly")}),e.length>1&&t.jsxs("div",{className:"bim-d-lu-pager bim-d-ui",children:[c>0?t.jsx("button",{type:"button","aria-label":s("workPage.catalog.prev",{name:a(e[c-1].source)}),onClick:()=>d(c-1),children:t.jsxs("span",{"aria-hidden":"true",children:["← ",a(e[c-1].source)]})}):t.jsx("span",{"aria-hidden":"true"}),t.jsxs("span",{className:"bim-d-meta",children:[c+1," / ",e.length]}),c<e.length-1?t.jsx("button",{type:"button","aria-label":s("workPage.catalog.next",{name:a(e[c+1].source)}),onClick:()=>d(c+1),children:t.jsxs("span",{"aria-hidden":"true",children:[a(e[c+1].source)," →"]})}):t.jsx("span",{"aria-hidden":"true"})]})]})]})})}function Vb(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 Gb(e,n){if(!e.lineage)return null;const i=e.lineage;return{id:e.id,kind:"book",label:e.title,year:i.year,year_text:i.year_text,year_uncertain:i.year_uncertain,category:i.category,status:i.status,extant_juan:i.extant_juan,group:n[e.id],note:i.note}}function Ma(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 Yb(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 qb(e,n){var p;if(n==="all")return null;const i=(p=e.collections)==null?void 0:p[n],o=Array.isArray(i==null?void 0:i.groups)&&i.groups.length>0,s=Array.isArray(i==null?void 0:i.book_ids)&&i.book_ids.length>0,a=o||s||!!(i!=null&&i.hypothetical_ids);if(!a&&n==="core"&&Array.isArray(e.core_books)&&e.core_books.length>0)return{books:new Set(e.core_books),hypos:e.core_hypotheticals?new Set(e.core_hypotheticals):null};if(!i||!a)return null;const l=o?new Set(i.groups):null,d=new Set(i.book_ids??[]);if(l&&e.node_groups)for(const[h,u]of Object.entries(e.node_groups))l.has(u)&&d.add(h);let c=null;if(i.hypothetical_ids&&(c=new Set(i.hypothetical_ids)),l){c||(c=new Set);for(const h of e.hypothetical_nodes??[])h.group&&l.has(h.group)&&c.add(h.id)}return{books:d,hypos:c}}function fi(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=qb(o,i??o.default_collection??"all"),c=d!==null,p=(d==null?void 0:d.books)??null,h=(d==null?void 0:d.hypos)??null,u=new Set,m=new Set;if(c){const v=new Map(n.map(T=>[T.id,T])),j=new Map((o.hypothetical_nodes??[]).map(T=>[T.id,T])),C=T=>{const z=v.get(T);if(z&&z.lineage)return(z.lineage.derived_from??[]).map(H=>H.ref);const M=j.get(T);return M?(M.derived_from??[]).map(H=>H.ref):[]},S=T=>j.has(T)?!h||h.has(T):!p||p.has(T),_=new Set,A=T=>{if(!_.has(T)){_.add(T);for(const z of C(T))a.has(z)||(S(z)||(j.has(z)?m.add(z):v.has(z)&&u.add(z)),A(z))}};for(const T of n)p&&p.has(T.id)&&!a.has(T.id)&&A(T.id);for(const T of o.hypothetical_nodes??[])h&&h.has(T.id)&&A(T.id)}const f=n.filter(v=>!a.has(v.id)).filter(v=>!p||p.has(v.id)||u.has(v.id)).map(v=>{const j=Gb(v,l);return j&&u.has(v.id)&&(j.bridge=!0),j}).filter(v=>v!==null),x=(o.hypothetical_nodes??[]).filter(v=>!h||h.has(v.id)||m.has(v.id)).map(v=>{const j=Vb(v);return m.has(v.id)&&(j.bridge=!0),j}),k=[...f,...x],y=new Set(k.map(v=>v.id)),$=new Set,b=[],w=v=>{$.has(v.id)||!y.has(v.source)||!y.has(v.target)||($.add(v.id),b.push(v))};for(const v of n)a.has(v.id)||!v.lineage||p&&!p.has(v.id)&&!u.has(v.id)||((v.lineage.derived_from??[]).forEach((j,C)=>{w(Ma(v.id,j,C))}),(v.lineage.related_to??[]).forEach((j,C)=>{w(Yb(v.id,j,C))}));for(const v of o.hypothetical_nodes??[])h&&!h.has(v.id)&&!m.has(v.id)||(v.derived_from??[]).forEach((j,C)=>{w(Ma(v.id,j,C))});return{nodes:k,edges:b,groups:o.groups??[],title:o.title,description:o.description,layout:o.layout??"LR",excluded:Array.from(a)}}function kd(e,n,i){const o=(e??(n!=null?String(n):"")).trim();return o?!i||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(o)?o:`约 ${o}`:""}function Kb(e,n){const i=[],o=e.version_graph;if(!o)return i;const s=new Set(n.map(c=>c.id)),a=new Set((o.hypothetical_nodes??[]).map(c=>c.id)),l=new Set([...s,...a]),d=(c,p)=>{l.has(p.ref)||i.push(`${c}: derived_from.ref "${p.ref}" 未在 books 或 hypothetical_nodes 中找到`),p.ref_type==="book"&&!s.has(p.ref)&&i.push(`${c}: derived_from.ref "${p.ref}" 标记为 book 但不在 books 列表中`),p.ref_type==="hypothetical"&&!a.has(p.ref)&&i.push(`${c}: derived_from.ref "${p.ref}" 标记为 hypothetical 但不在 hypothetical_nodes 中`)};for(const c of n){if(!c.lineage)continue;const p=`Book ${c.id} (${c.title})`;(c.lineage.derived_from??[]).forEach(h=>d(p,h)),(c.lineage.related_to??[]).forEach(h=>{s.has(h.book_id)||i.push(`${p}: related_to.book_id "${h.book_id}" 不在 books 列表中`)})}for(const c of o.hypothetical_nodes??[]){const p=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(h=>d(p,h))}return i}const wd=({graph:e,renderLink:n,className:i,style:o})=>{const{t:s,convert:a}=ne();if(!e.nodes.length)return t.jsx("div",{style:{...cy,...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 k=d.get(x)??[];k.push(f),d.set(x,k)}const c=new Map(e.nodes.map(f=>[f.id,f])),p=new Map,h=[];for(const f of e.nodes)if(f.group){const x=p.get(f.group)??[];x.push(f),p.set(f.group,x)}else h.push(f);const u=(f,x)=>(f.year??9999)-(x.year??9999);p.forEach(f=>f.sort(u)),h.sort(u);const m=e.groups.filter(f=>p.has(f.id));return t.jsxs("div",{className:i,style:{...Zb,...o},children:[e.title&&t.jsx("div",{style:Jb,children:a(e.title)}),e.description&&t.jsx("div",{style:Qb,children:a(e.description)}),m.map(f=>t.jsx(Pa,{label:f.label,color:f.color,nodes:p.get(f.id),incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n},f.id)),h.length>0&&t.jsx(Pa,{label:s("lineage.otherGroup"),nodes:h,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},Pa=({label:e,color:n,nodes:i,incomingMap:o,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=ne();return t.jsxs("div",{style:ey,children:[t.jsx("div",{style:{...ty,borderLeftColor:n??r("widget-border")},children:d(e)}),i.map(c=>t.jsx(Xb,{node:c,incoming:o.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},Xb=({node:e,incoming:n,siblings:i,nodeMap:o,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=ne();return t.jsxs("div",{style:{...ny,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:iy,children:[t.jsx("span",{style:ry,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:oy,children:kd(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:sy,children:[e.category&&t.jsx(In,{children:c(e.category)}),e.status==="lost"&&t.jsx(In,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(In,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(In,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(In,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:ay,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:ly,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:Oa,children:[t.jsx("div",{style:Wa,children:d("lineage.sources")}),n.map(p=>{const h=o.get(p.source);return t.jsxs("div",{style:Fa(p.confidence),children:[t.jsx("span",{style:Ha,children:c(p.relation)}),t.jsx("span",{children:(h==null?void 0:h.kind)==="book"&&s?s(h.id,c(h.label)):c((h==null?void 0:h.label)??p.source)}),p.confidence!=="consensus"&&p.confidence!=="certain"&&t.jsx(Ba,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Da,children:["· ",c(p.evidence)]})]},p.id)})]}),i.length>0&&t.jsxs("div",{style:Oa,children:[t.jsx("div",{style:Wa,children:d("lineage.related")}),i.map(p=>{const h=p.source===e.id?p.target:p.source,u=o.get(h);return t.jsxs("div",{style:Fa(p.confidence),children:[t.jsx("span",{style:Ha,children:c(p.relation)}),t.jsx("span",{children:(u==null?void 0:u.kind)==="book"&&s?s(u.id,c(u.label)):c((u==null?void 0:u.label)??h)}),t.jsx(Ba,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Da,children:["· ",c(p.evidence)]})]},p.id)})]})]})},In=({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})},Ba=({level:e})=>{const{t:n}=ne(),o={certain:{key:"certain",color:r("confidence-certain")},consensus:{key:"consensus",color:r("confidence-consensus")},probable:{key:"probable",color:r("confidence-probable")},disputed:{key:"disputed",color:r("confidence-disputed")}}[e];return o?t.jsx("span",{style:{display:"inline-block",padding:"0 6px",fontSize:"10px",border:`1px solid ${o.color}`,color:o.color,borderRadius:"8px",marginLeft:"4px"},children:n(`lineage.confidence.${o.key}`)}):null},Zb={fontSize:"14px",color:r("fg")},Jb={fontSize:"16px",fontWeight:600,marginBottom:"8px"},Qb={fontSize:"13px",color:r("muted"),marginBottom:"16px",lineHeight:1.6},ey={marginBottom:"16px"},ty={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:r("fg")},ny={border:`1px solid ${r("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:r("bg")},iy={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},ry={fontSize:"15px",fontWeight:600},oy={fontSize:"12px",color:r("muted")},sy={marginBottom:"6px"},ay={fontSize:"12px",color:r("muted"),margin:"2px 0"},ly={fontSize:"12px",color:r("muted"),fontStyle:"italic",margin:"4px 0"},Oa={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${r("widget-border")}`},Wa={fontSize:"11px",color:r("muted"),marginBottom:"2px"},Fa=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),Ha={display:"inline-block",padding:"0 6px",fontSize:"11px",background:r("tag-bg"),color:r("fg"),borderRadius:"3px",marginRight:"6px"},Da={fontSize:"11px",color:r("muted")},cy={padding:"20px",textAlign:"center",color:r("muted"),fontSize:"13px"},Sd=({selectedNodeId:e,...n})=>{const{t:i}=ne(),[o,s]=g.useState("loading"),[a,l]=g.useState(null);return g.useEffect(()=>{let d=!1;return dy().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),o==="loading"?t.jsx("div",{style:Va,children:i("lineage.graphLoading")}):o==="missing"||!a?t.jsxs("div",{style:Va,children:[t.jsx("div",{children:Ua(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:Ua(i("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(py,{modules:a,selectedNodeId:e,...n})};function Ua(e,n){return e.split(/(\{\w+\})/).map((i,o)=>{const s=/^\{(\w+)\}$/.exec(i);return t.jsx(g.Fragment,{children:s&&s[1]in n?n[s[1]]:i},o)})}async function dy(){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 py=({graph:e,renderLink:n,height:i=600,className:o,style:s,selectedNodeId:a,modules:l})=>{const{ReactFlow:d,Background:c,Controls:p,Handle:h,Position:u,BaseEdge:m,EdgeLabelRenderer:f,getSmoothStepPath:x,dagre:k}=l,y=g.useMemo(()=>({lineage:C=>{var P,K,te,ie;const S=((P=C.data)==null?void 0:P.stepPosition)??.85,[_,A,T]=x({sourceX:C.sourceX,sourceY:C.sourceY,sourcePosition:C.sourcePosition,targetX:C.targetX,targetY:C.targetY,targetPosition:C.targetPosition,stepPosition:S,borderRadius:5}),z=!!((K=C.data)!=null&&K.isSibling),M=z?A:C.targetX-18,H=z?T:C.targetY-12,I=(te=C.data)==null?void 0:te.labelStyle,R=(ie=C.data)==null?void 0:ie.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(m,{id:C.id,path:_,style:C.style,markerStart:C.markerStart,markerEnd:C.markerEnd}),C.label&&t.jsx(f,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${M}px,${H}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,...I},children:C.label})})]})}}),[m,f,x]),$=g.useMemo(()=>({version:C=>{const{t:S}=ne(),_=C.data,A=_.kind==="hypothetical",T=_.status==="lost",z=_.isSelected,M=_.bridge,H=_.borderColor??r("muted"),I=M||A?"dashed":"solid",R=M?.5:T?.6:1;return t.jsxs("div",{style:{background:r(M?"bg-subtle":"bg"),border:`2px ${I} ${z?r("primary"):H}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:R,boxShadow:z?r("shadow-node-selected"):A||M?"none":r("shadow-node")},title:M?S("lineage.bridgeTitle"):void 0,children:[t.jsx(h,{type:"target",position:u.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:A||!_.renderLink?_.label:_.renderLink(_.bookId,_.label)}),_.description&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.25,marginTop:1},children:_.description}),_.yearText&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.2},children:kd(_.yearText,void 0,_.uncertain)}),T&&t.jsx("div",{style:{fontSize:9,color:r("lost-fg"),marginTop:1},children:S("lineage.lost")}),t.jsx(h,{type:"source",position:u.Right,style:{visibility:"hidden"}})]})}}),[h,u]),{convert:b}=ne(),{rfNodes:w,rfEdges:v}=g.useMemo(()=>uy(e,k,n,a,b),[e,k,n,a,b]);return t.jsx("div",{style:{width:"100%",height:i,...s},className:o,children:t.jsxs(d,{nodes:w,edges:v,nodeTypes:$,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 uy(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($=>[$.id,$.color??r("muted")]));for(const $ of e.nodes)c.setNode($.id,{width:160,height:90});const h=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const $ of e.edges)$.kind==="derive"&&(h.has($.relation)||c.setEdge($.source,$.target));n.layout(c);const u=e.nodes.map($=>{const b=c.node($.id),w=o?$.id===o:void 0,v={kind:$.kind,label:s($.label),bookId:$.kind==="book"?$.id:void 0,yearText:s($.year_text??hy($)),uncertain:$.year_uncertain,category:$.category,status:$.status,borderColor:$.group?p.get($.group):void 0,renderLink:i,isSelected:w,description:s($.description),bridge:$.bridge};return{id:$.id,type:"version",position:{x:b.x-160/2,y:b.y-90/2},data:v,draggable:!1,selected:w}}),m=.78,f=.06,x=new Map;for(const $ of e.edges)$.kind==="derive"&&(x.has($.source)||x.set($.source,[]),x.get($.source).push($));const k=new Map;for(const[$,b]of x){if(b.length<=1)continue;const w=[...b].sort((j,C)=>{var A,T;const S=((A=c.node(j.target))==null?void 0:A.y)??0,_=((T=c.node(C.target))==null?void 0:T.y)??0;return S-_}),v=w.length;w.forEach((j,C)=>{const S=(C-(v-1)/2)*f;k.set(j.id,m+S)})}const y=e.edges.map($=>my($,k.get($.id),s));return{rfNodes:u,rfEdges:y}}function my(e,n,i=o=>o??""){const o=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=gy(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 hy(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function gy(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 Va={padding:"40px 20px",textAlign:"center",color:r("muted"),fontSize:"13px",border:`1px dashed ${r("widget-border")}`,borderRadius:8,background:r("bg")},Vo=({graph:e,defaultMode:n="list",renderLink:i,graphHeight:o=600,selectedNodeId:s,onModeChange:a,collection:l,onCollectionChange:d,collectionsAvailable:c,collectionCounts:p,className:h,style:u})=>{var v;const{t:m,convert:f}=ne(),[x,k]=g.useState(n),y=j=>{k(j),a==null||a(j)},$=(()=>{if(!c)return[];const j=Object.entries(c);return j.length===0||c.all?j:[...j,["all",{label:m("lineage.collectionAll"),description:m("lineage.collectionAllDesc")}]]})(),b=!!(d&&$.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:r("muted"),textAlign:"center"},children:m("lineage.empty")});const w=l?(v=c==null?void 0:c[l])==null?void 0:v.description:void 0;return t.jsxs("div",{className:h,style:u,children:[t.jsxs("div",{style:fy,children:[t.jsx("button",{onClick:()=>y("list"),style:xr(x==="list"),children:m("lineage.modeList")}),t.jsx("button",{onClick:()=>y("graph"),style:xr(x==="graph"),children:m("lineage.modeGraph")}),b&&t.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:12,color:r("muted"),marginRight:4},children:m("lineage.collectionLabel")}),$.map(([j,C])=>{const S=p==null?void 0:p[j];return t.jsxs("button",{onClick:()=>d==null?void 0:d(j),style:xr(l===j),title:C.description?f(C.description):void 0,children:[f(C.label),S!=null?` ${S}`:""]},j)})]})]}),b&&w&&t.jsx("div",{style:{fontSize:12,color:r("muted"),marginBottom:8,padding:"4px 8px",background:r("bg-subtle"),borderRadius:4},children:f(w)}),x==="list"?t.jsx(wd,{graph:e,renderLink:i}):t.jsx(Sd,{graph:e,renderLink:i,height:o,selectedNodeId:s})]})},fy={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},xr=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"}),Ga=40,Ya=2,xy=9,by=new Set(["certain","consensus","probable","disputed"]);function br(e){if(!e)return["",""];const n=e.split(/[  ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const _d=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:h})=>{var se,ve,L,me,oe,be,_e,Ve,Ye,tt,Ze;const u=Ie(),{t:m,convert:f}=ne(),[x,k]=g.useState(null),[y,$]=g.useState(new Map),[b,w]=g.useState([]),[v,j]=g.useState(new Map),[C,S]=g.useState(!1),[_,A]=g.useState("flow"),[T,z]=g.useState(null);g.useEffect(()=>{if(!n||!e.work_id){k(null);return}let N=!1;return n.getItem(e.work_id).then(Y=>{!N&&Y&&Y.type==="work"&&k(Y)}).catch(()=>{}),()=>{N=!0}},[n,e.work_id]),g.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){z(null);return}let N=!1;return n.getLineageGraph(e.work_id).then(Y=>{N||z(Y&&Y.nodes.length>1?Y:null)}).catch(()=>{N||z(null)}),()=>{N=!0}},[n,e.work_id]),g.useEffect(()=>{const N=e._collections||[];if(!n||N.length===0){$(new Map);return}let Y=!1;return Promise.all(N.map(ce=>{const ye=ce.id;return n.getItem(ye).then(Ee=>[ye,Ee]).catch(()=>[ye,null])})).then(ce=>{if(Y)return;const ye=new Map;for(const[Ee,fe]of ce)fe&&ye.set(Ee,fe);$(ye)}),()=>{Y=!0}},[n,e._collections]);const M=g.useMemo(()=>{const N=new Set([...x?ho(x):[],...e.related_books||[]]);return N.add(e.id),[...N]},[x,e.related_books,e.id]),H=M.length-1;g.useEffect(()=>{if(!n||H<=0){w([]);return}const N=M.length<=Ga,Y=N?M:M.slice(0,8);let ce=!1;return Promise.all(Y.map(ye=>ye===e.id?Promise.resolve({id:ye,title:e.title,edition:e.edition,year:yi(e)}):n.getItem(ye).then(Ee=>{const fe=Ee??{};return{id:ye,title:fe.title,edition:fe.edition,year:Ee?yi(fe):void 0}}).catch(()=>({id:ye})))).then(ye=>{if(ce)return;const Ee=ye.filter(fe=>fe.id===e.id||fe.title||fe.edition);N&&Ee.sort((fe,Me)=>(fe.year??1/0)-(Me.year??1/0)),w(Ee)}),()=>{ce=!0}},[n,M,H,e]);const I=e.lineage,R=g.useMemo(()=>[...((I==null?void 0:I.derived_from)||[]).filter(N=>N.ref_type==="book").map(N=>N.ref),...((I==null?void 0:I.related_to)||[]).map(N=>N.book_id)].filter(Boolean),[I]);g.useEffect(()=>{if(!n||R.length===0){j(new Map);return}let N=!1;return Promise.all(R.map(Y=>n.getItem(Y).then(ce=>[Y,{id:Y,title:ce==null?void 0:ce.title,edition:ce==null?void 0:ce.edition}]).catch(()=>[Y,{id:Y}]))).then(Y=>{N||j(new Map(Y))}),()=>{N=!0}},[n,R]);const P=g.useMemo(()=>bd(e.resources,e.resource_groups,m),[e.resources,e.resource_groups,m]),K=P.groups.reduce((N,Y)=>N+Y.rows.length+Y.mirrors.length,0),te=P.groups.length>0&&P.groups.every(N=>N.key==="_physical"),ie=Fn(e),U=ac(e),pe=Ht(e,u.unit.juan),G=new Set((e._collections||[]).map(N=>Mn(N.vol).length).filter(N=>N>0)),ee=N=>{var ye;const Y=(ye=e.base_edition)==null?void 0:ye.find(Ee=>Ee.book_id===N&&Ee.name);if(Y!=null&&Y.name)return Y.name;const ce=v.get(N);return(ce==null?void 0:ce.edition)||(ce==null?void 0:ce.title)||""},ae=g.useMemo(()=>{var Z,ze,We,Oe,Re;const N=[];U&&N.push({label:m("bookPage.fact.editionType"),value:f(U),title:e.edition_type||(Z=e.lineage)!=null&&Z.category?void 0:m("bookPage.inferredFromEdition")}),(ze=e.publication_info)!=null&&ze.details?N.push({label:m("bookPage.fact.publication"),value:f(e.publication_info.details)}):(ie.era||ie.reign)&&N.push({label:m("bookPage.fact.era"),value:f([ie.era,ie.reign].filter(Boolean).join(" ")),title:ie.source==="edition"?m("bookPage.inferredFromEdition"):void 0}),pe&&N.push({label:m("bookPage.fact.measure"),value:f(pe)});const Y=(e._collections||[]).flatMap(xe=>Mn(xe.vol));Y.length&&N.push({label:m("bookPage.fact.volumes"),value:m("bookPage.volumesValue",{range:Li(Y,u.unit.volume),unit:u.unit.volume,n:Y.length})});const ce=(((We=e.lineage)==null?void 0:We.derived_from)||[]).find(xe=>xe.relation==="底本"&&xe.ref_type==="book");ce&&ee(ce.ref)&&N.push({label:m("bookPage.fact.baseEdition"),value:t.jsx(et,{id:ce.ref,label:f(ee(ce.ref)),onNavigate:i,renderLink:o,dense:!0})});const ye=(e.base_edition||[]).filter(xe=>xe&&xe.name);for(const xe of["底本","配補","參校"]){if(xe==="底本"&&ce&&ee(ce.ref))continue;const Be=ye.filter($e=>$e.role===xe);Be.length&&N.push({label:f(xe),value:Be.map(($e,Je)=>t.jsxs(g.Fragment,{children:[Je>0&&"、",$e.book_id?t.jsx(et,{id:$e.book_id,label:f($e.name),onNavigate:i,renderLink:o,dense:!0}):f($e.name)]},Je))})}const Ee=(e.provenance||[]).filter(xe=>xe&&xe.institution),fe=(e.resources||[]).filter(xe=>Wt(xe).includes("physical"));if(Ee.length){N.push({label:m("bookPage.fact.holdings"),value:Ee.slice(0,2).map($e=>f($e.institution)).join("、")+(Ee.length>2?m("bookPage.andMorePlaces",{n:Ee.length}):"")});const xe=Ee.filter($e=>$e.call_number).slice(0,2).map($e=>`${f($e.institution)} ${$e.call_number}`);xe.length&&N.push({label:m("bookPage.fact.callNumber"),value:xe.join(";")+(Ee.filter($e=>$e.call_number).length>2?"…":"")});const Be=Ee.flatMap($e=>$e.seals||[]).filter(Boolean);Be.length&&N.push({label:m("bookPage.fact.seals"),value:f(Be.join("、"))})}else fe.length?N.push({label:m("bookPage.fact.holdings"),value:fe.slice(0,2).map(xe=>f(xe.name)).join("、")+(fe.length>2?m("bookPage.andMorePlaces",{n:fe.length}):"")}):(Oe=e.current_location)!=null&&Oe.name&&N.push({label:m("bookPage.fact.holdings"),value:f(e.current_location.name)});const Me=e.physical_description;if(Me){const xe=[[m("bookPage.fact.leafStyle"),Me.leaf_style],[m("bookPage.fact.binding"),Me.binding],[m("bookPage.fact.dimensions"),Me.dimensions],[m("bookPage.fact.condition"),Me.condition]];for(const[Be,$e]of xe)$e&&$e.trim()&&N.push({label:Be,value:f($e)})}(Re=e.page_count)!=null&&Re.description&&N.push({label:u.label.pageCount,value:f(e.page_count.description)});const qe=[...Lr(e.additional_titles),...Lr(e.attached_texts)];return qe.length&&N.push({label:m("bookPage.fact.aliases"),value:qe.map(f).join("、")}),N},[e,f,u,m,ie,U,pe,v,i,o]),Se=f(e.title),O=e.edition?f(e.edition):void 0,je=((se=e.lineage)==null?void 0:se.year_text)||"",de=t.jsx(Dn,{kind:m("bookPage.kind"),title:Se,subtitle:O,byline:t.jsx(Do,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:i,renderLink:o}),meta:(()=>{const N=[U?f(U):"",ie.era?f([ie.era,ie.reign].filter(Boolean).join("")):"",pe?f(pe):""].filter(Boolean);return N.length?t.jsx("span",{className:"bim-d-tags",children:N.map((Y,ce)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(ce,2)}`,children:Y},ce))}):null})(),description:(ve=e.description)!=null&&ve.text?t.jsx(Ft,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:bo((L=e.description)==null?void 0:L.text)?6:void 0,facts:ae,readAction:s,secondaryAction:s&&K>0&&!te?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:m("bookPage.viewImages")}):void 0,foot:t.jsx(Un,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),we=e._collections||[],Te=(a==null?void 0:a.chapters)||[],Fe=f(Te[0]&&br(Te[0].title)[0].slice(-1)||"")||m("bookPage.chapterUnit"),re=m("bookPage.chapterCount",{n:Te.length,unit:Fe}),B=!!((me=I==null?void 0:I.derived_from)!=null&&me.length||(oe=I==null?void 0:I.related_to)!=null&&oe.length||(be=e.appendix)!=null&&be.length),V=[],he=m(te?"bookPage.sec.physical":"bookPage.sec.images");(Te.length||P.text.length||l)&&V.push({id:"fulltext",label:m("bookPage.sec.fulltext"),count:Te.length?re:void 0}),P.groups.length&&V.push({id:"images",label:he,count:K}),B&&V.push({id:"lineage",label:m("bookPage.sec.lineage")}),we.length&&V.push({id:"collections",label:m("section.containedIn"),count:we.length}),(_e=e.location_history)!=null&&_e.length&&V.push({id:"provenance",label:m("section.locationHistory")});const X=N=>(d==null?void 0:d(N))??null,ge=Te[0],W=ge?X(ge.file):null,le=C?Te:Te.slice(0,xy),q=(N,Y,ce)=>N?t.jsx("a",{className:ce,href:N.href??"#",onClick:N.onClick?ye=>{ye.metaKey||ye.ctrlKey||(ye.preventDefault(),N.onClick())}:void 0,children:Y}):t.jsx("span",{className:ce,children:Y}),D=t.jsxs(t.Fragment,{children:[(Te.length>0||P.text.length>0||l)&&t.jsxs(lt,{id:"fulltext",title:m("bookPage.sec.fulltext"),meta:Te.length>0?t.jsx(at,{items:[re,(Ve=a==null?void 0:a.source)!=null&&Ve.name?m("bookPage.sourceBy",{src:f(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!ge&&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"})]}),ge&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:m("bookPage.readFrom",{ch:f(br(ge.title)[0])||m("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:f((ge.title||"").replace(/^第.+?[回章卷篇節节][  ]*/,""))}),q(W,t.jsxs(t.Fragment,{children:[m("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),Te.length>1&&t.jsx("ul",{className:"bim-d-chap",children:le.map(N=>{const[Y,ce]=br(N.title);return t.jsx("li",{children:q(X(N.file),t.jsxs(t.Fragment,{children:[Y&&t.jsx("b",{children:f(Y)}),f(ce||N.file)]}))},N.file)})}),Te.length>le.length&&t.jsx(xo,{label:m("detail.expandRest",{n:Te.length-le.length,unit:Fe}),onClick:()=>S(!0)}),P.text.length>0&&t.jsxs(t.Fragment,{children:[(Te.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:m("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:P.text.map((N,Y)=>t.jsx(Uo,{item:N,siblings:P.text,listedVolumeCounts:G},`${N.id||N.url||N.name}-${Y}`))})})]})]}),P.groups.length>0&&t.jsx(lt,{id:"images",title:he,meta:t.jsx(at,{items:[P.groups.length>1?m("bookPage.groupCount",{n:P.groups.length}):"",m("bookPage.placeCount",{n:K})]}),children:t.jsx(jd,{groups:P.groups,listedVolumeCounts:G})}),B&&t.jsx(lt,{id:"lineage",title:m("bookPage.sec.lineage"),meta:(Ye=I==null?void 0:I.derived_from)!=null&&Ye.length?m("bookPage.lineageMeta"):void 0,action:T?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":m("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":_==="flow",onClick:()=>A("flow"),children:m("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":_==="graph",onClick:()=>A("graph"),children:m("bookPage.viewGraph")})]}):void 0,children:_==="graph"&&T?t.jsx(Vo,{graph:T,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(N,Y)=>t.jsx(et,{id:N,label:f(Y),onNavigate:i,renderLink:o,dense:!0})}):t.jsx(jy,{data:e,heading:O||Se,yearText:je,refName:ee,onNavigate:i,renderLink:o})}),we.length>0&&t.jsx(lt,{id:"collections",title:m("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:we.map((N,Y)=>{const ce=N.id,ye=Mn(N.vol),Ee=y.get(ce),fe=Nh(Ee);return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(et,{id:ce,label:Ee?f(Ee.title):ce,onNavigate:i,renderLink:o,dense:!0}),ye.length>0&&t.jsx(yy,{volumes:ye,unit:u.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${fe?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:fe>0&&m("bookPage.totalOf",{n:fe,unit:u.unit.bu})})]},`${ce}-${Y}`)})})})}),(tt=e.location_history)!=null&&tt.length?t.jsx(lt,{id:"provenance",title:m("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((N,Y)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:f(N.name)}),([N.start_date,N.end_date].filter(Boolean).join("—")||N.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(at,{items:[[N.start_date,N.end_date].filter(Boolean).join("—"),N.description?f(N.description):""]})})]},Y))})}):null,V.length===0&&t.jsx(lt,{title:m("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:m("bookPage.emptyText")})})]}),Q=b.findIndex(N=>N.id===e.id),Ce=M.length<=Ga,Le=Ce&&Q>=0?b.slice(Math.max(0,Q-Ya),Q+Ya+1):b.filter(N=>N.id!==e.id),Ae=t.jsxs(t.Fragment,{children:[x&&t.jsxs("div",{id:"work",className:"bim-d-side",style:{scrollMarginTop:16},children:[t.jsx("h2",{className:"bim-d-ui bim-d-side-h",children:f(u.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(et,{id:x.id,label:f(x.title),onNavigate:i,renderLink:o})}),t.jsx(at,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(N=>`${N.dynasty?`〔${f(N.dynasty)}〕`:""}${f(N.name)}`),f(Ht(x,u.unit.juan)),x._edition_count?m("bookPage.editionCount",{n:x._edition_count}):""]}),((Ze=x.description)==null?void 0:Ze.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,""))})]}),H>0&&Le.length>0&&t.jsxs("div",{children:[t.jsx(rn,{id:"siblings",timeline:!0,title:Ce?m("bookPage.siblings"):u.relation.siblingVersions,meta:Ce?m("bookPage.byEra"):m("bookPage.kindCount",{n:H}),cap:Le.length,items:Le.map(N=>N.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:f(N.edition||N.title||N.id)}):t.jsx(et,{id:N.id,label:f(N.edition||N.title||N.id),onNavigate:i,renderLink:o,dense:!0})),metas:Le.map(N=>[N.year!=null?N.year<0?m("detail.bce",{n:-N.year}):String(N.year):"",N.id===e.id?m("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:Le.findIndex(N=>N.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(et,{id:x.id,label:m("bookPage.viewAllInWork",{n:M.length}),onNavigate:i,renderLink:o,dense:!0})})]})]}),F=e.work_id?t.jsx(uc,{caption:u.section.belongsToWork,children:t.jsx(et,{id:e.work_id,label:x?f(x.title):" ",onNavigate:i,renderLink:o,dense:!0})}):void 0;return t.jsx(Hn,{railTop:c,back:p,up:F,nav:V,railLinks:h,main:D,card:de,side:Ae})};function yy({volumes:e,unit:n}){const{t:i}=ne();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[i("bookPage.volumeRange",{range:Li(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 jy({data:e,heading:n,yearText:i,refName:o,onNavigate:s,renderLink:a}){var $;const{t:l,convert:d}=ne(),c=e.lineage,p=(c==null?void 0:c.derived_from)||[],h=p.filter(b=>b.ref_type!=="book"),u=p.filter(b=>b.ref_type==="book"&&b.relation==="底本"),m=p.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),f=(c==null?void 0:c.related_to)||[],x=p.length>0||f.length>0,k=b=>b&&by.has(b)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${b}`)}):"",y=(b,w)=>t.jsx(et,{id:b,label:d(w||b),onNavigate:s,renderLink:a,dense:!0});return t.jsxs("div",{className:"bim-d-lf",children:[x&&t.jsxs("ol",{className:"bim-d-lf-list",children:[h.map((b,w)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:b.relation?d(b.relation):l("bookPage.lineage.ancestor")}),t.jsx("span",{className:"bim-d-lf-name",children:l("bookPage.lineage.reconstructed")}),b.evidence&&t.jsxs("span",{className:"bim-d-meta",children:[d(b.evidence),k(b.confidence)]})]})},`a-${w}`)),u.map((b,w)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-card",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,o(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),k(b.confidence)]})]})},`b-${w}`)),t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-cur",children:[t.jsxs("div",{className:"bim-d-lf-here",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:l("bookPage.lineage.thisEdition")}),t.jsx("span",{className:"bim-d-lf-name",children:n}),i&&t.jsx("span",{className:"bim-d-lf-yr",children:d(i)})]}),m.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:m.map((b,w)=>t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,o(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),k(b.confidence)]})]},w))})]}),f.length>0&&t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-out",children:[t.jsx("span",{className:"bim-d-lf-out-h bim-d-ui",children:l("bookPage.lineage.derivatives")}),t.jsx("span",{className:"bim-d-lf-chips",children:f.map((b,w)=>t.jsxs("span",{className:"bim-d-lf-chip",title:b.evidence?d(b.evidence):void 0,children:[y(b.book_id,o(b.book_id)),t.jsx("span",{className:"bim-d-meta",children:d(b.relation)})]},w))})]})]}),($=e.appendix)==null?void 0:$.map((b,w)=>t.jsxs("details",{className:"bim-d-lf-app",children:[t.jsxs("summary",{className:"bim-d-ui",children:[t.jsx("span",{className:"bim-d-meta",children:l("bookPage.lineage.appendix")})," ",d(b.title)]}),t.jsx(Ft,{text:b.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${w}`)),(c==null?void 0:c.note)&&t.jsx("p",{className:"bim-d-meta",style:{margin:"12px 0 0",maxWidth:"46em"},children:d(c.note)})]})}const En=16,vy=200,ky=16,$d=({data:e,catalog:n,transport:i,onNavigate:o,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var Q,Ce,Le,Ae,F,se,ve;const{t:p,convert:h,messages:u}=ne(),[m,f]=g.useState(""),[x,k]=g.useState(!1),[y,$]=g.useState(null),[b,w]=g.useState(""),[v,j]=g.useState(!1),C=g.useMemo(()=>oc(e,n),[e,n]),S=g.useMemo(()=>rc(e),[e]),[_,A]=g.useState(new Map),T=!!i&&C.rows.length>0&&C.rows.length<=vy,z=T&&(C.rows.length<=En||v),M=z&&C.rows.every(L=>!L.id||_.has(L.id)),H=L=>{var me;return Dr(L?(me=_.get(L))==null?void 0:me.l1:void 0)},I=g.useMemo(()=>{const L=m.trim(),me=L?h(L):"";return C.rows.filter(oe=>{var _e,Ve;if(b&&Dr(oe.id?(_e=_.get(oe.id))==null?void 0:_e.l1:void 0)!==b)return!1;if(!me)return!0;const be=oe.id&&((Ve=_.get(oe.id))==null?void 0:Ve.title)||oe.title;return h(be).includes(me)||(oe.subItems||[]).some(Ye=>h(Ye).includes(me))})},[C.rows,m,b,_,h]),R=x?I:I.slice(0,En),P=g.useMemo(()=>(z?C.rows:R).filter(L=>L.id&&!_.has(L.id)).map(L=>L.id),[z,C.rows,R,_]);g.useEffect(()=>{if(!i||P.length===0)return;let L=!1;const me=P.slice(0,ky);return Wi(me,Oi,oe=>i.getItem(oe).then(be=>{var Ye,tt;const _e=be??{},Ve={title:_e.title,edition:_e.edition,authors:_e.authors,measure:be?Ht(be,u.unit.juan):void 0,versionCount:_e._edition_count??((Ye=_e._books)==null?void 0:Ye.length),l1:((tt=go(_e))==null?void 0:tt.l1)||void 0};return[oe,Ve]}).catch(()=>[oe,{}]),()=>L).then(oe=>{L||A(be=>{const _e=new Map(be);for(const[Ve,Ye]of oe)_e.set(Ve,Ye);return _e})}),()=>{L=!0}},[i,P,u.unit.juan]);const K=(Q=(e.contained_in||[])[0])==null?void 0:Q.id;g.useEffect(()=>{if(!K){$(null);return}if($({id:K}),!i)return;let L=!1;return i.getItem(K).then(me=>{L||$({id:K,title:me==null?void 0:me.title})}).catch(()=>{}),()=>{L=!0}},[i,K]);const te=g.useMemo(()=>bd(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),ie=te.text.length+te.groups.reduce((L,me)=>L+me.rows.length+me.mirrors.length,0),U=S.works,pe=new Set(C.rows.map(L=>L.id).filter(Boolean)),G=U.length>0&&!U.every(L=>pe.has(L.id)),ee=(()=>{const L=C.rows.map(me=>me.edition).filter(Boolean);return L.length>1&&new Set(L).size===1})(),ae=C.rows.some(L=>L.volumes.length>0||L.expected!=null),Se=S.total,O=S.truncated?Se:C.rows.length,je=Ht(e,u.unit.juan),de=e.count,we=L=>typeof L=="number"&&Number.isFinite(L)?L:null,Te=we(de==null?void 0:de.juan)??we((Ce=e.juan_count)==null?void 0:Ce.number),Fe=we(de==null?void 0:de.ce)??(C.totalVolumes||null),re=[{value:O,label:p("collectionPage.stat.titles")},{value:Te??0,label:u.unit.juan},{value:Fe??0,label:u.unit.volume}],B=g.useMemo(()=>{var oe,be;const L=[];if((oe=e.publication_info)!=null&&oe.details&&L.push({label:p("collectionPage.fact.publication"),value:h(e.publication_info.details)}),Se&&(Se!==C.rows.length||S.truncated)){const _e=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");L.push({label:_e,value:`${Se} ${u.unit.bu}`,title:p("collectionPage.memberNote")})}const me=[we(de==null?void 0:de.zhong)!=null?p("collectionPage.nZhong",{n:de.zhong}):"",we(de==null?void 0:de.han)!=null?p("collectionPage.nHan",{n:de.han}):""].filter(Boolean);return me.length&&L.push({label:p("collectionPage.fact.expected"),value:me.join(" ")}),Te==null&&je&&L.push({label:p("collectionPage.fact.measure"),value:h(je),title:(be=e.juan_count)!=null&&be.description?h(e.juan_count.description):void 0}),L},[e,Se,S.truncated,C.rows.length,Te,je,de,h,p,u]),V=g.useMemo(()=>{if(!M)return[];const L=new Map;for(const oe of C.rows){const be=H(oe.id);be&&L.set(be,(L.get(be)??0)+1)}const me=Bn.filter(oe=>(L.get(oe.key)??0)>0);return me.length<2?[]:[{key:"",label:`${u.catalog.all} ${O}`},...me.map(oe=>({key:oe.key,label:`${oe.label} ${L.get(oe.key)}`}))]},[M,C.rows,_,u]),he=g.useMemo(()=>{if(!M||!C.rows.some(be=>be.volumes.length>0))return null;const L=[],me=C.rows.filter(be=>be.volumes.length>0).map(be=>({k:H(be.id)??"",from:Math.min(...be.volumes),to:Math.max(...be.volumes)})).sort((be,_e)=>be.from-_e.from);for(const be of me){const _e=be.to-be.from+1,Ve=L[L.length-1];Ve&&Ve.key===be.k?(Ve.to=Math.max(Ve.to,be.to),Ve.n+=_e):L.push({key:be.k,from:be.from,to:be.to,n:_e})}const oe=me.reduce((be,_e)=>Math.max(be,_e.to),0);return L.length>1&&L.some(be=>be.key)?{segs:L,last:oe}:null},[M,C.rows,_]),X=(Le=e.description)==null?void 0:Le.text,ge=t.jsx(Dn,{kind:p("collectionPage.kind"),title:h(e.title),byline:t.jsx(Do,{authors:e.authors,onNavigate:o,renderLink:s}),meta:t.jsx(at,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(Ae=e.publication_info)!=null&&Ae.year?h(e.publication_info.year):""]}),description:X||(F=e.history)!=null&&F.length?t.jsxs(t.Fragment,{children:[X&&t.jsx(Ft,{text:X,style:{fontSize:15,lineHeight:1.85}}),(se=e.history)!=null&&se.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((L,me)=>t.jsx("li",{children:h(L)},me))}):null]}):void 0,clampDescription:bo(X)||(((ve=e.history)==null?void 0:ve.length)??0)>2?6:void 0,stats:re,facts:B,foot:t.jsx(Un,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:he&&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:he.segs.map((L,me)=>{const oe=Bn.find(be=>be.key===L.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!oe,title:oe?p("collectionPage.dist.segTitle",{section:h(oe.label),from:L.from,to:L.to}):void 0,"aria-label":oe?p("collectionPage.dist.only",{section:h(oe.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!oe&&b===L.key,style:{flexGrow:L.n,background:r(oe?oe.token:"rule")},onClick:()=>{oe&&(w(b===L.key?"":L.key),k(!1))}},me)})}),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:he.last})})]})]})}),W=[];C.rows.length&&W.push({id:"titles",label:p("collectionPage.sec.titles"),count:O}),ie&&W.push({id:"resources",label:p("collectionPage.sec.resources"),count:ie}),G&&W.push({id:"works",label:u.section.containedWorks,count:U.length});const le=t.jsxs(t.Fragment,{children:[C.rows.length>0&&t.jsxs(lt,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(at,{items:[`${O} ${u.unit.items}`,C.totalVolumes?p("collectionPage.totalVolumes",{n:C.totalVolumes,unit:u.unit.volume}):"",I.length!==O?p("collectionPage.currentN",{n:I.length,unit:u.unit.items}):""]}),action:a,children:[(C.rows.length>En||V.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[V.length>0&&t.jsx(Ai,{items:V,value:b,onChange:L=>{w(L),k(!1)}}),T&&C.rows.length>En&&!M&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:v,onClick:()=>j(!0),title:p("collectionPage.loadAllTitle",{n:C.rows.length,unit:u.unit.items}),children:p(v?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),C.rows.length>En&&t.jsx("input",{type:"search",className:"bim-d-find",value:m,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:L=>{f(L.target.value),k(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Mi(I.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[ae&&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((L,me)=>{var Ze;const oe=L.id?_.get(L.id):void 0,be=oe!=null&&oe.title&&L.title===L.id?oe.title:L.title,_e=((oe==null?void 0:oe.authors)||[]).find(N=>N&&N.name),Ve=[_e?`${_e.dynasty?`〔${h(_e.dynasty)}〕`:""}${h(_e.name)}${_e.role?` ${h(_e.role)}`:""}`:"",oe!=null&&oe.measure?h(oe.measure):"",(Ze=L.subItems)!=null&&Ze.length?L.subItems.map(N=>h(N)).join("、"):"",(oe!=null&&oe.edition||L.edition)&&!ee?h((oe==null?void 0:oe.edition)||L.edition||""):""].filter(Boolean),Ye=Bn.find(N=>N.key===H(L.id)),tt=L.volumes.length>0?p("collectionPage.volumeRange",{range:Li(L.volumes,u.unit.volume),unit:u.unit.volume}):L.expected!=null?`${L.found??0}/${L.expected} ${u.unit.volume}`:"";return t.jsxs("tr",{children:[ae&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${tt?"":" bim-d-zt-blank"}`,children:[Ye&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:r(Ye.token)}}),tt||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[L.id?t.jsx(et,{id:L.id,label:h(be),onNavigate:o,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:h(be)}),Ve.length>0?t.jsx(at,{items:Ve}):L.id&&!oe&&i?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${oe!=null&&oe.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:oe!=null&&oe.versionCount?p("collectionPage.nZhong",{n:oe.versionCount}):""})]},`${L.id??L.title}-${me}`)})})]}),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(fo,{total:I.length,shown:R.length,unit:u.unit.items,onClick:()=>k(!0)})]}),ie>0&&t.jsxs(lt,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:ie}),children:[te.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[te.groups.length>0&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:p("collectionPage.text")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:te.text.map((L,me)=>t.jsx(Uo,{item:L,siblings:te.text},`${L.id||L.url||L.name}-${me}`))})})]}),t.jsx(jd,{groups:te.groups})]}),C.rows.length===0&&ie===0&&t.jsx(lt,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),q=G?t.jsx(rn,{id:"works",title:u.section.containedWorks,meta:p("collectionPage.nZhong",{n:U.length}),cap:12,items:U.map(L=>t.jsx(et,{id:L.id,label:h(L.title),onNavigate:o,renderLink:s,dense:!0}))}):null,D=y?t.jsx(uc,{caption:p("collectionPage.parent"),children:t.jsx(et,{id:y.id,label:h(y.title||y.id),onNavigate:o,renderLink:s,dense:!0})}):void 0;return t.jsx(Hn,{railTop:l,back:d,up:D,nav:W,railLinks:c,main:le,card:ge,side:q})},wy=8;function Cd(e){return typeof e!="string"||!e||e.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.split("/").some(n=>n==="..")?null:e}function Sy(e){return(e||[]).filter(n=>{var i,o;return Cd(n==null?void 0:n.file)&&((i=n.credit)==null?void 0:i.trim())&&((o=n.license)==null?void 0:o.trim())}).slice(0,wy)}function _y({images:e,assetBase:n,name:i}){const{t:o,convert:s}=ne(),[a,l]=g.useState(0),[d,c]=g.useState(!1),p=n?Sy(e):[];if(!n||d||p.length===0)return null;const h=n.endsWith("/")?n:n+"/",u=p[Math.min(a,p.length-1)],m=u.width&&u.height&&u.width>0&&u.height>0?`${u.width} / ${u.height}`:void 0,f=x=>h+Cd(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(u),alt:o("entityPage.sealAlt",{name:i})+(p.length>1?` ${a+1}`:""),style:m?{"--seal-ar":m}:void 0,width:u.width,height:u.height,decoding:"async",fetchPriority:"high",onError:()=>c(!0)},u.file),p.length>1&&t.jsx("div",{className:"bim-d-seal-thumbs",children:p.map((x,k)=>t.jsx("button",{type:"button","aria-pressed":k===a,"aria-label":`${o("entityPage.sealAlt",{name:i})} ${k+1}`,onClick:()=>l(k),children:t.jsx("img",{src:f(x),alt:"",loading:"lazy",decoding:"async"})},x.file))}),t.jsxs("figcaption",{children:[o("entityPage.imgCredit",{credit:s(u.credit)})," · ",o("entityPage.imgLicense",{license:s(u.license)}),u.source_url&&/^https?:\/\//i.test(u.source_url)&&t.jsxs(t.Fragment,{children:[" · ",t.jsx("a",{href:u.source_url,target:"_blank",rel:"noopener noreferrer nofollow",children:o("entityPage.imgSource")})]}),u.note&&t.jsxs(t.Fragment,{children:[" · ",s(u.note)]})]})]})}const $y=16,yr=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function qa(e){if(!e)return yr.length;const n=yr.indexOf(e);return n===-1?yr.length:n}function Cy(e,n,i){if(n)return e[n]??i(n)}function zy(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const Ty={秦:[-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]},zd=({data:e,transport:n,onNavigate:i,renderLink:o,railTop:s,back:a,railLinks:l,assetBase:d})=>{var D,Q,Ce,Le,Ae;const{t:c,convert:p,messages:h}=ne(),u=F=>zy(F,c),[m,f]=g.useState("全部"),[x,k]=g.useState(!1),[y,$]=g.useState("default"),[b,w]=g.useState(new Map),v=g.useMemo(()=>e._works||[],[e._works]),j=g.useMemo(()=>v.map(F=>{const se=b.get(F.work_id);return{id:F.work_id,title:(se==null?void 0:se.title)??F.title??F.work_id,role:F.role||"",cls:uo(F.role),versionCount:se==null?void 0:se.versionCount,section:se==null?void 0:se.cls,l1:se==null?void 0:se.l1,measure:se==null?void 0:se.measure,hasImage:se==null?void 0:se.hasImage,loaded:!!(se!=null&&se.loaded)}}),[v,b]),C=g.useMemo(()=>ic(v.map(F=>F.role),c("detail.roleAll")),[v,c]),S=g.useMemo(()=>{const F=m==="全部"?j:j.filter(se=>se.cls===m);return y==="versions"?[...F].sort((se,ve)=>(ve.versionCount??-1)-(se.versionCount??-1)):F},[j,m,y]),_=x?S:S.slice(0,$y),A=g.useMemo(()=>_.filter(F=>!b.has(F.id)).map(F=>F.id),[_,b]);g.useEffect(()=>{if(!n||A.length===0)return;let F=!1;return Wi(A,Oi,se=>n.getItem(se).then(ve=>{var _e;const L=ve??{},me=L._edition_count??((_e=L._books)==null?void 0:_e.length)??0,oe=go(L),be=[oe==null?void 0:oe.l1,oe==null?void 0:oe.l2].filter(Boolean).join(" ");return[se,{id:se,title:L.title,versionCount:me,loaded:!0,cls:be||void 0,l1:(oe==null?void 0:oe.l1)||void 0,measure:ve&&Ht(ve,h.unit.juan)||void 0,hasImage:!!L._has_image}]}).catch(()=>[se,{id:se,loaded:!0}]),()=>F).then(se=>{F||w(ve=>{const L=new Map(ve);for(const[me,oe]of se)L.set(me,oe);return L})}),()=>{F=!0}},[n,A,h.unit.juan]);const T=g.useMemo(()=>{const F=new Map;for(const se of e.alt_names||[]){const ve=se.type||h.section.aliases;F.has(ve)||F.set(ve,[]),F.get(ve).push(se.name)}return[...F.entries()].sort((se,ve)=>qa(se[0])-qa(ve[0])).map(([se,ve])=>({label:se,names:ve}))},[e.alt_names,h]),z=((D=e.dates)==null?void 0:D.birth)??void 0,M=((Q=e.dates)==null?void 0:Q.death)??void 0,H=(Ce=e.dates)==null?void 0:Ce.floruit,I=z!=null||M!=null?`${u(z)||"?"}—${u(M)||"?"}`:Array.isArray(H)&&H.length===2&&H.every(F=>Number.isFinite(F))?c("entityPage.floruit",{from:u(H[0]),to:u(H[1])}):"",R=new Set(["本名","字","號","号"]),P=T.filter(F=>R.has(F.label)),K=T.filter(F=>!R.has(F.label)),te=K.reduce((F,se)=>F+se.names.length,0),ie=g.useMemo(()=>{const F=[];for(const ve of P)F.push({label:ve.label,value:ve.names.map(L=>p(L)).join("、")});const se=v.length;return se&&F.push({label:c("entityPage.fact.works"),value:c("entityPage.nZhong",{n:se})}),F},[v,P,p,c]),U=F=>{var se;return(se=T.find(ve=>F.includes(ve.label)))==null?void 0:se.names[0]},pe=U(["字"]),G=U(["號","号"]),ee=[pe?c("entityPage.zi",{name:p(pe)}):"",G?c("entityPage.hao",{name:p(G)}):""].filter(Boolean).join(","),ae=e.native_place,Se=e.dynasty?Ty[e.dynasty]:void 0,O=(()=>{if(!Se||z==null||M==null||M<z)return null;const[F,se]=Se,ve=Math.max(z,F),L=Math.min(M,se);if(L<=ve)return null;const me=se-F;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:u(z),death:u(M),years:M-z+1}),children:t.jsx("i",{style:{left:`${(ve-F)/me*100}%`,width:`${(L-ve)/me*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${u(F)} ${p(e.dynasty)}`}),t.jsx("span",{children:c("entityPage.lifeYears",{years:M-z+1})}),t.jsx("span",{children:u(se)})]})]})})(),je=g.useMemo(()=>{if(!n||j.length===0||j.some(ve=>!ve.loaded))return null;const F=new Map;for(const ve of j){const L=Dr(ve.l1);L&&F.set(L,(F.get(L)??0)+1)}const se=Bn.map(ve=>({...ve,n:F.get(ve.key)??0})).filter(ve=>ve.n>0);return se.length?se:null},[j,n]),de=t.jsxs(Dn,{kind:Cy(h.entityPage.subtype,e.subtype,p),title:p(e.primary_name||e.title),subtitle:ee||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(at,{items:[e.dynasty?p(e.dynasty):"",I,ae?c("entityPage.nativePlace",{place:p(ae)}):""]}),O,t.jsx(_y,{images:e.images,assetBase:d,name:p(e.primary_name||e.title)})]}),description:(Le=e.description)!=null&&Le.text?t.jsx(Ft,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:bo((Ae=e.description)==null?void 0:Ae.text)?6:void 0,facts:ie,foot:t.jsx(Un,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[te>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:c("entityPage.moreNames",{n:te})}),t.jsx("dl",{children:K.map(F=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:p(F.label)}),t.jsx("dd",{children:F.names.map(se=>p(se)).join("、")})]},F.label))})]}),je&&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:je.map(F=>t.jsx("i",{style:{flexGrow:F.n,background:r(F.token)}},F.key))}),t.jsx("div",{className:"bim-d-dist-key",children:je.map(F=>t.jsxs("span",{children:[t.jsx("i",{style:{background:r(F.token)}}),p(F.label)," ",F.n]},F.key))})]})]}),we=g.useMemo(()=>j.filter(F=>F.loaded&&(F.versionCount??0)>0).sort((F,se)=>(se.versionCount??0)-(F.versionCount??0)).slice(0,3),[j]),Te=!!n&&j.length>=3&&_.some(F=>!F.loaded),Fe=m==="全部"&&(Te||we.length>=2),re=e.external_ids||{},B=[];re.cbdb_id!=null&&B.push({label:"CBDB",id:String(re.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${re.cbdb_id}`,note:re.cbdb_match==="auto"?c("entityPage.autoMatch"):void 0});const V=re.wikidata_id;V&&B.push({label:"Wikidata",id:V,href:`https://www.wikidata.org/wiki/${V}`});const he=re.viaf_id;he&&B.push({label:"VIAF",id:he,href:`https://viaf.org/viaf/${he}`});const X=C.map(F=>({key:F.cls,label:`${F.label} ${F.count}`})),ge=[...Fe&&!Te?[{id:"featured",label:c("entityPage.sec.featured"),count:we.length}]:[],...j.length?[{id:"works",label:c("entityPage.sec.allWorks"),count:j.length}]:[],...B.length?[{id:"external",label:c("entityPage.sec.external"),count:B.length}]:[]],W=Fe?t.jsxs(lt,{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":Te||void 0,children:[Te&&[0,1,2].map(F=>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:" "})]},F)),!Te&&we.map(F=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(et,{id:F.id,label:p(F.title),onNavigate:i,renderLink:o,dense:!0})}),t.jsx(at,{items:[F.section?p(F.section):"",F.measure?p(F.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:F.versionCount}),t.jsx("span",{children:c("entityPage.versionsUnit")}),F.hasImage&&t.jsx("span",{className:"bim-d-flag",children:c("entityPage.hasImage")})]})]},F.id))]})]}):null,le=j.length===0?t.jsx(lt,{title:c("entityPage.sec.works"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("entityPage.empty")})}):t.jsxs(t.Fragment,{children:[W,t.jsxs(lt,{id:"works",title:c("entityPage.sec.works"),meta:t.jsx(at,{items:[c("entityPage.total",{n:j.length}),S.length!==j.length?c("entityPage.current",{n:S.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[X.length>1&&t.jsx(Ai,{items:X,value:m,onChange:F=>{f(F),k(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":y==="versions",onClick:()=>{y==="default"&&k(!0),$(F=>F==="default"?"versions":"default")},children:c(y==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Mi(S.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:_.map(F=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(et,{id:F.id,label:p(F.title),onNavigate:i,renderLink:o,dense:!0}),F.measure?t.jsx(at,{items:[p(F.measure)]}):!F.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${F.section||F.loaded?"":" bim-d-zt-blank"}`,children:F.section?p(F.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${F.role?"":" bim-d-zt-blank"}`,children:F.role?p(F.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${F.loaded?"":" bim-d-zt-blank"}`,children:F.loaded?F.versionCount?c("entityPage.nZhong",{n:F.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:c("entityPage.notRecorded")}):""}),t.jsx("td",{className:F.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:F.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:c("entityPage.hasImage")})})]},F.id))})]}),_.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c("entityPage.emptyRole")}),!x&&t.jsx(fo,{total:S.length,shown:_.length,unit:c("entityPage.moreUnit"),onClick:()=>k(!0)})]})]}),q=B.length>0?t.jsx(rn,{id:"external",title:c("entityPage.sec.external"),items:B.map(F=>t.jsxs("a",{href:F.href,target:"_blank",rel:"noopener noreferrer",children:[F.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:B.map(F=>F.id),foot:re.cbdb_id!=null&&re.cbdb_match==="auto"?c("entityPage.cbdbAuto"):void 0}):null;return t.jsx(Hn,{railTop:s,back:a,nav:ge,railLinks:l,main:le,card:de,side:q})},Go="(max-width: 719px)",Ny=`${Go}, (pointer: coarse)`,Td=`
1362
1369
  .bim-ct {
1363
1370
  display: grid; grid-template-columns: 248px minmax(0, 1fr); column-gap: 32px; align-items: start;
1364
1371
  max-width: 1440px; margin: 0 auto; padding: 20px 32px 48px; box-sizing: border-box;
@@ -1466,7 +1473,7 @@ ${B??""}`,[Qe,$t]=g.useState({key:De,data:Y,started:!!Y});if(Qe.key!==De)$t({key
1466
1473
  .bim-ct-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
1467
1474
  }
1468
1475
 
1469
- @media ${Vo} {
1476
+ @media ${Go} {
1470
1477
  .bim-ct { display: block; padding: 12px 16px 40px; }
1471
1478
  .bim-ct-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
1472
1479
  .bim-ct-lrow > a { grid-template-columns: minmax(0, 1fr); }
@@ -1491,7 +1498,7 @@ ${B??""}`,[Qe,$t]=g.useState({key:De,data:Y,started:!!Y});if(Qe.key!==De)$t({key
1491
1498
  }
1492
1499
 
1493
1500
  /* 点击目标 ≥44px(Q5):触屏与窄屏 */
1494
- @media ${Sy} {
1501
+ @media ${Ny} {
1495
1502
  .bim-ct-row { min-height: 44px; }
1496
1503
  .bim-ct-tw { width: 44px; }
1497
1504
  .bim-ct-pg { min-width: 44px; height: 44px; }
@@ -1517,7 +1524,7 @@ ${B??""}`,[Qe,$t]=g.useState({key:De,data:Y,started:!!Y});if(Qe.key!==De)$t({key
1517
1524
  /* 窄屏分类抽屉:界栏下按钮和面板都有框 */
1518
1525
  :root[data-layout="boxed"] .bim-ct-drawer-btn { border: ${r("fr-bd")}; background: ${r("fr-bg")}; }
1519
1526
  :root[data-layout="boxed"] .bim-ct-drawer { border: ${r("fr-bd")}; }
1520
- `,nn="未分類",Bt="all",Go=20;function Gn(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 _y(e){const n=Gn(e);return n.length?n.join("/"):nn}function $y(e){const n=Gn(e);return n.length?n.map((i,o)=>n.slice(0,o+1).join("/")):[nn]}function Cy(e,n=[]){const i=new Map;n.forEach((d,c)=>{const p=[d.cata_l1,d.cata_l2,d.cata_l3,d.cata_l4].filter(h=>!!h);p.forEach((h,u)=>{const m=p.slice(0,u+1).join("/");i.has(m)||i.set(m,c)})});const o=new Map;let s=0;for(const d of e){const c=Gn(d.classification);if(!c.length){s++;continue}let p=o;c.forEach((h,u)=>{const m=c.slice(0,u+1).join("/");let f=p.get(h);f||(f={id:m,label:h,count:0,children:new Map},p.set(h,f)),f.count++,p=f.children})}const a=d=>[...d.values()].sort((c,p)=>{const h=c.label===nn?1:0,u=p.label===nn?1:0;if(h!==u)return h-u;const m=i.get(c.id)??1/0,f=i.get(p.id)??1/0;return m!==f?m-f:c.label.localeCompare(p.label,"zh")}).map(c=>{const p={id:c.id,label:c.label,count:c.count};return c.children.size&&(p.children=a(c.children)),p}),l=a(o);return s>0&&l.push({id:nn,label:nn,count:s}),l}function mn(e,n){if(!n)return[];for(const i of e){if(i.id===n)return[i];if(i.children){const o=mn(i.children,n);if(o.length)return[i,...o]}}return[]}function Yo(e){return e.reduce((n,i)=>n+i.count,0)}function zy(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function Ty(e){var d;const n={id:e.id,title:e.title||e.id},i=e.juan_count,o=typeof i=="number"?i:i==null?void 0:i.number;typeof o=="number"&&o>0?n.juan=o:e.measure_info&&(n.juan=e.measure_info);const s=(e.authors??[]).filter(c=>c==null?void 0:c.name).map(c=>{const p=c.dynasty||(e.authors.length===1?e.dynasty:void 0);return p?{name:c.name,dynasty:p}:{name:c.name}});s.length&&(n.authors=s);const a=zy(typeof e.description=="string"?e.description:(d=e.description)==null?void 0:d.text);a&&(n.summary=a);const l=Gn(e.classification);return l.length&&(n.classification=l),n}function Ny(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 Iy(e,n=Go){return Math.max(1,Math.ceil(e/n))}function Nd(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 Ey=()=>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 Ry(e,n,i){const o=[];i&&o.push({id:Bt,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 Id({tree:e,selectedId:n,onSelect:i,allLabel:o,label:s}){const{t:a,convert:l}=te(),d=o===void 0?a("catalogPage.all"):o,c=s??a("catalogPage.classification"),p=g.useRef(null),h=n&&n!==Bt?n:null,u=d!==null,[m,f]=g.useState(()=>{const _=new Set;for(const L of mn(e,h))_.add(L.id);return _});g.useEffect(()=>{const _=mn(e,h);_.length&&f(L=>{if(_.every(z=>L.has(z.id)))return L;const T=new Set(L);for(const z of _)T.add(z.id);return T})},[e,h]);const x=g.useMemo(()=>Ry(e,m,u),[e,m,u]),[k,y]=g.useState(null);g.useEffect(()=>{y(null)},[n]);const $=h??(u?Bt:null),b=g.useMemo(()=>{var T;const _=new Set(x.map(z=>z.id));if(k&&_.has(k))return k;if($&&_.has($))return $;const L=mn(e,h).map(z=>z.id).filter(z=>_.has(z));return L.length?L[L.length-1]:((T=x[0])==null?void 0:T.id)??null},[x,k,$,e,h]),w=g.useCallback((_,L)=>{f(T=>{const z=T.has(_),M=L??!z;if(M===z)return T;const H=new Set(T);return M?H.add(_):H.delete(_),H})},[]),v=g.useCallback(_=>{y(_),requestAnimationFrame(()=>{var T;const L=Array.from(((T=p.current)==null?void 0:T.querySelectorAll("[data-ct-id]"))??[]).find(z=>z.dataset.ctId===_);L==null||L.focus()})},[]),j=g.useCallback((_,L)=>{L&&w(_,!0),i(_)},[i,w]),C=g.useCallback(_=>{const L=_.target.closest("[data-ct-id]");if(!L)return;const T=L.dataset.ctId,z=x.findIndex(N=>N.id===T);if(z<0)return;const M=x[z];let H=null;switch(_.key){case"ArrowDown":H=x[Math.min(x.length-1,z+1)].id;break;case"ArrowUp":H=x[Math.max(0,z-1)].id;break;case"Home":H=x[0].id;break;case"End":H=x[x.length-1].id;break;case"ArrowRight":if(!M.hasChildren)break;m.has(T)?H=M.firstChildId:w(T,!0);break;case"ArrowLeft":M.hasChildren&&m.has(T)?w(T,!1):H=M.parentId;break;case"Enter":case" ":_.preventDefault(),j(T,M.hasChildren);return;default:return}_.preventDefault(),H&&H!==T&&v(H)},[x,m,w,v,j]),S=(_,L)=>_.map((T,z)=>{var A;const M=(A=T.children)!=null&&A.length?T.children:null,H=!!M&&m.has(T.id),N=T.id===h,R=L===1&&_.length>1&&z===_.length-1;return t.jsxs("li",{role:"treeitem","aria-level":L,"aria-expanded":M?H:void 0,"aria-selected":N,tabIndex:b===T.id?0:-1,"data-ct-id":T.id,className:R?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":L-1},onClick:()=>{y(T.id),j(T.id,!!M)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:M?J=>{J.stopPropagation(),y(T.id),w(T.id)}:void 0,children:M?t.jsx(Ey,{}):null}),t.jsx("span",{className:"bim-ct-lb",children:l(T.label)}),t.jsx("span",{className:"bim-ct-n",children:T.count.toLocaleString("en-US")})]}),H&&t.jsx("ul",{role:"group",children:S(M,L+1)})]},T.id)});return t.jsxs("ul",{ref:p,role:"tree","aria-label":l(c),className:"bim-ct-tree",onKeyDown:C,children:[u&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!h,tabIndex:b===Bt?0:-1,"data-ct-id":Bt,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(Bt),i(Bt)},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:Yo(e).toLocaleString("en-US")})]})}),S(e,1)]})}const Ed=e=>`/item/${encodeURIComponent(e)}`;function Ly(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function Rd(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function Ld({work:e,href:n}){var d,c;const{t:i,convert:o}=te(),s=Rd(e.juan,i),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-card",children:t.jsxs("a",{href:n,children:[t.jsxs("div",{className:"bim-ct-ch",children:[t.jsx("h2",{className:"bim-ct-ct",children:o(e.title)}),s&&t.jsx("span",{className:"bim-ct-juan",children:o(s)})]}),a.length>0&&t.jsx("span",{className:"bim-ct-by",children:a.map((p,h)=>t.jsxs(g.Fragment,{children:[h>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},h))}),e.summary&&t.jsx("p",{className:"bim-ct-sum",children:o(e.summary)}),l.length>0&&t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function Ad({work:e,href:n}){var d,c;const{t:i,convert:o}=te(),s=Rd(e.juan,i),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-lrow",children:t.jsxs("a",{href:n,children:[t.jsxs("span",{className:"bim-ct-lt",children:[o(e.title),s&&t.jsx("span",{className:"bim-ct-juan",children:o(s)})]}),t.jsx("span",{className:"bim-ct-by",children:a.map((p,h)=>t.jsxs(g.Fragment,{children:[h>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},h))}),t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function Md({page:e,pageCount:n,onPage:i,pageHref:o,label:s}){const{t:a,convert:l}=te();if(n<=1)return null;const d=p=>h=>{i&&(o&&!Ly(h)||(h.preventDefault(),i(p)))},c=(p,h,u)=>{if(u.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:h});const m={className:"bim-ct-pg","aria-current":u.current?"page":void 0,"aria-label":u.aria};return o?t.jsx("a",{...m,href:o(p),onClick:d(p),children:h}):t.jsx("button",{type:"button",...m,onClick:u.current?void 0:d(p),children:h})};return t.jsxs("nav",{className:"bim-ct-pager","aria-label":s?l(s):a("catalogPage.pagerLabel"),children:[c(e-1,a("catalogPage.prevPage"),{disabled:e<=1}),t.jsx("ol",{children:Nd(e,n).map((p,h)=>t.jsx("li",{style:{display:"contents"},children:p===null?t.jsx("span",{className:"bim-ct-gap","aria-hidden":"true",children:"…"}):c(p,p,{current:p===e,aria:a("catalogPage.pageN",{n:p})})},p??`gap${h}`))}),t.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[e," / ",n]}),c(e+1,a("catalogPage.nextPage"),{disabled:e>=n})]})}function Pd({works:e,workLink:n=Ed,emptyText:i,view:o="card",...s}){const{t:a,convert:l}=te();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(Ad,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(Ld,{work:d,href:n(d.id)},d.id))}),t.jsx(Md,{...s})]})}const Ay=()=>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 My({tree:e,selectedId:n,page:i,pageCount:o,works:s,onSelect:a,onPage:l,searchSlot:d,workLink:c,pageHref:p,allLabel:h,allTitle:u,pageSize:m=Go,className:f,view:x,onViewChange:k}){const{t:y,convert:$}=te(),b=h===void 0?y("catalogPage.all"):h,w=u??y("catalogPage.allTitle"),j=`bim-ct-drawer-${g.useId().replace(/:/g,"")}`,[C,S]=g.useState(!1),[_,L]=g.useState("card"),T=x??_,z=J=>{L(J),k==null||k(J)},M=mn(e,n&&n!==Bt?n:null),H=M.length?M[M.length-1]:null,N=H?H.label:w,R=H?H.count:Yo(e),A=g.useCallback(J=>{S(!1),a(J)},[a]);return t.jsxs("div",{className:f?`bim-ct ${f}`:"bim-ct","data-drawer":C?"open":"closed",children:[t.jsx("style",{children:Td}),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":C,"aria-controls":j,onClick:()=>S(J=>!J),children:[t.jsx("span",{children:y("catalogPage.drawerLabel",{path:$(M.length?M.map(J=>J.label).join(" › "):b??w)})}),t.jsx(Ay,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:j,children:[t.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),t.jsx(Id,{tree:e,selectedId:n,onSelect:A,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:$(N)}),M.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:$(M.slice(0,-1).map(J=>J.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:R.toLocaleString("en-US"),size:m}),o>1&&y("catalogPage.statPage",{page:i,pages:o})]}),t.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":y("catalogPage.viewLabel"),children:[t.jsx("button",{type:"button","aria-pressed":T==="card",onClick:()=>z("card"),children:y("catalogPage.viewCard")}),t.jsx("button",{type:"button","aria-pressed":T==="list",onClick:()=>z("list"),children:y("catalogPage.viewList")})]})]}),d&&t.jsx("div",{className:"bim-ct-search",children:d}),t.jsx(Pd,{works:s,view:T,workLink:c,page:i,pageCount:o,onPage:l,pageHref:p})]})]})}const Yn="(max-width: 719px)",Py="(max-width: 1079px)",By=`${Yn}, (pointer: coarse)`,Wy=[8,18,30,42,88],qo=`
1527
+ `,nn="未分類",Bt="all",Yo=20;function Gn(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 Iy(e){const n=Gn(e);return n.length?n.join("/"):nn}function Ey(e){const n=Gn(e);return n.length?n.map((i,o)=>n.slice(0,o+1).join("/")):[nn]}function Ry(e,n=[]){const i=new Map;n.forEach((d,c)=>{const p=[d.cata_l1,d.cata_l2,d.cata_l3,d.cata_l4].filter(h=>!!h);p.forEach((h,u)=>{const m=p.slice(0,u+1).join("/");i.has(m)||i.set(m,c)})});const o=new Map;let s=0;for(const d of e){const c=Gn(d.classification);if(!c.length){s++;continue}let p=o;c.forEach((h,u)=>{const m=c.slice(0,u+1).join("/");let f=p.get(h);f||(f={id:m,label:h,count:0,children:new Map},p.set(h,f)),f.count++,p=f.children})}const a=d=>[...d.values()].sort((c,p)=>{const h=c.label===nn?1:0,u=p.label===nn?1:0;if(h!==u)return h-u;const m=i.get(c.id)??1/0,f=i.get(p.id)??1/0;return m!==f?m-f:c.label.localeCompare(p.label,"zh")}).map(c=>{const p={id:c.id,label:c.label,count:c.count};return c.children.size&&(p.children=a(c.children)),p}),l=a(o);return s>0&&l.push({id:nn,label:nn,count:s}),l}function mn(e,n){if(!n)return[];for(const i of e){if(i.id===n)return[i];if(i.children){const o=mn(i.children,n);if(o.length)return[i,...o]}}return[]}function qo(e){return e.reduce((n,i)=>n+i.count,0)}function Ly(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function Ay(e){var d;const n={id:e.id,title:e.title||e.id},i=e.juan_count,o=typeof i=="number"?i:i==null?void 0:i.number;typeof o=="number"&&o>0?n.juan=o:e.measure_info&&(n.juan=e.measure_info);const s=(e.authors??[]).filter(c=>c==null?void 0:c.name).map(c=>{const p=c.dynasty||(e.authors.length===1?e.dynasty:void 0);return p?{name:c.name,dynasty:p}:{name:c.name}});s.length&&(n.authors=s);const a=Ly(typeof e.description=="string"?e.description:(d=e.description)==null?void 0:d.text);a&&(n.summary=a);const l=Gn(e.classification);return l.length&&(n.classification=l),n}function My(e,n){const i=e.summary?0:1,o=n.summary?0:1;return i!==o?i-o:e.title.localeCompare(n.title,"zh")}function Py(e,n=Yo){return Math.max(1,Math.ceil(e/n))}function Nd(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 By=()=>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 Oy(e,n,i){const o=[];i&&o.push({id:Bt,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 Id({tree:e,selectedId:n,onSelect:i,allLabel:o,label:s}){const{t:a,convert:l}=ne(),d=o===void 0?a("catalogPage.all"):o,c=s??a("catalogPage.classification"),p=g.useRef(null),h=n&&n!==Bt?n:null,u=d!==null,[m,f]=g.useState(()=>{const _=new Set;for(const A of mn(e,h))_.add(A.id);return _});g.useEffect(()=>{const _=mn(e,h);_.length&&f(A=>{if(_.every(z=>A.has(z.id)))return A;const T=new Set(A);for(const z of _)T.add(z.id);return T})},[e,h]);const x=g.useMemo(()=>Oy(e,m,u),[e,m,u]),[k,y]=g.useState(null);g.useEffect(()=>{y(null)},[n]);const $=h??(u?Bt:null),b=g.useMemo(()=>{var T;const _=new Set(x.map(z=>z.id));if(k&&_.has(k))return k;if($&&_.has($))return $;const A=mn(e,h).map(z=>z.id).filter(z=>_.has(z));return A.length?A[A.length-1]:((T=x[0])==null?void 0:T.id)??null},[x,k,$,e,h]),w=g.useCallback((_,A)=>{f(T=>{const z=T.has(_),M=A??!z;if(M===z)return T;const H=new Set(T);return M?H.add(_):H.delete(_),H})},[]),v=g.useCallback(_=>{y(_),requestAnimationFrame(()=>{var T;const A=Array.from(((T=p.current)==null?void 0:T.querySelectorAll("[data-ct-id]"))??[]).find(z=>z.dataset.ctId===_);A==null||A.focus()})},[]),j=g.useCallback((_,A)=>{A&&w(_,!0),i(_)},[i,w]),C=g.useCallback(_=>{const A=_.target.closest("[data-ct-id]");if(!A)return;const T=A.dataset.ctId,z=x.findIndex(I=>I.id===T);if(z<0)return;const M=x[z];let H=null;switch(_.key){case"ArrowDown":H=x[Math.min(x.length-1,z+1)].id;break;case"ArrowUp":H=x[Math.max(0,z-1)].id;break;case"Home":H=x[0].id;break;case"End":H=x[x.length-1].id;break;case"ArrowRight":if(!M.hasChildren)break;m.has(T)?H=M.firstChildId:w(T,!0);break;case"ArrowLeft":M.hasChildren&&m.has(T)?w(T,!1):H=M.parentId;break;case"Enter":case" ":_.preventDefault(),j(T,M.hasChildren);return;default:return}_.preventDefault(),H&&H!==T&&v(H)},[x,m,w,v,j]),S=(_,A)=>_.map((T,z)=>{var P;const M=(P=T.children)!=null&&P.length?T.children:null,H=!!M&&m.has(T.id),I=T.id===h,R=A===1&&_.length>1&&z===_.length-1;return t.jsxs("li",{role:"treeitem","aria-level":A,"aria-expanded":M?H:void 0,"aria-selected":I,tabIndex:b===T.id?0:-1,"data-ct-id":T.id,className:R?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":A-1},onClick:()=>{y(T.id),j(T.id,!!M)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:M?K=>{K.stopPropagation(),y(T.id),w(T.id)}:void 0,children:M?t.jsx(By,{}):null}),t.jsx("span",{className:"bim-ct-lb",children:l(T.label)}),t.jsx("span",{className:"bim-ct-n",children:T.count.toLocaleString("en-US")})]}),H&&t.jsx("ul",{role:"group",children:S(M,A+1)})]},T.id)});return t.jsxs("ul",{ref:p,role:"tree","aria-label":l(c),className:"bim-ct-tree",onKeyDown:C,children:[u&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!h,tabIndex:b===Bt?0:-1,"data-ct-id":Bt,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(Bt),i(Bt)},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:qo(e).toLocaleString("en-US")})]})}),S(e,1)]})}const Ed=e=>`/item/${encodeURIComponent(e)}`;function Wy(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function Rd(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function Ld({work:e,href:n}){var d,c;const{t:i,convert:o}=ne(),s=Rd(e.juan,i),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-card",children:t.jsxs("a",{href:n,children:[t.jsxs("div",{className:"bim-ct-ch",children:[t.jsx("h2",{className:"bim-ct-ct",children:o(e.title)}),s&&t.jsx("span",{className:"bim-ct-juan",children:o(s)})]}),a.length>0&&t.jsx("span",{className:"bim-ct-by",children:a.map((p,h)=>t.jsxs(g.Fragment,{children:[h>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},h))}),e.summary&&t.jsx("p",{className:"bim-ct-sum",children:o(e.summary)}),l.length>0&&t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function Ad({work:e,href:n}){var d,c;const{t:i,convert:o}=ne(),s=Rd(e.juan,i),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-lrow",children:t.jsxs("a",{href:n,children:[t.jsxs("span",{className:"bim-ct-lt",children:[o(e.title),s&&t.jsx("span",{className:"bim-ct-juan",children:o(s)})]}),t.jsx("span",{className:"bim-ct-by",children:a.map((p,h)=>t.jsxs(g.Fragment,{children:[h>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},h))}),t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function Md({page:e,pageCount:n,onPage:i,pageHref:o,label:s}){const{t:a,convert:l}=ne();if(n<=1)return null;const d=p=>h=>{i&&(o&&!Wy(h)||(h.preventDefault(),i(p)))},c=(p,h,u)=>{if(u.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:h});const m={className:"bim-ct-pg","aria-current":u.current?"page":void 0,"aria-label":u.aria};return o?t.jsx("a",{...m,href:o(p),onClick:d(p),children:h}):t.jsx("button",{type:"button",...m,onClick:u.current?void 0:d(p),children:h})};return t.jsxs("nav",{className:"bim-ct-pager","aria-label":s?l(s):a("catalogPage.pagerLabel"),children:[c(e-1,a("catalogPage.prevPage"),{disabled:e<=1}),t.jsx("ol",{children:Nd(e,n).map((p,h)=>t.jsx("li",{style:{display:"contents"},children:p===null?t.jsx("span",{className:"bim-ct-gap","aria-hidden":"true",children:"…"}):c(p,p,{current:p===e,aria:a("catalogPage.pageN",{n:p})})},p??`gap${h}`))}),t.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[e," / ",n]}),c(e+1,a("catalogPage.nextPage"),{disabled:e>=n})]})}function Pd({works:e,workLink:n=Ed,emptyText:i,view:o="card",...s}){const{t:a,convert:l}=ne();return t.jsxs("div",{className:"bim-ct-works",children:[e.length===0?t.jsx("p",{className:"bim-ct-empty",children:i===void 0?a("catalogPage.emptyWorks"):typeof i=="string"?l(i):i}):o==="list"?t.jsx("ul",{className:"bim-ct-list",children:e.map(d=>t.jsx(Ad,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(Ld,{work:d,href:n(d.id)},d.id))}),t.jsx(Md,{...s})]})}const Fy=()=>t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:t.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Hy({tree:e,selectedId:n,page:i,pageCount:o,works:s,onSelect:a,onPage:l,searchSlot:d,workLink:c,pageHref:p,allLabel:h,allTitle:u,pageSize:m=Yo,className:f,view:x,onViewChange:k}){const{t:y,convert:$}=ne(),b=h===void 0?y("catalogPage.all"):h,w=u??y("catalogPage.allTitle"),j=`bim-ct-drawer-${g.useId().replace(/:/g,"")}`,[C,S]=g.useState(!1),[_,A]=g.useState("card"),T=x??_,z=K=>{A(K),k==null||k(K)},M=mn(e,n&&n!==Bt?n:null),H=M.length?M[M.length-1]:null,I=H?H.label:w,R=H?H.count:qo(e),P=g.useCallback(K=>{S(!1),a(K)},[a]);return t.jsxs("div",{className:f?`bim-ct ${f}`:"bim-ct","data-drawer":C?"open":"closed",children:[t.jsx("style",{children:Td}),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":C,"aria-controls":j,onClick:()=>S(K=>!K),children:[t.jsx("span",{children:y("catalogPage.drawerLabel",{path:$(M.length?M.map(K=>K.label).join(" › "):b??w)})}),t.jsx(Fy,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:j,children:[t.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),t.jsx(Id,{tree:e,selectedId:n,onSelect:P,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:$(I)}),M.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:$(M.slice(0,-1).map(K=>K.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:R.toLocaleString("en-US"),size:m}),o>1&&y("catalogPage.statPage",{page:i,pages:o})]}),t.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":y("catalogPage.viewLabel"),children:[t.jsx("button",{type:"button","aria-pressed":T==="card",onClick:()=>z("card"),children:y("catalogPage.viewCard")}),t.jsx("button",{type:"button","aria-pressed":T==="list",onClick:()=>z("list"),children:y("catalogPage.viewList")})]})]}),d&&t.jsx("div",{className:"bim-ct-search",children:d}),t.jsx(Pd,{works:s,view:T,workLink:c,page:i,pageCount:o,onPage:l,pageHref:p})]})]})}const Yn="(max-width: 719px)",Dy="(max-width: 1079px)",Uy=`${Yn}, (pointer: coarse)`,Vy=[8,18,30,42,88],Ko=`
1521
1528
  .bim-rh { color: ${r("ink")}; font-family: ${r("font-ui")}; font-size: 14px; line-height: 1.6; }
1522
1529
  .bim-rh *, .bim-rh *::before, .bim-rh *::after { box-sizing: border-box; }
1523
1530
  .bim-rh a { color: ${r("accent")}; text-decoration: none; }
@@ -1665,7 +1672,7 @@ ${B??""}`,[Qe,$t]=g.useState({key:De,data:Y,started:!!Y});if(Qe.key!==De)$t({key
1665
1672
  flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 8px; overflow: hidden;
1666
1673
  color: ${r("ink")} !important; font-size: 13px;
1667
1674
  }
1668
- ${Wy.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb, ${r("accent")} ${e}%, ${r("card-bg")}); }`).join(`
1675
+ ${Vy.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb, ${r("accent")} ${e}%, ${r("card-bg")}); }`).join(`
1669
1676
  `)}
1670
1677
  .bim-rh-band a[data-k="4"] { color: ${r("page-bg")} !important; }
1671
1678
  .bim-rh-band a:hover { outline: 2px solid ${r("ink")}; outline-offset: -2px; }
@@ -1693,7 +1700,7 @@ ${Wy.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1693
1700
  }
1694
1701
 
1695
1702
  /* ── 中屏 ── */
1696
- @media ${Py} {
1703
+ @media ${Dy} {
1697
1704
  .bim-rh-picks, .bim-rh-works, .bim-rh-groups, .bim-rh-bu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
1698
1705
  .bim-rh-authors { grid-template-columns: repeat(3, minmax(0, 1fr)); }
1699
1706
  }
@@ -1736,7 +1743,7 @@ ${Wy.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1736
1743
  }
1737
1744
 
1738
1745
  /* 触屏或窄屏:点击目标放大到 44px */
1739
- @media ${By} {
1746
+ @media ${Uy} {
1740
1747
  .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; }
1741
1748
  .bim-rh-chip { display: inline-flex; }
1742
1749
  }
@@ -1747,7 +1754,7 @@ ${Wy.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1747
1754
  }
1748
1755
 
1749
1756
  @media (prefers-reduced-motion: reduce) { .bim-rh * { scroll-behavior: auto !important; transition: none !important; } }
1750
- `,Oy=Jr["zh-Hant"].period,Bd={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function qt(e){return{...Bd,...e??{}}}function Ko(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 Hi(e){return(e.authors??[]).filter(i=>i==null?void 0:i.name).map(i=>i.dynasty?`〔${i.dynasty}〕${i.name}`:i.name).join(" ")}function Wd(e,n=Jr["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 Od(e){return Math.max(150,Array.from(e).length*18+44)}function Fd(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 Hd=.04;function Ke(e){return e.toLocaleString("en-US")}function Dd({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,i)=>t.jsx("span",{children:n},i))})}function mt({id:e,title:n,sub:i,more:o,children:s}){const{convert:a}=te(),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 Ud({counts:e}){const{t:n}=te();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:Ke(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:Ke(e.pieces)}),n("readHome.pieces")]})]})}function Vd({picks:e,links:n}){const{t:i,convert:o}=te(),s=qt(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=Hi(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(Dd,{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 Gd(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function Xo({topic:e,links:n,hint:i,legendCount:o,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=te(),c=qt(n);if(!e.items.length)return null;const p=o===void 0?l("readHome.shelfLegendCount"):o,h=Wd(e.items,l("readHome.shelfOther")),u=m=>{const f=m.records?Ke(m.records):Gd(m.text_count,l),x=Ko(m),k=[d(m.title),m.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",m.records?l("readHome.spineRecords",{n:f}):f?l("readHome.spineOnSite",{n:f}):""].filter(Boolean).join(",");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-spine",href:c.read(m.id),"data-orig":m.orig?"":void 0,"aria-label":k,title:k,style:{height:Od(m.title)},children:[t.jsx(Dd,{text:d(m.title)}),f&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":m.records?"":void 0,children:f})]})},m.id)};return t.jsxs("div",{className:"bim-rh-shelf-box",children:[s&&t.jsxs("h3",{className:"bim-rh-gt",children:[d(e.label),t.jsx("small",{children:i?d(i):l("readHome.shelfHint")})]}),t.jsx("div",{className:"bim-rh-shelf-wrap",tabIndex:0,role:"region","aria-label":l("readHome.shelfRegion",{label:d(e.label)}),children:t.jsx("ul",{className:"bim-rh-shelf",children:h.map(m=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(m.label),children:m.items.map(u)}),t.jsx("span",{"aria-hidden":"true",children:d(m.label)})]},m.label))})}),t.jsxs("p",{className:"bim-rh-legend",children:[t.jsxs("span",{children:[t.jsx("i",{"data-orig":"","aria-hidden":"true"}),l("readHome.origZhi")]}),t.jsxs("span",{children:[t.jsx("i",{"aria-hidden":"true"}),l("readHome.laterZhi")]}),p&&t.jsx("span",{children:d(p)}),a==null?void 0:a.map(m=>t.jsx("span",{children:d(m)},m))]})]})}const Fy=4,On=e=>e>Fy+1;function Yd({topic:e,links:n}){const{t:i,convert:o}=te(),s=qt(n),[a,l]=g.useState(!1);if(!e.items.length)return null;const d=`bim-rh-g-${e.key}`;return t.jsxs("div",{className:"bim-rh-grp","data-cap":On(e.items.length)?"":void 0,"data-open":a?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",id:d,children:[o(e.label),t.jsx("small",{className:"bim-rh-num",children:i("readHome.nWorks",{n:Ke(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=Gd(c.text_count,i),h=Ko(c);return t.jsx("li",{children:t.jsxs("a",{href:s.read(c.id),children:[t.jsx("span",{className:"bim-rh-t",children:o(c.title)}),p&&t.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:p}),h&&t.jsx("small",{children:o(h)})]})},c.id)})}),On(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 qd({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(Xo,{topic:s,links:n},s.key)),o.length>0&&t.jsx("div",{className:"bim-rh-groups",children:o.map(s=>t.jsx(Yd,{topic:s,links:n},s.key))})]})}function Kd({famous:e,links:n}){const{t:i,convert:o}=te(),s=qt(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 Zo({bu:e,unclassified:n,links:i,unclassifiedNote:o}){const{t:s,convert:a}=te(),l=qt(i);return!e.length&&!n?null:t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-bu",children:e.map(d=>{var p;const c=((p=d.top[0])==null?void 0:p.count)||1;return t.jsxs("li",{className:"bim-rh-bu-c",children:[t.jsxs("a",{className:"bim-rh-bu-h",href:l.node(d.id),children:[t.jsx("b",{children:a(d.label)}),t.jsx("span",{className:"bim-rh-num",children:s("readHome.nWorks",{n:Ke(d.count)})})]}),d.top.length>0&&t.jsx("ul",{className:"bim-rh-bu-l","aria-label":s("readHome.subClasses",{label:a(d.label)}),children:d.top.map(h=>t.jsx("li",{children:t.jsxs("a",{href:l.node(h.id),children:[t.jsx("span",{children:a(h.label)}),t.jsx("small",{className:"bim-rh-num",children:Ke(h.count)}),t.jsx("span",{className:"bim-rh-bar","aria-hidden":"true",style:{"--bimrh-w":`${Math.round(h.count/c*100)}%`}})]})},h.id))}),d.children_total>d.top.length&&t.jsx("a",{className:"bim-rh-bu-more",href:l.node(d.id),children:s("readHome.allNClasses",{label:a(d.label),n:d.children_total})})]},d.id)})}),!!n&&t.jsxs("p",{className:"bim-rh-uncl bim-rh-num",children:[t.jsx("b",{children:s("readHome.unclassified")}),t.jsx("span",{children:s("readHome.nWorks",{n:Ke(n)})}),t.jsx("span",{children:o?a(o):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function Xd({periods:e,unknown:n,links:i}){const{t:o,convert:s,messages:a}=te(),l=a.readHome.period,d=qt(i),c=e.filter(u=>u.count>0);if(!c.length)return null;const p=c.reduce((u,m)=>u+m.count,0),h=Math.max(...c.map(u=>u.count));return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-band",children:c.map(u=>{const m=u.label?s(u.label):l[u.key]??s(u.key),f=u.count/p,x=o("readHome.periodItem",{label:m,n:Ke(u.count)});return t.jsx("li",{style:{flex:`0 0 ${(f*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(u.key),"data-k":Fd(u.count,h),"data-narrow":f<Hd?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:m}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(m)[0]}),t.jsx("small",{className:"bim-rh-num",children:Ke(u.count)})]})},u.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:o("readHome.periodUnknown",{n:Ke(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:o("readHome.hoverHint")})]})]})}function Zd({authors:e,links:n}){const{t:i,convert:o}=te(),s=qt(n);return e.length?t.jsx("ul",{className:"bim-rh-authors",children:e.map(a=>t.jsxs("li",{className:"bim-rh-au",children:[t.jsxs("h3",{className:"bim-rh-au-h",children:[o(a.name),a.dynasty&&t.jsx("span",{children:o(a.dynasty)}),t.jsx("small",{className:"bim-rh-num",children:i("readHome.nPieces",{n:Ke(a.count)})})]}),t.jsx("ul",{children:a.items.map(l=>t.jsx("li",{children:t.jsx("a",{href:s.read(l.id),children:o(l.title)})},l.id))}),s.author&&t.jsx("a",{className:"bim-rh-more",href:s.author(a.name),children:i("readHome.authorAll",{name:o(a.name),n:a.count})})]},a.name))}):null}const Jd={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function Hy({sections:e,links:n,head:i,piecesMoreHref:o,className:s}){const{t:a}=te(),l=e,d=Jd,c=l.topics.filter(m=>!m.shelf),p={picks:l.picks.length>0,topics:c.some(m=>m.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(m=>m.count>0),pieces:l.pieces.authors.length>0},h=Object.keys(d).filter(m=>p[m]),u=m=>a(`readHome.nav.${m}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:qo}),t.jsxs("div",{className:"bim-rh-head",children:[i,t.jsx(Ud,{counts:l.counts})]}),h.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":a("readHome.navLabel"),children:t.jsx("ul",{children:h.map(m=>t.jsx("li",{children:t.jsx("a",{href:`#${d[m]}`,children:u(m)})},m))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(mt,{id:d.picks,title:u("picks"),sub:a("readHome.picksSub"),children:t.jsx(Vd,{picks:l.picks,links:n})}),p.topics&&t.jsx(mt,{id:d.topics,title:u("topics"),sub:a("readHome.topicsSub"),children:t.jsx(qd,{topics:c,links:n})}),p.famous&&t.jsx(mt,{id:d.famous,title:u("famous"),sub:a("readHome.famousSub"),children:t.jsx(Kd,{famous:l.famous,links:n})}),p.sibu&&t.jsx(mt,{id:d.sibu,title:u("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(Zo,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(mt,{id:d.period,title:u("period"),sub:a("readHome.periodSub"),children:t.jsx(Xd,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(mt,{id:d.pieces,title:u("pieces"),sub:a("readHome.piecesSub"),more:o?t.jsx("a",{className:"bim-rh-more",href:o,children:a("readHome.piecesMore")}):void 0,children:t.jsx(Zd,{authors:l.pieces.authors,links:n})})]})]})}const Dy="(max-width: 1079px)",Uy=`${Yn}, (pointer: coarse)`,Qd=`
1757
+ `,Gy=Qr["zh-Hant"].period,Bd={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function qt(e){return{...Bd,...e??{}}}function Xo(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 Hi(e){return(e.authors??[]).filter(i=>i==null?void 0:i.name).map(i=>i.dynasty?`〔${i.dynasty}〕${i.name}`:i.name).join(" ")}function Od(e,n=Qr["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 Wd(e){return Math.max(150,Array.from(e).length*18+44)}function Fd(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 Hd=.04;function Ke(e){return e.toLocaleString("en-US")}function Dd({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,i)=>t.jsx("span",{children:n},i))})}function mt({id:e,title:n,sub:i,more:o,children:s}){const{convert:a}=ne(),l=`${e}-h`;return t.jsxs("section",{className:"bim-rh-sec",id:e,"aria-labelledby":l,children:[t.jsxs("div",{className:"bim-rh-hd",children:[t.jsx("h2",{id:l,children:a(n)}),i&&t.jsx("span",{className:"bim-rh-sub",children:i}),o]}),t.jsx("div",{className:"bim-rh-bd",children:s})]})}function Ud({counts:e}){const{t:n}=ne();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:Ke(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:Ke(e.pieces)}),n("readHome.pieces")]})]})}function Vd({picks:e,links:n}){const{t:i,convert:o}=ne(),s=qt(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=Hi(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(Dd,{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 Gd(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function Zo({topic:e,links:n,hint:i,legendCount:o,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=ne(),c=qt(n);if(!e.items.length)return null;const p=o===void 0?l("readHome.shelfLegendCount"):o,h=Od(e.items,l("readHome.shelfOther")),u=m=>{const f=m.records?Ke(m.records):Gd(m.text_count,l),x=Xo(m),k=[d(m.title),m.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",m.records?l("readHome.spineRecords",{n:f}):f?l("readHome.spineOnSite",{n:f}):""].filter(Boolean).join(",");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-spine",href:c.read(m.id),"data-orig":m.orig?"":void 0,"aria-label":k,title:k,style:{height:Wd(m.title)},children:[t.jsx(Dd,{text:d(m.title)}),f&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":m.records?"":void 0,children:f})]})},m.id)};return t.jsxs("div",{className:"bim-rh-shelf-box",children:[s&&t.jsxs("h3",{className:"bim-rh-gt",children:[d(e.label),t.jsx("small",{children:i?d(i):l("readHome.shelfHint")})]}),t.jsx("div",{className:"bim-rh-shelf-wrap",tabIndex:0,role:"region","aria-label":l("readHome.shelfRegion",{label:d(e.label)}),children:t.jsx("ul",{className:"bim-rh-shelf",children:h.map(m=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(m.label),children:m.items.map(u)}),t.jsx("span",{"aria-hidden":"true",children:d(m.label)})]},m.label))})}),t.jsxs("p",{className:"bim-rh-legend",children:[t.jsxs("span",{children:[t.jsx("i",{"data-orig":"","aria-hidden":"true"}),l("readHome.origZhi")]}),t.jsxs("span",{children:[t.jsx("i",{"aria-hidden":"true"}),l("readHome.laterZhi")]}),p&&t.jsx("span",{children:d(p)}),a==null?void 0:a.map(m=>t.jsx("span",{children:d(m)},m))]})]})}const Yy=4,Wn=e=>e>Yy+1;function Yd({topic:e,links:n}){const{t:i,convert:o}=ne(),s=qt(n),[a,l]=g.useState(!1);if(!e.items.length)return null;const d=`bim-rh-g-${e.key}`;return t.jsxs("div",{className:"bim-rh-grp","data-cap":Wn(e.items.length)?"":void 0,"data-open":a?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",id:d,children:[o(e.label),t.jsx("small",{className:"bim-rh-num",children:i("readHome.nWorks",{n:Ke(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=Gd(c.text_count,i),h=Xo(c);return t.jsx("li",{children:t.jsxs("a",{href:s.read(c.id),children:[t.jsx("span",{className:"bim-rh-t",children:o(c.title)}),p&&t.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:p}),h&&t.jsx("small",{children:o(h)})]})},c.id)})}),Wn(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 qd({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(Zo,{topic:s,links:n},s.key)),o.length>0&&t.jsx("div",{className:"bim-rh-groups",children:o.map(s=>t.jsx(Yd,{topic:s,links:n},s.key))})]})}function Kd({famous:e,links:n}){const{t:i,convert:o}=ne(),s=qt(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 Jo({bu:e,unclassified:n,links:i,unclassifiedNote:o}){const{t:s,convert:a}=ne(),l=qt(i);return!e.length&&!n?null:t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-bu",children:e.map(d=>{var p;const c=((p=d.top[0])==null?void 0:p.count)||1;return t.jsxs("li",{className:"bim-rh-bu-c",children:[t.jsxs("a",{className:"bim-rh-bu-h",href:l.node(d.id),children:[t.jsx("b",{children:a(d.label)}),t.jsx("span",{className:"bim-rh-num",children:s("readHome.nWorks",{n:Ke(d.count)})})]}),d.top.length>0&&t.jsx("ul",{className:"bim-rh-bu-l","aria-label":s("readHome.subClasses",{label:a(d.label)}),children:d.top.map(h=>t.jsx("li",{children:t.jsxs("a",{href:l.node(h.id),children:[t.jsx("span",{children:a(h.label)}),t.jsx("small",{className:"bim-rh-num",children:Ke(h.count)}),t.jsx("span",{className:"bim-rh-bar","aria-hidden":"true",style:{"--bimrh-w":`${Math.round(h.count/c*100)}%`}})]})},h.id))}),d.children_total>d.top.length&&t.jsx("a",{className:"bim-rh-bu-more",href:l.node(d.id),children:s("readHome.allNClasses",{label:a(d.label),n:d.children_total})})]},d.id)})}),!!n&&t.jsxs("p",{className:"bim-rh-uncl bim-rh-num",children:[t.jsx("b",{children:s("readHome.unclassified")}),t.jsx("span",{children:s("readHome.nWorks",{n:Ke(n)})}),t.jsx("span",{children:o?a(o):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function Xd({periods:e,unknown:n,links:i}){const{t:o,convert:s,messages:a}=ne(),l=a.readHome.period,d=qt(i),c=e.filter(u=>u.count>0);if(!c.length)return null;const p=c.reduce((u,m)=>u+m.count,0),h=Math.max(...c.map(u=>u.count));return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-band",children:c.map(u=>{const m=u.label?s(u.label):l[u.key]??s(u.key),f=u.count/p,x=o("readHome.periodItem",{label:m,n:Ke(u.count)});return t.jsx("li",{style:{flex:`0 0 ${(f*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(u.key),"data-k":Fd(u.count,h),"data-narrow":f<Hd?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:m}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(m)[0]}),t.jsx("small",{className:"bim-rh-num",children:Ke(u.count)})]})},u.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:o("readHome.periodUnknown",{n:Ke(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:o("readHome.hoverHint")})]})]})}function Zd({authors:e,links:n}){const{t:i,convert:o}=ne(),s=qt(n);return e.length?t.jsx("ul",{className:"bim-rh-authors",children:e.map(a=>t.jsxs("li",{className:"bim-rh-au",children:[t.jsxs("h3",{className:"bim-rh-au-h",children:[o(a.name),a.dynasty&&t.jsx("span",{children:o(a.dynasty)}),t.jsx("small",{className:"bim-rh-num",children:i("readHome.nPieces",{n:Ke(a.count)})})]}),t.jsx("ul",{children:a.items.map(l=>t.jsx("li",{children:t.jsx("a",{href:s.read(l.id),children:o(l.title)})},l.id))}),s.author&&t.jsx("a",{className:"bim-rh-more",href:s.author(a.name),children:i("readHome.authorAll",{name:o(a.name),n:a.count})})]},a.name))}):null}const Jd={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function qy({sections:e,links:n,head:i,piecesMoreHref:o,className:s}){const{t:a}=ne(),l=e,d=Jd,c=l.topics.filter(m=>!m.shelf),p={picks:l.picks.length>0,topics:c.some(m=>m.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(m=>m.count>0),pieces:l.pieces.authors.length>0},h=Object.keys(d).filter(m=>p[m]),u=m=>a(`readHome.nav.${m}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:Ko}),t.jsxs("div",{className:"bim-rh-head",children:[i,t.jsx(Ud,{counts:l.counts})]}),h.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":a("readHome.navLabel"),children:t.jsx("ul",{children:h.map(m=>t.jsx("li",{children:t.jsx("a",{href:`#${d[m]}`,children:u(m)})},m))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(mt,{id:d.picks,title:u("picks"),sub:a("readHome.picksSub"),children:t.jsx(Vd,{picks:l.picks,links:n})}),p.topics&&t.jsx(mt,{id:d.topics,title:u("topics"),sub:a("readHome.topicsSub"),children:t.jsx(qd,{topics:c,links:n})}),p.famous&&t.jsx(mt,{id:d.famous,title:u("famous"),sub:a("readHome.famousSub"),children:t.jsx(Kd,{famous:l.famous,links:n})}),p.sibu&&t.jsx(mt,{id:d.sibu,title:u("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(Jo,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(mt,{id:d.period,title:u("period"),sub:a("readHome.periodSub"),children:t.jsx(Xd,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(mt,{id:d.pieces,title:u("pieces"),sub:a("readHome.piecesSub"),more:o?t.jsx("a",{className:"bim-rh-more",href:o,children:a("readHome.piecesMore")}):void 0,children:t.jsx(Zd,{authors:l.pieces.authors,links:n})})]})]})}const Ky="(max-width: 1079px)",Xy=`${Yn}, (pointer: coarse)`,Qd=`
1751
1758
  /* ── 页首:检索(宿主插槽)+类型签|最近浏览 ── */
1752
1759
  .bim-mh-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 16px 48px; align-items: start; padding-top: 8px; }
1753
1760
  .bim-mh-q { min-width: 0; }
@@ -1887,7 +1894,7 @@ ${Wy.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1887
1894
  .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")}; }
1888
1895
 
1889
1896
  /* ── 中屏 ── */
1890
- @media ${Dy} {
1897
+ @media ${Ky} {
1891
1898
  .bim-mh-head, .bim-mh-zhi { grid-template-columns: minmax(0, 1fr); }
1892
1899
  .bim-mh-cg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
1893
1900
  .bim-mh-lin { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@@ -1914,8 +1921,8 @@ ${Wy.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1914
1921
  .bim-mh-tbl tr > :nth-child(2), .bim-mh-tbl tr > :nth-child(3) { display: none; }
1915
1922
  }
1916
1923
 
1917
- @media ${Uy} {
1924
+ @media ${Xy} {
1918
1925
  .bim-mh-recent li a, .bim-mh-types a, .bim-mh-tl-list a { min-height: 44px; align-items: center; }
1919
1926
  .bim-mh-recent-h button { min-height: 44px; }
1920
1927
  }
1921
- `,ep={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function Kt(e){return{...ep,...e??{}}}function tp(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 Jo(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function np(e){const n=e.filter(p=>Number.isFinite(p.birth_year)||Number.isFinite(p.death_year)),i=e.filter(p=>!n.includes(p));if(!n.length)return{min:0,max:0,placed:[],missing:i};const o=p=>{const h=Number.isFinite(p.birth_year)?p.birth_year:p.death_year-50,u=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(h,u),Math.max(h,u)]},s=n.map(o),a=Math.min(...s.map(p=>p[0])),l=Math.max(...s.map(p=>p[1])),d=Math.max(1,l-a),c=n.map((p,h)=>({p,from:s[h][0],to:s[h][1]})).sort((p,h)=>p.from-h.from).map(p=>({...p,left:(p.from-a)/d*100,width:Math.max(.8,(p.to-p.from)/d*100)}));return{min:a,max:l,placed:c,missing:i}}function wi(e,n=vn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function Vy(e){return{read:e.item,work:e.item,node:e.node}}function ip({counts:e,links:n}){const{t:i}=te(),o=n==null?void 0:n.type;if(!o)return null;const s=[["all",i("metaHome.typeAll"),null],["work",i("metaHome.typeLabel.work"),e.works],["book",i("metaHome.typeLabel.book"),e.books],["collection",i("metaHome.typeLabel.collection"),e.collections],["entity",i("metaHome.typeLabel.entity"),e.entities]];return t.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":i("metaHome.typeChipsLabel"),children:s.map(([a,l,d])=>t.jsx("li",{children:t.jsxs("a",{href:o(a),children:[t.jsx("b",{children:l}),d!=null&&d>0&&t.jsx("small",{children:Ke(d)})]})},a))})}function rp(e,n=5){const[i,o]=g.useState(null);g.useEffect(()=>{let a=!1;const l=Yt().slice(0,n);if(!l.length||!e){o([]);return}return Promise.all(l.map(d=>no(e,d))).then(d=>{a||o(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=g.useCallback(()=>{to(),o([])},[]);return{entries:i,clear:s}}function Gy(e,n,i){const o=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return o?i(o):op(e.type,n)}function op(e,n){return n(`metaHome.typeLabel.${e}`)}function sp({entries:e,onClear:n,links:i}){const{t:o,convert:s}=te(),a=Kt(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?op(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:Gy(l,o,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:o("metaHome.recentEmpty")})]})}function ap(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 lp({rows:e,links:n}){const{t:i,convert:o}=te(),s=Kt(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=Jo(a.imported,a.total),d=a.work_id??a.collection_id,c=o(a.edition?`${a.name}·${a.edition}`:a.name);return t.jsxs("tr",{children:[t.jsx("th",{scope:"row",children:d?t.jsx("a",{href:s.item(d),children:c}):c}),t.jsx("td",{className:"bim-mh-r",children:Ke(a.total)}),t.jsx("td",{className:"bim-mh-r",children:Ke(a.imported)}),t.jsx("td",{children:t.jsxs("span",{className:"bim-mh-meter",children:[t.jsx("i",{"aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[l,"%"]})]})}),t.jsx("td",{children:a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:ap(a.status,i,o)})})]},a.id||a.name)})})]})}):null}function cp({items:e,links:n,label:i}){const{convert:o}=te();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 dp({works:e,links:n}){const{t:i}=te(),[o,s]=g.useState(!1);if(!e.length)return null;const a=On(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(cp,{items:e.map(l=>({id:l.id,title:l.title,sub:Hi(l)||void 0})),links:Kt(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 pp="siku_qige";function Yy({group:e,links:n}){const{t:i,convert:o}=te(),[s,a]=g.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":On(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(cp,{items:e.items,links:n,label:e.label}),On(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 up({groups:e,links:n}){const{t:i,convert:o}=te(),s=Kt(n);if(!e.length)return null;const a=e.find(c=>c.key===pp),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(Yy,{group:c,links:s},c.key))})]})}const Ka=34,Xa=13;function Za(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?wi(e.birth_year,n):"?"}–${e.death_year!=null?wi(e.death_year,n):"?"}`}function qy(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 mp({people:e,links:n}){const{t:i,convert:o}=te(),s=Kt(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=np(e),p=[],h=d.map(m=>{const f=m.left>70,x=f?Math.min(m.left,m.left+m.width-Xa):m.left;let k=0;for(;p[k]!=null&&p[k]>x;)k++;return p[k]=f?m.left+m.width:m.left+Math.max(m.width,Xa),{...m,lane:k,end:f}}),u=Math.max(1,l-a);return t.jsxs(t.Fragment,{children:[h.length>0&&t.jsxs("div",{className:"bim-mh-tl",children:[t.jsx("ul",{className:"bim-mh-tl-rows",style:{height:p.length*Ka+10},children:h.map(m=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":m.end?"":void 0,style:{left:`${m.left}%`,top:m.lane*Ka+4,width:`${Math.max(m.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(m.p.id),children:[o(m.p.name),t.jsx("small",{className:"bim-rh-num",children:Za(m.p,i)})]})]},m.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:qy(a,l).map(m=>t.jsx("span",{style:{left:`${(m-a)/u*100}%`},children:wi(m,i)},m))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":h.length?void 0:"",children:(h.length?e:c).map(m=>t.jsx("li",{children:t.jsxs("a",{href:s.item(m.id),children:[t.jsx("span",{children:o(m.name)}),t.jsx("small",{className:"bim-rh-num",children:[m.dynasty?o(m.dynasty):"",Za(m,i)].filter(Boolean).join(" ")})]})},m.id))}),c.length>0&&h.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:i("metaHome.missingLife",{names:o(c.map(m=>m.name).join("、"))})})]})}const Ky=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 hp({works:e,links:n}){const{t:i,convert:o}=te(),s=Kt(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=Hi(a);return t.jsx("li",{children:t.jsxs("a",{href:tp(s,a.id),children:[Ky,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 gp({sites:e}){const{t:n,convert:i}=te(),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=Jo(a.imported,a.total);return t.jsxs("li",{children:[a.url?t.jsx("a",{href:a.url,rel:"noopener noreferrer",target:"_blank",children:i(a.name)}):t.jsx("span",{children:i(a.name)}),t.jsx("span",{className:"bim-mh-bar","aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[`${Ke(a.imported)} / ${Ke(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:ap(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 Ja=["extant","partially_extant","lost","unknown"];function fp({stats:e,links:n,version:i,repoUrl:o,downloadHref:s}){const{t:a}=te(),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=Ja.some(p=>{var h;return(((h=e.loss)==null?void 0:h[p])??0)>0});return t.jsxs("div",{className:"bim-mh-data",children:[l.length>0&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.dataScale")}),t.jsx("ul",{className:"bim-mh-nums",children:l.map(([p,h])=>t.jsxs("li",{children:[t.jsx("b",{className:"bim-rh-num",children:Ke(p)}),t.jsx("span",{children:h})]},h))})]}),d&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.byLoss")}),t.jsx("ul",{className:"bim-mh-loss",children:Ja.map(p=>{var m;const h=((m=e.loss)==null?void 0:m[p])??0,u=a(`metaHome.lossNote.${p}`);return t.jsx("li",{children:t.jsxs("a",{href:d(p),children:[a(`metaHome.loss.${p}`),t.jsx("small",{className:"bim-rh-num",children:c&&h>0?a("metaHome.lossCount",{n:Ke(h),note:u}):u})]})},p)})})]}),t.jsxs("div",{className:"bim-mh-lic",children:[t.jsxs("p",{children:[t.jsx("span",{className:"bim-mh-cc0",children:"CC0"}),a("metaHome.license")]}),t.jsxs("p",{children:[a("metaHome.repo"),o?t.jsx("a",{href:o,children:t.jsx("code",{children:"book-index"})}):t.jsx("code",{children:"book-index"}),a("metaHome.repoNote")]}),i&&t.jsxs("p",{children:[a("metaHome.version"),t.jsx("code",{children:i})]}),s&&t.jsx("p",{children:t.jsx("a",{href:s,children:a("metaHome.download")})})]})]})}const xp={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function Xy({sections:e,links:n,head:i,transport:o,catalogHref:s,collectionsHref:a,entitiesHref:l,version:d,repoUrl:c,downloadHref:p,className:h}){var j,C;const{t:u}=te(),m=e,f=Kt(n),x=Vy(f),k=xp,y=rp(o),$={zhi:!!((j=m.shelf)!=null&&j.items.length)||m.catalog_progress.length>0||m.related_catalogs.length>0,sibu:m.bu.length>0||m.unclassified>0,cong:m.collection_groups.length>0,people:m.bibliographers.length>0,lineage:m.lineage.length>0,sites:m.sites.length>0,data:!0},b=Object.keys(k).filter(S=>$[S]),w=S=>u(`metaHome.nav.${S}`),v=(S,_)=>S?t.jsx("a",{className:"bim-rh-more",href:S,children:_}):void 0;return t.jsxs("div",{className:h?`bim-rh bim-mh ${h}`:"bim-rh bim-mh",children:[t.jsx("style",{children:qo+Qd}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[i,t.jsx(ip,{counts:m.counts,links:n})]}),o&&t.jsx(sp,{entries:y.entries,onClear:y.clear,links:n})]}),b.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":u("metaHome.navLabel"),children:t.jsx("ul",{children:b.map(S=>t.jsx("li",{children:t.jsx("a",{href:`#${k[S]}`,children:w(S)})},S))})}),t.jsxs("div",{className:"bim-rh-main",children:[$.zhi&&t.jsxs(mt,{id:k.zhi,title:w("zhi"),sub:u("metaHome.zhiSub"),children:[m.shelf&&m.shelf.items.length>0&&t.jsx(Xo,{topic:{key:"shelf",label:m.shelf.label,shelf:!0,items:m.shelf.items},links:x,showTitle:!1,legendCount:m.shelf.items.some(S=>S.records)?u("metaHome.shelfLegendCount"):null,legendExtra:[u("metaHome.shelfLegendClick")]}),(m.catalog_progress.length>0||m.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:(C=m.shelf)!=null&&C.items.length?void 0:{marginTop:0},children:[t.jsx(lp,{rows:m.catalog_progress,links:n}),t.jsx(dp,{works:m.related_catalogs,links:n})]})]}),$.sibu&&t.jsx(mt,{id:k.sibu,title:w("sibu"),sub:u("metaHome.sibuSub"),more:v(s,u("metaHome.toCatalog")),children:t.jsx(Zo,{bu:m.bu,unclassified:m.unclassified,links:x,unclassifiedNote:u("metaHome.unclassifiedNote")})}),$.cong&&t.jsx(mt,{id:k.cong,title:w("cong"),sub:u("metaHome.congSub"),more:v(a,u("metaHome.allNKindsMore",{n:Ke(m.counts.collections)})),children:t.jsx(up,{groups:m.collection_groups,links:n})}),$.people&&t.jsx(mt,{id:k.people,title:w("people"),sub:u("metaHome.peopleSub"),more:v(l,u("metaHome.allNPeopleMore",{n:Ke(m.counts.entities)})),children:t.jsx(mp,{people:m.bibliographers,links:n})}),$.lineage&&t.jsx(mt,{id:k.lineage,title:w("lineage"),sub:u("metaHome.lineageSub"),children:t.jsx(hp,{works:m.lineage,links:n})}),$.sites&&t.jsx(mt,{id:k.sites,title:w("sites"),sub:u("metaHome.sitesSub"),children:t.jsx(gp,{sites:m.sites})}),t.jsx(mt,{id:k.data,title:w("data"),sub:u("metaHome.dataSub"),children:t.jsx(fp,{stats:m.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const bp=["_related","_catalogs","_collections","_members","_children"],Zy=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Ur=e=>Zy(e)&&!!e.h;function Jy(e){return e?bp.some(n=>{const i=e[n];return Array.isArray(i)&&i.some(Ur)}):!1}function Qy(e,n){const i={...e};if(!n)return i;for(const o of bp){const s=e[o];!Array.isArray(s)||!s.some(Ur)||(i[o]=s.map(a=>{var c;if(!Ur(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 e0(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&&Qy(d,Jy(d)?await i():null)};const a=Reflect.get(o,s,o);return typeof a=="function"?a.bind(o):a}})}const Vr=({style:e})=>{const n=g.useContext(It),{t:i}=te();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")})]})},Gr=({href:e,label:n,size:i=16,className:o,style:s})=>{const{t:a}=te(),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 jr(e){const n=e.text_count;return typeof n=="number"&&n>0}function vr(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function t0(e,n){if(!n)return!1;const i=n.id;return i===void 0||i===e}const n0=({id:e,transport:n,initialDetail:i,initialEntry:o,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:h,onLineageCollectionChange:u,initialPage:m=1,selectedLineageNodeId:f,onNavigate:x,onBack:k,backLabel:y,renderLink:$,assetBase:b,enrichDetail:w,getSourceLink:v,readLink:j,railTop:C,extraTabs:S=[],showFeedbackTab:_=!0,feedbackApiUrl:L,height:T,footerExtra:z,hideHeaderControls:M=!1,className:H,style:N})=>{const R=g.useMemo(()=>e0(n),[n]),A=Ie(),{t:J,convert:ee}=te(),[oe]=g.useState(()=>{if(!t0(e,i))return null;const X={...i},$e=o??vr(e,X);return w&&w($e,X),{id:e,entry:$e,detail:X}}),[V,me]=g.useState((oe==null?void 0:oe.entry)??null),[G,q]=g.useState((oe==null?void 0:oe.detail)??null),[ce,we]=g.useState(!oe),[O,ye]=g.useState(!1),[de,ze]=g.useState([]),[Ce,Oe]=g.useState(!1),[ne,W]=g.useState(null),[U,he]=g.useState(null),[K,B]=g.useState(null),[Q,le]=g.useState(!1),ie=g.useRef(null),D=g.useRef(0),[se,Te]=g.useState(null),Me=l!==void 0?l:se,Le=g.useCallback(X=>{d?d(X):Te(X)},[d]),F=g.useCallback(async X=>{if(!R.getCollectionCatalogs&&!R.getCollectionCatalog){ze([]);return}Oe(!0);try{if(R.getCollectionCatalogs)ze(await R.getCollectionCatalogs(X)||[]);else if(R.getCollectionCatalog){const $e=await R.getCollectionCatalog(X);ze($e?[{resource_id:"",data:$e}]:[])}}catch{ze([])}finally{Oe(!1)}},[R]),ae=g.useCallback(async X=>{var $e,Fe;if(!R.getTextManifest||!R.getTextIndex){W(null),he(X);return}try{const We=ke.pickTextVersion(await R.getTextManifest(X)),Re=We?await R.getTextIndex(X,We.key):null;W(Re&&Re.chapters.length>0?{chapters:Re.chapters.map(be=>({n:be.n,title:be.title,file:be.file})),source:{name:(($e=Re.source)==null?void 0:$e.name)??(We==null?void 0:We.source_name),license:((Fe=Re.source)==null?void 0:Fe.license)??(We==null?void 0:We.license)??void 0}}:null)}catch{W(null)}finally{he(X)}},[R]),fe=g.useCallback(async(X,$e)=>{const Fe=++D.current,We=()=>Fe!==D.current;le(!0);try{if(R.getLineageGraph){const ot=await R.getLineageGraph(X);if(We())return;ot&&B(ot)}const Re=$e.version_graph;if(!Re||!Re.enabled){K||B(null),ie.current=null;return}const be=mo($e),_e=(await Oi(be,Wi,async ot=>{try{return await R.getItem(ot)}catch{return null}},We)).filter(Boolean);if(We())return;ie.current={work:$e,books:_e};const Je=h??Re.default_collection??(Re.core_books&&Re.core_books.length>0?"core":"all"),He=Je==="core"&&Array.isArray(Re.core_books)&&Re.core_books.length>0?"core":Je??"all";B(fi($e,_e,He))}catch{if(We())return;B(null),ie.current=null}finally{We()||le(!1)}},[R]),P=g.useRef({initialDetail:i,initialEntry:o});P.current={initialDetail:i,initialEntry:o},g.useEffect(()=>{let X=!1;D.current++,le(!1);const $e=be=>{be.type==="collection"?F(e):be.type==="work"?(be.version_graph||R.getLineageGraph)&&fe(e,be):be.type==="book"&&jr(be)&&ae(e)},Fe=P.current;let We=null;if(oe&&oe.id===e)We=oe;else if(Fe.initialDetail&&Fe.initialDetail.id===e){const be={...Fe.initialDetail},Be=Fe.initialEntry??vr(e,be);w&&w(Be,be),We={entry:Be,detail:be}}return We?(ye(!1),ze(be=>be.length?[]:be),W(null),B(null),ie.current=null,me(We.entry),q(We.detail),we(!1),$e(We.detail),()=>{X=!0}):((async()=>{we(!0),ye(!1),me(null),q(null),ze([]),W(null),B(null),ie.current=null;try{const be=await R.getItem(e);if(X)return;if(!be){ye(!0);return}const Be=be;let _e=null;if(R.getEntry&&(_e=await R.getEntry(e),X))return;_e||(_e=vr(e,Be)),w&&w(_e,Be),me(_e),q(Be),$e(Be)}catch{X||ye(!0)}finally{X||we(!1)}})(),()=>{X=!0})},[e,R,oe,w,F,fe,ae]),g.useEffect(()=>{const X=ie.current;!X||!h||B(fi(X.work,X.books,h))},[h]);const xe=[];if(G){if(xe.push({key:"basic",label:A.detailTab.basicInfo}),G.type==="collection"){Ce&&de.length===0&&xe.push({key:"catalog:loading",label:`${A.detailTab.catalog}…`});for(const X of de)xe.push({key:`catalog:${X.resource_id}`,label:X.short_name?`${ee(X.short_name)}${A.detailTab.catalogSuffix}`:A.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&xe.push({key:s,label:A.detailTab.fullText}),G.type==="work"&&(K||Q)&&xe.push({key:"lineage",label:Q?`${A.detailTab.lineage}…`:A.detailTab.lineage});for(const X of S)(X.position??"before-feedback")==="before-feedback"&&X.shouldShow(G)&&xe.push({key:X.key,label:X.label});_&&s==="feedback"&&xe.push({key:"feedback",label:A.detailTab.feedback});for(const X of S)X.position==="after-feedback"&&X.shouldShow(G)&&xe.push({key:X.key,label:X.label})}g.useEffect(()=>{if(s!=="emendated"||!G)return;a("basic");const X=setTimeout(()=>{var $e;($e=document.getElementById("studies"))==null||$e.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(X)},[s,G,a]);const re=V&&G&&v?v({activeTab:s,activeJuan:Me,entry:V,detail:G}):null,je=g.useMemo(()=>{var Re,be,Be,_e,Je;if(!G)return null;const $e=(G.authors??[]).map(He=>{const ot=uo(He.role);return`${He.dynasty?`〔${ee(He.dynasty)}〕`:""}${ee(He.name)}${ot?` ${ee(ot)}`:""}`}).join(" · ");let Fe=!1;try{Fe=ke.extractStatus(G.id)==="draft"}catch{}if(G.type==="book"){const He=G;return{title:ee(He.title),subtitle:He.edition?ee(He.edition):$e||void 0,aside:[Fe?A.status.draft:"",$e&&He.edition?$e:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(G.type==="collection"){const He=G;return{title:ee(He.title),subtitle:ee(Ht(He,A.unit.juan))||void 0,aside:[(Re=He.publication_info)==null?void 0:Re.year,Fe?A.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:$e||void 0}}if(G.type==="entity"){const He=G,ot=jt=>jt==null?"":jt<0?J("detail.bce",{n:-jt}):String(jt),Et=((be=He.dates)==null?void 0:be.birth)!=null||((Be=He.dates)==null?void 0:Be.death)!=null?`${ot(((_e=He.dates)==null?void 0:_e.birth)??void 0)||"?"}—${ot(((Je=He.dates)==null?void 0:Je.death)??void 0)||"?"}`:"";return{title:ee(He.primary_name||He.title),subtitle:[He.dynasty?`〔${ee(He.dynasty)}〕`:"",Et].filter(Boolean).join(" ")||void 0,aside:Fe?A.status.draft:void 0,secondLine:void 0}}const We=ee(Ht(G,A.unit.juan));return{title:ee(G.title),subtitle:[We,$e].filter(Boolean).join(" · ")||void 0,aside:[r0(A,G.subtype),Fe?A.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[G,ee,A,J]),Se=G&&jr(G)?"text":null,Ve=()=>{Le(null),a("fulltext")};let Ye=null;if(G&&j){const X=j({detail:G,kind:Se});X&&(Ye=t.jsx(Ir,{href:X}))}else Se&&(Ye=t.jsx(Ir,{onClick:Ve}));const et=X=>{if(!G)return null;const $e=X.replace(/\.[^.]+$/,"");if(j){const Fe=j({detail:G,kind:Se,juan:$e});return Fe?{href:Fe}:null}return{onClick:()=>{Le($e),a("fulltext")}}},Ze=new Set(S.map(X=>X.key)),I=xe.filter(X=>X.key.startsWith("catalog:")&&X.key!=="catalog:loading"||X.key==="lineage"&&!!K&&!Q||Ze.has(X.key)).map(X=>({key:X.key,label:X.label,onClick:()=>a(X.key)})),Y=()=>{var X;return G?G.type==="work"?t.jsx(vd,{data:G,transport:R,onNavigate:x,renderLink:$,readAction:Ye,railTop:C,railLinks:I}):G.type==="book"?t.jsx(_d,{data:G,transport:R,onNavigate:x,renderLink:$,readAction:Ye,fullText:ne,fullTextPending:jr(G)&&!!R.getTextManifest&&U!==G.id,chapterLink:et,railTop:C,railLinks:I}):G.type==="collection"?t.jsx($d,{data:G,catalog:(X=de[0])==null?void 0:X.data,transport:R,onNavigate:x,renderLink:$,readAction:Ye,railTop:C,railLinks:I,catalogAction:de.length>0?t.jsxs("a",{href:"#catalog",onClick:$e=>{$e.preventDefault(),a(`catalog:${de[0].resource_id}`)},children:[ee(A.detailTab.collectionCatalog)," →"]}):null}):t.jsx(zd,{data:G,transport:R,onNavigate:x,renderLink:$,railTop:C,railLinks:I,assetBase:b}):null},pe=()=>{var $e,Fe,We;if(!V||!G)return null;if(s==="basic"||s==="emendated")return Y();if(typeof s=="string"&&s.startsWith("catalog:")){const Re=($e=de.find(be=>`catalog:${be.resource_id}`===s))==null?void 0:$e.data;return t.jsx(ro,{data:Re,onNavigate:x,renderLink:$})}if(s==="collated"||s==="fulltext")return t.jsx(Wo,{id:e,transport:R,chapter:Me,onLocationChange:Re=>Le(Re.chapter),onNavigate:x});if(s==="lineage"){if(!K)return t.jsx("div",{style:{color:r("label-fg"),padding:"24px 0"},children:J(Q?"detail.loading":"detail.noLineageGraph")});const Re=G.type==="work"?G:null;return t.jsx(Uo,{graph:K,renderLink:$,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:f,collection:h??((Fe=Re==null?void 0:Re.version_graph)==null?void 0:Fe.default_collection),onCollectionChange:u,collectionsAvailable:(We=Re==null?void 0:Re.version_graph)==null?void 0:We.collections,collectionCounts:(()=>{var Je,He,ot,Et,jt,Ge,Z;if(!Re)return;const be={},Be=((Je=ie.current)==null?void 0:Je.books)??[];be.all=(((He=Re._books)==null?void 0:He.length)??0)-(((Et=(ot=Re.version_graph)==null?void 0:ot.excluded_books)==null?void 0:Et.length)??0);const _e=(jt=Re.version_graph)==null?void 0:jt.collections;if(_e)for(const De of Object.keys(_e))be[De]=fi(Re,Be,De).nodes.filter(Qe=>Qe.kind==="book"&&!Qe.bridge).length;return be.core==null&&((Z=(Ge=Re.version_graph)==null?void 0:Ge.core_books)!=null&&Z.length)&&(be.core=Re.version_graph.core_books.length),be})()})}if(s==="feedback"&&_)return t.jsx(xd,{resourceId:e,apiUrl:L});const X=S.find(Re=>Re.key===s);return X?X.render({detail:G,entry:V,transport:R,onNavigate:x}):null};if(ce)return t.jsx(Rn,{style:{minHeight:T,...N},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(O||!G||!V||!je)return t.jsx(Rn,{style:{minHeight:T,...N},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:r("label-fg"),fontSize:14},children:J("detail.notFound")})});const ve=s==="basic"||s==="emendated",Ee=[{label:y??A.detailTab.backToIndex,onClick:k}];if(G.type==="book"&&G.work_id){const X=G.work_id;Ee.push({label:A.indexType.work,id:X,onClick:()=>x==null?void 0:x(X)})}Ee.push({label:A.indexType[G.type]});const ge=s==="collated"||s==="fulltext",Ae=typeof z=="string"?A.status[z.trim()]??z:z,qe=t.jsx(_c,{left:t.jsxs(t.Fragment,{children:[Ae,Ae?" · ":"",t.jsx(i0,{id:G.id,label:A.label.id,copied:A.action.copied,copyLabel:A.action.copy})]}),right:t.jsxs(t.Fragment,{children:[_&&!ve&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg")},children:A.detailTab.submitVersion}),re&&t.jsx("a",{href:re.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:r("meta-fg")},children:A.detailTab.dataLicense})]})});return ve?t.jsx("div",{className:H,children:t.jsxs(Rn,{grid:!0,style:{minHeight:T,...N},children:[t.jsx(Er,{breadcrumb:t.jsx(Rr,{items:Ee}),actions:t.jsxs(t.Fragment,{children:[!M&&t.jsx(Vr,{style:{border:"none",background:"transparent"}}),!M&&re&&t.jsx(Gr,{...re})]})}),Y(),qe]})}):t.jsx("div",{className:H,children:t.jsxs(Rn,{wide:ge,style:{minHeight:T,...N},children:[t.jsx(Er,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(bo,{char:"籍"}),t.jsx(Rr,{items:Ee})]}),actions:t.jsxs(t.Fragment,{children:[!M&&t.jsx(Vr,{}),_&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),className:"bim-d-ui",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg")},children:A.detailTab.feedback}),!M&&re&&t.jsx(Gr,{...re})]})}),t.jsx(fc,{...je,aside:ge?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:[J("detail.workInfo")," →"]}):je.aside}),!ge&&xe.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:xe.map(X=>t.jsx(xc,{label:X.label,active:X.key===s||ve&&X.key==="basic",onClick:()=>a(X.key)},X.key))}),t.jsx("div",{style:{marginTop:!ge&&xe.length>1?8:0},children:pe()}),qe]})})};function i0({id:e,label:n,copied:i,copyLabel:o}){const[s,a]=g.useState(!1);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[t.jsxs("span",{children:[n," ",e]}),t.jsx("button",{type:"button",onClick:()=>{var l;(l=navigator.clipboard)==null||l.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},title:s?i:o,"aria-label":s?i:o,className:"bim-d-hit",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:14,minWidth:32,minHeight:32,display:"inline-flex",alignItems:"center",justifyContent:"center",color:r("aux-fg")},children:s?"✓":"⧉"})]})}function r0(e,n){return n?e.workSubtype[n]??n:""}const yp=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],Di="zhusha",Ui="bim-theme";function jp(e){return e==="zhusha"||e==="indigo"||e==="ink"}function Vi(e){return jp(e)?e:Di}function o0(){try{return Vi(window.localStorage.getItem(Ui))}catch{return Di}}function vp(e){try{window.localStorage.setItem(Ui,e)}catch{}}function kp(e){const n=Vi(e);return document.documentElement.setAttribute("data-theme",n),n}function wp(){return Vi(document.documentElement.getAttribute("data-theme"))}const s0=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Qo="airy",Gi="bim-layout";function Sp(e){return e==="airy"||e==="boxed"}function Yi(e){return Sp(e)?e:Qo}function a0(){try{return Yi(window.localStorage.getItem(Gi))}catch{return Qo}}function l0(e){try{window.localStorage.setItem(Gi,e)}catch{}}function c0(e){const n=Yi(e);return document.documentElement.setAttribute("data-layout",n),n}function d0(){return Yi(document.documentElement.getAttribute("data-layout"))}const p0=`try{var t=localStorage.getItem(${JSON.stringify(Ui)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Gi)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,u0={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},m0=({onChange:e,style:n})=>{const{t:i}=te(),[o,s]=g.useState(Di);g.useEffect(()=>{s(wp())},[]);const a=l=>{s(kp(l)),vp(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":i("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:yp.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(u0[l.name]),boxShadow:d?`0 0 0 2px ${r("page-bg")}, 0 0 0 3.5px ${r("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=ke.BidLink;exports.BookIndexError=ke.BookIndexError;exports.BookIndexManager=ke.BookIndexManager;exports.BookIndexStorage=ke.BookIndexStorage;exports.BundleStorage=ke.BundleStorage;exports.ConfigError=ke.ConfigError;exports.GithubStorage=ke.GithubStorage;exports.IdGenerationError=ke.IdGenerationError;exports.IdGenerator=ke.IdGenerator;exports.LocalStorage=ke.LocalStorage;exports.MigrationError=ke.MigrationError;exports.StorageError=ke.StorageError;exports.VARIANT_CHARS=ke.VARIANT_CHARS;exports.base36Decode=ke.base36Decode;exports.base36Encode=ke.base36Encode;exports.base58Decode=ke.base58Decode;exports.buildId=ke.buildId;exports.buildPromotionMap=ke.buildPromotionMap;exports.cleanName=ke.cleanName;exports.decodeId=ke.decodeId;exports.decodeIdString=ke.decodeIdString;exports.encodeId=ke.encodeId;exports.extractIdFromUrl=ke.extractIdFromUrl;exports.extractStatus=ke.extractStatus;exports.extractType=ke.extractType;exports.isChapterSegment=ke.isChapterSegment;exports.isTextKey=ke.isTextKey;exports.matchChapterAcrossVersions=ke.matchChapterAcrossVersions;exports.normalizeCatalog=ke.normalizeCatalog;exports.normalizeVariants=ke.normalizeVariants;exports.parseId=ke.parseId;exports.pickTextVersion=ke.pickTextVersion;exports.shardOf=ke.shardOf;exports.smartDecode=ke.smartDecode;exports.textVersionLabel=ke.textVersionLabel;exports.validateResource=ke.validateResource;exports.VARIANT_SUPPLEMENT=Qa.VARIANT_SUPPLEMENT;exports.Badge=ki;exports.BidUrlProvider=Kp;exports.BookDetailLayout=n0;exports.BookPage=_d;exports.Breadcrumb=Rr;exports.CATALOG_ALL_ID=Bt;exports.CATALOG_CSS=Td;exports.CATALOG_NARROW_QUERY=Vo;exports.CATALOG_PAGE_SIZE=Go;exports.CATALOG_UNCLASSIFIED_ID=nn;exports.CLASSIFICATIONS=Ti;exports.COMMON_TRADITIONAL_CHARS=dl;exports.CardFoot=Un;exports.CatalogPage=My;exports.CatalogPager=Md;exports.CatalogTree=Id;exports.CheckFilter=mc;exports.Chip=bc;exports.ChipWall=Xh;exports.CollectionCatalog=ro;exports.CollectionPage=$d;exports.CreateEntityDialog=cd;exports.DEFAULT_LAYOUT=Qo;exports.DEFAULT_META_HOME_LINKS=ep;exports.DEFAULT_READER_PREFS=so;exports.DEFAULT_READ_HOME_LINKS=Bd;exports.DEFAULT_THEME=Di;exports.DETAIL_CSS=gc;exports.DYNASTY_GROUPS=zi;exports.Dash=ng;exports.DataTable=Jh;exports.DetailFooter=_c;exports.DetailGrid=Hn;exports.DetailHeader=fc;exports.EMPTY_FILTERS=Ci;exports.ENTITY_TEXT_CSS=Lo;exports.EmendatedBySection=El;exports.EmptyNote=cg;exports.EntityDetail=$l;exports.EntityMark=Mo;exports.EntityPage=zd;exports.EntityPickerDialog=pd;exports.EntitySelector=ld;exports.EntityText=zf;exports.ExpandRow=ig;exports.ExtLink=dg;exports.FEEDBACK_FAB_OFFSET_VAR=Fr;exports.FILTER_SUPPORT=xl;exports.FONT_SIZE_STEPS=Pt;exports.FactList=Gh;exports.FeedbackButton=jb;exports.FeedbackDialog=gd;exports.FeedbackForm=fd;exports.FeedbackList=Oo;exports.FeedbackTab=xd;exports.FilterChip=xc;exports.FormInput=xt;exports.FormTextArea=on;exports.GUJI_MARKDOWN_FIELD=Ih;exports.GUJI_TABLE_NOTATION=$c;exports.GlyphBadge=bo;exports.GujiInteractiveReader=gx;exports.GujiTable=vo;exports.GujiTextViewer=Po;exports.GujiWarpCanvas=Ro;exports.HomePage=Wr;exports.ImagePanel=_r;exports.IndexApp=hx;exports.IndexBrowser=Sr;exports.IndexDetail=io;exports.IndexEditor=ud;exports.IndexView=sb;exports.IntroGrid=Vh;exports.LAYOUTS=s0;exports.LAYOUT_STORAGE_KEY=Gi;exports.LOSS_OPTIONS=fl;exports.LocaleContext=It;exports.LocaleProvider=wu;exports.LocaleToggle=Vr;exports.META_HOME_CSS=Qd;exports.META_HOME_SECTION_IDS=xp;exports.MetaCatalogTable=lp;exports.MetaCollectionGroups=up;exports.MetaDataLicense=fp;exports.MetaHomeView=Xy;exports.MetaLine=at;exports.MetaLineageCards=hp;exports.MetaOnlineSites=gp;exports.MetaPeopleTimeline=mp;exports.MetaRecentPanel=sp;exports.MetaRelatedCatalogs=dp;exports.MetaTypeChips=ip;exports.ModeIndicator=ul;exports.MoreButton=Kh;exports.MoreLink=fo;exports.PAGE_MAX_WIDTH=mi;exports.PERIOD_NARROW_SHARE=Hd;exports.PageFrame=Rn;exports.Quote=og;exports.READER_CSS=Wl;exports.READ_HOME_CSS=qo;exports.READ_HOME_NARROW_QUERY=Yn;exports.READ_HOME_SECTION_IDS=Jd;exports.READ_PERIOD_LABELS=Oy;exports.RECENT_IDS_STORAGE_KEY=hn;exports.ROLE_CLASS_ORDER=nc;exports.ReadButton=Ir;exports.ReadFamousWorks=Kd;exports.ReadHomeView=Hy;exports.ReadPeriodBand=Xd;exports.ReadPicks=Vd;exports.ReadPieces=Zd;exports.ReadSection=mt;exports.ReadShelf=Xo;exports.ReadSibu=Zo;exports.ReadStats=Ud;exports.ReadTopicGroup=Yd;exports.ReadTopics=qd;exports.ReaderMdText=_o;exports.ReaderShell=Yl;exports.ReaderToc=Fl;exports.RelationPanel=sd;exports.RepoSourceLink=Gr;exports.ResourceEditor=kr;exports.ResourceGroup=sg;exports.ResourceLine=ag;exports.ResourceList=Qr;exports.ResourceRow=wc;exports.SEARCH_VIEW_STORAGE_KEY=eo;exports.SEVEN_PAVILIONS_KEY=pp;exports.SNIPPET_MARK_END=nl;exports.SNIPPET_MARK_START=tl;exports.SORTABLE_TYPES=gl;exports.SearchInput=hl;exports.SearchResults=wl;exports.Sec=lt;exports.Section=St;exports.SectionHead=Yh;exports.SideList=rn;exports.SmartBidInput=gi;exports.SourceEditor=id;exports.StripWarpRenderer=Mr;exports.SummaryCard=Dn;exports.THEMES=yp;exports.THEME_INIT_SCRIPT=p0;exports.THEME_STORAGE_KEY=Ui;exports.TRADITIONAL_ALLOWLIST=pl;exports.TabFilter=Ai;exports.TableHead=Qh;exports.TableRow=eg;exports.TagRow=Sc;exports.TagRows=lg;exports.TextButton=qh;exports.TextReader=Wo;exports.ThemeToggle=m0;exports.TopStrip=Er;exports.VersionLineageGraph=Sd;exports.VersionLineageList=wd;exports.VersionLineageView=Uo;exports.VolumeChips=Zh;exports.VolumeLinks=yo;exports.WorkCard=Ld;exports.WorkCardGrid=Pd;exports.WorkCatalog=_x;exports.WorkPage=vd;exports.WorkRow=Ad;exports.adaptCharCord=Sx;exports.adaptEntityJson=Bc;exports.adaptNorm=nd;exports.adaptNormDetailed=td;exports.adaptPunctJson=xx;exports.applyLayout=c0;exports.applyTheme=kp;exports.authorsLine=Hi;exports.bookIndexUriToId=Ar;exports.bookMarkingOf=So;exports.bucketResources=co;exports.buildCatalogTree=Cy;exports.buildCollectionTable=oc;exports.buildLineageGraph=fi;exports.buildMeiliFilter=Fu;exports.buildPageUrl=Zr;exports.buildParagraphBlocks=Rc;exports.buildVersionRow=ec;exports.buildVersionTable=tc;exports.canParagraphize=ji;exports.catalogNodeIdOf=_y;exports.catalogNodeIdsOf=$y;exports.catalogPageCount=Iy;exports.catalogTotal=Yo;exports.classificationPath=Gn;exports.clearAllRecentIds=to;exports.compareCatalogCards=Ny;exports.computeVersionPartition=Sh;exports.countActiveFilters=Ni;exports.createTextApi=Ll;exports.currentLayout=d0;exports.currentTheme=wp;exports.defaultEntityHref=Yc;exports.defaultWorkLink=Ed;exports.deriveDating=vh;exports.deriveEditionType=ac;exports.deriveEra=Fn;exports.deriveYear=Ei;exports.deriveYearRange=lo;exports.detailToEditor=hd;exports.detectGenre=Pi;exports.displayAuthorRole=uo;exports.editorToDetail=ob;exports.eraRank=Tr;exports.filtersFromParams=Hu;exports.filtersToParams=xi;exports.findCatalogPath=mn;exports.findTraditionalChars=$u;exports.firstAuthorText=Ko;exports.flattenTitles=Lr;exports.flattenToc=Gl;exports.fmtCount=Ke;exports.formatHitCount=pi;exports.formatTemplate=bt;exports.formatVolumeRange=Li;exports.getDisplayNameFromUrl=bn;exports.getMessages=jn;exports.getStartPage=Xr;exports.getT=vn;exports.getTypeGroupKey=qr;exports.groupRelatedWorks=kh;exports.gujiInlineToPlain=pc;exports.hasActiveFilters=bl;exports.hasGujiMarkdownV02=Eh;exports.hasGujiTableNotation=pg;exports.hasSearchOptions=Bu;exports.iiifVolumeOf=bx;exports.isCountedChar=$o;exports.isLayoutName=Sp;exports.isThemeName=jp;exports.lineageHref=tp;exports.loadRecentIds=Yt;exports.measureText=Ht;exports.mergeVolumeResources=Kr;exports.normalizeEra=st;exports.normalizeLayout=Yi;exports.normalizeRole=po;exports.normalizeTheme=Vi;exports.normalizeVolumeIndex=Mn;exports.normalizeVolumes=ol;exports.numberToChinese=sc;exports.paginationItems=Nd;exports.parseChineseNumber=bi;exports.parseGujiInline=dc;exports.parseGujiTable=zc;exports.parseSourceString=rd;exports.pct=Jo;exports.periodLevel=Fd;exports.pickReaderVersion=Vl;exports.readStoredLayout=a0;exports.readStoredTheme=o0;exports.readerVersionOptionLabel=Cr;exports.remapPlainOffsets=Wc;exports.removeRecentId=Sl;exports.renderFullTextBody=vg;exports.renderProperNames=Mc;exports.renderReaderInline=Bi;exports.resolveRecentEntry=no;exports.resourceHref=yn;exports.resourceNote=Ri;exports.resultTabFromParam=Ju;exports.resultTabToParam=Qu;exports.roleFacets=ic;exports.rowNo=tg;exports.sameFilters=Du;exports.saveRecentId=wr;exports.segmentEntities=Oc;exports.shelfColumns=Wd;exports.sortFor=Wu;exports.sortYear=yi;exports.spineHeight=Od;exports.splitFullTextTables=jo;exports.splitHighlightSnippet=Yr;exports.splitTableRow=Cc;exports.storeLayout=l0;exports.storeTheme=vp;exports.stringifySources=od;exports.summaryFromEntry=Vc;exports.summaryFromItem=Uc;exports.timelineLayout=np;exports.toCatalogWorkCard=Ty;exports.transportSummaryLoader=Gc;exports.typeSupportsFilters=yl;exports.useBidUrl=rt;exports.useChapterWarpData=Xc;exports.useConvert=Pe;exports.useEntitySummaryLoader=Ao;exports.useI18n=te;exports.useReaderPrefs=Ul;exports.useRecentEntries=rp;exports.useT=Ie;exports.validateLineageGraph=Db;exports.volumeStats=Si;exports.withDefaultLinks=qt;exports.withMetaLinks=Kt;exports.yearText=wi;
1928
+ `,ep={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function Kt(e){return{...ep,...e??{}}}function tp(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 Qo(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function np(e){const n=e.filter(p=>Number.isFinite(p.birth_year)||Number.isFinite(p.death_year)),i=e.filter(p=>!n.includes(p));if(!n.length)return{min:0,max:0,placed:[],missing:i};const o=p=>{const h=Number.isFinite(p.birth_year)?p.birth_year:p.death_year-50,u=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(h,u),Math.max(h,u)]},s=n.map(o),a=Math.min(...s.map(p=>p[0])),l=Math.max(...s.map(p=>p[1])),d=Math.max(1,l-a),c=n.map((p,h)=>({p,from:s[h][0],to:s[h][1]})).sort((p,h)=>p.from-h.from).map(p=>({...p,left:(p.from-a)/d*100,width:Math.max(.8,(p.to-p.from)/d*100)}));return{min:a,max:l,placed:c,missing:i}}function wi(e,n=vn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function Zy(e){return{read:e.item,work:e.item,node:e.node}}function ip({counts:e,links:n}){const{t:i}=ne(),o=n==null?void 0:n.type;if(!o)return null;const s=[["all",i("metaHome.typeAll"),null],["work",i("metaHome.typeLabel.work"),e.works],["book",i("metaHome.typeLabel.book"),e.books],["collection",i("metaHome.typeLabel.collection"),e.collections],["entity",i("metaHome.typeLabel.entity"),e.entities]];return t.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":i("metaHome.typeChipsLabel"),children:s.map(([a,l,d])=>t.jsx("li",{children:t.jsxs("a",{href:o(a),children:[t.jsx("b",{children:l}),d!=null&&d>0&&t.jsx("small",{children:Ke(d)})]})},a))})}function rp(e,n=5){const[i,o]=g.useState(null);g.useEffect(()=>{let a=!1;const l=Yt().slice(0,n);if(!l.length||!e){o([]);return}return Promise.all(l.map(d=>io(e,d))).then(d=>{a||o(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=g.useCallback(()=>{no(),o([])},[]);return{entries:i,clear:s}}function Jy(e,n,i){const o=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return o?i(o):op(e.type,n)}function op(e,n){return n(`metaHome.typeLabel.${e}`)}function sp({entries:e,onClear:n,links:i}){const{t:o,convert:s}=ne(),a=Kt(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?op(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:Jy(l,o,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:o("metaHome.recentEmpty")})]})}function ap(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 lp({rows:e,links:n}){const{t:i,convert:o}=ne(),s=Kt(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=Qo(a.imported,a.total),d=a.work_id??a.collection_id,c=o(a.edition?`${a.name}·${a.edition}`:a.name);return t.jsxs("tr",{children:[t.jsx("th",{scope:"row",children:d?t.jsx("a",{href:s.item(d),children:c}):c}),t.jsx("td",{className:"bim-mh-r",children:Ke(a.total)}),t.jsx("td",{className:"bim-mh-r",children:Ke(a.imported)}),t.jsx("td",{children:t.jsxs("span",{className:"bim-mh-meter",children:[t.jsx("i",{"aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[l,"%"]})]})}),t.jsx("td",{children:a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:ap(a.status,i,o)})})]},a.id||a.name)})})]})}):null}function cp({items:e,links:n,label:i}){const{convert:o}=ne();return t.jsx("ul",{className:"bim-rh-rows","aria-label":i?o(i):void 0,children:e.map(s=>t.jsx("li",{children:t.jsxs("a",{href:n.item(s.id),children:[t.jsx("span",{className:"bim-rh-t",children:o(s.title)}),s.sub&&t.jsx("small",{children:o(s.sub)})]})},s.id))})}function dp({works:e,links:n}){const{t:i}=ne(),[o,s]=g.useState(!1);if(!e.length)return null;const a=Wn(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(cp,{items:e.map(l=>({id:l.id,title:l.title,sub:Hi(l)||void 0})),links:Kt(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 pp="siku_qige";function Qy({group:e,links:n}){const{t:i,convert:o}=ne(),[s,a]=g.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":Wn(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(cp,{items:e.items,links:n,label:e.label}),Wn(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 up({groups:e,links:n}){const{t:i,convert:o}=ne(),s=Kt(n);if(!e.length)return null;const a=e.find(c=>c.key===pp),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(Qy,{group:c,links:s},c.key))})]})}const Ka=34,Xa=13;function Za(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?wi(e.birth_year,n):"?"}–${e.death_year!=null?wi(e.death_year,n):"?"}`}function e0(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 mp({people:e,links:n}){const{t:i,convert:o}=ne(),s=Kt(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=np(e),p=[],h=d.map(m=>{const f=m.left>70,x=f?Math.min(m.left,m.left+m.width-Xa):m.left;let k=0;for(;p[k]!=null&&p[k]>x;)k++;return p[k]=f?m.left+m.width:m.left+Math.max(m.width,Xa),{...m,lane:k,end:f}}),u=Math.max(1,l-a);return t.jsxs(t.Fragment,{children:[h.length>0&&t.jsxs("div",{className:"bim-mh-tl",children:[t.jsx("ul",{className:"bim-mh-tl-rows",style:{height:p.length*Ka+10},children:h.map(m=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":m.end?"":void 0,style:{left:`${m.left}%`,top:m.lane*Ka+4,width:`${Math.max(m.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(m.p.id),children:[o(m.p.name),t.jsx("small",{className:"bim-rh-num",children:Za(m.p,i)})]})]},m.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:e0(a,l).map(m=>t.jsx("span",{style:{left:`${(m-a)/u*100}%`},children:wi(m,i)},m))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":h.length?void 0:"",children:(h.length?e:c).map(m=>t.jsx("li",{children:t.jsxs("a",{href:s.item(m.id),children:[t.jsx("span",{children:o(m.name)}),t.jsx("small",{className:"bim-rh-num",children:[m.dynasty?o(m.dynasty):"",Za(m,i)].filter(Boolean).join(" ")})]})},m.id))}),c.length>0&&h.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:i("metaHome.missingLife",{names:o(c.map(m=>m.name).join("、"))})})]})}const t0=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 hp({works:e,links:n}){const{t:i,convert:o}=ne(),s=Kt(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=Hi(a);return t.jsx("li",{children:t.jsxs("a",{href:tp(s,a.id),children:[t0,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 gp({sites:e}){const{t:n,convert:i}=ne(),o=e.filter(a=>a.status!=="todo"&&a.total>0),s=e.filter(a=>!o.includes(a));return e.length?t.jsxs(t.Fragment,{children:[o.length>0&&t.jsx("ul",{className:"bim-mh-cov",children:o.map(a=>{const l=Qo(a.imported,a.total);return t.jsxs("li",{children:[a.url?t.jsx("a",{href:a.url,rel:"noopener noreferrer",target:"_blank",children:i(a.name)}):t.jsx("span",{children:i(a.name)}),t.jsx("span",{className:"bim-mh-bar","aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[`${Ke(a.imported)} / ${Ke(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:ap(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 Ja=["extant","partially_extant","lost","unknown"];function fp({stats:e,links:n,version:i,repoUrl:o,downloadHref:s}){const{t:a}=ne(),l=["works","books","collections","entities","has_image","has_text","article","poem"].map(p=>[e[p],a(`metaHome.stat.${p}`)]).filter(([p])=>p>0),d=n==null?void 0:n.loss,c=Ja.some(p=>{var h;return(((h=e.loss)==null?void 0:h[p])??0)>0});return t.jsxs("div",{className:"bim-mh-data",children:[l.length>0&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.dataScale")}),t.jsx("ul",{className:"bim-mh-nums",children:l.map(([p,h])=>t.jsxs("li",{children:[t.jsx("b",{className:"bim-rh-num",children:Ke(p)}),t.jsx("span",{children:h})]},h))})]}),d&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.byLoss")}),t.jsx("ul",{className:"bim-mh-loss",children:Ja.map(p=>{var m;const h=((m=e.loss)==null?void 0:m[p])??0,u=a(`metaHome.lossNote.${p}`);return t.jsx("li",{children:t.jsxs("a",{href:d(p),children:[a(`metaHome.loss.${p}`),t.jsx("small",{className:"bim-rh-num",children:c&&h>0?a("metaHome.lossCount",{n:Ke(h),note:u}):u})]})},p)})})]}),t.jsxs("div",{className:"bim-mh-lic",children:[t.jsxs("p",{children:[t.jsx("span",{className:"bim-mh-cc0",children:"CC0"}),a("metaHome.license")]}),t.jsxs("p",{children:[a("metaHome.repo"),o?t.jsx("a",{href:o,children:t.jsx("code",{children:"book-index"})}):t.jsx("code",{children:"book-index"}),a("metaHome.repoNote")]}),i&&t.jsxs("p",{children:[a("metaHome.version"),t.jsx("code",{children:i})]}),s&&t.jsx("p",{children:t.jsx("a",{href:s,children:a("metaHome.download")})})]})]})}const xp={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function n0({sections:e,links:n,head:i,transport:o,catalogHref:s,collectionsHref:a,entitiesHref:l,version:d,repoUrl:c,downloadHref:p,className:h}){var j,C;const{t:u}=ne(),m=e,f=Kt(n),x=Zy(f),k=xp,y=rp(o),$={zhi:!!((j=m.shelf)!=null&&j.items.length)||m.catalog_progress.length>0||m.related_catalogs.length>0,sibu:m.bu.length>0||m.unclassified>0,cong:m.collection_groups.length>0,people:m.bibliographers.length>0,lineage:m.lineage.length>0,sites:m.sites.length>0,data:!0},b=Object.keys(k).filter(S=>$[S]),w=S=>u(`metaHome.nav.${S}`),v=(S,_)=>S?t.jsx("a",{className:"bim-rh-more",href:S,children:_}):void 0;return t.jsxs("div",{className:h?`bim-rh bim-mh ${h}`:"bim-rh bim-mh",children:[t.jsx("style",{children:Ko+Qd}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[i,t.jsx(ip,{counts:m.counts,links:n})]}),o&&t.jsx(sp,{entries:y.entries,onClear:y.clear,links:n})]}),b.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":u("metaHome.navLabel"),children:t.jsx("ul",{children:b.map(S=>t.jsx("li",{children:t.jsx("a",{href:`#${k[S]}`,children:w(S)})},S))})}),t.jsxs("div",{className:"bim-rh-main",children:[$.zhi&&t.jsxs(mt,{id:k.zhi,title:w("zhi"),sub:u("metaHome.zhiSub"),children:[m.shelf&&m.shelf.items.length>0&&t.jsx(Zo,{topic:{key:"shelf",label:m.shelf.label,shelf:!0,items:m.shelf.items},links:x,showTitle:!1,legendCount:m.shelf.items.some(S=>S.records)?u("metaHome.shelfLegendCount"):null,legendExtra:[u("metaHome.shelfLegendClick")]}),(m.catalog_progress.length>0||m.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:(C=m.shelf)!=null&&C.items.length?void 0:{marginTop:0},children:[t.jsx(lp,{rows:m.catalog_progress,links:n}),t.jsx(dp,{works:m.related_catalogs,links:n})]})]}),$.sibu&&t.jsx(mt,{id:k.sibu,title:w("sibu"),sub:u("metaHome.sibuSub"),more:v(s,u("metaHome.toCatalog")),children:t.jsx(Jo,{bu:m.bu,unclassified:m.unclassified,links:x,unclassifiedNote:u("metaHome.unclassifiedNote")})}),$.cong&&t.jsx(mt,{id:k.cong,title:w("cong"),sub:u("metaHome.congSub"),more:v(a,u("metaHome.allNKindsMore",{n:Ke(m.counts.collections)})),children:t.jsx(up,{groups:m.collection_groups,links:n})}),$.people&&t.jsx(mt,{id:k.people,title:w("people"),sub:u("metaHome.peopleSub"),more:v(l,u("metaHome.allNPeopleMore",{n:Ke(m.counts.entities)})),children:t.jsx(mp,{people:m.bibliographers,links:n})}),$.lineage&&t.jsx(mt,{id:k.lineage,title:w("lineage"),sub:u("metaHome.lineageSub"),children:t.jsx(hp,{works:m.lineage,links:n})}),$.sites&&t.jsx(mt,{id:k.sites,title:w("sites"),sub:u("metaHome.sitesSub"),children:t.jsx(gp,{sites:m.sites})}),t.jsx(mt,{id:k.data,title:w("data"),sub:u("metaHome.dataSub"),children:t.jsx(fp,{stats:m.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const bp=["_related","_catalogs","_collections","_members","_children"],i0=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Vr=e=>i0(e)&&!!e.h;function r0(e){return e?bp.some(n=>{const i=e[n];return Array.isArray(i)&&i.some(Vr)}):!1}function o0(e,n){const i={...e};if(!n)return i;for(const o of bp){const s=e[o];!Array.isArray(s)||!s.some(Vr)||(i[o]=s.map(a=>{var c;if(!Vr(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 s0(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&&o0(d,r0(d)?await i():null)};const a=Reflect.get(o,s,o);return typeof a=="function"?a.bind(o):a}})}const Gr=({style:e})=>{const n=g.useContext(It),{t:i}=ne();if(!n)return null;const{locale:o,setLocale:s}=n,a=o==="zh-Hant",l=()=>s(a?"zh-Hans":"zh-Hant");return t.jsxs("button",{type:"button",onClick:l,title:i(a?"common.toHans":"common.toHant"),style:{display:"inline-flex",alignItems:"center",gap:"2px",padding:"4px 10px",fontSize:"13px",fontWeight:500,lineHeight:1,border:`1px solid ${r("border")}`,borderRadius:"4px",background:r("bg"),color:r("fg"),cursor:"pointer",userSelect:"none",...e},children:[t.jsx("span",{style:{color:a?r("primary"):void 0,fontWeight:a?700:400},children:i("common.localeShortHant")}),t.jsx("span",{style:{opacity:.3},children:"/"}),t.jsx("span",{style:{color:a?void 0:r("primary"),fontWeight:a?400:700},children:i("common.localeShortHans")})]})},Yr=({href:e,label:n,size:i=16,className:o,style:s})=>{const{t:a}=ne(),l=n??a("common.repoSourceLink");return t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:l,"aria-label":l,className:o,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:i+8,height:i+8,borderRadius:4,color:r("desc-fg"),textDecoration:"none",transition:"color 120ms, background 120ms",...s},onMouseEnter:d=>{d.currentTarget.style.color=r("fg")},onMouseLeave:d=>{d.currentTarget.style.color=r("desc-fg")},children:t.jsx("svg",{width:i,height:i,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8a8 8 0 0 0 5.47 7.59c.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})})};function jr(e){const n=e.text_count;return typeof n=="number"&&n>0}function vr(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function a0(e,n){if(!n)return!1;const i=n.id;return i===void 0||i===e}const l0=({id:e,transport:n,initialDetail:i,initialEntry:o,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:h,onLineageCollectionChange:u,initialPage:m=1,selectedLineageNodeId:f,onNavigate:x,onBack:k,backLabel:y,renderLink:$,assetBase:b,enrichDetail:w,getSourceLink:v,readLink:j,railTop:C,extraTabs:S=[],showFeedbackTab:_=!0,feedbackApiUrl:A,height:T,footerExtra:z,hideHeaderControls:M=!1,className:H,style:I})=>{const R=g.useMemo(()=>s0(n),[n]),P=Ie(),{t:K,convert:te}=ne(),[ie]=g.useState(()=>{if(!a0(e,i))return null;const Z={...i},ze=o??vr(e,Z);return w&&w(ze,Z),{id:e,entry:ze,detail:Z}}),[U,pe]=g.useState((ie==null?void 0:ie.entry)??null),[G,ee]=g.useState((ie==null?void 0:ie.detail)??null),[ae,Se]=g.useState(!ie),[O,je]=g.useState(!1),[de,we]=g.useState([]),[Te,Fe]=g.useState(!1),[re,B]=g.useState(null),[V,he]=g.useState(null),[X,ge]=g.useState(null),[W,le]=g.useState(!1),q=g.useRef(null),D=g.useRef(0),[Q,Ce]=g.useState(null),Le=l!==void 0?l:Q,Ae=g.useCallback(Z=>{d?d(Z):Ce(Z)},[d]),F=g.useCallback(async Z=>{if(!R.getCollectionCatalogs&&!R.getCollectionCatalog){we([]);return}Fe(!0);try{if(R.getCollectionCatalogs)we(await R.getCollectionCatalogs(Z)||[]);else if(R.getCollectionCatalog){const ze=await R.getCollectionCatalog(Z);we(ze?[{resource_id:"",data:ze}]:[])}}catch{we([])}finally{Fe(!1)}},[R]),se=g.useCallback(async Z=>{var ze,We;if(!R.getTextManifest||!R.getTextIndex){B(null),he(Z);return}try{const Oe=ke.pickTextVersion(await R.getTextManifest(Z)),Re=Oe?await R.getTextIndex(Z,Oe.key):null;B(Re&&Re.chapters.length>0?{chapters:Re.chapters.map(xe=>({n:xe.n,title:xe.title,file:xe.file})),source:{name:((ze=Re.source)==null?void 0:ze.name)??(Oe==null?void 0:Oe.source_name),license:((We=Re.source)==null?void 0:We.license)??(Oe==null?void 0:Oe.license)??void 0}}:null)}catch{B(null)}finally{he(Z)}},[R]),ve=g.useCallback(async(Z,ze)=>{const We=++D.current,Oe=()=>We!==D.current;le(!0);try{if(R.getLineageGraph){const ot=await R.getLineageGraph(Z);if(Oe())return;ot&&ge(ot)}const Re=ze.version_graph;if(!Re||!Re.enabled){X||ge(null),q.current=null;return}const xe=ho(ze),$e=(await Wi(xe,Oi,async ot=>{try{return await R.getItem(ot)}catch{return null}},Oe)).filter(Boolean);if(Oe())return;q.current={work:ze,books:$e};const Je=h??Re.default_collection??(Re.core_books&&Re.core_books.length>0?"core":"all"),He=Je==="core"&&Array.isArray(Re.core_books)&&Re.core_books.length>0?"core":Je??"all";ge(fi(ze,$e,He))}catch{if(Oe())return;ge(null),q.current=null}finally{Oe()||le(!1)}},[R]),L=g.useRef({initialDetail:i,initialEntry:o});L.current={initialDetail:i,initialEntry:o},g.useEffect(()=>{let Z=!1;D.current++,le(!1);const ze=xe=>{xe.type==="collection"?F(e):xe.type==="work"?(xe.version_graph||R.getLineageGraph)&&ve(e,xe):xe.type==="book"&&jr(xe)&&se(e)},We=L.current;let Oe=null;if(ie&&ie.id===e)Oe=ie;else if(We.initialDetail&&We.initialDetail.id===e){const xe={...We.initialDetail},Be=We.initialEntry??vr(e,xe);w&&w(Be,xe),Oe={entry:Be,detail:xe}}return Oe?(je(!1),we(xe=>xe.length?[]:xe),B(null),ge(null),q.current=null,pe(Oe.entry),ee(Oe.detail),Se(!1),ze(Oe.detail),()=>{Z=!0}):((async()=>{Se(!0),je(!1),pe(null),ee(null),we([]),B(null),ge(null),q.current=null;try{const xe=await R.getItem(e);if(Z)return;if(!xe){je(!0);return}const Be=xe;let $e=null;if(R.getEntry&&($e=await R.getEntry(e),Z))return;$e||($e=vr(e,Be)),w&&w($e,Be),pe($e),ee(Be),ze(Be)}catch{Z||je(!0)}finally{Z||Se(!1)}})(),()=>{Z=!0})},[e,R,ie,w,F,ve,se]),g.useEffect(()=>{const Z=q.current;!Z||!h||ge(fi(Z.work,Z.books,h))},[h]);const me=[];if(G){if(me.push({key:"basic",label:P.detailTab.basicInfo}),G.type==="collection"){Te&&de.length===0&&me.push({key:"catalog:loading",label:`${P.detailTab.catalog}…`});for(const Z of de)me.push({key:`catalog:${Z.resource_id}`,label:Z.short_name?`${te(Z.short_name)}${P.detailTab.catalogSuffix}`:P.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&me.push({key:s,label:P.detailTab.fullText}),G.type==="work"&&(X||W)&&me.push({key:"lineage",label:W?`${P.detailTab.lineage}…`:P.detailTab.lineage});for(const Z of S)(Z.position??"before-feedback")==="before-feedback"&&Z.shouldShow(G)&&me.push({key:Z.key,label:Z.label});_&&s==="feedback"&&me.push({key:"feedback",label:P.detailTab.feedback});for(const Z of S)Z.position==="after-feedback"&&Z.shouldShow(G)&&me.push({key:Z.key,label:Z.label})}g.useEffect(()=>{if(s!=="emendated"||!G)return;a("basic");const Z=setTimeout(()=>{var ze;(ze=document.getElementById("studies"))==null||ze.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(Z)},[s,G,a]);const oe=U&&G&&v?v({activeTab:s,activeJuan:Le,entry:U,detail:G}):null,be=g.useMemo(()=>{var Re,xe,Be,$e,Je;if(!G)return null;const ze=(G.authors??[]).map(He=>{const ot=mo(He.role);return`${He.dynasty?`〔${te(He.dynasty)}〕`:""}${te(He.name)}${ot?` ${te(ot)}`:""}`}).join(" · ");let We=!1;try{We=ke.extractStatus(G.id)==="draft"}catch{}if(G.type==="book"){const He=G;return{title:te(He.title),subtitle:He.edition?te(He.edition):ze||void 0,aside:[We?P.status.draft:"",ze&&He.edition?ze:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(G.type==="collection"){const He=G;return{title:te(He.title),subtitle:te(Ht(He,P.unit.juan))||void 0,aside:[(Re=He.publication_info)==null?void 0:Re.year,We?P.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:ze||void 0}}if(G.type==="entity"){const He=G,ot=jt=>jt==null?"":jt<0?K("detail.bce",{n:-jt}):String(jt),Et=((xe=He.dates)==null?void 0:xe.birth)!=null||((Be=He.dates)==null?void 0:Be.death)!=null?`${ot((($e=He.dates)==null?void 0:$e.birth)??void 0)||"?"}—${ot(((Je=He.dates)==null?void 0:Je.death)??void 0)||"?"}`:"";return{title:te(He.primary_name||He.title),subtitle:[He.dynasty?`〔${te(He.dynasty)}〕`:"",Et].filter(Boolean).join(" ")||void 0,aside:We?P.status.draft:void 0,secondLine:void 0}}const Oe=te(Ht(G,P.unit.juan));return{title:te(G.title),subtitle:[Oe,ze].filter(Boolean).join(" · ")||void 0,aside:[d0(P,G.subtype),We?P.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[G,te,P,K]),_e=G&&jr(G)?"text":null,Ve=()=>{Ae(null),a("fulltext")};let Ye=null;if(G&&j){const Z=j({detail:G,kind:_e});Z&&(Ye=t.jsx(Ir,{href:Z}))}else _e&&(Ye=t.jsx(Ir,{onClick:Ve}));const tt=Z=>{if(!G)return null;const ze=Z.replace(/\.[^.]+$/,"");if(j){const We=j({detail:G,kind:_e,juan:ze});return We?{href:We}:null}return{onClick:()=>{Ae(ze),a("fulltext")}}},Ze=new Set(S.map(Z=>Z.key)),N=me.filter(Z=>Z.key.startsWith("catalog:")&&Z.key!=="catalog:loading"||Z.key==="lineage"&&!!X&&!W||Ze.has(Z.key)).map(Z=>({key:Z.key,label:Z.label,onClick:()=>a(Z.key)})),Y=()=>{var Z;return G?G.type==="work"?t.jsx(vd,{data:G,transport:R,onNavigate:x,renderLink:$,readAction:Ye,railTop:C,railLinks:N}):G.type==="book"?t.jsx(_d,{data:G,transport:R,onNavigate:x,renderLink:$,readAction:Ye,fullText:re,fullTextPending:jr(G)&&!!R.getTextManifest&&V!==G.id,chapterLink:tt,railTop:C,railLinks:N}):G.type==="collection"?t.jsx($d,{data:G,catalog:(Z=de[0])==null?void 0:Z.data,transport:R,onNavigate:x,renderLink:$,readAction:Ye,railTop:C,railLinks:N,catalogAction:de.length>0?t.jsxs("a",{href:"#catalog",onClick:ze=>{ze.preventDefault(),a(`catalog:${de[0].resource_id}`)},children:[te(P.detailTab.collectionCatalog)," →"]}):null}):t.jsx(zd,{data:G,transport:R,onNavigate:x,renderLink:$,railTop:C,railLinks:N,assetBase:b}):null},ce=()=>{var ze,We,Oe;if(!U||!G)return null;if(s==="basic"||s==="emendated")return Y();if(typeof s=="string"&&s.startsWith("catalog:")){const Re=(ze=de.find(xe=>`catalog:${xe.resource_id}`===s))==null?void 0:ze.data;return t.jsx(oo,{data:Re,onNavigate:x,renderLink:$})}if(s==="collated"||s==="fulltext")return t.jsx(Wo,{id:e,transport:R,chapter:Le,onLocationChange:Re=>Ae(Re.chapter),onNavigate:x});if(s==="lineage"){if(!X)return t.jsx("div",{style:{color:r("label-fg"),padding:"24px 0"},children:K(W?"detail.loading":"detail.noLineageGraph")});const Re=G.type==="work"?G:null;return t.jsx(Vo,{graph:X,renderLink:$,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:f,collection:h??((We=Re==null?void 0:Re.version_graph)==null?void 0:We.default_collection),onCollectionChange:u,collectionsAvailable:(Oe=Re==null?void 0:Re.version_graph)==null?void 0:Oe.collections,collectionCounts:(()=>{var Je,He,ot,Et,jt,Ge,J;if(!Re)return;const xe={},Be=((Je=q.current)==null?void 0:Je.books)??[];xe.all=(((He=Re._books)==null?void 0:He.length)??0)-(((Et=(ot=Re.version_graph)==null?void 0:ot.excluded_books)==null?void 0:Et.length)??0);const $e=(jt=Re.version_graph)==null?void 0:jt.collections;if($e)for(const De of Object.keys($e))xe[De]=fi(Re,Be,De).nodes.filter(Qe=>Qe.kind==="book"&&!Qe.bridge).length;return xe.core==null&&((J=(Ge=Re.version_graph)==null?void 0:Ge.core_books)!=null&&J.length)&&(xe.core=Re.version_graph.core_books.length),xe})()})}if(s==="feedback"&&_)return t.jsx(xd,{resourceId:e,apiUrl:A});const Z=S.find(Re=>Re.key===s);return Z?Z.render({detail:G,entry:U,transport:R,onNavigate:x}):null};if(ae)return t.jsx(Rn,{style:{minHeight:T,...I},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((Z,ze)=>t.jsx("div",{style:{height:ze===1?40:16,width:Z,opacity:.35,background:r("rule")}},ze))})});if(O||!G||!U||!be)return t.jsx(Rn,{style:{minHeight:T,...I},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:r("label-fg"),fontSize:14},children:K("detail.notFound")})});const ye=s==="basic"||s==="emendated",Ee=[{label:y??P.detailTab.backToIndex,onClick:k}];if(G.type==="book"&&G.work_id){const Z=G.work_id;Ee.push({label:P.indexType.work,id:Z,onClick:()=>x==null?void 0:x(Z)})}Ee.push({label:P.indexType[G.type]});const fe=s==="collated"||s==="fulltext",Me=typeof z=="string"?P.status[z.trim()]??z:z,qe=t.jsx(_c,{left:t.jsxs(t.Fragment,{children:[Me,Me?" · ":"",t.jsx(c0,{id:G.id,label:P.label.id,copied:P.action.copied,copyLabel:P.action.copy})]}),right:t.jsxs(t.Fragment,{children:[_&&!ye&&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:P.detailTab.submitVersion}),oe&&t.jsx("a",{href:oe.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:r("meta-fg")},children:P.detailTab.dataLicense})]})});return ye?t.jsx("div",{className:H,children:t.jsxs(Rn,{grid:!0,style:{minHeight:T,...I},children:[t.jsx(Er,{breadcrumb:t.jsx(Rr,{items:Ee}),actions:t.jsxs(t.Fragment,{children:[!M&&t.jsx(Gr,{style:{border:"none",background:"transparent"}}),!M&&oe&&t.jsx(Yr,{...oe})]})}),Y(),qe]})}):t.jsx("div",{className:H,children:t.jsxs(Rn,{wide:fe,style:{minHeight:T,...I},children:[t.jsx(Er,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(yo,{char:"籍"}),t.jsx(Rr,{items:Ee})]}),actions:t.jsxs(t.Fragment,{children:[!M&&t.jsx(Gr,{}),_&&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:P.detailTab.feedback}),!M&&oe&&t.jsx(Yr,{...oe})]})}),t.jsx(fc,{...be,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:[K("detail.workInfo")," →"]}):be.aside}),!fe&&me.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:me.map(Z=>t.jsx(xc,{label:Z.label,active:Z.key===s||ye&&Z.key==="basic",onClick:()=>a(Z.key)},Z.key))}),t.jsx("div",{style:{marginTop:!fe&&me.length>1?8:0},children:ce()}),qe]})})};function c0({id:e,label:n,copied:i,copyLabel:o}){const[s,a]=g.useState(!1);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[t.jsxs("span",{children:[n," ",e]}),t.jsx("button",{type:"button",onClick:()=>{var l;(l=navigator.clipboard)==null||l.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},title:s?i:o,"aria-label":s?i:o,className:"bim-d-hit",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:14,minWidth:32,minHeight:32,display:"inline-flex",alignItems:"center",justifyContent:"center",color:r("aux-fg")},children:s?"✓":"⧉"})]})}function d0(e,n){return n?e.workSubtype[n]??n:""}const yp=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],Di="zhusha",Ui="bim-theme";function jp(e){return e==="zhusha"||e==="indigo"||e==="ink"}function Vi(e){return jp(e)?e:Di}function p0(){try{return Vi(window.localStorage.getItem(Ui))}catch{return Di}}function vp(e){try{window.localStorage.setItem(Ui,e)}catch{}}function kp(e){const n=Vi(e);return document.documentElement.setAttribute("data-theme",n),n}function wp(){return Vi(document.documentElement.getAttribute("data-theme"))}const u0=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],es="airy",Gi="bim-layout";function Sp(e){return e==="airy"||e==="boxed"}function Yi(e){return Sp(e)?e:es}function m0(){try{return Yi(window.localStorage.getItem(Gi))}catch{return es}}function h0(e){try{window.localStorage.setItem(Gi,e)}catch{}}function g0(e){const n=Yi(e);return document.documentElement.setAttribute("data-layout",n),n}function f0(){return Yi(document.documentElement.getAttribute("data-layout"))}const x0=`try{var t=localStorage.getItem(${JSON.stringify(Ui)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Gi)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,b0={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},y0=({onChange:e,style:n})=>{const{t:i}=ne(),[o,s]=g.useState(Di);g.useEffect(()=>{s(wp())},[]);const a=l=>{s(kp(l)),vp(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":i("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:yp.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(b0[l.name]),boxShadow:d?`0 0 0 2px ${r("page-bg")}, 0 0 0 3.5px ${r("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=ke.BidLink;exports.BookIndexError=ke.BookIndexError;exports.BookIndexManager=ke.BookIndexManager;exports.BookIndexStorage=ke.BookIndexStorage;exports.BundleStorage=ke.BundleStorage;exports.ConfigError=ke.ConfigError;exports.GithubStorage=ke.GithubStorage;exports.IdGenerationError=ke.IdGenerationError;exports.IdGenerator=ke.IdGenerator;exports.LocalStorage=ke.LocalStorage;exports.MigrationError=ke.MigrationError;exports.StorageError=ke.StorageError;exports.VARIANT_CHARS=ke.VARIANT_CHARS;exports.base36Decode=ke.base36Decode;exports.base36Encode=ke.base36Encode;exports.base58Decode=ke.base58Decode;exports.buildId=ke.buildId;exports.buildPromotionMap=ke.buildPromotionMap;exports.cleanName=ke.cleanName;exports.decodeId=ke.decodeId;exports.decodeIdString=ke.decodeIdString;exports.encodeId=ke.encodeId;exports.extractIdFromUrl=ke.extractIdFromUrl;exports.extractStatus=ke.extractStatus;exports.extractType=ke.extractType;exports.isChapterSegment=ke.isChapterSegment;exports.isTextKey=ke.isTextKey;exports.matchChapterAcrossVersions=ke.matchChapterAcrossVersions;exports.normalizeCatalog=ke.normalizeCatalog;exports.normalizeVariants=ke.normalizeVariants;exports.parseId=ke.parseId;exports.pickTextVersion=ke.pickTextVersion;exports.shardOf=ke.shardOf;exports.smartDecode=ke.smartDecode;exports.textVersionLabel=ke.textVersionLabel;exports.validateResource=ke.validateResource;exports.VARIANT_SUPPLEMENT=Qa.VARIANT_SUPPLEMENT;exports.Badge=ki;exports.BidUrlProvider=Kp;exports.BookDetailLayout=l0;exports.BookPage=_d;exports.Breadcrumb=Rr;exports.CATALOG_ALL_ID=Bt;exports.CATALOG_CSS=Td;exports.CATALOG_NARROW_QUERY=Go;exports.CATALOG_PAGE_SIZE=Yo;exports.CATALOG_UNCLASSIFIED_ID=nn;exports.CLASSIFICATIONS=Ti;exports.COMMON_TRADITIONAL_CHARS=dl;exports.CardFoot=Un;exports.CatalogPage=Hy;exports.CatalogPager=Md;exports.CatalogTree=Id;exports.CheckFilter=mc;exports.Chip=bc;exports.ChipWall=eg;exports.CollectionCatalog=oo;exports.CollectionPage=$d;exports.CreateEntityDialog=cd;exports.DEFAULT_LAYOUT=es;exports.DEFAULT_META_HOME_LINKS=ep;exports.DEFAULT_READER_PREFS=ao;exports.DEFAULT_READ_HOME_LINKS=Bd;exports.DEFAULT_THEME=Di;exports.DETAIL_CSS=gc;exports.DYNASTY_GROUPS=zi;exports.Dash=sg;exports.DataTable=ng;exports.DetailFooter=_c;exports.DetailGrid=Hn;exports.DetailHeader=fc;exports.EMPTY_FILTERS=Ci;exports.ENTITY_TEXT_CSS=Ao;exports.EmendatedBySection=El;exports.EmptyNote=mg;exports.EntityDetail=$l;exports.EntityMark=Po;exports.EntityPage=zd;exports.EntityPickerDialog=pd;exports.EntitySelector=ld;exports.EntityText=Ef;exports.ExpandRow=ag;exports.ExtLink=hg;exports.FEEDBACK_FAB_OFFSET_VAR=Fr;exports.FILTER_SUPPORT=xl;exports.FONT_SIZE_STEPS=Pt;exports.FactList=Xh;exports.FeedbackButton=Sb;exports.FeedbackDialog=gd;exports.FeedbackForm=fd;exports.FeedbackList=Fo;exports.FeedbackTab=xd;exports.FilterChip=xc;exports.FormInput=xt;exports.FormTextArea=on;exports.GUJI_MARKDOWN_FIELD=Ah;exports.GUJI_TABLE_NOTATION=$c;exports.GlyphBadge=yo;exports.GujiInteractiveReader=yx;exports.GujiTable=ko;exports.GujiTextViewer=Bo;exports.GujiWarpCanvas=Lo;exports.HomePage=Or;exports.ImagePanel=_r;exports.IndexApp=bx;exports.IndexBrowser=Sr;exports.IndexDetail=ro;exports.IndexEditor=ud;exports.IndexView=db;exports.IntroGrid=Kh;exports.LAYOUTS=u0;exports.LAYOUT_STORAGE_KEY=Gi;exports.LOSS_OPTIONS=fl;exports.LocaleContext=It;exports.LocaleProvider=wu;exports.LocaleToggle=Gr;exports.META_HOME_CSS=Qd;exports.META_HOME_SECTION_IDS=xp;exports.MetaCatalogTable=lp;exports.MetaCollectionGroups=up;exports.MetaDataLicense=fp;exports.MetaHomeView=n0;exports.MetaLine=at;exports.MetaLineageCards=hp;exports.MetaOnlineSites=gp;exports.MetaPeopleTimeline=mp;exports.MetaRecentPanel=sp;exports.MetaRelatedCatalogs=dp;exports.MetaTypeChips=ip;exports.ModeIndicator=ul;exports.MoreButton=Qh;exports.MoreLink=xo;exports.PAGE_MAX_WIDTH=mi;exports.PERIOD_NARROW_SHARE=Hd;exports.PageFrame=Rn;exports.Quote=cg;exports.READER_CSS=Ol;exports.READ_HOME_CSS=Ko;exports.READ_HOME_NARROW_QUERY=Yn;exports.READ_HOME_SECTION_IDS=Jd;exports.READ_PERIOD_LABELS=Gy;exports.RECENT_IDS_STORAGE_KEY=hn;exports.ROLE_CLASS_ORDER=nc;exports.ReadButton=Ir;exports.ReadFamousWorks=Kd;exports.ReadHomeView=qy;exports.ReadPeriodBand=Xd;exports.ReadPicks=Vd;exports.ReadPieces=Zd;exports.ReadSection=mt;exports.ReadShelf=Zo;exports.ReadSibu=Jo;exports.ReadStats=Ud;exports.ReadTopicGroup=Yd;exports.ReadTopics=qd;exports.ReaderMdText=$o;exports.ReaderShell=Yl;exports.ReaderToc=Fl;exports.RelationPanel=sd;exports.RepoSourceLink=Yr;exports.ResourceEditor=kr;exports.ResourceGroup=dg;exports.ResourceLine=pg;exports.ResourceList=eo;exports.ResourceRow=wc;exports.SEARCH_VIEW_STORAGE_KEY=to;exports.SEVEN_PAVILIONS_KEY=pp;exports.SNIPPET_MARK_END=nl;exports.SNIPPET_MARK_START=tl;exports.SORTABLE_TYPES=gl;exports.SearchInput=hl;exports.SearchResults=wl;exports.Sec=lt;exports.Section=St;exports.SectionHead=Zh;exports.SideList=rn;exports.SmartBidInput=gi;exports.SourceEditor=id;exports.StripWarpRenderer=Mr;exports.SummaryCard=Dn;exports.THEMES=yp;exports.THEME_INIT_SCRIPT=x0;exports.THEME_STORAGE_KEY=Ui;exports.TRADITIONAL_ALLOWLIST=pl;exports.TabFilter=Ai;exports.TableHead=ig;exports.TableRow=rg;exports.TagRow=Sc;exports.TagRows=ug;exports.TextButton=Jh;exports.TextReader=Wo;exports.ThemeToggle=y0;exports.TopStrip=Er;exports.VersionLineageGraph=Sd;exports.VersionLineageList=wd;exports.VersionLineageView=Vo;exports.VolumeChips=tg;exports.VolumeLinks=jo;exports.WorkCard=Ld;exports.WorkCardGrid=Pd;exports.WorkCatalog=Tx;exports.WorkPage=vd;exports.WorkRow=Ad;exports.adaptCharCord=zx;exports.adaptEntityJson=Bc;exports.adaptNorm=nd;exports.adaptNormDetailed=td;exports.adaptPunctJson=vx;exports.applyLayout=g0;exports.applyTheme=kp;exports.authorsLine=Hi;exports.bookIndexUriToId=Ar;exports.bookMarkingOf=_o;exports.bucketResources=po;exports.buildCatalogTree=Ry;exports.buildCollectionTable=oc;exports.buildLineageGraph=fi;exports.buildMeiliFilter=Fu;exports.buildPageUrl=Jr;exports.buildParagraphBlocks=Rc;exports.buildVersionRow=ec;exports.buildVersionTable=tc;exports.canParagraphize=ji;exports.catalogNodeIdOf=Iy;exports.catalogNodeIdsOf=Ey;exports.catalogPageCount=Py;exports.catalogTotal=qo;exports.classificationPath=Gn;exports.clearAllRecentIds=no;exports.compareCatalogCards=My;exports.computeVersionPartition=zh;exports.countActiveFilters=Ni;exports.createTextApi=Ll;exports.currentLayout=f0;exports.currentTheme=wp;exports.defaultEntityHref=Yc;exports.defaultWorkLink=Ed;exports.deriveDating=vh;exports.deriveEditionType=ac;exports.deriveEra=Fn;exports.deriveYear=Ei;exports.deriveYearRange=co;exports.detailToEditor=hd;exports.detectGenre=Pi;exports.displayAuthorRole=mo;exports.editorToDetail=cb;exports.eraRank=Tr;exports.filtersFromParams=Hu;exports.filtersToParams=xi;exports.findCatalogPath=mn;exports.findTraditionalChars=$u;exports.firstAuthorText=Xo;exports.flattenTitles=Lr;exports.flattenToc=Gl;exports.fmtCount=Ke;exports.formatHitCount=pi;exports.formatTemplate=bt;exports.formatVolumeRange=Li;exports.getDisplayNameFromUrl=bn;exports.getMessages=jn;exports.getStartPage=Zr;exports.getT=vn;exports.getTypeGroupKey=Kr;exports.groupRelatedWorks=kh;exports.gujiInlineToPlain=pc;exports.hasActiveFilters=bl;exports.hasGujiMarkdownV02=Mh;exports.hasGujiTableNotation=gg;exports.hasSearchOptions=Bu;exports.iiifVolumeOf=kx;exports.isCountedChar=Co;exports.isLayoutName=Sp;exports.isThemeName=jp;exports.lineageHref=tp;exports.loadRecentIds=Yt;exports.measureText=Ht;exports.mergeVolumeResources=Xr;exports.normalizeEra=st;exports.normalizeLayout=Yi;exports.normalizeRole=uo;exports.normalizeTheme=Vi;exports.normalizeVolumeIndex=Mn;exports.normalizeVolumes=ol;exports.numberToChinese=sc;exports.paginationItems=Nd;exports.parseChineseNumber=bi;exports.parseGujiInline=dc;exports.parseGujiTable=zc;exports.parseSourceString=rd;exports.pct=Qo;exports.periodLevel=Fd;exports.pickReaderVersion=Vl;exports.readStoredLayout=m0;exports.readStoredTheme=p0;exports.readerVersionOptionLabel=Cr;exports.remapPlainOffsets=Oc;exports.removeRecentId=Sl;exports.renderFullTextBody=_g;exports.renderProperNames=Mc;exports.renderReaderInline=Bi;exports.resolveRecentEntry=io;exports.resourceHref=yn;exports.resourceNote=Ri;exports.resultTabFromParam=Ju;exports.resultTabToParam=Qu;exports.roleFacets=ic;exports.rowNo=og;exports.sameFilters=Du;exports.saveRecentId=wr;exports.segmentEntities=Wc;exports.shelfColumns=Od;exports.sortFor=Ou;exports.sortYear=yi;exports.spineHeight=Wd;exports.splitFullTextTables=vo;exports.splitHighlightSnippet=qr;exports.splitTableRow=Cc;exports.storeLayout=h0;exports.storeTheme=vp;exports.stringifySources=od;exports.summaryFromEntry=Vc;exports.summaryFromItem=Uc;exports.timelineLayout=np;exports.toCatalogWorkCard=Ay;exports.transportSummaryLoader=Gc;exports.typeSupportsFilters=yl;exports.useBidUrl=rt;exports.useChapterWarpData=Xc;exports.useConvert=Pe;exports.useEntitySummaryLoader=Mo;exports.useI18n=ne;exports.useReaderPrefs=Ul;exports.useRecentEntries=rp;exports.useT=Ie;exports.validateLineageGraph=Kb;exports.volumeStats=Si;exports.withDefaultLinks=qt;exports.withMetaLinks=Kt;exports.yearText=wi;