book-index-ui 0.61.1 → 0.61.2
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 +52 -52
- package/dist/index.js +1831 -1811
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var fu=Object.create;var Ps=Object.defineProperty;var gu=Object.getOwnPropertyDescriptor;var xu=Object.getOwnPropertyNames;var bu=Object.getPrototypeOf,yu=Object.prototype.hasOwnProperty;var ju=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of xu(n))!yu.call(e,s)&&s!==i&&Ps(e,s,{get:()=>n[s],enumerable:!(o=gu(n,s))||o.enumerable});return e};var ui=(e,n,i)=>(i=e!=null?fu(bu(e)):{},ju(n||!e||!e.__esModule?Ps(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ze=require("./storage-entry-Cx6j1zcJ.cjs"),t=require("react/jsx-runtime"),f=require("react"),vu=require("opencc-js/t2cn"),Sl=require("./variant-supplement.cjs"),ku=require("react-markdown"),wu=require("remark-gfm"),Su=e=>`/item/${e}`,_l=f.createContext(Su);function _u({buildUrl:e,children:n}){const i=f.useMemo(()=>e,[e]);return t.jsx(_l.Provider,{value:i,children:n})}function st(){return f.useContext(_l)}const $l="",Cl="";function co(e){const n=[];let i=!1,o=e;for(;o.length;){const s=i?Cl:$l,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 gt(e,n){return{title:e,tokens:n}}const Bs='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',$u=[gt("基础(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"}}),gt("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),gt("提示与警告",{"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)"}}),gt("遮罩与阴影",{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)"}}),gt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),gt("资源",{"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"}}),gt("整理本(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:"中性灰:占位"}}),gt("版本传承(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"}}),gt("编辑器视图(主要在 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")'}}),gt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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}}),gt('版式(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"}}),gt("阅读器(整理本 / 全文)",{"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:"版心外边线"}}),gt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),gt("字体(全站无衬线,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,只需覆盖那一个就同时换掉"}})],Cu=Object.assign({},...$u.map(e=>e.tokens)),zl={};for(const[e,n]of Object.entries(Cu))zl[e]=`var(--bim-${e}, ${n.value})`;function r(e){const n=zl[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function Ht(e){return e.types&&e.types.length>0?e.types:[]}function zu(e,n){return Ht(e).includes(n)}const Nu={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 Tu={"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 kn(e){try{return Tu[new URL(e).hostname]}catch{return}}const Os={text:0,image:1,physical:2};function po(e){return e.length===0?"physical":[...e].sort((n,i)=>(Os[n]??99)-(Os[i]??99)).join("+")}function Iu(e){return e.includes("text")&&e.includes("image")?"text+image":e[0]||"physical"}function uo(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,m]=p,u=`${h}|${po(Ht(c))}`;i.has(u)||i.set(u,{base:{...c,name:h,url:"",volumes:[]},volumes:[],indices:[]});const g=i.get(u);g.volumes.push({volume:m,url:c.url||void 0,status:"found"}),g.indices.push(d)}const o=[],s=new Set;for(const d of i.values())if(!(d.volumes.length<2)){d.volumes.sort((c,p)=>c.volume-p.volume),d.base.volumes=d.volumes,d.base.expected_volumes=d.volumes.length,d.base.url||(d.base.url=((l=d.volumes.find(c=>c.url))==null?void 0:l.url)??""),o.push(d.base);for(const c of d.indices)s.add(c)}const a=[...o];for(let d=0;d<e.length;d++)s.has(d)||a.push(e[d]);return a}function Nl(e){if(e.url)return e.url;for(const[n,i]of Object.entries(e))if(n.endsWith("_url")&&typeof i=="string")return i}function Tl(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||Nl(n)}))}function Ii(e){const n=Tl(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 mo(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 ho(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 wn(e){if(!e.url)return;const n=mo(e.metadata);return n?ho(e.url,n):e.url}const Lt=f.createContext(null),Il=["曹霑"];function Ru(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Eu(e,n=Il){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(Ru).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 En=null;function Rl(){if(En)return En;try{const e=vu.Converter({from:"t",to:"cn"});En=Eu(n=>e(ze.normalizeVariants(n)))}catch{En=e=>e}return En}const Lu={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:"圖片資源"}},Au={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 yt(e,n,i){return{"zh-Hant":e,"zh-Hans":n}}const Mu=yt({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:"无数据"}),Ri=yt({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:"作品信息"}),Pu=yt({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:"附记"}}),Bu=yt({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}"}}),Ou=yt({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:"上级丛编"}),Wu=yt({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:"来源"}),Fu=yt({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}",tocExpand:"展開",tocCollapse:"收起",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}",tocExpand:"展开",tocCollapse:"收起",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",originalSource:"本站独立整理",charGuess:"残字(推测)",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献",entityDetail:"查看详情 →"}),Hu=yt({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:"本卷条目"}),Du=yt({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:"规模、存佚、许可与版本"}),fo=yt({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:"按作者浏览全部 →"}),Uu=yt({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} 条"}),Vu=yt({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:"搜索"}),Gu=yt({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:"回复"}),Yu=yt({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:"有争议"}}),qu={common:Mu,detail:Ri,bookPage:Pu,workPage:Bu,collectionPage:Ou,entityPage:Wu,reader:Fu,collated:Hu,metaHome:Du,readHome:fo,catalogPage:Uu,searchPage:Vu,feedback:Gu,lineage:Yu};function Ku(e){const n={};for(const[i,o]of Object.entries(qu))n[i]=o[e];return n}function wt(e,n){return e.replace(/\{(\w+)\}/g,(i,o)=>String(n[o]??""))}const Ws=new Map;function Sn(e){let n=Ws.get(e);return n||(n={...e==="zh-Hans"?Au:Lu,...Ku(e)},Ws.set(e,n)),n}function Fs(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 El(e){return(n,i)=>{const o=Fs(e,n)??Fs(Sn("zh-Hant"),n)??n;return i?wt(o,i):o}}const Hs=new Map;function _n(e){let n=Hs.get(e);return n||(n=El(Sn(e)),Hs.set(e,n)),n}const Ll="bim-locale";function Xu(){try{const e=localStorage.getItem(Ll);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function Zu(e){try{localStorage.setItem(Ll,e)}catch{}}const Ju="zh-Hans",Qu=({locale:e,onLocaleChange:n,converter:i,children:o})=>{const[s,a]=f.useState(e??Ju),l=e??s;f.useEffect(()=>{if(e)return;const h=Xu();h&&h!==s&&a(h)},[]);const d=f.useMemo(()=>l==="zh-Hans"?i??Rl():null,[l,i]),c=f.useCallback(h=>{a(h),Zu(h),n==null||n(h)},[n]),p=f.useMemo(()=>({locale:l,setLocale:c,messages:Sn(l),converter:d}),[l,c,d]);return t.jsx(Lt.Provider,{value:p,children:o})};function Ae(){const e=f.useContext(Lt);return(e==null?void 0:e.messages)??Sn("zh-Hant")}const em=2e3;function Ve(){const e=f.useContext(Lt),n=(e==null?void 0:e.locale)??"zh-Hant",i=(e==null?void 0:e.converter)??null,o=f.useRef(new Map),s=f.useRef(n),a=f.useRef(i);(s.current!==n||a.current!==i)&&(o.current.clear(),s.current=n,a.current=i);const l=f.useCallback(d=>{if(!d)return"";if(!i)return d;const c=o.current.get(d);if(c!==void 0)return c;const p=i(d);if(o.current.size>=em){const h=o.current.keys().next().value;h!==void 0&&o.current.delete(h)}return o.current.set(d,p),p},[i]);return f.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function re(){const e=f.useContext(Lt),{convert:n,locale:i,isSimplified:o}=Ve(),s=(e==null?void 0:e.messages)??Sn("zh-Hant"),a=f.useMemo(()=>e?El(s):_n("zh-Hant"),[e,s]);return f.useMemo(()=>({t:a,convert:n,locale:i,isSimplified:o,messages:s}),[a,n,i,o,s])}const Al=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),tm=new Set([...Al,...Object.keys(ze.VARIANT_CHARS),...Object.keys(Sl.VARIANT_SUPPLEMENT)]),Ml=[...Il,"切換為繁體","漢籍リポジトリ"];function nm(e,n=Ml){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)=>{tm.has(a)&&o.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),o}function im(e,n,i){return e?e==="orig"?null:n==="zh-Hans"?i??Rl():e==="hant"?ze.normalizeVariants:i:n==="zh-Hans"?i:ze.normalizeVariants}const rm=({mode:e,children:n})=>{const i=f.useContext(Lt),o=f.useMemo(()=>i&&{...i,converter:im(e,i.locale,i.converter)},[i,e]);return t.jsx(Lt.Provider,{value:o,children:n})};function om(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 Ds(e){return e==="text+image"?["text","image"]:[e]}function Us(e){const n=Ht(e);return n.length===0?"text":Iu(n)}function sm(){return{id:"",name:"",url:"",types:["text"],details:""}}const Ar=({items:e,onChange:n,onDownload:i,downloadStatuses:o,filterType:s})=>{const a=Ae(),[l,d]=f.useState(null),c=[{value:"text",label:a.resourceTypeShort.text},{value:"image",label:a.resourceTypeShort.image},{value:"text+image",label:a.resourceTypeShort.textImage},{value:"physical",label:a.resourceTypeShort.physical}],p=[{value:"catalog",label:a.rootType.catalog},{value:"search",label:a.rootType.search}],h=w=>{if(!s)return!0;const v=Ht(w);return s==="text"?v.includes("text"):s==="image"?v.includes("image")||v.includes("physical"):s==="physical"?v.includes("physical"):v.includes(s)},m=e.map((w,v)=>({item:w,originalIndex:v})).filter(({item:w})=>h(w)),u=()=>{const w=sm();s&&(w.types=Ds(s)),n([...e,w]),d(e.length)},g=w=>{n(e.filter((v,k)=>k!==w)),d(null)},x=(w,v,k)=>{const z=[...e];if(z[w]={...z[w],[v]:k},v==="url"&&!z[w].id){const C=om(k);C&&(z[w].id=C)}n(z)},j=(w,v)=>{const k=[...e],{type:z,...C}=k[w];k[w]={...C,types:Ds(v)},n(k)},y=(w,v,k)=>{const C={...e[w].metadata||{}};k?C[v]=k:delete C[v],x(w,"metadata",Object.keys(C).length>0?C:void 0)},S=(w,v)=>{const k=v.trim()?v.split(/[,,、]/).map(z=>z.trim()).filter(Boolean):void 0;x(w,"structure",k)},b=(w,v,k)=>{const C=e[w].coverage||{level:1,ranges:""};v==="level"?C.level=parseInt(k)||1:C.ranges=k,x(w,"coverage",C.ranges?C:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[m.map(({item:w,originalIndex:v})=>{var k,z,C;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>d(l===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:am(Us(w)),color:r("on-color-fg")},children:(()=>{var R,T;const _=Ht(w);return _.length===0?"text":_.length===1?((R=c.find(N=>N.value===_[0]))==null?void 0:R.label)??_[0]:_.includes("text")&&_.includes("image")?((T=c.find(N=>N.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&&lm(v,o==null?void 0:o[v],i,a),t.jsx("button",{onClick:_=>{_.stopPropagation(),g(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:[zu(w,"image")&&w.url&&cm(w,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Ln,children:[t.jsx("span",{style:An,children:a.label.type}),t.jsx("select",{value:Us(w),onChange:_=>j(v,_.target.value),style:{...Tt,flex:1},children:c.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]}),t.jsxs("label",{style:Ln,children:[t.jsx("span",{style:An,children:a.label.rootType}),t.jsx("select",{value:w.root_type||"catalog",onChange:_=>x(v,"root_type",_.target.value),style:{...Tt,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:{...Tt,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:w.name,onChange:_=>x(v,"name",_.target.value),placeholder:a.editor.resourceName,style:{...Tt,flex:1}})]}),t.jsx("input",{type:"text",value:w.url,onChange:_=>x(v,"url",_.target.value),placeholder:a.editor.resourceUrl,style:Tt}),t.jsx("input",{type:"text",value:((k=w.structure)==null?void 0:k.join("、"))||"",onChange:_=>S(v,_.target.value),placeholder:a.editor.structurePlaceholder,style:Tt}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Ln,children:[t.jsx("span",{style:An,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((z=w.coverage)==null?void 0:z.level)??"",onChange:_=>b(v,"level",_.target.value),placeholder:"1",style:{...Tt,width:"60px"}})]}),t.jsxs("label",{style:{...Ln,flex:1},children:[t.jsx("span",{style:An,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:((C=w.coverage)==null?void 0:C.ranges)||"",onChange:_=>b(v,"ranges",_.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...Tt,flex:1}})]})]}),t.jsx("textarea",{value:w.details||"",onChange:_=>x(v,"details",_.target.value),placeholder:a.editor.detailsPlaceholder,style:{...Tt,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(([_,R])=>{var T;return t.jsxs("label",{style:{...Ln,gap:"4px"},children:[t.jsx("span",{style:{...An,minWidth:"56px"},children:R}),t.jsx("input",{type:"text",value:((T=w.metadata)==null?void 0:T[_])||"",onChange:N=>y(v,_,N.target.value),placeholder:R,style:{...Tt,flex:1}})]},_)})})]})]})]})]},v)}),t.jsxs("button",{onClick:u,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:a.action.addResource})]})]})};function am(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 lm(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 cm(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 Tt={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"},Ln={display:"flex",alignItems:"center",gap:"6px"},An={fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap"},Vs={text:r("restype-text"),image:r("restype-image"),"text+image":r("restype-text-image"),physical:r("restype-physical")};function dm(e){return e.includes("text")&&e.includes("image")?Vs["text+image"]:Vs[e[0]||"physical"]}const go=({items:e,groupByType:n=!0,resourceGroups:i,onNavigate:o,renderLink:s})=>{const a=Ae(),{convert:l}=Ve(),d=f.useMemo(()=>uo(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=f.useMemo(()=>{const y=new Map,S=[];for(const b of d){const w=b.group;w?(y.has(w)||y.set(w,[]),y.get(w).push(b)):S.push(b)}for(const b of y.values())b.sort((w,v)=>{const k=z=>z.group_role==="origin"?0:z.group_role==="mirror"?1:2;return k(w)-k(v)});return{mirrorGroups:y,ungroupedItems:S}},[d]),h={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},m=y=>h[y]?h[y]:y.split("+").map(S=>h[S]||S).join("+");if(!d||d.length===0)return t.jsx("div",{style:{padding:"16px",color:r("desc-fg"),fontSize:"13px",textAlign:"center"},children:a.misc.noResources});if(!n)return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:d.map((y,S)=>t.jsx(hr,{item:y},y.id||S))});const u=(y,S)=>{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:S.map((k,z)=>t.jsx(hr,{item:k,onNavigate:o,renderLink:s},k.id||z))})]},`group-${y}`)},g=new Map;for(const y of p){const S=po(Ht(y));g.has(S)||g.set(S,[]),g.get(S).push(y)}const x=["text","image","text+image","physical"],j=[...x.filter(y=>g.has(y)),...[...g.keys()].filter(y=>!x.includes(y)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,S])=>u(y,S)),j.map(y=>{const S=g.get(y),b=dm(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:m(y)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:S.map((w,v)=>t.jsx(hr,{item:w,onNavigate:o,renderLink:s},w.id||v))})]},y)})]})},pm={bw:{label:"",bg:r("colormode-bw-bg"),fg:r("colormode-bw-fg")},color:{label:"",bg:r("colormode-color-bg"),fg:r("colormode-color-fg")}},hr=({item:e})=>{const n=Ae(),{convert:i}=Ve(),[o,s]=f.useState(!1),a=f.useMemo(()=>(e.url?kn(e.url):void 0)||i(e.name),[e.url,e.name,i]),l=f.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||Nl(x)})),[e.volumes]),d=l&&l.length>0,c=d?new Set(l.filter(x=>x.status!=="missing").map(x=>x.volume)).size:0,p=d?new Set(l.filter(x=>x.status==="missing").map(x=>x.volume)).size:0,h=e.expected_volumes??(d?c+p:0),m=e.color_mode?{...pm[e.color_mode],label:n.colorMode[e.color_mode]}:null,u=e.details&&!d?i(e.details):null,g={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:g,children:[t.jsx("span",{style:{fontWeight:500},children:a}),m&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:m.bg,color:m.fg},children:m.label}),u&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:u}),d&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[c,"/",h,n.unit.volume,p>0&&t.jsx("span",{style:{color:r("missing-fg"),marginLeft:"3px"},children:wt(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=mo(e.metadata);return x?ho(e.url,x):e.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:r("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),d&&t.jsx("button",{onClick:()=>s(!o),style:{padding:"0 6px",fontSize:"11px",border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",lineHeight:1.4},children:o?"▲":"▼"})]}),d&&o&&t.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${r("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:l.map(x=>{const j=x.status==="missing";return x.url&&!j?t.jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",borderRadius:"3px",border:`1px solid ${r("widget-border")}`,color:r("link-fg"),textDecoration:"none"},children:x.volume},x.volume):t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:r(j?"missing-fg":"desc-fg"),textDecoration:j?"line-through":"none",opacity:j?.6:1},children:x.volume},x.volume)})})]})},Pl=({indexSource:e,syncConfig:n,variant:i="index-browser",onSwitchMode:o,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=Ae(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,h=(n==null?void 0:n.repoPath)||"",m=h?h.split(/[/\\]/).pop()||h:"",u={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:r("primary-soft"),color:r("primary")},g={onMouseOver:j=>j.currentTarget.style.opacity="0.8",onMouseOut:j=>j.currentTarget.style.opacity="1"},x=t.jsxs("div",{onClick:s,title:p?d.mode.switchToOfficial:d.mode.switchToDraft,style:{...u,background:r(p?"warning":"success"),color:r("on-color-fg")},...g,children:[t.jsx("span",{children:p?"📝":"📚"}),t.jsx("span",{children:p?"draft":"official"})]});return i==="index-browser"?c?t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[x,t.jsxs("div",{onClick:o,title:d.mode.switchToSync,style:u,...g,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:{...u,paddingLeft:"8px",paddingRight:"8px"},...g,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]})]}):t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.jsxs("div",{onClick:o,title:d.mode.switchToLocal,style:u,...g,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:m||d.mode.configurePath,style:{...u,background:"transparent",padding:"6px",fontSize:"12px"},...g,children:t.jsx("span",{children:"⚙️"})})]})]}):t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[t.jsxs("div",{onClick:o,title:c?d.mode.switchToGithub:d.mode.switchToLocal,style:u,...g,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:{...u,paddingLeft:"8px",paddingRight:"8px",minWidth:h?"100px":"auto",justifyContent:"space-between"},...g,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]}),!c&&m&&t.jsxs("div",{style:{...u,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:m})]})]})},Ei="bim-search-history",Gs=10,Ys=8;function Hn(){try{const e=localStorage.getItem(Ei);return e?JSON.parse(e):[]}catch{return[]}}function Bl(e){try{const n=Hn().filter(i=>i!==e);n.unshift(e),n.length>Gs&&(n.length=Gs),localStorage.setItem(Ei,JSON.stringify(n))}catch{}}function um(e){try{const n=Hn().filter(i=>i!==e);localStorage.setItem(Ei,JSON.stringify(n))}catch{}}function mm(){try{localStorage.removeItem(Ei)}catch{}}const Ol=({transport:e,value:n,onChange:i,onSearch:o,onEntrySelect:s,placeholder:a})=>{const l=Ae(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,h]=f.useState(!1),[m,u]=f.useState([]),[g,x]=f.useState(-1),[j,y]=f.useState(Hn),S=f.useRef(null),b=f.useRef(null),w=f.useRef(null),v=f.useRef(!1);f.useEffect(()=>{x(-1);const N=n.trim();if(!N){u(j.map(F=>({type:"history",text:F})));return}if(!e.searchAll){u([]);return}let E=!1;const W=setTimeout(()=>{e.searchAll(N,Ys).then(F=>{if(E)return;const A=[...F.works,...F.books,...F.collections,...F.entities??[]];u(A.slice(0,Ys).map(V=>({type:"entry",text:V.title||V.id,entry:V})))}).catch(()=>{E||u([])})},80);return()=>{E=!0,clearTimeout(W)}},[n,j,e]),f.useEffect(()=>{const N=E=>{w.current&&!w.current.contains(E.target)&&h(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]),f.useEffect(()=>{const N=E=>{var W,F;if(E.key==="/"&&document.activeElement!==S.current){const A=(W=document.activeElement)==null?void 0:W.tagName;if(A==="INPUT"||A==="TEXTAREA"||A==="SELECT")return;E.preventDefault(),(F=S.current)==null||F.focus()}};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[]);const k=f.useCallback(N=>{N.trim()&&(Bl(N.trim()),y(Hn())),o(N),h(!1)},[o]),z=f.useCallback(N=>{N.type==="history"?(i(N.text),k(N.text)):N.entry&&(s?(s(N.entry),h(!1)):(i(N.text),k(N.text)))},[i,k,s]),C=f.useCallback(N=>{if(!p||m.length===0){N.key==="Enter"&&k(n);return}switch(N.key){case"ArrowDown":N.preventDefault(),x(E=>(E+1)%m.length);break;case"ArrowUp":N.preventDefault(),x(E=>(E-1+m.length)%m.length);break;case"Enter":N.preventDefault(),g>=0&&g<m.length?z(m[g]):k(n);break;case"Escape":N.preventDefault(),h(!1);break}},[p,m,g,n,k,z]),_=f.useCallback((N,E)=>{E.stopPropagation(),um(N),y(Hn()),u(W=>W.filter(F=>!(F.type==="history"&&F.text===N)))},[]),R=f.useCallback(N=>{N.stopPropagation(),mm(),y([]),u([])},[]);f.useEffect(()=>{if(g>=0&&b.current){const N=b.current.children;N[g]&&N[g].scrollIntoView({block:"nearest"})}},[g]);const T=!n.trim()&&j.length>0;return t.jsxs("div",{ref:w,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:S,type:"text",placeholder:d,value:n,onChange:N=>{i(N.target.value),h(!0)},onCompositionStart:()=>{v.current=!0},onCompositionEnd:()=>{v.current=!1},onFocus:()=>{h(!0)},onKeyDown:C,style:{width:"100%",padding:"8px 12px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),fontSize:"14px",boxSizing:"border-box"}}),p&&m.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:R,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),m.map((N,E)=>t.jsxs("div",{onClick:()=>z(N),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:r("fg"),background:E===g?r("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:N.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N.text}),N.entry&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:[c[N.entry.type],N.entry.edition&&` · ${N.entry.edition}`,N.entry.author&&` · ${N.entry.author}`]}),N.type==="history"&&t.jsx("button",{onClick:W=>_(N.text,W),style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:l.action.remove,children:"×"})]},`${N.type}-${N.text}-${E}`))]})]})},$n=({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"}}),Wl=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],hm={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function lt(e){return hm[e]??e}const bn=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],yn={熹平: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},Fl={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function Li(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 fm(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 gm=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,qs={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function xo(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(qs))if(n.startsWith(s))return qs[s];const i=lt(n);if(nn[i]!=null)return i;const o=Ft(n);if(o&&n.length<=o.length+1)return lt(o)}function tn(e,n){if(n){const i=Fl[`${n}|${e}`];if(i!=null)return i}return yn[e]}const xm=1911;function bm(e){const n=yn[e];if(n==null)return;const i=Et[e];let o;for(const[s,a]of Object.entries(yn))Et[s]===i&&a>n&&(o==null||a<o)&&(o=a);return o!=null?o-1:void 0}const ym={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function Si(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=ym[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 Ft(e){for(const n of Wl)if(e.startsWith(n))return n}const Et={};{const e=(n,i)=>{for(const o of i)Et[o]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function rn(e,n){const i=n==="北宋"||n==="南宋"?"宋":n;for(const o of Object.keys(yn))if(e.includes(o)&&!(i&&Et[o]&&Et[o]!==i&&Fl[`${i}|${o}`]==null))return o}function Kn(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=Ft(o)??"";return{era:lt(p),reign:rn(o,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=Li(s);if(p)return{era:fm(p.from),reign:"",source:"publication"};const h=Ft(s)??xo(s)??((c=bn.find(g=>g.pattern.test(s)))==null?void 0:c.era)??"",m=rn(s,h)??"",u=h||(m?Et[m]??"":"");if(u||m)return{era:lt(u),reign:m,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=Ft(a);if(p)return{era:lt(p),reign:rn(a,p)??"",source:"edition"};const h=bn.find(m=>m.pattern.test(a));if(h)return{era:lt(h.era),reign:rn(a,h.era)??h.reign??"",source:"edition"}}return n}function Ai(e){var o,s,a,l,d,c,p,h,m;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 u=Li(n);if(u)return u.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 u of i){const g=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(g&&u!==g&&(Ft(g)||xo(g)))break;const x=u.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??u.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 j=u.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(j){const w=Ft(u);if(!w||lt(w)==="民國"){const k=Si(j[1]);if(k!=null&&k>=1&&k<=120)return xm+k}}const y=Ft(u)??((h=bn.find(w=>w.pattern.test(u)))==null?void 0:h.era),S=y?lt(y):void 0,b=rn(u,S)??(Ft(u)||(m=bn.find(w=>w.pattern.test(u)))==null?void 0:m.reign);if(b){const w=tn(b,S);if(w==null)continue;const v=u.indexOf(b),k=v>=0?u.slice(v+b.length):"",z=k.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??k.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),C=z?Si(z[1]):void 0;return w+(C?C-1:0)}}}function bo(e){var l,d,c,p,h,m;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 u=o.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(u){const g=Mr[lt(u[1])],x=nn[lt(u[2])];if(g!=null&&x!=null)return{from:Math.min(g,x)-20,to:Math.max(g,x)+40}}}const s=(p=e.publication_info)==null?void 0:p.year;if(s){const u=Li(s);if((u==null?void 0:u.to)!=null)return{from:u.from,to:u.to};const g=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(g){const x=Mr[lt(g[1])],j=nn[lt(g[2])];if(x!=null&&j!=null)return{from:Math.min(x,j)-20,to:Math.max(x,j)+40}}}const a=[(h=e.publication_info)==null?void 0:h.year,e.edition,e.title].filter(Boolean);for(const u of a){if(!/[間间]/.test(u))continue;const g=Ft(u)??xo(u)??((m=bn.find(y=>y.pattern.test(u)))==null?void 0:m.era),x=g?lt(g):void 0,j=[];for(const y of Object.keys(yn))u.includes(y)&&(x&&Et[y]&&Et[y]!==x||tn(y,x)!=null&&j.push(y));if(j.length===0){const y=u.match(/([一-鿿])([一-鿿])[間间]/);if(y&&x){for(const S of[y[1],y[2]])for(const b of Object.keys(yn))if(Et[b]===x&&!(b[0]!==S&&b[b.length-1]!==S)&&tn(b,x)!=null){j.push(b);break}}}if(j.length>0){const y=j.map(v=>tn(v,x)).filter(v=>v!=null),S=Math.min(...y),b=j.reduce((v,k)=>tn(v,x)>=tn(k,x)?v:k),w=bm(b)??fr(x??"")??Math.max(...y);return{from:S,to:w>S?w:fr(x??Et[b]??"")??S}}if(x&&nn[x]!=null)return{from:nn[x],to:fr(x)??nn[x]}}}const nn={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},jm=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],vm=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,Ks=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function Xs(e,n){for(const i of Wl){const o=e.indexOf(i);if(o<0)continue;if(i.length===1){const c=e[o+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!rn(e.slice(o),lt(i)))continue}const s=lt(i);if(s===n)continue;const a=e.slice(o),l=rn(a,s)??"";let d;if(l){const c=tn(l,s);if(c!=null){const h=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),m=h?Si(h[1]):void 0;d=c+(m?m-1:0)}}return{era:s,reign:l,year:d}}for(const i of bn)if(i.pattern.test(e))return{era:lt(i.era),reign:i.reign??""}}function km(e){var S,b,w,v,k;const n=Kn(e),i=((S=e.publication_info)==null?void 0:S.year)??"",o=i?Li(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"&&gm.test(i),p=n.source==="publication"&&/[間间]/.test(i),h=l.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let m;a||d||c||p?m=void 0:h?m=parseInt(h[2],10):m=Ai(e);const u=m==null?bo(e):void 0;let g;n.source==="publication"&&(c||Ks.test(i))?g="uncertain":n.source==="lineage"||n.source==="publication"?g="attested":Ks.test(s)||!n.reign&&m==null?g="uncertain":g="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)??""}」`:`出版著錄「${((k=e.publication_info)==null?void 0:k.year)??""}」`,j={era:n.era,reign:n.reign,year:m,yearRange:u,certainty:g,source:n.source==="edition"?"edition":"catalog",basis:x};if(h){const z=l.match(/[、,,]\s*([宋元明清])/);z&&z[1]!==j.era&&(j.laterRepair={era:z[1]})}if(!j.laterRepair&&vm.test(s)){const z=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);z&&z[1]!==n.era&&(j.laterRepair={era:z[1]})}const y=jm.find(z=>z.re.test(s));if(y){const z=s.search(y.re),C=s.slice(z),_=Xs(C,n.era)??Xs(s,n.era);_&&(j.basedOn={era:_.era,reign:_.reign,year:_.year,relation:y.relation})}return j}const Mr={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function fr(e){return Mr[e]}function _i(e){const n=Ai(e);if(n!=null)return n;const i=bo(e);if(i)return i.from;const o=Kn(e).era;return o?nn[o]:void 0}const Zs=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function Pr(e){const n=Zs.indexOf(e);return n===-1?Zs.length:n}function wm(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 yo(e,n){const i=uo(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,m)=>{const u=g=>g.group_role==="origin"?0:g.group_role==="mirror"?1:2;return u(h)-u(m)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const h=Ht(p),m=h.includes("text"),u=h.includes("image");m&&u?a.textImage.push(p):m?a.text.push(p):u?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 m,u;return{key:p,label:((m=n==null?void 0:n[p])==null?void 0:m.label)||p,description:(u=n==null?void 0:n[p])==null?void 0:u.description,items:h}});return{buckets:d,mirrors:c,total:i.length}}function Mi(e,n=_n("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=Ii(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 Hl(e,n){if(Mi(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 Sm="同版";function _m(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 $m(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===Sm&&o&&o!==e.id)return o}}function Cm(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 Dl(e,n){var a,l;const i=e.resources||[],o=[],s=[];for(const d of i){const c=Ht(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:Kn(e),year:Ai(e),sortYear:_i(e),images:o,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,callNumber:_m(s[0]),copyOf:$m(e),summary:e.summary,important:zm(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:o.length>0}}function zm(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 Ul(e,n,i={}){const o=new Set((n==null?void 0:n.excluded_books)??[]),s=Cm(e.filter(c=>!o.has(c.id)).map(c=>Dl(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,m=p.r.sortYear;return h!=null&&m!=null?h-m||c.i-p.i:h!=null?-1:m!=null?1:c.i-p.i}).map(c=>c.r):a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const h=m=>(m.important?0:1)*2+(m.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)=>Pr(c)-Pr(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function Nm(e,n){var y,S;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const i=(y=n.collections)==null?void 0:y[n.default_collection],o=(i==null?void 0:i.groups)??[],s=(i==null?void 0:i.book_ids)??[],a=o.length>0||s.length>0,l=!a&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!a&&l.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const d=new Set(o),c=new Set([...s,...l]),p=b=>{if(c.has(b))return!0;const w=n.node_groups[b];return w!=null&&d.has(w)},h=[],m=new Map,u=[];for(const b of e)if(!((S=n.excluded_books)!=null&&S.includes(b)))if(p(b))h.push(b);else{const w=n.node_groups[b];w?(m.has(w)||m.set(w,[]),m.get(w).push(b)):u.push(b)}if(u.length+[...m.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])),j=[...m.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 u.length>0&&j.push({id:"__other__",label:"其他版本",description:void 0,ids:u}),{useGrouping:!0,coreIds:h,groupedIds:j}}const Vl=["撰","編","注","校","譯","繪","其他"],Tm=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function jo(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n)return"撰";for(const{cls:i,re:o}of Tm)if(o.test(n))return i;return"其他"}function vo(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function Gl(e,n="全部"){const i=new Map;for(const s of e){const a=jo(s);i.set(a,(i.get(a)??0)+1)}const o=[{cls:"全部",label:n,count:e.length}];for(const s of Vl){const a=i.get(s);a&&o.push({cls:s,label:s,count:a})}return o.length>2?o:[]}function ko(e){return(e._books??[]).map(n=>n.id).filter(n=>typeof n=="string")}function wo(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 Yl(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:Dn(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 Im(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 ql(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}=Yl(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 Dn(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 Pi(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 Rm=["〇","一","二","三","四","五","六","七","八","九"],Js=["","十","百","千"];function Cn(e){if(!Number.isInteger(e)||e<=0)return"";if(e>=1e8)return String(e);if(e<1e4)return gr(e,!0);const n=Math.floor(e/1e4),i=e%1e4;let o=gr(n,!0)+"萬";return i>0&&(o+=(i<1e3?"〇":"")+gr(i,!1)),o}function gr(e,n){const i=String(e),o=i.length;let s="",a=!1;for(let l=0;l<o;l++){const d=parseInt(i[l]),c=o-1-l;d===0?a=!0:(a&&s&&(s+="〇"),a=!1,n&&d===1&&c===1&&l===0?s+=Js[c]:s+=Rm[d]+Js[c])}return s}function Em(e){return e==null?"":typeof e=="string"?e:"name"in e&&e.name?e.name:"title"in e&&e.title||""}function Lm(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 Dt(e,n="卷"){var o,s;const i=e;return i.measure_info?i.measure_info:(o=i.juan_count)!=null&&o.number?Cn(i.juan_count.number)+n:(s=i.juan_count)!=null&&s.description?i.juan_count.description:""}function Kl(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 Bi={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},Xl=new Set(["work","book","entity"]);function Am(e){return Ql(e)||!!e.sort}function Mm(e,n){return n.sort&&Xl.has(e)?n.sort:void 0}const Oi=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],Wi=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],Zl=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],Jl={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function Fi(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 Ql(e){return Fi(e)>0}function Pm(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 ec(e,n){const i=Jl[e];return Pm(n).every(o=>i.has(o))}const Mn=e=>JSON.stringify(e);function Bm(e,n){if(!ec(n,e))return null;const i=[];if(e.dynasty.length){const o=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=Oi.find(l=>l.key===s))==null?void 0:a.values)??[]})));o.length===1?i.push(`dynasty = ${Mn(o[0])}`):o.length>1&&i.push(`dynasty IN [${o.map(Mn).join(", ")}]`)}return e.classification.length&&i.push(e.classification.length===1?`classification = ${Mn(e.classification[0])}`:`classification IN [${e.classification.map(Mn).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 = ${Mn(e.loss)}`),i.join(" AND ")}const ft={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},tc="_";function $i(e,n=new URLSearchParams){for(const i of Object.values(ft))n.delete(i);return e.dynasty.length&&n.set(ft.dynasty,e.dynasty.join(",")),e.classification.length&&n.set(ft.classification,e.classification.map(i=>i||tc).join(",")),e.hasImage&&n.set(ft.hasImage,"1"),e.hasText&&n.set(ft.hasText,"1"),e.hasCollated&&n.set(ft.hasCollated,"1"),e.loss&&n.set(ft.loss,e.loss),e.sort&&n.set(ft.sort,e.sort),n}function Om(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),i=new Set(Oi.map(a=>a.key)),o=new Set(Wi.map(a=>a.value)),s=e.get(ft.loss);return{dynasty:Array.from(new Set(n(ft.dynasty).filter(a=>i.has(a)))),classification:Array.from(new Set(n(ft.classification).map(a=>a===tc?"":a).filter(a=>o.has(a)))),hasImage:e.get(ft.hasImage)==="1",hasText:e.get(ft.hasText)==="1"||e.get(ft.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(ft.sort))??""}}function Wm(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 Qs(e,n){return e.includes(n)?e.filter(i=>i!==n):[...e,n]}const Fm=({filters:e,onChange:n})=>{const i=Ae(),o=i.searchV4,{convert:s}=Ve(),[a,l]=f.useState(!1),d=f.useId(),c=Fi(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(wt(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:Oi.map(h=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(h.key),onClick:()=>p({dynasty:Qs(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)}),Wi.map(h=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(h.value),onChange:()=>p({classification:Qs(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:Zl.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({...Bi,sort:e.sort}),children:s(o.clearAllFilters)})]})]})};function nc({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 ea=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ae(),a=s.searchV4,{convert:l}=Ve(),d=st();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}`:"",m=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${l(c.author)}${c.role&&c.role!=="author"?` ${l(c.role)}`:""}`:"",u=c.type==="book"?c.era??c.dynasty:c.dynasty,g=u?l(u):"",x=c.classification?l(c.classification):"",j=[];c.has_image&&j.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&j.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&j.push({label:a.tagLost,cls:"bim-sr-tag--lost"});const y=[m,g,x].filter(Boolean).join(" · ");return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-sr-c-title",children:[t.jsxs("div",{className:"bim-sr-tl",children:[t.jsx("a",{href:d(c.id),onClick:S=>i(c,S),children:t.jsx(nc,{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($n,{type:c.type,size:6})," ",o(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:m||"—"}),t.jsx("td",{className:"bim-sr-c-era",children:g||"—"}),t.jsx("td",{className:"bim-sr-c-cls",children:x||"—"}),t.jsx("td",{className:"bim-sr-c-res",children:j.map(S=>t.jsx("span",{className:`bim-sr-tag ${S.cls}`,children:l(S.label)},S.label))})]},c.id)})})]})})},Hm=`
|
|
1
|
+
"use strict";var fu=Object.create;var Ps=Object.defineProperty;var gu=Object.getOwnPropertyDescriptor;var xu=Object.getOwnPropertyNames;var bu=Object.getPrototypeOf,yu=Object.prototype.hasOwnProperty;var ju=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of xu(n))!yu.call(e,s)&&s!==i&&Ps(e,s,{get:()=>n[s],enumerable:!(o=gu(n,s))||o.enumerable});return e};var mi=(e,n,i)=>(i=e!=null?fu(bu(e)):{},ju(n||!e||!e.__esModule?Ps(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ze=require("./storage-entry-Cx6j1zcJ.cjs"),t=require("react/jsx-runtime"),f=require("react"),vu=require("opencc-js/t2cn"),Sl=require("./variant-supplement.cjs"),ku=require("react-markdown"),wu=require("remark-gfm"),Su=e=>`/item/${e}`,_l=f.createContext(Su);function _u({buildUrl:e,children:n}){const i=f.useMemo(()=>e,[e]);return t.jsx(_l.Provider,{value:i,children:n})}function at(){return f.useContext(_l)}const $l="",Cl="";function po(e){const n=[];let i=!1,o=e;for(;o.length;){const s=i?Cl:$l,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 ft(e,n){return{title:e,tokens:n}}const Bs='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',$u=[ft("基础(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"}}),ft("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),ft("提示与警告",{"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)"}}),ft("遮罩与阴影",{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)"}}),ft("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),ft("资源",{"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"}}),ft("整理本(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:"中性灰:占位"}}),ft("版本传承(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"}}),ft("编辑器视图(主要在 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")'}}),ft("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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}}),ft('版式(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"}}),ft("阅读器(整理本 / 全文)",{"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:"版心外边线"}}),ft("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),ft("字体(全站无衬线,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,只需覆盖那一个就同时换掉"}})],Cu=Object.assign({},...$u.map(e=>e.tokens)),zl={};for(const[e,n]of Object.entries(Cu))zl[e]=`var(--bim-${e}, ${n.value})`;function r(e){const n=zl[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function Vt(e){return e.types&&e.types.length>0?e.types:[]}function zu(e,n){return Vt(e).includes(n)}const Nu={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 Tu={"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 $n(e){try{return Tu[new URL(e).hostname]}catch{return}}const Os={text:0,image:1,physical:2};function uo(e){return e.length===0?"physical":[...e].sort((n,i)=>(Os[n]??99)-(Os[i]??99)).join("+")}function Iu(e){return e.includes("text")&&e.includes("image")?"text+image":e[0]||"physical"}function mo(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,m]=p,u=`${h}|${uo(Vt(c))}`;i.has(u)||i.set(u,{base:{...c,name:h,url:"",volumes:[]},volumes:[],indices:[]});const g=i.get(u);g.volumes.push({volume:m,url:c.url||void 0,status:"found"}),g.indices.push(d)}const o=[],s=new Set;for(const d of i.values())if(!(d.volumes.length<2)){d.volumes.sort((c,p)=>c.volume-p.volume),d.base.volumes=d.volumes,d.base.expected_volumes=d.volumes.length,d.base.url||(d.base.url=((l=d.volumes.find(c=>c.url))==null?void 0:l.url)??""),o.push(d.base);for(const c of d.indices)s.add(c)}const a=[...o];for(let d=0;d<e.length;d++)s.has(d)||a.push(e[d]);return a}function Nl(e){if(e.url)return e.url;for(const[n,i]of Object.entries(e))if(n.endsWith("_url")&&typeof i=="string")return i}function Tl(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||Nl(n)}))}function Ri(e){const n=Tl(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 ho(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 fo(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 Cn(e){if(!e.url)return;const n=ho(e.metadata);return n?fo(e.url,n):e.url}const Mt=f.createContext(null),Il=["曹霑"];function Ru(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Eu(e,n=Il){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(Ru).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 Ln=null;function Rl(){if(Ln)return Ln;try{const e=vu.Converter({from:"t",to:"cn"});Ln=Eu(n=>e(ze.normalizeVariants(n)))}catch{Ln=e=>e}return Ln}const Lu={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:"圖片資源"}},Au={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 bt(e,n,i){return{"zh-Hant":e,"zh-Hans":n}}const Mu=bt({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:"无数据"}),Ei=bt({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:"作品信息"}),Pu=bt({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:"附记"}}),Bu=bt({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}"}}),Ou=bt({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:"上级丛编"}),Wu=bt({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:"来源"}),Fu=bt({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}",tocExpand:"展開",tocCollapse:"收起",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}",tocExpand:"展开",tocCollapse:"收起",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",originalSource:"本站独立整理",charGuess:"残字(推测)",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献",entityDetail:"查看详情 →"}),Hu=bt({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:"本卷条目"}),Du=bt({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:"规模、存佚、许可与版本"}),go=bt({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:"按作者浏览全部 →"}),Uu=bt({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} 条"}),Vu=bt({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:"搜索"}),Gu=bt({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:"回复"}),Yu=bt({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:"有争议"}}),qu={common:Mu,detail:Ei,bookPage:Pu,workPage:Bu,collectionPage:Ou,entityPage:Wu,reader:Fu,collated:Hu,metaHome:Du,readHome:go,catalogPage:Uu,searchPage:Vu,feedback:Gu,lineage:Yu};function Ku(e){const n={};for(const[i,o]of Object.entries(qu))n[i]=o[e];return n}function wt(e,n){return e.replace(/\{(\w+)\}/g,(i,o)=>String(n[o]??""))}const Ws=new Map;function zn(e){let n=Ws.get(e);return n||(n={...e==="zh-Hans"?Au:Lu,...Ku(e)},Ws.set(e,n)),n}function Fs(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 El(e){return(n,i)=>{const o=Fs(e,n)??Fs(zn("zh-Hant"),n)??n;return i?wt(o,i):o}}const Hs=new Map;function Nn(e){let n=Hs.get(e);return n||(n=El(zn(e)),Hs.set(e,n)),n}const Ll="bim-locale";function Xu(){try{const e=localStorage.getItem(Ll);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function Zu(e){try{localStorage.setItem(Ll,e)}catch{}}const Ju="zh-Hans",Qu=({locale:e,onLocaleChange:n,converter:i,children:o})=>{const[s,a]=f.useState(e??Ju),l=e??s;f.useEffect(()=>{if(e)return;const h=Xu();h&&h!==s&&a(h)},[]);const d=f.useMemo(()=>l==="zh-Hans"?i??Rl():null,[l,i]),c=f.useCallback(h=>{a(h),Zu(h),n==null||n(h)},[n]),p=f.useMemo(()=>({locale:l,setLocale:c,messages:zn(l),converter:d}),[l,c,d]);return t.jsx(Mt.Provider,{value:p,children:o})};function Ae(){const e=f.useContext(Mt);return(e==null?void 0:e.messages)??zn("zh-Hant")}const em=2e3;function Ue(){const e=f.useContext(Mt),n=(e==null?void 0:e.locale)??"zh-Hant",i=(e==null?void 0:e.converter)??null,o=f.useRef(new Map),s=f.useRef(n),a=f.useRef(i);(s.current!==n||a.current!==i)&&(o.current.clear(),s.current=n,a.current=i);const l=f.useCallback(d=>{if(!d)return"";if(!i)return d;const c=o.current.get(d);if(c!==void 0)return c;const p=i(d);if(o.current.size>=em){const h=o.current.keys().next().value;h!==void 0&&o.current.delete(h)}return o.current.set(d,p),p},[i]);return f.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function re(){const e=f.useContext(Mt),{convert:n,locale:i,isSimplified:o}=Ue(),s=(e==null?void 0:e.messages)??zn("zh-Hant"),a=f.useMemo(()=>e?El(s):Nn("zh-Hant"),[e,s]);return f.useMemo(()=>({t:a,convert:n,locale:i,isSimplified:o,messages:s}),[a,n,i,o,s])}const Al=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),tm=new Set([...Al,...Object.keys(ze.VARIANT_CHARS),...Object.keys(Sl.VARIANT_SUPPLEMENT)]),Ml=[...Il,"切換為繁體","漢籍リポジトリ"];function nm(e,n=Ml){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)=>{tm.has(a)&&o.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),o}function im(e,n,i){return e?e==="orig"?null:n==="zh-Hans"?i??Rl():e==="hant"?ze.normalizeVariants:i:n==="zh-Hans"?i:ze.normalizeVariants}const rm=({mode:e,children:n})=>{const i=f.useContext(Mt),o=f.useMemo(()=>i&&{...i,converter:im(e,i.locale,i.converter)},[i,e]);return t.jsx(Mt.Provider,{value:o,children:n})};function om(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 Ds(e){return e==="text+image"?["text","image"]:[e]}function Us(e){const n=Vt(e);return n.length===0?"text":Iu(n)}function sm(){return{id:"",name:"",url:"",types:["text"],details:""}}const Mr=({items:e,onChange:n,onDownload:i,downloadStatuses:o,filterType:s})=>{const a=Ae(),[l,d]=f.useState(null),c=[{value:"text",label:a.resourceTypeShort.text},{value:"image",label:a.resourceTypeShort.image},{value:"text+image",label:a.resourceTypeShort.textImage},{value:"physical",label:a.resourceTypeShort.physical}],p=[{value:"catalog",label:a.rootType.catalog},{value:"search",label:a.rootType.search}],h=w=>{if(!s)return!0;const v=Vt(w);return s==="text"?v.includes("text"):s==="image"?v.includes("image")||v.includes("physical"):s==="physical"?v.includes("physical"):v.includes(s)},m=e.map((w,v)=>({item:w,originalIndex:v})).filter(({item:w})=>h(w)),u=()=>{const w=sm();s&&(w.types=Ds(s)),n([...e,w]),d(e.length)},g=w=>{n(e.filter((v,k)=>k!==w)),d(null)},x=(w,v,k)=>{const z=[...e];if(z[w]={...z[w],[v]:k},v==="url"&&!z[w].id){const C=om(k);C&&(z[w].id=C)}n(z)},j=(w,v)=>{const k=[...e],{type:z,...C}=k[w];k[w]={...C,types:Ds(v)},n(k)},y=(w,v,k)=>{const C={...e[w].metadata||{}};k?C[v]=k:delete C[v],x(w,"metadata",Object.keys(C).length>0?C:void 0)},S=(w,v)=>{const k=v.trim()?v.split(/[,,、]/).map(z=>z.trim()).filter(Boolean):void 0;x(w,"structure",k)},b=(w,v,k)=>{const C=e[w].coverage||{level:1,ranges:""};v==="level"?C.level=parseInt(k)||1:C.ranges=k,x(w,"coverage",C.ranges?C:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[m.map(({item:w,originalIndex:v})=>{var k,z,C;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>d(l===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:am(Us(w)),color:r("on-color-fg")},children:(()=>{var R,T;const _=Vt(w);return _.length===0?"text":_.length===1?((R=c.find(N=>N.value===_[0]))==null?void 0:R.label)??_[0]:_.includes("text")&&_.includes("image")?((T=c.find(N=>N.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&&lm(v,o==null?void 0:o[v],i,a),t.jsx("button",{onClick:_=>{_.stopPropagation(),g(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:[zu(w,"image")&&w.url&&cm(w,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:An,children:[t.jsx("span",{style:Mn,children:a.label.type}),t.jsx("select",{value:Us(w),onChange:_=>j(v,_.target.value),style:{...Rt,flex:1},children:c.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]}),t.jsxs("label",{style:An,children:[t.jsx("span",{style:Mn,children:a.label.rootType}),t.jsx("select",{value:w.root_type||"catalog",onChange:_=>x(v,"root_type",_.target.value),style:{...Rt,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:{...Rt,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:w.name,onChange:_=>x(v,"name",_.target.value),placeholder:a.editor.resourceName,style:{...Rt,flex:1}})]}),t.jsx("input",{type:"text",value:w.url,onChange:_=>x(v,"url",_.target.value),placeholder:a.editor.resourceUrl,style:Rt}),t.jsx("input",{type:"text",value:((k=w.structure)==null?void 0:k.join("、"))||"",onChange:_=>S(v,_.target.value),placeholder:a.editor.structurePlaceholder,style:Rt}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:An,children:[t.jsx("span",{style:Mn,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((z=w.coverage)==null?void 0:z.level)??"",onChange:_=>b(v,"level",_.target.value),placeholder:"1",style:{...Rt,width:"60px"}})]}),t.jsxs("label",{style:{...An,flex:1},children:[t.jsx("span",{style:Mn,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:((C=w.coverage)==null?void 0:C.ranges)||"",onChange:_=>b(v,"ranges",_.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...Rt,flex:1}})]})]}),t.jsx("textarea",{value:w.details||"",onChange:_=>x(v,"details",_.target.value),placeholder:a.editor.detailsPlaceholder,style:{...Rt,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(([_,R])=>{var T;return t.jsxs("label",{style:{...An,gap:"4px"},children:[t.jsx("span",{style:{...Mn,minWidth:"56px"},children:R}),t.jsx("input",{type:"text",value:((T=w.metadata)==null?void 0:T[_])||"",onChange:N=>y(v,_,N.target.value),placeholder:R,style:{...Rt,flex:1}})]},_)})})]})]})]})]},v)}),t.jsxs("button",{onClick:u,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:a.action.addResource})]})]})};function am(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 lm(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 cm(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 Rt={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"},An={display:"flex",alignItems:"center",gap:"6px"},Mn={fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap"},Vs={text:r("restype-text"),image:r("restype-image"),"text+image":r("restype-text-image"),physical:r("restype-physical")};function dm(e){return e.includes("text")&&e.includes("image")?Vs["text+image"]:Vs[e[0]||"physical"]}const xo=({items:e,groupByType:n=!0,resourceGroups:i,onNavigate:o,renderLink:s})=>{const a=Ae(),{convert:l}=Ue(),d=f.useMemo(()=>mo(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=f.useMemo(()=>{const y=new Map,S=[];for(const b of d){const w=b.group;w?(y.has(w)||y.set(w,[]),y.get(w).push(b)):S.push(b)}for(const b of y.values())b.sort((w,v)=>{const k=z=>z.group_role==="origin"?0:z.group_role==="mirror"?1:2;return k(w)-k(v)});return{mirrorGroups:y,ungroupedItems:S}},[d]),h={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},m=y=>h[y]?h[y]:y.split("+").map(S=>h[S]||S).join("+");if(!d||d.length===0)return t.jsx("div",{style:{padding:"16px",color:r("desc-fg"),fontSize:"13px",textAlign:"center"},children:a.misc.noResources});if(!n)return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:d.map((y,S)=>t.jsx(fr,{item:y},y.id||S))});const u=(y,S)=>{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:S.map((k,z)=>t.jsx(fr,{item:k,onNavigate:o,renderLink:s},k.id||z))})]},`group-${y}`)},g=new Map;for(const y of p){const S=uo(Vt(y));g.has(S)||g.set(S,[]),g.get(S).push(y)}const x=["text","image","text+image","physical"],j=[...x.filter(y=>g.has(y)),...[...g.keys()].filter(y=>!x.includes(y)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,S])=>u(y,S)),j.map(y=>{const S=g.get(y),b=dm(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:m(y)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:S.map((w,v)=>t.jsx(fr,{item:w,onNavigate:o,renderLink:s},w.id||v))})]},y)})]})},pm={bw:{label:"",bg:r("colormode-bw-bg"),fg:r("colormode-bw-fg")},color:{label:"",bg:r("colormode-color-bg"),fg:r("colormode-color-fg")}},fr=({item:e})=>{const n=Ae(),{convert:i}=Ue(),[o,s]=f.useState(!1),a=f.useMemo(()=>(e.url?$n(e.url):void 0)||i(e.name),[e.url,e.name,i]),l=f.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||Nl(x)})),[e.volumes]),d=l&&l.length>0,c=d?new Set(l.filter(x=>x.status!=="missing").map(x=>x.volume)).size:0,p=d?new Set(l.filter(x=>x.status==="missing").map(x=>x.volume)).size:0,h=e.expected_volumes??(d?c+p:0),m=e.color_mode?{...pm[e.color_mode],label:n.colorMode[e.color_mode]}:null,u=e.details&&!d?i(e.details):null,g={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:g,children:[t.jsx("span",{style:{fontWeight:500},children:a}),m&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:m.bg,color:m.fg},children:m.label}),u&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:u}),d&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[c,"/",h,n.unit.volume,p>0&&t.jsx("span",{style:{color:r("missing-fg"),marginLeft:"3px"},children:wt(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=ho(e.metadata);return x?fo(e.url,x):e.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:r("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),d&&t.jsx("button",{onClick:()=>s(!o),style:{padding:"0 6px",fontSize:"11px",border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",lineHeight:1.4},children:o?"▲":"▼"})]}),d&&o&&t.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${r("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:l.map(x=>{const j=x.status==="missing";return x.url&&!j?t.jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",borderRadius:"3px",border:`1px solid ${r("widget-border")}`,color:r("link-fg"),textDecoration:"none"},children:x.volume},x.volume):t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:r(j?"missing-fg":"desc-fg"),textDecoration:j?"line-through":"none",opacity:j?.6:1},children:x.volume},x.volume)})})]})},Pl=({indexSource:e,syncConfig:n,variant:i="index-browser",onSwitchMode:o,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=Ae(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,h=(n==null?void 0:n.repoPath)||"",m=h?h.split(/[/\\]/).pop()||h:"",u={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:r("primary-soft"),color:r("primary")},g={onMouseOver:j=>j.currentTarget.style.opacity="0.8",onMouseOut:j=>j.currentTarget.style.opacity="1"},x=t.jsxs("div",{onClick:s,title:p?d.mode.switchToOfficial:d.mode.switchToDraft,style:{...u,background:r(p?"warning":"success"),color:r("on-color-fg")},...g,children:[t.jsx("span",{children:p?"📝":"📚"}),t.jsx("span",{children:p?"draft":"official"})]});return i==="index-browser"?c?t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[x,t.jsxs("div",{onClick:o,title:d.mode.switchToSync,style:u,...g,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:{...u,paddingLeft:"8px",paddingRight:"8px"},...g,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]})]}):t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.jsxs("div",{onClick:o,title:d.mode.switchToLocal,style:u,...g,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:m||d.mode.configurePath,style:{...u,background:"transparent",padding:"6px",fontSize:"12px"},...g,children:t.jsx("span",{children:"⚙️"})})]})]}):t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[t.jsxs("div",{onClick:o,title:c?d.mode.switchToGithub:d.mode.switchToLocal,style:u,...g,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:{...u,paddingLeft:"8px",paddingRight:"8px",minWidth:h?"100px":"auto",justifyContent:"space-between"},...g,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]}),!c&&m&&t.jsxs("div",{style:{...u,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:m})]})]})},Li="bim-search-history",Gs=10,Ys=8;function Dn(){try{const e=localStorage.getItem(Li);return e?JSON.parse(e):[]}catch{return[]}}function Bl(e){try{const n=Dn().filter(i=>i!==e);n.unshift(e),n.length>Gs&&(n.length=Gs),localStorage.setItem(Li,JSON.stringify(n))}catch{}}function um(e){try{const n=Dn().filter(i=>i!==e);localStorage.setItem(Li,JSON.stringify(n))}catch{}}function mm(){try{localStorage.removeItem(Li)}catch{}}const Ol=({transport:e,value:n,onChange:i,onSearch:o,onEntrySelect:s,placeholder:a})=>{const l=Ae(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,h]=f.useState(!1),[m,u]=f.useState([]),[g,x]=f.useState(-1),[j,y]=f.useState(Dn),S=f.useRef(null),b=f.useRef(null),w=f.useRef(null),v=f.useRef(!1);f.useEffect(()=>{x(-1);const N=n.trim();if(!N){u(j.map(F=>({type:"history",text:F})));return}if(!e.searchAll){u([]);return}let E=!1;const W=setTimeout(()=>{e.searchAll(N,Ys).then(F=>{if(E)return;const A=[...F.works,...F.books,...F.collections,...F.entities??[]];u(A.slice(0,Ys).map(V=>({type:"entry",text:V.title||V.id,entry:V})))}).catch(()=>{E||u([])})},80);return()=>{E=!0,clearTimeout(W)}},[n,j,e]),f.useEffect(()=>{const N=E=>{w.current&&!w.current.contains(E.target)&&h(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]),f.useEffect(()=>{const N=E=>{var W,F;if(E.key==="/"&&document.activeElement!==S.current){const A=(W=document.activeElement)==null?void 0:W.tagName;if(A==="INPUT"||A==="TEXTAREA"||A==="SELECT")return;E.preventDefault(),(F=S.current)==null||F.focus()}};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[]);const k=f.useCallback(N=>{N.trim()&&(Bl(N.trim()),y(Dn())),o(N),h(!1)},[o]),z=f.useCallback(N=>{N.type==="history"?(i(N.text),k(N.text)):N.entry&&(s?(s(N.entry),h(!1)):(i(N.text),k(N.text)))},[i,k,s]),C=f.useCallback(N=>{if(!p||m.length===0){N.key==="Enter"&&k(n);return}switch(N.key){case"ArrowDown":N.preventDefault(),x(E=>(E+1)%m.length);break;case"ArrowUp":N.preventDefault(),x(E=>(E-1+m.length)%m.length);break;case"Enter":N.preventDefault(),g>=0&&g<m.length?z(m[g]):k(n);break;case"Escape":N.preventDefault(),h(!1);break}},[p,m,g,n,k,z]),_=f.useCallback((N,E)=>{E.stopPropagation(),um(N),y(Dn()),u(W=>W.filter(F=>!(F.type==="history"&&F.text===N)))},[]),R=f.useCallback(N=>{N.stopPropagation(),mm(),y([]),u([])},[]);f.useEffect(()=>{if(g>=0&&b.current){const N=b.current.children;N[g]&&N[g].scrollIntoView({block:"nearest"})}},[g]);const T=!n.trim()&&j.length>0;return t.jsxs("div",{ref:w,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:S,type:"text",placeholder:d,value:n,onChange:N=>{i(N.target.value),h(!0)},onCompositionStart:()=>{v.current=!0},onCompositionEnd:()=>{v.current=!1},onFocus:()=>{h(!0)},onKeyDown:C,style:{width:"100%",padding:"8px 12px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),fontSize:"14px",boxSizing:"border-box"}}),p&&m.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:R,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),m.map((N,E)=>t.jsxs("div",{onClick:()=>z(N),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:r("fg"),background:E===g?r("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:N.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N.text}),N.entry&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:[c[N.entry.type],N.entry.edition&&` · ${N.entry.edition}`,N.entry.author&&` · ${N.entry.author}`]}),N.type==="history"&&t.jsx("button",{onClick:W=>_(N.text,W),style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:l.action.remove,children:"×"})]},`${N.type}-${N.text}-${E}`))]})]})},Tn=({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"}}),Wl=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],hm={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function ct(e){return hm[e]??e}const kn=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],wn={熹平:172,建安:196,黃初:220,正始:240,廣政:938,太康:280,永和:345,開皇:581,貞觀:627,開元:713,天寶:742,貞元:785,元和:806,開成:836,會昌:841,咸通:860,建隆:960,太平興國:976,咸平:998,天禧:1017,慶曆:1041,皇祐:1049,嘉祐:1056,治平:1064,熙寧:1068,元豐:1078,元祐:1086,紹聖:1094,崇寧:1102,大觀:1107,政和:1111,宣和:1119,建炎:1127,紹興:1131,隆興:1163,乾道:1165,淳熙:1174,紹熙:1190,慶元:1195,嘉泰:1201,開禧:1205,嘉定:1208,寶慶:1225,紹定:1228,端平:1234,嘉熙:1237,淳祐:1241,寶祐:1253,開慶:1259,景定:1260,咸淳:1265,大定:1161,明昌:1190,至元:1264,大德:1297,皇慶:1312,延祐:1314,泰定:1324,天曆:1328,至順:1330,至正:1341,洪武:1368,永樂:1403,宣德:1426,正統:1436,景泰:1450,天順:1457,成化:1465,弘治:1488,正德:1506,嘉靖:1522,隆慶:1567,萬曆:1573,泰昌:1620,天啟:1621,崇禎:1628,弘光:1645,隆武:1645,紹武:1646,永曆:1647,順治:1644,康熙:1662,雍正:1723,乾隆:1736,嘉慶:1796,道光:1821,咸豐:1851,同治:1862,光緒:1875,宣統:1909,慶長:1596,寬永:1624,正保:1644,慶安:1648,承應:1652,明曆:1655,萬治:1658,寬文:1661,延寶:1673,天和:1681,貞享:1684,元祿:1688,寶永:1704,享保:1716,元文:1736,寬保:1741,延享:1744,寬延:1748,寶曆:1751,明和:1764,安永:1772,天明:1781,寬政:1789,享和:1801,文化:1804,文政:1818,天保:1830,弘化:1844,嘉永:1848,安政:1854,萬延:1860,文久:1861,元治:1864,慶應:1865,明治:1868,大正:1912,昭和:1926,天正:1573,文祿:1592,永祿:1558,天文:1532},Fl={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function Ai(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 fm(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 gm=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,qs={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function bo(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(qs))if(n.startsWith(s))return qs[s];const i=ct(n);if(an[i]!=null)return i;const o=Ut(n);if(o&&n.length<=o.length+1)return ct(o)}function sn(e,n){if(n){const i=Fl[`${n}|${e}`];if(i!=null)return i}return wn[e]}const xm=1911;function bm(e){const n=wn[e];if(n==null)return;const i=At[e];let o;for(const[s,a]of Object.entries(wn))At[s]===i&&a>n&&(o==null||a<o)&&(o=a);return o!=null?o-1:void 0}const ym={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function _i(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=ym[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 Ut(e){for(const n of Wl)if(e.startsWith(n))return n}const At={};{const e=(n,i)=>{for(const o of i)At[o]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function ln(e,n){const i=n==="北宋"||n==="南宋"?"宋":n;for(const o of Object.keys(wn))if(e.includes(o)&&!(i&&At[o]&&At[o]!==i&&Fl[`${i}|${o}`]==null))return o}function Xn(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=Ut(o)??"";return{era:ct(p),reign:ln(o,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=Ai(s);if(p)return{era:fm(p.from),reign:"",source:"publication"};const h=Ut(s)??bo(s)??((c=kn.find(g=>g.pattern.test(s)))==null?void 0:c.era)??"",m=ln(s,h)??"",u=h||(m?At[m]??"":"");if(u||m)return{era:ct(u),reign:m,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=Ut(a);if(p)return{era:ct(p),reign:ln(a,p)??"",source:"edition"};const h=kn.find(m=>m.pattern.test(a));if(h)return{era:ct(h.era),reign:ln(a,h.era)??h.reign??"",source:"edition"}}return n}function Mi(e){var o,s,a,l,d,c,p,h,m;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 u=Ai(n);if(u)return u.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 u of i){const g=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(g&&u!==g&&(Ut(g)||bo(g)))break;const x=u.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??u.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 j=u.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(j){const w=Ut(u);if(!w||ct(w)==="民國"){const k=_i(j[1]);if(k!=null&&k>=1&&k<=120)return xm+k}}const y=Ut(u)??((h=kn.find(w=>w.pattern.test(u)))==null?void 0:h.era),S=y?ct(y):void 0,b=ln(u,S)??(Ut(u)||(m=kn.find(w=>w.pattern.test(u)))==null?void 0:m.reign);if(b){const w=sn(b,S);if(w==null)continue;const v=u.indexOf(b),k=v>=0?u.slice(v+b.length):"",z=k.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??k.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),C=z?_i(z[1]):void 0;return w+(C?C-1:0)}}}function yo(e){var l,d,c,p,h,m;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 u=o.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(u){const g=Pr[ct(u[1])],x=an[ct(u[2])];if(g!=null&&x!=null)return{from:Math.min(g,x)-20,to:Math.max(g,x)+40}}}const s=(p=e.publication_info)==null?void 0:p.year;if(s){const u=Ai(s);if((u==null?void 0:u.to)!=null)return{from:u.from,to:u.to};const g=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(g){const x=Pr[ct(g[1])],j=an[ct(g[2])];if(x!=null&&j!=null)return{from:Math.min(x,j)-20,to:Math.max(x,j)+40}}}const a=[(h=e.publication_info)==null?void 0:h.year,e.edition,e.title].filter(Boolean);for(const u of a){if(!/[間间]/.test(u))continue;const g=Ut(u)??bo(u)??((m=kn.find(y=>y.pattern.test(u)))==null?void 0:m.era),x=g?ct(g):void 0,j=[];for(const y of Object.keys(wn))u.includes(y)&&(x&&At[y]&&At[y]!==x||sn(y,x)!=null&&j.push(y));if(j.length===0){const y=u.match(/([一-鿿])([一-鿿])[間间]/);if(y&&x){for(const S of[y[1],y[2]])for(const b of Object.keys(wn))if(At[b]===x&&!(b[0]!==S&&b[b.length-1]!==S)&&sn(b,x)!=null){j.push(b);break}}}if(j.length>0){const y=j.map(v=>sn(v,x)).filter(v=>v!=null),S=Math.min(...y),b=j.reduce((v,k)=>sn(v,x)>=sn(k,x)?v:k),w=bm(b)??gr(x??"")??Math.max(...y);return{from:S,to:w>S?w:gr(x??At[b]??"")??S}}if(x&&an[x]!=null)return{from:an[x],to:gr(x)??an[x]}}}const an={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},jm=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],vm=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,Ks=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function Xs(e,n){for(const i of Wl){const o=e.indexOf(i);if(o<0)continue;if(i.length===1){const c=e[o+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!ln(e.slice(o),ct(i)))continue}const s=ct(i);if(s===n)continue;const a=e.slice(o),l=ln(a,s)??"";let d;if(l){const c=sn(l,s);if(c!=null){const h=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),m=h?_i(h[1]):void 0;d=c+(m?m-1:0)}}return{era:s,reign:l,year:d}}for(const i of kn)if(i.pattern.test(e))return{era:ct(i.era),reign:i.reign??""}}function km(e){var S,b,w,v,k;const n=Xn(e),i=((S=e.publication_info)==null?void 0:S.year)??"",o=i?Ai(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"&&gm.test(i),p=n.source==="publication"&&/[間间]/.test(i),h=l.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let m;a||d||c||p?m=void 0:h?m=parseInt(h[2],10):m=Mi(e);const u=m==null?yo(e):void 0;let g;n.source==="publication"&&(c||Ks.test(i))?g="uncertain":n.source==="lineage"||n.source==="publication"?g="attested":Ks.test(s)||!n.reign&&m==null?g="uncertain":g="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)??""}」`:`出版著錄「${((k=e.publication_info)==null?void 0:k.year)??""}」`,j={era:n.era,reign:n.reign,year:m,yearRange:u,certainty:g,source:n.source==="edition"?"edition":"catalog",basis:x};if(h){const z=l.match(/[、,,]\s*([宋元明清])/);z&&z[1]!==j.era&&(j.laterRepair={era:z[1]})}if(!j.laterRepair&&vm.test(s)){const z=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);z&&z[1]!==n.era&&(j.laterRepair={era:z[1]})}const y=jm.find(z=>z.re.test(s));if(y){const z=s.search(y.re),C=s.slice(z),_=Xs(C,n.era)??Xs(s,n.era);_&&(j.basedOn={era:_.era,reign:_.reign,year:_.year,relation:y.relation})}return j}const Pr={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function gr(e){return Pr[e]}function $i(e){const n=Mi(e);if(n!=null)return n;const i=yo(e);if(i)return i.from;const o=Xn(e).era;return o?an[o]:void 0}const Zs=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function Br(e){const n=Zs.indexOf(e);return n===-1?Zs.length:n}function wm(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 jo(e,n){const i=mo(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,m)=>{const u=g=>g.group_role==="origin"?0:g.group_role==="mirror"?1:2;return u(h)-u(m)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const h=Vt(p),m=h.includes("text"),u=h.includes("image");m&&u?a.textImage.push(p):m?a.text.push(p):u?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 m,u;return{key:p,label:((m=n==null?void 0:n[p])==null?void 0:m.label)||p,description:(u=n==null?void 0:n[p])==null?void 0:u.description,items:h}});return{buckets:d,mirrors:c,total:i.length}}function Pi(e,n=Nn("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=Ri(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 Hl(e,n){if(Pi(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 Sm="同版";function _m(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 $m(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===Sm&&o&&o!==e.id)return o}}function Cm(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 Dl(e,n){var a,l;const i=e.resources||[],o=[],s=[];for(const d of i){const c=Vt(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:Xn(e),year:Mi(e),sortYear:$i(e),images:o,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,callNumber:_m(s[0]),copyOf:$m(e),summary:e.summary,important:zm(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:o.length>0}}function zm(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 Ul(e,n,i={}){const o=new Set((n==null?void 0:n.excluded_books)??[]),s=Cm(e.filter(c=>!o.has(c.id)).map(c=>Dl(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,m=p.r.sortYear;return h!=null&&m!=null?h-m||c.i-p.i:h!=null?-1:m!=null?1:c.i-p.i}).map(c=>c.r):a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const h=m=>(m.important?0:1)*2+(m.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)=>Br(c)-Br(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function Nm(e,n){var y,S;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const i=(y=n.collections)==null?void 0:y[n.default_collection],o=(i==null?void 0:i.groups)??[],s=(i==null?void 0:i.book_ids)??[],a=o.length>0||s.length>0,l=!a&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!a&&l.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const d=new Set(o),c=new Set([...s,...l]),p=b=>{if(c.has(b))return!0;const w=n.node_groups[b];return w!=null&&d.has(w)},h=[],m=new Map,u=[];for(const b of e)if(!((S=n.excluded_books)!=null&&S.includes(b)))if(p(b))h.push(b);else{const w=n.node_groups[b];w?(m.has(w)||m.set(w,[]),m.get(w).push(b)):u.push(b)}if(u.length+[...m.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])),j=[...m.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 u.length>0&&j.push({id:"__other__",label:"其他版本",description:void 0,ids:u}),{useGrouping:!0,coreIds:h,groupedIds:j}}const Vl=["撰","編","注","校","譯","繪","其他"],Tm=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function vo(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n)return"撰";for(const{cls:i,re:o}of Tm)if(o.test(n))return i;return"其他"}function ko(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function Gl(e,n="全部"){const i=new Map;for(const s of e){const a=vo(s);i.set(a,(i.get(a)??0)+1)}const o=[{cls:"全部",label:n,count:e.length}];for(const s of Vl){const a=i.get(s);a&&o.push({cls:s,label:s,count:a})}return o.length>2?o:[]}function wo(e){return(e._books??[]).map(n=>n.id).filter(n=>typeof n=="string")}function So(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 Yl(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:Un(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 Im(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 ql(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}=Yl(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 Un(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 Bi(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 Rm=["〇","一","二","三","四","五","六","七","八","九"],Js=["","十","百","千"];function In(e){if(!Number.isInteger(e)||e<=0)return"";if(e>=1e8)return String(e);if(e<1e4)return xr(e,!0);const n=Math.floor(e/1e4),i=e%1e4;let o=xr(n,!0)+"萬";return i>0&&(o+=(i<1e3?"〇":"")+xr(i,!1)),o}function xr(e,n){const i=String(e),o=i.length;let s="",a=!1;for(let l=0;l<o;l++){const d=parseInt(i[l]),c=o-1-l;d===0?a=!0:(a&&s&&(s+="〇"),a=!1,n&&d===1&&c===1&&l===0?s+=Js[c]:s+=Rm[d]+Js[c])}return s}function Em(e){return e==null?"":typeof e=="string"?e:"name"in e&&e.name?e.name:"title"in e&&e.title||""}function Lm(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 Gt(e,n="卷"){var o,s;const i=e;return i.measure_info?i.measure_info:(o=i.juan_count)!=null&&o.number?In(i.juan_count.number)+n:(s=i.juan_count)!=null&&s.description?i.juan_count.description:""}function Kl(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 Oi={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},Xl=new Set(["work","book","entity"]);function Am(e){return Ql(e)||!!e.sort}function Mm(e,n){return n.sort&&Xl.has(e)?n.sort:void 0}const Wi=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],Fi=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],Zl=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],Jl={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function Hi(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 Ql(e){return Hi(e)>0}function Pm(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 ec(e,n){const i=Jl[e];return Pm(n).every(o=>i.has(o))}const Pn=e=>JSON.stringify(e);function Bm(e,n){if(!ec(n,e))return null;const i=[];if(e.dynasty.length){const o=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=Wi.find(l=>l.key===s))==null?void 0:a.values)??[]})));o.length===1?i.push(`dynasty = ${Pn(o[0])}`):o.length>1&&i.push(`dynasty IN [${o.map(Pn).join(", ")}]`)}return e.classification.length&&i.push(e.classification.length===1?`classification = ${Pn(e.classification[0])}`:`classification IN [${e.classification.map(Pn).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 = ${Pn(e.loss)}`),i.join(" AND ")}const ht={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},tc="_";function Ci(e,n=new URLSearchParams){for(const i of Object.values(ht))n.delete(i);return e.dynasty.length&&n.set(ht.dynasty,e.dynasty.join(",")),e.classification.length&&n.set(ht.classification,e.classification.map(i=>i||tc).join(",")),e.hasImage&&n.set(ht.hasImage,"1"),e.hasText&&n.set(ht.hasText,"1"),e.hasCollated&&n.set(ht.hasCollated,"1"),e.loss&&n.set(ht.loss,e.loss),e.sort&&n.set(ht.sort,e.sort),n}function Om(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),i=new Set(Wi.map(a=>a.key)),o=new Set(Fi.map(a=>a.value)),s=e.get(ht.loss);return{dynasty:Array.from(new Set(n(ht.dynasty).filter(a=>i.has(a)))),classification:Array.from(new Set(n(ht.classification).map(a=>a===tc?"":a).filter(a=>o.has(a)))),hasImage:e.get(ht.hasImage)==="1",hasText:e.get(ht.hasText)==="1"||e.get(ht.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(ht.sort))??""}}function Wm(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 Qs(e,n){return e.includes(n)?e.filter(i=>i!==n):[...e,n]}const Fm=({filters:e,onChange:n})=>{const i=Ae(),o=i.searchV4,{convert:s}=Ue(),[a,l]=f.useState(!1),d=f.useId(),c=Hi(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(wt(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:Wi.map(h=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(h.key),onClick:()=>p({dynasty:Qs(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)}),Fi.map(h=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(h.value),onChange:()=>p({classification:Qs(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:Zl.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({...Oi,sort:e.sort}),children:s(o.clearAllFilters)})]})]})};function nc({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 ea=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ae(),a=s.searchV4,{convert:l}=Ue(),d=at();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}`:"",m=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${l(c.author)}${c.role&&c.role!=="author"?` ${l(c.role)}`:""}`:"",u=c.type==="book"?c.era??c.dynasty:c.dynasty,g=u?l(u):"",x=c.classification?l(c.classification):"",j=[];c.has_image&&j.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&j.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&j.push({label:a.tagLost,cls:"bim-sr-tag--lost"});const y=[m,g,x].filter(Boolean).join(" · ");return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-sr-c-title",children:[t.jsxs("div",{className:"bim-sr-tl",children:[t.jsx("a",{href:d(c.id),onClick:S=>i(c,S),children:t.jsx(nc,{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(Tn,{type:c.type,size:6})," ",o(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:m||"—"}),t.jsx("td",{className:"bim-sr-c-era",children:g||"—"}),t.jsx("td",{className:"bim-sr-c-cls",children:x||"—"}),t.jsx("td",{className:"bim-sr-c-res",children:j.map(S=>t.jsx("span",{className:`bim-sr-tag ${S.cls}`,children:l(S.label)},S.label))})]},c.id)})})]})})},Hm=`
|
|
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
|
-
`,ta=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ae(),a=s.searchV4,{convert:l}=
|
|
15
|
+
`,ta=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ae(),a=s.searchV4,{convert:l}=Ue(),d=at();return t.jsxs("div",{className:"bim-sc-grid",children:[t.jsx("style",{children:Hm}),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??"?"}`:"":`${c.dynasty?`〔${l(c.dynasty)}〕`:""}${c.author?l(c.author):""}`,c.type==="book"&&c.edition?l(c.edition):"",h].filter(Boolean).join(" · "),g=[o(c.type),c.classification?l(c.classification):""].filter(Boolean).join(" · "),x=[];return c.has_image&&x.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&x.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&x.push({label:a.tagLost,cls:"bim-sr-tag--lost"}),t.jsxs("a",{className:"bim-sc",href:d(c.id),onClick:j=>i(c,j),children:[t.jsx("span",{className:"bim-sc-t",children:t.jsx(nc,{text:p,query:n?l(n):void 0})}),u&&t.jsx("span",{className:"bim-sc-m",children:u}),c.descriptionSnippet&&t.jsx("p",{className:"bim-sc-s",children:po(c.descriptionSnippet).map((j,y)=>j.marked?t.jsx("mark",{children:l(j.text)},y):t.jsx(f.Fragment,{children:l(j.text)},y))}),t.jsx("span",{className:"bim-sc-sp"}),t.jsxs("div",{className:"bim-sc-f",children:[t.jsx("span",{className:"bim-sc-fl",children:g}),t.jsx("span",{className:"bim-sc-tags",children:x.map(j=>t.jsx("span",{className:`bim-sr-tag ${j.cls}`,children:l(j.label)},j.label))})]})]},c.id)})]})};function Dm(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 Um(e,n,i){const o=Math.max(1,Math.ceil(n/i));return Math.min(Math.max(1,e),o)}const Vm=({page:e,pageSize:n,total:i,totalLabel:o,onPage:s})=>{const a=Ae().searchV4,{convert:l}=Ue(),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(wt(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)})}),Dm(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)})})]})]})},ic="(max-width: 719px)",Gm=`${ic}, (pointer: coarse)`,Ym=`
|
|
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
|
-
`,So="bim-search-view",xr=50,na=5,Un=1e3;function xi(e){return e>=Un?`${Un.toLocaleString()}+`:e.toLocaleString()}const qm={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function Km(e){return e&&qm[e.toLowerCase()]||"all"}function Xm(e){return e==="all"?null:e}const ia=["work","collection","book","entity"],Zm={work:"works",collection:"collections",book:"books",entity:"entities"},Jm={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function Qm(){try{return window.localStorage.getItem(So)==="card"?"card":"table"}catch{return"table"}}function eh(e){try{window.localStorage.setItem(So,e)}catch{}}const un=(e,n)=>(e==null?void 0:e[Jm[n]])??0,br=(e,n)=>(e==null?void 0:e[Zm[n]])??[],rc=({transport:e,query:n,filters:i,onFiltersChange:o,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const h=Ae(),m=h.searchV4,{convert:u}=Ve(),g=!!e.supportsSearchFilters,x=f.useMemo(()=>g?i:Bi,[g,i]),[j,y]=f.useState("table");f.useEffect(()=>{y(Qm())},[]);const S=X=>{y(X),eh(X)},[b,w]=f.useState(l??"all"),v=f.useRef(b);v.current=b,f.useEffect(()=>{l!==void 0&&l!==v.current&&(w(l),z(1))},[l]);const[k,z]=f.useState(c&&c>0?c:1),C=f.useRef(k);C.current=k,f.useEffect(()=>{c!==void 0&&c>0&&c!==C.current&&z(c)},[c]);const _=f.useRef(null),R=f.useCallback(X=>{var Pe;z(X),p==null||p(X);const ue=_.current;ue&&ue.getBoundingClientRect().top<0&&((Pe=ue.scrollIntoView)==null||Pe.call(ue,{block:"start",behavior:"instant"}))},[p]),[T,N]=f.useState(null),[E,W]=f.useState(null),[F,A]=f.useState(!1),[V,ae]=f.useState(""),xe=$i(x).toString(),me=Fi(x)>0,G=$i({...x,sort:""}).toString(),ye=f.useRef({query:n,filterOnlyKey:G,sort:x.sort});f.useEffect(()=>{const X=ye.current;X.query!==n||X.filterOnlyKey!==G?(w("all"),z(1)):X.sort!==x.sort&&z(1),ye.current={query:n,filterOnlyKey:G,sort:x.sort}},[n,G,x.sort]),f.useEffect(()=>{let X=!1;return A(!0),ae(""),(async()=>{try{let ue;if(e.searchAll)ue=await e.searchAll(n,na,x);else{const Pe=["work","book","collection","entity"],Me=await Promise.all(Pe.map(ke=>e.search(n,ke,{page:1,pageSize:na,filters:x})));ue={works:Me[0].entries,books:Me[1].entries,collections:Me[2].entries,entities:Me[3].entries,totalWorks:Me[0].total,totalBooks:Me[1].total,totalCollections:Me[2].total,totalEntities:Me[3].total}}X||N(ue)}catch(ue){X||(ae(ue instanceof Error?ue.message:String(ue)),N(null))}finally{X||A(!1)}})(),()=>{X=!0}},[e,n,xe]);const ne=b;f.useEffect(()=>{if(b==="all"){W(null);return}let X=!1;return A(!0),(async()=>{try{const ue=await e.search(n,b,{page:k,pageSize:xr,filters:x});X||W({key:ne,entries:ue.entries,total:ue.total})}catch(ue){X||(ae(ue instanceof Error?ue.message:String(ue)),W(null))}finally{X||A(!1)}})(),()=>{X=!0}},[e,n,xe,b,k]);const U=E&&E.key===ne?E:null;f.useEffect(()=>{if(b==="all"||!U||F)return;const X=Math.min(U.total,Un),ue=Um(k,X,xr);U.entries.length===0&&X>0&&ue!==k&&(z(ue),p==null||p(ue))},[b,U,F,k]);const Q=f.useMemo(()=>ia.filter(X=>un(T,X)>0),[T]),q=Q.reduce((X,ue)=>X+un(T,ue),0),je=Q.some(X=>un(T,X)>=Un)?`${q.toLocaleString()}+`:q.toLocaleString(),I=!F&&!V&&T!==null&&q===0,oe=f.useCallback(X=>{w(X),z(1),d==null||d(X)},[d]),$e=f.useMemo(()=>{const X=[];return x.dynasty.forEach(ue=>X.push({name:ue,remove:()=>o({...x,dynasty:x.dynasty.filter(Pe=>Pe!==ue)})})),x.classification.forEach(ue=>{var Pe;return X.push({name:ue?((Pe=Wi.find(Me=>Me.value===ue))==null?void 0:Pe.label)??ue:h.searchPage.unclassified,remove:()=>o({...x,classification:x.classification.filter(Me=>Me!==ue)})})}),x.hasImage&&X.push({name:m.hasImage,remove:()=>o({...x,hasImage:!1})}),x.hasText&&X.push({name:m.hasText,remove:()=>o({...x,hasText:!1})}),x.hasCollated&&X.push({name:m.hasCollated,remove:()=>o({...x,hasCollated:!1})}),x.loss&&X.push({name:`${m.extant}:${h.searchPage.loss[x.loss]}`,remove:()=>o({...x,loss:""})}),X},[x,o,m,h]),ve={query:n,onEntryLinkClick:s,typeName:a},Le=X=>j==="table"?t.jsx(ea,{entries:X,...ve}):t.jsx(ta,{entries:X,...ve}),Ne=ia.flatMap(X=>br(T,X));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":g?void 0:"true",children:[t.jsx("style",{children:Ym}),g&&t.jsx(Fm,{filters:x,onChange:o}),t.jsxs("div",{className:"bim-sr-main","aria-busy":F,ref:_,children:[Q.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(ra,{on:b==="all",onClick:()=>oe("all"),children:[h.search.allTab," ",t.jsx("small",{children:je})]}),Q.map(X=>t.jsxs(ra,{on:b===X,onClick:()=>oe(X),children:[a(X)," ",t.jsx("small",{children:xi(un(T,X))})]},X))]}),t.jsxs("div",{className:"bim-sr-tools",children:[g&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":u(m.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>o({...x,sort:""}),children:u(m.sortRelevance)}),["era","title"].map(X=>{const ue=x.sort.startsWith(`${X}:`)?x.sort.endsWith("desc")?"desc":"asc":null,Pe=X==="era"?m.sortEra:m.sortTitle,Me=X==="era"?ue==="desc"?m.sortEraDesc:m.sortEraAsc:ue==="desc"?m.sortTitleDesc:m.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":ue!==null,title:u(Me),onClick:()=>o({...x,sort:`${X}:${ue==="asc"?"desc":"asc"}`}),children:[u(Pe),ue?t.jsxs("span",{"aria-hidden":"true",children:[" ",ue==="asc"?"↑":"↓"]}):null]},X)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":u(m.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":j==="table",onClick:()=>S("table"),children:u(m.viewTable)}),t.jsx("button",{type:"button","aria-pressed":j==="card",onClick:()=>S("card"),children:u(m.viewCard)})]})]}),me&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:u(wt(m.filteredCount,{n:je}))}),$e.map(X=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":u(wt(m.removeFilter,{name:X.name})),onClick:X.remove,children:[u(X.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},X.name))]}),V&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:V}),I&&t.jsx("div",{className:"bim-sr-empty",children:u(me?m.emptyFiltered:wt(h.search.noResultsFor,{query:n}))}),!V&&!I&&b==="all"&&T&&(j==="table"?t.jsxs(t.Fragment,{children:[t.jsx(ea,{entries:Ne,...ve}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:u(m.limitedNote)})]}):t.jsx(t.Fragment,{children:Q.map(X=>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($n,{type:X,size:8}),a(X),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:r("meta-fg")},children:[xi(un(T,X))," ",h.unit.items]})]}),un(T,X)>br(T,X).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>oe(X),children:h.action.viewAll})]}),t.jsx(ta,{entries:br(T,X),...ve})]},X))})),!V&&b!=="all"&&!U&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:h.search.loading}),!V&&b!=="all"&&U&&U.entries.length>0&&t.jsxs(t.Fragment,{children:[Le(U.entries),t.jsx(Vm,{page:k,pageSize:xr,total:Math.min(U.total,Un),totalLabel:xi(U.total),onPage:R})]}),!V&&b!=="all"&&U&&U.entries.length===0&&!F&&t.jsxs("div",{className:"bim-sr-empty",children:[u(me?m.emptyFiltered:wt(h.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>oe("all"),children:h.search.allTab})})]})]})]})};function ra({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 jn="bim-recent-ids",oa="bim-recent-entries",sa=50;function Kt(){try{const e=localStorage.getItem(jn);if(e)return JSON.parse(e);const n=localStorage.getItem(oa);if(n){const i=JSON.parse(n).map(o=>o.id);return localStorage.setItem(jn,JSON.stringify(i)),localStorage.removeItem(oa),i}return[]}catch{return[]}}function Br(e){try{const n=Kt().filter(i=>i!==e);n.unshift(e),n.length>sa&&(n.length=sa),localStorage.setItem(jn,JSON.stringify(n))}catch{}}function oc(e){try{const n=Kt().filter(i=>i!==e);localStorage.setItem(jn,JSON.stringify(n))}catch{}}function _o(){try{localStorage.removeItem(jn)}catch{}}async function $o(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 yr=5,th=50,nh=200,aa={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},Or=({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:m,initialQuery:u,onQueryChange:g,headerRight:x,reserveViewportHeight:j=!1,filtersEnabled:y=!1,filters:S=Bi,onFiltersChange:b,resultTab:w,onResultTabChange:v,resultPage:k,onResultPageChange:z})=>{const C=Ae(),_=[{type:"work",name:C.indexType.work,key:"works"},{type:"book",name:C.indexType.book,key:"books"},{type:"collection",name:C.indexType.collection,key:"collections"},{type:"entity",name:C.indexType.entity,key:"entities"}],R=["work","collection","book","entity"],[T,N]=f.useState(u??""),[E,W]=f.useState(null),[F,A]=f.useState(u??""),V=$i(S).toString(),[ae,xe]=f.useState(S);f.useEffect(()=>{xe(S)},[V]);const me=$=>{xe($),b==null||b($)},[G,ye]=f.useState(null),[ne,U]=f.useState("all"),[Q,q]=f.useState(!1),[je,I]=f.useState(null),[oe,$e]=f.useState(""),[ve,Le]=f.useState(!(u!=null&&u.trim())),[Ne,X]=f.useState(Kt),[ue,Pe]=f.useState([]),[Me,ke]=f.useState(!1),[D,le]=f.useState(!1),[ce,Z]=f.useState(null),[we,He]=f.useState(null),Ge=f.useRef(void 0),Xe=f.useRef(!1),O=f.useCallback(async($,M)=>{if(!$.trim()){Le(!0),W(null),ye(null);return}if(Le(!1),y){A($);return}q(!0),$e("");try{if(e.searchAll){const P=await e.searchAll($,M??yr);W(P)}else{const P=["work","book","collection","entity"],K=await Promise.all(P.map(he=>e.search($,he,{page:1,pageSize:M??yr})));W({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})}}catch(P){$e(P instanceof Error?P.message:String(P)),W(null)}finally{q(!1)}},[e,y]);f.useEffect(()=>{let $=!1;const M=()=>{var We,Be;const P=["work","book","collection","entity"],K=Promise.all(P.map(Y=>e.loadEntries(Y,{page:1,pageSize:1}).catch(()=>({total:0})))),he=((We=e.getResourceCounts)==null?void 0:We.call(e).catch(()=>null))??Promise.resolve(null),se=((Be=e.getSubtypeStats)==null?void 0:Be.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([K,he,se]).then(([Y,H,fe])=>{$||(Z({works:Y[0].total,books:Y[1].total,collections:Y[2].total,entities:Y[3].total,hasText:H==null?void 0:H.hasText,hasImage:H==null?void 0:H.hasImage}),fe&&He(fe))})};return e.getCounts?e.getCounts().then(P=>{var K,he;$||(Z({works:P.works,books:P.books,collections:P.collections,entities:P.entities,hasText:(K=P.resourceCounts)==null?void 0:K.hasText,hasImage:(he=P.resourceCounts)==null?void 0:he.hasImage}),P.subtypeStats&&He(P.subtypeStats))}).catch(()=>{$||M()}):M(),()=>{$=!0}},[e]),f.useEffect(()=>{Xe.current||!(u!=null&&u.trim())||(Xe.current=!0,O(u))},[u,O]);const de=f.useCallback($=>{if(N($),!$.trim()){g==null||g($),Le(!0),W(null),ye(null),U("all");return}Ge.current&&clearTimeout(Ge.current),Ge.current=setTimeout(()=>{ye(null),U("all"),g==null||g($),O($)},nh)},[O,g]),Te=f.useCallback($=>{Ge.current&&clearTimeout(Ge.current),U("all"),g==null||g($),O($)},[O,g]),B=f.useCallback($=>{ye($),O(T,th)},[T,O]);f.useEffect(()=>{if(!Ne.length){Pe([]);return}let $=!1;return ke(!0),Promise.all(Ne.slice(0,10).map(M=>$o(e,M))).then(M=>{$||(Pe(M),ke(!1))}),()=>{$=!0}},[Ne,e]);const pe=$=>{I($.id),Br($.id),X(Kt()),o==null||o($)},ie=($,M)=>{if(o&&rh(M)){M.preventDefault(),pe($);return}Br($.id),X(Kt())},_e=$=>{oc($),X(Kt())},Re=()=>{_o(),X([])},De=$=>_.find(M=>M.type===$),Ye=!ve&&!E&&!oe,et=E&&(E.works.length>0||E.books.length>0||E.collections.length>0),Ze=t.jsxs(t.Fragment,{children:[t.jsx(Ol,{transport:e,value:T,onChange:de,onSearch:Te,onEntrySelect:pe}),y&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const $=T.trim();$&&Bl($),Te(T)},children:C.searchPage.submit}),s&&t.jsx("button",{onClick:()=>s("work"),style:{padding:"8px 14px",border:`1px solid ${r("primary")}`,borderRadius:"6px",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"13px"},children:C.action.newEntry})]});return t.jsxs("div",{className:"bim-browser-container",style:j?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:oh+(y?sh:"")}),(!y||x||!p)&&t.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[y?t.jsx("span",{}):t.jsx("h1",{style:{margin:0,fontSize:"18px",color:r("fg")},children:C.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!p&&t.jsx(Pl,{variant:"index-browser",indexSource:n,syncConfig:i,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c})]})]})}),y?t.jsxs("div",{className:"bim-ib-bar","data-nofilters":e.supportsSearchFilters?void 0:"true",children:[t.jsx("span",{"aria-hidden":"true"}),t.jsx("div",{className:"bim-ib-bar-main",children:Ze})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:Ze}),ve&&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:ce&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:we?t.jsxs(t.Fragment,{children:[(we.book??0)>0&&t.jsxs(t.Fragment,{children:[C.searchPage.statBook," ",t.jsx("strong",{style:{color:r("fg")},children:we.book.toLocaleString()})," ",C.unit.bu,C.searchPage.statComma,t.jsx("strong",{style:{color:r("fg")},children:ce.books.toLocaleString()})," ",C.searchPage.statBookCopies]}),we.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.searchPage.statArticle," ",t.jsx("strong",{style:{color:r("fg")},children:we.article.toLocaleString()})," ",C.searchPage.statArticleUnit]}):null,we.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.searchPage.statPoem," ",t.jsx("strong",{style:{color:r("fg")},children:we.poem.toLocaleString()})," ",C.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.searchPage.statCollection," ",t.jsx("strong",{style:{color:r("fg")},children:ce.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[C.indexType.work," ",t.jsx("strong",{style:{color:r("fg")},children:ce.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.indexType.book," ",t.jsx("strong",{style:{color:r("fg")},children:ce.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.indexType.collection," ",t.jsx("strong",{style:{color:r("fg")},children:ce.collections.toLocaleString()}),ce.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.indexType.entity," ",t.jsx("strong",{style:{color:r("fg")},children:ce.entities.toLocaleString()})]})]})}),ce.hasImage!=null&&ce.hasText!=null&&t.jsxs("span",{children:[C.resourceType.image," ",t.jsx("strong",{style:{color:r("fg")},children:ce.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.resourceType.text," ",t.jsx("strong",{style:{color:r("fg")},children:ce.hasText.toLocaleString()})]})]})}),y&&!ve&&t.jsx(rc,{transport:e,query:F,filters:ae,onFiltersChange:me,onEntryLinkClick:ie,typeName:$=>De($).name,tab:w,onTabChange:v,page:k,onPageChange:z}),!(y&&!ve)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:Q||Ye?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg"),minHeight:ih,boxSizing:"border-box"},children:C.search.searching}):oe?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:r("desc-fg")},children:oe})}):ve?t.jsx("div",{style:{flex:1},children:Me?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg")},children:C.search.loading}):ue.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:r("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{children:C.search.recentBrowse}),t.jsx("button",{onClick:Re,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:C.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:ue.slice(0,D?10:3).map($=>$.notFound?t.jsx(dh,{id:$.id,onRemove:_e,t:C},$.id):t.jsx(la,{entry:$,selected:je===$.id,onClick:ie,getConfig:De,onRemove:_e},$.id))}),!D&&ue.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:C.action.expandMore})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:C.search.searchTitle}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:C.search.searchSubtitle})]})}):et?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:ah}),(()=>{const $=se=>E[aa[se]]??0,M=R.map(se=>_.find(We=>We.type===se)).filter(se=>$(se.key)>0);if(M.length<2)return null;const P=M.reduce((se,We)=>se+$(We.key),0),K=se=>{if(U(se),se!=="all"&&G!==se){const We=_.find(Y=>Y.type===se),Be=(E[We.key]??[]).length;$(We.key)>Be&&B(se)}},he=se=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:r(se?"fg":"desc-fg"),fontWeight:se?700:400,boxShadow:se?`inset 0 -2px 0 ${r("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":C.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":ne==="all",style:he(ne==="all"),onClick:()=>K("all"),children:[C.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:P.toLocaleString()})]}),M.map(se=>t.jsxs("button",{type:"button","aria-pressed":ne===se.type,style:he(ne===se.type),onClick:()=>K(se.type),children:[se.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:$(se.key).toLocaleString()})]},se.type))]})})(),_.map(({type:$,name:M,key:P})=>{const K=E[P]??[],he=aa[P],se=E[he]??0;if(K.length===0||ne!=="all"&&ne!==$)return null;const Be=ne==="all"&&!(G===$)&&se>yr;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($n,{type:$})," ",M,t.jsxs("span",{style:{fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:[se," ",C.unit.items]})]}),Be&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>B($),style:{border:"none",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"12px"},children:C.action.viewAll})]}),t.jsx("div",{style:h==="list"?{display:"flex",flexDirection:"column",gap:0}:h==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:K.map(Y=>{if(m)return t.jsx(f.Fragment,{children:m(Y)},Y.id);const H=h==="card"?ch:la;return t.jsx(H,{entry:Y,selected:je===Y.id,onClick:ie,getConfig:De,query:T},Y.id)})})]},$)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:wt(C.search.noResultsFor,{query:T})}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:C.search.tryOther})]})})]})},ih=240;function rh(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const oh=`
|
|
120
|
+
`,_o="bim-search-view",br=50,na=5,Vn=1e3;function bi(e){return e>=Vn?`${Vn.toLocaleString()}+`:e.toLocaleString()}const qm={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function Km(e){return e&&qm[e.toLowerCase()]||"all"}function Xm(e){return e==="all"?null:e}const ia=["work","collection","book","entity"],Zm={work:"works",collection:"collections",book:"books",entity:"entities"},Jm={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function Qm(){try{return window.localStorage.getItem(_o)==="card"?"card":"table"}catch{return"table"}}function eh(e){try{window.localStorage.setItem(_o,e)}catch{}}const gn=(e,n)=>(e==null?void 0:e[Jm[n]])??0,yr=(e,n)=>(e==null?void 0:e[Zm[n]])??[],rc=({transport:e,query:n,filters:i,onFiltersChange:o,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const h=Ae(),m=h.searchV4,{convert:u}=Ue(),g=!!e.supportsSearchFilters,x=f.useMemo(()=>g?i:Oi,[g,i]),[j,y]=f.useState("table");f.useEffect(()=>{y(Qm())},[]);const S=Z=>{y(Z),eh(Z)},[b,w]=f.useState(l??"all"),v=f.useRef(b);v.current=b,f.useEffect(()=>{l!==void 0&&l!==v.current&&(w(l),z(1))},[l]);const[k,z]=f.useState(c&&c>0?c:1),C=f.useRef(k);C.current=k,f.useEffect(()=>{c!==void 0&&c>0&&c!==C.current&&z(c)},[c]);const _=f.useRef(null),R=f.useCallback(Z=>{var Pe;z(Z),p==null||p(Z);const ue=_.current;ue&&ue.getBoundingClientRect().top<0&&((Pe=ue.scrollIntoView)==null||Pe.call(ue,{block:"start",behavior:"instant"}))},[p]),[T,N]=f.useState(null),[E,W]=f.useState(null),[F,A]=f.useState(!1),[V,ae]=f.useState(""),xe=Ci(x).toString(),me=Hi(x)>0,G=Ci({...x,sort:""}).toString(),ye=f.useRef({query:n,filterOnlyKey:G,sort:x.sort});f.useEffect(()=>{const Z=ye.current;Z.query!==n||Z.filterOnlyKey!==G?(w("all"),z(1)):Z.sort!==x.sort&&z(1),ye.current={query:n,filterOnlyKey:G,sort:x.sort}},[n,G,x.sort]),f.useEffect(()=>{let Z=!1;return A(!0),ae(""),(async()=>{try{let ue;if(e.searchAll)ue=await e.searchAll(n,na,x);else{const Pe=["work","book","collection","entity"],Me=await Promise.all(Pe.map(ke=>e.search(n,ke,{page:1,pageSize:na,filters:x})));ue={works:Me[0].entries,books:Me[1].entries,collections:Me[2].entries,entities:Me[3].entries,totalWorks:Me[0].total,totalBooks:Me[1].total,totalCollections:Me[2].total,totalEntities:Me[3].total}}Z||N(ue)}catch(ue){Z||(ae(ue instanceof Error?ue.message:String(ue)),N(null))}finally{Z||A(!1)}})(),()=>{Z=!0}},[e,n,xe]);const ne=b;f.useEffect(()=>{if(b==="all"){W(null);return}let Z=!1;return A(!0),(async()=>{try{const ue=await e.search(n,b,{page:k,pageSize:br,filters:x});Z||W({key:ne,entries:ue.entries,total:ue.total})}catch(ue){Z||(ae(ue instanceof Error?ue.message:String(ue)),W(null))}finally{Z||A(!1)}})(),()=>{Z=!0}},[e,n,xe,b,k]);const U=E&&E.key===ne?E:null;f.useEffect(()=>{if(b==="all"||!U||F)return;const Z=Math.min(U.total,Vn),ue=Um(k,Z,br);U.entries.length===0&&Z>0&&ue!==k&&(z(ue),p==null||p(ue))},[b,U,F,k]);const ee=f.useMemo(()=>ia.filter(Z=>gn(T,Z)>0),[T]),q=ee.reduce((Z,ue)=>Z+gn(T,ue),0),je=ee.some(Z=>gn(T,Z)>=Vn)?`${q.toLocaleString()}+`:q.toLocaleString(),I=!F&&!V&&T!==null&&q===0,oe=f.useCallback(Z=>{w(Z),z(1),d==null||d(Z)},[d]),$e=f.useMemo(()=>{const Z=[];return x.dynasty.forEach(ue=>Z.push({name:ue,remove:()=>o({...x,dynasty:x.dynasty.filter(Pe=>Pe!==ue)})})),x.classification.forEach(ue=>{var Pe;return Z.push({name:ue?((Pe=Fi.find(Me=>Me.value===ue))==null?void 0:Pe.label)??ue:h.searchPage.unclassified,remove:()=>o({...x,classification:x.classification.filter(Me=>Me!==ue)})})}),x.hasImage&&Z.push({name:m.hasImage,remove:()=>o({...x,hasImage:!1})}),x.hasText&&Z.push({name:m.hasText,remove:()=>o({...x,hasText:!1})}),x.hasCollated&&Z.push({name:m.hasCollated,remove:()=>o({...x,hasCollated:!1})}),x.loss&&Z.push({name:`${m.extant}:${h.searchPage.loss[x.loss]}`,remove:()=>o({...x,loss:""})}),Z},[x,o,m,h]),ve={query:n,onEntryLinkClick:s,typeName:a},Le=Z=>j==="table"?t.jsx(ea,{entries:Z,...ve}):t.jsx(ta,{entries:Z,...ve}),Te=ia.flatMap(Z=>yr(T,Z));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":g?void 0:"true",children:[t.jsx("style",{children:Ym}),g&&t.jsx(Fm,{filters:x,onChange:o}),t.jsxs("div",{className:"bim-sr-main","aria-busy":F,ref:_,children:[ee.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(ra,{on:b==="all",onClick:()=>oe("all"),children:[h.search.allTab," ",t.jsx("small",{children:je})]}),ee.map(Z=>t.jsxs(ra,{on:b===Z,onClick:()=>oe(Z),children:[a(Z)," ",t.jsx("small",{children:bi(gn(T,Z))})]},Z))]}),t.jsxs("div",{className:"bim-sr-tools",children:[g&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":u(m.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>o({...x,sort:""}),children:u(m.sortRelevance)}),["era","title"].map(Z=>{const ue=x.sort.startsWith(`${Z}:`)?x.sort.endsWith("desc")?"desc":"asc":null,Pe=Z==="era"?m.sortEra:m.sortTitle,Me=Z==="era"?ue==="desc"?m.sortEraDesc:m.sortEraAsc:ue==="desc"?m.sortTitleDesc:m.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":ue!==null,title:u(Me),onClick:()=>o({...x,sort:`${Z}:${ue==="asc"?"desc":"asc"}`}),children:[u(Pe),ue?t.jsxs("span",{"aria-hidden":"true",children:[" ",ue==="asc"?"↑":"↓"]}):null]},Z)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":u(m.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":j==="table",onClick:()=>S("table"),children:u(m.viewTable)}),t.jsx("button",{type:"button","aria-pressed":j==="card",onClick:()=>S("card"),children:u(m.viewCard)})]})]}),me&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:u(wt(m.filteredCount,{n:je}))}),$e.map(Z=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":u(wt(m.removeFilter,{name:Z.name})),onClick:Z.remove,children:[u(Z.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},Z.name))]}),V&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:V}),I&&t.jsx("div",{className:"bim-sr-empty",children:u(me?m.emptyFiltered:wt(h.search.noResultsFor,{query:n}))}),!V&&!I&&b==="all"&&T&&(j==="table"?t.jsxs(t.Fragment,{children:[t.jsx(ea,{entries:Te,...ve}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:u(m.limitedNote)})]}):t.jsx(t.Fragment,{children:ee.map(Z=>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(Tn,{type:Z,size:8}),a(Z),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:r("meta-fg")},children:[bi(gn(T,Z))," ",h.unit.items]})]}),gn(T,Z)>yr(T,Z).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>oe(Z),children:h.action.viewAll})]}),t.jsx(ta,{entries:yr(T,Z),...ve})]},Z))})),!V&&b!=="all"&&!U&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:h.search.loading}),!V&&b!=="all"&&U&&U.entries.length>0&&t.jsxs(t.Fragment,{children:[Le(U.entries),t.jsx(Vm,{page:k,pageSize:br,total:Math.min(U.total,Vn),totalLabel:bi(U.total),onPage:R})]}),!V&&b!=="all"&&U&&U.entries.length===0&&!F&&t.jsxs("div",{className:"bim-sr-empty",children:[u(me?m.emptyFiltered:wt(h.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>oe("all"),children:h.search.allTab})})]})]})]})};function ra({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 Sn="bim-recent-ids",oa="bim-recent-entries",sa=50;function Qt(){try{const e=localStorage.getItem(Sn);if(e)return JSON.parse(e);const n=localStorage.getItem(oa);if(n){const i=JSON.parse(n).map(o=>o.id);return localStorage.setItem(Sn,JSON.stringify(i)),localStorage.removeItem(oa),i}return[]}catch{return[]}}function Or(e){try{const n=Qt().filter(i=>i!==e);n.unshift(e),n.length>sa&&(n.length=sa),localStorage.setItem(Sn,JSON.stringify(n))}catch{}}function oc(e){try{const n=Qt().filter(i=>i!==e);localStorage.setItem(Sn,JSON.stringify(n))}catch{}}function $o(){try{localStorage.removeItem(Sn)}catch{}}async function Co(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 jr=5,th=50,nh=200,aa={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},Wr=({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:m,initialQuery:u,onQueryChange:g,headerRight:x,reserveViewportHeight:j=!1,filtersEnabled:y=!1,filters:S=Oi,onFiltersChange:b,resultTab:w,onResultTabChange:v,resultPage:k,onResultPageChange:z})=>{const C=Ae(),_=[{type:"work",name:C.indexType.work,key:"works"},{type:"book",name:C.indexType.book,key:"books"},{type:"collection",name:C.indexType.collection,key:"collections"},{type:"entity",name:C.indexType.entity,key:"entities"}],R=["work","collection","book","entity"],[T,N]=f.useState(u??""),[E,W]=f.useState(null),[F,A]=f.useState(u??""),V=Ci(S).toString(),[ae,xe]=f.useState(S);f.useEffect(()=>{xe(S)},[V]);const me=$=>{xe($),b==null||b($)},[G,ye]=f.useState(null),[ne,U]=f.useState("all"),[ee,q]=f.useState(!1),[je,I]=f.useState(null),[oe,$e]=f.useState(""),[ve,Le]=f.useState(!(u!=null&&u.trim())),[Te,Z]=f.useState(Qt),[ue,Pe]=f.useState([]),[Me,ke]=f.useState(!1),[D,le]=f.useState(!1),[ce,J]=f.useState(null),[we,Fe]=f.useState(null),Ve=f.useRef(void 0),Ze=f.useRef(!1),O=f.useCallback(async($,M)=>{if(!$.trim()){Le(!0),W(null),ye(null);return}if(Le(!1),y){A($);return}q(!0),$e("");try{if(e.searchAll){const P=await e.searchAll($,M??jr);W(P)}else{const P=["work","book","collection","entity"],X=await Promise.all(P.map(he=>e.search($,he,{page:1,pageSize:M??jr})));W({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})}}catch(P){$e(P instanceof Error?P.message:String(P)),W(null)}finally{q(!1)}},[e,y]);f.useEffect(()=>{let $=!1;const M=()=>{var We,Be;const P=["work","book","collection","entity"],X=Promise.all(P.map(Y=>e.loadEntries(Y,{page:1,pageSize:1}).catch(()=>({total:0})))),he=((We=e.getResourceCounts)==null?void 0:We.call(e).catch(()=>null))??Promise.resolve(null),se=((Be=e.getSubtypeStats)==null?void 0:Be.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([X,he,se]).then(([Y,H,fe])=>{$||(J({works:Y[0].total,books:Y[1].total,collections:Y[2].total,entities:Y[3].total,hasText:H==null?void 0:H.hasText,hasImage:H==null?void 0:H.hasImage}),fe&&Fe(fe))})};return e.getCounts?e.getCounts().then(P=>{var X,he;$||(J({works:P.works,books:P.books,collections:P.collections,entities:P.entities,hasText:(X=P.resourceCounts)==null?void 0:X.hasText,hasImage:(he=P.resourceCounts)==null?void 0:he.hasImage}),P.subtypeStats&&Fe(P.subtypeStats))}).catch(()=>{$||M()}):M(),()=>{$=!0}},[e]),f.useEffect(()=>{Ze.current||!(u!=null&&u.trim())||(Ze.current=!0,O(u))},[u,O]);const de=f.useCallback($=>{if(N($),!$.trim()){g==null||g($),Le(!0),W(null),ye(null),U("all");return}Ve.current&&clearTimeout(Ve.current),Ve.current=setTimeout(()=>{ye(null),U("all"),g==null||g($),O($)},nh)},[O,g]),Ie=f.useCallback($=>{Ve.current&&clearTimeout(Ve.current),U("all"),g==null||g($),O($)},[O,g]),B=f.useCallback($=>{ye($),O(T,th)},[T,O]);f.useEffect(()=>{if(!Te.length){Pe([]);return}let $=!1;return ke(!0),Promise.all(Te.slice(0,10).map(M=>Co(e,M))).then(M=>{$||(Pe(M),ke(!1))}),()=>{$=!0}},[Te,e]);const pe=$=>{I($.id),Or($.id),Z(Qt()),o==null||o($)},ie=($,M)=>{if(o&&rh(M)){M.preventDefault(),pe($);return}Or($.id),Z(Qt())},_e=$=>{oc($),Z(Qt())},Re=()=>{$o(),Z([])},He=$=>_.find(M=>M.type===$),Ye=!ve&&!E&&!oe,tt=E&&(E.works.length>0||E.books.length>0||E.collections.length>0),Qe=t.jsxs(t.Fragment,{children:[t.jsx(Ol,{transport:e,value:T,onChange:de,onSearch:Ie,onEntrySelect:pe}),y&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const $=T.trim();$&&Bl($),Ie(T)},children:C.searchPage.submit}),s&&t.jsx("button",{onClick:()=>s("work"),style:{padding:"8px 14px",border:`1px solid ${r("primary")}`,borderRadius:"6px",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"13px"},children:C.action.newEntry})]});return t.jsxs("div",{className:"bim-browser-container",style:j?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:oh+(y?sh:"")}),(!y||x||!p)&&t.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[y?t.jsx("span",{}):t.jsx("h1",{style:{margin:0,fontSize:"18px",color:r("fg")},children:C.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!p&&t.jsx(Pl,{variant:"index-browser",indexSource:n,syncConfig:i,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c})]})]})}),y?t.jsxs("div",{className:"bim-ib-bar","data-nofilters":e.supportsSearchFilters?void 0:"true",children:[t.jsx("span",{"aria-hidden":"true"}),t.jsx("div",{className:"bim-ib-bar-main",children:Qe})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:Qe}),ve&&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:ce&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:we?t.jsxs(t.Fragment,{children:[(we.book??0)>0&&t.jsxs(t.Fragment,{children:[C.searchPage.statBook," ",t.jsx("strong",{style:{color:r("fg")},children:we.book.toLocaleString()})," ",C.unit.bu,C.searchPage.statComma,t.jsx("strong",{style:{color:r("fg")},children:ce.books.toLocaleString()})," ",C.searchPage.statBookCopies]}),we.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.searchPage.statArticle," ",t.jsx("strong",{style:{color:r("fg")},children:we.article.toLocaleString()})," ",C.searchPage.statArticleUnit]}):null,we.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.searchPage.statPoem," ",t.jsx("strong",{style:{color:r("fg")},children:we.poem.toLocaleString()})," ",C.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.searchPage.statCollection," ",t.jsx("strong",{style:{color:r("fg")},children:ce.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[C.indexType.work," ",t.jsx("strong",{style:{color:r("fg")},children:ce.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.indexType.book," ",t.jsx("strong",{style:{color:r("fg")},children:ce.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.indexType.collection," ",t.jsx("strong",{style:{color:r("fg")},children:ce.collections.toLocaleString()}),ce.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.indexType.entity," ",t.jsx("strong",{style:{color:r("fg")},children:ce.entities.toLocaleString()})]})]})}),ce.hasImage!=null&&ce.hasText!=null&&t.jsxs("span",{children:[C.resourceType.image," ",t.jsx("strong",{style:{color:r("fg")},children:ce.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),C.resourceType.text," ",t.jsx("strong",{style:{color:r("fg")},children:ce.hasText.toLocaleString()})]})]})}),y&&!ve&&t.jsx(rc,{transport:e,query:F,filters:ae,onFiltersChange:me,onEntryLinkClick:ie,typeName:$=>He($).name,tab:w,onTabChange:v,page:k,onPageChange:z}),!(y&&!ve)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:ee||Ye?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg"),minHeight:ih,boxSizing:"border-box"},children:C.search.searching}):oe?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:r("desc-fg")},children:oe})}):ve?t.jsx("div",{style:{flex:1},children:Me?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg")},children:C.search.loading}):ue.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:r("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{children:C.search.recentBrowse}),t.jsx("button",{onClick:Re,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:C.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:ue.slice(0,D?10:3).map($=>$.notFound?t.jsx(dh,{id:$.id,onRemove:_e,t:C},$.id):t.jsx(la,{entry:$,selected:je===$.id,onClick:ie,getConfig:He,onRemove:_e},$.id))}),!D&&ue.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:C.action.expandMore})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:C.search.searchTitle}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:C.search.searchSubtitle})]})}):tt?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:ah}),(()=>{const $=se=>E[aa[se]]??0,M=R.map(se=>_.find(We=>We.type===se)).filter(se=>$(se.key)>0);if(M.length<2)return null;const P=M.reduce((se,We)=>se+$(We.key),0),X=se=>{if(U(se),se!=="all"&&G!==se){const We=_.find(Y=>Y.type===se),Be=(E[We.key]??[]).length;$(We.key)>Be&&B(se)}},he=se=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:r(se?"fg":"desc-fg"),fontWeight:se?700:400,boxShadow:se?`inset 0 -2px 0 ${r("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":C.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":ne==="all",style:he(ne==="all"),onClick:()=>X("all"),children:[C.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:P.toLocaleString()})]}),M.map(se=>t.jsxs("button",{type:"button","aria-pressed":ne===se.type,style:he(ne===se.type),onClick:()=>X(se.type),children:[se.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:$(se.key).toLocaleString()})]},se.type))]})})(),_.map(({type:$,name:M,key:P})=>{const X=E[P]??[],he=aa[P],se=E[he]??0;if(X.length===0||ne!=="all"&&ne!==$)return null;const Be=ne==="all"&&!(G===$)&&se>jr;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(Tn,{type:$})," ",M,t.jsxs("span",{style:{fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:[se," ",C.unit.items]})]}),Be&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>B($),style:{border:"none",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"12px"},children:C.action.viewAll})]}),t.jsx("div",{style:h==="list"?{display:"flex",flexDirection:"column",gap:0}:h==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:X.map(Y=>{if(m)return t.jsx(f.Fragment,{children:m(Y)},Y.id);const H=h==="card"?ch:la;return t.jsx(H,{entry:Y,selected:je===Y.id,onClick:ie,getConfig:He,query:T},Y.id)})})]},$)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:wt(C.search.noResultsFor,{query:T})}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:C.search.tryOther})]})})]})},ih=240;function rh(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const oh=`
|
|
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
|
`,sh=`
|
|
@@ -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
|
-
}`,sc={color:"inherit",textDecoration:"none"},lh=({snippet:e})=>{const{convert:n}=Ve();return t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.6},children:co(e).map((i,o)=>i.marked?t.jsx("mark",{style:{background:r("highlight-bg"),color:r("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(i.text)},o):t.jsx(f.Fragment,{children:n(i.text)},o))})},ch=({entry:e,selected:n,onClick:i,getConfig:o,query:s})=>{const a=Ae(),{convert:l}=Ve(),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?`${Cn(e.juan_count)}${a.unit.juan}`:"",p=[...e.additional_titles||[],...e.attached_texts||[]],h=s&&p.length?p.find(g=>{const x=typeof g=="string"?g:g==null?void 0:g.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,m=r("cover-accent"),u=st();return t.jsxs("a",{href:u(e.id),onClick:g=>i(e,g),className:"bim-result-card",style:{...sc,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, ${m} 50%, ${r("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${m} 14%, ${r("bg")}), color-mix(in srgb, ${m} 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, ${m} 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:m},children:Array.from(d).map((g,x)=>t.jsx("span",{children:g},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(lh,{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($n,{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})]})]})]})},la=({entry:e,selected:n,onClick:i,getConfig:o,query:s,onRemove:a})=>{const l=Ae(),{convert:d}=Ve(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(m=>{const u=typeof m=="string"?m:m==null?void 0:m.book_title;return u==null?void 0:u.toLowerCase().includes(s.toLowerCase())}):void 0,h=st();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:m=>i(e,m),className:"bim-result-card",style:{...sc,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($n,{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:[Cn(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:"×"})]})},dh=({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 ph(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 uh({data:e}){var l,d;const{convert:n}=Ve(),{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 mh({alt_names:e}){const{convert:n}=Ve(),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 hh({data:e}){const n=Ae(),i=e.external_ids;if(!i)return null;const o=[];return i.cbdb_id&&o.push(t.jsxs("a",{href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${i.cbdb_id}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"2px 8px",fontSize:"12px",color:r("link-fg"),border:`1px solid ${r("link-fg")}40`,borderRadius:"3px",textDecoration:"none",background:`${r("link-fg")}08`},title:n.common.cbdbTitle,children:["CBDB ",i.cbdb_id]},"cbdb")),o.length===0?null:t.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:o})}function fh({works:e,transport:n,onNavigate:i,renderLink:o}){const s=Ae(),{convert:a}=Ve(),l=st(),[d,c]=f.useState(new Map);f.useEffect(()=>{if(!n)return;let u=!1;const g=e.map(j=>j.work_id);return(async()=>{const j=new Map;if(n.getEntriesByIds)try{const w=await n.getEntriesByIds(g);let v=!0;for(let k=0;k<g.length;k++){const z=w[k];z!=null&&z.title?j.set(g[k],z.title):z!=null&&z.primary_name?j.set(g[k],z.primary_name):v=!1}if(v)return j}catch{}const y=[...g],S=8,b=new Array(S).fill(0).map(async()=>{for(;y.length;){const w=y.shift();if(!w)break;if(!j.has(w))try{if(n.getEntry){const z=await n.getEntry(w);if(z!=null&&z.title){j.set(w,z.title);continue}}const v=await n.getItem(w),k=v&&(v.title||v.primary_name)||w;j.set(w,k)}catch{j.set(w,w)}}});return await Promise.all(b),j})().then(j=>{u||c(j)}),()=>{u=!0}},[e,n]);const p=new Map;for(const u of e){const g=u.role||"";p.has(g)||p.set(g,[]),p.get(g).push(u)}const h=["撰","編","注","輯","集","校","評","譯","述","作",""],m=[...p.keys()].sort((u,g)=>{const x=h.indexOf(u),j=h.indexOf(g);return x===-1&&j===-1?u.localeCompare(g):x===-1?1:j===-1?-1:x-j});return t.jsxs("div",{style:{marginTop:"12px"},children:[t.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:r("fg"),margin:"0 0 8px",paddingBottom:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[s.label.relatedWorks," ",t.jsxs("span",{style:{color:r("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",e.length,")"]})]}),m.map(u=>{const g=p.get(u);return t.jsxs("div",{style:{marginBottom:"8px"},children:[u&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"2px"},children:[a(u)," ",t.jsxs("span",{style:{color:r("desc-fg")},children:["(",g.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:u?"16px":"0",listStyle:u?"disc":"none",fontSize:"14px",lineHeight:1.8},children:g.map((x,j)=>{const y=a(d.get(x.work_id)||x.work_id);return o?t.jsx("li",{children:o(x.work_id,y)},j):i?t.jsx("li",{children:t.jsx("a",{href:l(x.work_id),onClick:S=>{S.metaKey||S.ctrlKey||(S.preventDefault(),i(x.work_id))},style:{color:r("link-fg"),textDecoration:"underline",cursor:"pointer"},children:y})},j):t.jsx("li",{children:y},j)})})]},u)})]})}const ac=({data:e,transport:n,onNavigate:i,renderLink:o,headerExtra:s,hideHeader:a})=>{var m;const l=Ae(),{convert:d}=Ve();let c=!1;try{c=ze.extractStatus(e.id)==="draft"}catch{}const p=ph(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(uh,{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(mh,{alt_names:e.alt_names}),t.jsx(hh,{data:e}),((m=e.description)==null?void 0:m.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(fh,{works:e.works,transport:n,onNavigate:i,renderLink:o})]})},gh=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function xh(e){const n=e.search(gh);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const lc={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===bh(e))){const[a,l]=xh(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 bh(e){try{return decodeURI(e)}catch{return e}}const yh={...lc,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},Ut=({text:e,plainStrong:n,style:i,className:o})=>{const{convert:s}=Ve(),a=n?yh:lc;return t.jsx("div",{className:o,style:i,children:t.jsx(ku,{remarkPlugins:[wu],components:a,children:s(e)})})};function cc(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 jh={book:r("type-book"),work:r("type-work"),collection:r("type-collection"),entity:r("type-entity")};function vh({type:e}){const n=Ae();return t.jsx("span",{style:cc(jh[e]),children:n.indexType[e]})}function kh({isDraft:e}){const n=Ae(),i=r(e?"status-draft":"status-official");return t.jsx("span",{style:cc(i),children:e?n.status.draft:n.status.official})}function wh({id:e}){const n=Ae(),[i,o]=f.useState(!1),s=()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})};return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:r("desc-fg"),background:r("bg-subtle"),border:`1px solid ${r("widget-border")}`,borderRadius:"2px"},children:[t.jsx("span",{children:n.label.id}),t.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:r("fg")},children:e}),t.jsx("span",{onClick:s,title:i?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"11px",opacity:i?1:.5,transition:"opacity 0.15s"},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity=i?"1":"0.5",children:i?"✓":"⧉"})]})}function _t({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 Rt({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 dc({authors:e,type:n,onNavigate:i,renderLink:o}){const{convert:s}=Ve();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(Nt,{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 Nt({id:e,label:n,onNavigate:i,renderLink:o}){const s=st();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 Sh({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(vh,{type:o}),t.jsx(kh,{isDraft:s}),t.jsx(wh,{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(dc,{authors:a,type:o,onNavigate:p,renderLink:h}),d]})]})}function pc({items:e,label:n,showMeta:i,onNavigate:o,renderLink:s}){const a=Ae(),{convert:l}=Ve();if(!e.length)return null;const[d,c]=f.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(_t,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((p,h)=>{const m=d===h;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...m?{boxShadow:r("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(m?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:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(p.source)}),!m&&i&&p.title_info&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l(p.title_info)}),p.source_bid&&t.jsx("span",{onClick:u=>u.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(Nt,{id:p.source_bid,label:a.action.view,onNavigate:o,renderLink:s})})]}),m&&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(Rt,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx(Rt,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx(Rt,{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 _h({items:e,onNavigate:n,renderLink:i}){const o=Ae();return t.jsx(pc,{items:e,label:o.section.indexed,showMeta:!0,onNavigate:n,renderLink:i})}function uc({items:e,onNavigate:n,renderLink:i}){const o=Ae();return t.jsx(pc,{items:e,label:o.section.emendated,onNavigate:n,renderLink:i})}function mc({label:e,items:n}){const{convert:i}=Ve();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(_t,{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 $h({items:e}){const n=Ae();return t.jsx(mc,{label:n.section.aliases,items:e})}function Ch({items:e}){const n=Ae();return t.jsx(mc,{label:n.section.attachedTexts,items:e})}function zh({items:e}){const n=Ae(),{convert:i}=Ve();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(_t,{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 Nh({items:e}){const n=Ae(),{convert:i}=Ve();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(_t,{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 Th({items:e}){const n=Ae(),{convert:i}=Ve();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(_t,{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 ca({title:e,ids:n,transport:i,onNavigate:o,renderLink:s}){const{convert:a}=Ve(),[l,d]=f.useState([]);return f.useEffect(()=>{if(!n.length){d([]);return}if(!i){d(n.map(p=>({id:p})));return}let c=!1;return Promise.all(n.map(p=>i.getItem(p).then(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(_t,{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(Nt,{id:c.id,label:p,onNavigate:o,renderLink:s})},c.id)})})]}):null}function jr({book:e,onNavigate:n,renderLink:i}){const o=Ae(),{convert:s}=Ve(),[a,l]=f.useState(!1),d=e.resources&&e.resources.length>0,c=e.edition?s(e.edition):s(e.title)||void 0;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:r("input-bg")},children:[t.jsxs("div",{style:{padding:"6px 12px",borderBottom:d&&!a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:t.jsx(Nt,{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(go,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:i})})]})}function Ih({ids:e,workData:n,transport:i,onNavigate:o,renderLink:s,footer:a}){const l=Ae(),{convert:d}=Ve(),[c,p]=f.useState([]);if(f.useEffect(()=>{if(!e.length){p([]);return}if(!i){p(e.map(j=>({id:j})));return}let x=!1;return Promise.all(e.map(j=>i.getItem(j).then(y=>({id:j,title:y?y.title:void 0,edition:y?y.edition:void 0,resources:y?y.resources:void 0,resource_groups:y?y.resource_groups:void 0})).catch(()=>({id:j})))).then(j=>{x||p(j)}),()=>{x=!0}},[e,i]),!e.length)return null;const h=c.length?c:e.map(x=>({id:x})),m=new Map(h.map(x=>[x.id,x])),u=n==null?void 0:n.version_graph,g=Rh(e,u,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(_t,{children:[l.section.relatedVersions,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",e.length,")"]})]}),a,g.useGrouping?t.jsxs(t.Fragment,{children:[g.coreIds.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:g.coreIds.map(x=>{const j=m.get(x);return j?t.jsx(jr,{book:j,onNavigate:o,renderLink:s},x):null})}),g.groupedIds.map(x=>t.jsxs("details",{style:{marginTop:12,border:`1px solid ${r("widget-border")}`,borderRadius:6,background:r("bg-subtle")},children:[t.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:r("fg"),userSelect:"none"},children:[d(x.label),t.jsxs("span",{style:{marginLeft:6,fontSize:12,color:r("desc-fg"),fontWeight:400},children:["(",x.ids.length,")"]}),x.description&&t.jsx("span",{style:{marginLeft:8,fontSize:12,color:r("desc-fg"),fontWeight:400},children:d(x.description)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"0 12px 12px"},children:x.ids.map(j=>{const y=m.get(j);return y?t.jsx(jr,{book:y,onNavigate:o,renderLink:s},j):null})})]},x.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:h.map(x=>t.jsx(jr,{book:x,onNavigate:o,renderLink:s},x.id))})]})}function Rh(e,n,i){var S,b;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const o=(S=n.collections)==null?void 0:S[n.default_collection],s=(o==null?void 0:o.groups)??[],a=(o==null?void 0:o.book_ids)??[],l=s.length>0||a.length>0,d=!l&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!l&&d.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const c=new Set(s),p=new Set([...a,...d]),h=w=>{if(p.has(w))return!0;const v=n.node_groups[w];return v!=null&&c.has(v)},m=[],u=new Map,g=[];for(const w of e)if(!((b=n.excluded_books)!=null&&b.includes(w)))if(h(w))m.push(w);else{const v=n.node_groups[w];v?(u.has(v)||u.set(v,[]),u.get(v).push(w)):g.push(w)}if(g.length+[...u.values()].reduce((w,v)=>w+v.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const j=new Map((n.groups??[]).map(w=>[w.id,w])),y=[...u.entries()].map(([w,v])=>{const k=j.get(w);return{id:w,label:(k==null?void 0:k.label)??w,description:k==null?void 0:k.description,ids:v}});return g.length>0&&y.push({id:"__other__",label:i,description:void 0,ids:g}),{useGrouping:!0,coreIds:m,groupedIds:y}}function Eh({workData:e,onNavigate:n,renderLink:i}){var l,d,c,p;const o=Ae(),{convert:s}=Ve(),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(Nt,{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:[Cn(e.juan_count.number),o.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(dc,{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(Ut,{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(Rt,{label:o.label.parentWork,children:t.jsx(Nt,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:i})})})]})]})}function Lh({items:e,onNavigate:n,renderLink:i}){const o=Ae(),{convert:s}=Ve();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(Nt,{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:wt(o.catalog.volume,{n:a.volume_index})})]},a.id))}):null}const Co=({data:e,id:n,transport:i,onNavigate:o,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var E,W,F,A,V,ae,xe,me;const p=Ae(),{convert:h}=Ve(),[m,u]=f.useState(null),[g,x]=f.useState(!1),[j,y]=f.useState(null),[S,b]=f.useState(null),[w,v]=f.useState([]),k=e||m;if(f.useEffect(()=>{if(e||!n||!i)return;let G=!1;return x(!0),y(null),i.getItem(n).then(ye=>{G||(ye?u(ye):y(p.misc.notFoundEntry))}).catch(ye=>{G||y(ye instanceof Error?ye.message:p.misc.loadFailed)}).finally(()=>{G||x(!1)}),()=>{G=!0}},[e,n,i]),f.useEffect(()=>{if(!k||!i){b(null),v([]);return}let G=!1;const ye=k.type==="book"||k.type==="collection"?k.work_id:void 0;if(ye?i.getItem(ye).then(ne=>{!G&&ne&&ne.type==="work"&&b(ne)}).catch(()=>{}):b(null),k.type==="book"){const ne=k;ne.contained_in&&ne.contained_in.length>0?Promise.all(ne.contained_in.map(U=>{const Q=typeof U=="string"?U:U.id,q=typeof U=="string"?void 0:U.volume_index;return i.getItem(Q).then(je=>({id:Q,title:je&&je.title||Q,volume_index:q})).catch(()=>({id:Q,title:Q,volume_index:q}))})).then(U=>{G||v(U)}):v([])}else v([]);return()=>{G=!0}},[k,i]),g)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((G,ye)=>t.jsx("div",{style:{height:ye===1?"32px":"16px",width:`${G}px`,background:r("widget-border"),borderRadius:"4px",opacity:.4}},ye))})});if(j)return t.jsx("div",{className:d,style:{...c,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:j});if(!k)return null;if(k.type==="entity")return t.jsx("div",{className:d,style:c,children:t.jsx(ac,{data:k,transport:i,onNavigate:o,renderLink:s,headerExtra:a})});const z=k.type==="book"?k:null,C=k.type==="collection"?k:null,_=k.type==="work"?k:null;let R=!1;try{R=ze.extractStatus(k.id)==="draft"}catch{}let T="";k.measure_info?T=h(k.measure_info):(E=k.juan_count)!=null&&E.number?T=Cn(k.juan_count.number)+p.unit.juan:(W=k.juan_count)!=null&&W.description&&(T=h(k.juan_count.description));const N=[];return(F=k.publication_info)!=null&&F.year&&N.push(t.jsx(Rt,{label:p.label.year,children:k.publication_info.year},"year")),(A=k.current_location)!=null&&A.name&&N.push(t.jsx(Rt,{label:p.label.currentLocation,children:h(k.current_location.name)},"loc")),(V=k.page_count)!=null&&V.description&&N.push(t.jsx(Rt,{label:p.label.pageCount,children:k.page_count.description},"page")),z!=null&&z.edition&&N.push(t.jsx(Rt,{label:p.label.edition,children:h(z.edition)},"ver")),_!=null&&_.parent_work&&N.push(t.jsx(Rt,{label:p.label.parentWork,children:t.jsx(Nt,{id:_.parent_work.id,label:h(_.parent_work.title),onNavigate:o,renderLink:s})},"pw")),_!=null&&_.parent_works&&_.parent_works.length>0&&!_.parent_work&&N.push(t.jsx(Rt,{label:p.label.parentWork,children:_.parent_works.map((G,ye)=>t.jsxs("span",{children:[ye>0&&"、",t.jsx(Nt,{id:G,onNavigate:o,renderLink:s})]},G))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(Sh,{id:k.id,title:h(k.title),edition:k.edition?h(k.edition):void 0,type:k.type,isDraft:R,authors:k.authors,volumeText:T,meta:N,headerExtra:a,onNavigate:o,renderLink:s}),((ae=k.description)==null?void 0:ae.text)&&t.jsx(Ut,{text:k.description.text,style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),k.appendix&&k.appendix.length>0&&t.jsx("div",{style:{marginTop:8,marginBottom:4},children:k.appendix.map((G,ye)=>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(G.title)}),t.jsx(Ut,{text:G.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:r("fg")}})]},ye))}),w.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(_t,{children:p.section.containedIn}),t.jsx(Lh,{items:w,onNavigate:o,renderLink:s})]}),S&&t.jsxs(t.Fragment,{children:[t.jsx(_t,{children:p.section.belongsToWork}),t.jsx(Eh,{workData:S,onNavigate:o,renderLink:s})]}),k.additional_works&&k.additional_works.length>0&&t.jsx(zh,{items:k.additional_works}),k.additional_titles&&k.additional_titles.length>0&&t.jsx($h,{items:k.additional_titles}),k.attached_texts&&k.attached_texts.length>0&&t.jsx(Ch,{items:k.attached_texts}),k.indexed_by&&k.indexed_by.length>0&&t.jsx(_h,{items:k.indexed_by,onNavigate:o,renderLink:s}),k.emendated_by&&k.emendated_by.length>0&&t.jsx(uc,{items:k.emendated_by,onNavigate:o,renderLink:s}),k.resources&&k.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(_t,{children:p.section.resources}),t.jsx(go,{items:k.resources,resourceGroups:k.resource_groups,groupByType:!0,onNavigate:o,renderLink:s})]}),(z==null?void 0:z.location_history)&&z.location_history.length>0&&t.jsx(Nh,{items:z.location_history}),(C==null?void 0:C.history)&&C.history.length>0&&t.jsx(Th,{items:C.history}),(z==null?void 0:z.related_books)&&z.related_books.length>0&&t.jsx(ca,{title:p.section.relatedVersions,ids:z.related_books,transport:i,onNavigate:o,renderLink:s}),(C==null?void 0:C.books)&&C.books.length>0&&t.jsx(ca,{title:p.section.containedBooks,ids:C.books,transport:i,onNavigate:o,renderLink:s}),(C==null?void 0:C.contained_works)&&C.contained_works.length>0&&t.jsxs("div",{children:[t.jsxs(_t,{children:[p.section.containedWorks,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",C.contained_works.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:C.contained_works.map(G=>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(Nt,{id:G.id,label:h(G.title),onNavigate:o,renderLink:s})},G.id))})]}),(((xe=_==null?void 0:_.books)==null?void 0:xe.length)||0)+(((me=_==null?void 0:_.collections)==null?void 0:me.length)||0)>0&&t.jsx(Ih,{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 G=[],ye=_.related_works.filter(I=>I.relation==="part_of"),ne=_.related_works.filter(I=>I.relation==="has_part"),U=_.related_works.filter(I=>I.relation==="has_adaptation"),Q=_.related_works.filter(I=>I.relation==="text_carried_by"),q=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),je=_.related_works.filter(I=>!I.relation||!q.has(I.relation));return ye.length>0&&G.push({label:p.section.belongsToWork,items:ye}),ne.length>0&&G.push({label:p.section.containedWorks,items:ne}),U.length>0&&G.push({label:p.section.adaptations,items:U}),Q.length>0&&G.push({label:p.section.derivativeWorks,items:Q}),je.length>0&&G.push({label:p.section.relatedWorks,items:je}),G.map(I=>t.jsxs("div",{children:[t.jsxs(_t,{children:[I.label,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",I.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:I.items.map(oe=>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(Nt,{id:oe.id,label:h(oe.title),onNavigate:o,renderLink:s})},oe.id))})]},I.label))})()]})};function Ah({data:e}){const n=Ae(),{convert:i}=Ve(),{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 Mh({sections:e,activeSection:n,onSelect:i}){const o=Ae();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>i(null),style:da(n===null),children:o.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>i(s.name),style:da(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 da(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 Ph({id:e,label:n,onNavigate:i,renderLink:o}){const s=st();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 Bh(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 pa({book:e,onNavigate:n,renderLink:i,showVolumes:o}){const s=Ae(),{convert:a}=Ve(),l=e.book_id||e.work_id,d=o&&e.volumes.length>0?Bh(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(Ph,{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 zo=({data:e,collectionId:n,transport:i,onNavigate:o,renderLink:s,className:a,style:l})=>{const d=Ae(),[c,p]=f.useState(null),[h,m]=f.useState(!1),[u,g]=f.useState(null),[x,j]=f.useState(null),[y,S]=f.useState(""),b=e||c;f.useEffect(()=>{if(e||!n||!(i!=null&&i.getCollectionCatalog))return;let C=!1;return m(!0),g(null),i.getCollectionCatalog(n).then(_=>{C||(_?p(_):g(d.catalog.notFound))}).catch(_=>{C||g(_ instanceof Error?_.message:d.catalog.loadFailed)}).finally(()=>{C||m(!1)}),()=>{C=!0}},[e,n,i,d]);const w=(b==null?void 0:b.sections)&&b.sections.length>0,v=f.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const C=b.books.map(R=>R.volumes[0]).filter(R=>R!=null);return new Set(C).size<C.length},[b]),k=f.useMemo(()=>{if(!b)return[];let C=b.books;if(x&&(C=C.filter(_=>_.section===x)),y.trim()){const _=y.trim().toLowerCase();C=C.filter(R=>R.title.toLowerCase().includes(_)||R.sub_items&&R.sub_items.some(T=>T.toLowerCase().includes(_))||R.edition&&R.edition.toLowerCase().includes(_))}return C},[b,x,y]),z=f.useMemo(()=>{if(!v)return null;const C=[],_=new Map;for(const T of k){if(!T.volumes||T.volumes.length===0)continue;const N=T.volumes[0];_.has(N)||_.set(N,[]),_.get(N).push(T)}const R=[..._.keys()].sort((T,N)=>T-N);for(const T of R)C.push({volume:T,books:_.get(T)});return C},[k,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})}):u?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:u}):b?t.jsxs("div",{className:a,style:l,children:[t.jsx(Ah,{data:b}),w&&t.jsx(Mh,{sections:b.sections,activeSection:x,onSelect:j}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:d.search.searchBookName,value:y,onChange:C=>S(C.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"}}),t.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:r("desc-fg")},children:[k.length," ",d.unit.bu]})]}),t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[z?z.map((C,_)=>t.jsxs("div",{children:[t.jsx("div",{style:{padding:"4px 12px",background:r("bg"),borderBottom:`1px solid ${r("widget-border")}`,fontSize:"12px",fontWeight:600,color:r("desc-fg"),position:"sticky",top:0,zIndex:1},children:wt(d.catalog.volume,{n:C.volume})}),C.books.map((R,T)=>t.jsx(pa,{book:R,onNavigate:o,renderLink:s,showVolumes:R.volumes.length>1},`${C.volume}-${T}`))]},`${C.volume}-${_}`)):k.map((C,_)=>t.jsx(pa,{book:C,onNavigate:o,renderLink:s,showVolumes:!0},_)),k.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},vr=e=>e?e.catch(()=>null):Promise.resolve(null);function hc(e){const n=new Map;function i(o){var a;let s=n.get(o);return s||(s=vr((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 ze.isSafeSegment(o)?i(o):Promise.resolve(null)},async getIndex(o,s){return!ze.isSafeSegment(o)||!ze.isSafeSegment(s)||!e.getTextIndex?null:vr(e.getTextIndex(o,s))},async getChapter(o,s,a,l){return!ze.isSafeSegment(o)||!ze.isSafeSegment(s)||!ze.isSafeSegment(a)||!e.getChapter?null:vr(e.getChapter(o,s,a,l))}}}const ln=()=>{const{t:e}=re(),[n,i]=f.useState(1);return f.useEffect(()=>{const o=setInterval(()=>i(s=>s>=3?1:s+1),500);return()=>clearInterval(o)},[]),t.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:r("desc-fg"),fontSize:"14px"},children:e("common.loading")+".".repeat(n)})},kr=String.raw`https?:\/\/[^\s()()<>"]+`,Oh=new RegExp(String.raw`\[([^\]\n]+)\]\((${kr})\)`+String.raw`|(《[^》\n]+》)\s?[((](${kr})[))]`+`|(${kr})`,"g");function Wh(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function Fh(e){const n=[];let i=0;for(const o of e.matchAll(Oh)){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:Wh(o[5]),url:o[5]}),i=s+o[0].length}return i<e.length&&n.push({text:e.slice(i)}),n}function fc({text:e,convert:n,className:i="bim-rd-link"}){return t.jsx(t.Fragment,{children:Fh(e).map((o,s)=>o.url?t.jsx("a",{className:i,href:o.url,target:"_blank",rel:"noopener noreferrer",children:n(o.text)},s):t.jsx(f.Fragment,{children:n(o.text)},s))})}const gc="(min-width: 1100px)",bi="(max-width: 719px)",xc="(max-width: 859px)",Hh=`${bi}, (pointer: coarse)`,It=r("reader-top"),Dh="48px",bc=`
|
|
145
|
+
}`,sc={color:"inherit",textDecoration:"none"},lh=({snippet:e})=>{const{convert:n}=Ue();return t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.6},children:po(e).map((i,o)=>i.marked?t.jsx("mark",{style:{background:r("highlight-bg"),color:r("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(i.text)},o):t.jsx(f.Fragment,{children:n(i.text)},o))})},ch=({entry:e,selected:n,onClick:i,getConfig:o,query:s})=>{const a=Ae(),{convert:l}=Ue(),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?`${In(e.juan_count)}${a.unit.juan}`:"",p=[...e.additional_titles||[],...e.attached_texts||[]],h=s&&p.length?p.find(g=>{const x=typeof g=="string"?g:g==null?void 0:g.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,m=r("cover-accent"),u=at();return t.jsxs("a",{href:u(e.id),onClick:g=>i(e,g),className:"bim-result-card",style:{...sc,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, ${m} 50%, ${r("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${m} 14%, ${r("bg")}), color-mix(in srgb, ${m} 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, ${m} 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:m},children:Array.from(d).map((g,x)=>t.jsx("span",{children:g},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(lh,{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(Tn,{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})]})]})]})},la=({entry:e,selected:n,onClick:i,getConfig:o,query:s,onRemove:a})=>{const l=Ae(),{convert:d}=Ue(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(m=>{const u=typeof m=="string"?m:m==null?void 0:m.book_title;return u==null?void 0:u.toLowerCase().includes(s.toLowerCase())}):void 0,h=at();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:m=>i(e,m),className:"bim-result-card",style:{...sc,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(Tn,{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:[In(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:"×"})]})},dh=({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 ph(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 uh({data:e}){var l,d;const{convert:n}=Ue(),{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 mh({alt_names:e}){const{convert:n}=Ue(),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 hh({data:e}){const n=Ae(),i=e.external_ids;if(!i)return null;const o=[];return i.cbdb_id&&o.push(t.jsxs("a",{href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${i.cbdb_id}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"2px 8px",fontSize:"12px",color:r("link-fg"),border:`1px solid ${r("link-fg")}40`,borderRadius:"3px",textDecoration:"none",background:`${r("link-fg")}08`},title:n.common.cbdbTitle,children:["CBDB ",i.cbdb_id]},"cbdb")),o.length===0?null:t.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:o})}function fh({works:e,transport:n,onNavigate:i,renderLink:o}){const s=Ae(),{convert:a}=Ue(),l=at(),[d,c]=f.useState(new Map);f.useEffect(()=>{if(!n)return;let u=!1;const g=e.map(j=>j.work_id);return(async()=>{const j=new Map;if(n.getEntriesByIds)try{const w=await n.getEntriesByIds(g);let v=!0;for(let k=0;k<g.length;k++){const z=w[k];z!=null&&z.title?j.set(g[k],z.title):z!=null&&z.primary_name?j.set(g[k],z.primary_name):v=!1}if(v)return j}catch{}const y=[...g],S=8,b=new Array(S).fill(0).map(async()=>{for(;y.length;){const w=y.shift();if(!w)break;if(!j.has(w))try{if(n.getEntry){const z=await n.getEntry(w);if(z!=null&&z.title){j.set(w,z.title);continue}}const v=await n.getItem(w),k=v&&(v.title||v.primary_name)||w;j.set(w,k)}catch{j.set(w,w)}}});return await Promise.all(b),j})().then(j=>{u||c(j)}),()=>{u=!0}},[e,n]);const p=new Map;for(const u of e){const g=u.role||"";p.has(g)||p.set(g,[]),p.get(g).push(u)}const h=["撰","編","注","輯","集","校","評","譯","述","作",""],m=[...p.keys()].sort((u,g)=>{const x=h.indexOf(u),j=h.indexOf(g);return x===-1&&j===-1?u.localeCompare(g):x===-1?1:j===-1?-1:x-j});return t.jsxs("div",{style:{marginTop:"12px"},children:[t.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:r("fg"),margin:"0 0 8px",paddingBottom:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[s.label.relatedWorks," ",t.jsxs("span",{style:{color:r("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",e.length,")"]})]}),m.map(u=>{const g=p.get(u);return t.jsxs("div",{style:{marginBottom:"8px"},children:[u&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"2px"},children:[a(u)," ",t.jsxs("span",{style:{color:r("desc-fg")},children:["(",g.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:u?"16px":"0",listStyle:u?"disc":"none",fontSize:"14px",lineHeight:1.8},children:g.map((x,j)=>{const y=a(d.get(x.work_id)||x.work_id);return o?t.jsx("li",{children:o(x.work_id,y)},j):i?t.jsx("li",{children:t.jsx("a",{href:l(x.work_id),onClick:S=>{S.metaKey||S.ctrlKey||(S.preventDefault(),i(x.work_id))},style:{color:r("link-fg"),textDecoration:"underline",cursor:"pointer"},children:y})},j):t.jsx("li",{children:y},j)})})]},u)})]})}const ac=({data:e,transport:n,onNavigate:i,renderLink:o,headerExtra:s,hideHeader:a})=>{var m;const l=Ae(),{convert:d}=Ue();let c=!1;try{c=ze.extractStatus(e.id)==="draft"}catch{}const p=ph(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(uh,{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(mh,{alt_names:e.alt_names}),t.jsx(hh,{data:e}),((m=e.description)==null?void 0:m.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(fh,{works:e.works,transport:n,onNavigate:i,renderLink:o})]})},gh=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function xh(e){const n=e.search(gh);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const lc={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===bh(e))){const[a,l]=xh(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 bh(e){try{return decodeURI(e)}catch{return e}}const yh={...lc,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},Yt=({text:e,plainStrong:n,style:i,className:o})=>{const{convert:s}=Ue(),a=n?yh:lc;return t.jsx("div",{className:o,style:i,children:t.jsx(ku,{remarkPlugins:[wu],components:a,children:s(e)})})};function cc(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 jh={book:r("type-book"),work:r("type-work"),collection:r("type-collection"),entity:r("type-entity")};function vh({type:e}){const n=Ae();return t.jsx("span",{style:cc(jh[e]),children:n.indexType[e]})}function kh({isDraft:e}){const n=Ae(),i=r(e?"status-draft":"status-official");return t.jsx("span",{style:cc(i),children:e?n.status.draft:n.status.official})}function wh({id:e}){const n=Ae(),[i,o]=f.useState(!1),s=()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})};return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:r("desc-fg"),background:r("bg-subtle"),border:`1px solid ${r("widget-border")}`,borderRadius:"2px"},children:[t.jsx("span",{children:n.label.id}),t.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:r("fg")},children:e}),t.jsx("span",{onClick:s,title:i?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"11px",opacity:i?1:.5,transition:"opacity 0.15s"},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity=i?"1":"0.5",children:i?"✓":"⧉"})]})}function Ct({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 Lt({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 dc({authors:e,type:n,onNavigate:i,renderLink:o}){const{convert:s}=Ue();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(It,{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 It({id:e,label:n,onNavigate:i,renderLink:o}){const s=at();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 Sh({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(vh,{type:o}),t.jsx(kh,{isDraft:s}),t.jsx(wh,{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(dc,{authors:a,type:o,onNavigate:p,renderLink:h}),d]})]})}function pc({items:e,label:n,showMeta:i,onNavigate:o,renderLink:s}){const a=Ae(),{convert:l}=Ue();if(!e.length)return null;const[d,c]=f.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(Ct,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((p,h)=>{const m=d===h;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...m?{boxShadow:r("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(m?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:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(p.source)}),!m&&i&&p.title_info&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l(p.title_info)}),p.source_bid&&t.jsx("span",{onClick:u=>u.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(It,{id:p.source_bid,label:a.action.view,onNavigate:o,renderLink:s})})]}),m&&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(Lt,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx(Lt,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx(Lt,{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 _h({items:e,onNavigate:n,renderLink:i}){const o=Ae();return t.jsx(pc,{items:e,label:o.section.indexed,showMeta:!0,onNavigate:n,renderLink:i})}function uc({items:e,onNavigate:n,renderLink:i}){const o=Ae();return t.jsx(pc,{items:e,label:o.section.emendated,onNavigate:n,renderLink:i})}function mc({label:e,items:n}){const{convert:i}=Ue();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(Ct,{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 $h({items:e}){const n=Ae();return t.jsx(mc,{label:n.section.aliases,items:e})}function Ch({items:e}){const n=Ae();return t.jsx(mc,{label:n.section.attachedTexts,items:e})}function zh({items:e}){const n=Ae(),{convert:i}=Ue();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Ct,{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 Nh({items:e}){const n=Ae(),{convert:i}=Ue();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Ct,{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 Th({items:e}){const n=Ae(),{convert:i}=Ue();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Ct,{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 ca({title:e,ids:n,transport:i,onNavigate:o,renderLink:s}){const{convert:a}=Ue(),[l,d]=f.useState([]);return f.useEffect(()=>{if(!n.length){d([]);return}if(!i){d(n.map(p=>({id:p})));return}let c=!1;return Promise.all(n.map(p=>i.getItem(p).then(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(Ct,{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(It,{id:c.id,label:p,onNavigate:o,renderLink:s})},c.id)})})]}):null}function vr({book:e,onNavigate:n,renderLink:i}){const o=Ae(),{convert:s}=Ue(),[a,l]=f.useState(!1),d=e.resources&&e.resources.length>0,c=e.edition?s(e.edition):s(e.title)||void 0;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:r("input-bg")},children:[t.jsxs("div",{style:{padding:"6px 12px",borderBottom:d&&!a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:t.jsx(It,{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(xo,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:i})})]})}function Ih({ids:e,workData:n,transport:i,onNavigate:o,renderLink:s,footer:a}){const l=Ae(),{convert:d}=Ue(),[c,p]=f.useState([]);if(f.useEffect(()=>{if(!e.length){p([]);return}if(!i){p(e.map(j=>({id:j})));return}let x=!1;return Promise.all(e.map(j=>i.getItem(j).then(y=>({id:j,title:y?y.title:void 0,edition:y?y.edition:void 0,resources:y?y.resources:void 0,resource_groups:y?y.resource_groups:void 0})).catch(()=>({id:j})))).then(j=>{x||p(j)}),()=>{x=!0}},[e,i]),!e.length)return null;const h=c.length?c:e.map(x=>({id:x})),m=new Map(h.map(x=>[x.id,x])),u=n==null?void 0:n.version_graph,g=Rh(e,u,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(Ct,{children:[l.section.relatedVersions,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",e.length,")"]})]}),a,g.useGrouping?t.jsxs(t.Fragment,{children:[g.coreIds.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:g.coreIds.map(x=>{const j=m.get(x);return j?t.jsx(vr,{book:j,onNavigate:o,renderLink:s},x):null})}),g.groupedIds.map(x=>t.jsxs("details",{style:{marginTop:12,border:`1px solid ${r("widget-border")}`,borderRadius:6,background:r("bg-subtle")},children:[t.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:r("fg"),userSelect:"none"},children:[d(x.label),t.jsxs("span",{style:{marginLeft:6,fontSize:12,color:r("desc-fg"),fontWeight:400},children:["(",x.ids.length,")"]}),x.description&&t.jsx("span",{style:{marginLeft:8,fontSize:12,color:r("desc-fg"),fontWeight:400},children:d(x.description)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"0 12px 12px"},children:x.ids.map(j=>{const y=m.get(j);return y?t.jsx(vr,{book:y,onNavigate:o,renderLink:s},j):null})})]},x.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:h.map(x=>t.jsx(vr,{book:x,onNavigate:o,renderLink:s},x.id))})]})}function Rh(e,n,i){var S,b;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const o=(S=n.collections)==null?void 0:S[n.default_collection],s=(o==null?void 0:o.groups)??[],a=(o==null?void 0:o.book_ids)??[],l=s.length>0||a.length>0,d=!l&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!l&&d.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const c=new Set(s),p=new Set([...a,...d]),h=w=>{if(p.has(w))return!0;const v=n.node_groups[w];return v!=null&&c.has(v)},m=[],u=new Map,g=[];for(const w of e)if(!((b=n.excluded_books)!=null&&b.includes(w)))if(h(w))m.push(w);else{const v=n.node_groups[w];v?(u.has(v)||u.set(v,[]),u.get(v).push(w)):g.push(w)}if(g.length+[...u.values()].reduce((w,v)=>w+v.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const j=new Map((n.groups??[]).map(w=>[w.id,w])),y=[...u.entries()].map(([w,v])=>{const k=j.get(w);return{id:w,label:(k==null?void 0:k.label)??w,description:k==null?void 0:k.description,ids:v}});return g.length>0&&y.push({id:"__other__",label:i,description:void 0,ids:g}),{useGrouping:!0,coreIds:m,groupedIds:y}}function Eh({workData:e,onNavigate:n,renderLink:i}){var l,d,c,p;const o=Ae(),{convert:s}=Ue(),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(It,{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:[In(e.juan_count.number),o.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(dc,{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(Yt,{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(Lt,{label:o.label.parentWork,children:t.jsx(It,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:i})})})]})]})}function Lh({items:e,onNavigate:n,renderLink:i}){const o=Ae(),{convert:s}=Ue();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(It,{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:wt(o.catalog.volume,{n:a.volume_index})})]},a.id))}):null}const zo=({data:e,id:n,transport:i,onNavigate:o,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var E,W,F,A,V,ae,xe,me;const p=Ae(),{convert:h}=Ue(),[m,u]=f.useState(null),[g,x]=f.useState(!1),[j,y]=f.useState(null),[S,b]=f.useState(null),[w,v]=f.useState([]),k=e||m;if(f.useEffect(()=>{if(e||!n||!i)return;let G=!1;return x(!0),y(null),i.getItem(n).then(ye=>{G||(ye?u(ye):y(p.misc.notFoundEntry))}).catch(ye=>{G||y(ye instanceof Error?ye.message:p.misc.loadFailed)}).finally(()=>{G||x(!1)}),()=>{G=!0}},[e,n,i]),f.useEffect(()=>{if(!k||!i){b(null),v([]);return}let G=!1;const ye=k.type==="book"||k.type==="collection"?k.work_id:void 0;if(ye?i.getItem(ye).then(ne=>{!G&&ne&&ne.type==="work"&&b(ne)}).catch(()=>{}):b(null),k.type==="book"){const ne=k;ne.contained_in&&ne.contained_in.length>0?Promise.all(ne.contained_in.map(U=>{const ee=typeof U=="string"?U:U.id,q=typeof U=="string"?void 0:U.volume_index;return i.getItem(ee).then(je=>({id:ee,title:je&&je.title||ee,volume_index:q})).catch(()=>({id:ee,title:ee,volume_index:q}))})).then(U=>{G||v(U)}):v([])}else v([]);return()=>{G=!0}},[k,i]),g)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((G,ye)=>t.jsx("div",{style:{height:ye===1?"32px":"16px",width:`${G}px`,background:r("widget-border"),borderRadius:"4px",opacity:.4}},ye))})});if(j)return t.jsx("div",{className:d,style:{...c,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:j});if(!k)return null;if(k.type==="entity")return t.jsx("div",{className:d,style:c,children:t.jsx(ac,{data:k,transport:i,onNavigate:o,renderLink:s,headerExtra:a})});const z=k.type==="book"?k:null,C=k.type==="collection"?k:null,_=k.type==="work"?k:null;let R=!1;try{R=ze.extractStatus(k.id)==="draft"}catch{}let T="";k.measure_info?T=h(k.measure_info):(E=k.juan_count)!=null&&E.number?T=In(k.juan_count.number)+p.unit.juan:(W=k.juan_count)!=null&&W.description&&(T=h(k.juan_count.description));const N=[];return(F=k.publication_info)!=null&&F.year&&N.push(t.jsx(Lt,{label:p.label.year,children:k.publication_info.year},"year")),(A=k.current_location)!=null&&A.name&&N.push(t.jsx(Lt,{label:p.label.currentLocation,children:h(k.current_location.name)},"loc")),(V=k.page_count)!=null&&V.description&&N.push(t.jsx(Lt,{label:p.label.pageCount,children:k.page_count.description},"page")),z!=null&&z.edition&&N.push(t.jsx(Lt,{label:p.label.edition,children:h(z.edition)},"ver")),_!=null&&_.parent_work&&N.push(t.jsx(Lt,{label:p.label.parentWork,children:t.jsx(It,{id:_.parent_work.id,label:h(_.parent_work.title),onNavigate:o,renderLink:s})},"pw")),_!=null&&_.parent_works&&_.parent_works.length>0&&!_.parent_work&&N.push(t.jsx(Lt,{label:p.label.parentWork,children:_.parent_works.map((G,ye)=>t.jsxs("span",{children:[ye>0&&"、",t.jsx(It,{id:G,onNavigate:o,renderLink:s})]},G))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(Sh,{id:k.id,title:h(k.title),edition:k.edition?h(k.edition):void 0,type:k.type,isDraft:R,authors:k.authors,volumeText:T,meta:N,headerExtra:a,onNavigate:o,renderLink:s}),((ae=k.description)==null?void 0:ae.text)&&t.jsx(Yt,{text:k.description.text,style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),k.appendix&&k.appendix.length>0&&t.jsx("div",{style:{marginTop:8,marginBottom:4},children:k.appendix.map((G,ye)=>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(G.title)}),t.jsx(Yt,{text:G.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:r("fg")}})]},ye))}),w.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Ct,{children:p.section.containedIn}),t.jsx(Lh,{items:w,onNavigate:o,renderLink:s})]}),S&&t.jsxs(t.Fragment,{children:[t.jsx(Ct,{children:p.section.belongsToWork}),t.jsx(Eh,{workData:S,onNavigate:o,renderLink:s})]}),k.additional_works&&k.additional_works.length>0&&t.jsx(zh,{items:k.additional_works}),k.additional_titles&&k.additional_titles.length>0&&t.jsx($h,{items:k.additional_titles}),k.attached_texts&&k.attached_texts.length>0&&t.jsx(Ch,{items:k.attached_texts}),k.indexed_by&&k.indexed_by.length>0&&t.jsx(_h,{items:k.indexed_by,onNavigate:o,renderLink:s}),k.emendated_by&&k.emendated_by.length>0&&t.jsx(uc,{items:k.emendated_by,onNavigate:o,renderLink:s}),k.resources&&k.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Ct,{children:p.section.resources}),t.jsx(xo,{items:k.resources,resourceGroups:k.resource_groups,groupByType:!0,onNavigate:o,renderLink:s})]}),(z==null?void 0:z.location_history)&&z.location_history.length>0&&t.jsx(Nh,{items:z.location_history}),(C==null?void 0:C.history)&&C.history.length>0&&t.jsx(Th,{items:C.history}),(z==null?void 0:z.related_books)&&z.related_books.length>0&&t.jsx(ca,{title:p.section.relatedVersions,ids:z.related_books,transport:i,onNavigate:o,renderLink:s}),(C==null?void 0:C.books)&&C.books.length>0&&t.jsx(ca,{title:p.section.containedBooks,ids:C.books,transport:i,onNavigate:o,renderLink:s}),(C==null?void 0:C.contained_works)&&C.contained_works.length>0&&t.jsxs("div",{children:[t.jsxs(Ct,{children:[p.section.containedWorks,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",C.contained_works.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:C.contained_works.map(G=>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(It,{id:G.id,label:h(G.title),onNavigate:o,renderLink:s})},G.id))})]}),(((xe=_==null?void 0:_.books)==null?void 0:xe.length)||0)+(((me=_==null?void 0:_.collections)==null?void 0:me.length)||0)>0&&t.jsx(Ih,{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 G=[],ye=_.related_works.filter(I=>I.relation==="part_of"),ne=_.related_works.filter(I=>I.relation==="has_part"),U=_.related_works.filter(I=>I.relation==="has_adaptation"),ee=_.related_works.filter(I=>I.relation==="text_carried_by"),q=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),je=_.related_works.filter(I=>!I.relation||!q.has(I.relation));return ye.length>0&&G.push({label:p.section.belongsToWork,items:ye}),ne.length>0&&G.push({label:p.section.containedWorks,items:ne}),U.length>0&&G.push({label:p.section.adaptations,items:U}),ee.length>0&&G.push({label:p.section.derivativeWorks,items:ee}),je.length>0&&G.push({label:p.section.relatedWorks,items:je}),G.map(I=>t.jsxs("div",{children:[t.jsxs(Ct,{children:[I.label,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",I.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:I.items.map(oe=>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(It,{id:oe.id,label:h(oe.title),onNavigate:o,renderLink:s})},oe.id))})]},I.label))})()]})};function Ah({data:e}){const n=Ae(),{convert:i}=Ue(),{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 Mh({sections:e,activeSection:n,onSelect:i}){const o=Ae();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>i(null),style:da(n===null),children:o.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>i(s.name),style:da(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 da(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 Ph({id:e,label:n,onNavigate:i,renderLink:o}){const s=at();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 Bh(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 pa({book:e,onNavigate:n,renderLink:i,showVolumes:o}){const s=Ae(),{convert:a}=Ue(),l=e.book_id||e.work_id,d=o&&e.volumes.length>0?Bh(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(Ph,{id:l,label:e.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:i}),!l&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const No=({data:e,collectionId:n,transport:i,onNavigate:o,renderLink:s,className:a,style:l})=>{const d=Ae(),[c,p]=f.useState(null),[h,m]=f.useState(!1),[u,g]=f.useState(null),[x,j]=f.useState(null),[y,S]=f.useState(""),b=e||c;f.useEffect(()=>{if(e||!n||!(i!=null&&i.getCollectionCatalog))return;let C=!1;return m(!0),g(null),i.getCollectionCatalog(n).then(_=>{C||(_?p(_):g(d.catalog.notFound))}).catch(_=>{C||g(_ instanceof Error?_.message:d.catalog.loadFailed)}).finally(()=>{C||m(!1)}),()=>{C=!0}},[e,n,i,d]);const w=(b==null?void 0:b.sections)&&b.sections.length>0,v=f.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const C=b.books.map(R=>R.volumes[0]).filter(R=>R!=null);return new Set(C).size<C.length},[b]),k=f.useMemo(()=>{if(!b)return[];let C=b.books;if(x&&(C=C.filter(_=>_.section===x)),y.trim()){const _=y.trim().toLowerCase();C=C.filter(R=>R.title.toLowerCase().includes(_)||R.sub_items&&R.sub_items.some(T=>T.toLowerCase().includes(_))||R.edition&&R.edition.toLowerCase().includes(_))}return C},[b,x,y]),z=f.useMemo(()=>{if(!v)return null;const C=[],_=new Map;for(const T of k){if(!T.volumes||T.volumes.length===0)continue;const N=T.volumes[0];_.has(N)||_.set(N,[]),_.get(N).push(T)}const R=[..._.keys()].sort((T,N)=>T-N);for(const T of R)C.push({volume:T,books:_.get(T)});return C},[k,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})}):u?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:u}):b?t.jsxs("div",{className:a,style:l,children:[t.jsx(Ah,{data:b}),w&&t.jsx(Mh,{sections:b.sections,activeSection:x,onSelect:j}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:d.search.searchBookName,value:y,onChange:C=>S(C.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"}}),t.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:r("desc-fg")},children:[k.length," ",d.unit.bu]})]}),t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[z?z.map((C,_)=>t.jsxs("div",{children:[t.jsx("div",{style:{padding:"4px 12px",background:r("bg"),borderBottom:`1px solid ${r("widget-border")}`,fontSize:"12px",fontWeight:600,color:r("desc-fg"),position:"sticky",top:0,zIndex:1},children:wt(d.catalog.volume,{n:C.volume})}),C.books.map((R,T)=>t.jsx(pa,{book:R,onNavigate:o,renderLink:s,showVolumes:R.volumes.length>1},`${C.volume}-${T}`))]},`${C.volume}-${_}`)):k.map((C,_)=>t.jsx(pa,{book:C,onNavigate:o,renderLink:s,showVolumes:!0},_)),k.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},kr=e=>e?e.catch(()=>null):Promise.resolve(null);function hc(e){const n=new Map;function i(o){var a;let s=n.get(o);return s||(s=kr((a=e.getTextManifest)==null?void 0:a.call(e,o)).then(l=>{const d=l&&Array.isArray(l.versions)&&l.versions.length>0?l:null;return d||n.delete(o),d}),n.set(o,s)),s}return{getManifest(o){return ze.isSafeSegment(o)?i(o):Promise.resolve(null)},async getIndex(o,s){return!ze.isSafeSegment(o)||!ze.isSafeSegment(s)||!e.getTextIndex?null:kr(e.getTextIndex(o,s))},async getChapter(o,s,a,l){return!ze.isSafeSegment(o)||!ze.isSafeSegment(s)||!ze.isSafeSegment(a)||!e.getChapter?null:kr(e.getChapter(o,s,a,l))}}}const un=()=>{const{t:e}=re(),[n,i]=f.useState(1);return f.useEffect(()=>{const o=setInterval(()=>i(s=>s>=3?1:s+1),500);return()=>clearInterval(o)},[]),t.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:r("desc-fg"),fontSize:"14px"},children:e("common.loading")+".".repeat(n)})},wr=String.raw`https?:\/\/[^\s()()<>"]+`,Oh=new RegExp(String.raw`\[([^\]\n]+)\]\((${wr})\)`+String.raw`|(《[^》\n]+》)\s?[((](${wr})[))]`+`|(${wr})`,"g");function Wh(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function Fh(e){const n=[];let i=0;for(const o of e.matchAll(Oh)){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:Wh(o[5]),url:o[5]}),i=s+o[0].length}return i<e.length&&n.push({text:e.slice(i)}),n}function fc({text:e,convert:n,className:i="bim-rd-link"}){return t.jsx(t.Fragment,{children:Fh(e).map((o,s)=>o.url?t.jsx("a",{className:i,href:o.url,target:"_blank",rel:"noopener noreferrer",children:n(o.text)},s):t.jsx(f.Fragment,{children:n(o.text)},s))})}const gc="(min-width: 1100px)",yi="(max-width: 719px)",xc="(max-width: 859px)",Hh=`${yi}, (pointer: coarse)`,Et=r("reader-top"),Dh="48px",bc=`
|
|
146
146
|
.bim-rd {
|
|
147
147
|
position: relative;
|
|
148
148
|
background: ${r("page-bg")};
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
|
|
179
179
|
/* ── 工具条:文字 + 图标,不画按钮外框 ── */
|
|
180
180
|
.bim-rd-bar {
|
|
181
|
-
position: sticky; top: ${
|
|
181
|
+
position: sticky; top: ${Et}; z-index: 30;
|
|
182
182
|
height: var(--bimrd-bar-h);
|
|
183
183
|
display: flex; align-items: center; gap: 16px;
|
|
184
184
|
padding: 0 20px;
|
|
@@ -234,14 +234,14 @@
|
|
|
234
234
|
display: grid;
|
|
235
235
|
grid-template-columns: auto auto minmax(0, 1fr) auto;
|
|
236
236
|
align-items: start;
|
|
237
|
-
min-height: calc(100vh - ${
|
|
237
|
+
min-height: calc(100vh - ${Et} - var(--bimrd-bar-h));
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
/* 目录:宽屏是侧栏 */
|
|
241
241
|
.bim-rd-toc {
|
|
242
242
|
grid-column: 1;
|
|
243
|
-
position: sticky; top: calc(${
|
|
244
|
-
width: 248px; height: calc(100vh - ${
|
|
243
|
+
position: sticky; top: calc(${Et} + var(--bimrd-bar-h));
|
|
244
|
+
width: 248px; height: calc(100vh - ${Et} - var(--bimrd-bar-h));
|
|
245
245
|
overflow-y: auto; overscroll-behavior: contain;
|
|
246
246
|
padding: 0 10px 40px;
|
|
247
247
|
background: ${r("sidebar-bg")};
|
|
@@ -288,8 +288,8 @@
|
|
|
288
288
|
/* 书影:正文左侧 */
|
|
289
289
|
.bim-rd-img {
|
|
290
290
|
grid-column: 2;
|
|
291
|
-
position: sticky; top: calc(${
|
|
292
|
-
width: clamp(300px, 32vw, 560px); height: calc(100vh - ${
|
|
291
|
+
position: sticky; top: calc(${Et} + var(--bimrd-bar-h));
|
|
292
|
+
width: clamp(300px, 32vw, 560px); height: calc(100vh - ${Et} - var(--bimrd-bar-h) - var(--bimrd-img-lead, 0px));
|
|
293
293
|
padding: 16px 0 16px 20px;
|
|
294
294
|
display: flex; flex-direction: column; gap: 8px;
|
|
295
295
|
}
|
|
@@ -300,7 +300,7 @@
|
|
|
300
300
|
display: flex; align-items: center; justify-content: center; overflow: hidden;
|
|
301
301
|
}
|
|
302
302
|
.bim-rd-img-fig { position: relative; margin: 0; max-width: 100%; max-height: 100%; }
|
|
303
|
-
.bim-rd-img-fig img { display: block; max-width: 100%; max-height: calc(100vh - ${
|
|
303
|
+
.bim-rd-img-fig img { display: block; max-width: 100%; max-height: calc(100vh - ${Et} - var(--bimrd-bar-h) - var(--bimrd-img-lead, 0px) - 80px); object-fit: contain; }
|
|
304
304
|
.bim-rd-img-fig svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
|
|
305
305
|
.bim-rd-img-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px; text-align: center; font-size: 13px; color: ${r("meta-fg")}; }
|
|
306
306
|
.bim-rd-img-empty b { font-size: 15px; font-weight: 500; color: ${r("quiet-fg")}; }
|
|
@@ -396,7 +396,7 @@
|
|
|
396
396
|
|
|
397
397
|
/* 竖排(预留):只在宿主打开 allowVertical 时可切换 */
|
|
398
398
|
.bim-rd-vertical .bim-rd-prose {
|
|
399
|
-
writing-mode: vertical-rl; max-height: calc(100vh - ${
|
|
399
|
+
writing-mode: vertical-rl; max-height: calc(100vh - ${Et} - var(--bimrd-bar-h) - 120px);
|
|
400
400
|
overflow-x: auto; text-align: start;
|
|
401
401
|
}
|
|
402
402
|
|
|
@@ -462,8 +462,8 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
462
462
|
/* ── 右侧「阅读设置」侧栏(overview#463):≥860px 是右栏,窄屏改走底栏的底部抽屉;分组 文字/标注/版面 ── */
|
|
463
463
|
.bim-rd-set {
|
|
464
464
|
grid-column: 4; grid-row: 1;
|
|
465
|
-
position: sticky; top: calc(${
|
|
466
|
-
width: 264px; height: calc(100vh - ${
|
|
465
|
+
position: sticky; top: calc(${Et} + var(--bimrd-bar-h));
|
|
466
|
+
width: 264px; height: calc(100vh - ${Et} - var(--bimrd-bar-h));
|
|
467
467
|
overflow-y: auto; overscroll-behavior: contain;
|
|
468
468
|
padding: 0 16px 40px;
|
|
469
469
|
/* 比目录栏(灰)暖一档:纸色里调入一点暖黄,与页面同色系又能分出层次 */
|
|
@@ -523,7 +523,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
523
523
|
}
|
|
524
524
|
|
|
525
525
|
/* ── 窄屏:书影收起,只留正文 ── */
|
|
526
|
-
@media ${
|
|
526
|
+
@media ${yi} {
|
|
527
527
|
.bim-rd-bar { padding: 0 12px; gap: 10px; }
|
|
528
528
|
.bim-rd-ttl span, .bim-rd-hide-narrow { display: none !important; }
|
|
529
529
|
/* 工具条放不下时(版本、自然段、标出作品链接都在)在条内左右滑,不撑宽页面 */
|
|
@@ -699,7 +699,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
699
699
|
}
|
|
700
700
|
|
|
701
701
|
/* ── 手机:正文两侧不留白(放在对读、界栏规则之后才压得过它们) ── */
|
|
702
|
-
@media ${
|
|
702
|
+
@media ${yi} {
|
|
703
703
|
.bim-rd-text, .bim-rd[data-warp="true"] .bim-rd-text { padding-left: 0; padding-right: 0; }
|
|
704
704
|
.bim-rd-col, :root[data-layout="boxed"] .bim-rd-col { padding-left: 14px; padding-right: 14px; }
|
|
705
705
|
:root[data-layout="boxed"] .bim-rd-col { border-left: 0; border-right: 0; }
|
|
@@ -710,13 +710,13 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
710
710
|
.guji-page-indicator { opacity: 0.55; transition: opacity 0.15s; outline: none; }
|
|
711
711
|
.guji-page-indicator:hover, .guji-page-indicator:focus-visible { opacity: 1; }
|
|
712
712
|
.guji-page-indicator:focus-visible { outline: 2px solid ${r("accent")}; outline-offset: 1px; border-radius: 3px; }
|
|
713
|
-
@media ${
|
|
714
|
-
`;function No(e,n){var i;return n?e.key===n?!0:!!((i=e.children)!=null&&i.some(o=>No(o,n))):!1}const ua=()=>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 Uh({item:e,activeKey:n,onSelect:i,tabKey:o}){const{t:s}=re(),a=No(e,n),[l,d]=f.useState(a||!!e.defaultExpanded);return f.useEffect(()=>{a&&d(!0)},[a]),f.useEffect(()=>{e.defaultExpanded&&d(!0)},[e.defaultExpanded]),e.selectable?t.jsxs("li",{children:[t.jsxs("div",{className:"bim-rd-ti-row",children:[t.jsx("button",{type:"button",className:"bim-rd-ti-tw","aria-expanded":l,"aria-label":s(l?"reader.tocCollapse":"reader.tocExpand"),tabIndex:-1,onClick:()=>d(c=>!c),children:t.jsx(ua,{})}),t.jsxs("button",{type:"button",className:`bim-rd-ti${e.inChapter?"":" bim-rd-ti-group"}`,"aria-current":e.key===n?"true":void 0,disabled:e.disabled,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>{d(!0),i(e.key)},onKeyDown:c=>{c.key==="ArrowRight"&&!l?(c.preventDefault(),d(!0)):c.key==="ArrowLeft"&&l&&(c.preventDefault(),d(!1))},children:[t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]})]}),l&&t.jsx(Wr,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]}):t.jsxs("li",{children:[t.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":l,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>d(c=>!c),children:[t.jsx(ua,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),l&&t.jsx(Wr,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]})}function Wr({items:e,activeKey:n,onSelect:i,tabKey:o}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(Uh,{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 ma(e,n){var i;for(const o of e)if(o.key===n||No(o,n))return o.key;return((i=e[0])==null?void 0:i.key)??null}function yc({items:e,activeKey:n,onSelect:i,label:o}){const{t:s}=re(),a=o??s("reader.toc"),l=f.useRef(null),[d,c]=f.useState(null);f.useEffect(()=>{c(null)},[n]);const p=f.useMemo(()=>d||(n??ma(e,n)),[d,n,e]);f.useEffect(()=>{const m=l.current;if(!m)return;const u=Array.from(m.querySelectorAll("[data-rd-toc-key]"));if(u.length===0)return;const g=u.find(x=>x.dataset.rdTocKey===p)??u.find(x=>x.dataset.rdTocKey===ma(e,n))??u.find(x=>!x.disabled)??u[0];for(const x of u)x.tabIndex=x===g?0:-1}),f.useEffect(()=>{const m=l.current,u=m==null?void 0:m.closest(".bim-rd-toc");if(!m||!u||!n)return;const g=Array.from(m.querySelectorAll("[data-rd-toc-key]")).find(j=>j.dataset.rdTocKey===n);if(!g)return;const x=g.getBoundingClientRect().top-u.getBoundingClientRect().top+u.scrollTop;(x<u.scrollTop+80||x>u.scrollTop+u.clientHeight-40)&&(u.scrollTop=Math.max(0,x-u.clientHeight/3))},[n]);const h=f.useCallback(m=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(m.key))return;const g=l.current;if(!g)return;const x=Array.from(g.querySelectorAll("[data-rd-toc-key]")).filter(b=>!b.disabled),j=x.indexOf(document.activeElement);let y=j;if(m.key==="ArrowDown"?y=Math.min(x.length-1,j+1):m.key==="ArrowUp"?y=Math.max(0,j-1):m.key==="Home"?y=0:m.key==="End"&&(y=x.length-1),y<0||y===j)return;m.preventDefault();const S=x[y];for(const b of x)b.tabIndex=-1;S.tabIndex=0,S.focus(),c(S.dataset.rdTocKey??null)},[]);return t.jsx("div",{ref:l,role:"navigation","aria-label":a,onKeyDown:h,children:t.jsx(Wr,{items:e,activeKey:n,onSelect:i,tabKey:p})})}function ha({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 Vh(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 g of n)[g.x,g.y,g.w,g.h].every(Number.isFinite)&&(s=Math.min(s,g.x),a=Math.min(a,g.y),l=Math.max(l,g.x+g.w),d=Math.max(d,g.y+g.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)),m=Math.min(i,Math.max(0,l+c))-p,u=Math.min(o,Math.max(0,d+c))-h;return!(m>0)||!(u>0)||m>=i*.98&&u>=o*.98?null:{x:p,y:h,w:m,h:u}}function Fr({pages:e,loading:n,page:i,onPageChange:o,renderOverlay:s,preserveMargins:a=!0}){const{t:l}=re(),[d,c]=f.useState(0),p=i??d,h=j=>{o?o(j):c(j)};if(f.useEffect(()=>{i===void 0&&c(0)},[e,i]),n)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsx("div",{className:"bim-rd-img-empty",children:l("reader.imagesLoading")})});if(!e||e.length===0)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsxs("div",{className:"bim-rd-img-empty",children:[t.jsx("div",{className:"bim-rd-img-frame","aria-hidden":"true"}),t.jsx("b",{children:l("reader.noImages")}),t.jsx("span",{children:l("reader.noImagesHint")})]})});const m=Math.max(0,Math.min(e.length-1,p)),u=e[m],g=u.label??`${m+1}`,x=!a&&!s?Vh(u):null;return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-img-box",children:x?t.jsxs("figure",{className:"bim-rd-img-fig bim-rd-img-trimmed","data-trim":`${Math.round(x.x)},${Math.round(x.y)},${Math.round(x.w)},${Math.round(x.h)}`,style:{aspectRatio:`${x.w} / ${x.h}`,overflow:"hidden",width:"100%",maxWidth:`calc((100vh - 200px) * ${x.w/x.h})`},children:[t.jsx("img",{src:u.url,alt:u.alt??l("reader.imageAlt",{label:g}),decoding:"async",style:{position:"absolute",maxWidth:"none",maxHeight:"none",width:`${u.width/x.w*100}%`,left:`${-x.x/x.w*100}%`,top:`${-x.y/x.h*100}%`}}),t.jsx(ha,{page:u,crop:x})]}):t.jsxs("figure",{className:"bim-rd-img-fig",children:[t.jsx("img",{src:u.url,alt:u.alt??l("reader.imageAlt",{label:g}),width:u.width,height:u.height,loading:"lazy",decoding:"async"}),t.jsx(ha,{page:u}),s==null?void 0:s(u,m)]})}),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:m===0,onClick:()=>h(m-1),children:"‹"}),t.jsx("span",{"aria-live":"polite",children:u.label??`${m+1} / ${e.length}`}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.nextImage"),disabled:m===e.length-1,onClick:()=>h(m+1),children:"›"})]})]})}function Gh(e){return e==="lite"||e==="full"}const Yn=[.1,.9],jc=[{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 Yh(e){var n;return((n=jc.find(i=>i.key===e))==null?void 0:n.stack)??null}const To={fontSize:null,readingMode:"line",properNameMode:null,writingMode:"horizontal",workLinks:!0,fontFamily:"song",pageBreaks:!1,pageIndicatorY:.33,bookTitleStyle:"bracket",showWorks:!0,quoteStyle:"original",scriptMode:null,preserveMargins:!0},Ot=[15,16,17,18,20,22,24],Hr=18,vc="bim-reader-prefs",kc=2,qh="bim-reading-mode";function Kh(){const e={...To};try{const n=localStorage.getItem(vc),i=n?JSON.parse(n):{};typeof i.fontSize=="number"&&Ot.includes(i.fontSize)&&(e.fontSize=i.fontSize),(i.readingMode??localStorage.getItem(qh))==="paragraph"&&(e.readingMode="paragraph"),i.properNameMode==="off"||i.properNameMode==="lite"||i.properNameMode==="full"?e.properNameMode=i.properNameMode:i.properNames===!0?e.properNameMode="full":i.properNames===!1&&(e.properNameMode="off"),i.writingMode==="vertical"&&(e.writingMode="vertical"),i.workLinks===!1&&(e.workLinks=!1),(i.fontFamily==="kai"||i.fontFamily==="system")&&(e.fontFamily=i.fontFamily);const s=i.v===kc;s&&typeof i.pageBreaks=="boolean"&&(e.pageBreaks=i.pageBreaks),typeof i.pageIndicatorY=="number"&&Number.isFinite(i.pageIndicatorY)&&i.pageIndicatorY>=Yn[0]&&i.pageIndicatorY<=Yn[1]&&(e.pageIndicatorY=i.pageIndicatorY),s&&(i.bookTitleStyle==="wavy"||i.bookTitleStyle==="bracket")&&(e.bookTitleStyle=i.bookTitleStyle),i.showWorks===!1&&(e.showWorks=!1),(i.quoteStyle==="modern"||i.quoteStyle==="classic")&&(e.quoteStyle=i.quoteStyle),(i.scriptMode==="orig"||i.scriptMode==="hant"||i.scriptMode==="hans")&&(e.scriptMode=i.scriptMode),i.preserveMargins===!1&&(e.preserveMargins=!1)}catch{}return e}function Xh(e){try{localStorage.setItem(vc,JSON.stringify({...e,v:kc}))}catch{}}function mi(e,n){const i=e??Hr,o=Ot;let s=o.indexOf(i);return s<0&&(s=o.indexOf(Hr)),o[Math.max(0,Math.min(o.length-1,s+n))]}function wc(){const[e,n]=f.useState(To);f.useEffect(()=>{n(Kh())},[]);const i=f.useCallback(o=>{n(s=>{const a={...s,...o};return Xh(a),a})},[]);return[e,i]}function Dr(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 Sc(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 _c(e){const n=[],i=o=>{for(const s of o){if(s.inChapter)continue;const a=!!s.children&&s.children.length>0;(!a||s.selectable)&&n.push(s),a&&i(s.children)}};return i(e),n}const fa=()=>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"})}),Zh=()=>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"})}),Jh=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M9 5l7 7-7 7"})}),ga=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M4 7h10M18 7h2M4 17h2M10 17h10"}),t.jsx("circle",{cx:"16",cy:"7",r:"2"}),t.jsx("circle",{cx:"8",cy:"17",r:"2"})]}),xa=()=>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 ba(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 ya(e,n){const[i,o]=f.useState(n);return f.useEffect(()=>{var l;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(e);o(s.matches);const a=()=>o(s.matches);return(l=s.addEventListener)==null||l.call(s,"change",a),()=>{var d;return(d=s.removeEventListener)==null?void 0:d.call(s,"change",a)}},[e]),i}function Qh({prefs:e,onPrefsChange:n,origAvailable:i}){const o=f.useContext(Lt),{t:s}=re();if(!o)return null;const a=o.locale==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a,d=[{key:"orig",short:s("reader.scriptOrigShort"),title:s(i?"reader.scriptOrig":"reader.scriptOrigUnavailable"),disabled:!i},{key:"hant",short:s("common.localeShortHant"),title:s("reader.scriptHant")},{key:"hans",short:s("common.localeShortHans"),title:s("reader.scriptHans")}];return t.jsx("span",{className:"bim-rd-script-sw",role:"group","aria-label":s("reader.scriptQuick"),children:d.map((c,p)=>t.jsxs(f.Fragment,{children:[p>0&&t.jsx("span",{className:"bim-rd-off","aria-hidden":"true",children:"|"}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":l===c.key,title:c.title,"aria-label":c.title,disabled:c.disabled,onClick:()=>{c.disabled||(n({scriptMode:c.key}),c.key==="hant"?o.setLocale("zh-Hant"):c.key==="hans"&&o.setLocale("zh-Hans"))},children:c.short})]},c.key))})}function yi({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 ef({prefs:e,onPrefsChange:n,origAvailable:i}){const o=f.useContext(Lt),{t:s}=re(),a=(o==null?void 0:o.locale)==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a;return t.jsx(yi,{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 tf(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 nf(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 $c({title:e,subtitle:n,toc:i,activeKey:o,tocActiveKey:s,onSelect:a,tocHeader:l,tocCaption:d,images:c,imagesLoading:p,renderImageOverlay:h,imagePanel:m="auto",prefs:u,onPrefsChange:g,paragraphToggle:x,properNameToggle:j=!0,allowVertical:y,origScriptAvailable:S=!0,byline:b,current:w,workLinkToggle:v,rail:k,onReportError:z,revisedAt:C,backHref:_,backLabel:R,bottomBar:T=!0,pager:N=!0,contentLoading:E=!1,pagerUnit:W,versions:F,currentVersionKey:A,onVersionChange:V,versionSource:ae=!0,keepChapterOnVersionChange:xe=!1,customImagePanel:me,toolbarExtra:G,settingsAnnotate:ye,settingsLayout:ne,isWarpMode:U,children:Q,className:q,style:je}){const{t:I,convert:oe}=re(),$e=R??I("reader.back"),ve=oe(W??I("reader.unitJuan")),Le=f.useId().replace(/:/g,""),Ne=`bim-rd-toc-${Le}`,X=`bim-rd-text-${Le}`,ue=f.useRef(null),Pe=f.useRef(null),Me=f.useRef(null),ke=f.useRef(null),D=ya(gc,!0),le=ya(xc,!1),ce=T&&le,[Z,we]=f.useState(null),[He,Ge]=f.useState(!1),Xe=f.useRef(null),O=`bim-rd-set-${Le}`,de=f.useRef(null),Te=f.useRef(null),B=(ee,Fe)=>{Te.current=Fe,we(pt=>pt===ee?null:ee)},pe=f.useCallback(()=>{var ee;we(null),(ee=Te.current)==null||ee.focus()},[]);f.useEffect(()=>{ce||we(null)},[ce]),f.useEffect(()=>{var ee,Fe;Z&&((Fe=(ee=de.current)==null?void 0:ee.querySelector("button:not([disabled])"))==null||Fe.focus())},[Z]);const[ie,_e]=f.useState("auto"),Re=ie==="auto"?D:ie==="open",De=!D,Ye=!!me||!!c&&c.length>0,[et,Ze]=f.useState(m);f.useEffect(()=>{Ze(m)},[m]);const $=et==="auto"?Ye||!!p:et==="open",M=f.useCallback(ee=>{var Fe;_e("auto"),ee&&((Fe=ke.current)==null||Fe.focus())},[]),P=()=>_e(Re?"closed":"open");f.useEffect(()=>{if(!De||ie!=="open")return;const ee=Me.current,Fe=ee==null?void 0:ee.querySelector('input, [data-rd-toc-key][tabindex="0"]');Fe==null||Fe.focus()},[De,ie]);const K=f.useCallback(ee=>{a(ee),De&&M(!1);const Fe=Pe.current,pt=ue.current;if(Fe&&pt&&typeof window<"u"){const mt=Fe.getBoundingClientRect().top-pt.getBoundingClientRect().bottom;mt<0&&window.scrollBy({top:mt})}},[a,De,M]),he=f.useMemo(()=>_c(i),[i]),[se,We]=f.useState(null),Be=Sc(F,A!==void 0?A:se),Y=(Be==null?void 0:Be.key)??null,H=f.useMemo(()=>he.map(ee=>ee.key).join(`
|
|
715
|
-
`),[he]),fe=f.useRef(null),Ce=ee=>{ee!==Y&&(xe||(fe.current={key:ee,sig:H,done:!1}),A===void 0&&We(ee),V==null||V(ee))};f.useEffect(()=>{const ee=fe.current;if(!ee||ee.key!==Y)return;const Fe=he.find(mt=>!mt.disabled);if(!Fe)return;const pt=H!==ee.sig;!pt&&ee.done||(pt?fe.current=null:ee.done=!0,Fe.key!==o&&K(Fe.key))},[Y,H,he,o,K]);const be=he.find(ee=>ee.key===o),J=()=>{var ee;z==null||z({chapterKey:o,chapterLabel:typeof(be==null?void 0:be.label)=="string"?be.label:void 0,anchor:tf(Pe.current,((ee=ue.current)==null?void 0:ee.getBoundingClientRect().bottom)??0),selectedText:nf(Pe.current)})},Ee=he.findIndex(ee=>ee.key===o),ge=Ee>0?he.slice(0,Ee).reverse().find(ee=>!ee.disabled):void 0,Oe=Ee>=0?he.slice(Ee+1).find(ee=>!ee.disabled):void 0,Se=u.fontSize??Hr,Ue=Yh(u.fontFamily),dt={...je,...u.fontSize?{"--bimrd-fs":`${u.fontSize}px`}:null,...Ue?{"--bimrd-ff":Ue}:null},at={song:I("reader.fontSong"),kai:I("reader.fontKai"),system:I("reader.fontSystem")},Ke=j||!!ye,Je=t.jsxs("div",{className:"bim-rd-sp",children:[t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${O}-g1`,children:[t.jsx("h3",{id:`${O}-g1`,className:"bim-rd-sp-h",children:I("reader.groupText")}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:I("reader.font")}),t.jsx("select",{className:"bim-rd-sp-sel","aria-label":I("reader.font"),value:u.fontFamily,onChange:ee=>g({fontFamily:ee.target.value}),children:jc.map(ee=>t.jsx("option",{value:ee.key,children:at[ee.key]},ee.key))})]}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:I("reader.fontSize")}),t.jsxs("span",{className:"bim-rd-sp-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":I("reader.fontSmaller"),disabled:Se<=Ot[0],onClick:()=>g({fontSize:mi(u.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[Se,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":I("reader.fontLarger"),disabled:Se>=Ot[Ot.length-1],onClick:()=>g({fontSize:mi(u.fontSize,1)}),children:"A+"})]})]}),t.jsx(ef,{prefs:u,onPrefsChange:g,origAvailable:S}),t.jsx(yi,{label:I("reader.quoteStyle"),value:u.quoteStyle,options:[{key:"modern",label:I("reader.quoteModern")},{key:"classic",label:I("reader.quoteClassic")},{key:"original",label:I("reader.quoteOriginal")}],onPick:ee=>g({quoteStyle:ee})})]}),Ke&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${O}-g2`,children:[t.jsx("h3",{id:`${O}-g2`,className:"bim-rd-sp-h",children:I("reader.groupMark")}),j&&t.jsxs(t.Fragment,{children:[t.jsx(yi,{label:I("reader.properName"),value:u.properNameMode,title:I("reader.properNameTitle"),options:[{key:"off",label:I("reader.properNameOff")},{key:"lite",label:I("reader.properNameLite"),title:I("reader.properNameLiteTitle")},{key:"full",label:I("reader.properNameFull")}],onPick:ee=>g({properNameMode:ee})}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.showWorks,onChange:ee=>g({showWorks:ee.target.checked})}),t.jsx("span",{children:I("reader.showWorks")})]}),t.jsx(yi,{label:I("reader.bookTitleStyle"),value:u.bookTitleStyle,options:[{key:"wavy",label:I("reader.bookTitleWavy")},{key:"bracket",label:I("reader.bookTitleBracket")}],onPick:ee=>g({bookTitleStyle:ee})})]}),ye]}),t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${O}-g3`,children:[t.jsx("h3",{id:`${O}-g3`,className:"bim-rd-sp-h",children:I("reader.groupLayout")}),x&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.readingMode==="paragraph",title:I("reader.paragraphTitle"),onClick:()=>g({readingMode:u.readingMode==="paragraph"?"line":"paragraph"}),children:I("reader.paragraph")}),v&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.workLinks,onChange:ee=>g({workLinks:ee.target.checked})}),t.jsx("span",{children:I("reader.workLinks")})]}),y&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.writingMode==="vertical",onClick:()=>g({writingMode:u.writingMode==="vertical"?"horizontal":"vertical"}),children:I("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:ee=>g({pageBreaks:ee.target.checked})}),t.jsx("span",{children:I("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:ee=>g({preserveMargins:ee.target.checked})}),t.jsx("span",{children:I("reader.preserveMargins")})]}),ne]})]});return t.jsxs("div",{className:["bim-rd",u.writingMode==="vertical"&&y?"bim-rd-vertical":"",q].filter(Boolean).join(" "),"data-toc":ie,"data-img":$?"open":"closed","data-bb":ce?"":void 0,"data-set":!ce&&He?"open":void 0,"data-warp":U?"true":void 0,style:dt,children:[t.jsx("style",{children:bc}),t.jsx("a",{className:"bim-rd-skip",href:`#${X}`,onClick:ee=>{var Fe,pt,mt;ee.preventDefault(),(Fe=Pe.current)==null||Fe.focus(),(mt=(pt=Pe.current)==null?void 0:pt.scrollIntoView)==null||mt.call(pt,{block:"start"})},children:I("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:ue,children:[_&&t.jsxs("a",{className:"bim-rd-back",href:_,"aria-label":I("reader.backAria",{label:$e}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:$e})]}),(e||n||b||w)&&t.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[e&&t.jsx("b",{children:e}),b&&t.jsx("span",{className:"bim-rd-by",children:b}),w&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-rd-cur",children:w})]}),n&&t.jsx("span",{className:"bim-rd-ttl-src",children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":I("reader.settings"),children:[F&&F.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:Be?oe(Dr(Be)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:I("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:I("reader.versionShort")}),t.jsx("select",{"aria-label":I("reader.version"),value:Y??"",onChange:ee=>Ce(ee.target.value),children:F.map(ee=>t.jsx("option",{value:ee.key,children:oe(Dr(ee))},ee.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),N&&(ge||Oe)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":I("reader.pagerGroup",{unit:ve}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":I("reader.prevUnit",{unit:ve}),title:ge?typeof ge.label=="string"&&ge.label?I("reader.prevUnitTitle",{unit:ve,label:ge.label}):I("reader.prevUnit",{unit:ve}):I("reader.firstUnit",{unit:ve}),disabled:!ge,onClick:()=>ge&&K(ge.key),children:t.jsx(Zh,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":I("reader.nextUnit",{unit:ve}),title:Oe?typeof Oe.label=="string"&&Oe.label?I("reader.nextUnitTitle",{unit:ve,label:Oe.label}):I("reader.nextUnit",{unit:ve}):I("reader.lastUnit",{unit:ve}),disabled:!Oe,onClick:()=>Oe&&K(Oe.key),children:t.jsx(Jh,{})})]}),N&&(ge||Oe)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:ke,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":Re,"aria-controls":Ne,onClick:P,children:[t.jsx(fa,{}),t.jsx("span",{className:"bim-rd-tlabel",children:I("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":$,onClick:()=>Ze($?"closed":"open"),children:[t.jsx(xa,{}),I("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(Qh,{prefs:u,onPrefsChange:g,origAvailable:S}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":I("reader.fontSmaller"),disabled:Se<=Ot[0],onClick:()=>g({fontSize:mi(u.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":I("reader.fontLarger"),disabled:Se>=Ot[Ot.length-1],onClick:()=>g({fontSize:mi(u.fontSize,1)}),children:"A+"}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsxs("button",{ref:Xe,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":He,"aria-controls":O,onClick:()=>Ge(ee=>!ee),children:[t.jsx(ga,{}),t.jsx("span",{className:"bim-rd-tlabel",children:I("reader.settings")})]}),G]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:Ne,ref:Me,role:De&&Re?"dialog":void 0,"aria-modal":De&&Re?!0:void 0,"aria-label":De&&Re?I("reader.toc"):void 0,onKeyDown:ee=>{if(!(!De||!Re)){if(ee.key==="Escape"){ee.stopPropagation(),M(!0);return}ee.key==="Tab"&&ba(ee,Me.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:d??I("reader.toc")}),De&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":I("reader.closeToc"),onClick:()=>M(!0),children:"✕"})]}),l]}),t.jsx(yc,{items:i,activeKey:s!==void 0?s:o,onSelect:K})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>M(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":I("reader.images"),children:$&&(me||t.jsx(Fr,{pages:c??null,loading:p,renderOverlay:h,preserveMargins:u.preserveMargins}))}),!ce&&He&&t.jsxs("aside",{className:"bim-rd-set",id:O,"aria-label":I("reader.settings"),onKeyDown:ee=>{var Fe;ee.key==="Escape"&&(ee.stopPropagation(),Ge(!1),(Fe=Xe.current)==null||Fe.focus())},children:[t.jsxs("div",{className:"bim-rd-sp-top",children:[t.jsx("span",{children:I("reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":I("reader.closeSettings"),onClick:()=>{var ee;Ge(!1),(ee=Xe.current)==null||ee.focus()},children:"✕"})]}),Je]}),t.jsxs("div",{className:"bim-rd-text",id:X,ref:Pe,tabIndex:-1,"data-rail":(k||z)&&!U?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[Q,ae&&Be&&(Be.sourceName||Be.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":Be.key,children:[Be.sourceName&&t.jsxs(t.Fragment,{children:[I("reader.sourceLabel")," ",Be.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:Be.sourceUrl,target:"_blank",rel:"noreferrer",children:oe(Be.sourceName)}):oe(Be.sourceName)]}),Be.sourceName&&Be.license&&t.jsx("span",{className:"bim-rd-dot"}),Be.license&&t.jsx(t.Fragment,{children:I("reader.licenseOf",{license:Be.license})})]}),C&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:I("reader.revisedAt",{date:C})}),z&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:ee=>ee.preventDefault(),onClick:J,children:I("reader.reportError")})}),N&&!E&&(ge||Oe)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":I("reader.pagerNav"),children:[ge?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>K(ge.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),I("reader.prevUnit",{unit:ve})]}),t.jsx("span",{className:"bim-rd-pglabel",children:ge.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",I("reader.firstUnit",{unit:ve})]}),Oe?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>K(Oe.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[I("reader.nextUnit",{unit:ve}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:Oe.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[I("reader.lastUnit",{unit:ve})," →"]})]})]}),(k||z)&&!U&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":I("reader.rail"),children:[k,z&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:ee=>ee.preventDefault(),onClick:J,children:I("reader.reportError")})})]})]})]}),ce&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":I("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":Re,"aria-controls":Ne,onClick:()=>{we(null),P()},children:[t.jsx(fa,{}),t.jsx("span",{children:I("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":Z==="img","aria-haspopup":"dialog",onClick:ee=>B("img",ee.currentTarget),children:[t.jsx(xa,{}),t.jsx("span",{children:I("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":Z==="set","aria-haspopup":"dialog",onClick:ee=>B("set",ee.currentTarget),children:[t.jsx(ga,{}),t.jsx("span",{children:I("reader.settingsShort")})]}),z&&t.jsxs("button",{type:"button",onMouseDown:ee=>ee.preventDefault(),onClick:()=>{we(null),J()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:I("reader.reportError")})]})]}),ce&&Z&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:pe}),t.jsxs("div",{className:"bim-rd-sheet",ref:de,role:"dialog","aria-modal":"true","aria-label":I(Z==="img"?"reader.images":"reader.settings"),onKeyDown:ee=>{if(ee.key==="Escape"){ee.stopPropagation(),pe();return}ee.key==="Tab"&&ba(ee,de.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:I(Z==="img"?"reader.images":"reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":I("reader.close"),onClick:pe,children:"✕"})]}),Z==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(Fr,{pages:c??null,loading:p,renderOverlay:h,preserveMargins:u.preserveMargins})}):Je]})]})]})}function rf(e,n,i){return i?Cc(e).includes("\r")?"lone-cr":Array.from(e).length!==Array.from(n).length?"convert-length":n.includes(":::")?"tables":null:"quoteStyle"}function Cc(e){return e.replace(/\r\n/g,`
|
|
713
|
+
@media ${yi} { .guji-page-indicator { display: none; } }
|
|
714
|
+
`;function To(e,n){var i;return n?e.key===n?!0:!!((i=e.children)!=null&&i.some(o=>To(o,n))):!1}const ua=()=>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 Uh({item:e,activeKey:n,onSelect:i,tabKey:o}){const{t:s}=re(),a=To(e,n),[l,d]=f.useState(a||!!e.defaultExpanded);return f.useEffect(()=>{a&&d(!0)},[a]),f.useEffect(()=>{e.defaultExpanded&&d(!0)},[e.defaultExpanded]),e.selectable?t.jsxs("li",{children:[t.jsxs("div",{className:"bim-rd-ti-row",children:[t.jsx("button",{type:"button",className:"bim-rd-ti-tw","aria-expanded":l,"aria-label":s(l?"reader.tocCollapse":"reader.tocExpand"),tabIndex:-1,onClick:()=>d(c=>!c),children:t.jsx(ua,{})}),t.jsxs("button",{type:"button",className:`bim-rd-ti${e.inChapter?"":" bim-rd-ti-group"}`,"aria-current":e.key===n?"true":void 0,disabled:e.disabled,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>{d(!0),i(e.key)},onKeyDown:c=>{c.key==="ArrowRight"&&!l?(c.preventDefault(),d(!0)):c.key==="ArrowLeft"&&l&&(c.preventDefault(),d(!1))},children:[t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]})]}),l&&t.jsx(Fr,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]}):t.jsxs("li",{children:[t.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":l,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>d(c=>!c),children:[t.jsx(ua,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),l&&t.jsx(Fr,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]})}function Fr({items:e,activeKey:n,onSelect:i,tabKey:o}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(Uh,{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 ma(e,n){var i;for(const o of e)if(o.key===n||To(o,n))return o.key;return((i=e[0])==null?void 0:i.key)??null}function yc({items:e,activeKey:n,onSelect:i,label:o}){const{t:s}=re(),a=o??s("reader.toc"),l=f.useRef(null),[d,c]=f.useState(null);f.useEffect(()=>{c(null)},[n]);const p=f.useMemo(()=>d||(n??ma(e,n)),[d,n,e]);f.useEffect(()=>{const m=l.current;if(!m)return;const u=Array.from(m.querySelectorAll("[data-rd-toc-key]"));if(u.length===0)return;const g=u.find(x=>x.dataset.rdTocKey===p)??u.find(x=>x.dataset.rdTocKey===ma(e,n))??u.find(x=>!x.disabled)??u[0];for(const x of u)x.tabIndex=x===g?0:-1}),f.useEffect(()=>{const m=l.current,u=m==null?void 0:m.closest(".bim-rd-toc");if(!m||!u||!n)return;const g=Array.from(m.querySelectorAll("[data-rd-toc-key]")).find(j=>j.dataset.rdTocKey===n);if(!g)return;const x=g.getBoundingClientRect().top-u.getBoundingClientRect().top+u.scrollTop;(x<u.scrollTop+80||x>u.scrollTop+u.clientHeight-40)&&(u.scrollTop=Math.max(0,x-u.clientHeight/3))},[n]);const h=f.useCallback(m=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(m.key))return;const g=l.current;if(!g)return;const x=Array.from(g.querySelectorAll("[data-rd-toc-key]")).filter(b=>!b.disabled),j=x.indexOf(document.activeElement);let y=j;if(m.key==="ArrowDown"?y=Math.min(x.length-1,j+1):m.key==="ArrowUp"?y=Math.max(0,j-1):m.key==="Home"?y=0:m.key==="End"&&(y=x.length-1),y<0||y===j)return;m.preventDefault();const S=x[y];for(const b of x)b.tabIndex=-1;S.tabIndex=0,S.focus(),c(S.dataset.rdTocKey??null)},[]);return t.jsx("div",{ref:l,role:"navigation","aria-label":a,onKeyDown:h,children:t.jsx(Fr,{items:e,activeKey:n,onSelect:i,tabKey:p})})}function ha({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 Vh(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 g of n)[g.x,g.y,g.w,g.h].every(Number.isFinite)&&(s=Math.min(s,g.x),a=Math.min(a,g.y),l=Math.max(l,g.x+g.w),d=Math.max(d,g.y+g.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)),m=Math.min(i,Math.max(0,l+c))-p,u=Math.min(o,Math.max(0,d+c))-h;return!(m>0)||!(u>0)||m>=i*.98&&u>=o*.98?null:{x:p,y:h,w:m,h:u}}function Hr({pages:e,loading:n,page:i,onPageChange:o,renderOverlay:s,preserveMargins:a=!0}){const{t:l}=re(),[d,c]=f.useState(0),p=i??d,h=j=>{o?o(j):c(j)};if(f.useEffect(()=>{i===void 0&&c(0)},[e,i]),n)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsx("div",{className:"bim-rd-img-empty",children:l("reader.imagesLoading")})});if(!e||e.length===0)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsxs("div",{className:"bim-rd-img-empty",children:[t.jsx("div",{className:"bim-rd-img-frame","aria-hidden":"true"}),t.jsx("b",{children:l("reader.noImages")}),t.jsx("span",{children:l("reader.noImagesHint")})]})});const m=Math.max(0,Math.min(e.length-1,p)),u=e[m],g=u.label??`${m+1}`,x=!a&&!s?Vh(u):null;return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-img-box",children:x?t.jsxs("figure",{className:"bim-rd-img-fig bim-rd-img-trimmed","data-trim":`${Math.round(x.x)},${Math.round(x.y)},${Math.round(x.w)},${Math.round(x.h)}`,style:{aspectRatio:`${x.w} / ${x.h}`,overflow:"hidden",width:"100%",maxWidth:`calc((100vh - 200px) * ${x.w/x.h})`},children:[t.jsx("img",{src:u.url,alt:u.alt??l("reader.imageAlt",{label:g}),decoding:"async",style:{position:"absolute",maxWidth:"none",maxHeight:"none",width:`${u.width/x.w*100}%`,left:`${-x.x/x.w*100}%`,top:`${-x.y/x.h*100}%`}}),t.jsx(ha,{page:u,crop:x})]}):t.jsxs("figure",{className:"bim-rd-img-fig",children:[t.jsx("img",{src:u.url,alt:u.alt??l("reader.imageAlt",{label:g}),width:u.width,height:u.height,loading:"lazy",decoding:"async"}),t.jsx(ha,{page:u}),s==null?void 0:s(u,m)]})}),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:m===0,onClick:()=>h(m-1),children:"‹"}),t.jsx("span",{"aria-live":"polite",children:u.label??`${m+1} / ${e.length}`}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.nextImage"),disabled:m===e.length-1,onClick:()=>h(m+1),children:"›"})]})]})}function Gh(e){return e==="lite"||e==="full"}const qn=[.1,.9],jc=[{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 Yh(e){var n;return((n=jc.find(i=>i.key===e))==null?void 0:n.stack)??null}const Io={fontSize:null,readingMode:"line",properNameMode:null,writingMode:"horizontal",workLinks:!0,fontFamily:"song",pageBreaks:!1,pageIndicatorY:.33,bookTitleStyle:"bracket",showWorks:!0,quoteStyle:"original",scriptMode:null,preserveMargins:!0},Ht=[15,16,17,18,20,22,24],Dr=18,vc="bim-reader-prefs",kc=2,qh="bim-reading-mode";function Kh(){const e={...Io};try{const n=localStorage.getItem(vc),i=n?JSON.parse(n):{};typeof i.fontSize=="number"&&Ht.includes(i.fontSize)&&(e.fontSize=i.fontSize),(i.readingMode??localStorage.getItem(qh))==="paragraph"&&(e.readingMode="paragraph"),i.properNameMode==="off"||i.properNameMode==="lite"||i.properNameMode==="full"?e.properNameMode=i.properNameMode:i.properNames===!0?e.properNameMode="full":i.properNames===!1&&(e.properNameMode="off"),i.writingMode==="vertical"&&(e.writingMode="vertical"),i.workLinks===!1&&(e.workLinks=!1),(i.fontFamily==="kai"||i.fontFamily==="system")&&(e.fontFamily=i.fontFamily);const s=i.v===kc;s&&typeof i.pageBreaks=="boolean"&&(e.pageBreaks=i.pageBreaks),typeof i.pageIndicatorY=="number"&&Number.isFinite(i.pageIndicatorY)&&i.pageIndicatorY>=qn[0]&&i.pageIndicatorY<=qn[1]&&(e.pageIndicatorY=i.pageIndicatorY),s&&(i.bookTitleStyle==="wavy"||i.bookTitleStyle==="bracket")&&(e.bookTitleStyle=i.bookTitleStyle),i.showWorks===!1&&(e.showWorks=!1),(i.quoteStyle==="modern"||i.quoteStyle==="classic")&&(e.quoteStyle=i.quoteStyle),(i.scriptMode==="orig"||i.scriptMode==="hant"||i.scriptMode==="hans")&&(e.scriptMode=i.scriptMode),i.preserveMargins===!1&&(e.preserveMargins=!1)}catch{}return e}function Xh(e){try{localStorage.setItem(vc,JSON.stringify({...e,v:kc}))}catch{}}function hi(e,n){const i=e??Dr,o=Ht;let s=o.indexOf(i);return s<0&&(s=o.indexOf(Dr)),o[Math.max(0,Math.min(o.length-1,s+n))]}function wc(){const[e,n]=f.useState(Io);f.useEffect(()=>{n(Kh())},[]);const i=f.useCallback(o=>{n(s=>{const a={...s,...o};return Xh(a),a})},[]);return[e,i]}function Ur(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 Sc(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 _c(e){const n=[],i=o=>{for(const s of o){if(s.inChapter)continue;const a=!!s.children&&s.children.length>0;(!a||s.selectable)&&n.push(s),a&&i(s.children)}};return i(e),n}const fa=()=>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"})}),Zh=()=>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"})}),Jh=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M9 5l7 7-7 7"})}),ga=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M4 7h10M18 7h2M4 17h2M10 17h10"}),t.jsx("circle",{cx:"16",cy:"7",r:"2"}),t.jsx("circle",{cx:"8",cy:"17",r:"2"})]}),xa=()=>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 ba(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 ya(e,n){const[i,o]=f.useState(n);return f.useEffect(()=>{var l;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(e);o(s.matches);const a=()=>o(s.matches);return(l=s.addEventListener)==null||l.call(s,"change",a),()=>{var d;return(d=s.removeEventListener)==null?void 0:d.call(s,"change",a)}},[e]),i}function Qh({prefs:e,onPrefsChange:n,origAvailable:i}){const o=f.useContext(Mt),{t:s}=re();if(!o)return null;const a=o.locale==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a,d=[{key:"orig",short:s("reader.scriptOrigShort"),title:s(i?"reader.scriptOrig":"reader.scriptOrigUnavailable"),disabled:!i},{key:"hant",short:s("common.localeShortHant"),title:s("reader.scriptHant")},{key:"hans",short:s("common.localeShortHans"),title:s("reader.scriptHans")}];return t.jsx("span",{className:"bim-rd-script-sw",role:"group","aria-label":s("reader.scriptQuick"),children:d.map((c,p)=>t.jsxs(f.Fragment,{children:[p>0&&t.jsx("span",{className:"bim-rd-off","aria-hidden":"true",children:"|"}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":l===c.key,title:c.title,"aria-label":c.title,disabled:c.disabled,onClick:()=>{c.disabled||(n({scriptMode:c.key}),c.key==="hant"?o.setLocale("zh-Hant"):c.key==="hans"&&o.setLocale("zh-Hans"))},children:c.short})]},c.key))})}function ji({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 ef({prefs:e,onPrefsChange:n,origAvailable:i}){const o=f.useContext(Mt),{t:s}=re(),a=(o==null?void 0:o.locale)==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a;return t.jsx(ji,{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 tf(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 nf(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 $c({title:e,subtitle:n,toc:i,activeKey:o,tocActiveKey:s,onSelect:a,tocHeader:l,tocCaption:d,images:c,imagesLoading:p,renderImageOverlay:h,imagePanel:m="auto",prefs:u,onPrefsChange:g,paragraphToggle:x,properNameToggle:j=!0,allowVertical:y,origScriptAvailable:S=!0,byline:b,current:w,workLinkToggle:v,rail:k,onReportError:z,revisedAt:C,backHref:_,backLabel:R,bottomBar:T=!0,pager:N=!0,contentLoading:E=!1,pagerUnit:W,versions:F,currentVersionKey:A,onVersionChange:V,versionSource:ae=!0,keepChapterOnVersionChange:xe=!1,customImagePanel:me,toolbarExtra:G,settingsAnnotate:ye,settingsLayout:ne,isWarpMode:U,children:ee,className:q,style:je}){const{t:I,convert:oe}=re(),$e=R??I("reader.back"),ve=oe(W??I("reader.unitJuan")),Le=f.useId().replace(/:/g,""),Te=`bim-rd-toc-${Le}`,Z=`bim-rd-text-${Le}`,ue=f.useRef(null),Pe=f.useRef(null),Me=f.useRef(null),ke=f.useRef(null),D=ya(gc,!0),le=ya(xc,!1),ce=T&&le,[J,we]=f.useState(null),[Fe,Ve]=f.useState(!1),Ze=f.useRef(null),O=`bim-rd-set-${Le}`,de=f.useRef(null),Ie=f.useRef(null),B=(K,Ge)=>{Ie.current=Ge,we(nt=>nt===K?null:K)},pe=f.useCallback(()=>{var K;we(null),(K=Ie.current)==null||K.focus()},[]);f.useEffect(()=>{ce||we(null)},[ce]),f.useEffect(()=>{var K,Ge;J&&((Ge=(K=de.current)==null?void 0:K.querySelector("button:not([disabled])"))==null||Ge.focus())},[J]);const[ie,_e]=f.useState("auto"),Re=ie==="auto"?D:ie==="open",He=!D,Ye=!!me||!!c&&c.length>0,[tt,Qe]=f.useState(m);f.useEffect(()=>{Qe(m)},[m]);const $=tt==="auto"?Ye||!!p:tt==="open",M=f.useCallback(K=>{var Ge;_e("auto"),K&&((Ge=ke.current)==null||Ge.focus())},[]),P=()=>_e(Re?"closed":"open");f.useEffect(()=>{if(!He||ie!=="open")return;const K=Me.current,Ge=K==null?void 0:K.querySelector('input, [data-rd-toc-key][tabindex="0"]');Ge==null||Ge.focus()},[He,ie]);const X=f.useCallback(K=>{a(K),He&&M(!1);const Ge=Pe.current,nt=ue.current;if(Ge&&nt&&typeof window<"u"){const _t=Ge.getBoundingClientRect().top-nt.getBoundingClientRect().bottom;_t<0&&window.scrollBy({top:_t})}},[a,He,M]),he=f.useMemo(()=>_c(i),[i]),[se,We]=f.useState(null),Be=Sc(F,A!==void 0?A:se),Y=(Be==null?void 0:Be.key)??null,H=f.useMemo(()=>he.map(K=>K.key).join(`
|
|
715
|
+
`),[he]),fe=f.useRef(null),Ce=K=>{K!==Y&&(xe||(fe.current={key:K,sig:H,done:!1}),A===void 0&&We(K),V==null||V(K))};f.useEffect(()=>{const K=fe.current;if(!K||K.key!==Y)return;const Ge=he.find(_t=>!_t.disabled);if(!Ge)return;const nt=H!==K.sig;!nt&&K.done||(nt?fe.current=null:K.done=!0,Ge.key!==o&&X(Ge.key))},[Y,H,he,o,X]);const be=he.find(K=>K.key===o),Q=()=>{var K;z==null||z({chapterKey:o,chapterLabel:typeof(be==null?void 0:be.label)=="string"?be.label:void 0,anchor:tf(Pe.current,((K=ue.current)==null?void 0:K.getBoundingClientRect().bottom)??0),selectedText:nf(Pe.current)})},Ee=he.findIndex(K=>K.key===o),ge=Ee>0?he.slice(0,Ee).reverse().find(K=>!K.disabled):void 0,Oe=Ee>=0?he.slice(Ee+1).find(K=>!K.disabled):void 0,Se=u.fontSize??Dr,De=Yh(u.fontFamily),pt={...je,...u.fontSize?{"--bimrd-fs":`${u.fontSize}px`}:null,...De?{"--bimrd-ff":De}:null},lt={song:I("reader.fontSong"),kai:I("reader.fontKai"),system:I("reader.fontSystem")},Ke=j||!!ye,et=t.jsxs("div",{className:"bim-rd-sp",children:[t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${O}-g1`,children:[t.jsx("h3",{id:`${O}-g1`,className:"bim-rd-sp-h",children:I("reader.groupText")}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:I("reader.font")}),t.jsx("select",{className:"bim-rd-sp-sel","aria-label":I("reader.font"),value:u.fontFamily,onChange:K=>g({fontFamily:K.target.value}),children:jc.map(K=>t.jsx("option",{value:K.key,children:lt[K.key]},K.key))})]}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:I("reader.fontSize")}),t.jsxs("span",{className:"bim-rd-sp-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":I("reader.fontSmaller"),disabled:Se<=Ht[0],onClick:()=>g({fontSize:hi(u.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[Se,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":I("reader.fontLarger"),disabled:Se>=Ht[Ht.length-1],onClick:()=>g({fontSize:hi(u.fontSize,1)}),children:"A+"})]})]}),t.jsx(ef,{prefs:u,onPrefsChange:g,origAvailable:S}),t.jsx(ji,{label:I("reader.quoteStyle"),value:u.quoteStyle,options:[{key:"modern",label:I("reader.quoteModern")},{key:"classic",label:I("reader.quoteClassic")},{key:"original",label:I("reader.quoteOriginal")}],onPick:K=>g({quoteStyle:K})})]}),Ke&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${O}-g2`,children:[t.jsx("h3",{id:`${O}-g2`,className:"bim-rd-sp-h",children:I("reader.groupMark")}),j&&t.jsxs(t.Fragment,{children:[t.jsx(ji,{label:I("reader.properName"),value:u.properNameMode,title:I("reader.properNameTitle"),options:[{key:"off",label:I("reader.properNameOff")},{key:"lite",label:I("reader.properNameLite"),title:I("reader.properNameLiteTitle")},{key:"full",label:I("reader.properNameFull")}],onPick:K=>g({properNameMode:K})}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.showWorks,onChange:K=>g({showWorks:K.target.checked})}),t.jsx("span",{children:I("reader.showWorks")})]}),t.jsx(ji,{label:I("reader.bookTitleStyle"),value:u.bookTitleStyle,options:[{key:"wavy",label:I("reader.bookTitleWavy")},{key:"bracket",label:I("reader.bookTitleBracket")}],onPick:K=>g({bookTitleStyle:K})})]}),ye]}),t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${O}-g3`,children:[t.jsx("h3",{id:`${O}-g3`,className:"bim-rd-sp-h",children:I("reader.groupLayout")}),x&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.readingMode==="paragraph",title:I("reader.paragraphTitle"),onClick:()=>g({readingMode:u.readingMode==="paragraph"?"line":"paragraph"}),children:I("reader.paragraph")}),v&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.workLinks,onChange:K=>g({workLinks:K.target.checked})}),t.jsx("span",{children:I("reader.workLinks")})]}),y&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.writingMode==="vertical",onClick:()=>g({writingMode:u.writingMode==="vertical"?"horizontal":"vertical"}),children:I("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:K=>g({pageBreaks:K.target.checked})}),t.jsx("span",{children:I("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:K=>g({preserveMargins:K.target.checked})}),t.jsx("span",{children:I("reader.preserveMargins")})]}),ne]})]}),yt=f.useRef(null);return f.useEffect(()=>{const K=yt.current;if(!K||!$)return;let Ge=0,nt=-1;const _t=()=>{Ge=0;const qt=parseFloat(getComputedStyle(K).top);if(!Number.isFinite(qt))return;const Pt=Math.max(0,Math.round(K.getBoundingClientRect().top-qt));Pt!==nt&&(nt=Pt,K.style.setProperty("--bimrd-img-lead",`${Pt}px`))},Xe=()=>{Ge||(Ge=requestAnimationFrame(_t))};Xe(),window.addEventListener("scroll",Xe,{passive:!0}),window.addEventListener("resize",Xe);const $t=typeof ResizeObserver<"u"?new ResizeObserver(Xe):null;return $t==null||$t.observe(document.body),()=>{window.removeEventListener("scroll",Xe),window.removeEventListener("resize",Xe),$t==null||$t.disconnect(),Ge&&cancelAnimationFrame(Ge),K.style.removeProperty("--bimrd-img-lead")}},[$]),t.jsxs("div",{className:["bim-rd",u.writingMode==="vertical"&&y?"bim-rd-vertical":"",q].filter(Boolean).join(" "),"data-toc":ie,"data-img":$?"open":"closed","data-bb":ce?"":void 0,"data-set":!ce&&Fe?"open":void 0,"data-warp":U?"true":void 0,style:pt,children:[t.jsx("style",{children:bc}),t.jsx("a",{className:"bim-rd-skip",href:`#${Z}`,onClick:K=>{var Ge,nt,_t;K.preventDefault(),(Ge=Pe.current)==null||Ge.focus(),(_t=(nt=Pe.current)==null?void 0:nt.scrollIntoView)==null||_t.call(nt,{block:"start"})},children:I("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:ue,children:[_&&t.jsxs("a",{className:"bim-rd-back",href:_,"aria-label":I("reader.backAria",{label:$e}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:$e})]}),(e||n||b||w)&&t.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[e&&t.jsx("b",{children:e}),b&&t.jsx("span",{className:"bim-rd-by",children:b}),w&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-rd-cur",children:w})]}),n&&t.jsx("span",{className:"bim-rd-ttl-src",children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":I("reader.settings"),children:[F&&F.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:Be?oe(Ur(Be)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:I("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:I("reader.versionShort")}),t.jsx("select",{"aria-label":I("reader.version"),value:Y??"",onChange:K=>Ce(K.target.value),children:F.map(K=>t.jsx("option",{value:K.key,children:oe(Ur(K))},K.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),N&&(ge||Oe)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":I("reader.pagerGroup",{unit:ve}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":I("reader.prevUnit",{unit:ve}),title:ge?typeof ge.label=="string"&&ge.label?I("reader.prevUnitTitle",{unit:ve,label:ge.label}):I("reader.prevUnit",{unit:ve}):I("reader.firstUnit",{unit:ve}),disabled:!ge,onClick:()=>ge&&X(ge.key),children:t.jsx(Zh,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":I("reader.nextUnit",{unit:ve}),title:Oe?typeof Oe.label=="string"&&Oe.label?I("reader.nextUnitTitle",{unit:ve,label:Oe.label}):I("reader.nextUnit",{unit:ve}):I("reader.lastUnit",{unit:ve}),disabled:!Oe,onClick:()=>Oe&&X(Oe.key),children:t.jsx(Jh,{})})]}),N&&(ge||Oe)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:ke,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":Re,"aria-controls":Te,onClick:P,children:[t.jsx(fa,{}),t.jsx("span",{className:"bim-rd-tlabel",children:I("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":$,onClick:()=>Qe($?"closed":"open"),children:[t.jsx(xa,{}),I("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(Qh,{prefs:u,onPrefsChange:g,origAvailable:S}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":I("reader.fontSmaller"),disabled:Se<=Ht[0],onClick:()=>g({fontSize:hi(u.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":I("reader.fontLarger"),disabled:Se>=Ht[Ht.length-1],onClick:()=>g({fontSize:hi(u.fontSize,1)}),children:"A+"}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsxs("button",{ref:Ze,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":Fe,"aria-controls":O,onClick:()=>Ve(K=>!K),children:[t.jsx(ga,{}),t.jsx("span",{className:"bim-rd-tlabel",children:I("reader.settings")})]}),G]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:Te,ref:Me,role:He&&Re?"dialog":void 0,"aria-modal":He&&Re?!0:void 0,"aria-label":He&&Re?I("reader.toc"):void 0,onKeyDown:K=>{if(!(!He||!Re)){if(K.key==="Escape"){K.stopPropagation(),M(!0);return}K.key==="Tab"&&ba(K,Me.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:d??I("reader.toc")}),He&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":I("reader.closeToc"),onClick:()=>M(!0),children:"✕"})]}),l]}),t.jsx(yc,{items:i,activeKey:s!==void 0?s:o,onSelect:X})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>M(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":I("reader.images"),ref:yt,children:$&&(me||t.jsx(Hr,{pages:c??null,loading:p,renderOverlay:h,preserveMargins:u.preserveMargins}))}),!ce&&Fe&&t.jsxs("aside",{className:"bim-rd-set",id:O,"aria-label":I("reader.settings"),onKeyDown:K=>{var Ge;K.key==="Escape"&&(K.stopPropagation(),Ve(!1),(Ge=Ze.current)==null||Ge.focus())},children:[t.jsxs("div",{className:"bim-rd-sp-top",children:[t.jsx("span",{children:I("reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":I("reader.closeSettings"),onClick:()=>{var K;Ve(!1),(K=Ze.current)==null||K.focus()},children:"✕"})]}),et]}),t.jsxs("div",{className:"bim-rd-text",id:Z,ref:Pe,tabIndex:-1,"data-rail":(k||z)&&!U?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[ee,ae&&Be&&(Be.sourceName||Be.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":Be.key,children:[Be.sourceName&&t.jsxs(t.Fragment,{children:[I("reader.sourceLabel")," ",Be.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:Be.sourceUrl,target:"_blank",rel:"noreferrer",children:oe(Be.sourceName)}):oe(Be.sourceName)]}),Be.sourceName&&Be.license&&t.jsx("span",{className:"bim-rd-dot"}),Be.license&&t.jsx(t.Fragment,{children:I("reader.licenseOf",{license:Be.license})})]}),C&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:I("reader.revisedAt",{date:C})}),z&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:K=>K.preventDefault(),onClick:Q,children:I("reader.reportError")})}),N&&!E&&(ge||Oe)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":I("reader.pagerNav"),children:[ge?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>X(ge.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),I("reader.prevUnit",{unit:ve})]}),t.jsx("span",{className:"bim-rd-pglabel",children:ge.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",I("reader.firstUnit",{unit:ve})]}),Oe?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>X(Oe.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[I("reader.nextUnit",{unit:ve}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:Oe.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[I("reader.lastUnit",{unit:ve})," →"]})]})]}),(k||z)&&!U&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":I("reader.rail"),children:[k,z&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:K=>K.preventDefault(),onClick:Q,children:I("reader.reportError")})})]})]})]}),ce&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":I("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":Re,"aria-controls":Te,onClick:()=>{we(null),P()},children:[t.jsx(fa,{}),t.jsx("span",{children:I("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":J==="img","aria-haspopup":"dialog",onClick:K=>B("img",K.currentTarget),children:[t.jsx(xa,{}),t.jsx("span",{children:I("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":J==="set","aria-haspopup":"dialog",onClick:K=>B("set",K.currentTarget),children:[t.jsx(ga,{}),t.jsx("span",{children:I("reader.settingsShort")})]}),z&&t.jsxs("button",{type:"button",onMouseDown:K=>K.preventDefault(),onClick:()=>{we(null),Q()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:I("reader.reportError")})]})]}),ce&&J&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:pe}),t.jsxs("div",{className:"bim-rd-sheet",ref:de,role:"dialog","aria-modal":"true","aria-label":I(J==="img"?"reader.images":"reader.settings"),onKeyDown:K=>{if(K.key==="Escape"){K.stopPropagation(),pe();return}K.key==="Tab"&&ba(K,de.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:I(J==="img"?"reader.images":"reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":I("reader.close"),onClick:pe,children:"✕"})]}),J==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(Hr,{pages:c??null,loading:p,renderOverlay:h,preserveMargins:u.preserveMargins})}):et]})]})]})}function rf(e,n,i){return i?Cc(e).includes("\r")?"lone-cr":Array.from(e).length!==Array.from(n).length?"convert-length":n.includes(":::")?"tables":null:"quoteStyle"}function Cc(e){return e.replace(/\r\n/g,`
|
|
716
716
|
`)}const ja=2,of=400,sf=6,zc=e=>e==="*"||e==="#"||e==="<"||e===">"||/\s/.test(e);function Nc(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 af(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=Nc(e,o);if(a>=0){o=a+1;continue}if(zc(e[o])){o++;continue}if(i[s]===" "){s++;continue}return-1}return o}function lf(e){const n=Array.from(Cc(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>=sf;let l=0;for(let d=i;d<n.length&&d-i<=(a?of:ja+64);d++){const c=Nc(n,d);if(c>=0){d=c;continue}if(!zc(n[d])){const h=af(n,d,s);if(h>=0)return i=h,d;if(l++,!a&&l>ja)return}}}}}const cf=65536,df="guji_markdown";function pf(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 uf=/^□\{guess=([^\s{}]+)\}/;function mf(e,n){const i=e[n+1];return i!==void 0&&!/[A-Za-z/!?>\s]/.test(i)}function Tc(e,n){let i=0;for(let o=n;o<e.length;o++){const s=e[o];if(s===`
|
|
717
717
|
`)return-1;if(s==="\\"){o++;continue}if(s==="[")i++;else if(s==="]"&&(i--,i===0))return o}return-1}function hf(e){return e.replace(/\\([\\[\]<>|{}])/g,"$1")}function ff(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(`
|
|
718
718
|
`)<0?{node:{type:"qw",label:e.slice(n+2,o)},end:o+2}:null}if(i===":"&&e.startsWith(":zi[",n)){const o=Tc(e,n+3);return o>n+4?{node:{type:"zi",label:hf(e.slice(n+4,o))},end:o+1}:null}if(i==="□"&&e[n+1]==="{"){const o=uf.exec(e.slice(n,n+64));if(o)return{node:{type:"qz",guess:o[1]},end:n+o[0].length}}return null}function Ic(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===`
|
|
719
|
-
`)return null}const h=ff(e,n);if(h){c(),a.push(h.node),n=h.end;continue}let m=null;if(p==="<"&&mf(e,n)&&(m=">"),m){const u=Ic(e,n+1,m,!0,s);if(u&&!(u.end-(n+1)>s)){c(),a.push({type:"jz",children:u.nodes}),n=u.end+1;continue}}l+=p,n++}return i!==null?null:(c(),{nodes:a,end:n})}function Rc(e,n){return Ic(e,0,null,!1,(n==null?void 0:n.jzMaxLength)??cf).nodes}function gf(e){return/[<□]|\[\[|:zi\[/.test(e)}function Ec(e){return e.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${Ec(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const xf=216,va="clamp(280px, 23vw, 360px)",bf=1440,
|
|
719
|
+
`)return null}const h=ff(e,n);if(h){c(),a.push(h.node),n=h.end;continue}let m=null;if(p==="<"&&mf(e,n)&&(m=">"),m){const u=Ic(e,n+1,m,!0,s);if(u&&!(u.end-(n+1)>s)){c(),a.push({type:"jz",children:u.nodes}),n=u.end+1;continue}}l+=p,n++}return i!==null?null:(c(),{nodes:a,end:n})}function Rc(e,n){return Ic(e,0,null,!1,(n==null?void 0:n.jzMaxLength)??cf).nodes}function gf(e){return/[<□]|\[\[|:zi\[/.test(e)}function Ec(e){return e.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${Ec(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const xf=216,va="clamp(280px, 23vw, 360px)",bf=1440,Vr="(max-width: 719px)",yf=`${Vr}, (pointer: coarse)`,jf=`
|
|
720
720
|
.bim-d-main.bim-d-main-grid { max-width: ${bf}px; padding: 16px 32px 0; }
|
|
721
721
|
.bim-d-grid {
|
|
722
722
|
display: grid;
|
|
@@ -1125,7 +1125,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1125
1125
|
}
|
|
1126
1126
|
|
|
1127
1127
|
/* 手机:左栏收起,提要卡 → 正文 → 旁栏 */
|
|
1128
|
-
@media ${
|
|
1128
|
+
@media ${Vr} {
|
|
1129
1129
|
.bim-d-main.bim-d-main-grid { padding: 8px 16px 0; }
|
|
1130
1130
|
.bim-d-grid {
|
|
1131
1131
|
grid-template-columns: minmax(0, 1fr);
|
|
@@ -1200,7 +1200,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1200
1200
|
:root[data-layout="boxed"] .bim-d-g-rail { border: ${r("fr-bd")}; background: ${r("fr-bg")}; padding: 14px 8px; }
|
|
1201
1201
|
:root[data-layout="boxed"] .bim-d-filters { border-bottom: 1px solid ${r("fr-tab-bd")}; }
|
|
1202
1202
|
:root[data-layout="boxed"] .bim-d-filters .bim-d-tab { margin-bottom: -1px; }
|
|
1203
|
-
@media ${
|
|
1203
|
+
@media ${Vr} {
|
|
1204
1204
|
:root[data-layout="boxed"] .bim-d-card { padding: 16px; }
|
|
1205
1205
|
:root[data-layout="boxed"] .bim-d-g-rail { border: 0; background: transparent; padding: 0; }
|
|
1206
1206
|
}
|
|
@@ -1215,7 +1215,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1215
1215
|
: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 {
|
|
1216
1216
|
text-decoration-color: currentColor; text-decoration-thickness: 2px;
|
|
1217
1217
|
}
|
|
1218
|
-
`;function
|
|
1218
|
+
`;function Zn({railTop:e,back:n,up:i,nav:o,railLinks:s,main:a,card:l,side:d}){const{t:c,convert:p}=re(),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(m=>t.jsx("li",{children:t.jsxs("a",{href:`#${m.id}`,children:[t.jsx("span",{children:p(m.label)}),m.count!=null&&t.jsx("span",{className:"bim-d-meta",children:m.count})]})},m.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(m=>t.jsx("li",{children:t.jsxs("a",{href:m.href??"#",onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),m.onClick())},children:[t.jsx("span",{children:p(m.label)}),t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:"→"})]})},m.key))})]})]}),t.jsx("div",{className:"bim-d-g-main",children:a}),t.jsx("div",{className:"bim-d-g-card",children:l}),t.jsx("div",{className:"bim-d-g-side",children:d})]})}function Lc({caption:e,children:n}){const{convert:i}=re();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 ut({id:e,title:n,meta:i,action:o,children:s}){const{convert:a}=re();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 dt({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(f.Fragment,{children:[a>0&&t.jsx("span",{className:"bim-d-dot"}),t.jsx("span",{children:s})]},a))}):null}function Di({items:e,value:n,onChange:i}){const{convert:o}=re();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 Ac({label:e,checked:n,onChange:i}){const{convert:o}=re();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 Mc=6,Ui=e=>e>Mc+1;function Ro({total:e,shown:n,unit:i,onClick:o}){const{t:s,convert:a}=re(),l=e-n,d=Ui(e)?e-Math.min(n,Mc):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 Eo({label:e,onClick:n}){const{convert:i}=re();return t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:i(e)})}function Jn({kind:e,title:n,subtitle:i,byline:o,meta:s,description:a,clampDescription:l,facts:d,stats:c,readAction:p,secondaryAction:h,children:m,foot:u}){const{t:g,convert:x}=re(),j=(d||[]).filter(v=>v.value!=null&&v.value!==""),y=(c||[]).filter(v=>v.value!=null&&v.value!==""&&v.value!==0),[S,b]=f.useState(!1),w=!!l&&!S;return t.jsxs("div",{className:"bim-d-card",children:[e&&t.jsx("div",{className:"bim-d-card-kind bim-d-ui",children:x(e)}),t.jsx("h1",{className:typeof n=="string"&&[...n].length>7?"bim-d-card-long":void 0,children:n}),i&&t.jsx("div",{className:"bim-d-card-sub",children:i}),o&&t.jsx("p",{className:"bim-d-card-byline",style:{marginBottom:0},children:o}),s&&t.jsx("div",{className:"bim-d-card-cls bim-d-ui",children:s}),a&&t.jsx("div",{className:w?"bim-d-card-desc bim-d-clamp":"bim-d-card-desc",style:w?{"--detail-clamp":l}:void 0,children:a}),a&&!!l&&t.jsx("button",{type:"button",className:"bim-d-card-toggle bim-d-ui","aria-expanded":S,onClick:()=>b(v=>!v),children:g(S?"action.collapse":"action.expand")}),y.length>0&&t.jsx("div",{className:"bim-d-stats bim-d-ui",children:y.map((v,k)=>t.jsxs("div",{children:[t.jsx("b",{children:v.value}),t.jsx("span",{children:x(v.label)})]},k))}),j.length>0&&t.jsx("dl",{className:"bim-d-ui",children:j.map((v,k)=>t.jsxs(f.Fragment,{children:[t.jsx("dt",{children:x(v.label)}),t.jsx("dd",{title:v.title,children:v.value})]},k))}),m,p,h,u&&t.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:u})]})}function Lo(e){return!!e&&[...e.replace(/\s+/g,"")].length>110}function Gr({href:e,onClick:n,label:i}){const{t:o,convert:s}=re(),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 dn({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:m,convert:u}=re(),[g,x]=f.useState(!1);if(!o.length)return null;const j=g?o:o.slice(0,l),y=o.length-j.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:[u(n),i!=null&&i!==""&&t.jsx("span",{className:"bim-d-meta",children:i})]}),p&&t.jsx("p",{className:"bim-d-side-sub bim-d-ui",children:p}),t.jsx("ul",{children:j.map((S,b)=>t.jsxs("li",{className:b===a?"bim-d-side-cur":void 0,"aria-current":b===a?"page":void 0,children:[S,s!=null&&s[b]?t.jsx("span",{className:"bim-d-meta",style:{marginLeft:"auto"},children:s[b]}):null]},b))}),y>0&&t.jsx(Eo,{label:d?d(y):m("detail.showMore",{n:y}),onClick:()=>x(!0)}),c&&t.jsx("p",{className:"bim-d-side-note bim-d-ui",children:c})]})}const vf=new Set(["reviewed","disputed","unreviewed","draft"]);function Qn({revision:e,revisedAt:n,review:i,todo:o}){const{t:s,convert:a}=re(),l=i&&vf.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(dt,{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,m)=>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(" · "),")"]})]},m))})]})]})}const vi=1e3,ka=208,kf=1440,wf="(max-width: 719px)",Pc=`
|
|
1219
1219
|
.bim-d-page {
|
|
1220
1220
|
background: ${r("page-bg")};
|
|
1221
1221
|
color: ${r("ink")};
|
|
@@ -1224,7 +1224,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1224
1224
|
padding-bottom: 64px;
|
|
1225
1225
|
}
|
|
1226
1226
|
.bim-d-main {
|
|
1227
|
-
max-width: ${
|
|
1227
|
+
max-width: ${vi}px;
|
|
1228
1228
|
margin: 0 auto;
|
|
1229
1229
|
padding: 24px clamp(16px, 4vw, 28px) 0;
|
|
1230
1230
|
}
|
|
@@ -1267,9 +1267,9 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1267
1267
|
*/
|
|
1268
1268
|
.bim-d-reader {
|
|
1269
1269
|
display: grid;
|
|
1270
|
-
grid-template-columns: ${ka}px minmax(0, ${
|
|
1270
|
+
grid-template-columns: ${ka}px minmax(0, ${vi}px);
|
|
1271
1271
|
gap: 32px;
|
|
1272
|
-
max-width: ${ka+
|
|
1272
|
+
max-width: ${ka+vi+32}px;
|
|
1273
1273
|
margin: 0 auto;
|
|
1274
1274
|
align-items: start;
|
|
1275
1275
|
}
|
|
@@ -1310,20 +1310,20 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1310
1310
|
padding-right: 0; padding-bottom: 12px;
|
|
1311
1311
|
}
|
|
1312
1312
|
}
|
|
1313
|
-
${jf}`;function
|
|
1314
|
-
`)||(n.push({start:i,end:l+1,inner:d}),i=l)}return n}function Hc(e,n){if(e.length<=n)return e;let i=n;for(const o of Fc(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 Dc={fontSize:".78em",color:r("meta-fg"),lineHeight:1.55},Pf={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 Uc(e,n,i,o){return e.map((s,a)=>{switch(s.type){case"text":return t.jsx(f.Fragment,{children:n(s.text)},a);case"jz":return t.jsx("span",{className:"bim-jiazhu",style:i===0?Dc:void 0,children:Uc(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:Pf,children:s.label},a)}})}function St(e,n=o=>o,i){if(!e)return"";if(i!=null&&i.gujiMarkdown)return gf(e)?Uc(Rc(e,{jzMaxLength:i.jzMaxLength}),n,0,i.t??
|
|
1313
|
+
${jf}`;function Hn({children:e,style:n,wide:i,grid:o}){return t.jsxs("div",{className:"bim-d-page",style:n,children:[t.jsx("style",{children:Pc}),t.jsx("div",{className:o?"bim-d-main bim-d-main-grid":i?"bim-d-main bim-d-main-wide":"bim-d-main",children:e})]})}function Yr({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 Ao({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 qr({items:e}){const n=at();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(f.Fragment,{children:[a,d]},o)})})}function Bc({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 Sf({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 _f({items:e,horizontal:n}){const{convert:i}=Ue();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 $f({glyph:e,tone:n,title:i,count:o,actions:s,id:a}){const{convert:l}=Ue();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(Ao,{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 Oc({label:e,active:n,onClick:i,dashed:o}){const{convert:s}=Ue();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 Cf({label:e,onClick:n}){const{convert:i}=Ue();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 zf({label:e,onClick:n,inline:i}){const{convert:o}=Ue();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 Wc({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 Nf({children:e}){return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e})}function Tf({volumes:e,unit:n,max:i=60}){const{t:o}=re(),s=n??o("unit.volume"),[a,l]=f.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 If({children:e}){return t.jsx("div",{style:{borderTop:`1px solid ${r("rule-strong")}`},children:e})}function Rf({spec:e}){const{convert:n}=Ue();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 Ef({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 Lf(e){return String(e+1).padStart(2,"0")}function Af(){return t.jsx("span",{style:{color:r("hint-fg")},children:"—"})}function Mf({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 Fc(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(`
|
|
1314
|
+
`)||(n.push({start:i,end:l+1,inner:d}),i=l)}return n}function Hc(e,n){if(e.length<=n)return e;let i=n;for(const o of Fc(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 Dc={fontSize:".78em",color:r("meta-fg"),lineHeight:1.55},Pf={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 Uc(e,n,i,o){return e.map((s,a)=>{switch(s.type){case"text":return t.jsx(f.Fragment,{children:n(s.text)},a);case"jz":return t.jsx("span",{className:"bim-jiazhu",style:i===0?Dc:void 0,children:Uc(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:Pf,children:s.label},a)}})}function St(e,n=o=>o,i){if(!e)return"";if(i!=null&&i.gujiMarkdown)return gf(e)?Uc(Rc(e,{jzMaxLength:i.jzMaxLength}),n,0,i.t??Nn("zh-Hant")):n(e);if(e.indexOf("<")<0)return n(e);const o=[];let s=0,a=0;for(const l of Fc(e))l.start>s&&o.push(t.jsx(f.Fragment,{children:n(e.slice(s,l.start))},a++)),o.push(t.jsx("span",{className:"bim-jiazhu",style:Dc,children:n(l.inner)},a++)),s=l.end;return s<e.length&&o.push(t.jsx(f.Fragment,{children:n(e.slice(s))},a++)),o}function Bf({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 Of({title:e,tag:n,children:i}){const{convert:o}=Ue();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 Vc({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 Wf({item:e,siblings:n,showVolumes:i=!0,fallbackNote:o}){const{t:s,convert:a}=re(),[l,d]=f.useState(!1),c=Ri(e),p=i&&!!c&&c.expected>0,h=(e.url?$n(e.url):void 0)||a(e.name),m=n?Hl(e,n):"",u=m?`${h}(${m})`:h;return t.jsx(Vc,{name:u,note:Pi(e,s)||o,href:Cn(e),extra:p?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>d(g=>!g),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(Mo,{item:e})]}):void 0})}function Mo({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 Gc({label:e,items:n}){const{convert:i}=Ue();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(Wc,{children:i(o)},s))]}):null}function Ff({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(Gc,{label:i.label,items:i.items},i.label))}):null}function Kr(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Yc({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 Hf({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 ot({id:e,label:n,onNavigate:i,renderLink:o,style:s,dense:a}){const l=at();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 Df({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 qc="guji-table-v1";function Uf(e){return!!e&&e.table_notation===qc}const Vf=/^:::table(?:\{[^}]*\})?[ \t]*$/,Gf=/^:::[ \t]*$/;function Kc(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=Tc(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 Yf=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function qf(e){if(e==="^")return{cont:!0};const n=Yf.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 Xc(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 m=!1;h.startsWith("!")&&(m=!0,h=h.slice(1));const u=Kc(h).map(qf),g=a.map(S=>S>0),x=a.map(S=>S>0?S-1:0),j=[];let y=0;for(const S of u){if(S.cont){g[y]||i.push(`第 ${p} 行第 ${y+1} 列:续格 ^ 上方没有跨行格`),y+=1;continue}const{cell:b}=S;for(let w=y;w<y+b.colspan;w++)if(g[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;j.push(b),y+=b.colspan}for(let S=y;S<g.length;S++)g[S]&&i.push(`第 ${p} 行第 ${S+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let S=0;S<x.length;S++)x[S]===void 0&&(x[S]=0);a=x,o.push({header:m,cells:j}),s.push({width:y,line:p})});const l=s.reduce((d,c)=>Math.max(d,c.width),0);for(const d of s)d.width!==l&&i.push(`第 ${d.line} 行:占 ${d.width} 列,与总列数 ${l} 不符`);return a.some(d=>d>0)&&i.push("表尾:有跨行格超出了表的最后一行"),o.length===0&&i.push("空表"),{rows:o,columns:l,warnings:i}}function Po(e){const n=e.split(`
|
|
1315
1315
|
`),i=[];let o=[];const s=()=>{if(o.length===0)return;const l=o.join(`
|
|
1316
1316
|
`);o=[],i.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(Vf.test(n[a].trim())){let l=a+1;for(;l<n.length&&!Gf.test(n[l].trim());)l++;if(l<n.length){s();const d=n.slice(a+1,l);i.push({type:"table",table:Xc(d,a+1),source:n.slice(a,l+1).join(`
|
|
1317
|
-
`)}),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 Kf={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},Xf={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},Zf=`1px solid ${r("table-border")}`,Zc={border:Zf,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},Jf={...Zc,background:r("table-head-bg"),fontWeight:600};function
|
|
1318
|
-
`).map(n=>n.trim()).filter(n=>n&&!
|
|
1319
|
-
`)){const s=o.trim();if(!s||
|
|
1317
|
+
`)}),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 Kf={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},Xf={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},Zf=`1px solid ${r("table-border")}`,Zc={border:Zf,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},Jf={...Zc,background:r("table-head-bg"),fontWeight:600};function Bo({table:e,opts:n}){return t.jsx("div",{className:"bim-guji-table-wrap",style:Kf,children:t.jsx("table",{className:"bim-guji-table",style:Xf,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?Jf:Zc,children:s.empty?null:St(s.text,void 0,n)},a)})},o))})})})}function Qf(e,n){return e.indexOf("**")<0?St(e,void 0,n):e.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((o,s)=>s%2===1?t.jsx("strong",{children:St(o.trim().slice(2,-2),void 0,n)},s):t.jsx(f.Fragment,{children:St(o,void 0,n)},s))}function eg(e,n,i=!1){const o=i?{gujiMarkdown:!0}:void 0;return n?Po(e).map((s,a)=>s.type==="table"?t.jsx(Bo,{table:s.table,opts:o},a):t.jsx(f.Fragment,{children:Qf(s.text,o)},a)):St(e,void 0,o)}const tg=/^(#{1,6})\s+(.*)$/,ng=/^\*\*([^*\n]+)\*\*\s*$/;function Oo(e){const n=e.match(tg);if(n)return{level:n[1].length,text:n[2].trim()};const i=e.trim().match(ng);return i?{level:3,text:i[1].trim()}:null}const Wo=/^<!--.*-->$/;function Jc(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function Qc(e){return e.split(`
|
|
1318
|
+
`).map(n=>n.trim()).filter(n=>n&&!Wo.test(n))}const ig=60;function ed(e){let n=0,i=0;for(const o of e.split(`
|
|
1319
|
+
`)){const s=o.trim();if(!s||Wo.test(s)||Oo(s))continue;const a=s.replace(/<[^<>\n]*>/g,"").replace(/\s/g,"").length;n+=a,a>ig&&(i+=a)}return n>0&&i*2>=n}function rg(e){return e.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function Vi(e){if(e=rg(e),ed(e))return"unknown";const n=Jc(e);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const i=n.map(s=>Qc(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 og(e){const n=e.split(`
|
|
1320
1320
|
`),i=[];let o=null,s=[];const a=()=>{i.push({heading:o,body:s.join(`
|
|
1321
|
-
`)}),s=[]};for(const l of n){const d=
|
|
1322
|
-
`)){const o=
|
|
1323
|
-
`)?"":n)}function dg(e){return e<=1?2:e===2?3:4}function pg(){let e=1;return n=>{const i=dg(n),o=Math.min(i,e+1);return e=o,{Tag:`h${o}`,className:`bim-rd-hl${i}`}}}function
|
|
1324
|
-
`);let p=0;return t.jsx(t.Fragment,{children:c.map((h,m)=>{const u=h.match(
|
|
1325
|
-
,。、;:?!「」『』()…—·`));function Ho(e){return!gg.has(e)}function ad(e,n,i=0){const o=[],s=Array.from(e);let a=0;for(const d of s)Ho(d)&&o.push(a),a+=d.length;const l=[];for(const d of n){if(!gn(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],m=e.codePointAt(h)>65535?2:1;l.push({...d,start:o[c],end:h+m})}return l}function xg(e,n){return n.text?Array.from(e.slice(n.start,n.end)).filter(Ho).join("")===n.text:!0}function bg(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 ld(e,n,i=16){const o=[];for(const l of n){if(!gn(l))continue;let d={...l,start:Math.max(0,l.start),end:Math.min(e.length,l.end)};(d.end<=d.start||!xg(e,d))&&(d=bg(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 yg={off:[],lite:["people","place","dynasty"],full:["people","place","dynasty","office","reign","other"]};function jg(e,n,i){const o=(i==null?void 0:i.showWorks)!==!1,s=new Set(yg[n]);return e.filter(a=>a.kind==="work"?o:s.has(a.kind))}function vg(e,n,i){const[o,s]=f.useState(null),[a,l]=f.useState(!1),d=f.useRef(0);return f.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 kg(){let e=null;const n=new Set;return{get:()=>e,set:i=>{i!==e&&(e=i,n.forEach(o=>o()))},subscribe:i=>(n.add(i),()=>{n.delete(i)})}}function wg(e){return f.useSyncExternalStore(e.subscribe,e.get,e.get)}function za({store:e,children:n}){const i=wg(e);return f.createElement(f.Fragment,null,n(i))}function Sg(e){return typeof e!="string"?null:e==="published"?"source":Object.prototype.hasOwnProperty.call(Nu,e)?e:null}function _g(e){if(e==="none")return{color:r("quality-none"),fontWeight:400};if(e==="placeholder")return{color:r("quality-placeholder"),fontWeight:400}}const $g={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释",tally:"小计"},cd="\0";function Cg(e,n,i){const[o,s=""]=e.split(cd);return t.jsxs(t.Fragment,{children:[o,t.jsx(fc,{text:n,convert:i}),s]})}function $t(e){return typeof e!="string"?"":$g[e]??e}const zg=["〇","一","二","三","四","五","六","七","八","九"],Na=["","十","百","千"],Ng=["","萬","億"];function Do(e){if(e===0)return"〇";if(e<0)return`負${Do(-e)}`;const n=[];let i=e,o=0;for(;i>0;){const s=i%1e4;s>0?n.unshift(Tg(s,o>0)+Ng[o]):n.length>0&&n.unshift("〇"),i=Math.floor(i/1e4),o++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Tg(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+=Na[d]:s+=zg[l]+Na[d]}return s.replace(/〇$/,"")}let Vn=null,hi=null;const zi=new Set;function Ig(){return Vn?Promise.resolve():hi||(hi=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});Vn=i=>n(ze.normalizeVariants(i)),zi.forEach(i=>i())}).catch(()=>{Vn=e=>e,zi.forEach(e=>e())}),hi)}const Rg=e=>e;function cn(){const[,e]=f.useState(0);return f.useEffect(()=>{if(Vn)return;const n=()=>e(i=>i+1);return zi.add(n),Ig(),()=>{zi.delete(n)}},[]),Vn??Rg}function vn(e,n){return n(e).toLowerCase()}const Eg=r("highlight-bg");function Qn(e,n,i){if(!n)return e;const o=vn(n,i);if(!o)return e;const s=vn(e,i),a=Array.from(e),l=Array.from(s);if(l.length!==a.length)return e;const d=new Map;let c=0;l.forEach((x,j)=>{d.set(c,j),c+=x.length});const p=Array.from(o).length,h=[];let m=0,u=0,g=0;for(;m<a.length;){const x=s.indexOf(o,u),j=x===-1?void 0:d.get(x);if(x===-1){h.push(a.slice(m).join(""));break}if(j===void 0){u=x+1;continue}j>m&&h.push(a.slice(m,j).join("")),h.push(t.jsx("mark",{style:{background:Eg,padding:0,color:"inherit"},children:a.slice(j,j+p).join("")},g++)),m=j+p,u=x+o.length}return t.jsx(t.Fragment,{children:h})}function Uo(e,n,i,o){if(!n)return!0;const s=vn(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"&&vn(l,o).includes(s))}function Lg(e,n,i){return n?vn(e,i).includes(vn(n,i)):!0}const Vo={类:r("section-lei"),书:r("section-shu"),序:r("section-xu"),结语:r("section-jieyu"),注释:r("section-zhushi")},Ag={考证:r("section-kaozhen")};function Go(e,n,i){return e.collated.sectionType[n]??i(n)}function dd(e){var o;const n=e.files.length,i=((o=e.children)==null?void 0:o.reduce((s,a)=>s+dd(a),0))||0;return n+i}function Mg(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 Pg={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function Yo({enabled:e,expanded:n,onClick:i,style:o,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:i,style:{...Pg,...o},children:s}):t.jsx("span",{style:o,children:s})}function Bg({type:e}){const{convert:n,messages:i}=re(),o=$t(e),s=Vo[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:Go(i,o,n)})}function Og({section:e,onNavigate:n,highlightQuery:i="",no:o,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=re(),c=st(),p=cn(),h=w=>w?St(d(w),v=>i?Qn(v,i,p):v,{t:l}):"",[m,u]=f.useState(!1),g=!!e.summary,x=!!e.comment,j=!!e.additional_comment,y=!!(e.content&&e.content.length>60),S=g||x||j||y;f.useEffect(()=>{i&&u(!0)},[i]);const b=!m&&y?Hc(e.content.replace(/\n/g," "),80)+"…":null;return t.jsxs("div",{className:"bim-rd-row",id:a,style:{borderBottom:`1px solid ${r("rule")}`,overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>S&&u(!m),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:S?"pointer":"default",userSelect:"none"},children:[o!=null&&t.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:r("label-fg")},children:o}),t.jsxs(Yo,{enabled:S,expanded:m,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[S&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),transition:"transform 0.15s",transform:m?"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(Do(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)})]}),!m&&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")})]}),m&&S&&t.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${r("widget-border")}`,background:r("bg")},children:[e.author_info&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"8px"},children:h(e.author_info)}),e.summary&&t.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.summary")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:h(e.summary)})]}),e.comment&&t.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.comment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:h(e.comment)})]}),e.additional_comment&&t.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.additionalComment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:h(e.additional_comment)})]}),y&&!g&&!x&&!j&&t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:h(e.content)})]})]})}function Wg({section:e,highlightQuery:n=""}){const{t:i,convert:o}=re(),s=cn(),a=p=>p?St(o(p),h=>n?Qn(h,n,s):h,{t:i}):"",[l,d]=f.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(Yo,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(Bg,{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, ${Vo[$t(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 Fg=100;function qo(e){return $t(e.type)!=="page_header"?!1:(e.content||"").length>=Fg}function Hg({section:e,highlightQuery:n=""}){const{t:i,convert:o,messages:s}=re(),a=cn();if($t(e.type)==="page_header"&&!qo(e)||!e.content&&!e.title)return null;const l=o((e.content||e.title||"").replace(/\n{2,}/g,`
|
|
1326
|
-
`)),d=St(l,m=>n?Qn(m,n,a):m,{t:i}),c=$t(e.type),p=Vo[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:Go(s,c,o)}),d]})}function Dg(e,n,i){const[o,s]=f.useState({});return f.useEffect(()=>{var p;if(!n||e.length===0)return;let a=!1;const l=e.filter(h=>{var m;return!((m=i==null?void 0:i.current)!=null&&m.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 m;try{if(n.getEntry){const y=await n.getEntry(h);if(y)return{title:y.title,author:y.author}}const u=await n.getItem(h);if(!u)return null;const g=u.title||h,x=u.authors,j=(m=x==null?void 0:x[0])==null?void 0:m.name;return{title:g,author:j}}catch{return null}};return Promise.all(l.map(async h=>{var u;const m=await c(h);return(u=i==null?void 0:i.current)==null||u.set(h,m),[h,m]})).then(h=>{a||s(m=>{const u={...m};for(const[g,x]of h)u[g]=x;return u})}),()=>{a=!0}},[e.join(","),n]),o}function Ug({section:e,onNavigate:n,transport:i,workLabelCache:o,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=re(),c=st(),p=cn(),h=v=>v?St(l(v),k=>s?Qn(k,s,p):k,{t:a}):"",[m,u]=f.useState(!1);f.useEffect(()=>{s&&u(!0)},[s]);const g=$t(e.type),x=Ag[g]||r("desc-fg"),j=!!e.content,y=e.work_ids||[],S=y.length>1,b=Dg(S?y:[],i,o),w=j&&!m&&e.content.length>80?Hc(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${r("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>j&&u(!m),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:j?"pointer":"default",userSelect:"none"},children:[t.jsxs(Yo,{enabled:j,expanded:m,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[j&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:m?"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)}),!m&&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")}),S&&t.jsx("span",{style:{fontSize:"11px",color:r("link-fg"),flexShrink:0},children:a("collated.nWorks",{n:y.length})}),t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:x,border:`1px solid ${x}40`,borderRadius:"2px",background:`${x}08`},children:Go(d,g,l)})]})]}),S&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:y.map(v=>{const k=b[v],z=k?`${l(k.title)}${k.author?`(${l(k.author)})`:""}`:v.slice(0,8)+"…";return t.jsxs("a",{href:c(v),onClick:C=>{C.metaKey||C.ctrlKey||(C.preventDefault(),C.stopPropagation(),n(v))},style:{fontSize:"12px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:v,children:["→",z]},v)})}),m&&j&&t.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${x}40`,borderRadius:"0 4px 4px 0",background:r("bg")},children:[t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children: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 Vg({juan:e,searchQuery:n,onNavigate:i,transport:o,workLabelCache:s}){const{t:a}=re(),l=cn(),d=n.trim(),c=f.useMemo(()=>d?e.sections.filter(p=>Uo(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(Ug,{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 Gg(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function Yg({sections:e,onNavigate:n,inline:i,workLinks:o=!0}){const s=st(),{t:a,convert:l}=re(),d=Gg();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const h=$t(c.type);if(h==="page_header"&&!qo(c))return null;if(h==="类")return t.jsxs(f.Fragment,{children:[f.createElement(d("类"),null,i(l(c.title))),c.content&&t.jsx("p",{children:i(l(c.content))})]},p);if(h==="书"||h==="诗"||h==="考证"||h==="注释"){const m=c.book_title?`《${c.book_title}》${c.n_juan!=null?a("collated.nJuan",{n:Do(c.n_juan)}):""}`:c.title,u=i(l(m));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[f.createElement(d("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&o?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:s(c.work_id),onClick:g=>{g.metaKey||g.ctrlKey||(g.preventDefault(),n(c.work_id))},title:a("collated.viewWork"),children:u}),t.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:g=>{g.metaKey||g.ctrlKey||(g.preventDefault(),n(c.work_id))},"aria-label":a("collated.viewWorkOf",{title:l(m)}),children:a("collated.workArrow")})]}):u),c.author_info&&t.jsx("p",{className:"bim-rd-sub",children:i(l(c.author_info))}),c.content&&c.content.split(/\n+/).map((g,x)=>t.jsx("p",{children:i(l(g))},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 pd(e){return e.some(n=>{const i=$t(n.type);return i==="书"||i==="诗"||i==="考证"||i==="注释"||i==="类"||(i==="序"||i==="结语")&&!!n.content||i==="page_header"&&qo(n)})}function qg({juan:e,rawText:n,positionLabel:i,groupLabel:o,index:s,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c,prefs:p,view:h,onViewChange:m}){var ne;const{t:u,convert:g,messages:x}=re(),j=cn(),[y,S]=f.useState("text"),b=h??y,w=U=>{S(U),m==null||m(U)},v=a.trim(),k=(s==null?void 0:s.type)==="kaozhen",z=f.useCallback(U=>v?Qn(U,v,j):U,[v,j]),C=Wo(p),_=U=>Vi(U,{renderText:z,bookMarking:C,quoteStyle:p.quoteStyle,t:u}),R=f.useMemo(()=>v?e.sections.filter(U=>Uo(U,v,k,j)):e.sections,[e.sections,v,k,j]),T=(U,Q)=>Q.filter(q=>$t(q.type)===U).length,N=T("书",e.sections),E=T("诗",e.sections),W=T("考证",e.sections);let F="";k?F=v?u("collated.countTiaoOf",{m:T("考证",R),n:W}):u("collated.countTiao",{n:W}):E>0?F=v?u("collated.countPoemsOf",{m:T("诗",R),n:E}):u("collated.countPoems",{n:E}):N>0&&(F=v?u("collated.countBooksOf",{m:T("书",R),n:N}):u("collated.countBooks",{n:N}));const A=s!=null&&s.text_quality?Sg(s.text_quality.grade):null,V=[];if(F&&V.push(F),k&&(s!=null&&s.target_source)&&V.push(t.jsx(t.Fragment,{children:u("collated.kaozhenTarget",{target:g(s.target_source)})})),A){const U=t.jsx("span",{className:"bim-rd-grade",style:_g(A),children:x.collated.qualityLabel[A]});V.push(t.jsx("span",{title:x.collated.qualityCriteria[A],children:(ne=s==null?void 0:s.text_quality)!=null&&ne.source_note?t.jsxs(t.Fragment,{children:[Cg(u("collated.baseText",{note:cd}),s.text_quality.source_note,g),U]}):t.jsxs(t.Fragment,{children:[u("collated.textQuality"),U]})}))}e.source_url&&V.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:u("collated.originalSource")}));const ae=!k&&pd(e.sections),xe=!!n&&(!ae||p.readingMode==="paragraph"&&Ci(n)),me=!k&&(ae||!!n),G=k||!me?"entries":b;let ye=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&&g(o)]}),t.jsx("h1",{className:"bim-rd-h1",children:g(e.title)}),V.length>0&&t.jsx("p",{className:"bim-rd-meta",children:V.map((U,Q)=>t.jsxs(f.Fragment,{children:[Q>0&&t.jsx("span",{className:"bim-rd-dot"}),U]},Q))}),me&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":u("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":G==="text",onClick:()=>w("text"),children:u("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":G==="entries",onClick:()=>w("entries"),children:u("collated.viewEntries")})]})]}),G==="text"&&t.jsx("article",{className:"bim-rd-prose",children:xe?t.jsx(Fo,{text:n,mode:p.readingMode,bookMarking:C,quoteStyle:p.quoteStyle,renderText:z,dropTitle:e.title}):t.jsx(Yg,{sections:e.sections,onNavigate:l,inline:_,workLinks:p.workLinks})}),G==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:k?t.jsx(Vg,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[R.some(U=>["书","诗","考证"].includes($t(U.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:u("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:u("collated.rowHeadTitle")}),t.jsx("span",{children:u("collated.rowHeadWork")})]}),R.map((U,Q)=>{const q=$t(U.type);return q==="书"||q==="诗"||q==="考证"?(ye+=1,t.jsx(Og,{domId:`rd-e-${e.sections.indexOf(U)}`,section:U,onNavigate:p.workLinks?l:void 0,highlightQuery:v,no:ye,showUnlinked:p.workLinks&&!!l},Q)):q==="类"?t.jsx(Wg,{section:U,highlightQuery:v},Q):t.jsx(Hg,{section:U,highlightQuery:v},Q)}),R.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:u("collated.noMatch")})]})})]})}function Kg(e){const{resetKey:n,load:i,files:o,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=cn(),h=f.useRef(new Map),[m,u]=f.useState({}),[g,x]=f.useState({}),j=f.useCallback((S,b)=>{const w=b==null?void 0:b.title;w&&x(v=>v[S]===w?v:{...v,[S]:w})},[]);f.useEffect(()=>{s&&a&&(h.current.set(s,{juan:a,rawText:l}),j(s,a))},[s,a,l,j]),f.useEffect(()=>{h.current.clear(),u({}),x({})},[n]);const y=f.useCallback((S,b)=>{let w=0;if(S.juan)for(const v of S.juan.sections)Uo(v,b,c,p)&&w++;return w===0&&S.rawText&&Lg(S.rawText,b,p)&&(w=1),w},[c,p]);return f.useEffect(()=>{const S=d.trim();if(!S){u({});return}if(!i||o.length===0)return;let b=!1;const w={},v=[];for(const R of o){const T=h.current.get(R);T?w[R]=y(T,S):(w[R]="loading",v.push(R))}u(w);const k=8;let z=0;const C=async()=>{for(;z<v.length;){if(b)return;const R=z++,T=v[R];try{const N=await i(T),E=N.juan;if(h.current.set(T,N),j(T,E),b)return;u(W=>({...W,[T]:y(N,S)}))}catch{if(b)return;u(N=>({...N,[T]:0}))}}},_=Array.from({length:Math.min(k,v.length)},()=>C());return Promise.all(_),()=>{b=!0}},[d,n,i,o.join(","),y,p,j]),{matchStates:m,titles:g}}function Xg({juan:e,view:n,onView:i,textHasEntries:o}){const{t:s,convert:a}=re(),l=e.sections.map((h,m)=>({s:h,i:m,t:$t(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 m=()=>{var u,g;return(g=(u=document.getElementById(`rd-e-${h}`))==null?void 0:u.scrollIntoView)==null?void 0:g.call(u,{block:"start",behavior:"smooth"})};n==="text"&&!o&&i("entries"),n==="text"&&!o?setTimeout(m,0):m()};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:m})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${m}`,onClick:u=>{u.preventDefault(),p(m)},children:[t.jsx("span",{className:`bim-rd-rail-dot${h.work_id?" on":""}`,"aria-hidden":"true"}),t.jsx("span",{children:Vi(a(h.book_title||h.title),{t:s})})]})},m))})]})]})}const Zg=`
|
|
1321
|
+
`)}),s=[]};for(const l of n){const d=Oo(l);if(d){a(),o={kind:"heading",level:d.level,text:d.text};continue}s.push(l)}return a(),i}function wa(e){const n=[];for(const i of e.split(`
|
|
1322
|
+
`)){const o=Oo(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 td(e){if(!e)return[];const n=Vi(e);if(n==="unknown")return wa(e);const i=[];for(const{heading:o,body:s}of og(e)){o&&i.push(o);const a=Jc(s);if(a.length!==0){if(ed(s)){i.push(...wa(s));continue}if(n==="record"){const l=a.join(" ");l&&i.push({kind:"body",text:l})}else for(const l of a){const d=Qc(l);d.length&&i.push({kind:"body",text:d.join(" ")})}}}return i}const sg={"「":"“","」":"”","『":"‘","』":"’"},ag={"“":"「","”":"」","‘":"『","’":"』"},lg=new Set(["《","》","〈","〉"]);function nd(e,n){const i=n.quoteStyle==="modern"?sg:n.quoteStyle==="classic"?ag:null;let o="";for(const s of e)n.hideBookBrackets&&lg.has(s)||(o+=(i==null?void 0:i[s])??s);return o}const id=e=>e;function Fo(e){return e.showWorks?e.bookTitleStyle==="bracket"?"bracket":Gh(e.properNameMode)?"wavy":"bracket":"none"}function rd(e,n=id,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(f.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(f.Fragment,{children:c},l++)),a=d.index+d[0].length}return a===0?n(e):(a<e.length&&o.push(t.jsx(f.Fragment,{children:n(e.slice(a))},l++)),o)}function Gi(e,n={}){let i=n.renderText??id;const o=n.quoteStyle;if(o&&o!=="original"){const d=i;i=c=>d(nd(c,{quoteStyle:o}))}const s=n.bookMarking??(n.properNames?"wavy":"bracket"),a=s==="bracket"?i:d=>rd(d,i,s),l=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return St(e,a,l)}function Sa(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(f.Fragment,{children:n(s)},`${i}-${a}`))}const Sr=/^(#{1,6})\s+(.*)$/,cg=/^\s*<!--.*-->\s*$/;function od(e){return e.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
|
|
1323
|
+
`)?"":n)}function dg(e){return e<=1?2:e===2?3:4}function pg(){let e=1;return n=>{const i=dg(n),o=Math.min(i,e+1);return e=o,{Tag:`h${o}`,className:`bim-rd-hl${i}`}}}function zi(e){return e?Vi(od(e))!=="unknown":!1}function ug(e){return/^\u3000{2}/.test(e)}const _a=e=>ug(e)?"bim-rd-noindent":void 0;function $a({text:e,mode:n,inline:i,dropTitle:o,onStart:s}){s==null||s();const a=od(e),l=(h,m,u)=>!!o&&u<=1&&h<=2&&m.trim()===o.trim(),d=pg();if(n==="paragraph"&&Vi(a)!=="unknown"){const h=td(a);return t.jsx(t.Fragment,{children:h.map((m,u)=>{if(m.kind==="heading"){if(l(m.level??1,m.text,u))return null;const{Tag:g,className:x}=d(m.level??1);return t.jsx(g,{className:x,children:i(m.text)},u)}return t.jsx("p",{className:_a(m.text),children:Sa(m.text,i,u)},u)})})}const c=a.split(`
|
|
1324
|
+
`);let p=0;return t.jsx(t.Fragment,{children:c.map((h,m)=>{const u=h.match(Sr);if(u){const x=p++;if(l(u[1].length,u[2],x))return null;const{Tag:j,className:y}=d(u[1].length);return t.jsx(j,{className:y,children:i(u[2])},m)}if(!h.trim())return m>=2&&!!c[m-1].trim()&&!!c[m-2].trim()&&!Sr.test(c[m-1])&&!Sr.test(c[m-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},m):null;if(cg.test(h))return null;if(p++,/^\*\*[^*]+\*\*\s*$/.test(h.trim())){const{Tag:x,className:j}=d(3);return t.jsx(x,{className:j,children:i(h.trim().slice(2,-2))},m)}return t.jsx("p",{className:_a(h),children:Sa(h,i,m)},m)})})}function mg(e){const{convert:n}=Ue();return f.useMemo(()=>e?n(e):"",[e,n])}function Ho({text:e,mode:n,tables:i=!1,gujiMarkdown:o=!1,properNames:s=!1,bookMarking:a,quoteStyle:l,renderText:d,dropTitle:c}){const p=mg(e),{t:h,convert:m}=re();let u=null;const g=!!d&&!rf(e,p,!l||l==="original"),x=d&&g?w=>d(w,{mdStart:u==null?void 0:u.align(w)}):d,j=g?()=>{u=lf(e)}:void 0,y=w=>Gi(w,{renderText:x,properNames:s,bookMarking:a,quoteStyle:l,gujiMarkdown:o,t:h}),S=o?{gujiMarkdown:!0,t:h}:void 0,b=c?m(c):void 0;return!i||p.indexOf(":::")<0?t.jsx($a,{text:p,mode:n,inline:y,dropTitle:b,onStart:j}):t.jsx(t.Fragment,{children:Po(p).map((w,v)=>w.type==="table"?t.jsx(Bo,{table:w.table,opts:S},v):t.jsx($a,{text:w.text,mode:n,inline:y,dropTitle:v===0?b:void 0},v))})}const Ca={work:"work",book:"work",people:"people",person:"people",place:"place",office:"office",dynasty:"dynasty",reign:"reign"};function hg(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(Ca,e)&&Ca[e]||"other"}function Xr(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 Jt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function st(e){return typeof e=="string"&&e?e:void 0}function fg(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={};st(s.entity_id)!==void 0&&(a.entity_id=st(s.entity_id)),st(s.canonical_name)!==void 0&&(a.canonical_name=st(s.canonical_name)),Jt(s.confidence)!==void 0&&(a.confidence=Jt(s.confidence)),i.push(a)}return i}const jn=e=>e.start!==void 0&&e.end!==void 0;function sd(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=Jt(l.start_offset)??Jt(a.start_offset),p=Jt(l.end_offset)??Jt(a.end_offset),h=c!==void 0&&p!==void 0&&c>=0&&p>c,m=a.anchor??{},u=st(m.start),g=st(m.end);if(!h&&!!!(u&&g))return;const j=st(d.status),y=j===void 0||j==="matched"?Xr(st(d.entity_id))??Xr(st(d.href))??void 0:void 0,S=Jt(d.confidence),b=fg(a.ambiguous);i.push({...u&&g?{anchor:{start:u,end:g}}:{},key:st(a.id)??`e${s}`,kind:hg(a.type),...h?{start:c,end:p}:{},text:st(a.text),targetId:y,canonicalName:st(d.canonical_name),confidence:Jt(a.confidence)??S,...S!==void 0?{targetConfidence:S}:{},...st(d.level)!==void 0?{targetLevel:st(d.level)}:{},...st(d.note)!==void 0?{targetNote:st(d.note)}:{},...st(a.group)!==void 0?{group:st(a.group)}:{},...b!==void 0?{candidates:b}:{}})}),i.sort((o,s)=>!jn(o)||!jn(s)?+!jn(o)-+!jn(s):o.start-s.start||s.end-o.end)}const gg=new Set(Array.from(`《》/<>\r
|
|
1325
|
+
,。、;:?!「」『』()…—·`));function Do(e){return!gg.has(e)}function ad(e,n,i=0){const o=[],s=Array.from(e);let a=0;for(const d of s)Do(d)&&o.push(a),a+=d.length;const l=[];for(const d of n){if(!jn(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],m=e.codePointAt(h)>65535?2:1;l.push({...d,start:o[c],end:h+m})}return l}function xg(e,n){return n.text?Array.from(e.slice(n.start,n.end)).filter(Do).join("")===n.text:!0}function bg(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 ld(e,n,i=16){const o=[];for(const l of n){if(!jn(l))continue;let d={...l,start:Math.max(0,l.start),end:Math.min(e.length,l.end)};(d.end<=d.start||!xg(e,d))&&(d=bg(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 yg={off:[],lite:["people","place","dynasty"],full:["people","place","dynasty","office","reign","other"]};function jg(e,n,i){const o=(i==null?void 0:i.showWorks)!==!1,s=new Set(yg[n]);return e.filter(a=>a.kind==="work"?o:s.has(a.kind))}function vg(e,n,i){const[o,s]=f.useState(null),[a,l]=f.useState(!1),d=f.useRef(0);return f.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 kg(){let e=null;const n=new Set;return{get:()=>e,set:i=>{i!==e&&(e=i,n.forEach(o=>o()))},subscribe:i=>(n.add(i),()=>{n.delete(i)})}}function wg(e){return f.useSyncExternalStore(e.subscribe,e.get,e.get)}function za({store:e,children:n}){const i=wg(e);return f.createElement(f.Fragment,null,n(i))}function Sg(e){return typeof e!="string"?null:e==="published"?"source":Object.prototype.hasOwnProperty.call(Nu,e)?e:null}function _g(e){if(e==="none")return{color:r("quality-none"),fontWeight:400};if(e==="placeholder")return{color:r("quality-placeholder"),fontWeight:400}}const $g={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释",tally:"小计"},cd="\0";function Cg(e,n,i){const[o,s=""]=e.split(cd);return t.jsxs(t.Fragment,{children:[o,t.jsx(fc,{text:n,convert:i}),s]})}function zt(e){return typeof e!="string"?"":$g[e]??e}const zg=["〇","一","二","三","四","五","六","七","八","九"],Na=["","十","百","千"],Ng=["","萬","億"];function Uo(e){if(e===0)return"〇";if(e<0)return`負${Uo(-e)}`;const n=[];let i=e,o=0;for(;i>0;){const s=i%1e4;s>0?n.unshift(Tg(s,o>0)+Ng[o]):n.length>0&&n.unshift("〇"),i=Math.floor(i/1e4),o++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Tg(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+=Na[d]:s+=zg[l]+Na[d]}return s.replace(/〇$/,"")}let Gn=null,fi=null;const Ni=new Set;function Ig(){return Gn?Promise.resolve():fi||(fi=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});Gn=i=>n(ze.normalizeVariants(i)),Ni.forEach(i=>i())}).catch(()=>{Gn=e=>e,Ni.forEach(e=>e())}),fi)}const Rg=e=>e;function mn(){const[,e]=f.useState(0);return f.useEffect(()=>{if(Gn)return;const n=()=>e(i=>i+1);return Ni.add(n),Ig(),()=>{Ni.delete(n)}},[]),Gn??Rg}function _n(e,n){return n(e).toLowerCase()}const Eg=r("highlight-bg");function ei(e,n,i){if(!n)return e;const o=_n(n,i);if(!o)return e;const s=_n(e,i),a=Array.from(e),l=Array.from(s);if(l.length!==a.length)return e;const d=new Map;let c=0;l.forEach((x,j)=>{d.set(c,j),c+=x.length});const p=Array.from(o).length,h=[];let m=0,u=0,g=0;for(;m<a.length;){const x=s.indexOf(o,u),j=x===-1?void 0:d.get(x);if(x===-1){h.push(a.slice(m).join(""));break}if(j===void 0){u=x+1;continue}j>m&&h.push(a.slice(m,j).join("")),h.push(t.jsx("mark",{style:{background:Eg,padding:0,color:"inherit"},children:a.slice(j,j+p).join("")},g++)),m=j+p,u=x+o.length}return t.jsx(t.Fragment,{children:h})}function Vo(e,n,i,o){if(!n)return!0;const s=_n(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"&&_n(l,o).includes(s))}function Lg(e,n,i){return n?_n(e,i).includes(_n(n,i)):!0}const Go={类:r("section-lei"),书:r("section-shu"),序:r("section-xu"),结语:r("section-jieyu"),注释:r("section-zhushi")},Ag={考证:r("section-kaozhen")};function Yo(e,n,i){return e.collated.sectionType[n]??i(n)}function dd(e){var o;const n=e.files.length,i=((o=e.children)==null?void 0:o.reduce((s,a)=>s+dd(a),0))||0;return n+i}function Mg(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 Pg={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function qo({enabled:e,expanded:n,onClick:i,style:o,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:i,style:{...Pg,...o},children:s}):t.jsx("span",{style:o,children:s})}function Bg({type:e}){const{convert:n,messages:i}=re(),o=zt(e),s=Go[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:Yo(i,o,n)})}function Og({section:e,onNavigate:n,highlightQuery:i="",no:o,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=re(),c=at(),p=mn(),h=w=>w?St(d(w),v=>i?ei(v,i,p):v,{t:l}):"",[m,u]=f.useState(!1),g=!!e.summary,x=!!e.comment,j=!!e.additional_comment,y=!!(e.content&&e.content.length>60),S=g||x||j||y;f.useEffect(()=>{i&&u(!0)},[i]);const b=!m&&y?Hc(e.content.replace(/\n/g," "),80)+"…":null;return t.jsxs("div",{className:"bim-rd-row",id:a,style:{borderBottom:`1px solid ${r("rule")}`,overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>S&&u(!m),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:S?"pointer":"default",userSelect:"none"},children:[o!=null&&t.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:r("label-fg")},children:o}),t.jsxs(qo,{enabled:S,expanded:m,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[S&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),transition:"transform 0.15s",transform:m?"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(Uo(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)})]}),!m&&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")})]}),m&&S&&t.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${r("widget-border")}`,background:r("bg")},children:[e.author_info&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"8px"},children:h(e.author_info)}),e.summary&&t.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.summary")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:h(e.summary)})]}),e.comment&&t.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.comment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:h(e.comment)})]}),e.additional_comment&&t.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.additionalComment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:h(e.additional_comment)})]}),y&&!g&&!x&&!j&&t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:h(e.content)})]})]})}function Wg({section:e,highlightQuery:n=""}){const{t:i,convert:o}=re(),s=mn(),a=p=>p?St(o(p),h=>n?ei(h,n,s):h,{t:i}):"",[l,d]=f.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(qo,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(Bg,{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, ${Go[zt(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 Fg=100;function Ko(e){return zt(e.type)!=="page_header"?!1:(e.content||"").length>=Fg}function Hg({section:e,highlightQuery:n=""}){const{t:i,convert:o,messages:s}=re(),a=mn();if(zt(e.type)==="page_header"&&!Ko(e)||!e.content&&!e.title)return null;const l=o((e.content||e.title||"").replace(/\n{2,}/g,`
|
|
1326
|
+
`)),d=St(l,m=>n?ei(m,n,a):m,{t:i}),c=zt(e.type),p=Go[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:Yo(s,c,o)}),d]})}function Dg(e,n,i){const[o,s]=f.useState({});return f.useEffect(()=>{var p;if(!n||e.length===0)return;let a=!1;const l=e.filter(h=>{var m;return!((m=i==null?void 0:i.current)!=null&&m.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 m;try{if(n.getEntry){const y=await n.getEntry(h);if(y)return{title:y.title,author:y.author}}const u=await n.getItem(h);if(!u)return null;const g=u.title||h,x=u.authors,j=(m=x==null?void 0:x[0])==null?void 0:m.name;return{title:g,author:j}}catch{return null}};return Promise.all(l.map(async h=>{var u;const m=await c(h);return(u=i==null?void 0:i.current)==null||u.set(h,m),[h,m]})).then(h=>{a||s(m=>{const u={...m};for(const[g,x]of h)u[g]=x;return u})}),()=>{a=!0}},[e.join(","),n]),o}function Ug({section:e,onNavigate:n,transport:i,workLabelCache:o,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=re(),c=at(),p=mn(),h=v=>v?St(l(v),k=>s?ei(k,s,p):k,{t:a}):"",[m,u]=f.useState(!1);f.useEffect(()=>{s&&u(!0)},[s]);const g=zt(e.type),x=Ag[g]||r("desc-fg"),j=!!e.content,y=e.work_ids||[],S=y.length>1,b=Dg(S?y:[],i,o),w=j&&!m&&e.content.length>80?Hc(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${r("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>j&&u(!m),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:j?"pointer":"default",userSelect:"none"},children:[t.jsxs(qo,{enabled:j,expanded:m,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[j&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:m?"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)}),!m&&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")}),S&&t.jsx("span",{style:{fontSize:"11px",color:r("link-fg"),flexShrink:0},children:a("collated.nWorks",{n:y.length})}),t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:x,border:`1px solid ${x}40`,borderRadius:"2px",background:`${x}08`},children:Yo(d,g,l)})]})]}),S&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:y.map(v=>{const k=b[v],z=k?`${l(k.title)}${k.author?`(${l(k.author)})`:""}`:v.slice(0,8)+"…";return t.jsxs("a",{href:c(v),onClick:C=>{C.metaKey||C.ctrlKey||(C.preventDefault(),C.stopPropagation(),n(v))},style:{fontSize:"12px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:v,children:["→",z]},v)})}),m&&j&&t.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${x}40`,borderRadius:"0 4px 4px 0",background:r("bg")},children:[t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children: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 Vg({juan:e,searchQuery:n,onNavigate:i,transport:o,workLabelCache:s}){const{t:a}=re(),l=mn(),d=n.trim(),c=f.useMemo(()=>d?e.sections.filter(p=>Vo(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(Ug,{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 Gg(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function Yg({sections:e,onNavigate:n,inline:i,workLinks:o=!0}){const s=at(),{t:a,convert:l}=re(),d=Gg();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const h=zt(c.type);if(h==="page_header"&&!Ko(c))return null;if(h==="类")return t.jsxs(f.Fragment,{children:[f.createElement(d("类"),null,i(l(c.title))),c.content&&t.jsx("p",{children:i(l(c.content))})]},p);if(h==="书"||h==="诗"||h==="考证"||h==="注释"){const m=c.book_title?`《${c.book_title}》${c.n_juan!=null?a("collated.nJuan",{n:Uo(c.n_juan)}):""}`:c.title,u=i(l(m));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[f.createElement(d("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&o?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:s(c.work_id),onClick:g=>{g.metaKey||g.ctrlKey||(g.preventDefault(),n(c.work_id))},title:a("collated.viewWork"),children:u}),t.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:g=>{g.metaKey||g.ctrlKey||(g.preventDefault(),n(c.work_id))},"aria-label":a("collated.viewWorkOf",{title:l(m)}),children:a("collated.workArrow")})]}):u),c.author_info&&t.jsx("p",{className:"bim-rd-sub",children:i(l(c.author_info))}),c.content&&c.content.split(/\n+/).map((g,x)=>t.jsx("p",{children:i(l(g))},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 pd(e){return e.some(n=>{const i=zt(n.type);return i==="书"||i==="诗"||i==="考证"||i==="注释"||i==="类"||(i==="序"||i==="结语")&&!!n.content||i==="page_header"&&Ko(n)})}function qg({juan:e,rawText:n,positionLabel:i,groupLabel:o,index:s,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c,prefs:p,view:h,onViewChange:m}){var ne;const{t:u,convert:g,messages:x}=re(),j=mn(),[y,S]=f.useState("text"),b=h??y,w=U=>{S(U),m==null||m(U)},v=a.trim(),k=(s==null?void 0:s.type)==="kaozhen",z=f.useCallback(U=>v?ei(U,v,j):U,[v,j]),C=Fo(p),_=U=>Gi(U,{renderText:z,bookMarking:C,quoteStyle:p.quoteStyle,t:u}),R=f.useMemo(()=>v?e.sections.filter(U=>Vo(U,v,k,j)):e.sections,[e.sections,v,k,j]),T=(U,ee)=>ee.filter(q=>zt(q.type)===U).length,N=T("书",e.sections),E=T("诗",e.sections),W=T("考证",e.sections);let F="";k?F=v?u("collated.countTiaoOf",{m:T("考证",R),n:W}):u("collated.countTiao",{n:W}):E>0?F=v?u("collated.countPoemsOf",{m:T("诗",R),n:E}):u("collated.countPoems",{n:E}):N>0&&(F=v?u("collated.countBooksOf",{m:T("书",R),n:N}):u("collated.countBooks",{n:N}));const A=s!=null&&s.text_quality?Sg(s.text_quality.grade):null,V=[];if(F&&V.push(F),k&&(s!=null&&s.target_source)&&V.push(t.jsx(t.Fragment,{children:u("collated.kaozhenTarget",{target:g(s.target_source)})})),A){const U=t.jsx("span",{className:"bim-rd-grade",style:_g(A),children:x.collated.qualityLabel[A]});V.push(t.jsx("span",{title:x.collated.qualityCriteria[A],children:(ne=s==null?void 0:s.text_quality)!=null&&ne.source_note?t.jsxs(t.Fragment,{children:[Cg(u("collated.baseText",{note:cd}),s.text_quality.source_note,g),U]}):t.jsxs(t.Fragment,{children:[u("collated.textQuality"),U]})}))}e.source_url&&V.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:u("collated.originalSource")}));const ae=!k&&pd(e.sections),xe=!!n&&(!ae||p.readingMode==="paragraph"&&zi(n)),me=!k&&(ae||!!n),G=k||!me?"entries":b;let ye=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&&g(o)]}),t.jsx("h1",{className:"bim-rd-h1",children:g(e.title)}),V.length>0&&t.jsx("p",{className:"bim-rd-meta",children:V.map((U,ee)=>t.jsxs(f.Fragment,{children:[ee>0&&t.jsx("span",{className:"bim-rd-dot"}),U]},ee))}),me&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":u("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":G==="text",onClick:()=>w("text"),children:u("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":G==="entries",onClick:()=>w("entries"),children:u("collated.viewEntries")})]})]}),G==="text"&&t.jsx("article",{className:"bim-rd-prose",children:xe?t.jsx(Ho,{text:n,mode:p.readingMode,bookMarking:C,quoteStyle:p.quoteStyle,renderText:z,dropTitle:e.title}):t.jsx(Yg,{sections:e.sections,onNavigate:l,inline:_,workLinks:p.workLinks})}),G==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:k?t.jsx(Vg,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[R.some(U=>["书","诗","考证"].includes(zt(U.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:u("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:u("collated.rowHeadTitle")}),t.jsx("span",{children:u("collated.rowHeadWork")})]}),R.map((U,ee)=>{const q=zt(U.type);return q==="书"||q==="诗"||q==="考证"?(ye+=1,t.jsx(Og,{domId:`rd-e-${e.sections.indexOf(U)}`,section:U,onNavigate:p.workLinks?l:void 0,highlightQuery:v,no:ye,showUnlinked:p.workLinks&&!!l},ee)):q==="类"?t.jsx(Wg,{section:U,highlightQuery:v},ee):t.jsx(Hg,{section:U,highlightQuery:v},ee)}),R.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:u("collated.noMatch")})]})})]})}function Kg(e){const{resetKey:n,load:i,files:o,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=mn(),h=f.useRef(new Map),[m,u]=f.useState({}),[g,x]=f.useState({}),j=f.useCallback((S,b)=>{const w=b==null?void 0:b.title;w&&x(v=>v[S]===w?v:{...v,[S]:w})},[]);f.useEffect(()=>{s&&a&&(h.current.set(s,{juan:a,rawText:l}),j(s,a))},[s,a,l,j]),f.useEffect(()=>{h.current.clear(),u({}),x({})},[n]);const y=f.useCallback((S,b)=>{let w=0;if(S.juan)for(const v of S.juan.sections)Vo(v,b,c,p)&&w++;return w===0&&S.rawText&&Lg(S.rawText,b,p)&&(w=1),w},[c,p]);return f.useEffect(()=>{const S=d.trim();if(!S){u({});return}if(!i||o.length===0)return;let b=!1;const w={},v=[];for(const R of o){const T=h.current.get(R);T?w[R]=y(T,S):(w[R]="loading",v.push(R))}u(w);const k=8;let z=0;const C=async()=>{for(;z<v.length;){if(b)return;const R=z++,T=v[R];try{const N=await i(T),E=N.juan;if(h.current.set(T,N),j(T,E),b)return;u(W=>({...W,[T]:y(N,S)}))}catch{if(b)return;u(N=>({...N,[T]:0}))}}},_=Array.from({length:Math.min(k,v.length)},()=>C());return Promise.all(_),()=>{b=!0}},[d,n,i,o.join(","),y,p,j]),{matchStates:m,titles:g}}function Xg({juan:e,view:n,onView:i,textHasEntries:o}){const{t:s,convert:a}=re(),l=e.sections.map((h,m)=>({s:h,i:m,t:zt(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 m=()=>{var u,g;return(g=(u=document.getElementById(`rd-e-${h}`))==null?void 0:u.scrollIntoView)==null?void 0:g.call(u,{block:"start",behavior:"smooth"})};n==="text"&&!o&&i("entries"),n==="text"&&!o?setTimeout(m,0):m()};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:m})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${m}`,onClick:u=>{u.preventDefault(),p(m)},children:[t.jsx("span",{className:`bim-rd-rail-dot${h.work_id?" on":""}`,"aria-hidden":"true"}),t.jsx("span",{children:Gi(a(h.book_title||h.title),{t:s})})]})},m))})]})]})}const Zg=`
|
|
1327
1327
|
attribute vec2 a_position; // 目标画布像素坐标 [0, canvasWidth] x [0, canvasHeight]
|
|
1328
1328
|
attribute vec2 a_texCoord; // 原图像素坐标 [0, imgWidth] x [0, imgHeight]
|
|
1329
1329
|
|
|
@@ -1351,7 +1351,7 @@ ${jf}`;function Fn({children:e,style:n,wide:i,grid:o}){return t.jsxs("div",{clas
|
|
|
1351
1351
|
vec4 tex = texture2D(u_image, v_texCoord);
|
|
1352
1352
|
gl_FragColor = vec4(tex.rgb, tex.a * u_alpha);
|
|
1353
1353
|
}
|
|
1354
|
-
`;function Ta(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 Xr{constructor(n){const i=n.getContext("webgl",{alpha:!0,antialias:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1});if(!i)throw new Error("WebGL not supported");this.gl=i;const o=Ta(i,i.VERTEX_SHADER,Zg),s=Ta(i,i.FRAGMENT_SHADER,Jg);if(!o||!s)throw new Error("Failed to create shaders");const a=i.createProgram();if(!a)throw new Error("Failed to create program");if(i.attachShader(a,o),i.attachShader(a,s),i.linkProgram(a),!i.getProgramParameter(a,i.LINK_STATUS))throw new Error("Program link error: "+i.getProgramInfoLog(a));this.program=a,this.positionBuffer=i.createBuffer(),this.texCoordBuffer=i.createBuffer(),this.uResolutionLoc=i.getUniformLocation(a,"u_resolution"),this.uImgResolutionLoc=i.getUniformLocation(a,"u_imgResolution"),this.uAlphaLoc=i.getUniformLocation(a,"u_alpha"),this.aPositionLoc=i.getAttribLocation(a,"a_position"),this.aTexCoordLoc=i.getAttribLocation(a,"a_texCoord"),i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.clear(n.width,n.height)}clear(n,i){const o=this.gl;o.viewport(0,0,o.drawingBufferWidth,o.drawingBufferHeight),o.clearColor(.98,.97,.95,1),o.clear(o.COLOR_BUFFER_BIT)}createTexture(n){const i=this.gl,o=i.createTexture();return i.bindTexture(i.TEXTURE_2D,o),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,n),o}renderStripsWithTexture(n,i,o,s,a,l,d=1){if(l.length===0)return;const c=this.gl;c.viewport(0,0,c.drawingBufferWidth,c.drawingBufferHeight),c.useProgram(this.program),c.uniform2f(this.uResolutionLoc,i,o),c.uniform2f(this.uImgResolutionLoc,s,a),c.uniform1f(this.uAlphaLoc,d);const p=[],h=[],m=8;for(const u of l){const g=u.colOffsetX||0,x=u.colOffsetY||0,{srcQuad:j,dstRect:y}=u.strip,[S,b,w,v]=y,k=g+S,z=x+b,[C,_,R,T]=j;for(let N=0;N<m;N++){const E=N/m,W=(N+1)/m,F=z+v*E,A=z+v*W,V=[C[0]+(T[0]-C[0])*E,C[1]+(T[1]-C[1])*E],ae=[C[0]+(T[0]-C[0])*W,C[1]+(T[1]-C[1])*W],xe=[_[0]+(R[0]-_[0])*E,_[1]+(R[1]-_[1])*E],me=[_[0]+(R[0]-_[0])*W,_[1]+(R[1]-_[1])*W],G=[k,F],ye=[k+w,F],ne=[k,A],U=[k+w,A];p.push(G[0],G[1],ye[0],ye[1],ne[0],ne[1]),h.push(V[0],V[1],xe[0],xe[1],ae[0],ae[1]),p.push(ye[0],ye[1],U[0],U[1],ne[0],ne[1]),h.push(xe[0],xe[1],me[0],me[1],ae[0],ae[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 Qg(e){const[n,i]=e.image_size||[0,0];if(!(n>0)||!(i>0)||e.columns.some(u=>{var g;return(((g=u.strips)==null?void 0:g.length)??0)>0}))return null;let o=1/0,s=1/0,a=-1/0,l=-1/0;for(const u of e.columns)for(const g of u.chars){const[x,j,y,S]=g.bbox_col;![x,j,y,S].every(Number.isFinite)||!(y>x)||!(S>j)||(o=Math.min(o,u.offset_x+x),s=Math.min(s,j),a=Math.max(a,u.offset_x+y),l=Math.max(l,S))}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,m=Math.min(i,Math.max(0,l+d))-p;return!(h>0)||!(m>0)||h>=n*.98&&m>=i*.98?null:{x:c,y:p,w:h,h:m}}const Ia=typeof window>"u"?f.useEffect:f.useLayoutEffect;function ex(e,n){const i=Math.max(1,Math.round(e)),o=Math.max(1,Math.round(n));return`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${i}" height="${o}"/>`)}`}const Sr=[1,1.5,2,3,4,6];function tx(e){for(const n of Sr)if(e<=n)return n;return Sr[Sr.length-1]}function nx(e,n,i,o,s=1){if(!(e>0)||!(n>0))return[1,1];if(i===null||!(i>0))return[1,1];const a=Math.ceil(i*Math.min(Math.max(o,1),2)*tx(s)/64)*64,l=Math.max(1,Math.min(Math.round(e),a)),d=Math.max(1,Math.round(l*n/e));return[l,d]}const Gt=new Map,ix=8;function Zr(e){let n=Gt.get(e);if(n)return Gt.delete(e),Gt.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=()=>{Gt.delete(e),i(null)},o.src=e}),Gt.set(e,n);Gt.size>ix;)Gt.delete(Gt.keys().next().value);return n}const Ko=({imageUrl:e,pageData:n,selectedCharIds:i,hoveredCharId:o,preserveMargins:s=!1,onCharClick:a,onCharHover:l,renderScale:d=1})=>{const c=f.useRef(null),p=f.useRef(null),h=typeof ResizeObserver<"u",[m,u]=f.useState(null);Ia(()=>{const U=p.current;if(!U||typeof ResizeObserver>"u")return;const Q=new ResizeObserver(q=>{var I;const je=((I=q[q.length-1])==null?void 0:I.contentRect.width)??0;u(oe=>oe===je?oe:je)});return Q.observe(U),()=>Q.disconnect()},[]);const g=!h||m!==null&&m>0,x=f.useRef(null),j=f.useRef(null),y=f.useRef(null),S=f.useRef(null),b=f.useRef(null),[w,v]=f.useState(0),[k,z]=f.useState(0),C=f.useRef(""),_=f.useMemo(()=>Math.max(...n.columns.map(U=>U.warped_h),2440),[n]),R=n.total_warped_w,T=n.banxin,N=f.useMemo(()=>{var $e;if(!s)return{top:0,bottom:0,left:0,right:0};const[U,Q]=n.image_size||[2386,3082];let q=1/0,je=-1/0,I=1/0,oe=-1/0;for(const ve of n.columns)for(const Le of ve.strips||[])for(const Ne of Le.srcQuad)Ne[0]<q&&(q=Ne[0]),Ne[0]>je&&(je=Ne[0]),Ne[1]<I&&(I=Ne[1]),Ne[1]>oe&&(oe=Ne[1]);if(($e=n.banxin)!=null&&$e.current_page_strips)for(const ve of n.banxin.current_page_strips)for(const Le of ve.srcQuad)Le[0]<q&&(q=Le[0]),Le[0]>je&&(je=Le[0]),Le[1]<I&&(I=Le[1]),Le[1]>oe&&(oe=Le[1]);return isFinite(q)||(q=0),isFinite(je)||(je=U),isFinite(I)||(I=0),isFinite(oe)||(oe=Q),{top:Math.max(0,Math.round(I)),bottom:Math.max(0,Math.round(Q-oe)),left:Math.max(0,Math.round(q)),right:Math.max(0,Math.round(U-je)),rawMinX:q,rawMaxX:je,rawMinY:I,rawMaxY:oe,imgW:U,imgH:Q}},[n,s]),E=f.useMemo(()=>s?null:Qg(n),[n,s]),W=R+(T?T.total_w:0),F=E?E.w:W+N.left+N.right,A=E?E.h:_+N.top+N.bottom,V=typeof window<"u"&&window.devicePixelRatio||1,[ae,xe]=h?nx(F,A,m,V,d):[Math.round(F),Math.round(A)],me=f.useCallback(()=>{const U=x.current;if(!(!U||!c.current)&&!(e&&C.current!==e)){if(U.clear(F,A),s&&N.rawMinX!==void 0&&S.current&&j.current){const{rawMinX:Q,rawMaxX:q,rawMinY:je,rawMaxY:I,imgW:oe,imgH:$e,top:ve,bottom:Le,left:Ne,right:X}=N,ue=[];Ne>0&&ue.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[Q,0],[Q,$e],[0,$e]],dstRect:[0,0,Ne,A]}}),ve>0&&ue.push({colOffsetX:Ne,colOffsetY:0,strip:{srcQuad:[[Q,0],[q,0],[q,je],[Q,je]],dstRect:[0,0,W,ve]}}),Le>0&&ue.push({colOffsetX:Ne,colOffsetY:ve+_,strip:{srcQuad:[[Q,I],[q,I],[q,$e],[Q,$e]],dstRect:[0,0,W,Le]}}),X>0&&ue.push({colOffsetX:Ne+W,colOffsetY:0,strip:{srcQuad:[[q,0],[oe,0],[oe,$e],[q,$e]],dstRect:[0,0,X,A]}}),U.renderStripsWithTexture(S.current,F,A,n.image_size[0],n.image_size[1],ue,1)}if(S.current&&j.current){const Q=n.columns.flatMap(q=>(q.strips||[]).map(je=>({colOffsetX:N.left+q.offset_x,colOffsetY:N.top,strip:je})));if(Q.length>0?U.renderStripsWithTexture(S.current,F,A,n.image_size[0],n.image_size[1],Q,1):U.renderStripsWithTexture(S.current,F,A,n.image_size[0],n.image_size[1],[{colOffsetX:0,colOffsetY:0,strip:{srcQuad:E?[[E.x,E.y],[E.x+E.w,E.y],[E.x+E.w,E.y+E.h],[E.x,E.y+E.h]]:[[0,0],[n.image_size[0],0],[n.image_size[0],n.image_size[1]],[0,n.image_size[1]]],dstRect:[0,0,F,A]}}],1),T&&T.current_page_strips.length>0){const q=T.current_page_strips.map(je=>({colOffsetX:N.left+R,colOffsetY:N.top,strip:je}));U.renderStripsWithTexture(S.current,F,A,n.image_size[0],n.image_size[1],q,1)}}if(T&&b.current&&y.current&&T.mate_page_strips.length>0){const Q=T.mate_page_strips.map(q=>({colOffsetX:N.left+R+T.half_w,colOffsetY:N.top,strip:q}));U.renderStripsWithTexture(b.current,F,A,T.mate_img_size[0],T.mate_img_size[1],Q,.65)}}},[e,n,T,F,A,R,_,W,N,s,E]),G=f.useRef(me);G.current=me,f.useEffect(()=>{const U=c.current;if(!U)return;const Q=I=>{S.current=j.current?I.createTexture(j.current):null,b.current=y.current?I.createTexture(y.current):null,G.current()};try{const I=new Xr(U);x.current=I,Q(I)}catch(I){console.error("Failed to init WebGL renderer:",I)}const q=I=>{I.preventDefault(),console.warn("WebGL context lost")},je=()=>{console.info("WebGL context restored, re-initializing..."),c.current&&(x.current=new Xr(c.current),Q(x.current))};return U.addEventListener("webglcontextlost",q,!1),U.addEventListener("webglcontextrestored",je,!1),()=>{U.removeEventListener("webglcontextlost",q),U.removeEventListener("webglcontextrestored",je),x.current&&(x.current.deleteTexture(S.current),x.current.deleteTexture(b.current),x.current.destroy(),x.current=null)}},[]),f.useEffect(()=>{if(!e||!g)return;let U=!0;return Zr(e).then(Q=>{if(!U||!Q)return;j.current=Q,C.current=e;const q=x.current;q&&(q.deleteTexture(S.current),S.current=q.createTexture(Q)),v(je=>je+1)}),()=>{U=!1}},[e,g]);const ye=T==null?void 0:T.mate_image_url;f.useEffect(()=>{if(!ye||!g)return;let U=!0;return Zr(ye).then(Q=>{if(!U||!Q)return;y.current=Q;const q=x.current;q&&(q.deleteTexture(b.current),b.current=q.createTexture(Q)),z(je=>je+1)}),()=>{U=!1}},[ye,g]),Ia(()=>{g&&me()},[me,w,k,ae,xe,g]);const ne=f.useMemo(()=>{const U=[];for(const Q of n.columns)for(const q of Q.chars){const[je,I,oe,$e]=q.bbox_col;U.push({id:q.id,char:q.char,x:N.left+Q.offset_x+je-((E==null?void 0:E.x)??0),y:N.top+I-((E==null?void 0:E.y)??0),w:Math.max(oe-je,1),h:Math.max($e-I,1)})}return U},[n,N,E]);return t.jsxs("div",{ref:p,className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${F} / ${A}`,backgroundColor:r("warp-bg"),boxShadow:r("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("img",{alt:"","aria-hidden":"true","data-warp-sizer":"",src:ex(F,A),style:{display:"block",width:"100%",height:"100%",visibility:"hidden"}}),t.jsx("canvas",{ref:c,width:ae,height:xe,"data-logical-size":`${Math.floor(F)}x${Math.floor(A)}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block",backgroundColor:r("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${F} ${A}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[ne.map(U=>{const Q=i.has(U.id),q=o===U.id;return t.jsx("rect",{"data-selected":Q?"true":void 0,x:U.x,y:U.y,width:U.w,height:U.h,fill:Q?r("warp-sel-bg"):q?r("warp-hover-bg"):"transparent",stroke:Q?r("warp-sel-stroke"):q?r("warp-hover-stroke"):"transparent",strokeWidth:Q?3.5:q?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>a==null?void 0:a(U.id),onMouseEnter:()=>l==null?void 0:l(U.id),onMouseLeave:()=>l==null?void 0:l(null),children:t.jsx("title",{children:U.char})},U.id)}),T&&t.jsxs("g",{children:[t.jsx("line",{x1:N.left+R,y1:N.top,x2:N.left+R,y2:N.top+_,stroke:r("warp-banxin-border"),strokeWidth:1.5}),t.jsx("line",{x1:N.left+R+T.half_w,y1:N.top,x2:N.left+R+T.half_w,y2:N.top+_,stroke:r("warp-banxin-fold"),strokeWidth:1.5,strokeDasharray:"8 6"}),t.jsx("line",{x1:N.left+W,y1:N.top,x2:N.left+W,y2:N.top+_,stroke:r("warp-banxin-outer"),strokeWidth:1})]})]})]})},Xo=`
|
|
1354
|
+
`;function Ta(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 Zr{constructor(n){const i=n.getContext("webgl",{alpha:!0,antialias:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1});if(!i)throw new Error("WebGL not supported");this.gl=i;const o=Ta(i,i.VERTEX_SHADER,Zg),s=Ta(i,i.FRAGMENT_SHADER,Jg);if(!o||!s)throw new Error("Failed to create shaders");const a=i.createProgram();if(!a)throw new Error("Failed to create program");if(i.attachShader(a,o),i.attachShader(a,s),i.linkProgram(a),!i.getProgramParameter(a,i.LINK_STATUS))throw new Error("Program link error: "+i.getProgramInfoLog(a));this.program=a,this.positionBuffer=i.createBuffer(),this.texCoordBuffer=i.createBuffer(),this.uResolutionLoc=i.getUniformLocation(a,"u_resolution"),this.uImgResolutionLoc=i.getUniformLocation(a,"u_imgResolution"),this.uAlphaLoc=i.getUniformLocation(a,"u_alpha"),this.aPositionLoc=i.getAttribLocation(a,"a_position"),this.aTexCoordLoc=i.getAttribLocation(a,"a_texCoord"),i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.clear(n.width,n.height)}clear(n,i){const o=this.gl;o.viewport(0,0,o.drawingBufferWidth,o.drawingBufferHeight),o.clearColor(.98,.97,.95,1),o.clear(o.COLOR_BUFFER_BIT)}createTexture(n){const i=this.gl,o=i.createTexture();return i.bindTexture(i.TEXTURE_2D,o),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,n),o}renderStripsWithTexture(n,i,o,s,a,l,d=1){if(l.length===0)return;const c=this.gl;c.viewport(0,0,c.drawingBufferWidth,c.drawingBufferHeight),c.useProgram(this.program),c.uniform2f(this.uResolutionLoc,i,o),c.uniform2f(this.uImgResolutionLoc,s,a),c.uniform1f(this.uAlphaLoc,d);const p=[],h=[],m=8;for(const u of l){const g=u.colOffsetX||0,x=u.colOffsetY||0,{srcQuad:j,dstRect:y}=u.strip,[S,b,w,v]=y,k=g+S,z=x+b,[C,_,R,T]=j;for(let N=0;N<m;N++){const E=N/m,W=(N+1)/m,F=z+v*E,A=z+v*W,V=[C[0]+(T[0]-C[0])*E,C[1]+(T[1]-C[1])*E],ae=[C[0]+(T[0]-C[0])*W,C[1]+(T[1]-C[1])*W],xe=[_[0]+(R[0]-_[0])*E,_[1]+(R[1]-_[1])*E],me=[_[0]+(R[0]-_[0])*W,_[1]+(R[1]-_[1])*W],G=[k,F],ye=[k+w,F],ne=[k,A],U=[k+w,A];p.push(G[0],G[1],ye[0],ye[1],ne[0],ne[1]),h.push(V[0],V[1],xe[0],xe[1],ae[0],ae[1]),p.push(ye[0],ye[1],U[0],U[1],ne[0],ne[1]),h.push(xe[0],xe[1],me[0],me[1],ae[0],ae[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 Qg(e){const[n,i]=e.image_size||[0,0];if(!(n>0)||!(i>0)||e.columns.some(u=>{var g;return(((g=u.strips)==null?void 0:g.length)??0)>0}))return null;let o=1/0,s=1/0,a=-1/0,l=-1/0;for(const u of e.columns)for(const g of u.chars){const[x,j,y,S]=g.bbox_col;![x,j,y,S].every(Number.isFinite)||!(y>x)||!(S>j)||(o=Math.min(o,u.offset_x+x),s=Math.min(s,j),a=Math.max(a,u.offset_x+y),l=Math.max(l,S))}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,m=Math.min(i,Math.max(0,l+d))-p;return!(h>0)||!(m>0)||h>=n*.98&&m>=i*.98?null:{x:c,y:p,w:h,h:m}}const Ia=typeof window>"u"?f.useEffect:f.useLayoutEffect;function ex(e,n){const i=Math.max(1,Math.round(e)),o=Math.max(1,Math.round(n));return`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${i}" height="${o}"/>`)}`}const _r=[1,1.5,2,3,4,6];function tx(e){for(const n of _r)if(e<=n)return n;return _r[_r.length-1]}function nx(e,n,i,o,s=1){if(!(e>0)||!(n>0))return[1,1];if(i===null||!(i>0))return[1,1];const a=Math.ceil(i*Math.min(Math.max(o,1),2)*tx(s)/64)*64,l=Math.max(1,Math.min(Math.round(e),a)),d=Math.max(1,Math.round(l*n/e));return[l,d]}const Xt=new Map,ix=8;function Jr(e){let n=Xt.get(e);if(n)return Xt.delete(e),Xt.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=()=>{Xt.delete(e),i(null)},o.src=e}),Xt.set(e,n);Xt.size>ix;)Xt.delete(Xt.keys().next().value);return n}const Xo=({imageUrl:e,pageData:n,selectedCharIds:i,hoveredCharId:o,preserveMargins:s=!1,onCharClick:a,onCharHover:l,renderScale:d=1})=>{const c=f.useRef(null),p=f.useRef(null),h=typeof ResizeObserver<"u",[m,u]=f.useState(null);Ia(()=>{const U=p.current;if(!U||typeof ResizeObserver>"u")return;const ee=new ResizeObserver(q=>{var I;const je=((I=q[q.length-1])==null?void 0:I.contentRect.width)??0;u(oe=>oe===je?oe:je)});return ee.observe(U),()=>ee.disconnect()},[]);const g=!h||m!==null&&m>0,x=f.useRef(null),j=f.useRef(null),y=f.useRef(null),S=f.useRef(null),b=f.useRef(null),[w,v]=f.useState(0),[k,z]=f.useState(0),C=f.useRef(""),_=f.useMemo(()=>Math.max(...n.columns.map(U=>U.warped_h),2440),[n]),R=n.total_warped_w,T=n.banxin,N=f.useMemo(()=>{var $e;if(!s)return{top:0,bottom:0,left:0,right:0};const[U,ee]=n.image_size||[2386,3082];let q=1/0,je=-1/0,I=1/0,oe=-1/0;for(const ve of n.columns)for(const Le of ve.strips||[])for(const Te of Le.srcQuad)Te[0]<q&&(q=Te[0]),Te[0]>je&&(je=Te[0]),Te[1]<I&&(I=Te[1]),Te[1]>oe&&(oe=Te[1]);if(($e=n.banxin)!=null&&$e.current_page_strips)for(const ve of n.banxin.current_page_strips)for(const Le of ve.srcQuad)Le[0]<q&&(q=Le[0]),Le[0]>je&&(je=Le[0]),Le[1]<I&&(I=Le[1]),Le[1]>oe&&(oe=Le[1]);return isFinite(q)||(q=0),isFinite(je)||(je=U),isFinite(I)||(I=0),isFinite(oe)||(oe=ee),{top:Math.max(0,Math.round(I)),bottom:Math.max(0,Math.round(ee-oe)),left:Math.max(0,Math.round(q)),right:Math.max(0,Math.round(U-je)),rawMinX:q,rawMaxX:je,rawMinY:I,rawMaxY:oe,imgW:U,imgH:ee}},[n,s]),E=f.useMemo(()=>s?null:Qg(n),[n,s]),W=R+(T?T.total_w:0),F=E?E.w:W+N.left+N.right,A=E?E.h:_+N.top+N.bottom,V=typeof window<"u"&&window.devicePixelRatio||1,[ae,xe]=h?nx(F,A,m,V,d):[Math.round(F),Math.round(A)],me=f.useCallback(()=>{const U=x.current;if(!(!U||!c.current)&&!(e&&C.current!==e)){if(U.clear(F,A),s&&N.rawMinX!==void 0&&S.current&&j.current){const{rawMinX:ee,rawMaxX:q,rawMinY:je,rawMaxY:I,imgW:oe,imgH:$e,top:ve,bottom:Le,left:Te,right:Z}=N,ue=[];Te>0&&ue.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[ee,0],[ee,$e],[0,$e]],dstRect:[0,0,Te,A]}}),ve>0&&ue.push({colOffsetX:Te,colOffsetY:0,strip:{srcQuad:[[ee,0],[q,0],[q,je],[ee,je]],dstRect:[0,0,W,ve]}}),Le>0&&ue.push({colOffsetX:Te,colOffsetY:ve+_,strip:{srcQuad:[[ee,I],[q,I],[q,$e],[ee,$e]],dstRect:[0,0,W,Le]}}),Z>0&&ue.push({colOffsetX:Te+W,colOffsetY:0,strip:{srcQuad:[[q,0],[oe,0],[oe,$e],[q,$e]],dstRect:[0,0,Z,A]}}),U.renderStripsWithTexture(S.current,F,A,n.image_size[0],n.image_size[1],ue,1)}if(S.current&&j.current){const ee=n.columns.flatMap(q=>(q.strips||[]).map(je=>({colOffsetX:N.left+q.offset_x,colOffsetY:N.top,strip:je})));if(ee.length>0?U.renderStripsWithTexture(S.current,F,A,n.image_size[0],n.image_size[1],ee,1):U.renderStripsWithTexture(S.current,F,A,n.image_size[0],n.image_size[1],[{colOffsetX:0,colOffsetY:0,strip:{srcQuad:E?[[E.x,E.y],[E.x+E.w,E.y],[E.x+E.w,E.y+E.h],[E.x,E.y+E.h]]:[[0,0],[n.image_size[0],0],[n.image_size[0],n.image_size[1]],[0,n.image_size[1]]],dstRect:[0,0,F,A]}}],1),T&&T.current_page_strips.length>0){const q=T.current_page_strips.map(je=>({colOffsetX:N.left+R,colOffsetY:N.top,strip:je}));U.renderStripsWithTexture(S.current,F,A,n.image_size[0],n.image_size[1],q,1)}}if(T&&b.current&&y.current&&T.mate_page_strips.length>0){const ee=T.mate_page_strips.map(q=>({colOffsetX:N.left+R+T.half_w,colOffsetY:N.top,strip:q}));U.renderStripsWithTexture(b.current,F,A,T.mate_img_size[0],T.mate_img_size[1],ee,.65)}}},[e,n,T,F,A,R,_,W,N,s,E]),G=f.useRef(me);G.current=me,f.useEffect(()=>{const U=c.current;if(!U)return;const ee=I=>{S.current=j.current?I.createTexture(j.current):null,b.current=y.current?I.createTexture(y.current):null,G.current()};try{const I=new Zr(U);x.current=I,ee(I)}catch(I){console.error("Failed to init WebGL renderer:",I)}const q=I=>{I.preventDefault(),console.warn("WebGL context lost")},je=()=>{console.info("WebGL context restored, re-initializing..."),c.current&&(x.current=new Zr(c.current),ee(x.current))};return U.addEventListener("webglcontextlost",q,!1),U.addEventListener("webglcontextrestored",je,!1),()=>{U.removeEventListener("webglcontextlost",q),U.removeEventListener("webglcontextrestored",je),x.current&&(x.current.deleteTexture(S.current),x.current.deleteTexture(b.current),x.current.destroy(),x.current=null)}},[]),f.useEffect(()=>{if(!e||!g)return;let U=!0;return Jr(e).then(ee=>{if(!U||!ee)return;j.current=ee,C.current=e;const q=x.current;q&&(q.deleteTexture(S.current),S.current=q.createTexture(ee)),v(je=>je+1)}),()=>{U=!1}},[e,g]);const ye=T==null?void 0:T.mate_image_url;f.useEffect(()=>{if(!ye||!g)return;let U=!0;return Jr(ye).then(ee=>{if(!U||!ee)return;y.current=ee;const q=x.current;q&&(q.deleteTexture(b.current),b.current=q.createTexture(ee)),z(je=>je+1)}),()=>{U=!1}},[ye,g]),Ia(()=>{g&&me()},[me,w,k,ae,xe,g]);const ne=f.useMemo(()=>{const U=[];for(const ee of n.columns)for(const q of ee.chars){const[je,I,oe,$e]=q.bbox_col;U.push({id:q.id,char:q.char,x:N.left+ee.offset_x+je-((E==null?void 0:E.x)??0),y:N.top+I-((E==null?void 0:E.y)??0),w:Math.max(oe-je,1),h:Math.max($e-I,1)})}return U},[n,N,E]);return t.jsxs("div",{ref:p,className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${F} / ${A}`,backgroundColor:r("warp-bg"),boxShadow:r("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("img",{alt:"","aria-hidden":"true","data-warp-sizer":"",src:ex(F,A),style:{display:"block",width:"100%",height:"100%",visibility:"hidden"}}),t.jsx("canvas",{ref:c,width:ae,height:xe,"data-logical-size":`${Math.floor(F)}x${Math.floor(A)}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block",backgroundColor:r("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${F} ${A}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[ne.map(U=>{const ee=i.has(U.id),q=o===U.id;return t.jsx("rect",{"data-selected":ee?"true":void 0,x:U.x,y:U.y,width:U.w,height:U.h,fill:ee?r("warp-sel-bg"):q?r("warp-hover-bg"):"transparent",stroke:ee?r("warp-sel-stroke"):q?r("warp-hover-stroke"):"transparent",strokeWidth:ee?3.5:q?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>a==null?void 0:a(U.id),onMouseEnter:()=>l==null?void 0:l(U.id),onMouseLeave:()=>l==null?void 0:l(null),children:t.jsx("title",{children:U.char})},U.id)}),T&&t.jsxs("g",{children:[t.jsx("line",{x1:N.left+R,y1:N.top,x2:N.left+R,y2:N.top+_,stroke:r("warp-banxin-border"),strokeWidth:1.5}),t.jsx("line",{x1:N.left+R+T.half_w,y1:N.top,x2:N.left+R+T.half_w,y2:N.top+_,stroke:r("warp-banxin-fold"),strokeWidth:1.5,strokeDasharray:"8 6"}),t.jsx("line",{x1:N.left+W,y1:N.top,x2:N.left+W,y2:N.top+_,stroke:r("warp-banxin-outer"),strokeWidth:1})]})]})]})},Zo=`
|
|
1355
1355
|
.bim-et-w { position: relative; display: inline; }
|
|
1356
1356
|
.bim-et {
|
|
1357
1357
|
color: inherit; text-decoration-line: underline;
|
|
@@ -1393,17 +1393,17 @@ a.bim-et:focus-visible { outline: 2px solid ${r("accent")}; outline-offset: 2px;
|
|
|
1393
1393
|
.bim-et-card { animation: bim-et-in 120ms ease-out; }
|
|
1394
1394
|
@keyframes bim-et-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
|
|
1395
1395
|
}
|
|
1396
|
-
`,rx=120;function xt(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function ox(e,n=rx){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 sx(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 ax(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(i=>{if(!i||typeof i!="object")return"";const o=i,s=xt(o.name);return s?[xt(o.dynasty)&&`〔${xt(o.dynasty)}〕`,s,xt(o.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function ud(e,n){const i=xt(n.type),o=xt(n.primary_name)??xt(n.title)??e,s=i==="entity"?[xt(n.dynasty),sx(n),xt(n.native_place)].filter(Boolean).join(" · "):[ax(n),xt(n.edition),xt(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?xt(n.description.text):xt(n.description);return{id:xt(n.id)??e,type:i,title:o,meta:s||void 0,description:ox(a)}}function md(e){const n=[e.dynasty,e.author,e.edition].filter(Boolean).join(" · ");return{id:e.id,type:e.type,title:e.title,meta:n||void 0}}function hd(e){return async n=>{const i=await e.getItem(n);if(i)return ud(n,i);if(e.getEntry){const o=await e.getEntry(n);if(o)return md(o)}return null}}const Ra=new WeakMap;function lx(e,n,i){let o=Ra.get(e);o||(o=new Map,Ra.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 fd=e=>`/item/${encodeURIComponent(e)}`,Ea={work:"書名",people:"人名",place:"地名",office:"官職",dynasty:"朝代",reign:"年號",other:"專名"},cx=typeof window>"u"?f.useEffect:f.useLayoutEffect;function Zo(e,n){return f.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:hd(e)}:null,[n,e])}const dx=e=>e,px=({text:e,entities:n,offsets:i="text",plainBase:o=0,transport:s,loadSummary:a,buildHref:l=fd,onNavigate:d,renderText:c=dx,hoverDelayMs:p=250,closeDelayMs:h,injectStyles:m=!0,className:u})=>{const g=f.useMemo(()=>{const j=i==="plain"?ad(e,n,o):n;return ld(e,j)},[e,n,i,o]),x=Zo(s,a);return t.jsxs("span",{className:u?`bim-et-root ${u}`:"bim-et-root",children:[m&&t.jsx("style",{children:Xo}),g.map(j=>j.type==="text"?t.jsx(f.Fragment,{children:c(j.text)},`t${j.start}`):t.jsx(Jo,{span:j.span,label:j.text,hasBrackets:e[j.start-1]==="《"&&e[j.start+j.text.length]==="》",loader:x,buildHref:l,onNavigate:d,renderText:c,hoverDelayMs:p,closeDelayMs:h},`${j.span.key}@${j.start}`))]})};let Yt=null;const Jo=({span:e,label:n,hasBrackets:i,plain:o,loader:s,buildHref:a,onNavigate:l,onCardNavigate:d=l,cardNewTab:c,renderText:p,hoverDelayMs:h,closeDelayMs:m=280})=>{const u=f.useId(),[g,x]=f.useState(!1),[j,y]=f.useState(!1),S=f.useRef(null),b=f.useRef(null),w=`bim-et bim-et-${e.kind}${o?" bim-et-nu":""}`,v=e.kind==="work"&&!i,k=t.jsxs(t.Fragment,{children:[v&&t.jsx("span",{className:"bim-et-sr",children:"《"}),p(n),v&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),z=()=>{S.current&&(clearTimeout(S.current),S.current=null)},C=()=>{b.current&&(clearTimeout(b.current),b.current=null)},_=f.useCallback(()=>{z(),C(),x(!1),y(!1),Yt===_&&(Yt=null)},[]);f.useEffect(()=>()=>{z(),C(),Yt===_&&(Yt=null)},[_]);const R=f.useCallback(()=>{Yt&&Yt!==_&&Yt(),Yt=_,x(!0)},[_]),T=f.useCallback(A=>{C(),y(!0),!g&&(z(),A<=0?R():S.current=setTimeout(R,A))},[g,R]),N=f.useCallback(()=>{z(),C(),b.current=setTimeout(_,m)},[_,m]),E=!!e.targetId,W=e.targetId,F={className:"bim-et-w","data-active":j?"":void 0,onMouseEnter:()=>T(h),onMouseLeave:N,onBlur:A=>{A.currentTarget.contains(A.relatedTarget)||_()},onKeyDown:A=>{A.key==="Escape"&&g&&(A.stopPropagation(),_())}};return!E||!W?t.jsxs("span",{...F,children:[t.jsx("span",{className:w,children:k}),g&&t.jsx(La,{id:u,entityId:null,span:e,loader:null,buildHref:a,onNavigate:l})]}):t.jsxs("span",{...F,children:[t.jsx("a",{className:w,href:a(W),"data-entity-id":W,"aria-describedby":g?u:void 0,onFocus:()=>T(0),onClick:l?A=>l(W,A):void 0,children:k}),g&&t.jsx(La,{id:u,entityId:W,span:e,loader:s,buildHref:a,onNavigate:c?void 0:d,newTab:c})]})},La=({id:e,entityId:n,span:i,loader:o,buildHref:s,onNavigate:a,newTab:l})=>{const{convert:d,t:c}=re(),p=f.useRef(null),[h,m]=f.useState("start"),[u,g]=f.useState(o&&n?{status:"loading"}:{status:"ready",summary:null});f.useEffect(()=>{if(!o||!n)return;let y=!1;return g({status:"loading"}),lx(o.owner,o.load,n).then(S=>{y||g({status:"ready",summary:S})}).catch(()=>{y||g({status:"error"})}),()=>{y=!0}},[o,n]),cx(()=>{const y=p.current;if(!y||typeof window>"u")return;const S=y.getBoundingClientRect(),b=document.documentElement.clientWidth||window.innerWidth;S.right>b-8&&h==="start"&&m("end")},[u,h]);const x=u.status==="ready"?u.summary:null,j=(x==null?void 0:x.title)??i.canonicalName??i.text;return n?t.jsxs("span",{ref:p,id:e,role:"tooltip",className:"bim-et-card","data-align":h,children:[t.jsx("span",{className:"bim-et-card-k",children:d(Ea[i.kind])}),j&&t.jsx("span",{className:"bim-et-card-t",children:d(j)}),(x==null?void 0:x.meta)&&t.jsx("span",{className:"bim-et-card-m",children:d(x.meta)}),(x==null?void 0:x.description)&&t.jsx("span",{className:"bim-et-card-d",children:d(x.description)}),u.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:d("載入中…")}),u.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:d("摘要載入失敗")}),x&&t.jsx("a",{className:"bim-et-card-a",href:s(x.id||n),...l?{target:"_blank",rel:"noopener"}:{},onClick:a?y=>a(x.id||n,y):void 0,children:c("reader.entityDetail")})]}):t.jsx("span",{ref:p,id:e,role:"tooltip",className:"bim-et-card","data-align":h,children:t.jsx("span",{className:"bim-et-card-k",children:d(Ea[i.kind])})})},ux=e=>`/item/${encodeURIComponent(e)}`;function mx(e){const n=e.filter(i=>i.kind==null||i.kind==="point");return{before:n.filter(i=>i.pos==="before"),after:n.filter(i=>i.pos!=="before")}}function hx(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 Qo=({pageData:e,pages:n,punctuations:i=bx,selectedCharIds:o,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:h,convert:m,scrollToPage:u,scrollToAnchor:g,onVisibleHeadingChange:x,entities:j,entityTransport:y,loadEntitySummary:S,buildEntityHref:b,onEntityNavigate:w,pageBreaks:v=!0,pageIndicatorY:k,onPageIndicatorYChange:z,quoteStyle:C,bookTitleStyle:_,showWorks:R})=>{var Ye,et,Ze;const T=f.useRef(null),N=f.useRef(0),E=f.useMemo(()=>{const $=new Map;return p&&i.forEach((M,P)=>{const K=M.id?M:{...M,id:`${M.anchor}#${P}`},he=$.get(K.anchor)||[];he.push(K),$.set(K.anchor,he)}),$},[i,p]),W=f.useMemo(()=>C===void 0&&_===void 0&&R===void 0?null:{quoteStyle:C??"original",hideBookBrackets:_==="wavy"||R===!1},[C,_,R]),F=_==="bracket",A=f.useMemo(()=>{var Y;const $=n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}],M=new Map;for(const H of $)for(const fe of H.columns)fe.chars.length>0&&!fe.raised&&M.set(fe.lead_blank||0,(M.get(fe.lead_blank||0)||0)+1);let P=0,K=-1;for(const[H,fe]of M)(fe>K||fe===K&&H<P)&&(P=H,K=fe);const he=H=>!!H.raised||(H.lead_blank||0)<P,se=$.filter(H=>H.columns.some(fe=>fe.chars.length>0)).map(H=>{const fe=[...H.columns].sort((Ue,dt)=>Ue.col-dt.col),Ce=[];let be=[];const J=()=>{const Ue=jx(E.get(be[0].charData.id));Ce.push({id:`para-p${H.page}-${Ce.length}`,chars:be,...Ue?{heading:{level:Ue.mark.length,anchor:be[0].charData.id,...Ue.toc===!1?{toc:!1}:{}}}:{}}),be=[]};let Ee=!1,ge=0,Oe;for(const Ue of fe){if(Ue.chars.length===0){Ue.kind==="blank"&&ge++;continue}const dt=Ue.raised||Ue.lead_blank||ge?{raised:Ue.raised,leadBlank:Ue.lead_blank,blankBefore:ge}:void 0;ge=0,he(Ue)||(Oe=Ue.lead_blank||0);let at=!0;for(const Ke of Ue.chars){const Je=E.get(Ke.id)||[],{before:ee,after:Fe}=mx(Je),pt=Je.some(mt=>mt.kind==="break"&&mt.pos!=="before");Je.some(mt=>mt.kind==="heading")&&(be.length>0?J():Ce.length===0&&(Ee=!0)),be.push({charData:Ke,col:Ue.col,beforePuncts:ee,afterPuncts:Fe,...at&&dt?{start:dt}:{}}),at=!1,pt&&J()}}const Se=be.length>0;return Se&&J(),{page:H.page,paragraphs:Ce,endsOpen:Se,...Oe!==void 0?{tailLead:Oe}:{},...Ee?{leadStarts:Ee}:{},...H.label?{label:H.label}:{},...ge>0?{trailingBlank:ge}:{}}}),We=new Map;if(!v){let H=null;for(const fe of se){const Ce=fe.paragraphs[0],be=(Y=Ce==null?void 0:Ce.chars[0])==null?void 0:Y.start,J=(be==null?void 0:be.leadBlank)||0,Ee=!!be&&!be.raised&&J>=P&&J>((H==null?void 0:H.tailLead)??P),ge=!!fe.leadStarts||!!(be!=null&&be.blankBefore)||Ee,Oe=fe.paragraphs.length===1&&!!fe.trailingBlank;if(H&&Ce&&!ge&&!Oe){for(const Se of Ce.chars)We.set(Se.charData.id,H.owner);H.para.chars=H.para.chars.concat(Ce.chars),fe.leadFirstId=Ce.chars[0].charData.id,fe.paragraphs=fe.paragraphs.slice(1)}if(fe.endsOpen&&!fe.trailingBlank){const Se=fe.paragraphs[fe.paragraphs.length-1];Se?H={para:Se,owner:fe.page,tailLead:fe.tailLead??(H==null?void 0:H.tailLead)??P}:H&&fe.tailLead!==void 0&&(H.tailLead=fe.tailLead)}else H=null}}const Be=new Map;for(const H of se)H.leadFirstId&&Be.set(H.leadFirstId,H.page);return{pages:se,mergedOwner:We,pageStarts:Be}},[n,e,E,v]),V=A.pages,ae=f.useRef(V);ae.current=V;const xe=f.useMemo(()=>V.map($=>$.paragraphs.reduce((M,P)=>M+P.chars.length,0)),[V]),me=f.useCallback(($,M)=>{let P=$,K=0;for(;P<xe.length&&(P===$||K+xe[P]<=M);)K+=xe[P++];return P},[xe]),G=`${V.length}:${((Ze=(et=(Ye=V[0])==null?void 0:Ye.paragraphs[0])==null?void 0:et.chars[0])==null?void 0:Ze.charData.id)??""}`,[ye,ne]=f.useState(()=>({sig:G,n:me(0,Aa)}));let U=ye.n;ye.sig!==G&&(U=me(0,Aa),ne({sig:G,n:U})),U=Math.min(U,V.length);const Q=U>=V.length;f.useEffect(()=>Q?void 0:(M=>{const P=window;if(P.requestIdleCallback){const he=P.requestIdleCallback(M,{timeout:300});return()=>{var se;return(se=P.cancelIdleCallback)==null?void 0:se.call(P,he)}}const K=setTimeout(M,16);return()=>clearTimeout(K)})(()=>ne(M=>M.sig===G?{sig:M.sig,n:Math.max(M.n,me(M.n,fx))}:M)),[Q,U,G,me]);const q=f.useCallback($=>{const M=ae.current.findIndex(K=>K.page>=$),P=(M<0?ae.current.length:M)+2;ne(K=>K.n>=P?K:{...K,n:P})},[]),je=Q?V:V.slice(0,U);f.useEffect(()=>{let $;const M=requestAnimationFrame(()=>{$=setTimeout(()=>{const P=T.current,K=P==null?void 0:P.querySelector(".guji-reflow-paragraph");if(!P||!K)return;const he=getComputedStyle(K),se=parseFloat(he.fontSize),We=K.clientWidth;if(!(se>0)||!(We>0))return;const Be=parseFloat(he.lineHeight);P.style.setProperty("--gtv-cpl",String(Math.max(8,Math.floor(We/se)))),P.style.setProperty("--gtv-lh",`${Math.round(Be>0?Be:se*2)}px`)},0)});return()=>{cancelAnimationFrame(M),$&&clearTimeout($)}},[G]);const I=f.useMemo(()=>{const $=[];for(const M of V)for(const P of M.paragraphs)for(const K of P.chars)$.push(K.charData.id);return $},[V]),oe=f.useMemo(()=>{const $=new Map;if(!j||j.length===0)return $;const M=new Map(I.map((P,K)=>[P,K]));for(const P of j){if(!P.anchor)continue;const K=M.get(P.anchor.start),he=M.get(P.anchor.end);if(!(K===void 0||he===void 0||he<K))for(let se=K;se<=he;se++)$.has(I[se])||$.set(I[se],P)}return $},[j,I]),$e=Zo(y,S),ve=oe.size>0,Le=f.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:w,onVisibleHeadingChange:x});Le.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:w,onVisibleHeadingChange:x};const Ne=f.useMemo(()=>({click:$=>{var M,P;N.current=Date.now()+1200,(P=(M=Le.current).onCharClick)==null||P.call(M,$)},enter:$=>{var M,P;return(P=(M=Le.current).onCharHover)==null?void 0:P.call(M,$)},leave:()=>{var $,M;return(M=($=Le.current).onCharHover)==null?void 0:M.call($,null)},navigate:($,M)=>{M.ctrlKey||M.metaKey||M.shiftKey||(M.preventDefault(),M.detail===0&&window.open(M.currentTarget.href,"_blank","noopener"))}}),[]),X=yx(o,A.mergedOwner),ue=f.useRef(U);ue.current=U;const Pe=f.useRef(null),Me=f.useCallback($=>{const M=Pe.current,P=M==null?void 0:M.map.get($);if(P&&P.isConnected)return P;if(M&&M.for===ae.current&&M.n===ue.current&&!P)return null;const K=T.current;if(!K)return null;const he=new Map;return K.querySelectorAll("span[data-char-id]").forEach(se=>{he.set(se.getAttribute("data-char-id"),se)}),Pe.current={for:ae.current,n:ue.current,map:he},he.get($)??null},[]),ke=f.useRef(null);f.useEffect(()=>{var M;if((M=ke.current)==null||M.classList.remove("is-hovered"),ke.current=null,!s)return;const $=Me(s);$&&($.classList.add("is-hovered"),ke.current=$)},[s,Me]);const D=f.useRef(null),le=$=>{var P;const M=$ instanceof Element?$.closest("span[data-char-id]"):null;return M&&((P=T.current)!=null&&P.contains(M))?M.getAttribute("data-char-id"):null},ce=$=>{const M=le($.target);M&&Ne.click(M)},Z=$=>{const M=le($.target);M!==D.current&&(D.current=M,M?Ne.enter(M):Ne.leave())},we=()=>{D.current!==null&&(D.current=null,Ne.leave())};f.useEffect(()=>{let $=null;const M=()=>{var ge,Oe;$=null;const K=window.getSelection(),he=T.current;if(!K||K.isCollapsed||K.rangeCount===0||!he)return;const se=K.getRangeAt(0),We=se.commonAncestorContainer,Be=We.nodeType===3?We.parentElement:We;if(!Be||!he.contains(Be))return;const Y=he.querySelectorAll("span[data-char-id]"),H=Se=>Se.firstChild??Se;let fe=0,Ce=Y.length;for(;fe<Ce;){const Se=fe+Ce>>1;se.comparePoint(H(Y[Se]),0)<0?fe=Se+1:Ce=Se}const be=fe;for(Ce=Y.length;fe<Ce;){const Se=fe+Ce>>1;se.comparePoint(H(Y[Se]),0)<=0?fe=Se+1:Ce=Se}let J=fe-1;if(J>=be&&se.endOffset===0&&se.endContainer===H(Y[J])&&J--,J<be)return;const Ee=[];for(let Se=be;Se<=J;Se++)Ee.push(Y[Se].getAttribute("data-char-id"));Ee.length>0&&(N.current=Date.now()+1200,(Oe=(ge=Le.current).onSelectionChange)==null||Oe.call(ge,Ee))},P=()=>{$&&clearTimeout($),$=setTimeout(M,120)};return document.addEventListener("selectionchange",P),()=>{document.removeEventListener("selectionchange",P),$&&clearTimeout($)}},[]);const He=f.useRef(null);f.useEffect(()=>{if(o.size!==1||He.current===o)return;const $=Array.from(o)[0],M=Me($);if(M)He.current=o,M.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"});else{const P=parseInt($.split(":")[0],10);isNaN(P)||q(P)}},[o,U,Me,q]);const Ge=$=>{var K;const M=T.current;if(!M)return null;const P=(K=V.find(he=>he.page===$))==null?void 0:K.leadFirstId;return P?M.querySelector(`span[data-char-id="${P}"]`):M.querySelector(`[data-page-section="${$}"]`)},Xe=u==null?void 0:u.nonce,O=f.useRef(null);f.useEffect(()=>{if(!u||O.current===u.nonce)return;const $=Ge(u.page);if(!$){!Q&&V.some(M=>M.page>=u.page)&&q(u.page);return}O.current=u.nonce,N.current=Date.now()+800,$.scrollIntoView({behavior:"auto",block:"start"})},[Xe,U]);const de=f.useRef(null);f.useEffect(()=>{var he,se;if(!g||de.current===g.nonce)return;const $=T.current,M=$==null?void 0:$.querySelector(`span[data-char-id="${kx(g.anchor)}"]`);if(!M){const We=parseInt(g.anchor.split(":")[0],10);!Q&&!isNaN(We)&&q(We);return}de.current=g.nonce;const P=M.closest(".guji-reflow-paragraph")??M;N.current=Date.now()+800,P.scrollIntoView({behavior:"auto",block:"start"});const K=parseInt(g.anchor.split(":")[0],10);isNaN(K)||(se=(he=Le.current).onVisiblePageChange)==null||se.call(he,K)},[g,V,U,Q,q]);const Te=!!h||!!x,B=!!h&&typeof k=="number",[pe,ie]=f.useState(null),_e=Jr(pe??k??0),Re=f.useRef(null);Re.current=B?_e:null;const De=f.useRef(()=>{});return f.useEffect(()=>{var Ce,be;if(!Te)return;const $=new Map,M=new Map;(Ce=T.current)==null||Ce.querySelectorAll("[data-page-section],[data-page-start]").forEach(J=>{const Ee=J.getAttribute("data-page-section");Ee!==null?$.set(Ee,J):M.set(J.getAttribute("data-page-start"),J)});const P=[],K=[];for(const J of je){const Ee=$.get(String(J.page));Ee&&(P.push(Ee),K.push(J.page))}if(P.length===0)return;const he=new Map(P.map((J,Ee)=>[J,Ee])),se=P.map(()=>[]);let We=0;(be=T.current)==null||be.querySelectorAll('.guji-reflow-heading:not([data-heading-toc="0"])').forEach(J=>{const Ee=he.get(J.closest("[data-page-section]"));Ee!==void 0&&(se[Ee].push(J),We++)});let Be,Y=0;const H=()=>{var dt,at;if(Y=0,Date.now()<N.current)return;const J=Ke=>Ke.getBoundingClientRect().top;if(P.length>1&&J(P[0])===J(P[P.length-1]))return;const Ee=Re.current===null?120:Re.current*window.innerHeight;let ge=0,Oe=P.length-1;for(;ge<Oe;){const Ke=ge+Oe+1>>1;J(P[Ke])<=Ee?ge=Ke:Oe=Ke-1}const Se=J(P[0])>Ee;let Ue=K[ge];for(let Ke=ge+1;Ke<P.length;Ke++){const Je=M.get(String(K[Ke]));if(!Je||!P[ge].contains(Je)||J(Je)>Ee)break;Ue=K[Ke]}if(We>0&&Le.current.onVisibleHeadingChange){let Ke=null;if(!Se){const ee=se[ge];for(let Fe=ee.length-1;Fe>=0&&!Ke;Fe--)J(ee[Fe])<=Ee&&(Ke=ee[Fe]);for(let Fe=ge-1;Fe>=0&&!Ke;Fe--)se[Fe].length>0&&(Ke=se[Fe][se[Fe].length-1])}const Je=Ke?vx(Ke):null;Je!==Be&&(Be=Je,Le.current.onVisibleHeadingChange(Je))}(at=(dt=Le.current).onVisiblePageChange)==null||at.call(dt,Ue)},fe=()=>{Y||(Y=requestAnimationFrame(H))};return De.current=()=>{Y||(Y=requestAnimationFrame(H))},window.addEventListener("scroll",fe,{passive:!0}),fe(),()=>{window.removeEventListener("scroll",fe),Y&&cancelAnimationFrame(Y),De.current=()=>{}}},[Te,V,U]),f.useEffect(()=>{B&&De.current()},[B,_e]),t.jsxs("div",{ref:T,className:"guji-text-pane-content",onClick:ce,onMouseOver:Z,onMouseLeave:we,children:[ve&&t.jsx("style",{children:Xo}),B&&t.jsx(zx,{y:_e,containerRef:T,onDrag:ie,onCommit:$=>{ie(null),z==null||z($)}}),t.jsx("div",{className:"guji-text-reflow-view",children:je.map(($,M)=>t.jsx(_x,{pGroup:$,first:M===0,pageBreaks:v,markOpts:W,plainBooks:F,selected:X.get($.page)??xx,entityOfChar:oe,entityLoader:$e,convert:m,buildHref:b??ux,handlers:Ne,charCount:xe[M]??0,pageStarts:A.pageStarts},`page-sec-${$.page}`))})]})},Aa=1800,fx=800,gx="auto calc((var(--gtv-pc) / var(--gtv-cpl, 30) + var(--gtv-pp) * 1.4) * var(--gtv-lh, 44px) + 64px)",xx=new Set,bx=[];function yx(e,n){const i=f.useRef(new Map);return f.useMemo(()=>{const o=new Map;e.forEach(a=>{const l=n.get(a)??parseInt(a.split(":")[0],10);let d=o.get(l);d||o.set(l,d=new Set),d.add(a)});const s=new Map;return o.forEach((a,l)=>{const d=i.current.get(l),c=d&&d.size===a.size&&Array.from(a).every(p=>d.has(p));s.set(l,c?d:a)}),i.current=s,s},[e,n])}function jx(e){return e==null?void 0:e.find(n=>n.kind==="heading"&&/^#{1,6}$/.test(n.mark))}function vx(e){return e.getAttribute("data-heading-anchor")}function kx(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}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 wx(e,n){const i=Array.from(n(e.join("")));return i.length===e.length&&e.every(o=>Array.from(o).length===1)?i:e.map(o=>n(o))}function Sx({heading:e,children:n}){if(!e)return t.jsx("p",{className:"guji-reflow-paragraph",children:n});const i=`h${Math.min(6,e.level+1)}`;return t.jsx(i,{className:`guji-reflow-paragraph guji-reflow-heading guji-reflow-h${e.level}`,"data-heading-anchor":e.anchor,"data-heading-level":e.level,"data-heading-toc":e.toc===!1?"0":void 0,children:n})}const _x=f.memo(function({pGroup:n,first:i,pageBreaks:o,markOpts:s,plainBooks:a,selected:l,entityOfChar:d,entityLoader:c,convert:p,buildHref:h,handlers:m,charCount:u,pageStarts:g}){const x=f.useMemo(()=>{const b=new Map;if(!p)return b;for(const w of n.paragraphs){const v=wx(w.chars.map(k=>k.charData.norm??k.charData.char),p);w.chars.forEach((k,z)=>b.set(k.charData.id,v[z]))}return b},[n,p]),j=b=>x.get(b.id)??b.char,{t:y}=re(),S=b=>{const w=s?nd(b.mark,s):b.mark;return w?t.jsx("span",{className:"guji-text-punct","data-punct-id":b.id,children:w},b.id):null};return t.jsxs("section",{"data-page-section":n.page,className:"guji-page-section",style:{position:"relative",scrollMarginTop:96,contentVisibility:"auto",containIntrinsicSize:gx,"--gtv-pc":u,"--gtv-pp":n.paragraphs.length},children:[!i&&o&&t.jsxs("div",{className:"guji-page-divider",style:{display:"flex",alignItems:"center",margin:"2rem 0 1.2rem",color:r("meta-fg"),fontSize:"0.82rem",letterSpacing:"0.08em",userSelect:"none"},children:[t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}}),t.jsxs("span",{style:{padding:"0 12px",fontWeight:500},"data-page-label":n.label,title:n.label?`${n.page}`:void 0,children:["第 ",n.label??n.page," 葉"]}),t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}})]}),n.paragraphs.map((b,w)=>t.jsxs(Sx,{heading:b.heading,children:[hx(b.chars,d).map((v,k)=>{const z=v.chars.map(({charData:R,beforePuncts:T,afterPuncts:N,start:E},W)=>{const F=!!v.entity&&W===0,A=!!v.entity&&W===v.chars.length-1,V=F?[]:T,ae=A?[]:N;return t.jsxs(f.Fragment,{children:[E&&E.blankBefore>0&&t.jsx(Ma,{n:E.blankBefore}),V.map(S),t.jsx("span",{"data-char-id":R.id,"data-page-start":g.get(R.id),className:`guji-text-char${l.has(R.id)?" is-selected":""}${R.sub?" is-sub":""}${R.lane==="solo"?" is-solo":""}${R.lacuna?" is-lacuna":""}${R.guess?" is-guess":""}${R.zi?" is-zi":""}${E!=null&&E.raised?" is-raised":""}`,"data-raised":(E==null?void 0:E.raised)||void 0,title:R.lacuna?y("detail.lacuna"):R.zi?y("detail.composedChar",{label:R.zi}):R.guess?y("reader.charGuess"):void 0,children:j(R)}),ae.map(S)]},R.id)});if(!v.entity)return t.jsx(f.Fragment,{children:z},`r${k}`);const C=v.chars[0].beforePuncts.map(S),_=v.chars[v.chars.length-1].afterPuncts.map(S);return t.jsxs(f.Fragment,{children:[C,t.jsx(Jo,{span:v.entity,label:v.chars.map(R=>j(R.charData)).join(""),hasBrackets:!0,plain:a&&v.entity.kind==="work",loader:c,buildHref:h,onNavigate:m.navigate,cardNewTab:!0,renderText:()=>z,hoverDelayMs:250}),_]},`${v.entity.key}@${k}`)}),w===n.paragraphs.length-1&&n.trailingBlank?t.jsx(Ma,{n:n.trailingBlank}):null]},b.id))]})});function Jr(e){const[n,i]=Yn,o=Number.isFinite(e)?e:.33;return Math.round(Math.min(i,Math.max(n,o))*1e3)/1e3}const $x=.02,mn=16,Cx=4;function zx({y:e,containerRef:n,onDrag:i,onCommit:o}){const{t:s}=re(),[a,l]=f.useState(0),d=f.useRef(!1),c=f.useRef(null),p=f.useRef(e);p.current=e;const h=f.useCallback(()=>{var j;const u=((j=c.current)==null?void 0:j.parentElement)??n.current,g=(u==null?void 0:u.closest(".bim-rd-col"))??u,x=g==null?void 0:g.getBoundingClientRect();l(Math.max(0,((x==null?void 0:x.left)??0)-mn-Cx))},[n]);f.useLayoutEffect(()=>{var j;h(),window.addEventListener("resize",h);const u=((j=c.current)==null?void 0:j.parentElement)??n.current,g=(u==null?void 0:u.closest(".bim-rd-col"))??u,x=typeof ResizeObserver<"u"?new ResizeObserver(()=>h()):null;for(const y of[g,u==null?void 0:u.closest(".bim-rd-text"),u==null?void 0:u.closest(".bim-rd-body")])y&&(x==null||x.observe(y));return()=>{window.removeEventListener("resize",h),x==null||x.disconnect()}},[h,n]);const m=u=>Jr(u/Math.max(1,window.innerHeight));return t.jsx("div",{ref:c,role:"slider",tabIndex:0,className:"guji-page-indicator","aria-label":s("reader.pageIndicator"),"aria-orientation":"vertical","aria-valuemin":Math.round(Yn[0]*100),"aria-valuemax":Math.round(Yn[1]*100),"aria-valuenow":Math.round(e*100),"data-indicator-y":e,style:{position:"fixed",left:a,top:`calc(${e*100}vh - ${mn/2}px)`,width:mn,height:mn,zIndex:20,cursor:"ns-resize",touchAction:"none",display:"flex",alignItems:"center",justifyContent:"center",color:r("meta-fg")},onPointerDown:u=>{d.current=!0;try{u.currentTarget.setPointerCapture(u.pointerId)}catch{}u.preventDefault()},onPointerMove:u=>{if(!d.current)return;const g=m(u.clientY);p.current=g,i(g)},onPointerUp:u=>{if(d.current){d.current=!1;try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}o(m(u.clientY))}},onPointerCancel:()=>{d.current&&(d.current=!1,o(p.current))},onKeyDown:u=>{const g=u.key==="ArrowUp"?-1:u.key==="ArrowDown"?1:0;g&&(u.preventDefault(),o(Jr(e+g*(u.shiftKey?5:1)*$x)))},children:t.jsx("svg",{width:mn,height:mn,viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M2 8h11M9 4l4 4-4 4"})})})}const gd=1,xd=6,fi={s:1,x:0,y:0},vi=(e,n,i)=>Math.min(i,Math.max(n,e));function es(e,n,i){const o=vi(e.s,gd,xd);return{s:o,x:vi(e.x,n*(1-o),0),y:vi(e.y,i*(1-o),0)}}function _r(e,n,i,o,s,a){const l=vi(e.s*o,gd,xd),d=l/e.s;return es({s:l,x:n-(n-e.x)*d,y:i-(i-e.y)*d},s,a)}function Nx(e,n,i,o,s){return es({s:e.s,x:e.x+n,y:e.y+i},o,s)}function Tx(e,n,i){const o=n===1?e*16:n===2?e*400:e;return Math.exp(-o*(i?.01:.0015))}const Pa=4,Ix=f.forwardRef(function({children:n,onScaleChange:i,resetKey:o,style:s},a){const l=f.useRef(null),[d,c]=f.useState(fi),p=f.useRef(d),h=f.useRef(i);h.current=i;const m=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))},u=()=>{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}};f.useImperativeHandle(a,()=>({zoomBy(b){const{w,h:v}=u();m(_r(p.current,w/2,v/2,b,w,v))},reset(){m(fi)}})),f.useEffect(()=>{m(fi)},[o]),f.useEffect(()=>{const b=l.current;if(!b||typeof ResizeObserver>"u")return;const w=new ResizeObserver(()=>{const{w:v,h:k}=u(),z=es(p.current,v,k);(z.x!==p.current.x||z.y!==p.current.y)&&m(z)});return w.observe(b),()=>w.disconnect()},[]),f.useEffect(()=>{const b=l.current;if(!b)return;const w=v=>{const k=Tx(v.deltaY,v.deltaMode,v.ctrlKey);if(p.current.s<=1&&k<1)return;v.preventDefault();const{w:z,h:C,left:_,top:R}=u();m(_r(p.current,v.clientX-_,v.clientY-R,k,z,C))};return b.addEventListener("wheel",w,{passive:!1}),()=>b.removeEventListener("wheel",w)},[]);const g=f.useRef(new Map),x=f.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),j=b=>{if(b.pointerType==="mouse"&&b.button!==0)return;g.current.set(b.pointerId,{x:b.clientX,y:b.clientY});const w=x.current;if(w.swallowClick=!1,g.current.size===1&&(w.moved=0,w.dragging=!1),g.current.size===2){const[v,k]=[...g.current.values()];w.pinchDist=Math.hypot(v.x-k.x,v.y-k.y),w.moved=Pa+1}},y=b=>{var E;const w=g.current.get(b.pointerId);if(!w)return;const v={x:b.clientX,y:b.clientY};g.current.set(b.pointerId,v);const k=x.current,{w:z,h:C,left:_,top:R}=u();if(g.current.size>=2){const[W,F]=[...g.current.values()],A=Math.hypot(W.x-F.x,W.y-F.y);if(k.pinchDist>0&&A>0){const V=(W.x+F.x)/2-_,ae=(W.y+F.y)/2-R;m(_r(p.current,V,ae,A/k.pinchDist,z,C))}k.pinchDist=A,k.swallowClick=!0;return}const T=v.x-w.x,N=v.y-w.y;if(k.moved+=Math.abs(T)+Math.abs(N),!(k.moved<=Pa)){if(!k.dragging){k.dragging=!0;try{(E=l.current)==null||E.setPointerCapture(b.pointerId)}catch{}}k.swallowClick=!0,p.current.s>1&&m(Nx(p.current,T,N,z,C))}},S=b=>{g.current.delete(b.pointerId);const w=x.current;w.pinchDist=0,g.current.size===0&&(w.dragging=!1)};return t.jsx("div",{ref:l,className:"bim-zp","data-zoom":d.s.toFixed(2),onPointerDown:j,onPointerMove:y,onPointerUp:S,onPointerCancel:S,onClickCapture:b=>{x.current.swallowClick&&(x.current.swallowClick=!1,b.stopPropagation(),b.preventDefault())},onDoubleClick:()=>m(fi),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 bd(e,n,i,o){const[s,a]=f.useState(n??null),[l,d]=f.useState(!1),c=f.useRef(0);return f.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(m=>{p===c.current&&a(m??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 Rx(e,n,i){const[o,s]=f.useState([]),a=f.useRef(0);return f.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?sd(c):[])}).catch(()=>{l===a.current&&s([])})},[e,n,i]),o}const Ex=/^#{1,6}$/,Lx=/^([^《》]*)《([^《》]+)》\s*(?:[〇零一二三四五六七八九十百千]+|不分|無|无)卷/;function Ax(e){let n=e.trim();const i=Lx.exec(n);return i&&(n=i[1]+i[2]),n.replace(/[《》〈〉]/g,"").trim()}const Ba=e=>e.kind==null||e.kind==="point";function yd(e,n){var d;if(!e||!n||n.length===0)return[];const i=new Map;let o=!1;for(const c of n){c.kind==="heading"&&(o=!0);const p=i.get(c.anchor);p?p.push(c):i.set(c.anchor,[c])}if(!o)return[];const s=[];let a=null;const l=()=>{a&&(a.fixed||(a.h.label=Ax(a.text)),a.h.label&&s.push(a.h)),a=null};for(const c of e){const p=[...c.columns].sort((h,m)=>h.col-m.col);for(const h of p)for(const m of h.chars){const u=i.get(m.id)??[],g=u.find(x=>x.kind==="heading"&&x.pos==="before"&&Ex.test(x.mark));if(g&&l(),g&&g.toc!==!1){const x=(d=g.label)==null?void 0:d.trim();a={h:{level:g.mark.length,label:x??"",anchor:m.id},text:"",fixed:!!x}}if(a&&!a.fixed){for(const x of u)Ba(x)&&x.pos==="before"&&(a.text+=x.mark);a.text+=m.char;for(const x of u)Ba(x)&&x.pos!=="before"&&(a.text+=x.mark)}u.some(x=>x.kind==="break"&&x.pos!=="before")&&l()}}return l(),s}function jd(e){if(!Array.isArray(e))return[];const n=[];for(const i of e){if(!i||typeof i!="object")continue;const{level:o,label:s,anchor:a}=i;typeof o!="number"||!Number.isInteger(o)||o<1||o>6||typeof s!="string"||!s.trim()||typeof a!="string"||!a||n.push({level:o,label:s.trim(),anchor:a})}return n}function ts(e,n){return`${e}#${n}`}function vd(e){const n=e.indexOf("#");return n<=0||n===e.length-1?null:{chapter:e.slice(0,n),anchor:e.slice(n+1)}}function kd(e){const n=[],i=[];for(const o of e){const s={...o,children:[]};for(;i.length>0&&i[i.length-1].level>=o.level;)i.pop();i.length===0?n.push(s):i[i.length-1].children.push(s),i.push(s)}return n}function Qr(e){return!!e&&!e.has_json&&typeof e.char_file=="string"&&!!e.char_file&&typeof e.cord_file=="string"&&!!e.cord_file}const Mx=150,Oa={padding:24,color:r("desc-fg"),fontSize:14};function Wa({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,Px=[];function Bx(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 Ox(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 Ha(e,n){return(n==null?void 0:n.type)==="kaozhen"?"章":n!=null&&n.juan_metadata&&Object.values(n.juan_metadata).some(i=>i.vol_label)||Array.isArray(n==null?void 0:n.heading_levels)&&n.heading_levels.length>0?"冊":ze.isCollatedKind(e==null?void 0:e.kind)?"卷":"章"}function wd(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 Sd(e,n,i){return n.map(o=>({key:ts(e,o.anchor),label:i(o.label),inChapter:!0,...o.children.length>0?{selectable:!0,children:Sd(e,o.children,i)}:{}}))}function Wx(e,n,i,o,s,a=()=>[]){var h;const l=new Map(e.chapters.map(m=>[m.file,m])),d=m=>m==="loading"?"…":typeof m=="number"&&m>0?m:void 0,c=(m,u)=>{const g=l.get(m),x=g?a(g):[];return{key:m,label:u??(g?wd(g,i,o,s):m),hint:d(n[m]),disabled:n[m]===0,...x.length>0?{selectable:!0,children:Sd(m,kd(x),o)}:{}}},p=(h=e.juan_groups)==null?void 0:h.filter(m=>{var u;return m.files.some(g=>l.has(g))||((u=m.children)==null?void 0:u.length)});if(p&&p.length>0){const m=(u,g)=>{var j;if(u.files.length===1&&!((j=u.children)!=null&&j.length))return c(u.files[0],o(u.label));const x=Mg(u,n);return{key:`group:${g}`,label:o(u.label),hint:x==="loading"?"…":typeof x=="number"&&x>0?`${x}`:dd(u),defaultExpanded:typeof x=="number"&&x>0,children:[...u.files.filter(y=>l.has(y)).map(y=>c(y)),...(u.children??[]).map((y,S)=>m(y,`${g}.${S}`))]}};return p.map((u,g)=>m(u,`${g}`))}return e.chapters.map(m=>c(m.file))}const ns=e=>{const n=wc();return t.jsx(rm,{mode:n[0].scriptMode,children:t.jsx(Fx,{...e,prefsState:n})})},Fx=({prefsState:e,id:n,transport:i,versionKey:o,chapter:s,onLocationChange:a,onNavigate:l,anchor:d,title:c,subtitle:p,resolveImages:h,renderImageOverlay:m,imagePanel:u,allowVertical:g,onReportError:x,revisedAt:j,backHref:y,backLabel:S,resolveWarpData:b,warpData:w,resolveEntities:v,onEntityNavigate:k,className:z,style:C})=>{var Ts,Is,Rs;const{t:_,convert:R}=re(),T=f.useMemo(()=>hc(i),[i]),[N,E]=e,W=st(),F=f.useRef(a);F.current=a;const[A,V]=f.useState(null),[ae,xe]=f.useState("loading");f.useEffect(()=>{let L=!1;return V(null),xe("loading"),T.getManifest(n).then(te=>{L||(te?(V(te),xe("ready")):xe("missing"))}).catch(()=>{L||xe("missing")}),()=>{L=!0}},[T,n]);const me=o!==void 0,G=s!==void 0,[ye,ne]=f.useState(null),[U,Q]=f.useState(null);f.useEffect(()=>{ne(null),Q(null)},[n]);const q=ze.pickTextVersion(A,me?o:ye),je=((Ts=A==null?void 0:A.versions.find(L=>L.key==="default"))==null?void 0:Ts.key)??((Is=A==null?void 0:A.versions[0])==null?void 0:Is.key)??"default",I=(q==null?void 0:q.key)??null,oe=G?s:U,$e=f.useCallback((L,te,Ie,Qe)=>{var qe;(qe=F.current)==null||qe.call(F,{key:L,chapter:te,isDefault:L===je,...Qe?{anchor:Qe}:{}},Ie)},[je]);f.useEffect(()=>{!A||!me||o==null||A.versions.some(L=>L.key===o)||$e(je,null,"auto")},[A,me,o,je,$e]);const ve=f.useRef(new Map);f.useEffect(()=>{ve.current.clear()},[T,n]);const Le=f.useCallback(async L=>{const te=`${n}
|
|
1397
|
-
${L}`;if(ve.current.has(te))return ve.current.get(te)??null;const
|
|
1398
|
-
${I}`:null,ke=
|
|
1399
|
-
${I}`;return
|
|
1396
|
+
`,rx=120;function gt(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function ox(e,n=rx){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 sx(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 ax(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(i=>{if(!i||typeof i!="object")return"";const o=i,s=gt(o.name);return s?[gt(o.dynasty)&&`〔${gt(o.dynasty)}〕`,s,gt(o.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function ud(e,n){const i=gt(n.type),o=gt(n.primary_name)??gt(n.title)??e,s=i==="entity"?[gt(n.dynasty),sx(n),gt(n.native_place)].filter(Boolean).join(" · "):[ax(n),gt(n.edition),gt(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?gt(n.description.text):gt(n.description);return{id:gt(n.id)??e,type:i,title:o,meta:s||void 0,description:ox(a)}}function md(e){const n=[e.dynasty,e.author,e.edition].filter(Boolean).join(" · ");return{id:e.id,type:e.type,title:e.title,meta:n||void 0}}function hd(e){return async n=>{const i=await e.getItem(n);if(i)return ud(n,i);if(e.getEntry){const o=await e.getEntry(n);if(o)return md(o)}return null}}const Ra=new WeakMap;function lx(e,n,i){let o=Ra.get(e);o||(o=new Map,Ra.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 fd=e=>`/item/${encodeURIComponent(e)}`,Ea={work:"書名",people:"人名",place:"地名",office:"官職",dynasty:"朝代",reign:"年號",other:"專名"},cx=typeof window>"u"?f.useEffect:f.useLayoutEffect;function Jo(e,n){return f.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:hd(e)}:null,[n,e])}const dx=e=>e,px=({text:e,entities:n,offsets:i="text",plainBase:o=0,transport:s,loadSummary:a,buildHref:l=fd,onNavigate:d,renderText:c=dx,hoverDelayMs:p=250,closeDelayMs:h,injectStyles:m=!0,className:u})=>{const g=f.useMemo(()=>{const j=i==="plain"?ad(e,n,o):n;return ld(e,j)},[e,n,i,o]),x=Jo(s,a);return t.jsxs("span",{className:u?`bim-et-root ${u}`:"bim-et-root",children:[m&&t.jsx("style",{children:Zo}),g.map(j=>j.type==="text"?t.jsx(f.Fragment,{children:c(j.text)},`t${j.start}`):t.jsx(Qo,{span:j.span,label:j.text,hasBrackets:e[j.start-1]==="《"&&e[j.start+j.text.length]==="》",loader:x,buildHref:l,onNavigate:d,renderText:c,hoverDelayMs:p,closeDelayMs:h},`${j.span.key}@${j.start}`))]})};let Zt=null;const Qo=({span:e,label:n,hasBrackets:i,plain:o,loader:s,buildHref:a,onNavigate:l,onCardNavigate:d=l,cardNewTab:c,renderText:p,hoverDelayMs:h,closeDelayMs:m=280})=>{const u=f.useId(),[g,x]=f.useState(!1),[j,y]=f.useState(!1),S=f.useRef(null),b=f.useRef(null),w=`bim-et bim-et-${e.kind}${o?" bim-et-nu":""}`,v=e.kind==="work"&&!i,k=t.jsxs(t.Fragment,{children:[v&&t.jsx("span",{className:"bim-et-sr",children:"《"}),p(n),v&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),z=()=>{S.current&&(clearTimeout(S.current),S.current=null)},C=()=>{b.current&&(clearTimeout(b.current),b.current=null)},_=f.useCallback(()=>{z(),C(),x(!1),y(!1),Zt===_&&(Zt=null)},[]);f.useEffect(()=>()=>{z(),C(),Zt===_&&(Zt=null)},[_]);const R=f.useCallback(()=>{Zt&&Zt!==_&&Zt(),Zt=_,x(!0)},[_]),T=f.useCallback(A=>{C(),y(!0),!g&&(z(),A<=0?R():S.current=setTimeout(R,A))},[g,R]),N=f.useCallback(()=>{z(),C(),b.current=setTimeout(_,m)},[_,m]),E=!!e.targetId,W=e.targetId,F={className:"bim-et-w","data-active":j?"":void 0,onMouseEnter:()=>T(h),onMouseLeave:N,onBlur:A=>{A.currentTarget.contains(A.relatedTarget)||_()},onKeyDown:A=>{A.key==="Escape"&&g&&(A.stopPropagation(),_())}};return!E||!W?t.jsxs("span",{...F,children:[t.jsx("span",{className:w,children:k}),g&&t.jsx(La,{id:u,entityId:null,span:e,loader:null,buildHref:a,onNavigate:l})]}):t.jsxs("span",{...F,children:[t.jsx("a",{className:w,href:a(W),"data-entity-id":W,"aria-describedby":g?u:void 0,onFocus:()=>T(0),onClick:l?A=>l(W,A):void 0,children:k}),g&&t.jsx(La,{id:u,entityId:W,span:e,loader:s,buildHref:a,onNavigate:c?void 0:d,newTab:c})]})},La=({id:e,entityId:n,span:i,loader:o,buildHref:s,onNavigate:a,newTab:l})=>{const{convert:d,t:c}=re(),p=f.useRef(null),[h,m]=f.useState("start"),[u,g]=f.useState(o&&n?{status:"loading"}:{status:"ready",summary:null});f.useEffect(()=>{if(!o||!n)return;let y=!1;return g({status:"loading"}),lx(o.owner,o.load,n).then(S=>{y||g({status:"ready",summary:S})}).catch(()=>{y||g({status:"error"})}),()=>{y=!0}},[o,n]),cx(()=>{const y=p.current;if(!y||typeof window>"u")return;const S=y.getBoundingClientRect(),b=document.documentElement.clientWidth||window.innerWidth;S.right>b-8&&h==="start"&&m("end")},[u,h]);const x=u.status==="ready"?u.summary:null,j=(x==null?void 0:x.title)??i.canonicalName??i.text;return n?t.jsxs("span",{ref:p,id:e,role:"tooltip",className:"bim-et-card","data-align":h,children:[t.jsx("span",{className:"bim-et-card-k",children:d(Ea[i.kind])}),j&&t.jsx("span",{className:"bim-et-card-t",children:d(j)}),(x==null?void 0:x.meta)&&t.jsx("span",{className:"bim-et-card-m",children:d(x.meta)}),(x==null?void 0:x.description)&&t.jsx("span",{className:"bim-et-card-d",children:d(x.description)}),u.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:d("載入中…")}),u.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:d("摘要載入失敗")}),x&&t.jsx("a",{className:"bim-et-card-a",href:s(x.id||n),...l?{target:"_blank",rel:"noopener"}:{},onClick:a?y=>a(x.id||n,y):void 0,children:c("reader.entityDetail")})]}):t.jsx("span",{ref:p,id:e,role:"tooltip",className:"bim-et-card","data-align":h,children:t.jsx("span",{className:"bim-et-card-k",children:d(Ea[i.kind])})})},ux=e=>`/item/${encodeURIComponent(e)}`;function mx(e){const n=e.filter(i=>i.kind==null||i.kind==="point");return{before:n.filter(i=>i.pos==="before"),after:n.filter(i=>i.pos!=="before")}}function hx(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 es=({pageData:e,pages:n,punctuations:i=bx,selectedCharIds:o,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:h,convert:m,scrollToPage:u,scrollToAnchor:g,onVisibleHeadingChange:x,entities:j,entityTransport:y,loadEntitySummary:S,buildEntityHref:b,onEntityNavigate:w,pageBreaks:v=!0,pageIndicatorY:k,onPageIndicatorYChange:z,quoteStyle:C,bookTitleStyle:_,showWorks:R})=>{var Ye,tt,Qe;const T=f.useRef(null),N=f.useRef(0),E=f.useMemo(()=>{const $=new Map;return p&&i.forEach((M,P)=>{const X=M.id?M:{...M,id:`${M.anchor}#${P}`},he=$.get(X.anchor)||[];he.push(X),$.set(X.anchor,he)}),$},[i,p]),W=f.useMemo(()=>C===void 0&&_===void 0&&R===void 0?null:{quoteStyle:C??"original",hideBookBrackets:_==="wavy"||R===!1},[C,_,R]),F=_==="bracket",A=f.useMemo(()=>{var Y;const $=n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}],M=new Map;for(const H of $)for(const fe of H.columns)fe.chars.length>0&&!fe.raised&&M.set(fe.lead_blank||0,(M.get(fe.lead_blank||0)||0)+1);let P=0,X=-1;for(const[H,fe]of M)(fe>X||fe===X&&H<P)&&(P=H,X=fe);const he=H=>!!H.raised||(H.lead_blank||0)<P,se=$.filter(H=>H.columns.some(fe=>fe.chars.length>0)).map(H=>{const fe=[...H.columns].sort((De,pt)=>De.col-pt.col),Ce=[];let be=[];const Q=()=>{const De=jx(E.get(be[0].charData.id));Ce.push({id:`para-p${H.page}-${Ce.length}`,chars:be,...De?{heading:{level:De.mark.length,anchor:be[0].charData.id,...De.toc===!1?{toc:!1}:{}}}:{}}),be=[]};let Ee=!1,ge=0,Oe;for(const De of fe){if(De.chars.length===0){De.kind==="blank"&&ge++;continue}const pt=De.raised||De.lead_blank||ge?{raised:De.raised,leadBlank:De.lead_blank,blankBefore:ge}:void 0;ge=0,he(De)||(Oe=De.lead_blank||0);let lt=!0;for(const Ke of De.chars){const et=E.get(Ke.id)||[],{before:yt,after:K}=mx(et),Ge=et.some(nt=>nt.kind==="break"&&nt.pos!=="before");et.some(nt=>nt.kind==="heading")&&(be.length>0?Q():Ce.length===0&&(Ee=!0)),be.push({charData:Ke,col:De.col,beforePuncts:yt,afterPuncts:K,...lt&&pt?{start:pt}:{}}),lt=!1,Ge&&Q()}}const Se=be.length>0;return Se&&Q(),{page:H.page,paragraphs:Ce,endsOpen:Se,...Oe!==void 0?{tailLead:Oe}:{},...Ee?{leadStarts:Ee}:{},...H.label?{label:H.label}:{},...ge>0?{trailingBlank:ge}:{}}}),We=new Map;if(!v){let H=null;for(const fe of se){const Ce=fe.paragraphs[0],be=(Y=Ce==null?void 0:Ce.chars[0])==null?void 0:Y.start,Q=(be==null?void 0:be.leadBlank)||0,Ee=!!be&&!be.raised&&Q>=P&&Q>((H==null?void 0:H.tailLead)??P),ge=!!fe.leadStarts||!!(be!=null&&be.blankBefore)||Ee,Oe=fe.paragraphs.length===1&&!!fe.trailingBlank;if(H&&Ce&&!ge&&!Oe){for(const Se of Ce.chars)We.set(Se.charData.id,H.owner);H.para.chars=H.para.chars.concat(Ce.chars),fe.leadFirstId=Ce.chars[0].charData.id,fe.paragraphs=fe.paragraphs.slice(1)}if(fe.endsOpen&&!fe.trailingBlank){const Se=fe.paragraphs[fe.paragraphs.length-1];Se?H={para:Se,owner:fe.page,tailLead:fe.tailLead??(H==null?void 0:H.tailLead)??P}:H&&fe.tailLead!==void 0&&(H.tailLead=fe.tailLead)}else H=null}}const Be=new Map;for(const H of se)H.leadFirstId&&Be.set(H.leadFirstId,H.page);return{pages:se,mergedOwner:We,pageStarts:Be}},[n,e,E,v]),V=A.pages,ae=f.useRef(V);ae.current=V;const xe=f.useMemo(()=>V.map($=>$.paragraphs.reduce((M,P)=>M+P.chars.length,0)),[V]),me=f.useCallback(($,M)=>{let P=$,X=0;for(;P<xe.length&&(P===$||X+xe[P]<=M);)X+=xe[P++];return P},[xe]),G=`${V.length}:${((Qe=(tt=(Ye=V[0])==null?void 0:Ye.paragraphs[0])==null?void 0:tt.chars[0])==null?void 0:Qe.charData.id)??""}`,[ye,ne]=f.useState(()=>({sig:G,n:me(0,Aa)}));let U=ye.n;ye.sig!==G&&(U=me(0,Aa),ne({sig:G,n:U})),U=Math.min(U,V.length);const ee=U>=V.length;f.useEffect(()=>ee?void 0:(M=>{const P=window;if(P.requestIdleCallback){const he=P.requestIdleCallback(M,{timeout:300});return()=>{var se;return(se=P.cancelIdleCallback)==null?void 0:se.call(P,he)}}const X=setTimeout(M,16);return()=>clearTimeout(X)})(()=>ne(M=>M.sig===G?{sig:M.sig,n:Math.max(M.n,me(M.n,fx))}:M)),[ee,U,G,me]);const q=f.useCallback($=>{const M=ae.current.findIndex(X=>X.page>=$),P=(M<0?ae.current.length:M)+2;ne(X=>X.n>=P?X:{...X,n:P})},[]),je=ee?V:V.slice(0,U);f.useEffect(()=>{let $;const M=requestAnimationFrame(()=>{$=setTimeout(()=>{const P=T.current,X=P==null?void 0:P.querySelector(".guji-reflow-paragraph");if(!P||!X)return;const he=getComputedStyle(X),se=parseFloat(he.fontSize),We=X.clientWidth;if(!(se>0)||!(We>0))return;const Be=parseFloat(he.lineHeight);P.style.setProperty("--gtv-cpl",String(Math.max(8,Math.floor(We/se)))),P.style.setProperty("--gtv-lh",`${Math.round(Be>0?Be:se*2)}px`)},0)});return()=>{cancelAnimationFrame(M),$&&clearTimeout($)}},[G]);const I=f.useMemo(()=>{const $=[];for(const M of V)for(const P of M.paragraphs)for(const X of P.chars)$.push(X.charData.id);return $},[V]),oe=f.useMemo(()=>{const $=new Map;if(!j||j.length===0)return $;const M=new Map(I.map((P,X)=>[P,X]));for(const P of j){if(!P.anchor)continue;const X=M.get(P.anchor.start),he=M.get(P.anchor.end);if(!(X===void 0||he===void 0||he<X))for(let se=X;se<=he;se++)$.has(I[se])||$.set(I[se],P)}return $},[j,I]),$e=Jo(y,S),ve=oe.size>0,Le=f.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:w,onVisibleHeadingChange:x});Le.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:w,onVisibleHeadingChange:x};const Te=f.useMemo(()=>({click:$=>{var M,P;N.current=Date.now()+1200,(P=(M=Le.current).onCharClick)==null||P.call(M,$)},enter:$=>{var M,P;return(P=(M=Le.current).onCharHover)==null?void 0:P.call(M,$)},leave:()=>{var $,M;return(M=($=Le.current).onCharHover)==null?void 0:M.call($,null)},navigate:($,M)=>{M.ctrlKey||M.metaKey||M.shiftKey||(M.preventDefault(),M.detail===0&&window.open(M.currentTarget.href,"_blank","noopener"))}}),[]),Z=yx(o,A.mergedOwner),ue=f.useRef(U);ue.current=U;const Pe=f.useRef(null),Me=f.useCallback($=>{const M=Pe.current,P=M==null?void 0:M.map.get($);if(P&&P.isConnected)return P;if(M&&M.for===ae.current&&M.n===ue.current&&!P)return null;const X=T.current;if(!X)return null;const he=new Map;return X.querySelectorAll("span[data-char-id]").forEach(se=>{he.set(se.getAttribute("data-char-id"),se)}),Pe.current={for:ae.current,n:ue.current,map:he},he.get($)??null},[]),ke=f.useRef(null);f.useEffect(()=>{var M;if((M=ke.current)==null||M.classList.remove("is-hovered"),ke.current=null,!s)return;const $=Me(s);$&&($.classList.add("is-hovered"),ke.current=$)},[s,Me]);const D=f.useRef(null),le=$=>{var P;const M=$ instanceof Element?$.closest("span[data-char-id]"):null;return M&&((P=T.current)!=null&&P.contains(M))?M.getAttribute("data-char-id"):null},ce=$=>{const M=le($.target);M&&Te.click(M)},J=$=>{const M=le($.target);M!==D.current&&(D.current=M,M?Te.enter(M):Te.leave())},we=()=>{D.current!==null&&(D.current=null,Te.leave())};f.useEffect(()=>{let $=null;const M=()=>{var ge,Oe;$=null;const X=window.getSelection(),he=T.current;if(!X||X.isCollapsed||X.rangeCount===0||!he)return;const se=X.getRangeAt(0),We=se.commonAncestorContainer,Be=We.nodeType===3?We.parentElement:We;if(!Be||!he.contains(Be))return;const Y=he.querySelectorAll("span[data-char-id]"),H=Se=>Se.firstChild??Se;let fe=0,Ce=Y.length;for(;fe<Ce;){const Se=fe+Ce>>1;se.comparePoint(H(Y[Se]),0)<0?fe=Se+1:Ce=Se}const be=fe;for(Ce=Y.length;fe<Ce;){const Se=fe+Ce>>1;se.comparePoint(H(Y[Se]),0)<=0?fe=Se+1:Ce=Se}let Q=fe-1;if(Q>=be&&se.endOffset===0&&se.endContainer===H(Y[Q])&&Q--,Q<be)return;const Ee=[];for(let Se=be;Se<=Q;Se++)Ee.push(Y[Se].getAttribute("data-char-id"));Ee.length>0&&(N.current=Date.now()+1200,(Oe=(ge=Le.current).onSelectionChange)==null||Oe.call(ge,Ee))},P=()=>{$&&clearTimeout($),$=setTimeout(M,120)};return document.addEventListener("selectionchange",P),()=>{document.removeEventListener("selectionchange",P),$&&clearTimeout($)}},[]);const Fe=f.useRef(null);f.useEffect(()=>{if(o.size!==1||Fe.current===o)return;const $=Array.from(o)[0],M=Me($);if(M)Fe.current=o,M.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"});else{const P=parseInt($.split(":")[0],10);isNaN(P)||q(P)}},[o,U,Me,q]);const Ve=$=>{var X;const M=T.current;if(!M)return null;const P=(X=V.find(he=>he.page===$))==null?void 0:X.leadFirstId;return P?M.querySelector(`span[data-char-id="${P}"]`):M.querySelector(`[data-page-section="${$}"]`)},Ze=u==null?void 0:u.nonce,O=f.useRef(null);f.useEffect(()=>{if(!u||O.current===u.nonce)return;const $=Ve(u.page);if(!$){!ee&&V.some(M=>M.page>=u.page)&&q(u.page);return}O.current=u.nonce,N.current=Date.now()+800,$.scrollIntoView({behavior:"auto",block:"start"})},[Ze,U]);const de=f.useRef(null);f.useEffect(()=>{var he,se;if(!g||de.current===g.nonce)return;const $=T.current,M=$==null?void 0:$.querySelector(`span[data-char-id="${kx(g.anchor)}"]`);if(!M){const We=parseInt(g.anchor.split(":")[0],10);!ee&&!isNaN(We)&&q(We);return}de.current=g.nonce;const P=M.closest(".guji-reflow-paragraph")??M;N.current=Date.now()+800,P.scrollIntoView({behavior:"auto",block:"start"});const X=parseInt(g.anchor.split(":")[0],10);isNaN(X)||(se=(he=Le.current).onVisiblePageChange)==null||se.call(he,X)},[g,V,U,ee,q]);const Ie=!!h||!!x,B=!!h&&typeof k=="number",[pe,ie]=f.useState(null),_e=Qr(pe??k??0),Re=f.useRef(null);Re.current=B?_e:null;const He=f.useRef(()=>{});return f.useEffect(()=>{var Ce,be;if(!Ie)return;const $=new Map,M=new Map;(Ce=T.current)==null||Ce.querySelectorAll("[data-page-section],[data-page-start]").forEach(Q=>{const Ee=Q.getAttribute("data-page-section");Ee!==null?$.set(Ee,Q):M.set(Q.getAttribute("data-page-start"),Q)});const P=[],X=[];for(const Q of je){const Ee=$.get(String(Q.page));Ee&&(P.push(Ee),X.push(Q.page))}if(P.length===0)return;const he=new Map(P.map((Q,Ee)=>[Q,Ee])),se=P.map(()=>[]);let We=0;(be=T.current)==null||be.querySelectorAll('.guji-reflow-heading:not([data-heading-toc="0"])').forEach(Q=>{const Ee=he.get(Q.closest("[data-page-section]"));Ee!==void 0&&(se[Ee].push(Q),We++)});let Be,Y=0;const H=()=>{var pt,lt;if(Y=0,Date.now()<N.current)return;const Q=Ke=>Ke.getBoundingClientRect().top;if(P.length>1&&Q(P[0])===Q(P[P.length-1]))return;const Ee=Re.current===null?120:Re.current*window.innerHeight;let ge=0,Oe=P.length-1;for(;ge<Oe;){const Ke=ge+Oe+1>>1;Q(P[Ke])<=Ee?ge=Ke:Oe=Ke-1}const Se=Q(P[0])>Ee;let De=X[ge];for(let Ke=ge+1;Ke<P.length;Ke++){const et=M.get(String(X[Ke]));if(!et||!P[ge].contains(et)||Q(et)>Ee)break;De=X[Ke]}if(We>0&&Le.current.onVisibleHeadingChange){let Ke=null;if(!Se){const yt=se[ge];for(let K=yt.length-1;K>=0&&!Ke;K--)Q(yt[K])<=Ee&&(Ke=yt[K]);for(let K=ge-1;K>=0&&!Ke;K--)se[K].length>0&&(Ke=se[K][se[K].length-1])}const et=Ke?vx(Ke):null;et!==Be&&(Be=et,Le.current.onVisibleHeadingChange(et))}(lt=(pt=Le.current).onVisiblePageChange)==null||lt.call(pt,De)},fe=()=>{Y||(Y=requestAnimationFrame(H))};return He.current=()=>{Y||(Y=requestAnimationFrame(H))},window.addEventListener("scroll",fe,{passive:!0}),fe(),()=>{window.removeEventListener("scroll",fe),Y&&cancelAnimationFrame(Y),He.current=()=>{}}},[Ie,V,U]),f.useEffect(()=>{B&&He.current()},[B,_e]),t.jsxs("div",{ref:T,className:"guji-text-pane-content",onClick:ce,onMouseOver:J,onMouseLeave:we,children:[ve&&t.jsx("style",{children:Zo}),B&&t.jsx(zx,{y:_e,containerRef:T,onDrag:ie,onCommit:$=>{ie(null),z==null||z($)}}),t.jsx("div",{className:"guji-text-reflow-view",children:je.map(($,M)=>t.jsx(_x,{pGroup:$,first:M===0,pageBreaks:v,markOpts:W,plainBooks:F,selected:Z.get($.page)??xx,entityOfChar:oe,entityLoader:$e,convert:m,buildHref:b??ux,handlers:Te,charCount:xe[M]??0,pageStarts:A.pageStarts},`page-sec-${$.page}`))})]})},Aa=1800,fx=800,gx="auto calc((var(--gtv-pc) / var(--gtv-cpl, 30) + var(--gtv-pp) * 1.4) * var(--gtv-lh, 44px) + 64px)",xx=new Set,bx=[];function yx(e,n){const i=f.useRef(new Map);return f.useMemo(()=>{const o=new Map;e.forEach(a=>{const l=n.get(a)??parseInt(a.split(":")[0],10);let d=o.get(l);d||o.set(l,d=new Set),d.add(a)});const s=new Map;return o.forEach((a,l)=>{const d=i.current.get(l),c=d&&d.size===a.size&&Array.from(a).every(p=>d.has(p));s.set(l,c?d:a)}),i.current=s,s},[e,n])}function jx(e){return e==null?void 0:e.find(n=>n.kind==="heading"&&/^#{1,6}$/.test(n.mark))}function vx(e){return e.getAttribute("data-heading-anchor")}function kx(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}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 wx(e,n){const i=Array.from(n(e.join("")));return i.length===e.length&&e.every(o=>Array.from(o).length===1)?i:e.map(o=>n(o))}function Sx({heading:e,children:n}){if(!e)return t.jsx("p",{className:"guji-reflow-paragraph",children:n});const i=`h${Math.min(6,e.level+1)}`;return t.jsx(i,{className:`guji-reflow-paragraph guji-reflow-heading guji-reflow-h${e.level}`,"data-heading-anchor":e.anchor,"data-heading-level":e.level,"data-heading-toc":e.toc===!1?"0":void 0,children:n})}const _x=f.memo(function({pGroup:n,first:i,pageBreaks:o,markOpts:s,plainBooks:a,selected:l,entityOfChar:d,entityLoader:c,convert:p,buildHref:h,handlers:m,charCount:u,pageStarts:g}){const x=f.useMemo(()=>{const b=new Map;if(!p)return b;for(const w of n.paragraphs){const v=wx(w.chars.map(k=>k.charData.norm??k.charData.char),p);w.chars.forEach((k,z)=>b.set(k.charData.id,v[z]))}return b},[n,p]),j=b=>x.get(b.id)??b.char,{t:y}=re(),S=b=>{const w=s?nd(b.mark,s):b.mark;return w?t.jsx("span",{className:"guji-text-punct","data-punct-id":b.id,children:w},b.id):null};return t.jsxs("section",{"data-page-section":n.page,className:"guji-page-section",style:{position:"relative",scrollMarginTop:96,contentVisibility:"auto",containIntrinsicSize:gx,"--gtv-pc":u,"--gtv-pp":n.paragraphs.length},children:[!i&&o&&t.jsxs("div",{className:"guji-page-divider",style:{display:"flex",alignItems:"center",margin:"2rem 0 1.2rem",color:r("meta-fg"),fontSize:"0.82rem",letterSpacing:"0.08em",userSelect:"none"},children:[t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}}),t.jsxs("span",{style:{padding:"0 12px",fontWeight:500},"data-page-label":n.label,title:n.label?`${n.page}`:void 0,children:["第 ",n.label??n.page," 葉"]}),t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}})]}),n.paragraphs.map((b,w)=>t.jsxs(Sx,{heading:b.heading,children:[hx(b.chars,d).map((v,k)=>{const z=v.chars.map(({charData:R,beforePuncts:T,afterPuncts:N,start:E},W)=>{const F=!!v.entity&&W===0,A=!!v.entity&&W===v.chars.length-1,V=F?[]:T,ae=A?[]:N;return t.jsxs(f.Fragment,{children:[E&&E.blankBefore>0&&t.jsx(Ma,{n:E.blankBefore}),V.map(S),t.jsx("span",{"data-char-id":R.id,"data-page-start":g.get(R.id),className:`guji-text-char${l.has(R.id)?" is-selected":""}${R.sub?" is-sub":""}${R.lane==="solo"?" is-solo":""}${R.lacuna?" is-lacuna":""}${R.guess?" is-guess":""}${R.zi?" is-zi":""}${E!=null&&E.raised?" is-raised":""}`,"data-raised":(E==null?void 0:E.raised)||void 0,title:R.lacuna?y("detail.lacuna"):R.zi?y("detail.composedChar",{label:R.zi}):R.guess?y("reader.charGuess"):void 0,children:j(R)}),ae.map(S)]},R.id)});if(!v.entity)return t.jsx(f.Fragment,{children:z},`r${k}`);const C=v.chars[0].beforePuncts.map(S),_=v.chars[v.chars.length-1].afterPuncts.map(S);return t.jsxs(f.Fragment,{children:[C,t.jsx(Qo,{span:v.entity,label:v.chars.map(R=>j(R.charData)).join(""),hasBrackets:!0,plain:a&&v.entity.kind==="work",loader:c,buildHref:h,onNavigate:m.navigate,cardNewTab:!0,renderText:()=>z,hoverDelayMs:250}),_]},`${v.entity.key}@${k}`)}),w===n.paragraphs.length-1&&n.trailingBlank?t.jsx(Ma,{n:n.trailingBlank}):null]},b.id))]})});function Qr(e){const[n,i]=qn,o=Number.isFinite(e)?e:.33;return Math.round(Math.min(i,Math.max(n,o))*1e3)/1e3}const $x=.02,xn=16,Cx=4;function zx({y:e,containerRef:n,onDrag:i,onCommit:o}){const{t:s}=re(),[a,l]=f.useState(0),d=f.useRef(!1),c=f.useRef(null),p=f.useRef(e);p.current=e;const h=f.useCallback(()=>{var j;const u=((j=c.current)==null?void 0:j.parentElement)??n.current,g=(u==null?void 0:u.closest(".bim-rd-col"))??u,x=g==null?void 0:g.getBoundingClientRect();l(Math.max(0,((x==null?void 0:x.left)??0)-xn-Cx))},[n]);f.useLayoutEffect(()=>{var j;h(),window.addEventListener("resize",h);const u=((j=c.current)==null?void 0:j.parentElement)??n.current,g=(u==null?void 0:u.closest(".bim-rd-col"))??u,x=typeof ResizeObserver<"u"?new ResizeObserver(()=>h()):null;for(const y of[g,u==null?void 0:u.closest(".bim-rd-text"),u==null?void 0:u.closest(".bim-rd-body")])y&&(x==null||x.observe(y));return()=>{window.removeEventListener("resize",h),x==null||x.disconnect()}},[h,n]);const m=u=>Qr(u/Math.max(1,window.innerHeight));return t.jsx("div",{ref:c,role:"slider",tabIndex:0,className:"guji-page-indicator","aria-label":s("reader.pageIndicator"),"aria-orientation":"vertical","aria-valuemin":Math.round(qn[0]*100),"aria-valuemax":Math.round(qn[1]*100),"aria-valuenow":Math.round(e*100),"data-indicator-y":e,style:{position:"fixed",left:a,top:`calc(${e*100}vh - ${xn/2}px)`,width:xn,height:xn,zIndex:20,cursor:"ns-resize",touchAction:"none",display:"flex",alignItems:"center",justifyContent:"center",color:r("meta-fg")},onPointerDown:u=>{d.current=!0;try{u.currentTarget.setPointerCapture(u.pointerId)}catch{}u.preventDefault()},onPointerMove:u=>{if(!d.current)return;const g=m(u.clientY);p.current=g,i(g)},onPointerUp:u=>{if(d.current){d.current=!1;try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}o(m(u.clientY))}},onPointerCancel:()=>{d.current&&(d.current=!1,o(p.current))},onKeyDown:u=>{const g=u.key==="ArrowUp"?-1:u.key==="ArrowDown"?1:0;g&&(u.preventDefault(),o(Qr(e+g*(u.shiftKey?5:1)*$x)))},children:t.jsx("svg",{width:xn,height:xn,viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M2 8h11M9 4l4 4-4 4"})})})}const gd=1,xd=6,gi={s:1,x:0,y:0},ki=(e,n,i)=>Math.min(i,Math.max(n,e));function ts(e,n,i){const o=ki(e.s,gd,xd);return{s:o,x:ki(e.x,n*(1-o),0),y:ki(e.y,i*(1-o),0)}}function $r(e,n,i,o,s,a){const l=ki(e.s*o,gd,xd),d=l/e.s;return ts({s:l,x:n-(n-e.x)*d,y:i-(i-e.y)*d},s,a)}function Nx(e,n,i,o,s){return ts({s:e.s,x:e.x+n,y:e.y+i},o,s)}function Tx(e,n,i){const o=n===1?e*16:n===2?e*400:e;return Math.exp(-o*(i?.01:.0015))}const Pa=4,Ix=f.forwardRef(function({children:n,onScaleChange:i,resetKey:o,style:s},a){const l=f.useRef(null),[d,c]=f.useState(gi),p=f.useRef(d),h=f.useRef(i);h.current=i;const m=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))},u=()=>{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}};f.useImperativeHandle(a,()=>({zoomBy(b){const{w,h:v}=u();m($r(p.current,w/2,v/2,b,w,v))},reset(){m(gi)}})),f.useEffect(()=>{m(gi)},[o]),f.useEffect(()=>{const b=l.current;if(!b||typeof ResizeObserver>"u")return;const w=new ResizeObserver(()=>{const{w:v,h:k}=u(),z=ts(p.current,v,k);(z.x!==p.current.x||z.y!==p.current.y)&&m(z)});return w.observe(b),()=>w.disconnect()},[]),f.useEffect(()=>{const b=l.current;if(!b)return;const w=v=>{const k=Tx(v.deltaY,v.deltaMode,v.ctrlKey);if(p.current.s<=1&&k<1)return;v.preventDefault();const{w:z,h:C,left:_,top:R}=u();m($r(p.current,v.clientX-_,v.clientY-R,k,z,C))};return b.addEventListener("wheel",w,{passive:!1}),()=>b.removeEventListener("wheel",w)},[]);const g=f.useRef(new Map),x=f.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),j=b=>{if(b.pointerType==="mouse"&&b.button!==0)return;g.current.set(b.pointerId,{x:b.clientX,y:b.clientY});const w=x.current;if(w.swallowClick=!1,g.current.size===1&&(w.moved=0,w.dragging=!1),g.current.size===2){const[v,k]=[...g.current.values()];w.pinchDist=Math.hypot(v.x-k.x,v.y-k.y),w.moved=Pa+1}},y=b=>{var E;const w=g.current.get(b.pointerId);if(!w)return;const v={x:b.clientX,y:b.clientY};g.current.set(b.pointerId,v);const k=x.current,{w:z,h:C,left:_,top:R}=u();if(g.current.size>=2){const[W,F]=[...g.current.values()],A=Math.hypot(W.x-F.x,W.y-F.y);if(k.pinchDist>0&&A>0){const V=(W.x+F.x)/2-_,ae=(W.y+F.y)/2-R;m($r(p.current,V,ae,A/k.pinchDist,z,C))}k.pinchDist=A,k.swallowClick=!0;return}const T=v.x-w.x,N=v.y-w.y;if(k.moved+=Math.abs(T)+Math.abs(N),!(k.moved<=Pa)){if(!k.dragging){k.dragging=!0;try{(E=l.current)==null||E.setPointerCapture(b.pointerId)}catch{}}k.swallowClick=!0,p.current.s>1&&m(Nx(p.current,T,N,z,C))}},S=b=>{g.current.delete(b.pointerId);const w=x.current;w.pinchDist=0,g.current.size===0&&(w.dragging=!1)};return t.jsx("div",{ref:l,className:"bim-zp","data-zoom":d.s.toFixed(2),onPointerDown:j,onPointerMove:y,onPointerUp:S,onPointerCancel:S,onClickCapture:b=>{x.current.swallowClick&&(x.current.swallowClick=!1,b.stopPropagation(),b.preventDefault())},onDoubleClick:()=>m(gi),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 bd(e,n,i,o){const[s,a]=f.useState(n??null),[l,d]=f.useState(!1),c=f.useRef(0);return f.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(m=>{p===c.current&&a(m??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 Rx(e,n,i){const[o,s]=f.useState([]),a=f.useRef(0);return f.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?sd(c):[])}).catch(()=>{l===a.current&&s([])})},[e,n,i]),o}const Ex=/^#{1,6}$/,Lx=/^([^《》]*)《([^《》]+)》\s*(?:[〇零一二三四五六七八九十百千]+|不分|無|无)卷/;function Ax(e){let n=e.trim();const i=Lx.exec(n);return i&&(n=i[1]+i[2]),n.replace(/[《》〈〉]/g,"").trim()}const Ba=e=>e.kind==null||e.kind==="point";function yd(e,n){var d;if(!e||!n||n.length===0)return[];const i=new Map;let o=!1;for(const c of n){c.kind==="heading"&&(o=!0);const p=i.get(c.anchor);p?p.push(c):i.set(c.anchor,[c])}if(!o)return[];const s=[];let a=null;const l=()=>{a&&(a.fixed||(a.h.label=Ax(a.text)),a.h.label&&s.push(a.h)),a=null};for(const c of e){const p=[...c.columns].sort((h,m)=>h.col-m.col);for(const h of p)for(const m of h.chars){const u=i.get(m.id)??[],g=u.find(x=>x.kind==="heading"&&x.pos==="before"&&Ex.test(x.mark));if(g&&l(),g&&g.toc!==!1){const x=(d=g.label)==null?void 0:d.trim();a={h:{level:g.mark.length,label:x??"",anchor:m.id},text:"",fixed:!!x}}if(a&&!a.fixed){for(const x of u)Ba(x)&&x.pos==="before"&&(a.text+=x.mark);a.text+=m.char;for(const x of u)Ba(x)&&x.pos!=="before"&&(a.text+=x.mark)}u.some(x=>x.kind==="break"&&x.pos!=="before")&&l()}}return l(),s}function jd(e){if(!Array.isArray(e))return[];const n=[];for(const i of e){if(!i||typeof i!="object")continue;const{level:o,label:s,anchor:a}=i;typeof o!="number"||!Number.isInteger(o)||o<1||o>6||typeof s!="string"||!s.trim()||typeof a!="string"||!a||n.push({level:o,label:s.trim(),anchor:a})}return n}function ns(e,n){return`${e}#${n}`}function vd(e){const n=e.indexOf("#");return n<=0||n===e.length-1?null:{chapter:e.slice(0,n),anchor:e.slice(n+1)}}function kd(e){const n=[],i=[];for(const o of e){const s={...o,children:[]};for(;i.length>0&&i[i.length-1].level>=o.level;)i.pop();i.length===0?n.push(s):i[i.length-1].children.push(s),i.push(s)}return n}function eo(e){return!!e&&!e.has_json&&typeof e.char_file=="string"&&!!e.char_file&&typeof e.cord_file=="string"&&!!e.cord_file}const Mx=150,Oa={padding:24,color:r("desc-fg"),fontSize:14};function Wa({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,Px=[];function Bx(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 Ox(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 Ha(e,n){return(n==null?void 0:n.type)==="kaozhen"?"章":n!=null&&n.juan_metadata&&Object.values(n.juan_metadata).some(i=>i.vol_label)||Array.isArray(n==null?void 0:n.heading_levels)&&n.heading_levels.length>0?"冊":ze.isCollatedKind(e==null?void 0:e.kind)?"卷":"章"}function wd(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 Sd(e,n,i){return n.map(o=>({key:ns(e,o.anchor),label:i(o.label),inChapter:!0,...o.children.length>0?{selectable:!0,children:Sd(e,o.children,i)}:{}}))}function Wx(e,n,i,o,s,a=()=>[]){var h;const l=new Map(e.chapters.map(m=>[m.file,m])),d=m=>m==="loading"?"…":typeof m=="number"&&m>0?m:void 0,c=(m,u)=>{const g=l.get(m),x=g?a(g):[];return{key:m,label:u??(g?wd(g,i,o,s):m),hint:d(n[m]),disabled:n[m]===0,...x.length>0?{selectable:!0,children:Sd(m,kd(x),o)}:{}}},p=(h=e.juan_groups)==null?void 0:h.filter(m=>{var u;return m.files.some(g=>l.has(g))||((u=m.children)==null?void 0:u.length)});if(p&&p.length>0){const m=(u,g)=>{var j;if(u.files.length===1&&!((j=u.children)!=null&&j.length))return c(u.files[0],o(u.label));const x=Mg(u,n);return{key:`group:${g}`,label:o(u.label),hint:x==="loading"?"…":typeof x=="number"&&x>0?`${x}`:dd(u),defaultExpanded:typeof x=="number"&&x>0,children:[...u.files.filter(y=>l.has(y)).map(y=>c(y)),...(u.children??[]).map((y,S)=>m(y,`${g}.${S}`))]}};return p.map((u,g)=>m(u,`${g}`))}return e.chapters.map(m=>c(m.file))}const is=e=>{const n=wc();return t.jsx(rm,{mode:n[0].scriptMode,children:t.jsx(Fx,{...e,prefsState:n})})},Fx=({prefsState:e,id:n,transport:i,versionKey:o,chapter:s,onLocationChange:a,onNavigate:l,anchor:d,title:c,subtitle:p,resolveImages:h,renderImageOverlay:m,imagePanel:u,allowVertical:g,onReportError:x,revisedAt:j,backHref:y,backLabel:S,resolveWarpData:b,warpData:w,resolveEntities:v,onEntityNavigate:k,className:z,style:C})=>{var Ts,Is,Rs;const{t:_,convert:R}=re(),T=f.useMemo(()=>hc(i),[i]),[N,E]=e,W=at(),F=f.useRef(a);F.current=a;const[A,V]=f.useState(null),[ae,xe]=f.useState("loading");f.useEffect(()=>{let L=!1;return V(null),xe("loading"),T.getManifest(n).then(te=>{L||(te?(V(te),xe("ready")):xe("missing"))}).catch(()=>{L||xe("missing")}),()=>{L=!0}},[T,n]);const me=o!==void 0,G=s!==void 0,[ye,ne]=f.useState(null),[U,ee]=f.useState(null);f.useEffect(()=>{ne(null),ee(null)},[n]);const q=ze.pickTextVersion(A,me?o:ye),je=((Ts=A==null?void 0:A.versions.find(L=>L.key==="default"))==null?void 0:Ts.key)??((Is=A==null?void 0:A.versions[0])==null?void 0:Is.key)??"default",I=(q==null?void 0:q.key)??null,oe=G?s:U,$e=f.useCallback((L,te,Ne,Je)=>{var qe;(qe=F.current)==null||qe.call(F,{key:L,chapter:te,isDefault:L===je,...Je?{anchor:Je}:{}},Ne)},[je]);f.useEffect(()=>{!A||!me||o==null||A.versions.some(L=>L.key===o)||$e(je,null,"auto")},[A,me,o,je,$e]);const ve=f.useRef(new Map);f.useEffect(()=>{ve.current.clear()},[T,n]);const Le=f.useCallback(async L=>{const te=`${n}
|
|
1397
|
+
${L}`;if(ve.current.has(te))return ve.current.get(te)??null;const Ne=await T.getIndex(n,L).catch(()=>null);return Ne&&ve.current.set(te,Ne),Ne},[T,n]),[Te,Z]=f.useState(null),[ue,Pe]=f.useState("loading"),Me=I?`${n}
|
|
1398
|
+
${I}`:null,ke=Te&&Te.owner===Me?Te.idx:null;f.useEffect(()=>{if(!I)return;let L=!1;const te=`${n}
|
|
1399
|
+
${I}`;return Z(null),Pe("loading"),Le(I).then(Ne=>{L||(Ne&&Ne.chapters.length>0?(Z({owner:te,idx:Ne}),Pe("ready")):Pe("failed"))}),()=>{L=!0}},[n,I,Le]),f.useEffect(()=>{if(!ke||!I||oe!=null&&ke.chapters.some(Ne=>Ne.file===oe))return;const te=ke.chapters[0].file;G||ee(te),$e(I,te,"auto")},[ke,I,oe,G,$e]);const D=ke?oe!=null&&ke.chapters.some(L=>L.file===oe)?oe:ke.chapters[0].file:oe,le=f.useMemo(()=>ke&&D?ke.chapters.find(L=>L.file===D)??null:null,[ke,D]),ce=f.useRef(0),J=f.useCallback(async L=>{if(!A||L===I||!A.versions.some(Nt=>Nt.key===L))return;const te=++ce.current,Ne=await Le(L);if(te!==ce.current)return;const Je=le??(D?{file:D}:null),qe=ze.matchChapterAcrossVersions(Je,Ne);me||ne(L),G||ee(qe),$e(L,qe,"version")},[A,I,Le,le,D,me,G,$e]),[we,Fe]=f.useState(null),[Ve,Ze]=f.useState(null),O=f.useRef(0),de=f.useCallback((L,te)=>{Fe({chapter:L,anchor:te,nonce:++O.current}),Ze({chapter:L,anchor:te})},[]),Ie=f.useCallback(L=>{if(!I)return;const te=vd(L);if(te){de(te.chapter,te.anchor),G||ee(te.chapter),$e(I,te.chapter,"chapter",te.anchor);return}G||ee(L),$e(I,L,"chapter")},[I,G,$e,de]),B=f.useRef(null);f.useEffect(()=>{!d||!D||d===B.current||(B.current=d,de(D,d))},[d,D,de]),f.useEffect(()=>{d||(B.current=null)},[d]);const[pe,ie]=f.useState(null),_e=I&&le?`${n}
|
|
1400
1400
|
${I}
|
|
1401
|
-
${le.file}`:null,[Re,
|
|
1401
|
+
${le.file}`:null,[Re,He]=f.useState(null),Ye=_e!==null&&Re!==_e,tt=f.useRef(0);f.useEffect(()=>{if(!I||!le)return;const L=++tt.current,te=`${n}
|
|
1402
1402
|
${I}
|
|
1403
|
-
${le.file}`;if(ie(null),
|
|
1404
|
-
${I??""}`,load:P,files:he,activeFile:D??null,activeJuan:(pe==null?void 0:pe.json)??null,activeRawText:(pe==null?void 0:pe.md)??null,query:$,isKaozhen:
|
|
1403
|
+
${le.file}`;if(ie(null),eo(le)){He(te);return}T.getChapter(n,I,le.file,{json:!!le.has_json}).then(Ne=>{L===tt.current&&ie(Ne)}).catch(()=>{L===tt.current&&ie(null)}).finally(()=>{L===tt.current&&He(te)})},[T,n,I,le]);const Qe=ze.isCollatedKind(q==null?void 0:q.kind),[$,M]=f.useState("");f.useEffect(()=>{M("")},[n,I]);const P=f.useMemo(()=>I&&Qe?async L=>{const te=await T.getChapter(n,I,L,{json:!0});return{juan:(te==null?void 0:te.json)??null,rawText:(te==null?void 0:te.md)??null}}:null,[T,n,I,Qe]),X=(ke==null?void 0:ke.type)==="kaozhen",he=f.useMemo(()=>(ke==null?void 0:ke.chapters.map(L=>L.file))??[],[ke]),{matchStates:se}=Kg({resetKey:`${n}
|
|
1404
|
+
${I??""}`,load:P,files:he,activeFile:D??null,activeJuan:(pe==null?void 0:pe.json)??null,activeRawText:(pe==null?void 0:pe.md)??null,query:$,isKaozhen:X}),We=f.useRef(new Map);f.useEffect(()=>{We.current.clear()},[n]);const Be=f.useMemo(()=>({versionKey:I,chapter:le??null}),[I,le]),Y=vg(h,D??null,Be),{warpData:H,loading:fe}=bd(b,w,D??null,Be),Ce=Rx(v,D??null,Be),be=N.properNameMode??(Ce.length>0?"full":"off"),Q=f.useMemo(()=>({...N,properNameMode:be}),[N,be]),Ee=f.useMemo(()=>jg(Ce,be,{showWorks:Q.showWorks}),[Ce,be,Q.showWorks]),[ge,Oe]=f.useState(new Set),[Se]=f.useState(kg),[De,pt]=f.useState(!0),lt=N.preserveMargins;f.useCallback(L=>E({preserveMargins:L}),[E]);const Ke=f.useRef(null),[et,yt]=f.useState(1),[K,Ge]=f.useState(null),nt=L=>{var Ne;const te=parseInt(((Ne=L==null?void 0:L.page_id)==null?void 0:Ne.split(":")[1])??"",10);return isNaN(te)?null:te},_t=L=>{var Ne,Je;const te=(L==null?void 0:L.pages)??[];return((Ne=te.find(qe=>qe.columns.some(Nt=>Nt.chars.length>0)))==null?void 0:Ne.page)??nt(L)??((Je=te[0])==null?void 0:Je.page)??1},[Xe,$t]=f.useState(()=>_t(H)),qt=`${n}
|
|
1405
1405
|
${I}
|
|
1406
|
-
${D??""}`,[Tn,bs]=f.useState({key:Nn,data:H,started:!!H});if(Tn.key!==Nn)bs({key:Nn,data:H,started:!1});else if(H!==Tn.data&&(bs({key:Nn,data:H,started:!!H}),H)){const L=H.pages??[];(!Tn.started||!L.some(te=>te.page===tt))&&zn(xs(H))}f.useEffect(()=>{Oe(new Set),Se.set(null)},[D,I,Se]);const tr=Tn.key===Nn&&Tn.started,ys=f.useMemo(()=>tr&&H?yd(H.pages,H.punctuations):[],[tr,H]),nr=f.useCallback(L=>{const te=jd(L.headings);return te.length>0?te:L.file===D?ys:[]},[D,ys]),Jp=f.useCallback(L=>{if(Oe(new Set(L)),L.length>0){const te=L[0],Ie=parseInt(te.split(":")[0],10);isNaN(Ie)||zn(Ie)}},[]),At=f.useMemo(()=>{const L=new Map;for(const te of(H==null?void 0:H.pages)??[])L.set(te.page,te);return L},[H]),In=mt(H),ni=f.useCallback(L=>{var Qe;const te=Y.images;if(!te||te.length===0)return;const Ie=(Qe=At.get(L))==null?void 0:Qe.seq;return(Ie?te.find(qe=>qe.seq===Ie):void 0)??te.find(qe=>qe.pageNo===L)??te[L-1]},[Y.images,At]),js=Je>1.5,ii=f.useCallback((L,te=!1)=>{const Ie=ni(L);return Ie?L===In||te?Ie.hiresUrl??Ie.url:Ie.url:L===In?(H==null?void 0:H.imageUrl)??"":""},[ni,H,In]),Qp=f.useMemo(()=>ii(tt,js),[ii,tt,js]),Mt=f.useMemo(()=>[...At.keys()].sort((L,te)=>L-te),[At]),Jt=f.useRef(tt);Jt.current=tt;const ir=f.useRef(0),rr=f.useRef({page:null,timer:null}),eu=f.useCallback(L=>{const te=rr.current;L!==te.page&&(te.timer&&(clearTimeout(te.timer),te.timer=null),te.page=null,!(L===Jt.current||Date.now()<ir.current)&&(te.page=L,te.timer=setTimeout(()=>{te.timer=null,te.page=null,!(Date.now()<ir.current||Jt.current===L)&&(Jt.current=L,zn(L))},Mx)))},[]);f.useEffect(()=>()=>{rr.current.timer&&clearTimeout(rr.current.timer)},[]);const ri=f.useCallback(L=>{var te;Jt.current===L||!At.has(L)||(ir.current=Date.now()+1e3,Jt.current=L,zn(L),(te=At.get(L))!=null&&te.columns.some(Ie=>Ie.chars.length>0)&&pt(Ie=>({page:L,nonce:((Ie==null?void 0:Ie.nonce)??0)+1})))},[At]),Rn=f.useCallback(L=>{const te=Jt.current,Ie=Mt.indexOf(te),Qe=Mt[Ie<0?0:Ie+L];Qe===void 0||Qe===te||ri(Qe)},[Mt,ri]),vs=f.useCallback(L=>{if(!L.trim().match(/^\d+$/)||Mt.length===0)return null;const Ie=parseInt(L.trim(),10),Qe=Number.isFinite(Ie)?Ie:Number.MAX_SAFE_INTEGER;return Mt.reduce((qe,Ct)=>Math.abs(Ct-Qe)<Math.abs(qe-Qe)?Ct:qe,Mt[0])},[Mt]),[or,sr]=f.useState(null),oi=f.useRef(null),tu=f.useCallback(L=>{oi.current=L,sr(L)},[]),ks=f.useCallback(()=>{const L=oi.current;if(oi.current=null,sr(null),L===null)return;const te=vs(L);te!==null&&ri(te)},[vs,ri]),ar=Mt.indexOf(tt),nu=f.useCallback(L=>{if(L.altKey||L.ctrlKey||L.metaKey)return;const te=L.target.tagName;te==="INPUT"||te==="TEXTAREA"||te==="SELECT"||(L.key==="ArrowLeft"||L.key==="PageUp"?(L.preventDefault(),Rn(-1)):(L.key==="ArrowRight"||L.key==="PageDown")&&(L.preventDefault(),Rn(1)))},[Rn]),ws=f.useRef(null);f.useEffect(()=>{if(!H)return;const L=ws.current;if(!(!L||L.offsetWidth===0))for(const te of[1,-1]){const Ie=ii(tt+te);Ie&&Zr(Ie)}},[H,tt,ii]);const Ss=f.useMemo(()=>{var Ms;if(!H)return null;if(tt===In)return H;const L=At.get(tt);if(L&&L.width>0&&L.height>0)return{page_id:`p:${tt}`,title:`第${tt}葉`,image_size:[L.width,L.height],total_warped_w:L.width,columns:[{col:1,warped_w:L.width,warped_h:L.height,offset_x:0,strips:[],chars:L.columns.flatMap(it=>it.chars).map(it=>({id:it.id,char:it.char,slot:it.slot,pos:it.pos,sub:it.sub,bbox_col:it.bbox??[0,0,0,0]}))}]};const te=(Ms=H.pages)==null?void 0:Ms.find(it=>it.page===tt),[Ie,Qe]=H.image_size||[2386,3082],qe=ni(tt),Ct=(qe==null?void 0:qe.width)??Ie,ur=(qe==null?void 0:qe.height)??Qe,Es=Ct/Ie,Ls=ur/Qe,As=new Map;for(const it of H.columns){const vt=(it.strips||[]).flatMap(di=>di.srcQuad.map(pi=>pi[0]));if(vt.length===0)continue;const Pt=it.top_y??0,mr=it.bottom_y??Pt+it.warped_h;As.set(it.col,{x0:Math.min(...vt),x1:Math.max(...vt),top:Pt,slotH:(mr-Pt)/21})}return{page_id:`p:${tt}`,title:`第${tt}葉`,image_size:[Ct,ur],total_warped_w:Ct,columns:te?te.columns.map(it=>{const vt=As.get(it.col)??{x0:0,x1:0,top:0,slotH:118};return{col:it.col,warped_w:Ct,warped_h:ur,offset_x:0,strips:[],chars:it.chars.map(Pt=>{const mr=Pt.slot??Pt.pos??0,di=(vt.top+(mr-1)*vt.slotH)*Ls,pi=(vt.x0+vt.x1)/2,[mu,hu]=Pt.sub==="a"?[pi,vt.x1]:Pt.sub==="b"?[vt.x0,pi]:[vt.x0,vt.x1];return{...Pt,bbox_col:[mu*Es,di,hu*Es,di+vt.slotH*Ls]}})}}):[]}},[H,tt,In,At,ni]),{entryTitle:si,authors:_s}=Ux(n,i,c===void 0),[$s,lr]=f.useState("text");f.useEffect(()=>{lr("text")},[D,I]);const iu=f.useMemo(()=>ke?Wx(ke,se,Ha(q,ke),R,Ze,nr):[],[ke,se,q,R,Ze,nr]);if(ae==="loading")return t.jsx(Wa,{className:z,style:C,title:c??si,label:_("reader.loading")});if(ae==="missing"||!A||!q)return t.jsx("div",{className:z,style:{...C,...Oa},children:_("reader.noText")});if(ue==="failed")return t.jsx("div",{className:z,style:{...C,...Oa},children:_("reader.tocFailed")});if(!ke)return t.jsx(Wa,{className:z,style:C,title:c??si,label:_("reader.tocLoading")});const dn=Ha(q,ke),ru=iu,Cs=Ge&&D&&Ge.chapter===D?ts(D,Ge.anchor):null,ou=Cs&&le&&nr(le).some(L=>L.anchor===Ge.anchor)?Cs:D??null,cr=A.versions.map(L=>({key:L.key,label:ze.textVersionLabel(L),optionLabel:R(ze.textVersionLabel(L)),sourceName:Da(L)?_("reader.originalSource"):L.source_name?R(L.source_name):void 0,license:L.license??void 0,sourceUrl:L.source_url??void 0,primary:L.key===je})),jt=Bx((Rs=ke.source)==null?void 0:Rs.upstream),ai=(typeof c=="string"?R(c):c)??(ke.title?R(ke.title):si?R(si):void 0),zs=q.edition_label?R(q.edition_label):void 0,dr=ai?t.jsx("a",{href:W(n),title:_("reader.viewEntry"),onClick:l?L=>{L.metaKey||L.ctrlKey||(L.preventDefault(),l(n))}:void 0,children:ai}):void 0,su=dr&&zs?t.jsxs(t.Fragment,{children:[dr,t.jsxs("span",{className:"bim-rd-ed",children:["·",zs]})]}):dr,au=_s.length>0?R(_s.slice(0,2).map(L=>`${L.dynasty?`〔${L.dynasty}〕`:""}${L.name}${` ${L.role||_("reader.defaultRole")}`}`).join("、")):void 0,pr=le?wd(le,dn,R,Ze):void 0,Qt=Ze&&!!(pe!=null&&pe.json),en=(pe==null?void 0:pe.json)??null,pn=(pe==null?void 0:pe.md)??null,Ns=Qt&&!K&&pd(en.sections),lu=Ns&&!(pn&&J.readingMode==="paragraph"&&Ci(pn)),cu=Qt&&Ns?t.jsx(Xg,{juan:en,view:$s,onView:lr,textHasEntries:lu}):void 0,du=!0,li=pn?pn.replace(/^##\s+[^\n]+\n+/,""):null,ci=Da(q),Vt=ci?_("reader.originalSource"):q.source_name?R(q.source_name):void 0,pu=(typeof p=="string"?R(p):p)??(ci?void 0:Vt??R(ze.textVersionLabel(q))),uu=(H==null?void 0:H.hasNorm)===!0;return t.jsxs($c,{className:z,style:C,title:su,subtitle:pu,byline:au,current:pr,pagerUnit:dn,rail:cu,revisedAt:j,backHref:y,backLabel:S,onReportError:x?L=>x({...L,bookTitle:typeof ai=="string"?ai:void 0,entryId:n}):void 0,workLinkToggle:Qt&&!K&&!!l&&!!(en!=null&&en.sections.some(L=>L.work_id)),toc:ru,tocCaption:_("reader.tocCaption",{n:ke.chapters.length,unit:R(dn)}),tocHeader:Ze&&ke.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:K?_("reader.searchChaptersPlaceholder"):_("reader.searchUnitPlaceholder",{unit:R(dn)}),"aria-label":K?_("reader.searchChapters"):_("reader.searchUnit",{unit:R(dn)}),value:$,onChange:L=>M(L.target.value)}):void 0,activeKey:D??null,tocActiveKey:ou,onSelect:Te,images:Qr(le)&&fe&&!H?null:Y.images,renderImageOverlay:m,imagePanel:H?"open":u,isWarpMode:!!H,customImagePanel:H&&Ss?t.jsxs("div",{ref:ws,className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:nu,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:[ge.size>0&&t.jsxs("button",{type:"button",onClick:()=>Oe(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${r("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",ge.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:Je<=1,onClick:()=>{var L;return(L=Ke.current)==null?void 0:L.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(Je*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:Je>=6,onClick:()=>{var L;return(L=Ke.current)==null?void 0:L.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:Je===1,onClick:()=>{var L;return(L=Ke.current)==null?void 0:L.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(Ix,{ref:Ke,resetKey:tt,onScaleChange:ee,style:{flex:1,minHeight:0},children:t.jsx(za,{store:Se,children:L=>t.jsx(Ko,{imageUrl:Qp,pageData:Ss,selectedCharIds:ge,hoveredCharId:L,preserveMargins:at,renderScale:Je,onCharClick:te=>{Oe(Qe=>{const qe=new Set(Qe);return qe.has(te)?qe.delete(te):(qe.clear(),qe.add(te)),qe});const Ie=document.querySelector(`[data-char-id="${te}"]`);Ie&&Ie.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:Se.set})})}),t.jsxs("div",{"data-testid":"facsimile-pager",role:"group","aria-label":_("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:ar<=0,onClick:()=>Rn(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":tt,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":_("reader.facsimilePageInput"),size:Math.max(2,String(or??tt).length),value:or??String(tt),onFocus:L=>L.currentTarget.select(),onChange:L=>tu(L.target.value),onKeyDown:L=>{L.key==="Enter"?(L.preventDefault(),ks()):L.key==="Escape"&&(oi.current=null,sr(null)),L.stopPropagation()},onBlur:ks,style:{width:`${Math.max(2,String(or??tt).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:ar<0||ar>=Mt.length-1,onClick:()=>Rn(1),children:"›"})]})]}):void 0,settingsAnnotate:H?t.jsx("button",{type:"button",className:`bim-rd-t bim-rd-sp-tg ${Ue?"bim-rd-on":""}`,"aria-pressed":Ue,title:"切换外挂现代断句标点",onClick:()=>dt(L=>!L),children:Ue?"标点":"无标点"}):void 0,prefs:J,onPrefsChange:E,versions:cr.length>1?cr:void 0,currentVersionKey:cr.length>1?q.key:void 0,onVersionChange:Z,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:Ci(pn),allowVertical:g,origScriptAvailable:uu,contentLoading:Ye,children:[(Ye||fe&&!H&&!Qt&&li==null)&&t.jsx(ln,{}),!Ye&&H&&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:le!=null&&le.title?R(le.title):pr}),(Vt||q.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[Vt,q.license&&t.jsxs(t.Fragment,{children:[Vt&&t.jsx("span",{className:"bim-rd-dot"}),q.license]})]})]}),t.jsx(za,{store:Se,children:L=>t.jsx(Qo,{pageData:H,pages:H.pages,punctuations:H.punctuations||Px,selectedCharIds:ge,hoveredCharId:L,onSelectionChange:Jp,onCharClick:te=>{Oe(Qe=>{const qe=new Set(Qe);return qe.has(te)?qe.delete(te):(qe.clear(),qe.add(te)),qe});const Ie=parseInt(te.split(":")[0],10);isNaN(Ie)||zn(Ie)},onCharHover:Se.set,mode:"horizontal",showPunctuation:Ue,entities:Ee,entityTransport:i,onEntityNavigate:k,onVisiblePageChange:eu,convert:R,scrollToPage:Fe,scrollToAnchor:we&&we.chapter===D&&tr?we:null,onVisibleHeadingChange:te=>Xe(te&&D?{chapter:D,anchor:te}:null),pageBreaks:J.pageBreaks,pageIndicatorY:J.pageIndicatorY,onPageIndicatorYChange:te=>E({pageIndicatorY:te}),quoteStyle:J.quoteStyle,bookTitleStyle:J.bookTitleStyle,showWorks:J.showWorks})})]}),!Ye&&!H&&Qt&&en&&t.jsx(qg,{juan:en,rawText:pn,positionLabel:Hx(le,ke,dn,R),groupLabel:Dx(ke,D??null),index:Ox(n,ke),searchQuery:$,onNavigate:l,transport:i,workLabelCache:We,prefs:J,view:$s,onViewChange:lr},`${I}/${D}`),!Ye&&!H&&!Qt&&li!=null&&le&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:le.title?R(le.title):pr}),(Vt||q.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[ci&&Vt&&t.jsx(t.Fragment,{children:Vt}),!ci&&q.source_name&&t.jsxs(t.Fragment,{children:[_("reader.textSource")," ",q.source_url?t.jsx("a",{className:"bim-rd-link",href:q.source_url,target:"_blank",rel:"noreferrer",children:R(q.source_name)}):R(q.source_name)]}),Vt&&q.license&&t.jsx("span",{className:"bim-rd-dot"}),q.license]}),jt&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[_("reader.upstream")," ",jt.url?t.jsx("a",{className:"bim-rd-link",href:jt.url,target:"_blank",rel:"noreferrer",children:R(jt.name??jt.url)}):R(jt.name??""),jt.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),jt.license_url?t.jsx("a",{className:"bim-rd-link",href:jt.license_url,target:"_blank",rel:"noreferrer",children:jt.license}):jt.license]}),jt.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(fc,{text:jt.note,convert:R})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(Fo,{text:li,mode:J.readingMode,tables:du,gujiMarkdown:!0,bookMarking:Wo(J),quoteStyle:J.quoteStyle})})]}),!Ye&&!fe&&!H&&!Qt&&li==null&&le&&t.jsx("div",{className:"bim-rd-state",children:_("reader.chapterFailed")}),!Ye&&ke.references&&ke.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:_("reader.references")}),t.jsx("ol",{children:ke.references.map((L,te)=>t.jsxs("li",{children:[L.url?t.jsx("a",{className:"bim-rd-link",href:L.url,target:"_blank",rel:"noopener noreferrer",children:R(L.title)}):t.jsx("span",{children:R(L.title)}),L.author&&t.jsxs("span",{children:[",",R(L.author)]}),L.note&&t.jsxs("span",{children:["。",R(L.note)]})]},te))})]})]})};function Da(e){return e.is_original===!0||e.source==="original"}function Hx(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 Dx(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 Ux(e,n,i){const[o,s]=f.useState({entryTitle:void 0,authors:[]});return f.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let a=!1;return Promise.resolve(n.getItem(e)).then(l=>{if(a||!l)return;const d=(l.authors??[]).filter(c=>c&&c.name);s({entryTitle:i&&typeof l.title=="string"?l.title:void 0,authors:d})}).catch(()=>{}),()=>{a=!0}},[e,n,i]),o}const _d={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")}},Vx=_d.other,$d={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")}},Gx=$d.pending;function Yx(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 qx(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 is=({items:e,loading:n})=>{const i=st(),{t:o,convert:s}=re();return n?t.jsx(ln,{}):e.length===0?t.jsx("div",{style:Kx,children:o("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=_d[a.type]||Vx,d=$d[a.status]||Gx,c=typeof window<"u"&&qx(a.pageUrl,window.location.href);return t.jsxs("div",{style:Xx,children:[t.jsxs("div",{style:Zx,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...Ua,background:l.color},children:o(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...Ua,background:d.color},children:o(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:Jx,children:Yx(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:Qx,children:[a.resourceId&&t.jsx("a",{href:i(a.resourceId),style:$r,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:$r,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:$r,children:a.pageUrl}))]}),t.jsx("div",{style:eb,children:s(a.content)}),a.reply&&t.jsxs("div",{style:tb,children:[t.jsx("div",{style:nb,children:o("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},Kx={textAlign:"center",padding:"40px 0",color:r("desc-fg"),fontSize:"14px"},Xx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"16px"},Zx={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},Ua={fontSize:"12px",color:r("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},Jx={fontSize:"12px",color:r("desc-fg")},Qx={fontSize:"12px",marginBottom:"6px"},$r={color:r("primary"),textDecoration:"none",borderBottom:`1px dashed ${r("primary")}`},eb={fontSize:"14px",lineHeight:"1.6",color:r("fg"),whiteSpace:"pre-wrap"},tb={marginTop:"12px",padding:"10px 12px",background:r("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:r("fg")},nb={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:r("primary")},eo=({transport:e,onNavigate:n,recommendedIds:i,activeTab:o,onTabChange:s,feedbackApiUrl:a})=>{const l=Ae(),[d,c]=f.useState(null),[p,h]=f.useState([]),[m,u]=f.useState("recommend"),[g,x]=f.useState([]),[j,y]=f.useState(!1),S=o??m,b=A=>{u(A),s==null||s(A)},[w,v]=f.useState(!0),[k,z]=f.useState(null),[C,_]=f.useState(null),[R,T]=f.useState(null);f.useEffect(()=>{let A=!1;if(e.getCounts)return e.getCounts().then(V=>{A||c({works:V.works,books:V.books,collections:V.collections})}).catch(()=>{}),()=>{A=!0}},[e]),f.useEffect(()=>{let A=!1;return(async()=>{if(i)return i;if(e.getRecommended)try{const ae=await e.getRecommended();if(ae!=null&&ae.groups)return ae.groups.flatMap(xe=>xe.items.map(me=>({...me,group:xe.name})))}catch{}return[]})().then(async ae=>{if(A)return;const xe=ae.filter(G=>G.id);if(xe.length===0){v(!1);return}const me=await Promise.all(xe.map(async G=>{if(G.type)return{id:G.id,title:G.title,type:G.type,author:G.author,dynasty:G.dynasty,role:G.role,edition:G.edition,has_text:G.has_text,has_image:G.has_image,has_collated:G.has_collated,subtype:G.subtype,primary_name:G.primary_name,group:G.group,fallbackDescription:G.description};try{let ye=null;if(e.getEntry)ye=await e.getEntry(G.id);else{const ne=await e.getItem(G.id);ne&&(ye={id:G.id,title:ne.title||G.id,type:ne.type||"work"})}if(ye)return{...ye,group:G.group,fallbackDescription:G.description}}catch{}return{id:G.id,title:G.title,type:ze.extractType(G.id),group:G.group,fallbackDescription:G.description}}));A||(h(me.filter(G=>G!==null)),v(!1))}),()=>{A=!0}},[e,i]);const N=f.useRef(!1),E=f.useRef(!1),W=f.useRef(!1);f.useEffect(()=>{if(S!=="catalog"||N.current)return;const A=e.getCatalogProgress??e.getResourceProgress;if(!A)return;N.current=!0;let V=!1;return A.call(e).then(ae=>{V||z(ae)}).catch(()=>{N.current=!1}),()=>{V=!0}},[e,S]),f.useEffect(()=>{if(S!=="collection"||E.current||!e.getCollectionProgress)return;E.current=!0;let A=!1;return e.getCollectionProgress().then(V=>{A||_(V)}).catch(()=>{E.current=!1}),()=>{A=!0}},[e,S]),f.useEffect(()=>{if(S!=="site"||W.current||!e.getSiteProgress)return;W.current=!0;let A=!1;return e.getSiteProgress().then(V=>{A||T(V)}).catch(()=>{W.current=!1}),()=>{A=!0}},[e,S]),f.useEffect(()=>{if(!a||S!=="feedback")return;let A=!1;return y(!0),fetch(a).then(V=>V.json()).then(V=>{!A&&V.success&&x(V.items||[])}).catch(()=>{}).finally(()=>{A||y(!1)}),()=>{A=!0}},[a,S]);const F=A=>t.jsx($n,{type:A,size:12});return t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:r("fg")},children:t.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[t.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${r("widget-border")}`,marginBottom:"16px"},children:[t.jsx(Pn,{label:l.home.recommendTab,active:S==="recommend",onClick:()=>b("recommend")}),t.jsx(Pn,{label:l.home.catalogTab,active:S==="catalog",onClick:()=>b("catalog")}),t.jsx(Pn,{label:l.home.collectionTab,active:S==="collection",onClick:()=>b("collection")}),t.jsx(Pn,{label:l.home.siteTab,active:S==="site",onClick:()=>b("site")}),a&&t.jsx(Pn,{label:l.home.feedbackTab,active:S==="feedback",onClick:()=>b("feedback")})]}),S==="recommend"&&t.jsx(ib,{recommended:p,loading:w,onNavigate:n,getIcon:F,t:l}),S==="catalog"&&t.jsx(Va,{progress:k,t:l,onNavigate:n}),S==="collection"&&t.jsx(Va,{progress:C,t:l,onNavigate:n}),S==="site"&&t.jsx(ob,{progress:R,t:l,totalWorks:(d==null?void 0:d.works)??0}),S==="feedback"&&a&&t.jsx(is,{items:g,loading:j})]})})},Pn=({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}),ib=({recommended:e,loading:n,onNavigate:i,getIcon:o,t:s})=>{const a=st();if(n)return t.jsx(ln,{});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:m=>{m.metaKey||m.ctrlKey||(m.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))})},Va=({progress:e,t:n,onNavigate:i})=>{if(!e)return t.jsx(ln,{});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(rb,{item:p,t:n,statusColor:l[d],onNavigate:i},p.id))})]},d)})})},rb=({item:e,t:n,statusColor:i,onNavigate:o})=>{const s=st(),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?wt(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})]})},ob=({progress:e,t:n,totalWorks:i})=>{if(!e)return t.jsx(ln,{});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(Ga,{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(Ga,{item:c,t:n,totalWorks:i},c.id))})]})]})},Ga=({item:e,t:n,totalWorks:i})=>{const o=i>0?Math.round(e.imported/i*100):0;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:t.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:e.url?t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:e.name}):e.name})}),t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.imported>0?`${e.imported.toLocaleString()} ${n.indexType.work} (${o}%)`:n.home.statusTodo})]}),e.imported>0&&i>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:r("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${o}%`,borderRadius:"2px",background:r("progress-done"),transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"4px"},children:e.description})]})},Ya="(max-width: 768px)";function sb(){const[e,n]=f.useState(()=>typeof window>"u"?!1:window.matchMedia(Ya).matches);return f.useEffect(()=>{const i=window.matchMedia(Ya),o=s=>n(s.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),e}const ab=({transport:e,hideModeIndicator:n=!0,onEntryClick:i,recommendedIds:o,headerRight:s})=>{var E;const a=Ae(),{convert:l}=Ve(),d=sb(),[c,p]=f.useState(null),[h,m]=f.useState(null),[u,g]=f.useState(!1),[x,j]=f.useState("detail"),[y,S]=f.useState([]),[b,w]=f.useState(!1),v=f.useCallback(async W=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){S([]);return}w(!0);try{if(e.getCollectionCatalogs){const F=await e.getCollectionCatalogs(W);S(F||[])}else if(e.getCollectionCatalog){const F=await e.getCollectionCatalog(W);S(F?[{resource_id:"",data:F}]:[])}}catch{S([])}finally{w(!1)}},[e]),k=f.useCallback(async W=>{if(i){i(W);return}p(W),m(null),S([]),j("detail"),g(!0);try{const F=await e.getItem(W.id);F&&(m(F),F.type==="collection"&&v(W.id))}catch(F){console.error("加载详情失败:",F)}finally{g(!1)}},[e,i,v]),z=f.useCallback(async W=>{m(null),S([]),j("detail"),g(!0);try{const F=await e.getItem(W);F&&(m(F),p({id:W,title:F.title||W,type:F.type||"book"}),F.type==="collection"&&v(W))}catch(F){console.error("导航失败:",F)}finally{g(!1)}},[e,v]),C=typeof(h==null?void 0:h.text_count)=="number"&&h.text_count>0,_=(h==null?void 0:h.type)==="collection"&&(y.length>0||b)||(h==null?void 0:h.type)==="work"&&C,R=d&&(u||h),T=f.useCallback(()=>{p(null),m(null),S([]),j("detail")},[]),N=t.jsx(t.Fragment,{children:u?t.jsx(ln,{}):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:()=>j("detail"),style:gi(x==="detail"),children:a.detailTab.basicInfo}),h.type==="collection"&&b&&y.length===0&&t.jsxs("button",{onClick:()=>{},style:gi(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),h.type==="collection"&&y.map(W=>t.jsx("button",{onClick:()=>j(`catalog:${W.resource_id}`),style:gi(x===`catalog:${W.resource_id}`),children:W.short_name?`${l(W.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},W.resource_id)),h.type==="work"&&C&&t.jsx("button",{onClick:()=>j("collated"),style:gi(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(Co,{data:h,transport:e,onNavigate:z}):x.startsWith("catalog:")?t.jsx(zo,{data:(E=y.find(W=>`catalog:${W.resource_id}`===x))==null?void 0:E.data,onNavigate:z}):x==="collated"?t.jsx(ns,{id:h.id,transport:e,onNavigate:z}):null})]}):t.jsx(eo,{transport:e,onNavigate:z,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:R?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:N})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(Or,{transport:e,onEntryClick:k,hideModeIndicator:n}),!h&&t.jsx(eo,{transport:e,onNavigate:z,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(Or,{transport:e,onEntryClick:k,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:r("bg"),display:"flex",flexDirection:"column"},children:N})]})};function gi(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 lb=({pageData:e,rawImageUrl:n="",punctuations:i=[],title:o,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=f.useState(new Set),[h,m]=f.useState(null),[u,g]=f.useState("horizontal"),[x,j]=f.useState(!0),y=f.useRef(null),S=f.useCallback(k=>{p(new Set(k))},[]),b=f.useCallback(k=>{if(p(z=>{const C=new Set(z);return C.has(k)?C.delete(k):(C.clear(),C.add(k)),C}),y.current){const z=y.current.querySelector(`[data-char-id="${k}"]`);z&&z.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),w=()=>{var k;p(new Set),window.getSelection&&((k=window.getSelection())==null||k.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:()=>j(k=>!k),className:`guji-reader-btn ${x?"active":""}`,title:"独立外挂标点 (guji-punct v0.1)",children:x?"✓ 标点":"底本文本"}),t.jsx("button",{type:"button",onClick:()=>g(k=>k==="horizontal"?"vertical":"horizontal"),className:"guji-reader-btn primary",children:u==="horizontal"?"切换竖排":"切换横排"})]})]}),t.jsxs("div",{className:"guji-reader-body",children:[t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%",position:"sticky",top:0},children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:"底本书影 (WebGL 分带透视矫正 + 完整版心)"}),t.jsx("span",{className:"guji-pane-hint",children:"点击字框可联动文本定位"})]}),t.jsx("div",{className:"guji-pane-content",children:t.jsx(Ko,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:h,onCharClick:b,onCharHover:m})})]}),t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%"},ref:y,children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:u==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(Qo,{pageData:e,punctuations:v,selectedCharIds:c,hoveredCharId:h,onSelectionChange:S,onCharClick:b,onCharHover:m,mode:u,showPunctuation:x})]})]})]})},cb=e=>typeof e=="string"&&Array.from(e).length===1,db=new Set(["point","break","heading"]),pb=/^#{1,6}$/;function ub(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.punctuations)?e.punctuations:[],i=[];for(const o of n){if(!o||typeof o!="object")continue;const s=o;if(typeof s.anchor!="string"||typeof s.mark!="string"||s.pre_char!=null&&!cb(s.pre_char)||s.kind!=null&&!db.has(s.kind)||s.pos!=null&&s.pos!=="after"&&s.pos!=="before")continue;const a={id:typeof s.id=="string"?s.id:void 0,anchor:s.anchor,mark:s.mark,kind:s.kind,pos:s.pos,pre_char:s.pre_char??void 0};if(!(s.kind==="break"&&s.pos==="before")){if(s.kind==="heading"){if(s.pos!=="before"||!pb.test(s.mark))continue;typeof s.label=="string"&&s.label.trim()&&(a.label=s.label.trim()),s.toc===!1&&(a.toc=!1)}i.push(a)}}return i}function mb(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 Cd=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function ht(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}const hb=new Set(["main","solo","jz_r","jz_l"]),fb=new Set(["body","banxin","blank"]);function gb(e){const n={};return typeof e.lane=="string"&&hb.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 xb(e){const n={};typeof e.kind=="string"&&fb.has(e.kind)&&e.kind!=="body"&&(n.kind=e.kind);const i=ht(e.raised);i!==void 0&&Number.isInteger(i)&&i>0&&(n.raised=i);const o=ht(e.lead_blank);return o!==void 0&&Number.isInteger(o)&&o>0&&(n.lead_blank=o),n}function Cr(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(i=>!!i&&typeof i=="object"):[]}function bb(e){return typeof e=="string"&&Array.from(e).length===1}function zd(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"||!Cd.test(a)){i.badAnchor++;continue}if(!bb(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 zd(e).map}function yb(e,n,i){var h,m,u,g,x,j,y,S,b,w;const o=i==null?null:Nd(i),s=new Map,a=new Map;for(const v of Cr(n)){const k=ht(v.page);if(k!==void 0){s.set(k,v);for(const z of Array.isArray(v.cells)?v.cells:[]){const C=z==null?void 0:z.box;typeof(z==null?void 0:z.a)=="string"&&Array.isArray(C)&&C.length===4&&C.every(_=>ht(_)!==void 0)&&a.set(z.a,[C[0],C[1],C[0]+C[2],C[1]+C[3]])}}}const l=[],d=new Map,c=new Map;for(const v of Cr(e)){const k=ht(v.page);k!==void 0&&typeof v.label=="string"&&v.label&&d.set(k,v.label)}for(const v of Cr(e)){const k=ht(v.page);if(k===void 0)continue;const z=[];for(const _ of Array.isArray(v.columns)?v.columns:[]){const R=ht(_==null?void 0:_.col);if(R===void 0)continue;const T=[];for(const E of Array.isArray(_.cells)?_.cells:[]){const W=Cd.exec(String((E==null?void 0:E.a)??""));if(!W||typeof E.c!="string")continue;const F=parseInt(W[3],10),A=o==null?void 0:o.get(E.a);T.push({id:E.a,char:E.c,slot:F,pos:F,sub:W[4]||null,bbox:a.get(E.a)??null,...gb(E),...A!==void 0&&A!==E.c?{norm:A}:{}})}const N=xb(_);(T.length>0||N.kind==="blank")&&z.push({col:R,chars:T,...N})}if(!z.some(_=>_.chars.length>0)){z.length>0&&c.set(k,z);continue}z.sort((_,R)=>_.col-R.col);const C=s.get(k);l.push({page:k,seq:String(((h=C==null?void 0:C.canvas)==null?void 0:h.seq)??""),width:ht((m=C==null?void 0:C.canvas)==null?void 0:m.width)??ht((u=C==null?void 0:C.image)==null?void 0:u.width)??0,height:ht((g=C==null?void 0:C.canvas)==null?void 0:g.height)??ht((x=C==null?void 0:C.image)==null?void 0:x.height)??0,...typeof v.label=="string"&&v.label?{label:v.label}:{},columns:z})}const p=new Set(l.map(v=>v.page));for(const[v,k]of s){const z=(j=k==null?void 0:k.canvas)==null?void 0:j.seq;p.has(v)||typeof z!="string"&&typeof z!="number"||String(z)===""||l.push({page:v,seq:String(z),width:ht((y=k.canvas)==null?void 0:y.width)??ht((S=k.image)==null?void 0:S.width)??0,height:ht((b=k.canvas)==null?void 0:b.height)??ht((w=k.image)==null?void 0:w.height)??0,...d.has(v)?{label:d.get(v)}:{},columns:c.get(v)??[]})}return l.sort((v,k)=>v.page-k.page)}const jb=({data:e,onNavigate:n,className:i,style:o})=>{var h;const{t:s,convert:a}=re(),[l,d]=f.useState(((h=e.divisions[0])==null?void 0:h.name)??null),[c,p]=f.useState(null);return t.jsxs("div",{className:i,style:o,children:[t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:r("fg"),margin:"0 0 8px"},children:a(e.title)}),e.stats&&t.jsxs("div",{style:{fontSize:"13px",color:r("desc-fg"),display:"flex",gap:"16px"},children:[e.total_volumes!=null&&t.jsxs("span",{children:[s("catalog.totalVolumes")," ",t.jsx("strong",{children:e.total_volumes})," ",s("unit.juan")]}),e.stats.zhulu!=null&&t.jsxs("span",{children:[s("catalogPage.zhulu")," ",t.jsx("strong",{children:e.stats.zhulu})," ",s("unit.bu")]}),e.stats.cunmu!=null&&t.jsxs("span",{children:[s("catalogPage.cunmu")," ",t.jsx("strong",{children:e.stats.cunmu})," ",s("unit.bu")]}),e.stats.categories!=null&&t.jsx("span",{children:s("catalogPage.categoriesN",{n:e.stats.categories})})]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.divisions.map(m=>t.jsx(vb,{division:m,expanded:l===m.name,onToggle:()=>d(l===m.name?null:m.name),expandedCat:c,onCatToggle:u=>p(c===u?null:u),onNavigate:n},m.name))})]})},vb=({division:e,expanded:n,onToggle:i,expandedCat:o,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=re(),c=e.categories.reduce((p,h)=>{const m=h.stats||{zhulu:0,cunmu:0};return p+(m.zhulu||0)+(m.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(kb,{category:p,expanded:o===h,onToggle:()=>s(h),onNavigate:a},p.name)})})]})},kb=({category:e,expanded:n,onToggle:i,onNavigate:o})=>{var p,h,m,u;const{t:s,convert:a}=re(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((h=e.books)==null?void 0:h.cunmu)||[],c=(((m=e.stats)==null?void 0:m.zhulu)||l.length)+(((u=e.stats)==null?void 0:u.cunmu)||d.length);return t.jsxs("div",{children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px 6px 28px",border:"none",background:n?r("input-bg"):"transparent",cursor:"pointer",fontSize:"13px",color:r("fg"),textAlign:"left"},children:[t.jsxs("span",{style:{fontWeight:500},children:[a(e.name),e.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:a(e.volumes)})})]}),t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[s("catalogPage.booksN",{n:c})," ",n?"▲":"▼"]})]}),n&&(l.length>0||d.length>0)&&t.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[l.length>0&&t.jsx(qa,{label:s("catalogPage.zhulu"),books:l,onNavigate:o}),d.length>0&&t.jsx(qa,{label:s("catalogPage.cunmu"),books:d,onNavigate:o})]})]})},qa=({label:e,books:n,onNavigate:i})=>{const{t:o,convert:s}=re(),a=st(),[l,d]=f.useState(n.length<=20),c=l?n:n.slice(0,10);return t.jsxs("div",{style:{marginBottom:"8px"},children:[t.jsxs("div",{style:{fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},children:[e," (",n.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((p,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:m=>{m.metaKey||m.ctrlKey||(m.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})})]})},zt=({title:e,onSave:n,onAskAI:i,extraButtons:o,children:s})=>{const a=Ae();return t.jsxs("div",{style:{background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",paddingBottom:"8px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:r("fg")},children:e}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[o,i&&t.jsx("button",{onClick:i,style:Sb,children:"AI"}),n&&t.jsx("button",{onClick:n,style:wb,children:a.action.save})]})]}),s]})},wb={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Sb={padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},kt=({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"}})]}),an=({value:e,onChange:n,placeholder:i})=>{const o=f.useRef(null);return f.useEffect(()=>{o.current&&(o.current.style.height="auto",o.current.style.height=`${o.current.scrollHeight}px`)},[e]),t.jsx("textarea",{ref:o,value:e||"",onChange:s=>n(s.target.value),placeholder:i,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},Ni=({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 _b(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const ki=({value:e,onChange:n,label:i})=>{const[o,s]=f.useState(!1),a=f.useRef(null),l=_b(e||"");return f.useEffect(()=>{o&&a.current&&a.current.focus()},[o]),!o&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Ka,children:i}),t.jsxs("div",{onClick:()=>s(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:`1px solid ${r("input-border")}`,borderRadius:"2px",background:r("input-bg"),cursor:"pointer",minHeight:"30px"},children:[t.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:r("fg")},children:l.name}),t.jsx(Ni,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Ka,children:i}),t.jsx("input",{ref:a,type:"text",value:e||"",onChange:d=>n(d.target.value),onBlur:()=>s(!1),style:{width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},Ka={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500};function $b(e){switch(e){case"url":return r("source-url");case"bookID":return r("source-bookid");default:return r("desc-fg")}}function Cb(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const Td=({items:e,onChange:n,onOpenEntityPicker:i})=>{const o=Ae(),[s,a]=f.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=m=>{n(e.filter((u,g)=>g!==m)),s===m&&a(null)},c=(m,u,g)=>{const x=[...e];x[m]={...x[m],[u]:g},n(x)},p=(m,u)=>{const g=[...e];g[m]={...g[m],type:u,id:"",name:""},n(g),u==="bookID"&&i&&i(x=>{const j=[...e];j[m]={...j[m],id:x.id,name:x.title,type:"bookID"},n(j)})},h=m=>{i&&i(u=>{const g=[...e];g[m]={...g[m],id:u.id,name:u.title,type:"bookID"},n(g)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((m,u)=>t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>a(s===u?null:u),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===u?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:r("fg")},children:m.name||`${o.editor.sourcePlaceholder} ${u+1}`}),m.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:$b(m.type),color:r("on-color-fg"),borderRadius:"3px",fontWeight:500},children:Cb(m.type)}),t.jsx("button",{onClick:g=>{g.stopPropagation(),d(u)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:o.editor.deleteThisSource,children:"✕"})]}),s===u&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!m.type&&t.jsxs("div",{children:[t.jsx("label",{style:Bt,children:o.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(u,"bookID"),style:{...Xa,borderColor:r("source-bookid"),color:r("source-bookid")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"📚"}),t.jsx("span",{children:"Book ID"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.fromExistingBook})]}),t.jsxs("button",{onClick:()=>p(u,"url"),style:{...Xa,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})]})]})]}),m.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:Bt,children:o.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const g=[...e];g[u]={...g[u],type:"",id:"",name:""},n(g)},style:Za,children:o.action.changeType})]}),m.id&&m.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:m.name}),t.jsx("code",{style:{fontSize:"11px",background:r("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:m.id})]}),t.jsx("button",{onClick:()=>h(u),style:{background:"transparent",border:`1px solid ${r("widget-border")}`,color:r("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:o.action.reselect})]}):t.jsxs("button",{onClick:()=>h(u),style:{width:"100%",padding:"14px",border:`2px dashed ${r("widget-border")}`,borderRadius:"6px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[t.jsx("span",{children:"🔍"}),t.jsx("span",{children:o.action.clickToSelectBookOrWork})]})]})}),m.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:Bt,children:o.label.sourceName}),t.jsx("button",{onClick:()=>{const g=[...e];g[u]={...g[u],type:"",id:"",name:""},n(g)},style:Za,children:o.action.changeType})]}),t.jsx("input",{type:"text",value:m.name,onChange:g=>c(u,"name",g.target.value),placeholder:o.editor.sourceNamePlaceholder,style:hn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Bt,children:o.label.urlAddress}),t.jsx("input",{type:"text",value:m.id,onChange:g=>c(u,"id",g.target.value),placeholder:"https://...",style:hn})]})]}),m.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:{...Bt,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:Bt,children:o.label.detailsOptional}),t.jsx("input",{type:"text",value:m.details,onChange:g=>c(u,"details",g.target.value),placeholder:o.editor.detailsPlaceholder,style:hn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Bt,children:o.label.positionOptional}),t.jsx("input",{type:"text",value:m.position,onChange:g=>c(u,"position",g.target.value),placeholder:"如: 卷三, p.52",style:hn})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Bt,children:o.label.dataVersionOptional}),t.jsx("input",{type:"text",value:m.version,onChange:g=>c(u,"version",g.target.value),placeholder:"如: v1.0, 2024-01",style:hn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Bt,children:o.label.processorVersionOptional}),t.jsx("input",{type:"text",value:m.processor_version,onChange:g=>c(u,"processor_version",g.target.value),placeholder:"如: v0.1",style:hn})]})]})]})]})})]},u)),t.jsxs("button",{onClick:l,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:o.action.addSource})]})]})},Bt={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},hn={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"},Xa={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"},Za={background:"transparent",border:"none",color:r("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function Id(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 Rd(e){return!e||e.length===0?"":JSON.stringify(e)}const Ed=({entityType:e,entityId:n,entityTitle:i,parentWork:o,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:h,onLinkEntity:m,onUnlinkEntity:u,onViewEntity:g,onCreateAndLink:x,onSaveRelations:j})=>{const y=Ae();return t.jsxs("div",{style:{background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:"🔗"}),t.jsx("span",{children:y.section.relations})]}),j&&t.jsx("button",{onClick:j,style:zb,children:y.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(Bn,{direction:"up",title:y.relation.belongsToWork,entity:a,onView:g,onUnlink:()=>u("workId"),onLink:()=>m("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(Bn,{direction:"up",title:y.relation.containedInCollection,entity:l,onView:g,onUnlink:()=>u("collectionId"),onLink:()=>m("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(fn,{direction:"horizontal",title:`${y.relation.siblingVersions} (${h.length})`,entities:h,onView:g,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(Bn,{direction:"up",title:y.relation.parentWork,entity:o,onView:g,onUnlink:()=>u("parentWorkId"),onLink:()=>m("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(fn,{direction:"down",title:`${y.relation.childWorks} (${d.length})`,entities:d,onView:g,onAdd:()=>x("childWork","work",{parentWorkId:n}),addLabel:y.action.addSubWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),c&&c.length>0&&t.jsx(fn,{direction:"down",title:`${y.relation.collectionImpl} (${c.length})`,entities:c,onView:g,onAdd:()=>x("childCollection","collection",{workId:n}),addLabel:y.action.addCollectionImpl,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(fn,{direction:"down",title:`${y.relation.allVersions} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:g,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(Bn,{direction:"up",title:y.relation.correspondingWork,entity:a,onView:g,onUnlink:()=>u("workId"),onLink:()=>m("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(Bn,{direction:"up",title:y.relation.parentCollection,entity:s,onView:g,onUnlink:()=>u("parentCollectionId"),onLink:()=>m("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(fn,{direction:"down",title:`${y.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:g,onAdd:()=>x("childCollection","collection",{parentCollectionId:n}),addLabel:y.action.addSubCollection,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(fn,{direction:"down",title:`${y.relation.containedBooks} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:g,onAdd:()=>x("childBook","book",{collectionId:n}),addLabel:y.action.addBook,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]})]})]})},Bn=({direction:e,title:n,entity:i,onView:o,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:h,unlinkLabel:m})=>{const u=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),g=e==="up"?"⬆️":e==="down"?"⬇️":"↔️";return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:u,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:g}),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:Ld(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(Ja,{onClick:()=>o(i),title:h,children:"👁️"}),t.jsx(Ja,{onClick:s,title:m,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(to,{onClick:a,children:d}),t.jsx(to,{onClick:l,primary:!0,children:c})]})]})},fn=({direction:e,title:n,entities:i,onView:o,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=f.useState(!1),h=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),m=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",u=c?i:i.slice(0,5);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:h,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:m}),t.jsx("span",{children:n})]}),i.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[u.map(g=>t.jsxs("div",{onClick:()=>o(g),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:r("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[t.jsx("span",{children:Ld(g.type)}),t.jsx("span",{children:g.title})]},g.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(to,{onClick:s,primary:!0,children:["+ ",a]})})]})},Ja=({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}),to=({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 Ld(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const zb={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},Ad=({isOpen:e,entityType:n,title:i,onSelect:o,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[h,m]=f.useState(""),u=p?l.filter(y=>y.id!==p):l;f.useEffect(()=>{e&&(m(""),d(""))},[e]);const g=y=>{m(y),d(y)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",j=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:Nb,children:t.jsxs("div",{style:Tb,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:Ib,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:h,onChange:y=>g(y.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:Rb})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:zr,children:"搜索中..."}):u.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:u.map(y=>t.jsxs("div",{onClick:()=>o(y),style:Eb,children:[t.jsx("span",{style:{fontSize:"16px"},children:j}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[y.title,y.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:y.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[y.id,y.author&&` · ${y.author}`,y.dynasty&&` · ${y.dynasty}`]})]})]},y.id))}):h?t.jsxs("div",{style:zr,children:["未找到匹配的",x]}):t.jsxs("div",{style:zr,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:Lb,children:["创建新",x,"并关联"]})]})]})})},Nb={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Tb={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")},Ib={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},Rb={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"},Eb={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:r("primary-soft")},zr={padding:"20px",textAlign:"center",color:r("desc-fg")},Lb={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Qa={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},Ab={work:"📜",book:"📖",collection:"📚",entity:"👤"},Md=({isOpen:e,entityType:n,relationField:i,inheritData:o,onConfirm:s,onCancel:a})=>{const[l,d]=f.useState(""),c=f.useRef(null);f.useEffect(()=>{e&&(d((o==null?void 0:o.title)||""),setTimeout(()=>{var u,g;(u=c.current)==null||u.focus(),(g=c.current)==null||g.select()},100))},[e,o==null?void 0:o.title]);const p=u=>{u.key==="Enter"&&l.trim()?h():u.key==="Escape"&&a()},h=()=>{l.trim()&&s(l.trim(),{...o,title:l.trim()})};if(!e)return null;const m=()=>{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`创建新${Qa[n]}`}};return t.jsx("div",{style:Mb,onClick:u=>{u.target===u.currentTarget&&a()},children:t.jsxs("div",{style:Pb,onClick:u=>u.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Ab[n]}),t.jsx("span",{children:m()})]}),t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:r("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",t.jsx("span",{style:{color:r("danger"),marginLeft:"4px"},children:"*"})]}),t.jsx("input",{ref:c,type:"text",value:l,onChange:u=>d(u.target.value),onKeyDown:p,placeholder:`请输入${Qa[n]}名称...`,style:Bb})]}),((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:Ob,children:"取消"}),t.jsx("button",{onClick:h,disabled:!l.trim(),style:{...Wb,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},Mb={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Pb={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")},Bb={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"},Ob={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},Wb={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg")};function Fb(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Pd(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Hb(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 Bd=({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[m,u]=f.useState(""),[g,x]=f.useState([]),[j,y]=f.useState(!1),[S,b]=f.useState("recent");f.useEffect(()=>{e&&(u(""),x([]),b(o.length>0?"recent":"search"))},[e,o.length]),f.useEffect(()=>{if(!m.trim()){x([]);return}const _=setTimeout(async()=>{y(!0);try{x(await h(m,i))}catch{x([])}finally{y(!1)}},300);return()=>clearTimeout(_)},[m,i,h]);const w=f.useCallback(_=>{u(_.target.value),_.target.value.trim()&&b("search")},[]),v=f.useCallback(_=>s?_.filter(R=>R.id!==s):_,[s]);if(!e)return null;const k=n||(i==="all"?"选择实体":`选择${Pd(i)}`),z=v(o),C=v(g);return t.jsx("div",{style:Ub,children:t.jsxs("div",{style:Vb,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:k}),t.jsx("button",{onClick:c,style:Gb,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:m,onChange:w,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Yb}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),j&&t.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),z.length>0&&t.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs(el,{active:S==="recent",onClick:()=>b("recent"),children:["最近使用 (",z.length,")"]}),t.jsxs(el,{active:S==="search",onClick:()=>b("search"),children:["搜索结果 ",C.length>0&&`(${C.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:S==="recent"&&z.length>0?t.jsx(tl,{entities:z,onSelect:d}):m.trim()?j?t.jsx(Nr,{message:"搜索中..."}):C.length>0?t.jsx(tl,{entities:C,onSelect:d}):t.jsx(Nr,{message:"未找到匹配的结果"}):t.jsx(Nr,{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:qb,children:l||"创建新实体"})]})]})})},el=({active:e,onClick:n,children:i})=>t.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${r("primary")}`:"2px solid transparent",background:"transparent",color:r(e?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:e?600:400,marginBottom:"-1px"},children:i}),tl=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(i=>t.jsx(Db,{entity:i,onClick:()=>n(i)},i.id))}),Db=({entity:e,onClick:n})=>{const[i,o]=f.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:r("primary-soft"),transition:"background 0.1s"},children:[t.jsx("span",{style:{fontSize:"18px"},children:Fb(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:Hb(e.type),color:r("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:Pd(e.type)})]})},Nr=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:e}),Ub={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Vb={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")},Gb={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Yb={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"},qb={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Kb={work:r("editor-type-work"),collection:r("editor-type-collection"),book:r("editor-type-book"),entity:r("editor-type-entity")},Xb={work:"📜",collection:"📚",book:"📖",entity:"👤"},Od=({data:e,onChange:n,onSave:i,transport:o,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:h,relations:m,onRelationsChange:u})=>{var ce;const g=Ae(),[x,j]=f.useState(!1),[y,S]=f.useState("work"),[b,w]=f.useState(""),[v,k]=f.useState(""),[z,C]=f.useState([]),[_,R]=f.useState(!1),[T,N]=f.useState(!1),[E,W]=f.useState("work"),[F,A]=f.useState(""),[V,ae]=f.useState(),[xe,me]=f.useState(!1),[G,ye]=f.useState(null),[ne,U]=f.useState([]);f.useRef(null);const Q=e.type,q=Q==="work",je=Q==="collection",I=Q==="book",oe=f.useCallback((Z,we)=>{n({...e,[Z]:we})},[e,n]),$e=f.useCallback((Z,we)=>{w(Z),S(we),k(g.editor.selectToLink+g.indexType[we]),C([]),j(!0)},[g]),ve=f.useCallback(Z=>{o!=null&&o.unlinkEntity&&o.unlinkEntity(e.id,Z)},[o,e.id]),Le=f.useCallback(Z=>{s==null||s(Z.id,Z.type)},[s]),Ne=f.useCallback((Z,we,He)=>{const Ge={...He,author:(He==null?void 0:He.author)||e.author,dynasty:He==null?void 0:He.dynasty};W(we),A(Z),ae(Ge),N(!0)},[e.author]),X=f.useCallback((Z,we)=>{o!=null&&o.createAndLink&&o.createAndLink(e.id,F,{type:E,title:Z,inheritData:we}),N(!1)},[o,e.id,F,E]),ue=f.useCallback(Z=>{if(!Z.trim()){C([]);return}R(!0),o!=null&&o.searchEntities&&o.searchEntities(Z,y).then(we=>{C(we),R(!1)}).catch(()=>{C([]),R(!1)})},[o,y]),Pe=f.useCallback(Z=>{o!=null&&o.linkEntity&&o.linkEntity(e.id,b,Z.id),j(!1)},[o,e.id,b]),Me=f.useCallback(()=>{i()},[i]),ke=f.useCallback(Z=>{ye(()=>Z),me(!0),o!=null&&o.getRecentEntities&&o.getRecentEntities().then(U).catch(()=>{})},[o]),D=f.useCallback((Z,we)=>o!=null&&o.searchEntities?o.searchEntities(Z,we==="all"?void 0:we):Promise.resolve([]),[o]),le=f.useCallback(Z=>{o!=null&&o.addRecentEntity&&o.addRecentEntity(Z),U(we=>[Z,...we.filter(He=>He.id!==Z.id)].slice(0,10)),G==null||G(Z),me(!1),ye(null)},[o,G]);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:Xb[Q]}),t.jsx("span",{children:e.title||g.editor.untitled}),t.jsx(Ni,{children:e.id}),t.jsx(Ni,{color:Kb[Q],children:g.indexType[Q]})]})}),t.jsx(zt,{title:g.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(ki,{label:q?g.editor.workTitle:je?g.editor.collectionTitle:g.editor.bookTitle,value:e.title,onChange:Z=>oe("title",Z)}),I&&t.jsx(ki,{label:g.editor.belongsToWork,value:e.workName||"",onChange:Z=>oe("workName",Z)}),t.jsx(kt,{label:g.editor.authorLabel,value:e.author||"",onChange:Z=>oe("author",Z)}),t.jsx(kt,{label:g.editor.publicationYearLabel,value:e.publicationYear||"",onChange:Z=>oe("publicationYear",Z)}),(I||je)&&t.jsx(ki,{label:g.editor.containedIn,value:e.collection||"",onChange:Z=>oe("collection",Z)}),(I||je)&&t.jsx(kt,{label:g.editor.holderLabel,value:e.holder||"",onChange:Z=>oe("holder",Z)}),(I||je)&&t.jsx(kt,{label:I?g.editor.pageLabel:g.editor.volumeLabel,value:e.pages||"",onChange:Z=>oe("pages",Z)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(kt,{label:g.editor.firstImageLabel,value:e.firstImage||"",onChange:Z=>oe("firstImage",Z)})})]})}),t.jsx(zt,{title:g.section.description,onSave:i,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(an,{value:e.description||"",onChange:Z=>oe("description",Z),placeholder:g.editor.descriptionPlaceholder})}),(((ce=e.additional_works)==null?void 0:ce.length)||0)>0&&t.jsx(zt,{title:g.section.additionalWorks,onSave:i,children:t.jsx(Zb,{items:e.additional_works||[],onChange:Z=>oe("additional_works",Z)})}),t.jsx(zt,{title:g.section.indexedBy,onSave:i,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(Jb,{items:e.indexed_by||[],onChange:Z=>oe("indexed_by",Z)})}),t.jsx(zt,{title:g.section.emendatedBy,onSave:i,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(Qb,{items:e.emendated_by||[],onChange:Z=>oe("emendated_by",Z)})}),t.jsx(zt,{title:g.section.textResources,onSave:i,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(Ar,{items:e.resources||[],onChange:Z=>oe("resources",Z),onDownload:p,downloadStatuses:h,filterType:"text"})}),t.jsx(zt,{title:g.section.imageResources,onSave:i,children:t.jsx(Ar,{items:e.resources||[],onChange:Z=>oe("resources",Z),onDownload:p,downloadStatuses:h,filterType:"image"})}),t.jsx(zt,{title:g.section.sources,onSave:i,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(Td,{items:Id(e.sources||""),onChange:Z=>oe("sources",Rd(Z)),onOpenEntityPicker:ke})}),(I||je)&&t.jsx(zt,{title:g.section.provenance,onSave:i,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(an,{value:e.provenance||"",onChange:Z=>oe("provenance",Z),placeholder:g.editor.provenancePlaceholder})}),I&&t.jsx(zt,{title:g.section.otherEditions,onSave:i,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(an,{value:e.otherEditions||"",onChange:Z=>oe("otherEditions",Z),placeholder:g.editor.otherEditionsPlaceholder})}),t.jsx(Ed,{entityType:Q,entityId:e.id,entityTitle:e.title,parentWork:m==null?void 0:m.parentWork,parentCollection:m==null?void 0:m.parentCollection,belongsToWork:m==null?void 0:m.belongsToWork,belongsToCollection:m==null?void 0:m.belongsToCollection,childWorks:m==null?void 0:m.childWorks,childCollections:m==null?void 0:m.childCollections,containedBooks:m==null?void 0:m.containedBooks,siblingBooks:m==null?void 0:m.siblingBooks,onLinkEntity:$e,onUnlinkEntity:ve,onViewEntity:Le,onCreateAndLink:Ne,onSaveRelations:Me}),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:g.section.dangerZone}),t.jsx("p",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"12px"},children:g.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:g.editor.deleteEntity})]}),t.jsx(Ad,{isOpen:x,entityType:y,title:v,onSelect:Pe,onCancel:()=>j(!1),onCreate:()=>{j(!1),Ne(b,y)},searchResults:z,onSearch:ue,isLoading:_,excludeId:e.id}),t.jsx(Md,{isOpen:T,entityType:E,relationField:F,inheritData:V,onConfirm:X,onCancel:()=>N(!1)}),t.jsx(Bd,{isOpen:xe,title:g.action.selectBookOrWork,filterType:"all",recentEntities:ne,excludeId:e.id,onSelect:le,onCancel:()=>{me(!1),ye(null)},onSearch:D})]})};function Zb({items:e,onChange:n}){const i=Ae(),o=(l,d,c)=>{const p=e.map((h,m)=>m===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(kt,{label:i.editor.bookNameLabel,value:l.book_title,onChange:c=>o(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(kt,{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 Wd({items:e,onChange:n,showMeta:i,addLabel:o}){const s=Ae(),[a,l]=f.useState(null),d=(h,m,u)=>{const g=e.map((x,j)=>j===h?{...x,[m]:u||void 0}:x);n(g)},c=h=>{n(e.filter((m,u)=>u!==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,m)=>{const u=a===m;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:u?`color-mix(in srgb, ${r("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(u?null:m),children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.2s",transform:u?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children: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:g=>{g.stopPropagation(),c(m)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${r("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:r("muted")},children:"✕"})]}),!u&&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]}),u&&t.jsxs("div",{style:{padding:"8px 12px 12px",display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(kt,{label:s.label.sourceName,value:h.source,onChange:g=>d(m,"source",g)}),t.jsx(kt,{label:s.label.sourceBid,value:h.source_bid||"",onChange:g=>d(m,"source_bid",g)})]}),i&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(kt,{label:s.label.titleInfo,value:h.title_info||"",onChange:g=>d(m,"title_info",g)}),t.jsx(kt,{label:s.label.authorInfo,value:h.author_info||"",onChange:g=>d(m,"author_info",g)})]}),t.jsx(kt,{label:s.label.edition,value:h.edition||"",onChange:g=>d(m,"edition",g)})]}),t.jsx(an,{value:h.summary||"",onChange:g=>d(m,"summary",g),placeholder:s.editor.summaryPlaceholder}),t.jsx(an,{value:h.comment||"",onChange:g=>d(m,"comment",g),placeholder:s.editor.commentPlaceholder}),t.jsx(an,{value:h.additional_comment||"",onChange:g=>d(m,"additional_comment",g),placeholder:s.editor.additionalCommentPlaceholder})]})]},m)}),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 Jb({items:e,onChange:n}){const i=Ae();return t.jsx(Wd,{items:e,onChange:n,showMeta:!0,addLabel:i.action.addIndexedBy})}function Qb({items:e,onChange:n}){const i=Ae();return t.jsx(Wd,{items:e,onChange:n,addLabel:i.action.addEmendatedBy})}function Fd(e){var d,c,p,h,m,u,g;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=(m=e.page_count)!=null&&m.number?String(e.page_count.number):((u=e.page_count)==null?void 0:u.description)||"",a=typeof e.description=="object"&&e.description!==null&&e.description.text||"",l={id:e.id,title:e.title,type:e.type,author:n,publicationYear:i,holder:o,pages:s,description:a,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};if(e.type==="work"){const x=e;if(Array.isArray(x.related_works)){const j=x.related_works.find(y=>y.relation==="part_of");j&&(l.parentWorkId=j.id,l.parentWorkName=j.title)}}if(e.type==="book"){const x=e;l.workId=x.work_id,Array.isArray(x.contained_in)&&x.contained_in.length>0&&(l.collectionId=(g=x.contained_in[0])==null?void 0:g.id)}return l}function ey(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 ty=e=>{const{data:n,id:i,transport:o,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:h,onAskAI:m,renderSectionActions:u,onDownloadResource:g,downloadStatuses:x,relations:j,onRelationsChange:y,headerExtra:S,className:b,style:w}=e,v=Ae(),[k,z]=f.useState(s),C=a?s:k;f.useEffect(()=>{s!==k&&z(s)},[s]);const _=f.useCallback(()=>{const A=C==="view"?"edit":"view";a?a(A):z(A)},[C,a]),[R,T]=f.useState(null);f.useEffect(()=>{i&&o&&o.getItem(i).then(A=>{A&&T(A)})},[i,o]);const N=n||R,E=f.useMemo(()=>N?Fd(N):null,[N]),W=a||!n?t.jsx("button",{onClick:_,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:C==="edit"?r("accent-bg"):"transparent",color:r(C==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:C==="view"?v.common.switchToEdit:v.common.switchToView,children:C==="view"?v.common.modeEdit:v.common.modeView}):null,F=t.jsxs(t.Fragment,{children:[W,S]});return!N&&!E?t.jsx(ln,{}):C==="view"?t.jsx(Co,{data:N,transport:o,onNavigate:p?A=>p(A):void 0,renderLink:h,headerExtra:F,className:b,style:w}):E?t.jsxs("div",{className:b,style:w,children:[F&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:F}),t.jsx(Od,{data:E,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:o,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:m,renderSectionActions:u,onDownloadResource:g,downloadStatuses:x,relations:j,onRelationsChange:y})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:r("muted")},children:v.common.noData})},ny=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Hd=({isOpen:e,onClose:n,onSubmit:i,feedbackListUrl:o})=>{const{t:s}=re(),[a,l]=f.useState(null),[d,c]=f.useState(""),[p,h]=f.useState(""),[m,u]=f.useState("idle"),[g,x]=f.useState(""),j=f.useRef(null);f.useEffect(()=>{e&&(l(null),c(""),h(""),u("idle"),x(""))},[e]),f.useEffect(()=>{a&&setTimeout(()=>{var b;return(b=j.current)==null?void 0:b.focus()},100)},[a]),f.useEffect(()=>{if(m==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[m,n]),f.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())){u("submitting"),x("");try{await i({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),u("success")}catch(b){u("error"),x(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const S=a&&d.trim()&&m!=="submitting";return t.jsx("div",{style:iy,onClick:b=>{b.target===b.currentTarget&&n()},children:t.jsxs("div",{style:ry,onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{style:oy,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:sy,"aria-label":s("feedback.close"),children:"✕"})]}),m==="success"?t.jsxs("div",{style:py,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:ny.map(b=>t.jsxs("button",{onClick:()=>l(b.value),style:{...ay,...a===b.value?ly:{}},children:[t.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),t.jsx("textarea",{ref:j,value:d,onChange:b=>c(b.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||m==="submitting",style:{...cy,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||m==="submitting","aria-label":s("feedback.contactLabel"),style:my}),t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),m==="error"&&t.jsx("div",{style:uy,children:g}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:y,disabled:!S,style:{...dy,opacity:S?1:.6,cursor:S?"pointer":"not-allowed"},children:s(m==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},iy={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},ry={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:r("shadow-dialog")},oy={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},sy={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:r("desc-fg"),padding:"4px 8px",borderRadius:"4px"},ay={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"},ly={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},cy={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"},dy={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},py={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:r("success")},uy={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginBottom:"12px"},my={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"},no="--bim-feedback-fab-offset",io=48,hy=16,fy=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:i,hidden:o=!1,zIndex:s})=>{const{t:a}=re(),[l,d]=f.useState(!1),c=n.bottom??24;return f.useEffect(()=>{if(o||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(no,`calc(${c+io+hy}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(no)}},[o,c]),t.jsxs(t.Fragment,{children:[!o&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...gy,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(Hd,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:i})]})},gy={position:"fixed",width:`${io}px`,height:`${io}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"},xy=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Dd=({onSubmit:e})=>{const{t:n}=re(),[i,o]=f.useState("bug"),[s,a]=f.useState(""),[l,d]=f.useState(""),[c,p]=f.useState("idle"),[h,m]=f.useState(""),u=f.useRef(null);f.useEffect(()=>{i&&setTimeout(()=>{var j;return(j=u.current)==null?void 0:j.focus()},100)},[i]);const g=async()=>{if(!(!i||!s.trim())){p("submitting"),m("");try{await e({type:i,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),o("bug")}catch(j){p("error"),m(j instanceof Error?j.message:n("feedback.submitFailedRetry"))}}},x=i&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:nl,children:t.jsxs("div",{style:ky,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:wy,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:nl,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:xy.map(j=>t.jsxs("button",{onClick:()=>o(j.value),style:{...by,...i===j.value?yy:{}},children:[t.jsx("span",{children:j.icon})," ",n(`feedback.submitType.${j.value}`)]},j.value))}),t.jsx("textarea",{ref:u,value:s,onChange:j=>a(j.target.value),placeholder:n(i?`feedback.placeholder.${i}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...jy}}),t.jsx("input",{type:"text",value:l,onChange:j=>d(j.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:_y}),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:g,disabled:!x,style:{...vy,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:Sy,children:h})]})},nl={padding:"16px",border:`1px solid ${r("widget-border")}`,borderRadius:"8px",background:r("input-bg")},by={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"},yy={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},jy={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"},vy={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},ky={display:"flex",alignItems:"center",gap:"12px",color:r("success"),fontSize:"14px"},wy={background:"none",border:"none",color:r("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},Sy={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginTop:"8px"},_y={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 il(e){return typeof e=="function"?e():e??"/api/feedback"}const Ud=({resourceId:e,apiUrl:n})=>{const{t:i}=re(),[o,s]=f.useState([]),[a,l]=f.useState(!0),d=f.useCallback(async()=>{const p=il(n);l(!0);try{const m=await(await fetch(`${p}?resourceId=${encodeURIComponent(e)}`)).json();m.success&&s(m.items)}catch{}finally{l(!1)}},[e,n]);f.useEffect(()=>{d()},[d]);const c=async p=>{const h=il(n),m=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!m.ok){const u=await m.json().catch(()=>null);throw new Error((u==null?void 0:u.error)||i("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(is,{items:o,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(Dd,{onSubmit:c})})]})},Gi=8;async function Yi(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 $y=Ri["zh-Hant"].relation,Cy=Ri["zh-Hant"].lossStatus,zy=Ri["zh-Hant"].resourceKind,qi=_n("zh-Hant"),rs=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function rl(e,n=qi){return e?rs($y,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function Ny(e,n=qi){return rs(Cy,e)?n(`detail.lossStatus.${e}`):e}function Ty(e,n=qi){return rs(zy,e)?n(`detail.resourceKind.${e}`):""}function os({authors:e,onNavigate:n,renderLink:i}){const{convert:o}=re(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=vo(a.role);return t.jsxs(f.Fragment,{children:[l>0&&" ",a.dynasty&&t.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",o(a.dynasty),"〕"]}),a.entity_id?t.jsx(rt,{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 Vd(e,n,i=qi){var c,p;const o=yo(e,n),s=o.mirrors.map(h=>({key:h.key,label:h.label,description:h.description,rows:h.items.filter(m=>m.group_role!=="mirror"),mirrors:h.items.filter(m=>m.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 Gd(e,n){const i=(e.url?kn(e.url):void 0)||e.name,o=Hl(e,n);return o?`${i}(${o})`:i}function ss({item:e,siblings:n,listedVolumeCounts:i}){const{t:o,convert:s}=re(),[a,l]=f.useState(!1),d=Ii(e),c=!!d&&d.expected>0&&!(i!=null&&i.has(d.expected)),p=s(Gd(e,n)),h=wn(e),m=Mi(e,o)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var g,x;const u=(g=e.metadata)!=null&&g.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:"↗"}),u]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,u]})})(),m&&t.jsx("span",{className:"bim-d-meta",children:s(m)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(Ao,{item:e})})]}),t.jsx("td",{className:c?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:c&&t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":a,onClick:()=>l(u=>!u),children:a?o("detail.collapseVolumes"):o("detail.expandVolumes",{n:d.expected})})})]})}function Yd({groups:e,listedVolumeCounts:n}){const{t:i,convert:o}=re();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(ss,{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=wn(a),c=o(Gd(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 Gn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function ro(e){var i;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(i=Gn.find(o=>n.startsWith(o.key[0])))==null?void 0:i.key}const ol=12,Iy=60,qd=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,railTop:a,back:l,railLinks:d})=>{var Pe,Me,ke;const{t:c,convert:p,messages:h}=re(),m=f.useMemo(()=>ko({_books:e._books}),[e._books]),[u,g]=f.useState(new Map),[x,j]=f.useState(!1),[y,S]=f.useState(""),[b,w]=f.useState(!1),v=m.length<=Iy,k=v||x||!!y||b,z=f.useMemo(()=>k?m:m.slice(0,ol),[m,k]);f.useEffect(()=>{if(!n||z.length===0)return;const D=z.filter(ce=>!u.has(ce));if(D.length===0)return;let le=!1;return Yi(D,Gi,ce=>n.getItem(ce).then(Z=>{var He;const we=Z??{};return[ce,{id:ce,title:we.title,edition:we.edition,resources:we.resources,publication_info:we.publication_info,current_location:we.current_location,lineage:we.lineage,measure_info:we.measure_info,summary:Ry((He=Z==null?void 0:Z.description)==null?void 0:He.text)}]}).catch(()=>[ce,{id:ce}]),()=>le).then(ce=>{le||g(Z=>{const we=new Map(Z);for(const[He,Ge]of ce)we.set(He,Ge);return we})}),()=>{le=!0}},[n,z,u]);const C=f.useMemo(()=>m.map(D=>u.get(D)??{id:D}),[m,u]),_=m.length>0&&m.every(D=>u.has(D)),R=!!n&&z.some(D=>!u.has(D)),T=v||k,N=f.useMemo(()=>Ul(C,e.version_graph,{era:y,scanOnly:b,sort:T?"year":"default"}),[C,e.version_graph,y,b,T]),E=x?N.rows:N.rows.slice(0,ol),W=N.allRows.filter(D=>D.hasImage).length,F=N.allRows.reduce((D,le)=>{var ce;return D+(((ce=le.copies)==null?void 0:ce.length)??0)},0),A=f.useMemo(()=>(e._related||[]).map(D=>({...D,title:D.title??""})),[e._related]),V=A.filter(D=>D.relation==="collected_in"),ae=f.useMemo(()=>{const D=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],le=ce=>{const Z=D.indexOf(ce??"");return Z<0?D.length:Z};return A.filter(ce=>ce.relation!=="collected_in").map((ce,Z)=>({r:ce,i:Z})).sort((ce,Z)=>le(ce.r.relation)-le(Z.r.relation)||ce.i-Z.i).map(ce=>ce.r)},[A]),xe=f.useMemo(()=>{const D=yo(e.resources,e.resource_groups);return[...D.mirrors.flatMap(le=>le.items.map(ce=>({r:ce,kind:p(le.label)}))),...D.buckets.flatMap(le=>le.items.map(ce=>({r:ce,kind:p(Ty(le.key,c))})))]},[e.resources,e.resource_groups,p,c]),me=e.indexed_by||[],G=e.emendated_by||[],ye=f.useMemo(()=>{var O,de,Te;const D=[],le=(de=(O=e.authors)==null?void 0:O[0])==null?void 0:de.dynasty;le&&D.push({label:c("workPage.fact.written"),value:p(le)});const ce=Dt(e,h.unit.juan);if(ce){const B=(Te=e.juan_count)==null?void 0:Te.description;D.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(ce),B&&B!==ce?t.jsxs("span",{className:"bim-d-meta",children:["(",p(B),")"]}):null]})})}e.loss_status&&D.push({label:c("workPage.fact.loss"),value:p(Ny(e.loss_status,c))});const Z=N.allRows.filter(B=>B.sortYear!=null),we=Z.length>0?Z.reduce((B,pe)=>B.sortYear<=pe.sortYear?B:pe):null;we!=null&&we.era.era?D.push({label:c("workPage.fact.earliest"),value:p([we.era.era,we.era.reign].filter(Boolean).join(" ")),title:we.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):R&&D.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),G.length&&D.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:G.length})});const He=sl(e.additional_titles);He.length&&D.push({label:c("workPage.fact.alias"),value:He.map(p).join("、")});const Ge=sl(e.attached_texts);Ge.length&&D.push({label:c("workPage.fact.attached"),value:Ge.map(p).join("、")});const Xe=(e.additional_works||[]).map(B=>p(B.book_title)+(B.n_juan!=null?` ${B.n_juan}${h.unit.juan}`:""));return Xe.length&&D.push({label:c("workPage.fact.appendix"),value:Xe.join("、")}),D},[e,p,c,h,R,N.allRows,G.length]),U=[{value:e._edition_count??m.length,label:c("workPage.stat.editions")},{value:_?W:0,label:c("workPage.stat.hasImage")},{value:me.length,label:c("workPage.stat.catalogs")}],Q=wo(e),q=Q?[Q.l1,Q.l2,Q.l3,Q.l4].filter(Boolean).map(D=>p(D)):[],je=e.subtype?h.workSubtype[e.subtype]??p(e.subtype):"",I=t.jsx(Zn,{title:p(e.title),byline:t.jsx(os,{authors:e.authors,onNavigate:i,renderLink:o}),meta:t.jsx(ct,{items:[...q,Q!=null&&Q.source?c("workPage.classifiedBy",{source:p(Q.source.split("/")[0])}):"",je]}),description:(Pe=e.description)!=null&&Pe.text?t.jsxs(t.Fragment,{children:[t.jsx(Ut,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(Me=e.description.sources)!=null&&Me.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(D=>({text:p(Em(D)),href:Lm(D)})).filter(D=>D.text).map((D,le)=>t.jsxs(f.Fragment,{children:[le>0?" · ":null,D.href?t.jsx("a",{href:D.href,target:"_blank",rel:"noopener noreferrer",children:D.text}):D.text]},le))}):null]}):void 0,stats:U,facts:ye,readAction:s,foot:t.jsx(Jn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(ke=e.appendix)==null?void 0:ke.map((D,le)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(D.title)}),t.jsx(Ut,{text:D.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},le))}),oe=N.eras.length>=2?[{key:"",label:c("catalog.all")},...N.eras.map(D=>({key:D,label:`${D} ${N.allRows.filter(le=>le.era.era===D).length}`}))]:[],$e=[];m.length&&$e.push({id:"versions",label:c("workPage.sec.versions"),count:m.length}),me.length&&$e.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:me.length}),V.length&&$e.push({id:"collected",label:c("workPage.sec.collected"),count:V.length}),ae.length&&$e.push({id:"related",label:c("workPage.sec.related"),count:ae.length}),xe.length&&$e.push({id:"resources",label:c("workPage.sec.resources"),count:xe.length});const ve=m.length===0&&me.length===0,Le=t.jsxs(t.Fragment,{children:[m.length>0&&t.jsxs(ut,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(ct,{items:[c("workPage.versionsTotal",{n:m.length-F}),_&&W?c("workPage.versionsWithImage",{n:W}):"",N.rows.length!==N.allRows.length?c("workPage.versionsCurrent",{n:N.rows.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":R&&oe.length===0&&m.length>1?"":void 0,children:[oe.length>0&&t.jsx(Hi,{items:oe,value:y,onChange:D=>{S(D),j(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(Ac,{label:c("workPage.scanOnly"),checked:b,onChange:D=>{w(D),j(!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&&Di(N.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:E.map(D=>{var le;return t.jsx(Ly,{row:D,measure:(le=u.get(D.id))==null?void 0:le.measure_info,loaded:u.has(D.id),onNavigate:i,renderLink:o},`${D.id}:${u.has(D.id)?"r":"p"}`)})})]}),E.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(Io,{total:N.rows.length,shown:E.length,unit:c("workPage.moreUnit"),onClick:()=>j(!0)}),N.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),me.length>0&&t.jsx(Ay,{items:me,transport:n,onNavigate:i,renderLink:o}),ve&&t.jsx(ut,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),Ne=(D,le)=>t.jsx(rt,{id:D,label:p(le),onNavigate:i,renderLink:o,dense:!0}),X=f.useMemo(()=>{const D=new Map;for(const le of ae){const ce=rl(le.relation,c);D.set(ce,(D.get(ce)??0)+1)}return D.size>1?[...D.entries()].sort((le,ce)=>ce[1]-le[1]).slice(0,4).map(([le,ce])=>`${p(le)} ${ce}`).join(" · "):void 0},[ae,p,c]),ue=t.jsxs(t.Fragment,{children:[t.jsx(sn,{id:"collected",title:c("workPage.sec.collected"),items:V.map(D=>Ne(D.id,D.title))}),t.jsx(sn,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:ae.length}),sub:X,items:ae.map(D=>t.jsxs(t.Fragment,{children:[Ne(D.id,D.title),t.jsx("span",{className:"bim-d-meta",title:D.note?p(D.note):void 0,children:p(rl(D.relation,c))})]}))}),t.jsx(sn,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:xe.map(({r:D,kind:le})=>{const ce=p((D.url?kn(D.url):void 0)||D.name),Z=wn(D);return t.jsxs(t.Fragment,{children:[Z?t.jsxs("a",{href:Z,target:"_blank",rel:"noopener noreferrer",children:[ce," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:ce}),le&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:le})]})})})]});return t.jsx(Xn,{railTop:a,back:l,nav:$e,railLinks:d,main:Le,card:I,side:ue})};function sl(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function oo(e,n){return n((e.url?kn(e.url):void 0)||e.name)}function Ry(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 Ey({copies:e,onNavigate:n,renderLink:i}){const{t:o,convert:s}=re(),a=new Map;for(const l of e){const d=l.locationName||(l.holders[0]?oo(l.holders[0],s):"")||"",c=a.get(d)??[];c.push(l),a.set(d,c)}return t.jsxs("span",{className:"bim-d-zt-copies",children:[o("workPage.sameEditionCopies",{n:e.length}),[...a].map(([l,d],c)=>t.jsxs(f.Fragment,{children:[c>0?";":"",l?`${s(l)} `:"",d.map((p,h)=>t.jsxs(f.Fragment,{children:[h>0?" · ":"",t.jsx(rt,{id:p.id,label:p.callNumber||p.id,onNavigate:n,renderLink:i,dense:!0})]},p.id))]},l||c))]})}function Ly({row:e,measure:n,loaded:i,onNavigate:o,renderLink:s}){const{t:a,convert:l}=re(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],h=e.copies??[],m=h.length&&e.locationName?l(e.locationName):p?oo(p,l):e.locationName?l(e.locationName):"",u=e.images[0],g=u?wn(u):void 0,x=e.images.map(j=>oo(j,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(rt,{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(Ey,{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${m?"":" bim-d-zt-blank"}`,children:[m||(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&&(g?t.jsx("a",{className:"bim-d-flag",href:g,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 Ay({items:e,transport:n,onNavigate:i,renderLink:o}){const{t:s,convert:a}=re(),[l,d]=f.useState(0),c=Math.min(l,e.length-1),p=e[c],[h,m]=f.useState(new Map);return f.useEffect(()=>{if(!n)return;const u=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(u.length===0)return;let g=!1;return Promise.all(u.map(x=>n.getItem(x).then(j=>{var y,S;return[x,((S=(y=j==null?void 0:j.authors)==null?void 0:y[0])==null?void 0:S.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{g||m(new Map(x.filter(([,j])=>j)))}),()=>{g=!0}},[n,e]),t.jsx(ut,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(ct,{items:[s("workPage.catalog.meta",{n:e.length}),s("workPage.sortByCatalog")]}),children:t.jsxs("div",{className:"bim-d-lu",children:[t.jsx("ul",{className:"bim-d-tl2 bim-d-ui",role:"tablist","aria-label":s("workPage.catalog.tablist"),children:e.map((u,g)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":g===c,"aria-label":a(u.source),onClick:()=>d(g),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:h.get(u.source_bid??"")?a(h.get(u.source_bid??"")):" "}),t.jsx("i",{className:"bim-d-tl2-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-d-tl2-name","aria-hidden":"true",children:[...a(u.source)].slice(0,9).map((x,j)=>t.jsx("span",{children:x},j))})]})},g))}),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(ct,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(rt,{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:St(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:St(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:St(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 My(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 Py(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 al(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 By(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 Oy(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,m]of Object.entries(e.node_groups))l.has(m)&&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 wi(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=Oy(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,m=new Set,u=new Set;if(c){const v=new Map(n.map(T=>[T.id,T])),k=new Map((o.hypothetical_nodes??[]).map(T=>[T.id,T])),z=T=>{const N=v.get(T);if(N&&N.lineage)return(N.lineage.derived_from??[]).map(W=>W.ref);const E=k.get(T);return E?(E.derived_from??[]).map(W=>W.ref):[]},C=T=>k.has(T)?!h||h.has(T):!p||p.has(T),_=new Set,R=T=>{if(!_.has(T)){_.add(T);for(const N of z(T))a.has(N)||(C(N)||(k.has(N)?u.add(N):v.has(N)&&m.add(N)),R(N))}};for(const T of n)p&&p.has(T.id)&&!a.has(T.id)&&R(T.id);for(const T of o.hypothetical_nodes??[])h&&h.has(T.id)&&R(T.id)}const g=n.filter(v=>!a.has(v.id)).filter(v=>!p||p.has(v.id)||m.has(v.id)).map(v=>{const k=Py(v,l);return k&&m.has(v.id)&&(k.bridge=!0),k}).filter(v=>v!==null),x=(o.hypothetical_nodes??[]).filter(v=>!h||h.has(v.id)||u.has(v.id)).map(v=>{const k=My(v);return u.has(v.id)&&(k.bridge=!0),k}),j=[...g,...x],y=new Set(j.map(v=>v.id)),S=new Set,b=[],w=v=>{S.has(v.id)||!y.has(v.source)||!y.has(v.target)||(S.add(v.id),b.push(v))};for(const v of n)a.has(v.id)||!v.lineage||p&&!p.has(v.id)&&!m.has(v.id)||((v.lineage.derived_from??[]).forEach((k,z)=>{w(al(v.id,k,z))}),(v.lineage.related_to??[]).forEach((k,z)=>{w(By(v.id,k,z))}));for(const v of o.hypothetical_nodes??[])h&&!h.has(v.id)&&!u.has(v.id)||(v.derived_from??[]).forEach((k,z)=>{w(al(v.id,k,z))});return{nodes:j,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 Wy(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 Xd=({graph:e,renderLink:n,className:i,style:o})=>{const{t:s,convert:a}=re();if(!e.nodes.length)return t.jsx("div",{style:{...e0,...o},className:i,children:s("lineage.emptyGraph")});const l=new Map,d=new Map;for(const g of e.edges)if(g.kind==="derive"){const x=l.get(g.target)??[];x.push(g),l.set(g.target,x)}else for(const x of[g.source,g.target]){const j=d.get(x)??[];j.push(g),d.set(x,j)}const c=new Map(e.nodes.map(g=>[g.id,g])),p=new Map,h=[];for(const g of e.nodes)if(g.group){const x=p.get(g.group)??[];x.push(g),p.set(g.group,x)}else h.push(g);const m=(g,x)=>(g.year??9999)-(x.year??9999);p.forEach(g=>g.sort(m)),h.sort(m);const u=e.groups.filter(g=>p.has(g.id));return t.jsxs("div",{className:i,style:{...Hy,...o},children:[e.title&&t.jsx("div",{style:Dy,children:a(e.title)}),e.description&&t.jsx("div",{style:Uy,children:a(e.description)}),u.map(g=>t.jsx(ll,{label:g.label,color:g.color,nodes:p.get(g.id),incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n},g.id)),h.length>0&&t.jsx(ll,{label:s("lineage.otherGroup"),nodes:h,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},ll=({label:e,color:n,nodes:i,incomingMap:o,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=re();return t.jsxs("div",{style:Vy,children:[t.jsx("div",{style:{...Gy,borderLeftColor:n??r("widget-border")},children:d(e)}),i.map(c=>t.jsx(Fy,{node:c,incoming:o.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},Fy=({node:e,incoming:n,siblings:i,nodeMap:o,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=re();return t.jsxs("div",{style:{...Yy,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:qy,children:[t.jsx("span",{style:Ky,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:Xy,children:Kd(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:Zy,children:[e.category&&t.jsx(On,{children:c(e.category)}),e.status==="lost"&&t.jsx(On,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(On,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(On,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(On,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:Jy,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:Qy,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:dl,children:[t.jsx("div",{style:pl,children:d("lineage.sources")}),n.map(p=>{const h=o.get(p.source);return t.jsxs("div",{style:ul(p.confidence),children:[t.jsx("span",{style:ml,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(cl,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:hl,children:["· ",c(p.evidence)]})]},p.id)})]}),i.length>0&&t.jsxs("div",{style:dl,children:[t.jsx("div",{style:pl,children:d("lineage.related")}),i.map(p=>{const h=p.source===e.id?p.target:p.source,m=o.get(h);return t.jsxs("div",{style:ul(p.confidence),children:[t.jsx("span",{style:ml,children:c(p.relation)}),t.jsx("span",{children:(m==null?void 0:m.kind)==="book"&&s?s(m.id,c(m.label)):c((m==null?void 0:m.label)??h)}),t.jsx(cl,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:hl,children:["· ",c(p.evidence)]})]},p.id)})]})]})},On=({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})},cl=({level:e})=>{const{t:n}=re(),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},Hy={fontSize:"14px",color:r("fg")},Dy={fontSize:"16px",fontWeight:600,marginBottom:"8px"},Uy={fontSize:"13px",color:r("muted"),marginBottom:"16px",lineHeight:1.6},Vy={marginBottom:"16px"},Gy={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:r("fg")},Yy={border:`1px solid ${r("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:r("bg")},qy={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Ky={fontSize:"15px",fontWeight:600},Xy={fontSize:"12px",color:r("muted")},Zy={marginBottom:"6px"},Jy={fontSize:"12px",color:r("muted"),margin:"2px 0"},Qy={fontSize:"12px",color:r("muted"),fontStyle:"italic",margin:"4px 0"},dl={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${r("widget-border")}`},pl={fontSize:"11px",color:r("muted"),marginBottom:"2px"},ul=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),ml={display:"inline-block",padding:"0 6px",fontSize:"11px",background:r("tag-bg"),color:r("fg"),borderRadius:"3px",marginRight:"6px"},hl={fontSize:"11px",color:r("muted")},e0={padding:"20px",textAlign:"center",color:r("muted"),fontSize:"13px"},Zd=({selectedNodeId:e,...n})=>{const{t:i}=re(),[o,s]=f.useState("loading"),[a,l]=f.useState(null);return f.useEffect(()=>{let d=!1;return t0().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),o==="loading"?t.jsx("div",{style:gl,children:i("lineage.graphLoading")}):o==="missing"||!a?t.jsxs("div",{style:gl,children:[t.jsx("div",{children:fl(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:fl(i("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(n0,{modules:a,selectedNodeId:e,...n})};function fl(e,n){return e.split(/(\{\w+\})/).map((i,o)=>{const s=/^\{(\w+)\}$/.exec(i);return t.jsx(f.Fragment,{children:s&&s[1]in n?n[s[1]]:i},o)})}async function t0(){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 n0=({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:m,BaseEdge:u,EdgeLabelRenderer:g,getSmoothStepPath:x,dagre:j}=l,y=f.useMemo(()=>({lineage:z=>{var V,ae,xe,me;const C=((V=z.data)==null?void 0:V.stepPosition)??.85,[_,R,T]=x({sourceX:z.sourceX,sourceY:z.sourceY,sourcePosition:z.sourcePosition,targetX:z.targetX,targetY:z.targetY,targetPosition:z.targetPosition,stepPosition:C,borderRadius:5}),N=!!((ae=z.data)!=null&&ae.isSibling),E=N?R:z.targetX-18,W=N?T:z.targetY-12,F=(xe=z.data)==null?void 0:xe.labelStyle,A=(me=z.data)==null?void 0:me.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(u,{id:z.id,path:_,style:z.style,markerStart:z.markerStart,markerEnd:z.markerEnd}),z.label&&t.jsx(g,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${E}px,${W}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:r("bg"),border:`0.5px solid ${r("widget-border")}`,...A,...F},children:z.label})})]})}}),[u,g,x]),S=f.useMemo(()=>({version:z=>{const{t:C}=re(),_=z.data,R=_.kind==="hypothetical",T=_.status==="lost",N=_.isSelected,E=_.bridge,W=_.borderColor??r("muted"),F=E||R?"dashed":"solid",A=E?.5:T?.6:1;return t.jsxs("div",{style:{background:r(E?"bg-subtle":"bg"),border:`2px ${F} ${N?r("primary"):W}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:A,boxShadow:N?r("shadow-node-selected"):R||E?"none":r("shadow-node")},title:E?C("lineage.bridgeTitle"):void 0,children:[t.jsx(h,{type:"target",position:m.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:R||!_.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:C("lineage.lost")}),t.jsx(h,{type:"source",position:m.Right,style:{visibility:"hidden"}})]})}}),[h,m]),{convert:b}=re(),{rfNodes:w,rfEdges:v}=f.useMemo(()=>i0(e,j,n,a,b),[e,j,n,a,b]);return t.jsx("div",{style:{width:"100%",height:i,...s},className:o,children:t.jsxs(d,{nodes:w,edges:v,nodeTypes:S,edgeTypes:y,fitView:!0,fitViewOptions:{padding:.15},proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,minZoom:.2,maxZoom:1.8,children:[t.jsx(c,{gap:16}),t.jsx(p,{showInteractive:!1})]})})};function i0(e,n,i,o,s=a=>a??""){const d=e.layout==="LR"||!e.layout,c=new n.graphlib.Graph;c.setGraph({rankdir:d?"LR":"TB",ranksep:160,nodesep:40,edgesep:16,marginx:20,marginy:20}),c.setDefaultEdgeLabel(()=>({}));const p=new Map(e.groups.map(S=>[S.id,S.color??r("muted")]));for(const S of e.nodes)c.setNode(S.id,{width:160,height:90});const h=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const S of e.edges)S.kind==="derive"&&(h.has(S.relation)||c.setEdge(S.source,S.target));n.layout(c);const m=e.nodes.map(S=>{const b=c.node(S.id),w=o?S.id===o:void 0,v={kind:S.kind,label:s(S.label),bookId:S.kind==="book"?S.id:void 0,yearText:s(S.year_text??o0(S)),uncertain:S.year_uncertain,category:S.category,status:S.status,borderColor:S.group?p.get(S.group):void 0,renderLink:i,isSelected:w,description:s(S.description),bridge:S.bridge};return{id:S.id,type:"version",position:{x:b.x-160/2,y:b.y-90/2},data:v,draggable:!1,selected:w}}),u=.78,g=.06,x=new Map;for(const S of e.edges)S.kind==="derive"&&(x.has(S.source)||x.set(S.source,[]),x.get(S.source).push(S));const j=new Map;for(const[S,b]of x){if(b.length<=1)continue;const w=[...b].sort((k,z)=>{var R,T;const C=((R=c.node(k.target))==null?void 0:R.y)??0,_=((T=c.node(z.target))==null?void 0:T.y)??0;return C-_}),v=w.length;w.forEach((k,z)=>{const C=(z-(v-1)/2)*g;j.set(k.id,u+C)})}const y=e.edges.map(S=>r0(S,j.get(S.id),s));return{rfNodes:m,rfEdges:y}}function r0(e,n,i=o=>o??""){const o=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=s0(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 o0(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function s0(e){switch(e){case"certain":return r("confidence-certain");case"consensus":return r("lineage-edge-consensus");case"probable":return r("confidence-probable");case"disputed":return r("confidence-disputed");default:return r("muted")}}const gl={padding:"40px 20px",textAlign:"center",color:r("muted"),fontSize:"13px",border:`1px dashed ${r("widget-border")}`,borderRadius:8,background:r("bg")},as=({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:m})=>{var v;const{t:u,convert:g}=re(),[x,j]=f.useState(n),y=k=>{j(k),a==null||a(k)},S=(()=>{if(!c)return[];const k=Object.entries(c);return k.length===0||c.all?k:[...k,["all",{label:u("lineage.collectionAll"),description:u("lineage.collectionAllDesc")}]]})(),b=!!(d&&S.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:r("muted"),textAlign:"center"},children:u("lineage.empty")});const w=l?(v=c==null?void 0:c[l])==null?void 0:v.description:void 0;return t.jsxs("div",{className:h,style:m,children:[t.jsxs("div",{style:a0,children:[t.jsx("button",{onClick:()=>y("list"),style:Tr(x==="list"),children:u("lineage.modeList")}),t.jsx("button",{onClick:()=>y("graph"),style:Tr(x==="graph"),children:u("lineage.modeGraph")}),b&&t.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:12,color:r("muted"),marginRight:4},children:u("lineage.collectionLabel")}),S.map(([k,z])=>{const C=p==null?void 0:p[k];return t.jsxs("button",{onClick:()=>d==null?void 0:d(k),style:Tr(l===k),title:z.description?g(z.description):void 0,children:[g(z.label),C!=null?` ${C}`:""]},k)})]})]}),b&&w&&t.jsx("div",{style:{fontSize:12,color:r("muted"),marginBottom:8,padding:"4px 8px",background:r("bg-subtle"),borderRadius:4},children:g(w)}),x==="list"?t.jsx(Xd,{graph:e,renderLink:i}):t.jsx(Zd,{graph:e,renderLink:i,height:o,selectedNodeId:s})]})},a0={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},Tr=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"}),xl=40,bl=2,l0=9,c0=new Set(["certain","consensus","probable","disputed"]);function Ir(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const Jd=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:h})=>{var de,Te,B,pe,ie,_e,Re,De,Ye,et,Ze;const m=Ae(),{t:u,convert:g}=re(),[x,j]=f.useState(null),[y,S]=f.useState(new Map),[b,w]=f.useState([]),[v,k]=f.useState(new Map),[z,C]=f.useState(!1),[_,R]=f.useState("flow"),[T,N]=f.useState(null);f.useEffect(()=>{if(!n||!e.work_id){j(null);return}let $=!1;return n.getItem(e.work_id).then(M=>{!$&&M&&M.type==="work"&&j(M)}).catch(()=>{}),()=>{$=!0}},[n,e.work_id]),f.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){N(null);return}let $=!1;return n.getLineageGraph(e.work_id).then(M=>{$||N(M&&M.nodes.length>1?M:null)}).catch(()=>{$||N(null)}),()=>{$=!0}},[n,e.work_id]),f.useEffect(()=>{const $=e._collections||[];if(!n||$.length===0){S(new Map);return}let M=!1;return Promise.all($.map(P=>{const K=P.id;return n.getItem(K).then(he=>[K,he]).catch(()=>[K,null])})).then(P=>{if(M)return;const K=new Map;for(const[he,se]of P)se&&K.set(he,se);S(K)}),()=>{M=!0}},[n,e._collections]);const E=f.useMemo(()=>{const $=new Set([...x?ko(x):[],...e.related_books||[]]);return $.add(e.id),[...$]},[x,e.related_books,e.id]),W=E.length-1;f.useEffect(()=>{if(!n||W<=0){w([]);return}const $=E.length<=xl,M=$?E:E.slice(0,8);let P=!1;return Promise.all(M.map(K=>K===e.id?Promise.resolve({id:K,title:e.title,edition:e.edition,year:_i(e)}):n.getItem(K).then(he=>{const se=he??{};return{id:K,title:se.title,edition:se.edition,year:he?_i(se):void 0}}).catch(()=>({id:K})))).then(K=>{if(P)return;const he=K.filter(se=>se.id===e.id||se.title||se.edition);$&&he.sort((se,We)=>(se.year??1/0)-(We.year??1/0)),w(he)}),()=>{P=!0}},[n,E,W,e]);const F=e.lineage,A=f.useMemo(()=>[...((F==null?void 0:F.derived_from)||[]).filter($=>$.ref_type==="book").map($=>$.ref),...((F==null?void 0:F.related_to)||[]).map($=>$.book_id)].filter(Boolean),[F]);f.useEffect(()=>{if(!n||A.length===0){k(new Map);return}let $=!1;return Promise.all(A.map(M=>n.getItem(M).then(P=>[M,{id:M,title:P==null?void 0:P.title,edition:P==null?void 0:P.edition}]).catch(()=>[M,{id:M}]))).then(M=>{$||k(new Map(M))}),()=>{$=!0}},[n,A]);const V=f.useMemo(()=>Vd(e.resources,e.resource_groups,u),[e.resources,e.resource_groups,u]),ae=V.groups.reduce(($,M)=>$+M.rows.length+M.mirrors.length,0),xe=V.groups.length>0&&V.groups.every($=>$.key==="_physical"),me=Kn(e),G=Kl(e),ye=Dt(e,m.unit.juan),ne=new Set((e._collections||[]).map($=>Dn($.vol).length).filter($=>$>0)),U=$=>{var K;const M=(K=e.base_edition)==null?void 0:K.find(he=>he.book_id===$&&he.name);if(M!=null&&M.name)return M.name;const P=v.get($);return(P==null?void 0:P.edition)||(P==null?void 0:P.title)||""},Q=f.useMemo(()=>{var Y,H,fe,Ce,be;const $=[];G&&$.push({label:u("bookPage.fact.editionType"),value:g(G),title:e.edition_type||(Y=e.lineage)!=null&&Y.category?void 0:u("bookPage.inferredFromEdition")}),(H=e.publication_info)!=null&&H.details?$.push({label:u("bookPage.fact.publication"),value:g(e.publication_info.details)}):(me.era||me.reign)&&$.push({label:u("bookPage.fact.era"),value:g([me.era,me.reign].filter(Boolean).join(" ")),title:me.source==="edition"?u("bookPage.inferredFromEdition"):void 0}),ye&&$.push({label:u("bookPage.fact.measure"),value:g(ye)});const M=(e._collections||[]).flatMap(J=>Dn(J.vol));M.length&&$.push({label:u("bookPage.fact.volumes"),value:u("bookPage.volumesValue",{range:Pi(M,m.unit.volume),unit:m.unit.volume,n:M.length})});const P=(((fe=e.lineage)==null?void 0:fe.derived_from)||[]).find(J=>J.relation==="底本"&&J.ref_type==="book");P&&U(P.ref)&&$.push({label:u("bookPage.fact.baseEdition"),value:t.jsx(rt,{id:P.ref,label:g(U(P.ref)),onNavigate:i,renderLink:o,dense:!0})});const K=(e.base_edition||[]).filter(J=>J&&J.name);for(const J of["底本","配補","參校"]){if(J==="底本"&&P&&U(P.ref))continue;const Ee=K.filter(ge=>ge.role===J);Ee.length&&$.push({label:g(J),value:Ee.map((ge,Oe)=>t.jsxs(f.Fragment,{children:[Oe>0&&"、",ge.book_id?t.jsx(rt,{id:ge.book_id,label:g(ge.name),onNavigate:i,renderLink:o,dense:!0}):g(ge.name)]},Oe))})}const he=(e.provenance||[]).filter(J=>J&&J.institution),se=(e.resources||[]).filter(J=>Ht(J).includes("physical"));if(he.length){$.push({label:u("bookPage.fact.holdings"),value:he.slice(0,2).map(ge=>g(ge.institution)).join("、")+(he.length>2?u("bookPage.andMorePlaces",{n:he.length}):"")});const J=he.filter(ge=>ge.call_number).slice(0,2).map(ge=>`${g(ge.institution)} ${ge.call_number}`);J.length&&$.push({label:u("bookPage.fact.callNumber"),value:J.join(";")+(he.filter(ge=>ge.call_number).length>2?"…":"")});const Ee=he.flatMap(ge=>ge.seals||[]).filter(Boolean);Ee.length&&$.push({label:u("bookPage.fact.seals"),value:g(Ee.join("、"))})}else se.length?$.push({label:u("bookPage.fact.holdings"),value:se.slice(0,2).map(J=>g(J.name)).join("、")+(se.length>2?u("bookPage.andMorePlaces",{n:se.length}):"")}):(Ce=e.current_location)!=null&&Ce.name&&$.push({label:u("bookPage.fact.holdings"),value:g(e.current_location.name)});const We=e.physical_description;if(We){const J=[[u("bookPage.fact.leafStyle"),We.leaf_style],[u("bookPage.fact.binding"),We.binding],[u("bookPage.fact.dimensions"),We.dimensions],[u("bookPage.fact.condition"),We.condition]];for(const[Ee,ge]of J)ge&&ge.trim()&&$.push({label:Ee,value:g(ge)})}(be=e.page_count)!=null&&be.description&&$.push({label:m.label.pageCount,value:g(e.page_count.description)});const Be=[...qr(e.additional_titles),...qr(e.attached_texts)];return Be.length&&$.push({label:u("bookPage.fact.aliases"),value:Be.map(g).join("、")}),$},[e,g,m,u,me,G,ye,v,i,o]),q=g(e.title),je=e.edition?g(e.edition):void 0,I=((de=e.lineage)==null?void 0:de.year_text)||"",oe=t.jsx(Zn,{kind:u("bookPage.kind"),title:q,subtitle:je,byline:t.jsx(os,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:i,renderLink:o}),meta:(()=>{const $=[G?g(G):"",me.era?g([me.era,me.reign].filter(Boolean).join("")):"",ye?g(ye):""].filter(Boolean);return $.length?t.jsx("span",{className:"bim-d-tags",children:$.map((M,P)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(P,2)}`,children:M},P))}):null})(),description:(Te=e.description)!=null&&Te.text?t.jsx(Ut,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:Eo((B=e.description)==null?void 0:B.text)?6:void 0,facts:Q,readAction:s,secondaryAction:s&&ae>0&&!xe?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:u("bookPage.viewImages")}):void 0,foot:t.jsx(Jn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),$e=e._collections||[],ve=(a==null?void 0:a.chapters)||[],Le=g(ve[0]&&Ir(ve[0].title)[0].slice(-1)||"")||u("bookPage.chapterUnit"),Ne=u("bookPage.chapterCount",{n:ve.length,unit:Le}),X=!!((pe=F==null?void 0:F.derived_from)!=null&&pe.length||(ie=F==null?void 0:F.related_to)!=null&&ie.length||(_e=e.appendix)!=null&&_e.length),ue=[],Pe=u(xe?"bookPage.sec.physical":"bookPage.sec.images");(ve.length||V.text.length||l)&&ue.push({id:"fulltext",label:u("bookPage.sec.fulltext"),count:ve.length?Ne:void 0}),V.groups.length&&ue.push({id:"images",label:Pe,count:ae}),X&&ue.push({id:"lineage",label:u("bookPage.sec.lineage")}),$e.length&&ue.push({id:"collections",label:u("section.containedIn"),count:$e.length}),(Re=e.location_history)!=null&&Re.length&&ue.push({id:"provenance",label:u("section.locationHistory")});const Me=$=>(d==null?void 0:d($))??null,ke=ve[0],D=ke?Me(ke.file):null,le=z?ve:ve.slice(0,l0),ce=($,M,P)=>$?t.jsx("a",{className:P,href:$.href??"#",onClick:$.onClick?K=>{K.metaKey||K.ctrlKey||(K.preventDefault(),$.onClick())}:void 0,children:M}):t.jsx("span",{className:P,children:M}),Z=t.jsxs(t.Fragment,{children:[(ve.length>0||V.text.length>0||l)&&t.jsxs(ut,{id:"fulltext",title:u("bookPage.sec.fulltext"),meta:ve.length>0?t.jsx(ct,{items:[Ne,(De=a==null?void 0:a.source)!=null&&De.name?u("bookPage.sourceBy",{src:g(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!ke&&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"})]}),ke&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:u("bookPage.readFrom",{ch:g(Ir(ke.title)[0])||u("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:g((ke.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),ce(D,t.jsxs(t.Fragment,{children:[u("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),ve.length>1&&t.jsx("ul",{className:"bim-d-chap",children:le.map($=>{const[M,P]=Ir($.title);return t.jsx("li",{children:ce(Me($.file),t.jsxs(t.Fragment,{children:[M&&t.jsx("b",{children:g(M)}),g(P||$.file)]}))},$.file)})}),ve.length>le.length&&t.jsx(Ro,{label:u("detail.expandRest",{n:ve.length-le.length,unit:Le}),onClick:()=>C(!0)}),V.text.length>0&&t.jsxs(t.Fragment,{children:[(ve.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:u("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:V.text.map(($,M)=>t.jsx(ss,{item:$,siblings:V.text,listedVolumeCounts:ne},`${$.id||$.url||$.name}-${M}`))})})]})]}),V.groups.length>0&&t.jsx(ut,{id:"images",title:Pe,meta:t.jsx(ct,{items:[V.groups.length>1?u("bookPage.groupCount",{n:V.groups.length}):"",u("bookPage.placeCount",{n:ae})]}),children:t.jsx(Yd,{groups:V.groups,listedVolumeCounts:ne})}),X&&t.jsx(ut,{id:"lineage",title:u("bookPage.sec.lineage"),meta:(Ye=F==null?void 0:F.derived_from)!=null&&Ye.length?u("bookPage.lineageMeta"):void 0,action:T?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":u("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":_==="flow",onClick:()=>R("flow"),children:u("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":_==="graph",onClick:()=>R("graph"),children:u("bookPage.viewGraph")})]}):void 0,children:_==="graph"&&T?t.jsx(as,{graph:T,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:($,M)=>t.jsx(rt,{id:$,label:g(M),onNavigate:i,renderLink:o,dense:!0})}):t.jsx(p0,{data:e,heading:je||q,yearText:I,refName:U,onNavigate:i,renderLink:o})}),$e.length>0&&t.jsx(ut,{id:"collections",title:u("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:$e.map(($,M)=>{const P=$.id,K=Dn($.vol),he=y.get(P),se=Im(he);return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(rt,{id:P,label:he?g(he.title):P,onNavigate:i,renderLink:o,dense:!0}),K.length>0&&t.jsx(d0,{volumes:K,unit:m.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${se?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:se>0&&u("bookPage.totalOf",{n:se,unit:m.unit.bu})})]},`${P}-${M}`)})})})}),(et=e.location_history)!=null&&et.length?t.jsx(ut,{id:"provenance",title:u("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map(($,M)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:g($.name)}),([$.start_date,$.end_date].filter(Boolean).join("—")||$.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(ct,{items:[[$.start_date,$.end_date].filter(Boolean).join("—"),$.description?g($.description):""]})})]},M))})}):null,ue.length===0&&t.jsx(ut,{title:u("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:u("bookPage.emptyText")})})]}),we=b.findIndex($=>$.id===e.id),He=E.length<=xl,Ge=He&&we>=0?b.slice(Math.max(0,we-bl),we+bl+1):b.filter($=>$.id!==e.id),Xe=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:g(m.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(rt,{id:x.id,label:g(x.title),onNavigate:i,renderLink:o})}),t.jsx(ct,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map($=>`${$.dynasty?`〔${g($.dynasty)}〕`:""}${g($.name)}`),g(Dt(x,m.unit.juan)),x._edition_count?u("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:g(x.description.text.replace(/[#*_>`[\]]/g,""))})]}),W>0&&Ge.length>0&&t.jsxs("div",{children:[t.jsx(sn,{id:"siblings",timeline:!0,title:He?u("bookPage.siblings"):m.relation.siblingVersions,meta:He?u("bookPage.byEra"):u("bookPage.kindCount",{n:W}),cap:Ge.length,items:Ge.map($=>$.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:g($.edition||$.title||$.id)}):t.jsx(rt,{id:$.id,label:g($.edition||$.title||$.id),onNavigate:i,renderLink:o,dense:!0})),metas:Ge.map($=>[$.year!=null?$.year<0?u("detail.bce",{n:-$.year}):String($.year):"",$.id===e.id?u("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:Ge.findIndex($=>$.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(rt,{id:x.id,label:u("bookPage.viewAllInWork",{n:E.length}),onNavigate:i,renderLink:o,dense:!0})})]})]}),O=e.work_id?t.jsx(Lc,{caption:m.section.belongsToWork,children:t.jsx(rt,{id:e.work_id,label:x?g(x.title):" ",onNavigate:i,renderLink:o,dense:!0})}):void 0;return t.jsx(Xn,{railTop:c,back:p,up:O,nav:ue,railLinks:h,main:Z,card:oe,side:Xe})};function d0({volumes:e,unit:n}){const{t:i}=re();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[i("bookPage.volumeRange",{range:Pi(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 p0({data:e,heading:n,yearText:i,refName:o,onNavigate:s,renderLink:a}){var S;const{t:l,convert:d}=re(),c=e.lineage,p=(c==null?void 0:c.derived_from)||[],h=p.filter(b=>b.ref_type!=="book"),m=p.filter(b=>b.ref_type==="book"&&b.relation==="底本"),u=p.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),g=(c==null?void 0:c.related_to)||[],x=p.length>0||g.length>0,j=b=>b&&c0.has(b)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${b}`)}):"",y=(b,w)=>t.jsx(rt,{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),j(b.confidence)]})]})},`a-${w}`)),m.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),j(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)})]}),u.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:u.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),j(b.confidence)]})]},w))})]}),g.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:g.map((b,w)=>t.jsxs("span",{className:"bim-d-lf-chip",title:b.evidence?d(b.evidence):void 0,children:[y(b.book_id,o(b.book_id)),t.jsx("span",{className:"bim-d-meta",children:d(b.relation)})]},w))})]})]}),(S=e.appendix)==null?void 0:S.map((b,w)=>t.jsxs("details",{className:"bim-d-lf-app",children:[t.jsxs("summary",{className:"bim-d-ui",children:[t.jsx("span",{className:"bim-d-meta",children:l("bookPage.lineage.appendix")})," ",d(b.title)]}),t.jsx(Ut,{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 Wn=16,u0=200,m0=16,Qd=({data:e,catalog:n,transport:i,onNavigate:o,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var we,He,Ge,Xe,O,de,Te;const{t:p,convert:h,messages:m}=re(),[u,g]=f.useState(""),[x,j]=f.useState(!1),[y,S]=f.useState(null),[b,w]=f.useState(""),[v,k]=f.useState(!1),z=f.useMemo(()=>ql(e,n),[e,n]),C=f.useMemo(()=>Yl(e),[e]),[_,R]=f.useState(new Map),T=!!i&&z.rows.length>0&&z.rows.length<=u0,N=T&&(z.rows.length<=Wn||v),E=N&&z.rows.every(B=>!B.id||_.has(B.id)),W=B=>{var pe;return ro(B?(pe=_.get(B))==null?void 0:pe.l1:void 0)},F=f.useMemo(()=>{const B=u.trim(),pe=B?h(B):"";return z.rows.filter(ie=>{var Re,De;if(b&&ro(ie.id?(Re=_.get(ie.id))==null?void 0:Re.l1:void 0)!==b)return!1;if(!pe)return!0;const _e=ie.id&&((De=_.get(ie.id))==null?void 0:De.title)||ie.title;return h(_e).includes(pe)||(ie.subItems||[]).some(Ye=>h(Ye).includes(pe))})},[z.rows,u,b,_,h]),A=x?F:F.slice(0,Wn),V=f.useMemo(()=>(N?z.rows:A).filter(B=>B.id&&!_.has(B.id)).map(B=>B.id),[N,z.rows,A,_]);f.useEffect(()=>{if(!i||V.length===0)return;let B=!1;const pe=V.slice(0,m0);return Yi(pe,Gi,ie=>i.getItem(ie).then(_e=>{var Ye,et;const Re=_e??{},De={title:Re.title,edition:Re.edition,authors:Re.authors,measure:_e?Dt(_e,m.unit.juan):void 0,versionCount:Re._edition_count??((Ye=Re._books)==null?void 0:Ye.length),l1:((et=wo(Re))==null?void 0:et.l1)||void 0};return[ie,De]}).catch(()=>[ie,{}]),()=>B).then(ie=>{B||R(_e=>{const Re=new Map(_e);for(const[De,Ye]of ie)Re.set(De,Ye);return Re})}),()=>{B=!0}},[i,V,m.unit.juan]);const ae=(we=(e.contained_in||[])[0])==null?void 0:we.id;f.useEffect(()=>{if(!ae){S(null);return}if(S({id:ae}),!i)return;let B=!1;return i.getItem(ae).then(pe=>{B||S({id:ae,title:pe==null?void 0:pe.title})}).catch(()=>{}),()=>{B=!0}},[i,ae]);const xe=f.useMemo(()=>Vd(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),me=xe.text.length+xe.groups.reduce((B,pe)=>B+pe.rows.length+pe.mirrors.length,0),G=C.works,ye=new Set(z.rows.map(B=>B.id).filter(Boolean)),ne=G.length>0&&!G.every(B=>ye.has(B.id)),U=(()=>{const B=z.rows.map(pe=>pe.edition).filter(Boolean);return B.length>1&&new Set(B).size===1})(),Q=z.rows.some(B=>B.volumes.length>0||B.expected!=null),q=C.total,je=C.truncated?q:z.rows.length,I=Dt(e,m.unit.juan),oe=e.count,$e=B=>typeof B=="number"&&Number.isFinite(B)?B:null,ve=$e(oe==null?void 0:oe.juan)??$e((He=e.juan_count)==null?void 0:He.number),Le=$e(oe==null?void 0:oe.ce)??(z.totalVolumes||null),Ne=[{value:je,label:p("collectionPage.stat.titles")},{value:ve??0,label:m.unit.juan},{value:Le??0,label:m.unit.volume}],X=f.useMemo(()=>{var ie,_e;const B=[];if((ie=e.publication_info)!=null&&ie.details&&B.push({label:p("collectionPage.fact.publication"),value:h(e.publication_info.details)}),q&&(q!==z.rows.length||C.truncated)){const Re=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");B.push({label:Re,value:`${q} ${m.unit.bu}`,title:p("collectionPage.memberNote")})}const pe=[$e(oe==null?void 0:oe.zhong)!=null?p("collectionPage.nZhong",{n:oe.zhong}):"",$e(oe==null?void 0:oe.han)!=null?p("collectionPage.nHan",{n:oe.han}):""].filter(Boolean);return pe.length&&B.push({label:p("collectionPage.fact.expected"),value:pe.join(" ")}),ve==null&&I&&B.push({label:p("collectionPage.fact.measure"),value:h(I),title:(_e=e.juan_count)!=null&&_e.description?h(e.juan_count.description):void 0}),B},[e,q,C.truncated,z.rows.length,ve,I,oe,h,p,m]),ue=f.useMemo(()=>{if(!E)return[];const B=new Map;for(const ie of z.rows){const _e=W(ie.id);_e&&B.set(_e,(B.get(_e)??0)+1)}const pe=Gn.filter(ie=>(B.get(ie.key)??0)>0);return pe.length<2?[]:[{key:"",label:`${m.catalog.all} ${je}`},...pe.map(ie=>({key:ie.key,label:`${ie.label} ${B.get(ie.key)}`}))]},[E,z.rows,_,m]),Pe=f.useMemo(()=>{if(!E||!z.rows.some(_e=>_e.volumes.length>0))return null;const B=[],pe=z.rows.filter(_e=>_e.volumes.length>0).map(_e=>({k:W(_e.id)??"",from:Math.min(..._e.volumes),to:Math.max(..._e.volumes)})).sort((_e,Re)=>_e.from-Re.from);for(const _e of pe){const Re=_e.to-_e.from+1,De=B[B.length-1];De&&De.key===_e.k?(De.to=Math.max(De.to,_e.to),De.n+=Re):B.push({key:_e.k,from:_e.from,to:_e.to,n:Re})}const ie=pe.reduce((_e,Re)=>Math.max(_e,Re.to),0);return B.length>1&&B.some(_e=>_e.key)?{segs:B,last:ie}:null},[E,z.rows,_]),Me=(Ge=e.description)==null?void 0:Ge.text,ke=t.jsx(Zn,{kind:p("collectionPage.kind"),title:h(e.title),byline:t.jsx(os,{authors:e.authors,onNavigate:o,renderLink:s}),meta:t.jsx(ct,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(Xe=e.publication_info)!=null&&Xe.year?h(e.publication_info.year):""]}),description:Me||(O=e.history)!=null&&O.length?t.jsxs(t.Fragment,{children:[Me&&t.jsx(Ut,{text:Me,style:{fontSize:15,lineHeight:1.85}}),(de=e.history)!=null&&de.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((B,pe)=>t.jsx("li",{children:h(B)},pe))}):null]}):void 0,clampDescription:Eo(Me)||(((Te=e.history)==null?void 0:Te.length)??0)>2?6:void 0,stats:Ne,facts:X,foot:t.jsx(Jn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:Pe&&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:Pe.segs.map((B,pe)=>{const ie=Gn.find(_e=>_e.key===B.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!ie,title:ie?p("collectionPage.dist.segTitle",{section:h(ie.label),from:B.from,to:B.to}):void 0,"aria-label":ie?p("collectionPage.dist.only",{section:h(ie.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!ie&&b===B.key,style:{flexGrow:B.n,background:r(ie?ie.token:"rule")},onClick:()=>{ie&&(w(b===B.key?"":B.key),j(!1))}},pe)})}),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:Pe.last})})]})]})}),D=[];z.rows.length&&D.push({id:"titles",label:p("collectionPage.sec.titles"),count:je}),me&&D.push({id:"resources",label:p("collectionPage.sec.resources"),count:me}),ne&&D.push({id:"works",label:m.section.containedWorks,count:G.length});const le=t.jsxs(t.Fragment,{children:[z.rows.length>0&&t.jsxs(ut,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(ct,{items:[`${je} ${m.unit.items}`,z.totalVolumes?p("collectionPage.totalVolumes",{n:z.totalVolumes,unit:m.unit.volume}):"",F.length!==je?p("collectionPage.currentN",{n:F.length,unit:m.unit.items}):""]}),action:a,children:[(z.rows.length>Wn||ue.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[ue.length>0&&t.jsx(Hi,{items:ue,value:b,onChange:B=>{w(B),j(!1)}}),T&&z.rows.length>Wn&&!E&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:v,onClick:()=>k(!0),title:p("collectionPage.loadAllTitle",{n:z.rows.length,unit:m.unit.items}),children:p(v?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),z.rows.length>Wn&&t.jsx("input",{type:"search",className:"bim-d-find",value:u,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:B=>{g(B.target.value),j(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Di(F.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[Q&&t.jsx("th",{style:{width:"8.5em"},children:p("collectionPage.col.volumes")}),t.jsx("th",{children:p("collectionPage.col.title")}),t.jsx("th",{style:{textAlign:"right"},children:p("collectionPage.col.versions")})]})}),t.jsx("tbody",{children:A.map((B,pe)=>{var Ze;const ie=B.id?_.get(B.id):void 0,_e=ie!=null&&ie.title&&B.title===B.id?ie.title:B.title,Re=((ie==null?void 0:ie.authors)||[]).find($=>$&&$.name),De=[Re?`${Re.dynasty?`〔${h(Re.dynasty)}〕`:""}${h(Re.name)}${Re.role?` ${h(Re.role)}`:""}`:"",ie!=null&&ie.measure?h(ie.measure):"",(Ze=B.subItems)!=null&&Ze.length?B.subItems.map($=>h($)).join("、"):"",(ie!=null&&ie.edition||B.edition)&&!U?h((ie==null?void 0:ie.edition)||B.edition||""):""].filter(Boolean),Ye=Gn.find($=>$.key===W(B.id)),et=B.volumes.length>0?p("collectionPage.volumeRange",{range:Pi(B.volumes,m.unit.volume),unit:m.unit.volume}):B.expected!=null?`${B.found??0}/${B.expected} ${m.unit.volume}`:"";return t.jsxs("tr",{children:[Q&&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:[B.id?t.jsx(rt,{id:B.id,label:h(_e),onNavigate:o,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:h(_e)}),De.length>0?t.jsx(ct,{items:De}):B.id&&!ie&&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${ie!=null&&ie.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:ie!=null&&ie.versionCount?p("collectionPage.nZhong",{n:ie.versionCount}):""})]},`${B.id??B.title}-${pe}`)})})]}),A.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!x&&t.jsx(Io,{total:F.length,shown:A.length,unit:m.unit.items,onClick:()=>j(!0)})]}),me>0&&t.jsxs(ut,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:me}),children:[xe.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[xe.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:xe.text.map((B,pe)=>t.jsx(ss,{item:B,siblings:xe.text},`${B.id||B.url||B.name}-${pe}`))})})]}),t.jsx(Yd,{groups:xe.groups})]}),z.rows.length===0&&me===0&&t.jsx(ut,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),ce=ne?t.jsx(sn,{id:"works",title:m.section.containedWorks,meta:p("collectionPage.nZhong",{n:G.length}),cap:12,items:G.map(B=>t.jsx(rt,{id:B.id,label:h(B.title),onNavigate:o,renderLink:s,dense:!0}))}):null,Z=y?t.jsx(Lc,{caption:p("collectionPage.parent"),children:t.jsx(rt,{id:y.id,label:h(y.title||y.id),onNavigate:o,renderLink:s,dense:!0})}):void 0;return t.jsx(Xn,{railTop:l,back:d,up:Z,nav:D,railLinks:c,main:le,card:ke,side:ce})},h0=8;function ep(e){return typeof e!="string"||!e||e.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.split("/").some(n=>n==="..")?null:e}function f0(e){return(e||[]).filter(n=>{var i,o;return ep(n==null?void 0:n.file)&&((i=n.credit)==null?void 0:i.trim())&&((o=n.license)==null?void 0:o.trim())}).slice(0,h0)}function g0({images:e,assetBase:n,name:i}){const{t:o,convert:s}=re(),[a,l]=f.useState(0),[d,c]=f.useState(!1),p=n?f0(e):[];if(!n||d||p.length===0)return null;const h=n.endsWith("/")?n:n+"/",m=p[Math.min(a,p.length-1)],u=m.width&&m.height&&m.width>0&&m.height>0?`${m.width} / ${m.height}`:void 0,g=x=>h+ep(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:g(m),alt:o("entityPage.sealAlt",{name:i})+(p.length>1?` ${a+1}`:""),style:u?{"--seal-ar":u}:void 0,width:m.width,height:m.height,decoding:"async",fetchPriority:"high",onError:()=>c(!0)},m.file),p.length>1&&t.jsx("div",{className:"bim-d-seal-thumbs",children:p.map((x,j)=>t.jsx("button",{type:"button","aria-pressed":j===a,"aria-label":`${o("entityPage.sealAlt",{name:i})} ${j+1}`,onClick:()=>l(j),children:t.jsx("img",{src:g(x),alt:"",loading:"lazy",decoding:"async"})},x.file))}),t.jsxs("figcaption",{children:[o("entityPage.imgCredit",{credit:s(m.credit)})," · ",o("entityPage.imgLicense",{license:s(m.license)}),m.source_url&&/^https?:\/\//i.test(m.source_url)&&t.jsxs(t.Fragment,{children:[" · ",t.jsx("a",{href:m.source_url,target:"_blank",rel:"noopener noreferrer nofollow",children:o("entityPage.imgSource")})]}),m.note&&t.jsxs(t.Fragment,{children:[" · ",s(m.note)]})]})]})}const x0=16,Rr=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function yl(e){if(!e)return Rr.length;const n=Rr.indexOf(e);return n===-1?Rr.length:n}function b0(e,n,i){if(n)return e[n]??i(n)}function y0(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const j0={秦:[-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]},tp=({data:e,transport:n,onNavigate:i,renderLink:o,railTop:s,back:a,railLinks:l,assetBase:d})=>{var Z,we,He,Ge,Xe;const{t:c,convert:p,messages:h}=re(),m=O=>y0(O,c),[u,g]=f.useState("全部"),[x,j]=f.useState(!1),[y,S]=f.useState("default"),[b,w]=f.useState(new Map),v=f.useMemo(()=>e._works||[],[e._works]),k=f.useMemo(()=>v.map(O=>{const de=b.get(O.work_id);return{id:O.work_id,title:(de==null?void 0:de.title)??O.title??O.work_id,role:O.role||"",cls:jo(O.role),versionCount:de==null?void 0:de.versionCount,section:de==null?void 0:de.cls,l1:de==null?void 0:de.l1,measure:de==null?void 0:de.measure,hasImage:de==null?void 0:de.hasImage,loaded:!!(de!=null&&de.loaded)}}),[v,b]),z=f.useMemo(()=>Gl(v.map(O=>O.role),c("detail.roleAll")),[v,c]),C=f.useMemo(()=>{const O=u==="全部"?k:k.filter(de=>de.cls===u);return y==="versions"?[...O].sort((de,Te)=>(Te.versionCount??-1)-(de.versionCount??-1)):O},[k,u,y]),_=x?C:C.slice(0,x0),R=f.useMemo(()=>_.filter(O=>!b.has(O.id)).map(O=>O.id),[_,b]);f.useEffect(()=>{if(!n||R.length===0)return;let O=!1;return Yi(R,Gi,de=>n.getItem(de).then(Te=>{var Re;const B=Te??{},pe=B._edition_count??((Re=B._books)==null?void 0:Re.length)??0,ie=wo(B),_e=[ie==null?void 0:ie.l1,ie==null?void 0:ie.l2].filter(Boolean).join(" ");return[de,{id:de,title:B.title,versionCount:pe,loaded:!0,cls:_e||void 0,l1:(ie==null?void 0:ie.l1)||void 0,measure:Te&&Dt(Te,h.unit.juan)||void 0,hasImage:!!B._has_image}]}).catch(()=>[de,{id:de,loaded:!0}]),()=>O).then(de=>{O||w(Te=>{const B=new Map(Te);for(const[pe,ie]of de)B.set(pe,ie);return B})}),()=>{O=!0}},[n,R,h.unit.juan]);const T=f.useMemo(()=>{const O=new Map;for(const de of e.alt_names||[]){const Te=de.type||h.section.aliases;O.has(Te)||O.set(Te,[]),O.get(Te).push(de.name)}return[...O.entries()].sort((de,Te)=>yl(de[0])-yl(Te[0])).map(([de,Te])=>({label:de,names:Te}))},[e.alt_names,h]),N=((Z=e.dates)==null?void 0:Z.birth)??void 0,E=((we=e.dates)==null?void 0:we.death)??void 0,W=(He=e.dates)==null?void 0:He.floruit,F=N!=null||E!=null?`${m(N)||"?"}—${m(E)||"?"}`:Array.isArray(W)&&W.length===2&&W.every(O=>Number.isFinite(O))?c("entityPage.floruit",{from:m(W[0]),to:m(W[1])}):"",A=new Set(["本名","字","號","号"]),V=T.filter(O=>A.has(O.label)),ae=T.filter(O=>!A.has(O.label)),xe=ae.reduce((O,de)=>O+de.names.length,0),me=f.useMemo(()=>{const O=[];for(const Te of V)O.push({label:Te.label,value:Te.names.map(B=>p(B)).join("、")});const de=v.length;return de&&O.push({label:c("entityPage.fact.works"),value:c("entityPage.nZhong",{n:de})}),O},[v,V,p,c]),G=O=>{var de;return(de=T.find(Te=>O.includes(Te.label)))==null?void 0:de.names[0]},ye=G(["字"]),ne=G(["號","号"]),U=[ye?c("entityPage.zi",{name:p(ye)}):"",ne?c("entityPage.hao",{name:p(ne)}):""].filter(Boolean).join(","),Q=e.native_place,q=e.dynasty?j0[e.dynasty]:void 0,je=(()=>{if(!q||N==null||E==null||E<N)return null;const[O,de]=q,Te=Math.max(N,O),B=Math.min(E,de);if(B<=Te)return null;const pe=de-O;return t.jsxs("div",{className:"bim-d-life bim-d-ui",children:[t.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":c("entityPage.lifeAria",{birth:m(N),death:m(E),years:E-N+1}),children:t.jsx("i",{style:{left:`${(Te-O)/pe*100}%`,width:`${(B-Te)/pe*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${m(O)} ${p(e.dynasty)}`}),t.jsx("span",{children:c("entityPage.lifeYears",{years:E-N+1})}),t.jsx("span",{children:m(de)})]})]})})(),I=f.useMemo(()=>{if(!n||k.length===0||k.some(Te=>!Te.loaded))return null;const O=new Map;for(const Te of k){const B=ro(Te.l1);B&&O.set(B,(O.get(B)??0)+1)}const de=Gn.map(Te=>({...Te,n:O.get(Te.key)??0})).filter(Te=>Te.n>0);return de.length?de:null},[k,n]),oe=t.jsxs(Zn,{kind:b0(h.entityPage.subtype,e.subtype,p),title:p(e.primary_name||e.title),subtitle:U||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(ct,{items:[e.dynasty?p(e.dynasty):"",F,Q?c("entityPage.nativePlace",{place:p(Q)}):""]}),je,t.jsx(g0,{images:e.images,assetBase:d,name:p(e.primary_name||e.title)})]}),description:(Ge=e.description)!=null&&Ge.text?t.jsx(Ut,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:Eo((Xe=e.description)==null?void 0:Xe.text)?6:void 0,facts:me,foot:t.jsx(Jn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[xe>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:c("entityPage.moreNames",{n:xe})}),t.jsx("dl",{children:ae.map(O=>t.jsxs(f.Fragment,{children:[t.jsx("dt",{children:p(O.label)}),t.jsx("dd",{children:O.names.map(de=>p(de)).join("、")})]},O.label))})]}),I&&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:I.map(O=>t.jsx("i",{style:{flexGrow:O.n,background:r(O.token)}},O.key))}),t.jsx("div",{className:"bim-d-dist-key",children:I.map(O=>t.jsxs("span",{children:[t.jsx("i",{style:{background:r(O.token)}}),p(O.label)," ",O.n]},O.key))})]})]}),$e=f.useMemo(()=>k.filter(O=>O.loaded&&(O.versionCount??0)>0).sort((O,de)=>(de.versionCount??0)-(O.versionCount??0)).slice(0,3),[k]),ve=!!n&&k.length>=3&&_.some(O=>!O.loaded),Le=u==="全部"&&(ve||$e.length>=2),Ne=e.external_ids||{},X=[];Ne.cbdb_id!=null&&X.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 ue=Ne.wikidata_id;ue&&X.push({label:"Wikidata",id:ue,href:`https://www.wikidata.org/wiki/${ue}`});const Pe=Ne.viaf_id;Pe&&X.push({label:"VIAF",id:Pe,href:`https://viaf.org/viaf/${Pe}`});const Me=z.map(O=>({key:O.cls,label:`${O.label} ${O.count}`})),ke=[...Le&&!ve?[{id:"featured",label:c("entityPage.sec.featured"),count:$e.length}]:[],...k.length?[{id:"works",label:c("entityPage.sec.allWorks"),count:k.length}]:[],...X.length?[{id:"external",label:c("entityPage.sec.external"),count:X.length}]:[]],D=Le?t.jsxs(ut,{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":ve||void 0,children:[ve&&[0,1,2].map(O=>t.jsxs("div",{className:"bim-d-pick","aria-hidden":"true",children:[t.jsx("span",{className:"bim-d-pick-t",children:" "}),t.jsx("span",{className:"bim-d-meta",children:" "}),t.jsx("div",{className:"bim-d-pick-n",children:" "})]},O)),!ve&&$e.map(O=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(rt,{id:O.id,label:p(O.title),onNavigate:i,renderLink:o,dense:!0})}),t.jsx(ct,{items:[O.section?p(O.section):"",O.measure?p(O.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:O.versionCount}),t.jsx("span",{children:c("entityPage.versionsUnit")}),O.hasImage&&t.jsx("span",{className:"bim-d-flag",children:c("entityPage.hasImage")})]})]},O.id))]})]}):null,le=k.length===0?t.jsx(ut,{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:[D,t.jsxs(ut,{id:"works",title:c("entityPage.sec.works"),meta:t.jsx(ct,{items:[c("entityPage.total",{n:k.length}),C.length!==k.length?c("entityPage.current",{n:C.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[Me.length>1&&t.jsx(Hi,{items:Me,value:u,onChange:O=>{g(O),j(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":y==="versions",onClick:()=>{y==="default"&&j(!0),S(O=>O==="default"?"versions":"default")},children:c(y==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Di(C.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(O=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(rt,{id:O.id,label:p(O.title),onNavigate:i,renderLink:o,dense:!0}),O.measure?t.jsx(ct,{items:[p(O.measure)]}):!O.loaded&&n?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${O.section||O.loaded?"":" bim-d-zt-blank"}`,children:O.section?p(O.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${O.role?"":" bim-d-zt-blank"}`,children:O.role?p(O.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${O.loaded?"":" bim-d-zt-blank"}`,children:O.loaded?O.versionCount?c("entityPage.nZhong",{n:O.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:c("entityPage.notRecorded")}):""}),t.jsx("td",{className:O.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:O.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:c("entityPage.hasImage")})})]},O.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(Io,{total:C.length,shown:_.length,unit:c("entityPage.moreUnit"),onClick:()=>j(!0)})]})]}),ce=X.length>0?t.jsx(sn,{id:"external",title:c("entityPage.sec.external"),items:X.map(O=>t.jsxs("a",{href:O.href,target:"_blank",rel:"noopener noreferrer",children:[O.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:X.map(O=>O.id),foot:Ne.cbdb_id!=null&&Ne.cbdb_match==="auto"?c("entityPage.cbdbAuto"):void 0}):null;return t.jsx(Xn,{railTop:s,back:a,nav:ke,railLinks:l,main:le,card:oe,side:ce})},ls="(max-width: 719px)",v0=`${ls}, (pointer: coarse)`,np=`
|
|
1406
|
+
${D??""}`,[Pt,bs]=f.useState({key:qt,data:H,started:!!H});if(Pt.key!==qt)bs({key:qt,data:H,started:!1});else if(H!==Pt.data&&(bs({key:qt,data:H,started:!!H}),H)){const L=H.pages??[];(!Pt.started||!L.some(te=>te.page===Xe))&&$t(_t(H))}f.useEffect(()=>{Oe(new Set),Se.set(null)},[D,I,Se]);const nr=Pt.key===qt&&Pt.started,ys=f.useMemo(()=>nr&&H?yd(H.pages,H.punctuations):[],[nr,H]),ir=f.useCallback(L=>{const te=jd(L.headings);return te.length>0?te:L.file===D?ys:[]},[D,ys]),Jp=f.useCallback(L=>{if(Oe(new Set(L)),L.length>0){const te=L[0],Ne=parseInt(te.split(":")[0],10);isNaN(Ne)||$t(Ne)}},[]),Bt=f.useMemo(()=>{const L=new Map;for(const te of(H==null?void 0:H.pages)??[])L.set(te.page,te);return L},[H]),Rn=nt(H),ii=f.useCallback(L=>{var Je;const te=Y.images;if(!te||te.length===0)return;const Ne=(Je=Bt.get(L))==null?void 0:Je.seq;return(Ne?te.find(qe=>qe.seq===Ne):void 0)??te.find(qe=>qe.pageNo===L)??te[L-1]},[Y.images,Bt]),js=et>1.5,ri=f.useCallback((L,te=!1)=>{const Ne=ii(L);return Ne?L===Rn||te?Ne.hiresUrl??Ne.url:Ne.url:L===Rn?(H==null?void 0:H.imageUrl)??"":""},[ii,H,Rn]),Qp=f.useMemo(()=>ri(Xe,js),[ri,Xe,js]),Ot=f.useMemo(()=>[...Bt.keys()].sort((L,te)=>L-te),[Bt]),nn=f.useRef(Xe);nn.current=Xe;const rr=f.useRef(0),or=f.useRef({page:null,timer:null}),eu=f.useCallback(L=>{const te=or.current;L!==te.page&&(te.timer&&(clearTimeout(te.timer),te.timer=null),te.page=null,!(L===nn.current||Date.now()<rr.current)&&(te.page=L,te.timer=setTimeout(()=>{te.timer=null,te.page=null,!(Date.now()<rr.current||nn.current===L)&&(nn.current=L,$t(L))},Mx)))},[]);f.useEffect(()=>()=>{or.current.timer&&clearTimeout(or.current.timer)},[]);const oi=f.useCallback(L=>{var te;nn.current===L||!Bt.has(L)||(rr.current=Date.now()+1e3,nn.current=L,$t(L),(te=Bt.get(L))!=null&&te.columns.some(Ne=>Ne.chars.length>0)&&Ge(Ne=>({page:L,nonce:((Ne==null?void 0:Ne.nonce)??0)+1})))},[Bt]),En=f.useCallback(L=>{const te=nn.current,Ne=Ot.indexOf(te),Je=Ot[Ne<0?0:Ne+L];Je===void 0||Je===te||oi(Je)},[Ot,oi]),vs=f.useCallback(L=>{if(!L.trim().match(/^\d+$/)||Ot.length===0)return null;const Ne=parseInt(L.trim(),10),Je=Number.isFinite(Ne)?Ne:Number.MAX_SAFE_INTEGER;return Ot.reduce((qe,Nt)=>Math.abs(Nt-Je)<Math.abs(qe-Je)?Nt:qe,Ot[0])},[Ot]),[sr,ar]=f.useState(null),si=f.useRef(null),tu=f.useCallback(L=>{si.current=L,ar(L)},[]),ks=f.useCallback(()=>{const L=si.current;if(si.current=null,ar(null),L===null)return;const te=vs(L);te!==null&&oi(te)},[vs,oi]),lr=Ot.indexOf(Xe),nu=f.useCallback(L=>{if(L.altKey||L.ctrlKey||L.metaKey)return;const te=L.target.tagName;te==="INPUT"||te==="TEXTAREA"||te==="SELECT"||(L.key==="ArrowLeft"||L.key==="PageUp"?(L.preventDefault(),En(-1)):(L.key==="ArrowRight"||L.key==="PageDown")&&(L.preventDefault(),En(1)))},[En]),ws=f.useRef(null);f.useEffect(()=>{if(!H)return;const L=ws.current;if(!(!L||L.offsetWidth===0))for(const te of[1,-1]){const Ne=ri(Xe+te);Ne&&Jr(Ne)}},[H,Xe,ri]);const Ss=f.useMemo(()=>{var Ms;if(!H)return null;if(Xe===Rn)return H;const L=Bt.get(Xe);if(L&&L.width>0&&L.height>0)return{page_id:`p:${Xe}`,title:`第${Xe}葉`,image_size:[L.width,L.height],total_warped_w:L.width,columns:[{col:1,warped_w:L.width,warped_h:L.height,offset_x:0,strips:[],chars:L.columns.flatMap(rt=>rt.chars).map(rt=>({id:rt.id,char:rt.char,slot:rt.slot,pos:rt.pos,sub:rt.sub,bbox_col:rt.bbox??[0,0,0,0]}))}]};const te=(Ms=H.pages)==null?void 0:Ms.find(rt=>rt.page===Xe),[Ne,Je]=H.image_size||[2386,3082];if(!(Ne>0&&Je>0))return null;const qe=ii(Xe),Nt=(qe==null?void 0:qe.width)??Ne,mr=(qe==null?void 0:qe.height)??Je,Es=Nt/Ne,Ls=mr/Je,As=new Map;for(const rt of H.columns){const vt=(rt.strips||[]).flatMap(pi=>pi.srcQuad.map(ui=>ui[0]));if(vt.length===0)continue;const Wt=rt.top_y??0,hr=rt.bottom_y??Wt+rt.warped_h;As.set(rt.col,{x0:Math.min(...vt),x1:Math.max(...vt),top:Wt,slotH:(hr-Wt)/21})}return{page_id:`p:${Xe}`,title:`第${Xe}葉`,image_size:[Nt,mr],total_warped_w:Nt,columns:te?te.columns.map(rt=>{const vt=As.get(rt.col)??{x0:0,x1:0,top:0,slotH:118};return{col:rt.col,warped_w:Nt,warped_h:mr,offset_x:0,strips:[],chars:rt.chars.map(Wt=>{const hr=Wt.slot??Wt.pos??0,pi=(vt.top+(hr-1)*vt.slotH)*Ls,ui=(vt.x0+vt.x1)/2,[mu,hu]=Wt.sub==="a"?[ui,vt.x1]:Wt.sub==="b"?[vt.x0,ui]:[vt.x0,vt.x1];return{...Wt,bbox_col:[mu*Es,pi,hu*Es,pi+vt.slotH*Ls]}})}}):[]}},[H,Xe,Rn,Bt,ii]),{entryTitle:ai,authors:_s}=Ux(n,i,c===void 0),[$s,cr]=f.useState("text");f.useEffect(()=>{cr("text")},[D,I]);const iu=f.useMemo(()=>ke?Wx(ke,se,Ha(q,ke),R,Qe,ir):[],[ke,se,q,R,Qe,ir]);if(ae==="loading")return t.jsx(Wa,{className:z,style:C,title:c??ai,label:_("reader.loading")});if(ae==="missing"||!A||!q)return t.jsx("div",{className:z,style:{...C,...Oa},children:_("reader.noText")});if(ue==="failed")return t.jsx("div",{className:z,style:{...C,...Oa},children:_("reader.tocFailed")});if(!ke)return t.jsx(Wa,{className:z,style:C,title:c??ai,label:_("reader.tocLoading")});const hn=Ha(q,ke),ru=iu,Cs=Ve&&D&&Ve.chapter===D?ns(D,Ve.anchor):null,ou=Cs&&le&&ir(le).some(L=>L.anchor===Ve.anchor)?Cs:D??null,dr=A.versions.map(L=>({key:L.key,label:ze.textVersionLabel(L),optionLabel:R(ze.textVersionLabel(L)),sourceName:Da(L)?_("reader.originalSource"):L.source_name?R(L.source_name):void 0,license:L.license??void 0,sourceUrl:L.source_url??void 0,primary:L.key===je})),jt=Bx((Rs=ke.source)==null?void 0:Rs.upstream),li=(typeof c=="string"?R(c):c)??(ke.title?R(ke.title):ai?R(ai):void 0),zs=q.edition_label?R(q.edition_label):void 0,pr=li?t.jsx("a",{href:W(n),title:_("reader.viewEntry"),onClick:l?L=>{L.metaKey||L.ctrlKey||(L.preventDefault(),l(n))}:void 0,children:li}):void 0,su=pr&&zs?t.jsxs(t.Fragment,{children:[pr,t.jsxs("span",{className:"bim-rd-ed",children:["·",zs]})]}):pr,au=_s.length>0?R(_s.slice(0,2).map(L=>`${L.dynasty?`〔${L.dynasty}〕`:""}${L.name}${` ${L.role||_("reader.defaultRole")}`}`).join("、")):void 0,ur=le?wd(le,hn,R,Qe):void 0,rn=Qe&&!!(pe!=null&&pe.json),on=(pe==null?void 0:pe.json)??null,fn=(pe==null?void 0:pe.md)??null,Ns=rn&&!X&&pd(on.sections),lu=Ns&&!(fn&&Q.readingMode==="paragraph"&&zi(fn)),cu=rn&&Ns?t.jsx(Xg,{juan:on,view:$s,onView:cr,textHasEntries:lu}):void 0,du=!0,ci=fn?fn.replace(/^##\s+[^\n]+\n+/,""):null,di=Da(q),Kt=di?_("reader.originalSource"):q.source_name?R(q.source_name):void 0,pu=(typeof p=="string"?R(p):p)??(di?void 0:Kt??R(ze.textVersionLabel(q))),uu=(H==null?void 0:H.hasNorm)===!0;return t.jsxs($c,{className:z,style:C,title:su,subtitle:pu,byline:au,current:ur,pagerUnit:hn,rail:cu,revisedAt:j,backHref:y,backLabel:S,onReportError:x?L=>x({...L,bookTitle:typeof li=="string"?li:void 0,entryId:n}):void 0,workLinkToggle:rn&&!X&&!!l&&!!(on!=null&&on.sections.some(L=>L.work_id)),toc:ru,tocCaption:_("reader.tocCaption",{n:ke.chapters.length,unit:R(hn)}),tocHeader:Qe&&ke.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:X?_("reader.searchChaptersPlaceholder"):_("reader.searchUnitPlaceholder",{unit:R(hn)}),"aria-label":X?_("reader.searchChapters"):_("reader.searchUnit",{unit:R(hn)}),value:$,onChange:L=>M(L.target.value)}):void 0,activeKey:D??null,tocActiveKey:ou,onSelect:Ie,images:eo(le)&&fe&&!H?null:Y.images,renderImageOverlay:m,imagePanel:H?"open":u,isWarpMode:!!H,customImagePanel:H&&Ss?t.jsxs("div",{ref:ws,className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:nu,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:[ge.size>0&&t.jsxs("button",{type:"button",onClick:()=>Oe(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${r("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",ge.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:et<=1,onClick:()=>{var L;return(L=Ke.current)==null?void 0:L.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(et*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:et>=6,onClick:()=>{var L;return(L=Ke.current)==null?void 0:L.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:et===1,onClick:()=>{var L;return(L=Ke.current)==null?void 0:L.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(Ix,{ref:Ke,resetKey:Xe,onScaleChange:yt,style:{flex:1,minHeight:0},children:t.jsx(za,{store:Se,children:L=>t.jsx(Xo,{imageUrl:Qp,pageData:Ss,selectedCharIds:ge,hoveredCharId:L,preserveMargins:lt,renderScale:et,onCharClick:te=>{Oe(Je=>{const qe=new Set(Je);return qe.has(te)?qe.delete(te):(qe.clear(),qe.add(te)),qe});const Ne=document.querySelector(`[data-char-id="${te}"]`);Ne&&Ne.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:Se.set})})}),t.jsxs("div",{"data-testid":"facsimile-pager",role:"group","aria-label":_("reader.facsimilePager"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,padding:"6px 4px 0",fontSize:13,color:r("meta-fg")},children:[t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-prev","aria-label":"上一葉",style:{minWidth:40,minHeight:40,fontSize:20,lineHeight:1},disabled:lr<=0,onClick:()=>En(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":Xe,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":_("reader.facsimilePageInput"),size:Math.max(2,String(sr??Xe).length),value:sr??String(Xe),onFocus:L=>L.currentTarget.select(),onChange:L=>tu(L.target.value),onKeyDown:L=>{L.key==="Enter"?(L.preventDefault(),ks()):L.key==="Escape"&&(si.current=null,ar(null)),L.stopPropagation()},onBlur:ks,style:{width:`${Math.max(2,String(sr??Xe).length)+1}ch`,minHeight:28,textAlign:"center",font:"inherit",border:`1px solid ${r("rule")}`,borderRadius:4,background:"transparent",color:"inherit"}}),"葉"]}),t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-next","aria-label":"下一葉",style:{minWidth:40,minHeight:40,fontSize:20,lineHeight:1},disabled:lr<0||lr>=Ot.length-1,onClick:()=>En(1),children:"›"})]})]}):void 0,settingsAnnotate:H?t.jsx("button",{type:"button",className:`bim-rd-t bim-rd-sp-tg ${De?"bim-rd-on":""}`,"aria-pressed":De,title:"切换外挂现代断句标点",onClick:()=>pt(L=>!L),children:De?"标点":"无标点"}):void 0,prefs:Q,onPrefsChange:E,versions:dr.length>1?dr:void 0,currentVersionKey:dr.length>1?q.key:void 0,onVersionChange:J,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:zi(fn),allowVertical:g,origScriptAvailable:uu,contentLoading:Ye,children:[(Ye||fe&&!H&&!rn&&ci==null)&&t.jsx(un,{}),!Ye&&H&&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:le!=null&&le.title?R(le.title):ur}),(Kt||q.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[Kt,q.license&&t.jsxs(t.Fragment,{children:[Kt&&t.jsx("span",{className:"bim-rd-dot"}),q.license]})]})]}),t.jsx(za,{store:Se,children:L=>t.jsx(es,{pageData:H,pages:H.pages,punctuations:H.punctuations||Px,selectedCharIds:ge,hoveredCharId:L,onSelectionChange:Jp,onCharClick:te=>{Oe(Je=>{const qe=new Set(Je);return qe.has(te)?qe.delete(te):(qe.clear(),qe.add(te)),qe});const Ne=parseInt(te.split(":")[0],10);isNaN(Ne)||$t(Ne)},onCharHover:Se.set,mode:"horizontal",showPunctuation:De,entities:Ee,entityTransport:i,onEntityNavigate:k,onVisiblePageChange:eu,convert:R,scrollToPage:K,scrollToAnchor:we&&we.chapter===D&&nr?we:null,onVisibleHeadingChange:te=>Ze(te&&D?{chapter:D,anchor:te}:null),pageBreaks:Q.pageBreaks,pageIndicatorY:Q.pageIndicatorY,onPageIndicatorYChange:te=>E({pageIndicatorY:te}),quoteStyle:Q.quoteStyle,bookTitleStyle:Q.bookTitleStyle,showWorks:Q.showWorks})})]}),!Ye&&!H&&rn&&on&&t.jsx(qg,{juan:on,rawText:fn,positionLabel:Hx(le,ke,hn,R),groupLabel:Dx(ke,D??null),index:Ox(n,ke),searchQuery:$,onNavigate:l,transport:i,workLabelCache:We,prefs:Q,view:$s,onViewChange:cr},`${I}/${D}`),!Ye&&!H&&!rn&&ci!=null&&le&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:le.title?R(le.title):ur}),(Kt||q.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[di&&Kt&&t.jsx(t.Fragment,{children:Kt}),!di&&q.source_name&&t.jsxs(t.Fragment,{children:[_("reader.textSource")," ",q.source_url?t.jsx("a",{className:"bim-rd-link",href:q.source_url,target:"_blank",rel:"noreferrer",children:R(q.source_name)}):R(q.source_name)]}),Kt&&q.license&&t.jsx("span",{className:"bim-rd-dot"}),q.license]}),jt&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[_("reader.upstream")," ",jt.url?t.jsx("a",{className:"bim-rd-link",href:jt.url,target:"_blank",rel:"noreferrer",children:R(jt.name??jt.url)}):R(jt.name??""),jt.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),jt.license_url?t.jsx("a",{className:"bim-rd-link",href:jt.license_url,target:"_blank",rel:"noreferrer",children:jt.license}):jt.license]}),jt.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(fc,{text:jt.note,convert:R})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(Ho,{text:ci,mode:Q.readingMode,tables:du,gujiMarkdown:!0,bookMarking:Fo(Q),quoteStyle:Q.quoteStyle})})]}),!Ye&&!fe&&!H&&!rn&&ci==null&&le&&t.jsx("div",{className:"bim-rd-state",children:_("reader.chapterFailed")}),!Ye&&ke.references&&ke.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:_("reader.references")}),t.jsx("ol",{children:ke.references.map((L,te)=>t.jsxs("li",{children:[L.url?t.jsx("a",{className:"bim-rd-link",href:L.url,target:"_blank",rel:"noopener noreferrer",children:R(L.title)}):t.jsx("span",{children:R(L.title)}),L.author&&t.jsxs("span",{children:[",",R(L.author)]}),L.note&&t.jsxs("span",{children:["。",R(L.note)]})]},te))})]})]})};function Da(e){return e.is_original===!0||e.source==="original"}function Hx(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 Dx(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 Ux(e,n,i){const[o,s]=f.useState({entryTitle:void 0,authors:[]});return f.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let a=!1;return Promise.resolve(n.getItem(e)).then(l=>{if(a||!l)return;const d=(l.authors??[]).filter(c=>c&&c.name);s({entryTitle:i&&typeof l.title=="string"?l.title:void 0,authors:d})}).catch(()=>{}),()=>{a=!0}},[e,n,i]),o}const _d={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")}},Vx=_d.other,$d={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")}},Gx=$d.pending;function Yx(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 qx(e,n){if(!e)return!1;try{const i=new URL(e,n);if(i.protocol!=="http:"&&i.protocol!=="https:")return!1;const o=new URL(n);return i.hostname===o.hostname}catch{return!1}}const rs=({items:e,loading:n})=>{const i=at(),{t:o,convert:s}=re();return n?t.jsx(un,{}):e.length===0?t.jsx("div",{style:Kx,children:o("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=_d[a.type]||Vx,d=$d[a.status]||Gx,c=typeof window<"u"&&qx(a.pageUrl,window.location.href);return t.jsxs("div",{style:Xx,children:[t.jsxs("div",{style:Zx,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...Ua,background:l.color},children:o(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...Ua,background:d.color},children:o(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:Jx,children:Yx(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:Qx,children:[a.resourceId&&t.jsx("a",{href:i(a.resourceId),style:Cr,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:Cr,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:Cr,children:a.pageUrl}))]}),t.jsx("div",{style:eb,children:s(a.content)}),a.reply&&t.jsxs("div",{style:tb,children:[t.jsx("div",{style:nb,children:o("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},Kx={textAlign:"center",padding:"40px 0",color:r("desc-fg"),fontSize:"14px"},Xx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"16px"},Zx={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},Ua={fontSize:"12px",color:r("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},Jx={fontSize:"12px",color:r("desc-fg")},Qx={fontSize:"12px",marginBottom:"6px"},Cr={color:r("primary"),textDecoration:"none",borderBottom:`1px dashed ${r("primary")}`},eb={fontSize:"14px",lineHeight:"1.6",color:r("fg"),whiteSpace:"pre-wrap"},tb={marginTop:"12px",padding:"10px 12px",background:r("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:r("fg")},nb={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:r("primary")},to=({transport:e,onNavigate:n,recommendedIds:i,activeTab:o,onTabChange:s,feedbackApiUrl:a})=>{const l=Ae(),[d,c]=f.useState(null),[p,h]=f.useState([]),[m,u]=f.useState("recommend"),[g,x]=f.useState([]),[j,y]=f.useState(!1),S=o??m,b=A=>{u(A),s==null||s(A)},[w,v]=f.useState(!0),[k,z]=f.useState(null),[C,_]=f.useState(null),[R,T]=f.useState(null);f.useEffect(()=>{let A=!1;if(e.getCounts)return e.getCounts().then(V=>{A||c({works:V.works,books:V.books,collections:V.collections})}).catch(()=>{}),()=>{A=!0}},[e]),f.useEffect(()=>{let A=!1;return(async()=>{if(i)return i;if(e.getRecommended)try{const ae=await e.getRecommended();if(ae!=null&&ae.groups)return ae.groups.flatMap(xe=>xe.items.map(me=>({...me,group:xe.name})))}catch{}return[]})().then(async ae=>{if(A)return;const xe=ae.filter(G=>G.id);if(xe.length===0){v(!1);return}const me=await Promise.all(xe.map(async G=>{if(G.type)return{id:G.id,title:G.title,type:G.type,author:G.author,dynasty:G.dynasty,role:G.role,edition:G.edition,has_text:G.has_text,has_image:G.has_image,has_collated:G.has_collated,subtype:G.subtype,primary_name:G.primary_name,group:G.group,fallbackDescription:G.description};try{let ye=null;if(e.getEntry)ye=await e.getEntry(G.id);else{const ne=await e.getItem(G.id);ne&&(ye={id:G.id,title:ne.title||G.id,type:ne.type||"work"})}if(ye)return{...ye,group:G.group,fallbackDescription:G.description}}catch{}return{id:G.id,title:G.title,type:ze.extractType(G.id),group:G.group,fallbackDescription:G.description}}));A||(h(me.filter(G=>G!==null)),v(!1))}),()=>{A=!0}},[e,i]);const N=f.useRef(!1),E=f.useRef(!1),W=f.useRef(!1);f.useEffect(()=>{if(S!=="catalog"||N.current)return;const A=e.getCatalogProgress??e.getResourceProgress;if(!A)return;N.current=!0;let V=!1;return A.call(e).then(ae=>{V||z(ae)}).catch(()=>{N.current=!1}),()=>{V=!0}},[e,S]),f.useEffect(()=>{if(S!=="collection"||E.current||!e.getCollectionProgress)return;E.current=!0;let A=!1;return e.getCollectionProgress().then(V=>{A||_(V)}).catch(()=>{E.current=!1}),()=>{A=!0}},[e,S]),f.useEffect(()=>{if(S!=="site"||W.current||!e.getSiteProgress)return;W.current=!0;let A=!1;return e.getSiteProgress().then(V=>{A||T(V)}).catch(()=>{W.current=!1}),()=>{A=!0}},[e,S]),f.useEffect(()=>{if(!a||S!=="feedback")return;let A=!1;return y(!0),fetch(a).then(V=>V.json()).then(V=>{!A&&V.success&&x(V.items||[])}).catch(()=>{}).finally(()=>{A||y(!1)}),()=>{A=!0}},[a,S]);const F=A=>t.jsx(Tn,{type:A,size:12});return t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:r("fg")},children:t.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[t.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${r("widget-border")}`,marginBottom:"16px"},children:[t.jsx(Bn,{label:l.home.recommendTab,active:S==="recommend",onClick:()=>b("recommend")}),t.jsx(Bn,{label:l.home.catalogTab,active:S==="catalog",onClick:()=>b("catalog")}),t.jsx(Bn,{label:l.home.collectionTab,active:S==="collection",onClick:()=>b("collection")}),t.jsx(Bn,{label:l.home.siteTab,active:S==="site",onClick:()=>b("site")}),a&&t.jsx(Bn,{label:l.home.feedbackTab,active:S==="feedback",onClick:()=>b("feedback")})]}),S==="recommend"&&t.jsx(ib,{recommended:p,loading:w,onNavigate:n,getIcon:F,t:l}),S==="catalog"&&t.jsx(Va,{progress:k,t:l,onNavigate:n}),S==="collection"&&t.jsx(Va,{progress:C,t:l,onNavigate:n}),S==="site"&&t.jsx(ob,{progress:R,t:l,totalWorks:(d==null?void 0:d.works)??0}),S==="feedback"&&a&&t.jsx(rs,{items:g,loading:j})]})})},Bn=({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}),ib=({recommended:e,loading:n,onNavigate:i,getIcon:o,t:s})=>{const a=at();if(n)return t.jsx(un,{});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:m=>{m.metaKey||m.ctrlKey||(m.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))})},Va=({progress:e,t:n,onNavigate:i})=>{if(!e)return t.jsx(un,{});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(rb,{item:p,t:n,statusColor:l[d],onNavigate:i},p.id))})]},d)})})},rb=({item:e,t:n,statusColor:i,onNavigate:o})=>{const s=at(),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?wt(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})]})},ob=({progress:e,t:n,totalWorks:i})=>{if(!e)return t.jsx(un,{});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(Ga,{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(Ga,{item:c,t:n,totalWorks:i},c.id))})]})]})},Ga=({item:e,t:n,totalWorks:i})=>{const o=i>0?Math.round(e.imported/i*100):0;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:t.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:e.url?t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:e.name}):e.name})}),t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.imported>0?`${e.imported.toLocaleString()} ${n.indexType.work} (${o}%)`:n.home.statusTodo})]}),e.imported>0&&i>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:r("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${o}%`,borderRadius:"2px",background:r("progress-done"),transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"4px"},children:e.description})]})},Ya="(max-width: 768px)";function sb(){const[e,n]=f.useState(()=>typeof window>"u"?!1:window.matchMedia(Ya).matches);return f.useEffect(()=>{const i=window.matchMedia(Ya),o=s=>n(s.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),e}const ab=({transport:e,hideModeIndicator:n=!0,onEntryClick:i,recommendedIds:o,headerRight:s})=>{var E;const a=Ae(),{convert:l}=Ue(),d=sb(),[c,p]=f.useState(null),[h,m]=f.useState(null),[u,g]=f.useState(!1),[x,j]=f.useState("detail"),[y,S]=f.useState([]),[b,w]=f.useState(!1),v=f.useCallback(async W=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){S([]);return}w(!0);try{if(e.getCollectionCatalogs){const F=await e.getCollectionCatalogs(W);S(F||[])}else if(e.getCollectionCatalog){const F=await e.getCollectionCatalog(W);S(F?[{resource_id:"",data:F}]:[])}}catch{S([])}finally{w(!1)}},[e]),k=f.useCallback(async W=>{if(i){i(W);return}p(W),m(null),S([]),j("detail"),g(!0);try{const F=await e.getItem(W.id);F&&(m(F),F.type==="collection"&&v(W.id))}catch(F){console.error("加载详情失败:",F)}finally{g(!1)}},[e,i,v]),z=f.useCallback(async W=>{m(null),S([]),j("detail"),g(!0);try{const F=await e.getItem(W);F&&(m(F),p({id:W,title:F.title||W,type:F.type||"book"}),F.type==="collection"&&v(W))}catch(F){console.error("导航失败:",F)}finally{g(!1)}},[e,v]),C=typeof(h==null?void 0:h.text_count)=="number"&&h.text_count>0,_=(h==null?void 0:h.type)==="collection"&&(y.length>0||b)||(h==null?void 0:h.type)==="work"&&C,R=d&&(u||h),T=f.useCallback(()=>{p(null),m(null),S([]),j("detail")},[]),N=t.jsx(t.Fragment,{children:u?t.jsx(un,{}):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:()=>j("detail"),style:xi(x==="detail"),children:a.detailTab.basicInfo}),h.type==="collection"&&b&&y.length===0&&t.jsxs("button",{onClick:()=>{},style:xi(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),h.type==="collection"&&y.map(W=>t.jsx("button",{onClick:()=>j(`catalog:${W.resource_id}`),style:xi(x===`catalog:${W.resource_id}`),children:W.short_name?`${l(W.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},W.resource_id)),h.type==="work"&&C&&t.jsx("button",{onClick:()=>j("collated"),style:xi(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(zo,{data:h,transport:e,onNavigate:z}):x.startsWith("catalog:")?t.jsx(No,{data:(E=y.find(W=>`catalog:${W.resource_id}`===x))==null?void 0:E.data,onNavigate:z}):x==="collated"?t.jsx(is,{id:h.id,transport:e,onNavigate:z}):null})]}):t.jsx(to,{transport:e,onNavigate:z,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:R?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:N})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(Wr,{transport:e,onEntryClick:k,hideModeIndicator:n}),!h&&t.jsx(to,{transport:e,onNavigate:z,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(Wr,{transport:e,onEntryClick:k,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:r("bg"),display:"flex",flexDirection:"column"},children:N})]})};function xi(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 lb=({pageData:e,rawImageUrl:n="",punctuations:i=[],title:o,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=f.useState(new Set),[h,m]=f.useState(null),[u,g]=f.useState("horizontal"),[x,j]=f.useState(!0),y=f.useRef(null),S=f.useCallback(k=>{p(new Set(k))},[]),b=f.useCallback(k=>{if(p(z=>{const C=new Set(z);return C.has(k)?C.delete(k):(C.clear(),C.add(k)),C}),y.current){const z=y.current.querySelector(`[data-char-id="${k}"]`);z&&z.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),w=()=>{var k;p(new Set),window.getSelection&&((k=window.getSelection())==null||k.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:()=>j(k=>!k),className:`guji-reader-btn ${x?"active":""}`,title:"独立外挂标点 (guji-punct v0.1)",children:x?"✓ 标点":"底本文本"}),t.jsx("button",{type:"button",onClick:()=>g(k=>k==="horizontal"?"vertical":"horizontal"),className:"guji-reader-btn primary",children:u==="horizontal"?"切换竖排":"切换横排"})]})]}),t.jsxs("div",{className:"guji-reader-body",children:[t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%",position:"sticky",top:0},children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:"底本书影 (WebGL 分带透视矫正 + 完整版心)"}),t.jsx("span",{className:"guji-pane-hint",children:"点击字框可联动文本定位"})]}),t.jsx("div",{className:"guji-pane-content",children:t.jsx(Xo,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:h,onCharClick:b,onCharHover:m})})]}),t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%"},ref:y,children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:u==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(es,{pageData:e,punctuations:v,selectedCharIds:c,hoveredCharId:h,onSelectionChange:S,onCharClick:b,onCharHover:m,mode:u,showPunctuation:x})]})]})]})},cb=e=>typeof e=="string"&&Array.from(e).length===1,db=new Set(["point","break","heading"]),pb=/^#{1,6}$/;function ub(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.punctuations)?e.punctuations:[],i=[];for(const o of n){if(!o||typeof o!="object")continue;const s=o;if(typeof s.anchor!="string"||typeof s.mark!="string"||s.pre_char!=null&&!cb(s.pre_char)||s.kind!=null&&!db.has(s.kind)||s.pos!=null&&s.pos!=="after"&&s.pos!=="before")continue;const a={id:typeof s.id=="string"?s.id:void 0,anchor:s.anchor,mark:s.mark,kind:s.kind,pos:s.pos,pre_char:s.pre_char??void 0};if(!(s.kind==="break"&&s.pos==="before")){if(s.kind==="heading"){if(s.pos!=="before"||!pb.test(s.mark))continue;typeof s.label=="string"&&s.label.trim()&&(a.label=s.label.trim()),s.toc===!1&&(a.toc=!1)}i.push(a)}}return i}function mb(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 Cd=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function mt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}const hb=new Set(["main","solo","jz_r","jz_l"]),fb=new Set(["body","banxin","blank"]);function gb(e){const n={};return typeof e.lane=="string"&&hb.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 xb(e){const n={};typeof e.kind=="string"&&fb.has(e.kind)&&e.kind!=="body"&&(n.kind=e.kind);const i=mt(e.raised);i!==void 0&&Number.isInteger(i)&&i>0&&(n.raised=i);const o=mt(e.lead_blank);return o!==void 0&&Number.isInteger(o)&&o>0&&(n.lead_blank=o),n}function zr(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(i=>!!i&&typeof i=="object"):[]}function bb(e){return typeof e=="string"&&Array.from(e).length===1}function zd(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"||!Cd.test(a)){i.badAnchor++;continue}if(!bb(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 zd(e).map}function yb(e,n,i){var h,m,u,g,x,j,y,S,b,w;const o=i==null?null:Nd(i),s=new Map,a=new Map;for(const v of zr(n)){const k=mt(v.page);if(k!==void 0){s.set(k,v);for(const z of Array.isArray(v.cells)?v.cells:[]){const C=z==null?void 0:z.box;typeof(z==null?void 0:z.a)=="string"&&Array.isArray(C)&&C.length===4&&C.every(_=>mt(_)!==void 0)&&a.set(z.a,[C[0],C[1],C[0]+C[2],C[1]+C[3]])}}}const l=[],d=new Map,c=new Map;for(const v of zr(e)){const k=mt(v.page);k!==void 0&&typeof v.label=="string"&&v.label&&d.set(k,v.label)}for(const v of zr(e)){const k=mt(v.page);if(k===void 0)continue;const z=[];for(const _ of Array.isArray(v.columns)?v.columns:[]){const R=mt(_==null?void 0:_.col);if(R===void 0)continue;const T=[];for(const E of Array.isArray(_.cells)?_.cells:[]){const W=Cd.exec(String((E==null?void 0:E.a)??""));if(!W||typeof E.c!="string")continue;const F=parseInt(W[3],10),A=o==null?void 0:o.get(E.a);T.push({id:E.a,char:E.c,slot:F,pos:F,sub:W[4]||null,bbox:a.get(E.a)??null,...gb(E),...A!==void 0&&A!==E.c?{norm:A}:{}})}const N=xb(_);(T.length>0||N.kind==="blank")&&z.push({col:R,chars:T,...N})}if(!z.some(_=>_.chars.length>0)){z.length>0&&c.set(k,z);continue}z.sort((_,R)=>_.col-R.col);const C=s.get(k);l.push({page:k,seq:String(((h=C==null?void 0:C.canvas)==null?void 0:h.seq)??""),width:mt((m=C==null?void 0:C.canvas)==null?void 0:m.width)??mt((u=C==null?void 0:C.image)==null?void 0:u.width)??0,height:mt((g=C==null?void 0:C.canvas)==null?void 0:g.height)??mt((x=C==null?void 0:C.image)==null?void 0:x.height)??0,...typeof v.label=="string"&&v.label?{label:v.label}:{},columns:z})}const p=new Set(l.map(v=>v.page));for(const[v,k]of s){const z=(j=k==null?void 0:k.canvas)==null?void 0:j.seq;p.has(v)||typeof z!="string"&&typeof z!="number"||String(z)===""||l.push({page:v,seq:String(z),width:mt((y=k.canvas)==null?void 0:y.width)??mt((S=k.image)==null?void 0:S.width)??0,height:mt((b=k.canvas)==null?void 0:b.height)??mt((w=k.image)==null?void 0:w.height)??0,...d.has(v)?{label:d.get(v)}:{},columns:c.get(v)??[]})}return l.sort((v,k)=>v.page-k.page)}const jb=({data:e,onNavigate:n,className:i,style:o})=>{var h;const{t:s,convert:a}=re(),[l,d]=f.useState(((h=e.divisions[0])==null?void 0:h.name)??null),[c,p]=f.useState(null);return t.jsxs("div",{className:i,style:o,children:[t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:r("fg"),margin:"0 0 8px"},children:a(e.title)}),e.stats&&t.jsxs("div",{style:{fontSize:"13px",color:r("desc-fg"),display:"flex",gap:"16px"},children:[e.total_volumes!=null&&t.jsxs("span",{children:[s("catalog.totalVolumes")," ",t.jsx("strong",{children:e.total_volumes})," ",s("unit.juan")]}),e.stats.zhulu!=null&&t.jsxs("span",{children:[s("catalogPage.zhulu")," ",t.jsx("strong",{children:e.stats.zhulu})," ",s("unit.bu")]}),e.stats.cunmu!=null&&t.jsxs("span",{children:[s("catalogPage.cunmu")," ",t.jsx("strong",{children:e.stats.cunmu})," ",s("unit.bu")]}),e.stats.categories!=null&&t.jsx("span",{children:s("catalogPage.categoriesN",{n:e.stats.categories})})]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.divisions.map(m=>t.jsx(vb,{division:m,expanded:l===m.name,onToggle:()=>d(l===m.name?null:m.name),expandedCat:c,onCatToggle:u=>p(c===u?null:u),onNavigate:n},m.name))})]})},vb=({division:e,expanded:n,onToggle:i,expandedCat:o,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=re(),c=e.categories.reduce((p,h)=>{const m=h.stats||{zhulu:0,cunmu:0};return p+(m.zhulu||0)+(m.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(kb,{category:p,expanded:o===h,onToggle:()=>s(h),onNavigate:a},p.name)})})]})},kb=({category:e,expanded:n,onToggle:i,onNavigate:o})=>{var p,h,m,u;const{t:s,convert:a}=re(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((h=e.books)==null?void 0:h.cunmu)||[],c=(((m=e.stats)==null?void 0:m.zhulu)||l.length)+(((u=e.stats)==null?void 0:u.cunmu)||d.length);return t.jsxs("div",{children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px 6px 28px",border:"none",background:n?r("input-bg"):"transparent",cursor:"pointer",fontSize:"13px",color:r("fg"),textAlign:"left"},children:[t.jsxs("span",{style:{fontWeight:500},children:[a(e.name),e.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:a(e.volumes)})})]}),t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[s("catalogPage.booksN",{n:c})," ",n?"▲":"▼"]})]}),n&&(l.length>0||d.length>0)&&t.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[l.length>0&&t.jsx(qa,{label:s("catalogPage.zhulu"),books:l,onNavigate:o}),d.length>0&&t.jsx(qa,{label:s("catalogPage.cunmu"),books:d,onNavigate:o})]})]})},qa=({label:e,books:n,onNavigate:i})=>{const{t:o,convert:s}=re(),a=at(),[l,d]=f.useState(n.length<=20),c=l?n:n.slice(0,10);return t.jsxs("div",{style:{marginBottom:"8px"},children:[t.jsxs("div",{style:{fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},children:[e," (",n.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((p,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:m=>{m.metaKey||m.ctrlKey||(m.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})})]})},Tt=({title:e,onSave:n,onAskAI:i,extraButtons:o,children:s})=>{const a=Ae();return t.jsxs("div",{style:{background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",paddingBottom:"8px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:r("fg")},children:e}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[o,i&&t.jsx("button",{onClick:i,style:Sb,children:"AI"}),n&&t.jsx("button",{onClick:n,style:wb,children:a.action.save})]})]}),s]})},wb={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Sb={padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},kt=({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"}})]}),pn=({value:e,onChange:n,placeholder:i})=>{const o=f.useRef(null);return f.useEffect(()=>{o.current&&(o.current.style.height="auto",o.current.style.height=`${o.current.scrollHeight}px`)},[e]),t.jsx("textarea",{ref:o,value:e||"",onChange:s=>n(s.target.value),placeholder:i,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},Ti=({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 _b(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const wi=({value:e,onChange:n,label:i})=>{const[o,s]=f.useState(!1),a=f.useRef(null),l=_b(e||"");return f.useEffect(()=>{o&&a.current&&a.current.focus()},[o]),!o&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Ka,children:i}),t.jsxs("div",{onClick:()=>s(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:`1px solid ${r("input-border")}`,borderRadius:"2px",background:r("input-bg"),cursor:"pointer",minHeight:"30px"},children:[t.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:r("fg")},children:l.name}),t.jsx(Ti,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Ka,children:i}),t.jsx("input",{ref:a,type:"text",value:e||"",onChange:d=>n(d.target.value),onBlur:()=>s(!1),style:{width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},Ka={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500};function $b(e){switch(e){case"url":return r("source-url");case"bookID":return r("source-bookid");default:return r("desc-fg")}}function Cb(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const Td=({items:e,onChange:n,onOpenEntityPicker:i})=>{const o=Ae(),[s,a]=f.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=m=>{n(e.filter((u,g)=>g!==m)),s===m&&a(null)},c=(m,u,g)=>{const x=[...e];x[m]={...x[m],[u]:g},n(x)},p=(m,u)=>{const g=[...e];g[m]={...g[m],type:u,id:"",name:""},n(g),u==="bookID"&&i&&i(x=>{const j=[...e];j[m]={...j[m],id:x.id,name:x.title,type:"bookID"},n(j)})},h=m=>{i&&i(u=>{const g=[...e];g[m]={...g[m],id:u.id,name:u.title,type:"bookID"},n(g)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((m,u)=>t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>a(s===u?null:u),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===u?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:r("fg")},children:m.name||`${o.editor.sourcePlaceholder} ${u+1}`}),m.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:$b(m.type),color:r("on-color-fg"),borderRadius:"3px",fontWeight:500},children:Cb(m.type)}),t.jsx("button",{onClick:g=>{g.stopPropagation(),d(u)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:o.editor.deleteThisSource,children:"✕"})]}),s===u&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!m.type&&t.jsxs("div",{children:[t.jsx("label",{style:Ft,children:o.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(u,"bookID"),style:{...Xa,borderColor:r("source-bookid"),color:r("source-bookid")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"📚"}),t.jsx("span",{children:"Book ID"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.fromExistingBook})]}),t.jsxs("button",{onClick:()=>p(u,"url"),style:{...Xa,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})]})]})]}),m.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:Ft,children:o.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const g=[...e];g[u]={...g[u],type:"",id:"",name:""},n(g)},style:Za,children:o.action.changeType})]}),m.id&&m.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:m.name}),t.jsx("code",{style:{fontSize:"11px",background:r("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:m.id})]}),t.jsx("button",{onClick:()=>h(u),style:{background:"transparent",border:`1px solid ${r("widget-border")}`,color:r("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:o.action.reselect})]}):t.jsxs("button",{onClick:()=>h(u),style:{width:"100%",padding:"14px",border:`2px dashed ${r("widget-border")}`,borderRadius:"6px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[t.jsx("span",{children:"🔍"}),t.jsx("span",{children:o.action.clickToSelectBookOrWork})]})]})}),m.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:Ft,children:o.label.sourceName}),t.jsx("button",{onClick:()=>{const g=[...e];g[u]={...g[u],type:"",id:"",name:""},n(g)},style:Za,children:o.action.changeType})]}),t.jsx("input",{type:"text",value:m.name,onChange:g=>c(u,"name",g.target.value),placeholder:o.editor.sourceNamePlaceholder,style:bn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ft,children:o.label.urlAddress}),t.jsx("input",{type:"text",value:m.id,onChange:g=>c(u,"id",g.target.value),placeholder:"https://...",style:bn})]})]}),m.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:{...Ft,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:Ft,children:o.label.detailsOptional}),t.jsx("input",{type:"text",value:m.details,onChange:g=>c(u,"details",g.target.value),placeholder:o.editor.detailsPlaceholder,style:bn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ft,children:o.label.positionOptional}),t.jsx("input",{type:"text",value:m.position,onChange:g=>c(u,"position",g.target.value),placeholder:"如: 卷三, p.52",style:bn})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Ft,children:o.label.dataVersionOptional}),t.jsx("input",{type:"text",value:m.version,onChange:g=>c(u,"version",g.target.value),placeholder:"如: v1.0, 2024-01",style:bn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Ft,children:o.label.processorVersionOptional}),t.jsx("input",{type:"text",value:m.processor_version,onChange:g=>c(u,"processor_version",g.target.value),placeholder:"如: v0.1",style:bn})]})]})]})]})})]},u)),t.jsxs("button",{onClick:l,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:o.action.addSource})]})]})},Ft={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},bn={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"},Xa={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"},Za={background:"transparent",border:"none",color:r("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function Id(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 Rd(e){return!e||e.length===0?"":JSON.stringify(e)}const Ed=({entityType:e,entityId:n,entityTitle:i,parentWork:o,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:h,onLinkEntity:m,onUnlinkEntity:u,onViewEntity:g,onCreateAndLink:x,onSaveRelations:j})=>{const y=Ae();return t.jsxs("div",{style:{background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:"🔗"}),t.jsx("span",{children:y.section.relations})]}),j&&t.jsx("button",{onClick:j,style:zb,children:y.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(On,{direction:"up",title:y.relation.belongsToWork,entity:a,onView:g,onUnlink:()=>u("workId"),onLink:()=>m("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(On,{direction:"up",title:y.relation.containedInCollection,entity:l,onView:g,onUnlink:()=>u("collectionId"),onLink:()=>m("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(yn,{direction:"horizontal",title:`${y.relation.siblingVersions} (${h.length})`,entities:h,onView:g,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(On,{direction:"up",title:y.relation.parentWork,entity:o,onView:g,onUnlink:()=>u("parentWorkId"),onLink:()=>m("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(yn,{direction:"down",title:`${y.relation.childWorks} (${d.length})`,entities:d,onView:g,onAdd:()=>x("childWork","work",{parentWorkId:n}),addLabel:y.action.addSubWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),c&&c.length>0&&t.jsx(yn,{direction:"down",title:`${y.relation.collectionImpl} (${c.length})`,entities:c,onView:g,onAdd:()=>x("childCollection","collection",{workId:n}),addLabel:y.action.addCollectionImpl,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(yn,{direction:"down",title:`${y.relation.allVersions} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:g,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(On,{direction:"up",title:y.relation.correspondingWork,entity:a,onView:g,onUnlink:()=>u("workId"),onLink:()=>m("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(On,{direction:"up",title:y.relation.parentCollection,entity:s,onView:g,onUnlink:()=>u("parentCollectionId"),onLink:()=>m("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(yn,{direction:"down",title:`${y.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:g,onAdd:()=>x("childCollection","collection",{parentCollectionId:n}),addLabel:y.action.addSubCollection,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(yn,{direction:"down",title:`${y.relation.containedBooks} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:g,onAdd:()=>x("childBook","book",{collectionId:n}),addLabel:y.action.addBook,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]})]})]})},On=({direction:e,title:n,entity:i,onView:o,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:h,unlinkLabel:m})=>{const u=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),g=e==="up"?"⬆️":e==="down"?"⬇️":"↔️";return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:u,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:g}),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:Ld(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(Ja,{onClick:()=>o(i),title:h,children:"👁️"}),t.jsx(Ja,{onClick:s,title:m,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(no,{onClick:a,children:d}),t.jsx(no,{onClick:l,primary:!0,children:c})]})]})},yn=({direction:e,title:n,entities:i,onView:o,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=f.useState(!1),h=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),m=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",u=c?i:i.slice(0,5);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:h,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:m}),t.jsx("span",{children:n})]}),i.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[u.map(g=>t.jsxs("div",{onClick:()=>o(g),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:r("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[t.jsx("span",{children:Ld(g.type)}),t.jsx("span",{children:g.title})]},g.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(no,{onClick:s,primary:!0,children:["+ ",a]})})]})},Ja=({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}),no=({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 Ld(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const zb={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},Ad=({isOpen:e,entityType:n,title:i,onSelect:o,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[h,m]=f.useState(""),u=p?l.filter(y=>y.id!==p):l;f.useEffect(()=>{e&&(m(""),d(""))},[e]);const g=y=>{m(y),d(y)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",j=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:Nb,children:t.jsxs("div",{style:Tb,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:Ib,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:h,onChange:y=>g(y.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:Rb})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:Nr,children:"搜索中..."}):u.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:u.map(y=>t.jsxs("div",{onClick:()=>o(y),style:Eb,children:[t.jsx("span",{style:{fontSize:"16px"},children:j}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[y.title,y.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:y.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[y.id,y.author&&` · ${y.author}`,y.dynasty&&` · ${y.dynasty}`]})]})]},y.id))}):h?t.jsxs("div",{style:Nr,children:["未找到匹配的",x]}):t.jsxs("div",{style:Nr,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:Lb,children:["创建新",x,"并关联"]})]})]})})},Nb={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Tb={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")},Ib={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},Rb={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"},Eb={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:r("primary-soft")},Nr={padding:"20px",textAlign:"center",color:r("desc-fg")},Lb={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Qa={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},Ab={work:"📜",book:"📖",collection:"📚",entity:"👤"},Md=({isOpen:e,entityType:n,relationField:i,inheritData:o,onConfirm:s,onCancel:a})=>{const[l,d]=f.useState(""),c=f.useRef(null);f.useEffect(()=>{e&&(d((o==null?void 0:o.title)||""),setTimeout(()=>{var u,g;(u=c.current)==null||u.focus(),(g=c.current)==null||g.select()},100))},[e,o==null?void 0:o.title]);const p=u=>{u.key==="Enter"&&l.trim()?h():u.key==="Escape"&&a()},h=()=>{l.trim()&&s(l.trim(),{...o,title:l.trim()})};if(!e)return null;const m=()=>{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`创建新${Qa[n]}`}};return t.jsx("div",{style:Mb,onClick:u=>{u.target===u.currentTarget&&a()},children:t.jsxs("div",{style:Pb,onClick:u=>u.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Ab[n]}),t.jsx("span",{children:m()})]}),t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:r("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",t.jsx("span",{style:{color:r("danger"),marginLeft:"4px"},children:"*"})]}),t.jsx("input",{ref:c,type:"text",value:l,onChange:u=>d(u.target.value),onKeyDown:p,placeholder:`请输入${Qa[n]}名称...`,style:Bb})]}),((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:Ob,children:"取消"}),t.jsx("button",{onClick:h,disabled:!l.trim(),style:{...Wb,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},Mb={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Pb={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")},Bb={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"},Ob={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},Wb={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg")};function Fb(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Pd(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Hb(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 Bd=({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[m,u]=f.useState(""),[g,x]=f.useState([]),[j,y]=f.useState(!1),[S,b]=f.useState("recent");f.useEffect(()=>{e&&(u(""),x([]),b(o.length>0?"recent":"search"))},[e,o.length]),f.useEffect(()=>{if(!m.trim()){x([]);return}const _=setTimeout(async()=>{y(!0);try{x(await h(m,i))}catch{x([])}finally{y(!1)}},300);return()=>clearTimeout(_)},[m,i,h]);const w=f.useCallback(_=>{u(_.target.value),_.target.value.trim()&&b("search")},[]),v=f.useCallback(_=>s?_.filter(R=>R.id!==s):_,[s]);if(!e)return null;const k=n||(i==="all"?"选择实体":`选择${Pd(i)}`),z=v(o),C=v(g);return t.jsx("div",{style:Ub,children:t.jsxs("div",{style:Vb,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:k}),t.jsx("button",{onClick:c,style:Gb,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:m,onChange:w,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Yb}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),j&&t.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),z.length>0&&t.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs(el,{active:S==="recent",onClick:()=>b("recent"),children:["最近使用 (",z.length,")"]}),t.jsxs(el,{active:S==="search",onClick:()=>b("search"),children:["搜索结果 ",C.length>0&&`(${C.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:S==="recent"&&z.length>0?t.jsx(tl,{entities:z,onSelect:d}):m.trim()?j?t.jsx(Tr,{message:"搜索中..."}):C.length>0?t.jsx(tl,{entities:C,onSelect:d}):t.jsx(Tr,{message:"未找到匹配的结果"}):t.jsx(Tr,{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:qb,children:l||"创建新实体"})]})]})})},el=({active:e,onClick:n,children:i})=>t.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${r("primary")}`:"2px solid transparent",background:"transparent",color:r(e?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:e?600:400,marginBottom:"-1px"},children:i}),tl=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(i=>t.jsx(Db,{entity:i,onClick:()=>n(i)},i.id))}),Db=({entity:e,onClick:n})=>{const[i,o]=f.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:r("primary-soft"),transition:"background 0.1s"},children:[t.jsx("span",{style:{fontSize:"18px"},children:Fb(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:Hb(e.type),color:r("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:Pd(e.type)})]})},Tr=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:e}),Ub={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Vb={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")},Gb={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Yb={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"},qb={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Kb={work:r("editor-type-work"),collection:r("editor-type-collection"),book:r("editor-type-book"),entity:r("editor-type-entity")},Xb={work:"📜",collection:"📚",book:"📖",entity:"👤"},Od=({data:e,onChange:n,onSave:i,transport:o,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:h,relations:m,onRelationsChange:u})=>{var ce;const g=Ae(),[x,j]=f.useState(!1),[y,S]=f.useState("work"),[b,w]=f.useState(""),[v,k]=f.useState(""),[z,C]=f.useState([]),[_,R]=f.useState(!1),[T,N]=f.useState(!1),[E,W]=f.useState("work"),[F,A]=f.useState(""),[V,ae]=f.useState(),[xe,me]=f.useState(!1),[G,ye]=f.useState(null),[ne,U]=f.useState([]);f.useRef(null);const ee=e.type,q=ee==="work",je=ee==="collection",I=ee==="book",oe=f.useCallback((J,we)=>{n({...e,[J]:we})},[e,n]),$e=f.useCallback((J,we)=>{w(J),S(we),k(g.editor.selectToLink+g.indexType[we]),C([]),j(!0)},[g]),ve=f.useCallback(J=>{o!=null&&o.unlinkEntity&&o.unlinkEntity(e.id,J)},[o,e.id]),Le=f.useCallback(J=>{s==null||s(J.id,J.type)},[s]),Te=f.useCallback((J,we,Fe)=>{const Ve={...Fe,author:(Fe==null?void 0:Fe.author)||e.author,dynasty:Fe==null?void 0:Fe.dynasty};W(we),A(J),ae(Ve),N(!0)},[e.author]),Z=f.useCallback((J,we)=>{o!=null&&o.createAndLink&&o.createAndLink(e.id,F,{type:E,title:J,inheritData:we}),N(!1)},[o,e.id,F,E]),ue=f.useCallback(J=>{if(!J.trim()){C([]);return}R(!0),o!=null&&o.searchEntities&&o.searchEntities(J,y).then(we=>{C(we),R(!1)}).catch(()=>{C([]),R(!1)})},[o,y]),Pe=f.useCallback(J=>{o!=null&&o.linkEntity&&o.linkEntity(e.id,b,J.id),j(!1)},[o,e.id,b]),Me=f.useCallback(()=>{i()},[i]),ke=f.useCallback(J=>{ye(()=>J),me(!0),o!=null&&o.getRecentEntities&&o.getRecentEntities().then(U).catch(()=>{})},[o]),D=f.useCallback((J,we)=>o!=null&&o.searchEntities?o.searchEntities(J,we==="all"?void 0:we):Promise.resolve([]),[o]),le=f.useCallback(J=>{o!=null&&o.addRecentEntity&&o.addRecentEntity(J),U(we=>[J,...we.filter(Fe=>Fe.id!==J.id)].slice(0,10)),G==null||G(J),me(!1),ye(null)},[o,G]);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:Xb[ee]}),t.jsx("span",{children:e.title||g.editor.untitled}),t.jsx(Ti,{children:e.id}),t.jsx(Ti,{color:Kb[ee],children:g.indexType[ee]})]})}),t.jsx(Tt,{title:g.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(wi,{label:q?g.editor.workTitle:je?g.editor.collectionTitle:g.editor.bookTitle,value:e.title,onChange:J=>oe("title",J)}),I&&t.jsx(wi,{label:g.editor.belongsToWork,value:e.workName||"",onChange:J=>oe("workName",J)}),t.jsx(kt,{label:g.editor.authorLabel,value:e.author||"",onChange:J=>oe("author",J)}),t.jsx(kt,{label:g.editor.publicationYearLabel,value:e.publicationYear||"",onChange:J=>oe("publicationYear",J)}),(I||je)&&t.jsx(wi,{label:g.editor.containedIn,value:e.collection||"",onChange:J=>oe("collection",J)}),(I||je)&&t.jsx(kt,{label:g.editor.holderLabel,value:e.holder||"",onChange:J=>oe("holder",J)}),(I||je)&&t.jsx(kt,{label:I?g.editor.pageLabel:g.editor.volumeLabel,value:e.pages||"",onChange:J=>oe("pages",J)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(kt,{label:g.editor.firstImageLabel,value:e.firstImage||"",onChange:J=>oe("firstImage",J)})})]})}),t.jsx(Tt,{title:g.section.description,onSave:i,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(pn,{value:e.description||"",onChange:J=>oe("description",J),placeholder:g.editor.descriptionPlaceholder})}),(((ce=e.additional_works)==null?void 0:ce.length)||0)>0&&t.jsx(Tt,{title:g.section.additionalWorks,onSave:i,children:t.jsx(Zb,{items:e.additional_works||[],onChange:J=>oe("additional_works",J)})}),t.jsx(Tt,{title:g.section.indexedBy,onSave:i,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(Jb,{items:e.indexed_by||[],onChange:J=>oe("indexed_by",J)})}),t.jsx(Tt,{title:g.section.emendatedBy,onSave:i,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(Qb,{items:e.emendated_by||[],onChange:J=>oe("emendated_by",J)})}),t.jsx(Tt,{title:g.section.textResources,onSave:i,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(Mr,{items:e.resources||[],onChange:J=>oe("resources",J),onDownload:p,downloadStatuses:h,filterType:"text"})}),t.jsx(Tt,{title:g.section.imageResources,onSave:i,children:t.jsx(Mr,{items:e.resources||[],onChange:J=>oe("resources",J),onDownload:p,downloadStatuses:h,filterType:"image"})}),t.jsx(Tt,{title:g.section.sources,onSave:i,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(Td,{items:Id(e.sources||""),onChange:J=>oe("sources",Rd(J)),onOpenEntityPicker:ke})}),(I||je)&&t.jsx(Tt,{title:g.section.provenance,onSave:i,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(pn,{value:e.provenance||"",onChange:J=>oe("provenance",J),placeholder:g.editor.provenancePlaceholder})}),I&&t.jsx(Tt,{title:g.section.otherEditions,onSave:i,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(pn,{value:e.otherEditions||"",onChange:J=>oe("otherEditions",J),placeholder:g.editor.otherEditionsPlaceholder})}),t.jsx(Ed,{entityType:ee,entityId:e.id,entityTitle:e.title,parentWork:m==null?void 0:m.parentWork,parentCollection:m==null?void 0:m.parentCollection,belongsToWork:m==null?void 0:m.belongsToWork,belongsToCollection:m==null?void 0:m.belongsToCollection,childWorks:m==null?void 0:m.childWorks,childCollections:m==null?void 0:m.childCollections,containedBooks:m==null?void 0:m.containedBooks,siblingBooks:m==null?void 0:m.siblingBooks,onLinkEntity:$e,onUnlinkEntity:ve,onViewEntity:Le,onCreateAndLink:Te,onSaveRelations:Me}),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:g.section.dangerZone}),t.jsx("p",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"12px"},children:g.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:g.editor.deleteEntity})]}),t.jsx(Ad,{isOpen:x,entityType:y,title:v,onSelect:Pe,onCancel:()=>j(!1),onCreate:()=>{j(!1),Te(b,y)},searchResults:z,onSearch:ue,isLoading:_,excludeId:e.id}),t.jsx(Md,{isOpen:T,entityType:E,relationField:F,inheritData:V,onConfirm:Z,onCancel:()=>N(!1)}),t.jsx(Bd,{isOpen:xe,title:g.action.selectBookOrWork,filterType:"all",recentEntities:ne,excludeId:e.id,onSelect:le,onCancel:()=>{me(!1),ye(null)},onSearch:D})]})};function Zb({items:e,onChange:n}){const i=Ae(),o=(l,d,c)=>{const p=e.map((h,m)=>m===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(kt,{label:i.editor.bookNameLabel,value:l.book_title,onChange:c=>o(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(kt,{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 Wd({items:e,onChange:n,showMeta:i,addLabel:o}){const s=Ae(),[a,l]=f.useState(null),d=(h,m,u)=>{const g=e.map((x,j)=>j===h?{...x,[m]:u||void 0}:x);n(g)},c=h=>{n(e.filter((m,u)=>u!==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,m)=>{const u=a===m;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:u?`color-mix(in srgb, ${r("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(u?null:m),children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.2s",transform:u?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children: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:g=>{g.stopPropagation(),c(m)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${r("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:r("muted")},children:"✕"})]}),!u&&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]}),u&&t.jsxs("div",{style:{padding:"8px 12px 12px",display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(kt,{label:s.label.sourceName,value:h.source,onChange:g=>d(m,"source",g)}),t.jsx(kt,{label:s.label.sourceBid,value:h.source_bid||"",onChange:g=>d(m,"source_bid",g)})]}),i&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(kt,{label:s.label.titleInfo,value:h.title_info||"",onChange:g=>d(m,"title_info",g)}),t.jsx(kt,{label:s.label.authorInfo,value:h.author_info||"",onChange:g=>d(m,"author_info",g)})]}),t.jsx(kt,{label:s.label.edition,value:h.edition||"",onChange:g=>d(m,"edition",g)})]}),t.jsx(pn,{value:h.summary||"",onChange:g=>d(m,"summary",g),placeholder:s.editor.summaryPlaceholder}),t.jsx(pn,{value:h.comment||"",onChange:g=>d(m,"comment",g),placeholder:s.editor.commentPlaceholder}),t.jsx(pn,{value:h.additional_comment||"",onChange:g=>d(m,"additional_comment",g),placeholder:s.editor.additionalCommentPlaceholder})]})]},m)}),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 Jb({items:e,onChange:n}){const i=Ae();return t.jsx(Wd,{items:e,onChange:n,showMeta:!0,addLabel:i.action.addIndexedBy})}function Qb({items:e,onChange:n}){const i=Ae();return t.jsx(Wd,{items:e,onChange:n,addLabel:i.action.addEmendatedBy})}function Fd(e){var d,c,p,h,m,u,g;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=(m=e.page_count)!=null&&m.number?String(e.page_count.number):((u=e.page_count)==null?void 0:u.description)||"",a=typeof e.description=="object"&&e.description!==null&&e.description.text||"",l={id:e.id,title:e.title,type:e.type,author:n,publicationYear:i,holder:o,pages:s,description:a,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};if(e.type==="work"){const x=e;if(Array.isArray(x.related_works)){const j=x.related_works.find(y=>y.relation==="part_of");j&&(l.parentWorkId=j.id,l.parentWorkName=j.title)}}if(e.type==="book"){const x=e;l.workId=x.work_id,Array.isArray(x.contained_in)&&x.contained_in.length>0&&(l.collectionId=(g=x.contained_in[0])==null?void 0:g.id)}return l}function ey(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 ty=e=>{const{data:n,id:i,transport:o,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:h,onAskAI:m,renderSectionActions:u,onDownloadResource:g,downloadStatuses:x,relations:j,onRelationsChange:y,headerExtra:S,className:b,style:w}=e,v=Ae(),[k,z]=f.useState(s),C=a?s:k;f.useEffect(()=>{s!==k&&z(s)},[s]);const _=f.useCallback(()=>{const A=C==="view"?"edit":"view";a?a(A):z(A)},[C,a]),[R,T]=f.useState(null);f.useEffect(()=>{i&&o&&o.getItem(i).then(A=>{A&&T(A)})},[i,o]);const N=n||R,E=f.useMemo(()=>N?Fd(N):null,[N]),W=a||!n?t.jsx("button",{onClick:_,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:C==="edit"?r("accent-bg"):"transparent",color:r(C==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:C==="view"?v.common.switchToEdit:v.common.switchToView,children:C==="view"?v.common.modeEdit:v.common.modeView}):null,F=t.jsxs(t.Fragment,{children:[W,S]});return!N&&!E?t.jsx(un,{}):C==="view"?t.jsx(zo,{data:N,transport:o,onNavigate:p?A=>p(A):void 0,renderLink:h,headerExtra:F,className:b,style:w}):E?t.jsxs("div",{className:b,style:w,children:[F&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:F}),t.jsx(Od,{data:E,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:o,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:m,renderSectionActions:u,onDownloadResource:g,downloadStatuses:x,relations:j,onRelationsChange:y})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:r("muted")},children:v.common.noData})},ny=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Hd=({isOpen:e,onClose:n,onSubmit:i,feedbackListUrl:o})=>{const{t:s}=re(),[a,l]=f.useState(null),[d,c]=f.useState(""),[p,h]=f.useState(""),[m,u]=f.useState("idle"),[g,x]=f.useState(""),j=f.useRef(null);f.useEffect(()=>{e&&(l(null),c(""),h(""),u("idle"),x(""))},[e]),f.useEffect(()=>{a&&setTimeout(()=>{var b;return(b=j.current)==null?void 0:b.focus()},100)},[a]),f.useEffect(()=>{if(m==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[m,n]),f.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())){u("submitting"),x("");try{await i({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),u("success")}catch(b){u("error"),x(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const S=a&&d.trim()&&m!=="submitting";return t.jsx("div",{style:iy,onClick:b=>{b.target===b.currentTarget&&n()},children:t.jsxs("div",{style:ry,onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{style:oy,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:sy,"aria-label":s("feedback.close"),children:"✕"})]}),m==="success"?t.jsxs("div",{style:py,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:ny.map(b=>t.jsxs("button",{onClick:()=>l(b.value),style:{...ay,...a===b.value?ly:{}},children:[t.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),t.jsx("textarea",{ref:j,value:d,onChange:b=>c(b.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||m==="submitting",style:{...cy,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||m==="submitting","aria-label":s("feedback.contactLabel"),style:my}),t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),m==="error"&&t.jsx("div",{style:uy,children:g}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:y,disabled:!S,style:{...dy,opacity:S?1:.6,cursor:S?"pointer":"not-allowed"},children:s(m==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},iy={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},ry={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:r("shadow-dialog")},oy={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},sy={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:r("desc-fg"),padding:"4px 8px",borderRadius:"4px"},ay={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"},ly={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},cy={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"},dy={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},py={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:r("success")},uy={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginBottom:"12px"},my={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"},io="--bim-feedback-fab-offset",ro=48,hy=16,fy=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:i,hidden:o=!1,zIndex:s})=>{const{t:a}=re(),[l,d]=f.useState(!1),c=n.bottom??24;return f.useEffect(()=>{if(o||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(io,`calc(${c+ro+hy}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(io)}},[o,c]),t.jsxs(t.Fragment,{children:[!o&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...gy,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(Hd,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:i})]})},gy={position:"fixed",width:`${ro}px`,height:`${ro}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"},xy=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Dd=({onSubmit:e})=>{const{t:n}=re(),[i,o]=f.useState("bug"),[s,a]=f.useState(""),[l,d]=f.useState(""),[c,p]=f.useState("idle"),[h,m]=f.useState(""),u=f.useRef(null);f.useEffect(()=>{i&&setTimeout(()=>{var j;return(j=u.current)==null?void 0:j.focus()},100)},[i]);const g=async()=>{if(!(!i||!s.trim())){p("submitting"),m("");try{await e({type:i,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),o("bug")}catch(j){p("error"),m(j instanceof Error?j.message:n("feedback.submitFailedRetry"))}}},x=i&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:nl,children:t.jsxs("div",{style:ky,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:wy,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:nl,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:xy.map(j=>t.jsxs("button",{onClick:()=>o(j.value),style:{...by,...i===j.value?yy:{}},children:[t.jsx("span",{children:j.icon})," ",n(`feedback.submitType.${j.value}`)]},j.value))}),t.jsx("textarea",{ref:u,value:s,onChange:j=>a(j.target.value),placeholder:n(i?`feedback.placeholder.${i}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...jy}}),t.jsx("input",{type:"text",value:l,onChange:j=>d(j.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:_y}),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:g,disabled:!x,style:{...vy,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:Sy,children:h})]})},nl={padding:"16px",border:`1px solid ${r("widget-border")}`,borderRadius:"8px",background:r("input-bg")},by={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"},yy={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},jy={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"},vy={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},ky={display:"flex",alignItems:"center",gap:"12px",color:r("success"),fontSize:"14px"},wy={background:"none",border:"none",color:r("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},Sy={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginTop:"8px"},_y={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 il(e){return typeof e=="function"?e():e??"/api/feedback"}const Ud=({resourceId:e,apiUrl:n})=>{const{t:i}=re(),[o,s]=f.useState([]),[a,l]=f.useState(!0),d=f.useCallback(async()=>{const p=il(n);l(!0);try{const m=await(await fetch(`${p}?resourceId=${encodeURIComponent(e)}`)).json();m.success&&s(m.items)}catch{}finally{l(!1)}},[e,n]);f.useEffect(()=>{d()},[d]);const c=async p=>{const h=il(n),m=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!m.ok){const u=await m.json().catch(()=>null);throw new Error((u==null?void 0:u.error)||i("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(rs,{items:o,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(Dd,{onSubmit:c})})]})},Yi=8;async function qi(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 $y=Ei["zh-Hant"].relation,Cy=Ei["zh-Hant"].lossStatus,zy=Ei["zh-Hant"].resourceKind,Ki=Nn("zh-Hant"),os=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function rl(e,n=Ki){return e?os($y,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function Ny(e,n=Ki){return os(Cy,e)?n(`detail.lossStatus.${e}`):e}function Ty(e,n=Ki){return os(zy,e)?n(`detail.resourceKind.${e}`):""}function ss({authors:e,onNavigate:n,renderLink:i}){const{convert:o}=re(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=ko(a.role);return t.jsxs(f.Fragment,{children:[l>0&&" ",a.dynasty&&t.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",o(a.dynasty),"〕"]}),a.entity_id?t.jsx(ot,{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 Vd(e,n,i=Ki){var c,p;const o=jo(e,n),s=o.mirrors.map(h=>({key:h.key,label:h.label,description:h.description,rows:h.items.filter(m=>m.group_role!=="mirror"),mirrors:h.items.filter(m=>m.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 Gd(e,n){const i=(e.url?$n(e.url):void 0)||e.name,o=Hl(e,n);return o?`${i}(${o})`:i}function as({item:e,siblings:n,listedVolumeCounts:i}){const{t:o,convert:s}=re(),[a,l]=f.useState(!1),d=Ri(e),c=!!d&&d.expected>0&&!(i!=null&&i.has(d.expected)),p=s(Gd(e,n)),h=Cn(e),m=Pi(e,o)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var g,x;const u=(g=e.metadata)!=null&&g.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:"↗"}),u]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,u]})})(),m&&t.jsx("span",{className:"bim-d-meta",children:s(m)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(Mo,{item:e})})]}),t.jsx("td",{className:c?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:c&&t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":a,onClick:()=>l(u=>!u),children:a?o("detail.collapseVolumes"):o("detail.expandVolumes",{n:d.expected})})})]})}function Yd({groups:e,listedVolumeCounts:n}){const{t:i,convert:o}=re();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(as,{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=Cn(a),c=o(Gd(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 Yn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function oo(e){var i;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(i=Yn.find(o=>n.startsWith(o.key[0])))==null?void 0:i.key}const ol=12,Iy=60,qd=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,railTop:a,back:l,railLinks:d})=>{var Pe,Me,ke;const{t:c,convert:p,messages:h}=re(),m=f.useMemo(()=>wo({_books:e._books}),[e._books]),[u,g]=f.useState(new Map),[x,j]=f.useState(!1),[y,S]=f.useState(""),[b,w]=f.useState(!1),v=m.length<=Iy,k=v||x||!!y||b,z=f.useMemo(()=>k?m:m.slice(0,ol),[m,k]);f.useEffect(()=>{if(!n||z.length===0)return;const D=z.filter(ce=>!u.has(ce));if(D.length===0)return;let le=!1;return qi(D,Yi,ce=>n.getItem(ce).then(J=>{var Fe;const we=J??{};return[ce,{id:ce,title:we.title,edition:we.edition,resources:we.resources,publication_info:we.publication_info,current_location:we.current_location,lineage:we.lineage,measure_info:we.measure_info,summary:Ry((Fe=J==null?void 0:J.description)==null?void 0:Fe.text)}]}).catch(()=>[ce,{id:ce}]),()=>le).then(ce=>{le||g(J=>{const we=new Map(J);for(const[Fe,Ve]of ce)we.set(Fe,Ve);return we})}),()=>{le=!0}},[n,z,u]);const C=f.useMemo(()=>m.map(D=>u.get(D)??{id:D}),[m,u]),_=m.length>0&&m.every(D=>u.has(D)),R=!!n&&z.some(D=>!u.has(D)),T=v||k,N=f.useMemo(()=>Ul(C,e.version_graph,{era:y,scanOnly:b,sort:T?"year":"default"}),[C,e.version_graph,y,b,T]),E=x?N.rows:N.rows.slice(0,ol),W=N.allRows.filter(D=>D.hasImage).length,F=N.allRows.reduce((D,le)=>{var ce;return D+(((ce=le.copies)==null?void 0:ce.length)??0)},0),A=f.useMemo(()=>(e._related||[]).map(D=>({...D,title:D.title??""})),[e._related]),V=A.filter(D=>D.relation==="collected_in"),ae=f.useMemo(()=>{const D=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],le=ce=>{const J=D.indexOf(ce??"");return J<0?D.length:J};return A.filter(ce=>ce.relation!=="collected_in").map((ce,J)=>({r:ce,i:J})).sort((ce,J)=>le(ce.r.relation)-le(J.r.relation)||ce.i-J.i).map(ce=>ce.r)},[A]),xe=f.useMemo(()=>{const D=jo(e.resources,e.resource_groups);return[...D.mirrors.flatMap(le=>le.items.map(ce=>({r:ce,kind:p(le.label)}))),...D.buckets.flatMap(le=>le.items.map(ce=>({r:ce,kind:p(Ty(le.key,c))})))]},[e.resources,e.resource_groups,p,c]),me=e.indexed_by||[],G=e.emendated_by||[],ye=f.useMemo(()=>{var O,de,Ie;const D=[],le=(de=(O=e.authors)==null?void 0:O[0])==null?void 0:de.dynasty;le&&D.push({label:c("workPage.fact.written"),value:p(le)});const ce=Gt(e,h.unit.juan);if(ce){const B=(Ie=e.juan_count)==null?void 0:Ie.description;D.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(ce),B&&B!==ce?t.jsxs("span",{className:"bim-d-meta",children:["(",p(B),")"]}):null]})})}e.loss_status&&D.push({label:c("workPage.fact.loss"),value:p(Ny(e.loss_status,c))});const J=N.allRows.filter(B=>B.sortYear!=null),we=J.length>0?J.reduce((B,pe)=>B.sortYear<=pe.sortYear?B:pe):null;we!=null&&we.era.era?D.push({label:c("workPage.fact.earliest"),value:p([we.era.era,we.era.reign].filter(Boolean).join(" ")),title:we.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):R&&D.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),G.length&&D.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:G.length})});const Fe=sl(e.additional_titles);Fe.length&&D.push({label:c("workPage.fact.alias"),value:Fe.map(p).join("、")});const Ve=sl(e.attached_texts);Ve.length&&D.push({label:c("workPage.fact.attached"),value:Ve.map(p).join("、")});const Ze=(e.additional_works||[]).map(B=>p(B.book_title)+(B.n_juan!=null?` ${B.n_juan}${h.unit.juan}`:""));return Ze.length&&D.push({label:c("workPage.fact.appendix"),value:Ze.join("、")}),D},[e,p,c,h,R,N.allRows,G.length]),U=[{value:e._edition_count??m.length,label:c("workPage.stat.editions")},{value:_?W:0,label:c("workPage.stat.hasImage")},{value:me.length,label:c("workPage.stat.catalogs")}],ee=So(e),q=ee?[ee.l1,ee.l2,ee.l3,ee.l4].filter(Boolean).map(D=>p(D)):[],je=e.subtype?h.workSubtype[e.subtype]??p(e.subtype):"",I=t.jsx(Jn,{title:p(e.title),byline:t.jsx(ss,{authors:e.authors,onNavigate:i,renderLink:o}),meta:t.jsx(dt,{items:[...q,ee!=null&&ee.source?c("workPage.classifiedBy",{source:p(ee.source.split("/")[0])}):"",je]}),description:(Pe=e.description)!=null&&Pe.text?t.jsxs(t.Fragment,{children:[t.jsx(Yt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(Me=e.description.sources)!=null&&Me.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(D=>({text:p(Em(D)),href:Lm(D)})).filter(D=>D.text).map((D,le)=>t.jsxs(f.Fragment,{children:[le>0?" · ":null,D.href?t.jsx("a",{href:D.href,target:"_blank",rel:"noopener noreferrer",children:D.text}):D.text]},le))}):null]}):void 0,stats:U,facts:ye,readAction:s,foot:t.jsx(Qn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(ke=e.appendix)==null?void 0:ke.map((D,le)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(D.title)}),t.jsx(Yt,{text:D.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},le))}),oe=N.eras.length>=2?[{key:"",label:c("catalog.all")},...N.eras.map(D=>({key:D,label:`${D} ${N.allRows.filter(le=>le.era.era===D).length}`}))]:[],$e=[];m.length&&$e.push({id:"versions",label:c("workPage.sec.versions"),count:m.length}),me.length&&$e.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:me.length}),V.length&&$e.push({id:"collected",label:c("workPage.sec.collected"),count:V.length}),ae.length&&$e.push({id:"related",label:c("workPage.sec.related"),count:ae.length}),xe.length&&$e.push({id:"resources",label:c("workPage.sec.resources"),count:xe.length});const ve=m.length===0&&me.length===0,Le=t.jsxs(t.Fragment,{children:[m.length>0&&t.jsxs(ut,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(dt,{items:[c("workPage.versionsTotal",{n:m.length-F}),_&&W?c("workPage.versionsWithImage",{n:W}):"",N.rows.length!==N.allRows.length?c("workPage.versionsCurrent",{n:N.rows.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":R&&oe.length===0&&m.length>1?"":void 0,children:[oe.length>0&&t.jsx(Di,{items:oe,value:y,onChange:D=>{S(D),j(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(Ac,{label:c("workPage.scanOnly"),checked:b,onChange:D=>{w(D),j(!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&&Ui(N.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:E.map(D=>{var le;return t.jsx(Ly,{row:D,measure:(le=u.get(D.id))==null?void 0:le.measure_info,loaded:u.has(D.id),onNavigate:i,renderLink:o},`${D.id}:${u.has(D.id)?"r":"p"}`)})})]}),E.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(Ro,{total:N.rows.length,shown:E.length,unit:c("workPage.moreUnit"),onClick:()=>j(!0)}),N.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),me.length>0&&t.jsx(Ay,{items:me,transport:n,onNavigate:i,renderLink:o}),ve&&t.jsx(ut,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),Te=(D,le)=>t.jsx(ot,{id:D,label:p(le),onNavigate:i,renderLink:o,dense:!0}),Z=f.useMemo(()=>{const D=new Map;for(const le of ae){const ce=rl(le.relation,c);D.set(ce,(D.get(ce)??0)+1)}return D.size>1?[...D.entries()].sort((le,ce)=>ce[1]-le[1]).slice(0,4).map(([le,ce])=>`${p(le)} ${ce}`).join(" · "):void 0},[ae,p,c]),ue=t.jsxs(t.Fragment,{children:[t.jsx(dn,{id:"collected",title:c("workPage.sec.collected"),items:V.map(D=>Te(D.id,D.title))}),t.jsx(dn,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:ae.length}),sub:Z,items:ae.map(D=>t.jsxs(t.Fragment,{children:[Te(D.id,D.title),t.jsx("span",{className:"bim-d-meta",title:D.note?p(D.note):void 0,children:p(rl(D.relation,c))})]}))}),t.jsx(dn,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:xe.map(({r:D,kind:le})=>{const ce=p((D.url?$n(D.url):void 0)||D.name),J=Cn(D);return t.jsxs(t.Fragment,{children:[J?t.jsxs("a",{href:J,target:"_blank",rel:"noopener noreferrer",children:[ce," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:ce}),le&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:le})]})})})]});return t.jsx(Zn,{railTop:a,back:l,nav:$e,railLinks:d,main:Le,card:I,side:ue})};function sl(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function so(e,n){return n((e.url?$n(e.url):void 0)||e.name)}function Ry(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 Ey({copies:e,onNavigate:n,renderLink:i}){const{t:o,convert:s}=re(),a=new Map;for(const l of e){const d=l.locationName||(l.holders[0]?so(l.holders[0],s):"")||"",c=a.get(d)??[];c.push(l),a.set(d,c)}return t.jsxs("span",{className:"bim-d-zt-copies",children:[o("workPage.sameEditionCopies",{n:e.length}),[...a].map(([l,d],c)=>t.jsxs(f.Fragment,{children:[c>0?";":"",l?`${s(l)} `:"",d.map((p,h)=>t.jsxs(f.Fragment,{children:[h>0?" · ":"",t.jsx(ot,{id:p.id,label:p.callNumber||p.id,onNavigate:n,renderLink:i,dense:!0})]},p.id))]},l||c))]})}function Ly({row:e,measure:n,loaded:i,onNavigate:o,renderLink:s}){const{t:a,convert:l}=re(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],h=e.copies??[],m=h.length&&e.locationName?l(e.locationName):p?so(p,l):e.locationName?l(e.locationName):"",u=e.images[0],g=u?Cn(u):void 0,x=e.images.map(j=>so(j,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(ot,{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(Ey,{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${m?"":" bim-d-zt-blank"}`,children:[m||(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&&(g?t.jsx("a",{className:"bim-d-flag",href:g,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 Ay({items:e,transport:n,onNavigate:i,renderLink:o}){const{t:s,convert:a}=re(),[l,d]=f.useState(0),c=Math.min(l,e.length-1),p=e[c],[h,m]=f.useState(new Map);return f.useEffect(()=>{if(!n)return;const u=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(u.length===0)return;let g=!1;return Promise.all(u.map(x=>n.getItem(x).then(j=>{var y,S;return[x,((S=(y=j==null?void 0:j.authors)==null?void 0:y[0])==null?void 0:S.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{g||m(new Map(x.filter(([,j])=>j)))}),()=>{g=!0}},[n,e]),t.jsx(ut,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(dt,{items:[s("workPage.catalog.meta",{n:e.length}),s("workPage.sortByCatalog")]}),children:t.jsxs("div",{className:"bim-d-lu",children:[t.jsx("ul",{className:"bim-d-tl2 bim-d-ui",role:"tablist","aria-label":s("workPage.catalog.tablist"),children:e.map((u,g)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":g===c,"aria-label":a(u.source),onClick:()=>d(g),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:h.get(u.source_bid??"")?a(h.get(u.source_bid??"")):" "}),t.jsx("i",{className:"bim-d-tl2-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-d-tl2-name","aria-hidden":"true",children:[...a(u.source)].slice(0,9).map((x,j)=>t.jsx("span",{children:x},j))})]})},g))}),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(dt,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(ot,{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:St(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:St(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:St(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 My(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 Py(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 al(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 By(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 Oy(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,m]of Object.entries(e.node_groups))l.has(m)&&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 Si(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=Oy(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,m=new Set,u=new Set;if(c){const v=new Map(n.map(T=>[T.id,T])),k=new Map((o.hypothetical_nodes??[]).map(T=>[T.id,T])),z=T=>{const N=v.get(T);if(N&&N.lineage)return(N.lineage.derived_from??[]).map(W=>W.ref);const E=k.get(T);return E?(E.derived_from??[]).map(W=>W.ref):[]},C=T=>k.has(T)?!h||h.has(T):!p||p.has(T),_=new Set,R=T=>{if(!_.has(T)){_.add(T);for(const N of z(T))a.has(N)||(C(N)||(k.has(N)?u.add(N):v.has(N)&&m.add(N)),R(N))}};for(const T of n)p&&p.has(T.id)&&!a.has(T.id)&&R(T.id);for(const T of o.hypothetical_nodes??[])h&&h.has(T.id)&&R(T.id)}const g=n.filter(v=>!a.has(v.id)).filter(v=>!p||p.has(v.id)||m.has(v.id)).map(v=>{const k=Py(v,l);return k&&m.has(v.id)&&(k.bridge=!0),k}).filter(v=>v!==null),x=(o.hypothetical_nodes??[]).filter(v=>!h||h.has(v.id)||u.has(v.id)).map(v=>{const k=My(v);return u.has(v.id)&&(k.bridge=!0),k}),j=[...g,...x],y=new Set(j.map(v=>v.id)),S=new Set,b=[],w=v=>{S.has(v.id)||!y.has(v.source)||!y.has(v.target)||(S.add(v.id),b.push(v))};for(const v of n)a.has(v.id)||!v.lineage||p&&!p.has(v.id)&&!m.has(v.id)||((v.lineage.derived_from??[]).forEach((k,z)=>{w(al(v.id,k,z))}),(v.lineage.related_to??[]).forEach((k,z)=>{w(By(v.id,k,z))}));for(const v of o.hypothetical_nodes??[])h&&!h.has(v.id)&&!u.has(v.id)||(v.derived_from??[]).forEach((k,z)=>{w(al(v.id,k,z))});return{nodes:j,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 Wy(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 Xd=({graph:e,renderLink:n,className:i,style:o})=>{const{t:s,convert:a}=re();if(!e.nodes.length)return t.jsx("div",{style:{...e0,...o},className:i,children:s("lineage.emptyGraph")});const l=new Map,d=new Map;for(const g of e.edges)if(g.kind==="derive"){const x=l.get(g.target)??[];x.push(g),l.set(g.target,x)}else for(const x of[g.source,g.target]){const j=d.get(x)??[];j.push(g),d.set(x,j)}const c=new Map(e.nodes.map(g=>[g.id,g])),p=new Map,h=[];for(const g of e.nodes)if(g.group){const x=p.get(g.group)??[];x.push(g),p.set(g.group,x)}else h.push(g);const m=(g,x)=>(g.year??9999)-(x.year??9999);p.forEach(g=>g.sort(m)),h.sort(m);const u=e.groups.filter(g=>p.has(g.id));return t.jsxs("div",{className:i,style:{...Hy,...o},children:[e.title&&t.jsx("div",{style:Dy,children:a(e.title)}),e.description&&t.jsx("div",{style:Uy,children:a(e.description)}),u.map(g=>t.jsx(ll,{label:g.label,color:g.color,nodes:p.get(g.id),incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n},g.id)),h.length>0&&t.jsx(ll,{label:s("lineage.otherGroup"),nodes:h,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},ll=({label:e,color:n,nodes:i,incomingMap:o,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=re();return t.jsxs("div",{style:Vy,children:[t.jsx("div",{style:{...Gy,borderLeftColor:n??r("widget-border")},children:d(e)}),i.map(c=>t.jsx(Fy,{node:c,incoming:o.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},Fy=({node:e,incoming:n,siblings:i,nodeMap:o,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=re();return t.jsxs("div",{style:{...Yy,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:qy,children:[t.jsx("span",{style:Ky,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:Xy,children:Kd(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:Zy,children:[e.category&&t.jsx(Wn,{children:c(e.category)}),e.status==="lost"&&t.jsx(Wn,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(Wn,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(Wn,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(Wn,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:Jy,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:Qy,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:dl,children:[t.jsx("div",{style:pl,children:d("lineage.sources")}),n.map(p=>{const h=o.get(p.source);return t.jsxs("div",{style:ul(p.confidence),children:[t.jsx("span",{style:ml,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(cl,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:hl,children:["· ",c(p.evidence)]})]},p.id)})]}),i.length>0&&t.jsxs("div",{style:dl,children:[t.jsx("div",{style:pl,children:d("lineage.related")}),i.map(p=>{const h=p.source===e.id?p.target:p.source,m=o.get(h);return t.jsxs("div",{style:ul(p.confidence),children:[t.jsx("span",{style:ml,children:c(p.relation)}),t.jsx("span",{children:(m==null?void 0:m.kind)==="book"&&s?s(m.id,c(m.label)):c((m==null?void 0:m.label)??h)}),t.jsx(cl,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:hl,children:["· ",c(p.evidence)]})]},p.id)})]})]})},Wn=({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})},cl=({level:e})=>{const{t:n}=re(),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},Hy={fontSize:"14px",color:r("fg")},Dy={fontSize:"16px",fontWeight:600,marginBottom:"8px"},Uy={fontSize:"13px",color:r("muted"),marginBottom:"16px",lineHeight:1.6},Vy={marginBottom:"16px"},Gy={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:r("fg")},Yy={border:`1px solid ${r("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:r("bg")},qy={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Ky={fontSize:"15px",fontWeight:600},Xy={fontSize:"12px",color:r("muted")},Zy={marginBottom:"6px"},Jy={fontSize:"12px",color:r("muted"),margin:"2px 0"},Qy={fontSize:"12px",color:r("muted"),fontStyle:"italic",margin:"4px 0"},dl={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${r("widget-border")}`},pl={fontSize:"11px",color:r("muted"),marginBottom:"2px"},ul=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),ml={display:"inline-block",padding:"0 6px",fontSize:"11px",background:r("tag-bg"),color:r("fg"),borderRadius:"3px",marginRight:"6px"},hl={fontSize:"11px",color:r("muted")},e0={padding:"20px",textAlign:"center",color:r("muted"),fontSize:"13px"},Zd=({selectedNodeId:e,...n})=>{const{t:i}=re(),[o,s]=f.useState("loading"),[a,l]=f.useState(null);return f.useEffect(()=>{let d=!1;return t0().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),o==="loading"?t.jsx("div",{style:gl,children:i("lineage.graphLoading")}):o==="missing"||!a?t.jsxs("div",{style:gl,children:[t.jsx("div",{children:fl(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:fl(i("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(n0,{modules:a,selectedNodeId:e,...n})};function fl(e,n){return e.split(/(\{\w+\})/).map((i,o)=>{const s=/^\{(\w+)\}$/.exec(i);return t.jsx(f.Fragment,{children:s&&s[1]in n?n[s[1]]:i},o)})}async function t0(){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 n0=({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:m,BaseEdge:u,EdgeLabelRenderer:g,getSmoothStepPath:x,dagre:j}=l,y=f.useMemo(()=>({lineage:z=>{var V,ae,xe,me;const C=((V=z.data)==null?void 0:V.stepPosition)??.85,[_,R,T]=x({sourceX:z.sourceX,sourceY:z.sourceY,sourcePosition:z.sourcePosition,targetX:z.targetX,targetY:z.targetY,targetPosition:z.targetPosition,stepPosition:C,borderRadius:5}),N=!!((ae=z.data)!=null&&ae.isSibling),E=N?R:z.targetX-18,W=N?T:z.targetY-12,F=(xe=z.data)==null?void 0:xe.labelStyle,A=(me=z.data)==null?void 0:me.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(u,{id:z.id,path:_,style:z.style,markerStart:z.markerStart,markerEnd:z.markerEnd}),z.label&&t.jsx(g,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${E}px,${W}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:r("bg"),border:`0.5px solid ${r("widget-border")}`,...A,...F},children:z.label})})]})}}),[u,g,x]),S=f.useMemo(()=>({version:z=>{const{t:C}=re(),_=z.data,R=_.kind==="hypothetical",T=_.status==="lost",N=_.isSelected,E=_.bridge,W=_.borderColor??r("muted"),F=E||R?"dashed":"solid",A=E?.5:T?.6:1;return t.jsxs("div",{style:{background:r(E?"bg-subtle":"bg"),border:`2px ${F} ${N?r("primary"):W}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:A,boxShadow:N?r("shadow-node-selected"):R||E?"none":r("shadow-node")},title:E?C("lineage.bridgeTitle"):void 0,children:[t.jsx(h,{type:"target",position:m.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:R||!_.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:C("lineage.lost")}),t.jsx(h,{type:"source",position:m.Right,style:{visibility:"hidden"}})]})}}),[h,m]),{convert:b}=re(),{rfNodes:w,rfEdges:v}=f.useMemo(()=>i0(e,j,n,a,b),[e,j,n,a,b]);return t.jsx("div",{style:{width:"100%",height:i,...s},className:o,children:t.jsxs(d,{nodes:w,edges:v,nodeTypes:S,edgeTypes:y,fitView:!0,fitViewOptions:{padding:.15},proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,minZoom:.2,maxZoom:1.8,children:[t.jsx(c,{gap:16}),t.jsx(p,{showInteractive:!1})]})})};function i0(e,n,i,o,s=a=>a??""){const d=e.layout==="LR"||!e.layout,c=new n.graphlib.Graph;c.setGraph({rankdir:d?"LR":"TB",ranksep:160,nodesep:40,edgesep:16,marginx:20,marginy:20}),c.setDefaultEdgeLabel(()=>({}));const p=new Map(e.groups.map(S=>[S.id,S.color??r("muted")]));for(const S of e.nodes)c.setNode(S.id,{width:160,height:90});const h=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const S of e.edges)S.kind==="derive"&&(h.has(S.relation)||c.setEdge(S.source,S.target));n.layout(c);const m=e.nodes.map(S=>{const b=c.node(S.id),w=o?S.id===o:void 0,v={kind:S.kind,label:s(S.label),bookId:S.kind==="book"?S.id:void 0,yearText:s(S.year_text??o0(S)),uncertain:S.year_uncertain,category:S.category,status:S.status,borderColor:S.group?p.get(S.group):void 0,renderLink:i,isSelected:w,description:s(S.description),bridge:S.bridge};return{id:S.id,type:"version",position:{x:b.x-160/2,y:b.y-90/2},data:v,draggable:!1,selected:w}}),u=.78,g=.06,x=new Map;for(const S of e.edges)S.kind==="derive"&&(x.has(S.source)||x.set(S.source,[]),x.get(S.source).push(S));const j=new Map;for(const[S,b]of x){if(b.length<=1)continue;const w=[...b].sort((k,z)=>{var R,T;const C=((R=c.node(k.target))==null?void 0:R.y)??0,_=((T=c.node(z.target))==null?void 0:T.y)??0;return C-_}),v=w.length;w.forEach((k,z)=>{const C=(z-(v-1)/2)*g;j.set(k.id,u+C)})}const y=e.edges.map(S=>r0(S,j.get(S.id),s));return{rfNodes:m,rfEdges:y}}function r0(e,n,i=o=>o??""){const o=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=s0(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 o0(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function s0(e){switch(e){case"certain":return r("confidence-certain");case"consensus":return r("lineage-edge-consensus");case"probable":return r("confidence-probable");case"disputed":return r("confidence-disputed");default:return r("muted")}}const gl={padding:"40px 20px",textAlign:"center",color:r("muted"),fontSize:"13px",border:`1px dashed ${r("widget-border")}`,borderRadius:8,background:r("bg")},ls=({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:m})=>{var v;const{t:u,convert:g}=re(),[x,j]=f.useState(n),y=k=>{j(k),a==null||a(k)},S=(()=>{if(!c)return[];const k=Object.entries(c);return k.length===0||c.all?k:[...k,["all",{label:u("lineage.collectionAll"),description:u("lineage.collectionAllDesc")}]]})(),b=!!(d&&S.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:r("muted"),textAlign:"center"},children:u("lineage.empty")});const w=l?(v=c==null?void 0:c[l])==null?void 0:v.description:void 0;return t.jsxs("div",{className:h,style:m,children:[t.jsxs("div",{style:a0,children:[t.jsx("button",{onClick:()=>y("list"),style:Ir(x==="list"),children:u("lineage.modeList")}),t.jsx("button",{onClick:()=>y("graph"),style:Ir(x==="graph"),children:u("lineage.modeGraph")}),b&&t.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:12,color:r("muted"),marginRight:4},children:u("lineage.collectionLabel")}),S.map(([k,z])=>{const C=p==null?void 0:p[k];return t.jsxs("button",{onClick:()=>d==null?void 0:d(k),style:Ir(l===k),title:z.description?g(z.description):void 0,children:[g(z.label),C!=null?` ${C}`:""]},k)})]})]}),b&&w&&t.jsx("div",{style:{fontSize:12,color:r("muted"),marginBottom:8,padding:"4px 8px",background:r("bg-subtle"),borderRadius:4},children:g(w)}),x==="list"?t.jsx(Xd,{graph:e,renderLink:i}):t.jsx(Zd,{graph:e,renderLink:i,height:o,selectedNodeId:s})]})},a0={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},Ir=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"}),xl=40,bl=2,l0=9,c0=new Set(["certain","consensus","probable","disputed"]);function Rr(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const Jd=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:h})=>{var de,Ie,B,pe,ie,_e,Re,He,Ye,tt,Qe;const m=Ae(),{t:u,convert:g}=re(),[x,j]=f.useState(null),[y,S]=f.useState(new Map),[b,w]=f.useState([]),[v,k]=f.useState(new Map),[z,C]=f.useState(!1),[_,R]=f.useState("flow"),[T,N]=f.useState(null);f.useEffect(()=>{if(!n||!e.work_id){j(null);return}let $=!1;return n.getItem(e.work_id).then(M=>{!$&&M&&M.type==="work"&&j(M)}).catch(()=>{}),()=>{$=!0}},[n,e.work_id]),f.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){N(null);return}let $=!1;return n.getLineageGraph(e.work_id).then(M=>{$||N(M&&M.nodes.length>1?M:null)}).catch(()=>{$||N(null)}),()=>{$=!0}},[n,e.work_id]),f.useEffect(()=>{const $=e._collections||[];if(!n||$.length===0){S(new Map);return}let M=!1;return Promise.all($.map(P=>{const X=P.id;return n.getItem(X).then(he=>[X,he]).catch(()=>[X,null])})).then(P=>{if(M)return;const X=new Map;for(const[he,se]of P)se&&X.set(he,se);S(X)}),()=>{M=!0}},[n,e._collections]);const E=f.useMemo(()=>{const $=new Set([...x?wo(x):[],...e.related_books||[]]);return $.add(e.id),[...$]},[x,e.related_books,e.id]),W=E.length-1;f.useEffect(()=>{if(!n||W<=0){w([]);return}const $=E.length<=xl,M=$?E:E.slice(0,8);let P=!1;return Promise.all(M.map(X=>X===e.id?Promise.resolve({id:X,title:e.title,edition:e.edition,year:$i(e)}):n.getItem(X).then(he=>{const se=he??{};return{id:X,title:se.title,edition:se.edition,year:he?$i(se):void 0}}).catch(()=>({id:X})))).then(X=>{if(P)return;const he=X.filter(se=>se.id===e.id||se.title||se.edition);$&&he.sort((se,We)=>(se.year??1/0)-(We.year??1/0)),w(he)}),()=>{P=!0}},[n,E,W,e]);const F=e.lineage,A=f.useMemo(()=>[...((F==null?void 0:F.derived_from)||[]).filter($=>$.ref_type==="book").map($=>$.ref),...((F==null?void 0:F.related_to)||[]).map($=>$.book_id)].filter(Boolean),[F]);f.useEffect(()=>{if(!n||A.length===0){k(new Map);return}let $=!1;return Promise.all(A.map(M=>n.getItem(M).then(P=>[M,{id:M,title:P==null?void 0:P.title,edition:P==null?void 0:P.edition}]).catch(()=>[M,{id:M}]))).then(M=>{$||k(new Map(M))}),()=>{$=!0}},[n,A]);const V=f.useMemo(()=>Vd(e.resources,e.resource_groups,u),[e.resources,e.resource_groups,u]),ae=V.groups.reduce(($,M)=>$+M.rows.length+M.mirrors.length,0),xe=V.groups.length>0&&V.groups.every($=>$.key==="_physical"),me=Xn(e),G=Kl(e),ye=Gt(e,m.unit.juan),ne=new Set((e._collections||[]).map($=>Un($.vol).length).filter($=>$>0)),U=$=>{var X;const M=(X=e.base_edition)==null?void 0:X.find(he=>he.book_id===$&&he.name);if(M!=null&&M.name)return M.name;const P=v.get($);return(P==null?void 0:P.edition)||(P==null?void 0:P.title)||""},ee=f.useMemo(()=>{var Y,H,fe,Ce,be;const $=[];G&&$.push({label:u("bookPage.fact.editionType"),value:g(G),title:e.edition_type||(Y=e.lineage)!=null&&Y.category?void 0:u("bookPage.inferredFromEdition")}),(H=e.publication_info)!=null&&H.details?$.push({label:u("bookPage.fact.publication"),value:g(e.publication_info.details)}):(me.era||me.reign)&&$.push({label:u("bookPage.fact.era"),value:g([me.era,me.reign].filter(Boolean).join(" ")),title:me.source==="edition"?u("bookPage.inferredFromEdition"):void 0}),ye&&$.push({label:u("bookPage.fact.measure"),value:g(ye)});const M=(e._collections||[]).flatMap(Q=>Un(Q.vol));M.length&&$.push({label:u("bookPage.fact.volumes"),value:u("bookPage.volumesValue",{range:Bi(M,m.unit.volume),unit:m.unit.volume,n:M.length})});const P=(((fe=e.lineage)==null?void 0:fe.derived_from)||[]).find(Q=>Q.relation==="底本"&&Q.ref_type==="book");P&&U(P.ref)&&$.push({label:u("bookPage.fact.baseEdition"),value:t.jsx(ot,{id:P.ref,label:g(U(P.ref)),onNavigate:i,renderLink:o,dense:!0})});const X=(e.base_edition||[]).filter(Q=>Q&&Q.name);for(const Q of["底本","配補","參校"]){if(Q==="底本"&&P&&U(P.ref))continue;const Ee=X.filter(ge=>ge.role===Q);Ee.length&&$.push({label:g(Q),value:Ee.map((ge,Oe)=>t.jsxs(f.Fragment,{children:[Oe>0&&"、",ge.book_id?t.jsx(ot,{id:ge.book_id,label:g(ge.name),onNavigate:i,renderLink:o,dense:!0}):g(ge.name)]},Oe))})}const he=(e.provenance||[]).filter(Q=>Q&&Q.institution),se=(e.resources||[]).filter(Q=>Vt(Q).includes("physical"));if(he.length){$.push({label:u("bookPage.fact.holdings"),value:he.slice(0,2).map(ge=>g(ge.institution)).join("、")+(he.length>2?u("bookPage.andMorePlaces",{n:he.length}):"")});const Q=he.filter(ge=>ge.call_number).slice(0,2).map(ge=>`${g(ge.institution)} ${ge.call_number}`);Q.length&&$.push({label:u("bookPage.fact.callNumber"),value:Q.join(";")+(he.filter(ge=>ge.call_number).length>2?"…":"")});const Ee=he.flatMap(ge=>ge.seals||[]).filter(Boolean);Ee.length&&$.push({label:u("bookPage.fact.seals"),value:g(Ee.join("、"))})}else se.length?$.push({label:u("bookPage.fact.holdings"),value:se.slice(0,2).map(Q=>g(Q.name)).join("、")+(se.length>2?u("bookPage.andMorePlaces",{n:se.length}):"")}):(Ce=e.current_location)!=null&&Ce.name&&$.push({label:u("bookPage.fact.holdings"),value:g(e.current_location.name)});const We=e.physical_description;if(We){const Q=[[u("bookPage.fact.leafStyle"),We.leaf_style],[u("bookPage.fact.binding"),We.binding],[u("bookPage.fact.dimensions"),We.dimensions],[u("bookPage.fact.condition"),We.condition]];for(const[Ee,ge]of Q)ge&&ge.trim()&&$.push({label:Ee,value:g(ge)})}(be=e.page_count)!=null&&be.description&&$.push({label:m.label.pageCount,value:g(e.page_count.description)});const Be=[...Kr(e.additional_titles),...Kr(e.attached_texts)];return Be.length&&$.push({label:u("bookPage.fact.aliases"),value:Be.map(g).join("、")}),$},[e,g,m,u,me,G,ye,v,i,o]),q=g(e.title),je=e.edition?g(e.edition):void 0,I=((de=e.lineage)==null?void 0:de.year_text)||"",oe=t.jsx(Jn,{kind:u("bookPage.kind"),title:q,subtitle:je,byline:t.jsx(ss,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:i,renderLink:o}),meta:(()=>{const $=[G?g(G):"",me.era?g([me.era,me.reign].filter(Boolean).join("")):"",ye?g(ye):""].filter(Boolean);return $.length?t.jsx("span",{className:"bim-d-tags",children:$.map((M,P)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(P,2)}`,children:M},P))}):null})(),description:(Ie=e.description)!=null&&Ie.text?t.jsx(Yt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:Lo((B=e.description)==null?void 0:B.text)?6:void 0,facts:ee,readAction:s,secondaryAction:s&&ae>0&&!xe?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:u("bookPage.viewImages")}):void 0,foot:t.jsx(Qn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),$e=e._collections||[],ve=(a==null?void 0:a.chapters)||[],Le=g(ve[0]&&Rr(ve[0].title)[0].slice(-1)||"")||u("bookPage.chapterUnit"),Te=u("bookPage.chapterCount",{n:ve.length,unit:Le}),Z=!!((pe=F==null?void 0:F.derived_from)!=null&&pe.length||(ie=F==null?void 0:F.related_to)!=null&&ie.length||(_e=e.appendix)!=null&&_e.length),ue=[],Pe=u(xe?"bookPage.sec.physical":"bookPage.sec.images");(ve.length||V.text.length||l)&&ue.push({id:"fulltext",label:u("bookPage.sec.fulltext"),count:ve.length?Te:void 0}),V.groups.length&&ue.push({id:"images",label:Pe,count:ae}),Z&&ue.push({id:"lineage",label:u("bookPage.sec.lineage")}),$e.length&&ue.push({id:"collections",label:u("section.containedIn"),count:$e.length}),(Re=e.location_history)!=null&&Re.length&&ue.push({id:"provenance",label:u("section.locationHistory")});const Me=$=>(d==null?void 0:d($))??null,ke=ve[0],D=ke?Me(ke.file):null,le=z?ve:ve.slice(0,l0),ce=($,M,P)=>$?t.jsx("a",{className:P,href:$.href??"#",onClick:$.onClick?X=>{X.metaKey||X.ctrlKey||(X.preventDefault(),$.onClick())}:void 0,children:M}):t.jsx("span",{className:P,children:M}),J=t.jsxs(t.Fragment,{children:[(ve.length>0||V.text.length>0||l)&&t.jsxs(ut,{id:"fulltext",title:u("bookPage.sec.fulltext"),meta:ve.length>0?t.jsx(dt,{items:[Te,(He=a==null?void 0:a.source)!=null&&He.name?u("bookPage.sourceBy",{src:g(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!ke&&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"})]}),ke&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:u("bookPage.readFrom",{ch:g(Rr(ke.title)[0])||u("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:g((ke.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),ce(D,t.jsxs(t.Fragment,{children:[u("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),ve.length>1&&t.jsx("ul",{className:"bim-d-chap",children:le.map($=>{const[M,P]=Rr($.title);return t.jsx("li",{children:ce(Me($.file),t.jsxs(t.Fragment,{children:[M&&t.jsx("b",{children:g(M)}),g(P||$.file)]}))},$.file)})}),ve.length>le.length&&t.jsx(Eo,{label:u("detail.expandRest",{n:ve.length-le.length,unit:Le}),onClick:()=>C(!0)}),V.text.length>0&&t.jsxs(t.Fragment,{children:[(ve.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:u("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:V.text.map(($,M)=>t.jsx(as,{item:$,siblings:V.text,listedVolumeCounts:ne},`${$.id||$.url||$.name}-${M}`))})})]})]}),V.groups.length>0&&t.jsx(ut,{id:"images",title:Pe,meta:t.jsx(dt,{items:[V.groups.length>1?u("bookPage.groupCount",{n:V.groups.length}):"",u("bookPage.placeCount",{n:ae})]}),children:t.jsx(Yd,{groups:V.groups,listedVolumeCounts:ne})}),Z&&t.jsx(ut,{id:"lineage",title:u("bookPage.sec.lineage"),meta:(Ye=F==null?void 0:F.derived_from)!=null&&Ye.length?u("bookPage.lineageMeta"):void 0,action:T?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":u("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":_==="flow",onClick:()=>R("flow"),children:u("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":_==="graph",onClick:()=>R("graph"),children:u("bookPage.viewGraph")})]}):void 0,children:_==="graph"&&T?t.jsx(ls,{graph:T,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:($,M)=>t.jsx(ot,{id:$,label:g(M),onNavigate:i,renderLink:o,dense:!0})}):t.jsx(p0,{data:e,heading:je||q,yearText:I,refName:U,onNavigate:i,renderLink:o})}),$e.length>0&&t.jsx(ut,{id:"collections",title:u("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:$e.map(($,M)=>{const P=$.id,X=Un($.vol),he=y.get(P),se=Im(he);return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(ot,{id:P,label:he?g(he.title):P,onNavigate:i,renderLink:o,dense:!0}),X.length>0&&t.jsx(d0,{volumes:X,unit:m.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${se?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:se>0&&u("bookPage.totalOf",{n:se,unit:m.unit.bu})})]},`${P}-${M}`)})})})}),(tt=e.location_history)!=null&&tt.length?t.jsx(ut,{id:"provenance",title:u("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map(($,M)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:g($.name)}),([$.start_date,$.end_date].filter(Boolean).join("—")||$.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(dt,{items:[[$.start_date,$.end_date].filter(Boolean).join("—"),$.description?g($.description):""]})})]},M))})}):null,ue.length===0&&t.jsx(ut,{title:u("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:u("bookPage.emptyText")})})]}),we=b.findIndex($=>$.id===e.id),Fe=E.length<=xl,Ve=Fe&&we>=0?b.slice(Math.max(0,we-bl),we+bl+1):b.filter($=>$.id!==e.id),Ze=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:g(m.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(ot,{id:x.id,label:g(x.title),onNavigate:i,renderLink:o})}),t.jsx(dt,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map($=>`${$.dynasty?`〔${g($.dynasty)}〕`:""}${g($.name)}`),g(Gt(x,m.unit.juan)),x._edition_count?u("bookPage.editionCount",{n:x._edition_count}):""]}),((Qe=x.description)==null?void 0:Qe.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:g(x.description.text.replace(/[#*_>`[\]]/g,""))})]}),W>0&&Ve.length>0&&t.jsxs("div",{children:[t.jsx(dn,{id:"siblings",timeline:!0,title:Fe?u("bookPage.siblings"):m.relation.siblingVersions,meta:Fe?u("bookPage.byEra"):u("bookPage.kindCount",{n:W}),cap:Ve.length,items:Ve.map($=>$.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:g($.edition||$.title||$.id)}):t.jsx(ot,{id:$.id,label:g($.edition||$.title||$.id),onNavigate:i,renderLink:o,dense:!0})),metas:Ve.map($=>[$.year!=null?$.year<0?u("detail.bce",{n:-$.year}):String($.year):"",$.id===e.id?u("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:Ve.findIndex($=>$.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(ot,{id:x.id,label:u("bookPage.viewAllInWork",{n:E.length}),onNavigate:i,renderLink:o,dense:!0})})]})]}),O=e.work_id?t.jsx(Lc,{caption:m.section.belongsToWork,children:t.jsx(ot,{id:e.work_id,label:x?g(x.title):" ",onNavigate:i,renderLink:o,dense:!0})}):void 0;return t.jsx(Zn,{railTop:c,back:p,up:O,nav:ue,railLinks:h,main:J,card:oe,side:Ze})};function d0({volumes:e,unit:n}){const{t:i}=re();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[i("bookPage.volumeRange",{range:Bi(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 p0({data:e,heading:n,yearText:i,refName:o,onNavigate:s,renderLink:a}){var S;const{t:l,convert:d}=re(),c=e.lineage,p=(c==null?void 0:c.derived_from)||[],h=p.filter(b=>b.ref_type!=="book"),m=p.filter(b=>b.ref_type==="book"&&b.relation==="底本"),u=p.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),g=(c==null?void 0:c.related_to)||[],x=p.length>0||g.length>0,j=b=>b&&c0.has(b)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${b}`)}):"",y=(b,w)=>t.jsx(ot,{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),j(b.confidence)]})]})},`a-${w}`)),m.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),j(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)})]}),u.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:u.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),j(b.confidence)]})]},w))})]}),g.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:g.map((b,w)=>t.jsxs("span",{className:"bim-d-lf-chip",title:b.evidence?d(b.evidence):void 0,children:[y(b.book_id,o(b.book_id)),t.jsx("span",{className:"bim-d-meta",children:d(b.relation)})]},w))})]})]}),(S=e.appendix)==null?void 0:S.map((b,w)=>t.jsxs("details",{className:"bim-d-lf-app",children:[t.jsxs("summary",{className:"bim-d-ui",children:[t.jsx("span",{className:"bim-d-meta",children:l("bookPage.lineage.appendix")})," ",d(b.title)]}),t.jsx(Yt,{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 Fn=16,u0=200,m0=16,Qd=({data:e,catalog:n,transport:i,onNavigate:o,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var we,Fe,Ve,Ze,O,de,Ie;const{t:p,convert:h,messages:m}=re(),[u,g]=f.useState(""),[x,j]=f.useState(!1),[y,S]=f.useState(null),[b,w]=f.useState(""),[v,k]=f.useState(!1),z=f.useMemo(()=>ql(e,n),[e,n]),C=f.useMemo(()=>Yl(e),[e]),[_,R]=f.useState(new Map),T=!!i&&z.rows.length>0&&z.rows.length<=u0,N=T&&(z.rows.length<=Fn||v),E=N&&z.rows.every(B=>!B.id||_.has(B.id)),W=B=>{var pe;return oo(B?(pe=_.get(B))==null?void 0:pe.l1:void 0)},F=f.useMemo(()=>{const B=u.trim(),pe=B?h(B):"";return z.rows.filter(ie=>{var Re,He;if(b&&oo(ie.id?(Re=_.get(ie.id))==null?void 0:Re.l1:void 0)!==b)return!1;if(!pe)return!0;const _e=ie.id&&((He=_.get(ie.id))==null?void 0:He.title)||ie.title;return h(_e).includes(pe)||(ie.subItems||[]).some(Ye=>h(Ye).includes(pe))})},[z.rows,u,b,_,h]),A=x?F:F.slice(0,Fn),V=f.useMemo(()=>(N?z.rows:A).filter(B=>B.id&&!_.has(B.id)).map(B=>B.id),[N,z.rows,A,_]);f.useEffect(()=>{if(!i||V.length===0)return;let B=!1;const pe=V.slice(0,m0);return qi(pe,Yi,ie=>i.getItem(ie).then(_e=>{var Ye,tt;const Re=_e??{},He={title:Re.title,edition:Re.edition,authors:Re.authors,measure:_e?Gt(_e,m.unit.juan):void 0,versionCount:Re._edition_count??((Ye=Re._books)==null?void 0:Ye.length),l1:((tt=So(Re))==null?void 0:tt.l1)||void 0};return[ie,He]}).catch(()=>[ie,{}]),()=>B).then(ie=>{B||R(_e=>{const Re=new Map(_e);for(const[He,Ye]of ie)Re.set(He,Ye);return Re})}),()=>{B=!0}},[i,V,m.unit.juan]);const ae=(we=(e.contained_in||[])[0])==null?void 0:we.id;f.useEffect(()=>{if(!ae){S(null);return}if(S({id:ae}),!i)return;let B=!1;return i.getItem(ae).then(pe=>{B||S({id:ae,title:pe==null?void 0:pe.title})}).catch(()=>{}),()=>{B=!0}},[i,ae]);const xe=f.useMemo(()=>Vd(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),me=xe.text.length+xe.groups.reduce((B,pe)=>B+pe.rows.length+pe.mirrors.length,0),G=C.works,ye=new Set(z.rows.map(B=>B.id).filter(Boolean)),ne=G.length>0&&!G.every(B=>ye.has(B.id)),U=(()=>{const B=z.rows.map(pe=>pe.edition).filter(Boolean);return B.length>1&&new Set(B).size===1})(),ee=z.rows.some(B=>B.volumes.length>0||B.expected!=null),q=C.total,je=C.truncated?q:z.rows.length,I=Gt(e,m.unit.juan),oe=e.count,$e=B=>typeof B=="number"&&Number.isFinite(B)?B:null,ve=$e(oe==null?void 0:oe.juan)??$e((Fe=e.juan_count)==null?void 0:Fe.number),Le=$e(oe==null?void 0:oe.ce)??(z.totalVolumes||null),Te=[{value:je,label:p("collectionPage.stat.titles")},{value:ve??0,label:m.unit.juan},{value:Le??0,label:m.unit.volume}],Z=f.useMemo(()=>{var ie,_e;const B=[];if((ie=e.publication_info)!=null&&ie.details&&B.push({label:p("collectionPage.fact.publication"),value:h(e.publication_info.details)}),q&&(q!==z.rows.length||C.truncated)){const Re=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");B.push({label:Re,value:`${q} ${m.unit.bu}`,title:p("collectionPage.memberNote")})}const pe=[$e(oe==null?void 0:oe.zhong)!=null?p("collectionPage.nZhong",{n:oe.zhong}):"",$e(oe==null?void 0:oe.han)!=null?p("collectionPage.nHan",{n:oe.han}):""].filter(Boolean);return pe.length&&B.push({label:p("collectionPage.fact.expected"),value:pe.join(" ")}),ve==null&&I&&B.push({label:p("collectionPage.fact.measure"),value:h(I),title:(_e=e.juan_count)!=null&&_e.description?h(e.juan_count.description):void 0}),B},[e,q,C.truncated,z.rows.length,ve,I,oe,h,p,m]),ue=f.useMemo(()=>{if(!E)return[];const B=new Map;for(const ie of z.rows){const _e=W(ie.id);_e&&B.set(_e,(B.get(_e)??0)+1)}const pe=Yn.filter(ie=>(B.get(ie.key)??0)>0);return pe.length<2?[]:[{key:"",label:`${m.catalog.all} ${je}`},...pe.map(ie=>({key:ie.key,label:`${ie.label} ${B.get(ie.key)}`}))]},[E,z.rows,_,m]),Pe=f.useMemo(()=>{if(!E||!z.rows.some(_e=>_e.volumes.length>0))return null;const B=[],pe=z.rows.filter(_e=>_e.volumes.length>0).map(_e=>({k:W(_e.id)??"",from:Math.min(..._e.volumes),to:Math.max(..._e.volumes)})).sort((_e,Re)=>_e.from-Re.from);for(const _e of pe){const Re=_e.to-_e.from+1,He=B[B.length-1];He&&He.key===_e.k?(He.to=Math.max(He.to,_e.to),He.n+=Re):B.push({key:_e.k,from:_e.from,to:_e.to,n:Re})}const ie=pe.reduce((_e,Re)=>Math.max(_e,Re.to),0);return B.length>1&&B.some(_e=>_e.key)?{segs:B,last:ie}:null},[E,z.rows,_]),Me=(Ve=e.description)==null?void 0:Ve.text,ke=t.jsx(Jn,{kind:p("collectionPage.kind"),title:h(e.title),byline:t.jsx(ss,{authors:e.authors,onNavigate:o,renderLink:s}),meta:t.jsx(dt,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(Ze=e.publication_info)!=null&&Ze.year?h(e.publication_info.year):""]}),description:Me||(O=e.history)!=null&&O.length?t.jsxs(t.Fragment,{children:[Me&&t.jsx(Yt,{text:Me,style:{fontSize:15,lineHeight:1.85}}),(de=e.history)!=null&&de.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((B,pe)=>t.jsx("li",{children:h(B)},pe))}):null]}):void 0,clampDescription:Lo(Me)||(((Ie=e.history)==null?void 0:Ie.length)??0)>2?6:void 0,stats:Te,facts:Z,foot:t.jsx(Qn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:Pe&&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:Pe.segs.map((B,pe)=>{const ie=Yn.find(_e=>_e.key===B.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!ie,title:ie?p("collectionPage.dist.segTitle",{section:h(ie.label),from:B.from,to:B.to}):void 0,"aria-label":ie?p("collectionPage.dist.only",{section:h(ie.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!ie&&b===B.key,style:{flexGrow:B.n,background:r(ie?ie.token:"rule")},onClick:()=>{ie&&(w(b===B.key?"":B.key),j(!1))}},pe)})}),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:Pe.last})})]})]})}),D=[];z.rows.length&&D.push({id:"titles",label:p("collectionPage.sec.titles"),count:je}),me&&D.push({id:"resources",label:p("collectionPage.sec.resources"),count:me}),ne&&D.push({id:"works",label:m.section.containedWorks,count:G.length});const le=t.jsxs(t.Fragment,{children:[z.rows.length>0&&t.jsxs(ut,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(dt,{items:[`${je} ${m.unit.items}`,z.totalVolumes?p("collectionPage.totalVolumes",{n:z.totalVolumes,unit:m.unit.volume}):"",F.length!==je?p("collectionPage.currentN",{n:F.length,unit:m.unit.items}):""]}),action:a,children:[(z.rows.length>Fn||ue.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[ue.length>0&&t.jsx(Di,{items:ue,value:b,onChange:B=>{w(B),j(!1)}}),T&&z.rows.length>Fn&&!E&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:v,onClick:()=>k(!0),title:p("collectionPage.loadAllTitle",{n:z.rows.length,unit:m.unit.items}),children:p(v?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),z.rows.length>Fn&&t.jsx("input",{type:"search",className:"bim-d-find",value:u,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:B=>{g(B.target.value),j(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Ui(F.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[ee&&t.jsx("th",{style:{width:"8.5em"},children:p("collectionPage.col.volumes")}),t.jsx("th",{children:p("collectionPage.col.title")}),t.jsx("th",{style:{textAlign:"right"},children:p("collectionPage.col.versions")})]})}),t.jsx("tbody",{children:A.map((B,pe)=>{var Qe;const ie=B.id?_.get(B.id):void 0,_e=ie!=null&&ie.title&&B.title===B.id?ie.title:B.title,Re=((ie==null?void 0:ie.authors)||[]).find($=>$&&$.name),He=[Re?`${Re.dynasty?`〔${h(Re.dynasty)}〕`:""}${h(Re.name)}${Re.role?` ${h(Re.role)}`:""}`:"",ie!=null&&ie.measure?h(ie.measure):"",(Qe=B.subItems)!=null&&Qe.length?B.subItems.map($=>h($)).join("、"):"",(ie!=null&&ie.edition||B.edition)&&!U?h((ie==null?void 0:ie.edition)||B.edition||""):""].filter(Boolean),Ye=Yn.find($=>$.key===W(B.id)),tt=B.volumes.length>0?p("collectionPage.volumeRange",{range:Bi(B.volumes,m.unit.volume),unit:m.unit.volume}):B.expected!=null?`${B.found??0}/${B.expected} ${m.unit.volume}`:"";return t.jsxs("tr",{children:[ee&&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:[B.id?t.jsx(ot,{id:B.id,label:h(_e),onNavigate:o,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:h(_e)}),He.length>0?t.jsx(dt,{items:He}):B.id&&!ie&&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${ie!=null&&ie.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:ie!=null&&ie.versionCount?p("collectionPage.nZhong",{n:ie.versionCount}):""})]},`${B.id??B.title}-${pe}`)})})]}),A.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!x&&t.jsx(Ro,{total:F.length,shown:A.length,unit:m.unit.items,onClick:()=>j(!0)})]}),me>0&&t.jsxs(ut,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:me}),children:[xe.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[xe.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:xe.text.map((B,pe)=>t.jsx(as,{item:B,siblings:xe.text},`${B.id||B.url||B.name}-${pe}`))})})]}),t.jsx(Yd,{groups:xe.groups})]}),z.rows.length===0&&me===0&&t.jsx(ut,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),ce=ne?t.jsx(dn,{id:"works",title:m.section.containedWorks,meta:p("collectionPage.nZhong",{n:G.length}),cap:12,items:G.map(B=>t.jsx(ot,{id:B.id,label:h(B.title),onNavigate:o,renderLink:s,dense:!0}))}):null,J=y?t.jsx(Lc,{caption:p("collectionPage.parent"),children:t.jsx(ot,{id:y.id,label:h(y.title||y.id),onNavigate:o,renderLink:s,dense:!0})}):void 0;return t.jsx(Zn,{railTop:l,back:d,up:J,nav:D,railLinks:c,main:le,card:ke,side:ce})},h0=8;function ep(e){return typeof e!="string"||!e||e.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.split("/").some(n=>n==="..")?null:e}function f0(e){return(e||[]).filter(n=>{var i,o;return ep(n==null?void 0:n.file)&&((i=n.credit)==null?void 0:i.trim())&&((o=n.license)==null?void 0:o.trim())}).slice(0,h0)}function g0({images:e,assetBase:n,name:i}){const{t:o,convert:s}=re(),[a,l]=f.useState(0),[d,c]=f.useState(!1),p=n?f0(e):[];if(!n||d||p.length===0)return null;const h=n.endsWith("/")?n:n+"/",m=p[Math.min(a,p.length-1)],u=m.width&&m.height&&m.width>0&&m.height>0?`${m.width} / ${m.height}`:void 0,g=x=>h+ep(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:g(m),alt:o("entityPage.sealAlt",{name:i})+(p.length>1?` ${a+1}`:""),style:u?{"--seal-ar":u}:void 0,width:m.width,height:m.height,decoding:"async",fetchPriority:"high",onError:()=>c(!0)},m.file),p.length>1&&t.jsx("div",{className:"bim-d-seal-thumbs",children:p.map((x,j)=>t.jsx("button",{type:"button","aria-pressed":j===a,"aria-label":`${o("entityPage.sealAlt",{name:i})} ${j+1}`,onClick:()=>l(j),children:t.jsx("img",{src:g(x),alt:"",loading:"lazy",decoding:"async"})},x.file))}),t.jsxs("figcaption",{children:[o("entityPage.imgCredit",{credit:s(m.credit)})," · ",o("entityPage.imgLicense",{license:s(m.license)}),m.source_url&&/^https?:\/\//i.test(m.source_url)&&t.jsxs(t.Fragment,{children:[" · ",t.jsx("a",{href:m.source_url,target:"_blank",rel:"noopener noreferrer nofollow",children:o("entityPage.imgSource")})]}),m.note&&t.jsxs(t.Fragment,{children:[" · ",s(m.note)]})]})]})}const x0=16,Er=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function yl(e){if(!e)return Er.length;const n=Er.indexOf(e);return n===-1?Er.length:n}function b0(e,n,i){if(n)return e[n]??i(n)}function y0(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const j0={秦:[-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]},tp=({data:e,transport:n,onNavigate:i,renderLink:o,railTop:s,back:a,railLinks:l,assetBase:d})=>{var J,we,Fe,Ve,Ze;const{t:c,convert:p,messages:h}=re(),m=O=>y0(O,c),[u,g]=f.useState("全部"),[x,j]=f.useState(!1),[y,S]=f.useState("default"),[b,w]=f.useState(new Map),v=f.useMemo(()=>e._works||[],[e._works]),k=f.useMemo(()=>v.map(O=>{const de=b.get(O.work_id);return{id:O.work_id,title:(de==null?void 0:de.title)??O.title??O.work_id,role:O.role||"",cls:vo(O.role),versionCount:de==null?void 0:de.versionCount,section:de==null?void 0:de.cls,l1:de==null?void 0:de.l1,measure:de==null?void 0:de.measure,hasImage:de==null?void 0:de.hasImage,loaded:!!(de!=null&&de.loaded)}}),[v,b]),z=f.useMemo(()=>Gl(v.map(O=>O.role),c("detail.roleAll")),[v,c]),C=f.useMemo(()=>{const O=u==="全部"?k:k.filter(de=>de.cls===u);return y==="versions"?[...O].sort((de,Ie)=>(Ie.versionCount??-1)-(de.versionCount??-1)):O},[k,u,y]),_=x?C:C.slice(0,x0),R=f.useMemo(()=>_.filter(O=>!b.has(O.id)).map(O=>O.id),[_,b]);f.useEffect(()=>{if(!n||R.length===0)return;let O=!1;return qi(R,Yi,de=>n.getItem(de).then(Ie=>{var Re;const B=Ie??{},pe=B._edition_count??((Re=B._books)==null?void 0:Re.length)??0,ie=So(B),_e=[ie==null?void 0:ie.l1,ie==null?void 0:ie.l2].filter(Boolean).join(" ");return[de,{id:de,title:B.title,versionCount:pe,loaded:!0,cls:_e||void 0,l1:(ie==null?void 0:ie.l1)||void 0,measure:Ie&&Gt(Ie,h.unit.juan)||void 0,hasImage:!!B._has_image}]}).catch(()=>[de,{id:de,loaded:!0}]),()=>O).then(de=>{O||w(Ie=>{const B=new Map(Ie);for(const[pe,ie]of de)B.set(pe,ie);return B})}),()=>{O=!0}},[n,R,h.unit.juan]);const T=f.useMemo(()=>{const O=new Map;for(const de of e.alt_names||[]){const Ie=de.type||h.section.aliases;O.has(Ie)||O.set(Ie,[]),O.get(Ie).push(de.name)}return[...O.entries()].sort((de,Ie)=>yl(de[0])-yl(Ie[0])).map(([de,Ie])=>({label:de,names:Ie}))},[e.alt_names,h]),N=((J=e.dates)==null?void 0:J.birth)??void 0,E=((we=e.dates)==null?void 0:we.death)??void 0,W=(Fe=e.dates)==null?void 0:Fe.floruit,F=N!=null||E!=null?`${m(N)||"?"}—${m(E)||"?"}`:Array.isArray(W)&&W.length===2&&W.every(O=>Number.isFinite(O))?c("entityPage.floruit",{from:m(W[0]),to:m(W[1])}):"",A=new Set(["本名","字","號","号"]),V=T.filter(O=>A.has(O.label)),ae=T.filter(O=>!A.has(O.label)),xe=ae.reduce((O,de)=>O+de.names.length,0),me=f.useMemo(()=>{const O=[];for(const Ie of V)O.push({label:Ie.label,value:Ie.names.map(B=>p(B)).join("、")});const de=v.length;return de&&O.push({label:c("entityPage.fact.works"),value:c("entityPage.nZhong",{n:de})}),O},[v,V,p,c]),G=O=>{var de;return(de=T.find(Ie=>O.includes(Ie.label)))==null?void 0:de.names[0]},ye=G(["字"]),ne=G(["號","号"]),U=[ye?c("entityPage.zi",{name:p(ye)}):"",ne?c("entityPage.hao",{name:p(ne)}):""].filter(Boolean).join(","),ee=e.native_place,q=e.dynasty?j0[e.dynasty]:void 0,je=(()=>{if(!q||N==null||E==null||E<N)return null;const[O,de]=q,Ie=Math.max(N,O),B=Math.min(E,de);if(B<=Ie)return null;const pe=de-O;return t.jsxs("div",{className:"bim-d-life bim-d-ui",children:[t.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":c("entityPage.lifeAria",{birth:m(N),death:m(E),years:E-N+1}),children:t.jsx("i",{style:{left:`${(Ie-O)/pe*100}%`,width:`${(B-Ie)/pe*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${m(O)} ${p(e.dynasty)}`}),t.jsx("span",{children:c("entityPage.lifeYears",{years:E-N+1})}),t.jsx("span",{children:m(de)})]})]})})(),I=f.useMemo(()=>{if(!n||k.length===0||k.some(Ie=>!Ie.loaded))return null;const O=new Map;for(const Ie of k){const B=oo(Ie.l1);B&&O.set(B,(O.get(B)??0)+1)}const de=Yn.map(Ie=>({...Ie,n:O.get(Ie.key)??0})).filter(Ie=>Ie.n>0);return de.length?de:null},[k,n]),oe=t.jsxs(Jn,{kind:b0(h.entityPage.subtype,e.subtype,p),title:p(e.primary_name||e.title),subtitle:U||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(dt,{items:[e.dynasty?p(e.dynasty):"",F,ee?c("entityPage.nativePlace",{place:p(ee)}):""]}),je,t.jsx(g0,{images:e.images,assetBase:d,name:p(e.primary_name||e.title)})]}),description:(Ve=e.description)!=null&&Ve.text?t.jsx(Yt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:Lo((Ze=e.description)==null?void 0:Ze.text)?6:void 0,facts:me,foot:t.jsx(Qn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[xe>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:c("entityPage.moreNames",{n:xe})}),t.jsx("dl",{children:ae.map(O=>t.jsxs(f.Fragment,{children:[t.jsx("dt",{children:p(O.label)}),t.jsx("dd",{children:O.names.map(de=>p(de)).join("、")})]},O.label))})]}),I&&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:I.map(O=>t.jsx("i",{style:{flexGrow:O.n,background:r(O.token)}},O.key))}),t.jsx("div",{className:"bim-d-dist-key",children:I.map(O=>t.jsxs("span",{children:[t.jsx("i",{style:{background:r(O.token)}}),p(O.label)," ",O.n]},O.key))})]})]}),$e=f.useMemo(()=>k.filter(O=>O.loaded&&(O.versionCount??0)>0).sort((O,de)=>(de.versionCount??0)-(O.versionCount??0)).slice(0,3),[k]),ve=!!n&&k.length>=3&&_.some(O=>!O.loaded),Le=u==="全部"&&(ve||$e.length>=2),Te=e.external_ids||{},Z=[];Te.cbdb_id!=null&&Z.push({label:"CBDB",id:String(Te.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${Te.cbdb_id}`,note:Te.cbdb_match==="auto"?c("entityPage.autoMatch"):void 0});const ue=Te.wikidata_id;ue&&Z.push({label:"Wikidata",id:ue,href:`https://www.wikidata.org/wiki/${ue}`});const Pe=Te.viaf_id;Pe&&Z.push({label:"VIAF",id:Pe,href:`https://viaf.org/viaf/${Pe}`});const Me=z.map(O=>({key:O.cls,label:`${O.label} ${O.count}`})),ke=[...Le&&!ve?[{id:"featured",label:c("entityPage.sec.featured"),count:$e.length}]:[],...k.length?[{id:"works",label:c("entityPage.sec.allWorks"),count:k.length}]:[],...Z.length?[{id:"external",label:c("entityPage.sec.external"),count:Z.length}]:[]],D=Le?t.jsxs(ut,{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":ve||void 0,children:[ve&&[0,1,2].map(O=>t.jsxs("div",{className:"bim-d-pick","aria-hidden":"true",children:[t.jsx("span",{className:"bim-d-pick-t",children:" "}),t.jsx("span",{className:"bim-d-meta",children:" "}),t.jsx("div",{className:"bim-d-pick-n",children:" "})]},O)),!ve&&$e.map(O=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(ot,{id:O.id,label:p(O.title),onNavigate:i,renderLink:o,dense:!0})}),t.jsx(dt,{items:[O.section?p(O.section):"",O.measure?p(O.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:O.versionCount}),t.jsx("span",{children:c("entityPage.versionsUnit")}),O.hasImage&&t.jsx("span",{className:"bim-d-flag",children:c("entityPage.hasImage")})]})]},O.id))]})]}):null,le=k.length===0?t.jsx(ut,{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:[D,t.jsxs(ut,{id:"works",title:c("entityPage.sec.works"),meta:t.jsx(dt,{items:[c("entityPage.total",{n:k.length}),C.length!==k.length?c("entityPage.current",{n:C.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[Me.length>1&&t.jsx(Di,{items:Me,value:u,onChange:O=>{g(O),j(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":y==="versions",onClick:()=>{y==="default"&&j(!0),S(O=>O==="default"?"versions":"default")},children:c(y==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Ui(C.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(O=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(ot,{id:O.id,label:p(O.title),onNavigate:i,renderLink:o,dense:!0}),O.measure?t.jsx(dt,{items:[p(O.measure)]}):!O.loaded&&n?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${O.section||O.loaded?"":" bim-d-zt-blank"}`,children:O.section?p(O.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${O.role?"":" bim-d-zt-blank"}`,children:O.role?p(O.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${O.loaded?"":" bim-d-zt-blank"}`,children:O.loaded?O.versionCount?c("entityPage.nZhong",{n:O.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:c("entityPage.notRecorded")}):""}),t.jsx("td",{className:O.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:O.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:c("entityPage.hasImage")})})]},O.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(Ro,{total:C.length,shown:_.length,unit:c("entityPage.moreUnit"),onClick:()=>j(!0)})]})]}),ce=Z.length>0?t.jsx(dn,{id:"external",title:c("entityPage.sec.external"),items:Z.map(O=>t.jsxs("a",{href:O.href,target:"_blank",rel:"noopener noreferrer",children:[O.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:Z.map(O=>O.id),foot:Te.cbdb_id!=null&&Te.cbdb_match==="auto"?c("entityPage.cbdbAuto"):void 0}):null;return t.jsx(Zn,{railTop:s,back:a,nav:ke,railLinks:l,main:le,card:oe,side:ce})},cs="(max-width: 719px)",v0=`${cs}, (pointer: coarse)`,np=`
|
|
1407
1407
|
.bim-ct {
|
|
1408
1408
|
display: grid; grid-template-columns: 248px minmax(0, 1fr); column-gap: 32px; align-items: start;
|
|
1409
1409
|
max-width: 1440px; margin: 0 auto; padding: 20px 32px 48px; box-sizing: border-box;
|
|
@@ -1511,7 +1511,7 @@ ${D??""}`,[Tn,bs]=f.useState({key:Nn,data:H,started:!!H});if(Tn.key!==Nn)bs({key
|
|
|
1511
1511
|
.bim-ct-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1512
1512
|
}
|
|
1513
1513
|
|
|
1514
|
-
@media ${
|
|
1514
|
+
@media ${cs} {
|
|
1515
1515
|
.bim-ct { display: block; padding: 12px 16px 40px; }
|
|
1516
1516
|
.bim-ct-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
|
|
1517
1517
|
.bim-ct-lrow > a { grid-template-columns: minmax(0, 1fr); }
|
|
@@ -1562,7 +1562,7 @@ ${D??""}`,[Tn,bs]=f.useState({key:Nn,data:H,started:!!H});if(Tn.key!==Nn)bs({key
|
|
|
1562
1562
|
/* 窄屏分类抽屉:界栏下按钮和面板都有框 */
|
|
1563
1563
|
:root[data-layout="boxed"] .bim-ct-drawer-btn { border: ${r("fr-bd")}; background: ${r("fr-bg")}; }
|
|
1564
1564
|
:root[data-layout="boxed"] .bim-ct-drawer { border: ${r("fr-bd")}; }
|
|
1565
|
-
`,on="未分類",Wt="all",cs=20;function ei(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 k0(e){const n=ei(e);return n.length?n.join("/"):on}function w0(e){const n=ei(e);return n.length?n.map((i,o)=>n.slice(0,o+1).join("/")):[on]}function S0(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,m)=>{const u=p.slice(0,m+1).join("/");i.has(u)||i.set(u,c)})});const o=new Map;let s=0;for(const d of e){const c=ei(d.classification);if(!c.length){s++;continue}let p=o;c.forEach((h,m)=>{const u=c.slice(0,m+1).join("/");let g=p.get(h);g||(g={id:u,label:h,count:0,children:new Map},p.set(h,g)),g.count++,p=g.children})}const a=d=>[...d.values()].sort((c,p)=>{const h=c.label===on?1:0,m=p.label===on?1:0;if(h!==m)return h-m;const u=i.get(c.id)??1/0,g=i.get(p.id)??1/0;return u!==g?u-g: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:on,label:on,count:s}),l}function xn(e,n){if(!n)return[];for(const i of e){if(i.id===n)return[i];if(i.children){const o=xn(i.children,n);if(o.length)return[i,...o]}}return[]}function ds(e){return e.reduce((n,i)=>n+i.count,0)}function _0(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function $0(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=_0(typeof e.description=="string"?e.description:(d=e.description)==null?void 0:d.text);a&&(n.summary=a);const l=ei(e.classification);return l.length&&(n.classification=l),n}function C0(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 z0(e,n=cs){return Math.max(1,Math.ceil(e/n))}function ip(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 N0=()=>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 T0(e,n,i){const o=[];i&&o.push({id:Wt,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 rp({tree:e,selectedId:n,onSelect:i,allLabel:o,label:s}){const{t:a,convert:l}=re(),d=o===void 0?a("catalogPage.all"):o,c=s??a("catalogPage.classification"),p=f.useRef(null),h=n&&n!==Wt?n:null,m=d!==null,[u,g]=f.useState(()=>{const _=new Set;for(const R of xn(e,h))_.add(R.id);return _});f.useEffect(()=>{const _=xn(e,h);_.length&&g(R=>{if(_.every(N=>R.has(N.id)))return R;const T=new Set(R);for(const N of _)T.add(N.id);return T})},[e,h]);const x=f.useMemo(()=>T0(e,u,m),[e,u,m]),[j,y]=f.useState(null);f.useEffect(()=>{y(null)},[n]);const S=h??(m?Wt:null),b=f.useMemo(()=>{var T;const _=new Set(x.map(N=>N.id));if(j&&_.has(j))return j;if(S&&_.has(S))return S;const R=xn(e,h).map(N=>N.id).filter(N=>_.has(N));return R.length?R[R.length-1]:((T=x[0])==null?void 0:T.id)??null},[x,j,S,e,h]),w=f.useCallback((_,R)=>{g(T=>{const N=T.has(_),E=R??!N;if(E===N)return T;const W=new Set(T);return E?W.add(_):W.delete(_),W})},[]),v=f.useCallback(_=>{y(_),requestAnimationFrame(()=>{var T;const R=Array.from(((T=p.current)==null?void 0:T.querySelectorAll("[data-ct-id]"))??[]).find(N=>N.dataset.ctId===_);R==null||R.focus()})},[]),k=f.useCallback((_,R)=>{R&&w(_,!0),i(_)},[i,w]),z=f.useCallback(_=>{const R=_.target.closest("[data-ct-id]");if(!R)return;const T=R.dataset.ctId,N=x.findIndex(F=>F.id===T);if(N<0)return;const E=x[N];let W=null;switch(_.key){case"ArrowDown":W=x[Math.min(x.length-1,N+1)].id;break;case"ArrowUp":W=x[Math.max(0,N-1)].id;break;case"Home":W=x[0].id;break;case"End":W=x[x.length-1].id;break;case"ArrowRight":if(!E.hasChildren)break;u.has(T)?W=E.firstChildId:w(T,!0);break;case"ArrowLeft":E.hasChildren&&u.has(T)?w(T,!1):W=E.parentId;break;case"Enter":case" ":_.preventDefault(),k(T,E.hasChildren);return;default:return}_.preventDefault(),W&&W!==T&&v(W)},[x,u,w,v,k]),C=(_,R)=>_.map((T,N)=>{var V;const E=(V=T.children)!=null&&V.length?T.children:null,W=!!E&&u.has(T.id),F=T.id===h,A=R===1&&_.length>1&&N===_.length-1;return t.jsxs("li",{role:"treeitem","aria-level":R,"aria-expanded":E?W:void 0,"aria-selected":F,tabIndex:b===T.id?0:-1,"data-ct-id":T.id,className:A?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":R-1},onClick:()=>{y(T.id),k(T.id,!!E)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:E?ae=>{ae.stopPropagation(),y(T.id),w(T.id)}:void 0,children:E?t.jsx(N0,{}):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")})]}),W&&t.jsx("ul",{role:"group",children:C(E,R+1)})]},T.id)});return t.jsxs("ul",{ref:p,role:"tree","aria-label":l(c),className:"bim-ct-tree",onKeyDown:z,children:[m&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!h,tabIndex:b===Wt?0:-1,"data-ct-id":Wt,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(Wt),i(Wt)},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:ds(e).toLocaleString("en-US")})]})}),C(e,1)]})}const op=e=>`/item/${encodeURIComponent(e)}`;function I0(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function sp(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function ap({work:e,href:n}){var d,c;const{t:i,convert:o}=re(),s=sp(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(f.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 lp({work:e,href:n}){var d,c;const{t:i,convert:o}=re(),s=sp(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(f.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 cp({page:e,pageCount:n,onPage:i,pageHref:o,label:s}){const{t:a,convert:l}=re();if(n<=1)return null;const d=p=>h=>{i&&(o&&!I0(h)||(h.preventDefault(),i(p)))},c=(p,h,m)=>{if(m.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:h});const u={className:"bim-ct-pg","aria-current":m.current?"page":void 0,"aria-label":m.aria};return o?t.jsx("a",{...u,href:o(p),onClick:d(p),children:h}):t.jsx("button",{type:"button",...u,onClick:m.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:ip(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 dp({works:e,workLink:n=op,emptyText:i,view:o="card",...s}){const{t:a,convert:l}=re();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(lp,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(ap,{work:d,href:n(d.id)},d.id))}),t.jsx(cp,{...s})]})}const R0=()=>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 E0({tree:e,selectedId:n,page:i,pageCount:o,works:s,onSelect:a,onPage:l,searchSlot:d,workLink:c,pageHref:p,allLabel:h,allTitle:m,pageSize:u=cs,className:g,view:x,onViewChange:j}){const{t:y,convert:S}=re(),b=h===void 0?y("catalogPage.all"):h,w=m??y("catalogPage.allTitle"),k=`bim-ct-drawer-${f.useId().replace(/:/g,"")}`,[z,C]=f.useState(!1),[_,R]=f.useState("card"),T=x??_,N=ae=>{R(ae),j==null||j(ae)},E=xn(e,n&&n!==Wt?n:null),W=E.length?E[E.length-1]:null,F=W?W.label:w,A=W?W.count:ds(e),V=f.useCallback(ae=>{C(!1),a(ae)},[a]);return t.jsxs("div",{className:g?`bim-ct ${g}`:"bim-ct","data-drawer":z?"open":"closed",children:[t.jsx("style",{children:np}),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":z,"aria-controls":k,onClick:()=>C(ae=>!ae),children:[t.jsx("span",{children:y("catalogPage.drawerLabel",{path:S(E.length?E.map(ae=>ae.label).join(" › "):b??w)})}),t.jsx(R0,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:k,children:[t.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),t.jsx(rp,{tree:e,selectedId:n,onSelect:V,allLabel:b})]})]}),t.jsxs("div",{className:"bim-ct-main",children:[t.jsxs("header",{className:"bim-ct-head",children:[t.jsx("h1",{className:"bim-ct-title",children:S(F)}),E.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:S(E.slice(0,-1).map(ae=>ae.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:A.toLocaleString("en-US"),size:u}),o>1&&y("catalogPage.statPage",{page:i,pages:o})]}),t.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":y("catalogPage.viewLabel"),children:[t.jsx("button",{type:"button","aria-pressed":T==="card",onClick:()=>N("card"),children:y("catalogPage.viewCard")}),t.jsx("button",{type:"button","aria-pressed":T==="list",onClick:()=>N("list"),children:y("catalogPage.viewList")})]})]}),d&&t.jsx("div",{className:"bim-ct-search",children:d}),t.jsx(dp,{works:s,view:T,workLink:c,page:i,pageCount:o,onPage:l,pageHref:p})]})]})}const ti="(max-width: 719px)",L0="(max-width: 1079px)",A0=`${ti}, (pointer: coarse)`,M0=[8,18,30,42,88],ps=`
|
|
1565
|
+
`,cn="未分類",Dt="all",ds=20;function ti(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 k0(e){const n=ti(e);return n.length?n.join("/"):cn}function w0(e){const n=ti(e);return n.length?n.map((i,o)=>n.slice(0,o+1).join("/")):[cn]}function S0(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,m)=>{const u=p.slice(0,m+1).join("/");i.has(u)||i.set(u,c)})});const o=new Map;let s=0;for(const d of e){const c=ti(d.classification);if(!c.length){s++;continue}let p=o;c.forEach((h,m)=>{const u=c.slice(0,m+1).join("/");let g=p.get(h);g||(g={id:u,label:h,count:0,children:new Map},p.set(h,g)),g.count++,p=g.children})}const a=d=>[...d.values()].sort((c,p)=>{const h=c.label===cn?1:0,m=p.label===cn?1:0;if(h!==m)return h-m;const u=i.get(c.id)??1/0,g=i.get(p.id)??1/0;return u!==g?u-g: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:cn,label:cn,count:s}),l}function vn(e,n){if(!n)return[];for(const i of e){if(i.id===n)return[i];if(i.children){const o=vn(i.children,n);if(o.length)return[i,...o]}}return[]}function ps(e){return e.reduce((n,i)=>n+i.count,0)}function _0(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function $0(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=_0(typeof e.description=="string"?e.description:(d=e.description)==null?void 0:d.text);a&&(n.summary=a);const l=ti(e.classification);return l.length&&(n.classification=l),n}function C0(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 z0(e,n=ds){return Math.max(1,Math.ceil(e/n))}function ip(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 N0=()=>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 T0(e,n,i){const o=[];i&&o.push({id:Dt,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 rp({tree:e,selectedId:n,onSelect:i,allLabel:o,label:s}){const{t:a,convert:l}=re(),d=o===void 0?a("catalogPage.all"):o,c=s??a("catalogPage.classification"),p=f.useRef(null),h=n&&n!==Dt?n:null,m=d!==null,[u,g]=f.useState(()=>{const _=new Set;for(const R of vn(e,h))_.add(R.id);return _});f.useEffect(()=>{const _=vn(e,h);_.length&&g(R=>{if(_.every(N=>R.has(N.id)))return R;const T=new Set(R);for(const N of _)T.add(N.id);return T})},[e,h]);const x=f.useMemo(()=>T0(e,u,m),[e,u,m]),[j,y]=f.useState(null);f.useEffect(()=>{y(null)},[n]);const S=h??(m?Dt:null),b=f.useMemo(()=>{var T;const _=new Set(x.map(N=>N.id));if(j&&_.has(j))return j;if(S&&_.has(S))return S;const R=vn(e,h).map(N=>N.id).filter(N=>_.has(N));return R.length?R[R.length-1]:((T=x[0])==null?void 0:T.id)??null},[x,j,S,e,h]),w=f.useCallback((_,R)=>{g(T=>{const N=T.has(_),E=R??!N;if(E===N)return T;const W=new Set(T);return E?W.add(_):W.delete(_),W})},[]),v=f.useCallback(_=>{y(_),requestAnimationFrame(()=>{var T;const R=Array.from(((T=p.current)==null?void 0:T.querySelectorAll("[data-ct-id]"))??[]).find(N=>N.dataset.ctId===_);R==null||R.focus()})},[]),k=f.useCallback((_,R)=>{R&&w(_,!0),i(_)},[i,w]),z=f.useCallback(_=>{const R=_.target.closest("[data-ct-id]");if(!R)return;const T=R.dataset.ctId,N=x.findIndex(F=>F.id===T);if(N<0)return;const E=x[N];let W=null;switch(_.key){case"ArrowDown":W=x[Math.min(x.length-1,N+1)].id;break;case"ArrowUp":W=x[Math.max(0,N-1)].id;break;case"Home":W=x[0].id;break;case"End":W=x[x.length-1].id;break;case"ArrowRight":if(!E.hasChildren)break;u.has(T)?W=E.firstChildId:w(T,!0);break;case"ArrowLeft":E.hasChildren&&u.has(T)?w(T,!1):W=E.parentId;break;case"Enter":case" ":_.preventDefault(),k(T,E.hasChildren);return;default:return}_.preventDefault(),W&&W!==T&&v(W)},[x,u,w,v,k]),C=(_,R)=>_.map((T,N)=>{var V;const E=(V=T.children)!=null&&V.length?T.children:null,W=!!E&&u.has(T.id),F=T.id===h,A=R===1&&_.length>1&&N===_.length-1;return t.jsxs("li",{role:"treeitem","aria-level":R,"aria-expanded":E?W:void 0,"aria-selected":F,tabIndex:b===T.id?0:-1,"data-ct-id":T.id,className:A?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":R-1},onClick:()=>{y(T.id),k(T.id,!!E)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:E?ae=>{ae.stopPropagation(),y(T.id),w(T.id)}:void 0,children:E?t.jsx(N0,{}):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")})]}),W&&t.jsx("ul",{role:"group",children:C(E,R+1)})]},T.id)});return t.jsxs("ul",{ref:p,role:"tree","aria-label":l(c),className:"bim-ct-tree",onKeyDown:z,children:[m&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!h,tabIndex:b===Dt?0:-1,"data-ct-id":Dt,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(Dt),i(Dt)},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:ps(e).toLocaleString("en-US")})]})}),C(e,1)]})}const op=e=>`/item/${encodeURIComponent(e)}`;function I0(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function sp(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function ap({work:e,href:n}){var d,c;const{t:i,convert:o}=re(),s=sp(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(f.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 lp({work:e,href:n}){var d,c;const{t:i,convert:o}=re(),s=sp(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(f.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 cp({page:e,pageCount:n,onPage:i,pageHref:o,label:s}){const{t:a,convert:l}=re();if(n<=1)return null;const d=p=>h=>{i&&(o&&!I0(h)||(h.preventDefault(),i(p)))},c=(p,h,m)=>{if(m.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:h});const u={className:"bim-ct-pg","aria-current":m.current?"page":void 0,"aria-label":m.aria};return o?t.jsx("a",{...u,href:o(p),onClick:d(p),children:h}):t.jsx("button",{type:"button",...u,onClick:m.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:ip(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 dp({works:e,workLink:n=op,emptyText:i,view:o="card",...s}){const{t:a,convert:l}=re();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(lp,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(ap,{work:d,href:n(d.id)},d.id))}),t.jsx(cp,{...s})]})}const R0=()=>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 E0({tree:e,selectedId:n,page:i,pageCount:o,works:s,onSelect:a,onPage:l,searchSlot:d,workLink:c,pageHref:p,allLabel:h,allTitle:m,pageSize:u=ds,className:g,view:x,onViewChange:j}){const{t:y,convert:S}=re(),b=h===void 0?y("catalogPage.all"):h,w=m??y("catalogPage.allTitle"),k=`bim-ct-drawer-${f.useId().replace(/:/g,"")}`,[z,C]=f.useState(!1),[_,R]=f.useState("card"),T=x??_,N=ae=>{R(ae),j==null||j(ae)},E=vn(e,n&&n!==Dt?n:null),W=E.length?E[E.length-1]:null,F=W?W.label:w,A=W?W.count:ps(e),V=f.useCallback(ae=>{C(!1),a(ae)},[a]);return t.jsxs("div",{className:g?`bim-ct ${g}`:"bim-ct","data-drawer":z?"open":"closed",children:[t.jsx("style",{children:np}),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":z,"aria-controls":k,onClick:()=>C(ae=>!ae),children:[t.jsx("span",{children:y("catalogPage.drawerLabel",{path:S(E.length?E.map(ae=>ae.label).join(" › "):b??w)})}),t.jsx(R0,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:k,children:[t.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),t.jsx(rp,{tree:e,selectedId:n,onSelect:V,allLabel:b})]})]}),t.jsxs("div",{className:"bim-ct-main",children:[t.jsxs("header",{className:"bim-ct-head",children:[t.jsx("h1",{className:"bim-ct-title",children:S(F)}),E.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:S(E.slice(0,-1).map(ae=>ae.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:A.toLocaleString("en-US"),size:u}),o>1&&y("catalogPage.statPage",{page:i,pages:o})]}),t.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":y("catalogPage.viewLabel"),children:[t.jsx("button",{type:"button","aria-pressed":T==="card",onClick:()=>N("card"),children:y("catalogPage.viewCard")}),t.jsx("button",{type:"button","aria-pressed":T==="list",onClick:()=>N("list"),children:y("catalogPage.viewList")})]})]}),d&&t.jsx("div",{className:"bim-ct-search",children:d}),t.jsx(dp,{works:s,view:T,workLink:c,page:i,pageCount:o,onPage:l,pageHref:p})]})]})}const ni="(max-width: 719px)",L0="(max-width: 1079px)",A0=`${ni}, (pointer: coarse)`,M0=[8,18,30,42,88],us=`
|
|
1566
1566
|
.bim-rh { color: ${r("ink")}; font-family: ${r("font-ui")}; font-size: 14px; line-height: 1.6; }
|
|
1567
1567
|
.bim-rh *, .bim-rh *::before, .bim-rh *::after { box-sizing: border-box; }
|
|
1568
1568
|
.bim-rh a { color: ${r("accent")}; text-decoration: none; }
|
|
@@ -1744,7 +1744,7 @@ ${M0.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1744
1744
|
}
|
|
1745
1745
|
|
|
1746
1746
|
/* ── 手机 ── */
|
|
1747
|
-
@media ${
|
|
1747
|
+
@media ${ni} {
|
|
1748
1748
|
.bim-rh-main { padding-top: 24px; }
|
|
1749
1749
|
.bim-rh-stats { gap: 4px 18px; }
|
|
1750
1750
|
.bim-rh-stats b { font-size: 16px; }
|
|
@@ -1792,7 +1792,7 @@ ${M0.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1792
1792
|
}
|
|
1793
1793
|
|
|
1794
1794
|
@media (prefers-reduced-motion: reduce) { .bim-rh * { scroll-behavior: auto !important; transition: none !important; } }
|
|
1795
|
-
`,P0=fo["zh-Hant"].period,pp={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function Xt(e){return{...pp,...e??{}}}function us(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 Ki(e){return(e.authors??[]).filter(i=>i==null?void 0:i.name).map(i=>i.dynasty?`〔${i.dynasty}〕${i.name}`:i.name).join(" ")}function up(e,n=fo["zh-Hant"].shelfOther){var s;const i=[],o=new Map;for(const a of e){const l=((s=a.period_of)==null?void 0:s.trim())||n;let d=o.get(l);d||(d={label:l,items:[]},o.set(l,d),i.push(d)),d.items.push(a)}return i}function mp(e){return Math.max(150,Array.from(e).length*18+44)}function hp(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 fp=.04;function nt(e){return e.toLocaleString("en-US")}function gp({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,i)=>t.jsx("span",{children:n},i))})}function bt({id:e,title:n,sub:i,more:o,children:s}){const{convert:a}=re(),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 xp({counts:e}){const{t:n}=re();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:nt(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:nt(e.pieces)}),n("readHome.pieces")]})]})}function bp({picks:e,links:n}){const{t:i,convert:o}=re(),s=Xt(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=Ki(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(gp,{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 yp(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function ms({topic:e,links:n,hint:i,legendCount:o,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=re(),c=Xt(n);if(!e.items.length)return null;const p=o===void 0?l("readHome.shelfLegendCount"):o,h=up(e.items,l("readHome.shelfOther")),m=u=>{const g=u.records?nt(u.records):yp(u.text_count,l),x=us(u),j=[d(u.title),u.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",u.records?l("readHome.spineRecords",{n:g}):g?l("readHome.spineOnSite",{n:g}):""].filter(Boolean).join(",");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-spine",href:c.read(u.id),"data-orig":u.orig?"":void 0,"aria-label":j,title:j,style:{height:mp(u.title)},children:[t.jsx(gp,{text:d(u.title)}),g&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":u.records?"":void 0,children:g})]})},u.id)};return t.jsxs("div",{className:"bim-rh-shelf-box",children:[s&&t.jsxs("h3",{className:"bim-rh-gt",children:[d(e.label),t.jsx("small",{children:i?d(i):l("readHome.shelfHint")})]}),t.jsx("div",{className:"bim-rh-shelf-wrap",tabIndex:0,role:"region","aria-label":l("readHome.shelfRegion",{label:d(e.label)}),children:t.jsx("ul",{className:"bim-rh-shelf",children:h.map(u=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(u.label),children:u.items.map(m)}),t.jsx("span",{"aria-hidden":"true",children:d(u.label)})]},u.label))})}),t.jsxs("p",{className:"bim-rh-legend",children:[t.jsxs("span",{children:[t.jsx("i",{"data-orig":"","aria-hidden":"true"}),l("readHome.origZhi")]}),t.jsxs("span",{children:[t.jsx("i",{"aria-hidden":"true"}),l("readHome.laterZhi")]}),p&&t.jsx("span",{children:d(p)}),a==null?void 0:a.map(u=>t.jsx("span",{children:d(u)},u))]})]})}const B0=4,qn=e=>e>B0+1;function jp({topic:e,links:n}){const{t:i,convert:o}=re(),s=Xt(n),[a,l]=f.useState(!1);if(!e.items.length)return null;const d=`bim-rh-g-${e.key}`;return t.jsxs("div",{className:"bim-rh-grp","data-cap":qn(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:nt(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=yp(c.text_count,i),h=us(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)})}),qn(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 vp({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(ms,{topic:s,links:n},s.key)),o.length>0&&t.jsx("div",{className:"bim-rh-groups",children:o.map(s=>t.jsx(jp,{topic:s,links:n},s.key))})]})}function kp({famous:e,links:n}){const{t:i,convert:o}=re(),s=Xt(n);return e.length?t.jsx("ul",{className:"bim-rh-works",children:e.map(a=>t.jsx("li",{children:t.jsxs("article",{className:"bim-rh-wk",children:[t.jsxs("div",{className:"bim-rh-wk-h",children:[t.jsx("h3",{children:o(a.title)}),a.authors&&t.jsx("span",{className:"bim-rh-by",children:o(a.authors)}),t.jsx("span",{className:"bim-rh-c bim-rh-num",children:i("readHome.nCopiesCard",{n:a.text_count})})]}),a.systems.map((l,d)=>t.jsxs("div",{className:"bim-rh-lin",role:"group","aria-label":l.label?o(l.label):void 0,children:[l.label&&t.jsx("small",{"aria-hidden":"true",children:o(l.label)}),l.items.map(c=>t.jsx("a",{className:"bim-rh-chip",href:s.read(c.id),title:o([c.title,c.edition].filter(Boolean).join(" · ")),children:o(c.short)},c.id))]},d)),a.work_id&&t.jsx("div",{className:"bim-rh-wk-f",children:t.jsx("a",{href:s.work(a.work_id),children:i("readHome.workPageLink",{title:o(a.title)})})})]})},a.work_id??a.title))}):null}function hs({bu:e,unclassified:n,links:i,unclassifiedNote:o}){const{t:s,convert:a}=re(),l=Xt(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:nt(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:nt(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:nt(n)})}),t.jsx("span",{children:o?a(o):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function wp({periods:e,unknown:n,links:i}){const{t:o,convert:s,messages:a}=re(),l=a.readHome.period,d=Xt(i),c=e.filter(m=>m.count>0);if(!c.length)return null;const p=c.reduce((m,u)=>m+u.count,0),h=Math.max(...c.map(m=>m.count));return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-band",children:c.map(m=>{const u=m.label?s(m.label):l[m.key]??s(m.key),g=m.count/p,x=o("readHome.periodItem",{label:u,n:nt(m.count)});return t.jsx("li",{style:{flex:`0 0 ${(g*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(m.key),"data-k":hp(m.count,h),"data-narrow":g<fp?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:u}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(u)[0]}),t.jsx("small",{className:"bim-rh-num",children:nt(m.count)})]})},m.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:o("readHome.periodUnknown",{n:nt(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:o("readHome.hoverHint")})]})]})}function Sp({authors:e,links:n}){const{t:i,convert:o}=re(),s=Xt(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:nt(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 _p={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function O0({sections:e,links:n,head:i,piecesMoreHref:o,className:s}){const{t:a}=re(),l=e,d=_p,c=l.topics.filter(u=>!u.shelf),p={picks:l.picks.length>0,topics:c.some(u=>u.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(u=>u.count>0),pieces:l.pieces.authors.length>0},h=Object.keys(d).filter(u=>p[u]),m=u=>a(`readHome.nav.${u}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:ps}),t.jsxs("div",{className:"bim-rh-head",children:[i,t.jsx(xp,{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(u=>t.jsx("li",{children:t.jsx("a",{href:`#${d[u]}`,children:m(u)})},u))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(bt,{id:d.picks,title:m("picks"),sub:a("readHome.picksSub"),children:t.jsx(bp,{picks:l.picks,links:n})}),p.topics&&t.jsx(bt,{id:d.topics,title:m("topics"),sub:a("readHome.topicsSub"),children:t.jsx(vp,{topics:c,links:n})}),p.famous&&t.jsx(bt,{id:d.famous,title:m("famous"),sub:a("readHome.famousSub"),children:t.jsx(kp,{famous:l.famous,links:n})}),p.sibu&&t.jsx(bt,{id:d.sibu,title:m("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(hs,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(bt,{id:d.period,title:m("period"),sub:a("readHome.periodSub"),children:t.jsx(wp,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(bt,{id:d.pieces,title:m("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(Sp,{authors:l.pieces.authors,links:n})})]})]})}const W0="(max-width: 1079px)",F0=`${ti}, (pointer: coarse)`,$p=`
|
|
1795
|
+
`,P0=go["zh-Hant"].period,pp={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function en(e){return{...pp,...e??{}}}function ms(e){var i;const n=(i=e.authors)==null?void 0:i.find(o=>o==null?void 0:o.name);return n?n.dynasty?`${n.dynasty} ${n.name}`:n.name:""}function Xi(e){return(e.authors??[]).filter(i=>i==null?void 0:i.name).map(i=>i.dynasty?`〔${i.dynasty}〕${i.name}`:i.name).join(" ")}function up(e,n=go["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 mp(e){return Math.max(150,Array.from(e).length*18+44)}function hp(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 fp=.04;function it(e){return e.toLocaleString("en-US")}function gp({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,i)=>t.jsx("span",{children:n},i))})}function xt({id:e,title:n,sub:i,more:o,children:s}){const{convert:a}=re(),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 xp({counts:e}){const{t:n}=re();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:it(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:it(e.pieces)}),n("readHome.pieces")]})]})}function bp({picks:e,links:n}){const{t:i,convert:o}=re(),s=en(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=Xi(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(gp,{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 yp(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function hs({topic:e,links:n,hint:i,legendCount:o,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=re(),c=en(n);if(!e.items.length)return null;const p=o===void 0?l("readHome.shelfLegendCount"):o,h=up(e.items,l("readHome.shelfOther")),m=u=>{const g=u.records?it(u.records):yp(u.text_count,l),x=ms(u),j=[d(u.title),u.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",u.records?l("readHome.spineRecords",{n:g}):g?l("readHome.spineOnSite",{n:g}):""].filter(Boolean).join(",");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-spine",href:c.read(u.id),"data-orig":u.orig?"":void 0,"aria-label":j,title:j,style:{height:mp(u.title)},children:[t.jsx(gp,{text:d(u.title)}),g&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":u.records?"":void 0,children:g})]})},u.id)};return t.jsxs("div",{className:"bim-rh-shelf-box",children:[s&&t.jsxs("h3",{className:"bim-rh-gt",children:[d(e.label),t.jsx("small",{children:i?d(i):l("readHome.shelfHint")})]}),t.jsx("div",{className:"bim-rh-shelf-wrap",tabIndex:0,role:"region","aria-label":l("readHome.shelfRegion",{label:d(e.label)}),children:t.jsx("ul",{className:"bim-rh-shelf",children:h.map(u=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(u.label),children:u.items.map(m)}),t.jsx("span",{"aria-hidden":"true",children:d(u.label)})]},u.label))})}),t.jsxs("p",{className:"bim-rh-legend",children:[t.jsxs("span",{children:[t.jsx("i",{"data-orig":"","aria-hidden":"true"}),l("readHome.origZhi")]}),t.jsxs("span",{children:[t.jsx("i",{"aria-hidden":"true"}),l("readHome.laterZhi")]}),p&&t.jsx("span",{children:d(p)}),a==null?void 0:a.map(u=>t.jsx("span",{children:d(u)},u))]})]})}const B0=4,Kn=e=>e>B0+1;function jp({topic:e,links:n}){const{t:i,convert:o}=re(),s=en(n),[a,l]=f.useState(!1);if(!e.items.length)return null;const d=`bim-rh-g-${e.key}`;return t.jsxs("div",{className:"bim-rh-grp","data-cap":Kn(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:it(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=yp(c.text_count,i),h=ms(c);return t.jsx("li",{children:t.jsxs("a",{href:s.read(c.id),children:[t.jsx("span",{className:"bim-rh-t",children:o(c.title)}),p&&t.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:p}),h&&t.jsx("small",{children:o(h)})]})},c.id)})}),Kn(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 vp({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(hs,{topic:s,links:n},s.key)),o.length>0&&t.jsx("div",{className:"bim-rh-groups",children:o.map(s=>t.jsx(jp,{topic:s,links:n},s.key))})]})}function kp({famous:e,links:n}){const{t:i,convert:o}=re(),s=en(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 fs({bu:e,unclassified:n,links:i,unclassifiedNote:o}){const{t:s,convert:a}=re(),l=en(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:it(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:it(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:it(n)})}),t.jsx("span",{children:o?a(o):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function wp({periods:e,unknown:n,links:i}){const{t:o,convert:s,messages:a}=re(),l=a.readHome.period,d=en(i),c=e.filter(m=>m.count>0);if(!c.length)return null;const p=c.reduce((m,u)=>m+u.count,0),h=Math.max(...c.map(m=>m.count));return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-band",children:c.map(m=>{const u=m.label?s(m.label):l[m.key]??s(m.key),g=m.count/p,x=o("readHome.periodItem",{label:u,n:it(m.count)});return t.jsx("li",{style:{flex:`0 0 ${(g*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(m.key),"data-k":hp(m.count,h),"data-narrow":g<fp?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:u}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(u)[0]}),t.jsx("small",{className:"bim-rh-num",children:it(m.count)})]})},m.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:o("readHome.periodUnknown",{n:it(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:o("readHome.hoverHint")})]})]})}function Sp({authors:e,links:n}){const{t:i,convert:o}=re(),s=en(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:it(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 _p={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function O0({sections:e,links:n,head:i,piecesMoreHref:o,className:s}){const{t:a}=re(),l=e,d=_p,c=l.topics.filter(u=>!u.shelf),p={picks:l.picks.length>0,topics:c.some(u=>u.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(u=>u.count>0),pieces:l.pieces.authors.length>0},h=Object.keys(d).filter(u=>p[u]),m=u=>a(`readHome.nav.${u}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:us}),t.jsxs("div",{className:"bim-rh-head",children:[i,t.jsx(xp,{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(u=>t.jsx("li",{children:t.jsx("a",{href:`#${d[u]}`,children:m(u)})},u))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(xt,{id:d.picks,title:m("picks"),sub:a("readHome.picksSub"),children:t.jsx(bp,{picks:l.picks,links:n})}),p.topics&&t.jsx(xt,{id:d.topics,title:m("topics"),sub:a("readHome.topicsSub"),children:t.jsx(vp,{topics:c,links:n})}),p.famous&&t.jsx(xt,{id:d.famous,title:m("famous"),sub:a("readHome.famousSub"),children:t.jsx(kp,{famous:l.famous,links:n})}),p.sibu&&t.jsx(xt,{id:d.sibu,title:m("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(fs,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(xt,{id:d.period,title:m("period"),sub:a("readHome.periodSub"),children:t.jsx(wp,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(xt,{id:d.pieces,title:m("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(Sp,{authors:l.pieces.authors,links:n})})]})]})}const W0="(max-width: 1079px)",F0=`${ni}, (pointer: coarse)`,$p=`
|
|
1796
1796
|
/* ── 页首:检索(宿主插槽)+类型签|最近浏览 ── */
|
|
1797
1797
|
.bim-mh-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 16px 48px; align-items: start; padding-top: 8px; }
|
|
1798
1798
|
.bim-mh-q { min-width: 0; }
|
|
@@ -1942,7 +1942,7 @@ ${M0.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1942
1942
|
}
|
|
1943
1943
|
|
|
1944
1944
|
/* ── 手机 ── */
|
|
1945
|
-
@media ${
|
|
1945
|
+
@media ${ni} {
|
|
1946
1946
|
.bim-mh-cg, .bim-mh-data { grid-template-columns: minmax(0, 1fr); }
|
|
1947
1947
|
.bim-mh-ge { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
|
1948
1948
|
.bim-mh-lin { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
@@ -1963,4 +1963,4 @@ ${M0.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1963
1963
|
.bim-mh-recent li a, .bim-mh-types a, .bim-mh-tl-list a { min-height: 44px; align-items: center; }
|
|
1964
1964
|
.bim-mh-recent-h button { min-height: 44px; }
|
|
1965
1965
|
}
|
|
1966
|
-
`,Cp={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function Zt(e){return{...Cp,...e??{}}}function zp(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 fs(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,m=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(h,m),Math.max(h,m)]},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 Ti(e,n=_n("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function H0(e){return{read:e.item,work:e.item,node:e.node}}function Tp({counts:e,links:n}){const{t:i}=re(),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:nt(d)})]})},a))})}function Ip(e,n=5){const[i,o]=f.useState(null);f.useEffect(()=>{let a=!1;const l=Kt().slice(0,n);if(!l.length||!e){o([]);return}return Promise.all(l.map(d=>$o(e,d))).then(d=>{a||o(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=f.useCallback(()=>{_o(),o([])},[]);return{entries:i,clear:s}}function D0(e,n,i){const o=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return o?i(o):Rp(e.type,n)}function Rp(e,n){return n(`metaHome.typeLabel.${e}`)}function Ep({entries:e,onClear:n,links:i}){const{t:o,convert:s}=re(),a=Zt(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?Rp(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:D0(l,o,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:o("metaHome.recentEmpty")})]})}function Lp(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 Ap({rows:e,links:n}){const{t:i,convert:o}=re(),s=Zt(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=fs(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:nt(a.total)}),t.jsx("td",{className:"bim-mh-r",children:nt(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:Lp(a.status,i,o)})})]},a.id||a.name)})})]})}):null}function Mp({items:e,links:n,label:i}){const{convert:o}=re();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 Pp({works:e,links:n}){const{t:i}=re(),[o,s]=f.useState(!1);if(!e.length)return null;const a=qn(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(Mp,{items:e.map(l=>({id:l.id,title:l.title,sub:Ki(l)||void 0})),links:Zt(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 Bp="siku_qige";function U0({group:e,links:n}){const{t:i,convert:o}=re(),[s,a]=f.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":qn(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(Mp,{items:e.items,links:n,label:e.label}),qn(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 Op({groups:e,links:n}){const{t:i,convert:o}=re(),s=Zt(n);if(!e.length)return null;const a=e.find(c=>c.key===Bp),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(U0,{group:c,links:s},c.key))})]})}const jl=34,vl=13;function kl(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?Ti(e.birth_year,n):"?"}–${e.death_year!=null?Ti(e.death_year,n):"?"}`}function V0(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 Wp({people:e,links:n}){const{t:i,convert:o}=re(),s=Zt(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=Np(e),p=[],h=d.map(u=>{const g=u.left>70,x=g?Math.min(u.left,u.left+u.width-vl):u.left;let j=0;for(;p[j]!=null&&p[j]>x;)j++;return p[j]=g?u.left+u.width:u.left+Math.max(u.width,vl),{...u,lane:j,end:g}}),m=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*jl+10},children:h.map(u=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":u.end?"":void 0,style:{left:`${u.left}%`,top:u.lane*jl+4,width:`${Math.max(u.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(u.p.id),children:[o(u.p.name),t.jsx("small",{className:"bim-rh-num",children:kl(u.p,i)})]})]},u.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:V0(a,l).map(u=>t.jsx("span",{style:{left:`${(u-a)/m*100}%`},children:Ti(u,i)},u))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":h.length?void 0:"",children:(h.length?e:c).map(u=>t.jsx("li",{children:t.jsxs("a",{href:s.item(u.id),children:[t.jsx("span",{children:o(u.name)}),t.jsx("small",{className:"bim-rh-num",children:[u.dynasty?o(u.dynasty):"",kl(u,i)].filter(Boolean).join(" ")})]})},u.id))}),c.length>0&&h.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:i("metaHome.missingLife",{names:o(c.map(u=>u.name).join("、"))})})]})}const G0=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 Fp({works:e,links:n}){const{t:i,convert:o}=re(),s=Zt(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=Ki(a);return t.jsx("li",{children:t.jsxs("a",{href:zp(s,a.id),children:[G0,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 Hp({sites:e}){const{t:n,convert:i}=re(),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=fs(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:[`${nt(a.imported)} / ${nt(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:Lp(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 wl=["extant","partially_extant","lost","unknown"];function Dp({stats:e,links:n,version:i,repoUrl:o,downloadHref:s}){const{t:a}=re(),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=wl.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:nt(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:wl.map(p=>{var u;const h=((u=e.loss)==null?void 0:u[p])??0,m=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:nt(h),note:m}):m})]})},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 Up={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function Y0({sections:e,links:n,head:i,transport:o,catalogHref:s,collectionsHref:a,entitiesHref:l,version:d,repoUrl:c,downloadHref:p,className:h}){var k,z;const{t:m}=re(),u=e,g=Zt(n),x=H0(g),j=Up,y=Ip(o),S={zhi:!!((k=u.shelf)!=null&&k.items.length)||u.catalog_progress.length>0||u.related_catalogs.length>0,sibu:u.bu.length>0||u.unclassified>0,cong:u.collection_groups.length>0,people:u.bibliographers.length>0,lineage:u.lineage.length>0,sites:u.sites.length>0,data:!0},b=Object.keys(j).filter(C=>S[C]),w=C=>m(`metaHome.nav.${C}`),v=(C,_)=>C?t.jsx("a",{className:"bim-rh-more",href:C,children:_}):void 0;return t.jsxs("div",{className:h?`bim-rh bim-mh ${h}`:"bim-rh bim-mh",children:[t.jsx("style",{children:ps+$p}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[i,t.jsx(Tp,{counts:u.counts,links:n})]}),o&&t.jsx(Ep,{entries:y.entries,onClear:y.clear,links:n})]}),b.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":m("metaHome.navLabel"),children:t.jsx("ul",{children:b.map(C=>t.jsx("li",{children:t.jsx("a",{href:`#${j[C]}`,children:w(C)})},C))})}),t.jsxs("div",{className:"bim-rh-main",children:[S.zhi&&t.jsxs(bt,{id:j.zhi,title:w("zhi"),sub:m("metaHome.zhiSub"),children:[u.shelf&&u.shelf.items.length>0&&t.jsx(ms,{topic:{key:"shelf",label:u.shelf.label,shelf:!0,items:u.shelf.items},links:x,showTitle:!1,legendCount:u.shelf.items.some(C=>C.records)?m("metaHome.shelfLegendCount"):null,legendExtra:[m("metaHome.shelfLegendClick")]}),(u.catalog_progress.length>0||u.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:(z=u.shelf)!=null&&z.items.length?void 0:{marginTop:0},children:[t.jsx(Ap,{rows:u.catalog_progress,links:n}),t.jsx(Pp,{works:u.related_catalogs,links:n})]})]}),S.sibu&&t.jsx(bt,{id:j.sibu,title:w("sibu"),sub:m("metaHome.sibuSub"),more:v(s,m("metaHome.toCatalog")),children:t.jsx(hs,{bu:u.bu,unclassified:u.unclassified,links:x,unclassifiedNote:m("metaHome.unclassifiedNote")})}),S.cong&&t.jsx(bt,{id:j.cong,title:w("cong"),sub:m("metaHome.congSub"),more:v(a,m("metaHome.allNKindsMore",{n:nt(u.counts.collections)})),children:t.jsx(Op,{groups:u.collection_groups,links:n})}),S.people&&t.jsx(bt,{id:j.people,title:w("people"),sub:m("metaHome.peopleSub"),more:v(l,m("metaHome.allNPeopleMore",{n:nt(u.counts.entities)})),children:t.jsx(Wp,{people:u.bibliographers,links:n})}),S.lineage&&t.jsx(bt,{id:j.lineage,title:w("lineage"),sub:m("metaHome.lineageSub"),children:t.jsx(Fp,{works:u.lineage,links:n})}),S.sites&&t.jsx(bt,{id:j.sites,title:w("sites"),sub:m("metaHome.sitesSub"),children:t.jsx(Hp,{sites:u.sites})}),t.jsx(bt,{id:j.data,title:w("data"),sub:m("metaHome.dataSub"),children:t.jsx(Dp,{stats:u.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const Vp=["_related","_catalogs","_collections","_members","_children"],q0=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),so=e=>q0(e)&&!!e.h;function K0(e){return e?Vp.some(n=>{const i=e[n];return Array.isArray(i)&&i.some(so)}):!1}function X0(e,n){const i={...e};if(!n)return i;for(const o of Vp){const s=e[o];!Array.isArray(s)||!s.some(so)||(i[o]=s.map(a=>{var c;if(!so(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 Z0(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&&X0(d,K0(d)?await i():null)};const a=Reflect.get(o,s,o);return typeof a=="function"?a.bind(o):a}})}const ao=({style:e})=>{const n=f.useContext(Lt),{t:i}=re();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")})]})},lo=({href:e,label:n,size:i=16,className:o,style:s})=>{const{t:a}=re(),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 Er(e){const n=e.text_count;return typeof n=="number"&&n>0}function Lr(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function J0(e,n){if(!n)return!1;const i=n.id;return i===void 0||i===e}const Q0=({id:e,transport:n,initialDetail:i,initialEntry:o,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:h,onLineageCollectionChange:m,initialPage:u=1,selectedLineageNodeId:g,onNavigate:x,onBack:j,backLabel:y,renderLink:S,assetBase:b,enrichDetail:w,getSourceLink:v,readLink:k,railTop:z,extraTabs:C=[],showFeedbackTab:_=!0,feedbackApiUrl:R,height:T,footerExtra:N,hideHeaderControls:E=!1,className:W,style:F})=>{const A=f.useMemo(()=>Z0(n),[n]),V=Ae(),{t:ae,convert:xe}=re(),[me]=f.useState(()=>{if(!J0(e,i))return null;const Y={...i},H=o??Lr(e,Y);return w&&w(H,Y),{id:e,entry:H,detail:Y}}),[G,ye]=f.useState((me==null?void 0:me.entry)??null),[ne,U]=f.useState((me==null?void 0:me.detail)??null),[Q,q]=f.useState(!me),[je,I]=f.useState(!1),[oe,$e]=f.useState([]),[ve,Le]=f.useState(!1),[Ne,X]=f.useState(null),[ue,Pe]=f.useState(null),[Me,ke]=f.useState(null),[D,le]=f.useState(!1),ce=f.useRef(null),Z=f.useRef(0),[we,He]=f.useState(null),Ge=l!==void 0?l:we,Xe=f.useCallback(Y=>{d?d(Y):He(Y)},[d]),O=f.useCallback(async Y=>{if(!A.getCollectionCatalogs&&!A.getCollectionCatalog){$e([]);return}Le(!0);try{if(A.getCollectionCatalogs)$e(await A.getCollectionCatalogs(Y)||[]);else if(A.getCollectionCatalog){const H=await A.getCollectionCatalog(Y);$e(H?[{resource_id:"",data:H}]:[])}}catch{$e([])}finally{Le(!1)}},[A]),de=f.useCallback(async Y=>{var H,fe;if(!A.getTextManifest||!A.getTextIndex){X(null),Pe(Y);return}try{const Ce=ze.pickTextVersion(await A.getTextManifest(Y)),be=Ce?await A.getTextIndex(Y,Ce.key):null;X(be&&be.chapters.length>0?{chapters:be.chapters.map(J=>({n:J.n,title:J.title,file:J.file})),source:{name:((H=be.source)==null?void 0:H.name)??(Ce==null?void 0:Ce.source_name),license:((fe=be.source)==null?void 0:fe.license)??(Ce==null?void 0:Ce.license)??void 0}}:null)}catch{X(null)}finally{Pe(Y)}},[A]),Te=f.useCallback(async(Y,H)=>{const fe=++Z.current,Ce=()=>fe!==Z.current;le(!0);try{if(A.getLineageGraph){const Ue=await A.getLineageGraph(Y);if(Ce())return;Ue&&ke(Ue)}const be=H.version_graph;if(!be||!be.enabled){Me||ke(null),ce.current=null;return}const J=ko(H),ge=(await Yi(J,Gi,async Ue=>{try{return await A.getItem(Ue)}catch{return null}},Ce)).filter(Boolean);if(Ce())return;ce.current={work:H,books:ge};const Oe=h??be.default_collection??(be.core_books&&be.core_books.length>0?"core":"all"),Se=Oe==="core"&&Array.isArray(be.core_books)&&be.core_books.length>0?"core":Oe??"all";ke(wi(H,ge,Se))}catch{if(Ce())return;ke(null),ce.current=null}finally{Ce()||le(!1)}},[A]),B=f.useRef({initialDetail:i,initialEntry:o});B.current={initialDetail:i,initialEntry:o},f.useEffect(()=>{let Y=!1;Z.current++,le(!1);const H=J=>{J.type==="collection"?O(e):J.type==="work"?(J.version_graph||A.getLineageGraph)&&Te(e,J):J.type==="book"&&Er(J)&&de(e)},fe=B.current;let Ce=null;if(me&&me.id===e)Ce=me;else if(fe.initialDetail&&fe.initialDetail.id===e){const J={...fe.initialDetail},Ee=fe.initialEntry??Lr(e,J);w&&w(Ee,J),Ce={entry:Ee,detail:J}}return Ce?(I(!1),$e(J=>J.length?[]:J),X(null),ke(null),ce.current=null,ye(Ce.entry),U(Ce.detail),q(!1),H(Ce.detail),()=>{Y=!0}):((async()=>{q(!0),I(!1),ye(null),U(null),$e([]),X(null),ke(null),ce.current=null;try{const J=await A.getItem(e);if(Y)return;if(!J){I(!0);return}const Ee=J;let ge=null;if(A.getEntry&&(ge=await A.getEntry(e),Y))return;ge||(ge=Lr(e,Ee)),w&&w(ge,Ee),ye(ge),U(Ee),H(Ee)}catch{Y||I(!0)}finally{Y||q(!1)}})(),()=>{Y=!0})},[e,A,me,w,O,Te,de]),f.useEffect(()=>{const Y=ce.current;!Y||!h||ke(wi(Y.work,Y.books,h))},[h]);const pe=[];if(ne){if(pe.push({key:"basic",label:V.detailTab.basicInfo}),ne.type==="collection"){ve&&oe.length===0&&pe.push({key:"catalog:loading",label:`${V.detailTab.catalog}…`});for(const Y of oe)pe.push({key:`catalog:${Y.resource_id}`,label:Y.short_name?`${xe(Y.short_name)}${V.detailTab.catalogSuffix}`:V.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&pe.push({key:s,label:V.detailTab.fullText}),ne.type==="work"&&(Me||D)&&pe.push({key:"lineage",label:D?`${V.detailTab.lineage}…`:V.detailTab.lineage});for(const Y of C)(Y.position??"before-feedback")==="before-feedback"&&Y.shouldShow(ne)&&pe.push({key:Y.key,label:Y.label});_&&s==="feedback"&&pe.push({key:"feedback",label:V.detailTab.feedback});for(const Y of C)Y.position==="after-feedback"&&Y.shouldShow(ne)&&pe.push({key:Y.key,label:Y.label})}f.useEffect(()=>{if(s!=="emendated"||!ne)return;a("basic");const Y=setTimeout(()=>{var H;(H=document.getElementById("studies"))==null||H.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(Y)},[s,ne,a]);const ie=G&&ne&&v?v({activeTab:s,activeJuan:Ge,entry:G,detail:ne}):null,_e=f.useMemo(()=>{var be,J,Ee,ge,Oe;if(!ne)return null;const H=(ne.authors??[]).map(Se=>{const Ue=vo(Se.role);return`${Se.dynasty?`〔${xe(Se.dynasty)}〕`:""}${xe(Se.name)}${Ue?` ${xe(Ue)}`:""}`}).join(" · ");let fe=!1;try{fe=ze.extractStatus(ne.id)==="draft"}catch{}if(ne.type==="book"){const Se=ne;return{title:xe(Se.title),subtitle:Se.edition?xe(Se.edition):H||void 0,aside:[fe?V.status.draft:"",H&&Se.edition?H:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(ne.type==="collection"){const Se=ne;return{title:xe(Se.title),subtitle:xe(Dt(Se,V.unit.juan))||void 0,aside:[(be=Se.publication_info)==null?void 0:be.year,fe?V.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:H||void 0}}if(ne.type==="entity"){const Se=ne,Ue=at=>at==null?"":at<0?ae("detail.bce",{n:-at}):String(at),dt=((J=Se.dates)==null?void 0:J.birth)!=null||((Ee=Se.dates)==null?void 0:Ee.death)!=null?`${Ue(((ge=Se.dates)==null?void 0:ge.birth)??void 0)||"?"}—${Ue(((Oe=Se.dates)==null?void 0:Oe.death)??void 0)||"?"}`:"";return{title:xe(Se.primary_name||Se.title),subtitle:[Se.dynasty?`〔${xe(Se.dynasty)}〕`:"",dt].filter(Boolean).join(" ")||void 0,aside:fe?V.status.draft:void 0,secondLine:void 0}}const Ce=xe(Dt(ne,V.unit.juan));return{title:xe(ne.title),subtitle:[Ce,H].filter(Boolean).join(" · ")||void 0,aside:[t1(V,ne.subtype),fe?V.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[ne,xe,V,ae]),Re=ne&&Er(ne)?"text":null,De=()=>{Xe(null),a("fulltext")};let Ye=null;if(ne&&k){const Y=k({detail:ne,kind:Re});Y&&(Ye=t.jsx(Vr,{href:Y}))}else Re&&(Ye=t.jsx(Vr,{onClick:De}));const et=Y=>{if(!ne)return null;const H=Y.replace(/\.[^.]+$/,"");if(k){const fe=k({detail:ne,kind:Re,juan:H});return fe?{href:fe}:null}return{onClick:()=>{Xe(H),a("fulltext")}}},Ze=new Set(C.map(Y=>Y.key)),$=pe.filter(Y=>Y.key.startsWith("catalog:")&&Y.key!=="catalog:loading"||Y.key==="lineage"&&!!Me&&!D||Ze.has(Y.key)).map(Y=>({key:Y.key,label:Y.label,onClick:()=>a(Y.key)})),M=()=>{var Y;return ne?ne.type==="work"?t.jsx(qd,{data:ne,transport:A,onNavigate:x,renderLink:S,readAction:Ye,railTop:z,railLinks:$}):ne.type==="book"?t.jsx(Jd,{data:ne,transport:A,onNavigate:x,renderLink:S,readAction:Ye,fullText:Ne,fullTextPending:Er(ne)&&!!A.getTextManifest&&ue!==ne.id,chapterLink:et,railTop:z,railLinks:$}):ne.type==="collection"?t.jsx(Qd,{data:ne,catalog:(Y=oe[0])==null?void 0:Y.data,transport:A,onNavigate:x,renderLink:S,readAction:Ye,railTop:z,railLinks:$,catalogAction:oe.length>0?t.jsxs("a",{href:"#catalog",onClick:H=>{H.preventDefault(),a(`catalog:${oe[0].resource_id}`)},children:[xe(V.detailTab.collectionCatalog)," →"]}):null}):t.jsx(tp,{data:ne,transport:A,onNavigate:x,renderLink:S,railTop:z,railLinks:$,assetBase:b}):null},P=()=>{var H,fe,Ce;if(!G||!ne)return null;if(s==="basic"||s==="emendated")return M();if(typeof s=="string"&&s.startsWith("catalog:")){const be=(H=oe.find(J=>`catalog:${J.resource_id}`===s))==null?void 0:H.data;return t.jsx(zo,{data:be,onNavigate:x,renderLink:S})}if(s==="collated"||s==="fulltext")return t.jsx(ns,{id:e,transport:A,chapter:Ge,onLocationChange:be=>Xe(be.chapter),onNavigate:x});if(s==="lineage"){if(!Me)return t.jsx("div",{style:{color:r("label-fg"),padding:"24px 0"},children:ae(D?"detail.loading":"detail.noLineageGraph")});const be=ne.type==="work"?ne:null;return t.jsx(as,{graph:Me,renderLink:S,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:g,collection:h??((fe=be==null?void 0:be.version_graph)==null?void 0:fe.default_collection),onCollectionChange:m,collectionsAvailable:(Ce=be==null?void 0:be.version_graph)==null?void 0:Ce.collections,collectionCounts:(()=>{var Oe,Se,Ue,dt,at,Ke,Je;if(!be)return;const J={},Ee=((Oe=ce.current)==null?void 0:Oe.books)??[];J.all=(((Se=be._books)==null?void 0:Se.length)??0)-(((dt=(Ue=be.version_graph)==null?void 0:Ue.excluded_books)==null?void 0:dt.length)??0);const ge=(at=be.version_graph)==null?void 0:at.collections;if(ge)for(const ee of Object.keys(ge))J[ee]=wi(be,Ee,ee).nodes.filter(Fe=>Fe.kind==="book"&&!Fe.bridge).length;return J.core==null&&((Je=(Ke=be.version_graph)==null?void 0:Ke.core_books)!=null&&Je.length)&&(J.core=be.version_graph.core_books.length),J})()})}if(s==="feedback"&&_)return t.jsx(Ud,{resourceId:e,apiUrl:R});const Y=C.find(be=>be.key===s);return Y?Y.render({detail:ne,entry:G,transport:A,onNavigate:x}):null};if(Q)return t.jsx(Fn,{style:{minHeight:T,...F},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((Y,H)=>t.jsx("div",{style:{height:H===1?40:16,width:Y,opacity:.35,background:r("rule")}},H))})});if(je||!ne||!G||!_e)return t.jsx(Fn,{style:{minHeight:T,...F},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:r("label-fg"),fontSize:14},children:ae("detail.notFound")})});const K=s==="basic"||s==="emendated",he=[{label:y??V.detailTab.backToIndex,onClick:j}];if(ne.type==="book"&&ne.work_id){const Y=ne.work_id;he.push({label:V.indexType.work,id:Y,onClick:()=>x==null?void 0:x(Y)})}he.push({label:V.indexType[ne.type]});const se=s==="collated"||s==="fulltext",We=typeof N=="string"?V.status[N.trim()]??N:N,Be=t.jsx(Yc,{left:t.jsxs(t.Fragment,{children:[We,We?" · ":"",t.jsx(e1,{id:ne.id,label:V.label.id,copied:V.action.copied,copyLabel:V.action.copy})]}),right:t.jsxs(t.Fragment,{children:[_&&!K&&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:V.detailTab.submitVersion}),ie&&t.jsx("a",{href:ie.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:r("meta-fg")},children:V.detailTab.dataLicense})]})});return K?t.jsx("div",{className:W,children:t.jsxs(Fn,{grid:!0,style:{minHeight:T,...F},children:[t.jsx(Gr,{breadcrumb:t.jsx(Yr,{items:he}),actions:t.jsxs(t.Fragment,{children:[!E&&t.jsx(ao,{style:{border:"none",background:"transparent"}}),!E&&ie&&t.jsx(lo,{...ie})]})}),M(),Be]})}):t.jsx("div",{className:W,children:t.jsxs(Fn,{wide:se,style:{minHeight:T,...F},children:[t.jsx(Gr,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(Lo,{char:"籍"}),t.jsx(Yr,{items:he})]}),actions:t.jsxs(t.Fragment,{children:[!E&&t.jsx(ao,{}),_&&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:V.detailTab.feedback}),!E&&ie&&t.jsx(lo,{...ie})]})}),t.jsx(Bc,{..._e,aside:se?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:[ae("detail.workInfo")," →"]}):_e.aside}),!se&&pe.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:pe.map(Y=>t.jsx(Oc,{label:Y.label,active:Y.key===s||K&&Y.key==="basic",onClick:()=>a(Y.key)},Y.key))}),t.jsx("div",{style:{marginTop:!se&&pe.length>1?8:0},children:P()}),Be]})})};function e1({id:e,label:n,copied:i,copyLabel:o}){const[s,a]=f.useState(!1);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[t.jsxs("span",{children:[n," ",e]}),t.jsx("button",{type:"button",onClick:()=>{var l;(l=navigator.clipboard)==null||l.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},title:s?i:o,"aria-label":s?i:o,className:"bim-d-hit",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:14,minWidth:32,minHeight:32,display:"inline-flex",alignItems:"center",justifyContent:"center",color:r("aux-fg")},children:s?"✓":"⧉"})]})}function t1(e,n){return n?e.workSubtype[n]??n:""}const Gp=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],Xi="zhusha",Zi="bim-theme";function Yp(e){return e==="zhusha"||e==="indigo"||e==="ink"}function Ji(e){return Yp(e)?e:Xi}function n1(){try{return Ji(window.localStorage.getItem(Zi))}catch{return Xi}}function qp(e){try{window.localStorage.setItem(Zi,e)}catch{}}function Kp(e){const n=Ji(e);return document.documentElement.setAttribute("data-theme",n),n}function Xp(){return Ji(document.documentElement.getAttribute("data-theme"))}const i1=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],gs="airy",Qi="bim-layout";function Zp(e){return e==="airy"||e==="boxed"}function er(e){return Zp(e)?e:gs}function r1(){try{return er(window.localStorage.getItem(Qi))}catch{return gs}}function o1(e){try{window.localStorage.setItem(Qi,e)}catch{}}function s1(e){const n=er(e);return document.documentElement.setAttribute("data-layout",n),n}function a1(){return er(document.documentElement.getAttribute("data-layout"))}const l1=`try{var t=localStorage.getItem(${JSON.stringify(Zi)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Qi)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,c1={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},d1=({onChange:e,style:n})=>{const{t:i}=re(),[o,s]=f.useState(Xi);f.useEffect(()=>{s(Xp())},[]);const a=l=>{s(Kp(l)),qp(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":i("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:Gp.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(c1[l.name]),boxShadow:d?`0 0 0 2px ${r("page-bg")}, 0 0 0 3.5px ${r("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=ze.BidLink;exports.BookIndexError=ze.BookIndexError;exports.BookIndexManager=ze.BookIndexManager;exports.BookIndexStorage=ze.BookIndexStorage;exports.BundleStorage=ze.BundleStorage;exports.ConfigError=ze.ConfigError;exports.GithubStorage=ze.GithubStorage;exports.IdGenerationError=ze.IdGenerationError;exports.IdGenerator=ze.IdGenerator;exports.LocalStorage=ze.LocalStorage;exports.MigrationError=ze.MigrationError;exports.StorageError=ze.StorageError;exports.VARIANT_CHARS=ze.VARIANT_CHARS;exports.base36Decode=ze.base36Decode;exports.base36Encode=ze.base36Encode;exports.base58Decode=ze.base58Decode;exports.buildId=ze.buildId;exports.buildPromotionMap=ze.buildPromotionMap;exports.cleanName=ze.cleanName;exports.decodeId=ze.decodeId;exports.decodeIdString=ze.decodeIdString;exports.encodeId=ze.encodeId;exports.extractIdFromUrl=ze.extractIdFromUrl;exports.extractStatus=ze.extractStatus;exports.extractType=ze.extractType;exports.isChapterSegment=ze.isChapterSegment;exports.isTextKey=ze.isTextKey;exports.matchChapterAcrossVersions=ze.matchChapterAcrossVersions;exports.normalizeCatalog=ze.normalizeCatalog;exports.normalizeVariants=ze.normalizeVariants;exports.parseId=ze.parseId;exports.pickTextVersion=ze.pickTextVersion;exports.shardOf=ze.shardOf;exports.smartDecode=ze.smartDecode;exports.textVersionLabel=ze.textVersionLabel;exports.validateResource=ze.validateResource;exports.VARIANT_SUPPLEMENT=Sl.VARIANT_SUPPLEMENT;exports.Badge=Ni;exports.BidUrlProvider=_u;exports.BookDetailLayout=Q0;exports.BookPage=Jd;exports.Breadcrumb=Yr;exports.CATALOG_ALL_ID=Wt;exports.CATALOG_CSS=np;exports.CATALOG_NARROW_QUERY=ls;exports.CATALOG_PAGE_SIZE=cs;exports.CATALOG_UNCLASSIFIED_ID=on;exports.CLASSIFICATIONS=Wi;exports.COMMON_TRADITIONAL_CHARS=Al;exports.CardFoot=Jn;exports.CatalogPage=E0;exports.CatalogPager=cp;exports.CatalogTree=rp;exports.CheckFilter=Ac;exports.Chip=Wc;exports.ChipWall=Nf;exports.CollectionCatalog=zo;exports.CollectionPage=Qd;exports.CreateEntityDialog=Md;exports.DEFAULT_LAYOUT=gs;exports.DEFAULT_META_HOME_LINKS=Cp;exports.DEFAULT_READER_PREFS=To;exports.DEFAULT_READ_HOME_LINKS=pp;exports.DEFAULT_THEME=Xi;exports.DETAIL_CSS=Pc;exports.DYNASTY_GROUPS=Oi;exports.Dash=Af;exports.DataTable=If;exports.DetailFooter=Yc;exports.DetailGrid=Xn;exports.DetailHeader=Bc;exports.EMPTY_FILTERS=Bi;exports.ENTITY_TEXT_CSS=Xo;exports.EmendatedBySection=uc;exports.EmptyNote=Hf;exports.EntityDetail=ac;exports.EntityMark=Jo;exports.EntityPage=tp;exports.EntityPickerDialog=Bd;exports.EntitySelector=Ad;exports.EntityText=px;exports.ExpandRow=Mf;exports.ExtLink=Df;exports.FEEDBACK_FAB_OFFSET_VAR=no;exports.FILTER_SUPPORT=Jl;exports.FONT_SIZE_STEPS=Ot;exports.FactList=_f;exports.FeedbackButton=fy;exports.FeedbackDialog=Hd;exports.FeedbackForm=Dd;exports.FeedbackList=is;exports.FeedbackTab=Ud;exports.FilterChip=Oc;exports.FormInput=kt;exports.FormTextArea=an;exports.GUJI_MARKDOWN_FIELD=df;exports.GUJI_TABLE_NOTATION=qc;exports.GlyphBadge=Lo;exports.GujiInteractiveReader=lb;exports.GujiTable=Po;exports.GujiTextViewer=Qo;exports.GujiWarpCanvas=Ko;exports.HomePage=eo;exports.ImagePanel=Fr;exports.IndexApp=ab;exports.IndexBrowser=Or;exports.IndexDetail=Co;exports.IndexEditor=Od;exports.IndexView=ty;exports.IntroGrid=Sf;exports.LAYOUTS=i1;exports.LAYOUT_STORAGE_KEY=Qi;exports.LOSS_OPTIONS=Zl;exports.LocaleContext=Lt;exports.LocaleProvider=Qu;exports.LocaleToggle=ao;exports.META_HOME_CSS=$p;exports.META_HOME_SECTION_IDS=Up;exports.MetaCatalogTable=Ap;exports.MetaCollectionGroups=Op;exports.MetaDataLicense=Dp;exports.MetaHomeView=Y0;exports.MetaLine=ct;exports.MetaLineageCards=Fp;exports.MetaOnlineSites=Hp;exports.MetaPeopleTimeline=Wp;exports.MetaRecentPanel=Ep;exports.MetaRelatedCatalogs=Pp;exports.MetaTypeChips=Tp;exports.ModeIndicator=Pl;exports.MoreButton=zf;exports.MoreLink=Ro;exports.PAGE_MAX_WIDTH=ji;exports.PERIOD_NARROW_SHARE=fp;exports.PageFrame=Fn;exports.Quote=Bf;exports.READER_CSS=bc;exports.READ_HOME_CSS=ps;exports.READ_HOME_NARROW_QUERY=ti;exports.READ_HOME_SECTION_IDS=_p;exports.READ_PERIOD_LABELS=P0;exports.RECENT_IDS_STORAGE_KEY=jn;exports.ROLE_CLASS_ORDER=Vl;exports.ReadButton=Vr;exports.ReadFamousWorks=kp;exports.ReadHomeView=O0;exports.ReadPeriodBand=wp;exports.ReadPicks=bp;exports.ReadPieces=Sp;exports.ReadSection=bt;exports.ReadShelf=ms;exports.ReadSibu=hs;exports.ReadStats=xp;exports.ReadTopicGroup=jp;exports.ReadTopics=vp;exports.ReaderMdText=Fo;exports.ReaderShell=$c;exports.ReaderToc=yc;exports.RelationPanel=Ed;exports.RepoSourceLink=lo;exports.ResourceEditor=Ar;exports.ResourceGroup=Of;exports.ResourceLine=Wf;exports.ResourceList=go;exports.ResourceRow=Vc;exports.SEARCH_VIEW_STORAGE_KEY=So;exports.SEVEN_PAVILIONS_KEY=Bp;exports.SNIPPET_MARK_END=Cl;exports.SNIPPET_MARK_START=$l;exports.SORTABLE_TYPES=Xl;exports.SearchInput=Ol;exports.SearchResults=rc;exports.Sec=ut;exports.Section=zt;exports.SectionHead=$f;exports.SideList=sn;exports.SmartBidInput=ki;exports.SourceEditor=Td;exports.StripWarpRenderer=Xr;exports.SummaryCard=Zn;exports.THEMES=Gp;exports.THEME_INIT_SCRIPT=l1;exports.THEME_STORAGE_KEY=Zi;exports.TRADITIONAL_ALLOWLIST=Ml;exports.TabFilter=Hi;exports.TableHead=Rf;exports.TableRow=Ef;exports.TagRow=Gc;exports.TagRows=Ff;exports.TextButton=Cf;exports.TextReader=ns;exports.ThemeToggle=d1;exports.TopStrip=Gr;exports.VersionLineageGraph=Zd;exports.VersionLineageList=Xd;exports.VersionLineageView=as;exports.VolumeChips=Tf;exports.VolumeLinks=Ao;exports.WorkCard=ap;exports.WorkCardGrid=dp;exports.WorkCatalog=jb;exports.WorkPage=qd;exports.WorkRow=lp;exports.adaptCharCord=yb;exports.adaptEntityJson=sd;exports.adaptNorm=Nd;exports.adaptNormDetailed=zd;exports.adaptPunctJson=ub;exports.applyLayout=s1;exports.applyTheme=Kp;exports.authorsLine=Ki;exports.bookIndexUriToId=Kr;exports.bookMarkingOf=Wo;exports.bucketResources=yo;exports.buildCatalogTree=S0;exports.buildCollectionTable=ql;exports.buildLineageGraph=wi;exports.buildMeiliFilter=Bm;exports.buildPageUrl=ho;exports.buildParagraphBlocks=td;exports.buildVersionRow=Dl;exports.buildVersionTable=Ul;exports.canParagraphize=Ci;exports.catalogNodeIdOf=k0;exports.catalogNodeIdsOf=w0;exports.catalogPageCount=z0;exports.catalogTotal=ds;exports.classificationPath=ei;exports.clearAllRecentIds=_o;exports.compareCatalogCards=C0;exports.computeVersionPartition=Nm;exports.countActiveFilters=Fi;exports.createTextApi=hc;exports.currentLayout=a1;exports.currentTheme=Xp;exports.defaultEntityHref=fd;exports.defaultWorkLink=op;exports.deriveDating=km;exports.deriveEditionType=Kl;exports.deriveEra=Kn;exports.deriveYear=Ai;exports.deriveYearRange=bo;exports.detailToEditor=Fd;exports.detectGenre=Ui;exports.displayAuthorRole=vo;exports.editorToDetail=ey;exports.eraRank=Pr;exports.filtersFromParams=Om;exports.filtersToParams=$i;exports.findCatalogPath=xn;exports.findTraditionalChars=nm;exports.firstAuthorText=us;exports.flattenTitles=qr;exports.flattenToc=_c;exports.fmtCount=nt;exports.formatHitCount=xi;exports.formatTemplate=wt;exports.formatVolumeRange=Pi;exports.getDisplayNameFromUrl=kn;exports.getMessages=Sn;exports.getStartPage=mo;exports.getT=_n;exports.getTypeGroupKey=po;exports.groupRelatedWorks=wm;exports.gujiInlineToPlain=Ec;exports.hasActiveFilters=Ql;exports.hasGujiMarkdownV02=pf;exports.hasGujiTableNotation=Uf;exports.hasSearchOptions=Am;exports.headingKey=ts;exports.headingsFromPunct=yd;exports.iiifVolumeOf=mb;exports.isCountedChar=Ho;exports.isDuiduChapter=Qr;exports.isLayoutName=Zp;exports.isThemeName=Yp;exports.lineageHref=zp;exports.loadRecentIds=Kt;exports.measureText=Dt;exports.mergeVolumeResources=uo;exports.nestHeadings=kd;exports.normalizeEra=lt;exports.normalizeLayout=er;exports.normalizeRole=jo;exports.normalizeTheme=Ji;exports.normalizeVolumeIndex=Dn;exports.normalizeVolumes=Tl;exports.numberToChinese=Cn;exports.paginationItems=ip;exports.parseChineseNumber=Si;exports.parseGujiInline=Rc;exports.parseGujiTable=Xc;exports.parseHeadingKey=vd;exports.parseSourceString=Id;exports.pct=fs;exports.periodLevel=hp;exports.pickReaderVersion=Sc;exports.readStoredLayout=r1;exports.readStoredTheme=n1;exports.readerVersionOptionLabel=Dr;exports.remapPlainOffsets=ad;exports.removeRecentId=oc;exports.renderFullTextBody=eg;exports.renderProperNames=rd;exports.renderReaderInline=Vi;exports.resolveRecentEntry=$o;exports.resourceHref=wn;exports.resourceNote=Mi;exports.resultTabFromParam=Km;exports.resultTabToParam=Xm;exports.roleFacets=Gl;exports.rowNo=Lf;exports.sameFilters=Wm;exports.sanitizeHeadings=jd;exports.saveRecentId=Br;exports.segmentEntities=ld;exports.shelfColumns=up;exports.sortFor=Mm;exports.sortYear=_i;exports.spineHeight=mp;exports.splitFullTextTables=Mo;exports.splitHighlightSnippet=co;exports.splitTableRow=Kc;exports.storeLayout=o1;exports.storeTheme=qp;exports.stringifySources=Rd;exports.summaryFromEntry=md;exports.summaryFromItem=ud;exports.timelineLayout=Np;exports.toCatalogWorkCard=$0;exports.transportSummaryLoader=hd;exports.typeSupportsFilters=ec;exports.useBidUrl=st;exports.useChapterWarpData=bd;exports.useConvert=Ve;exports.useEntitySummaryLoader=Zo;exports.useI18n=re;exports.useReaderPrefs=wc;exports.useRecentEntries=Ip;exports.useT=Ae;exports.validateLineageGraph=Wy;exports.volumeStats=Ii;exports.withDefaultLinks=Xt;exports.withMetaLinks=Zt;exports.yearText=Ti;
|
|
1966
|
+
`,Cp={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function tn(e){return{...Cp,...e??{}}}function zp(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 gs(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,m=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(h,m),Math.max(h,m)]},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 Ii(e,n=Nn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function H0(e){return{read:e.item,work:e.item,node:e.node}}function Tp({counts:e,links:n}){const{t:i}=re(),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:it(d)})]})},a))})}function Ip(e,n=5){const[i,o]=f.useState(null);f.useEffect(()=>{let a=!1;const l=Qt().slice(0,n);if(!l.length||!e){o([]);return}return Promise.all(l.map(d=>Co(e,d))).then(d=>{a||o(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=f.useCallback(()=>{$o(),o([])},[]);return{entries:i,clear:s}}function D0(e,n,i){const o=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return o?i(o):Rp(e.type,n)}function Rp(e,n){return n(`metaHome.typeLabel.${e}`)}function Ep({entries:e,onClear:n,links:i}){const{t:o,convert:s}=re(),a=tn(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?Rp(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:D0(l,o,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:o("metaHome.recentEmpty")})]})}function Lp(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 Ap({rows:e,links:n}){const{t:i,convert:o}=re(),s=tn(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=gs(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:it(a.total)}),t.jsx("td",{className:"bim-mh-r",children:it(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:Lp(a.status,i,o)})})]},a.id||a.name)})})]})}):null}function Mp({items:e,links:n,label:i}){const{convert:o}=re();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 Pp({works:e,links:n}){const{t:i}=re(),[o,s]=f.useState(!1);if(!e.length)return null;const a=Kn(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(Mp,{items:e.map(l=>({id:l.id,title:l.title,sub:Xi(l)||void 0})),links:tn(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 Bp="siku_qige";function U0({group:e,links:n}){const{t:i,convert:o}=re(),[s,a]=f.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":Kn(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(Mp,{items:e.items,links:n,label:e.label}),Kn(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 Op({groups:e,links:n}){const{t:i,convert:o}=re(),s=tn(n);if(!e.length)return null;const a=e.find(c=>c.key===Bp),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(U0,{group:c,links:s},c.key))})]})}const jl=34,vl=13;function kl(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?Ii(e.birth_year,n):"?"}–${e.death_year!=null?Ii(e.death_year,n):"?"}`}function V0(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 Wp({people:e,links:n}){const{t:i,convert:o}=re(),s=tn(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=Np(e),p=[],h=d.map(u=>{const g=u.left>70,x=g?Math.min(u.left,u.left+u.width-vl):u.left;let j=0;for(;p[j]!=null&&p[j]>x;)j++;return p[j]=g?u.left+u.width:u.left+Math.max(u.width,vl),{...u,lane:j,end:g}}),m=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*jl+10},children:h.map(u=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":u.end?"":void 0,style:{left:`${u.left}%`,top:u.lane*jl+4,width:`${Math.max(u.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(u.p.id),children:[o(u.p.name),t.jsx("small",{className:"bim-rh-num",children:kl(u.p,i)})]})]},u.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:V0(a,l).map(u=>t.jsx("span",{style:{left:`${(u-a)/m*100}%`},children:Ii(u,i)},u))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":h.length?void 0:"",children:(h.length?e:c).map(u=>t.jsx("li",{children:t.jsxs("a",{href:s.item(u.id),children:[t.jsx("span",{children:o(u.name)}),t.jsx("small",{className:"bim-rh-num",children:[u.dynasty?o(u.dynasty):"",kl(u,i)].filter(Boolean).join(" ")})]})},u.id))}),c.length>0&&h.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:i("metaHome.missingLife",{names:o(c.map(u=>u.name).join("、"))})})]})}const G0=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 Fp({works:e,links:n}){const{t:i,convert:o}=re(),s=tn(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=Xi(a);return t.jsx("li",{children:t.jsxs("a",{href:zp(s,a.id),children:[G0,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 Hp({sites:e}){const{t:n,convert:i}=re(),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=gs(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:[`${it(a.imported)} / ${it(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:Lp(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 wl=["extant","partially_extant","lost","unknown"];function Dp({stats:e,links:n,version:i,repoUrl:o,downloadHref:s}){const{t:a}=re(),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=wl.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:it(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:wl.map(p=>{var u;const h=((u=e.loss)==null?void 0:u[p])??0,m=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:it(h),note:m}):m})]})},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 Up={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function Y0({sections:e,links:n,head:i,transport:o,catalogHref:s,collectionsHref:a,entitiesHref:l,version:d,repoUrl:c,downloadHref:p,className:h}){var k,z;const{t:m}=re(),u=e,g=tn(n),x=H0(g),j=Up,y=Ip(o),S={zhi:!!((k=u.shelf)!=null&&k.items.length)||u.catalog_progress.length>0||u.related_catalogs.length>0,sibu:u.bu.length>0||u.unclassified>0,cong:u.collection_groups.length>0,people:u.bibliographers.length>0,lineage:u.lineage.length>0,sites:u.sites.length>0,data:!0},b=Object.keys(j).filter(C=>S[C]),w=C=>m(`metaHome.nav.${C}`),v=(C,_)=>C?t.jsx("a",{className:"bim-rh-more",href:C,children:_}):void 0;return t.jsxs("div",{className:h?`bim-rh bim-mh ${h}`:"bim-rh bim-mh",children:[t.jsx("style",{children:us+$p}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[i,t.jsx(Tp,{counts:u.counts,links:n})]}),o&&t.jsx(Ep,{entries:y.entries,onClear:y.clear,links:n})]}),b.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":m("metaHome.navLabel"),children:t.jsx("ul",{children:b.map(C=>t.jsx("li",{children:t.jsx("a",{href:`#${j[C]}`,children:w(C)})},C))})}),t.jsxs("div",{className:"bim-rh-main",children:[S.zhi&&t.jsxs(xt,{id:j.zhi,title:w("zhi"),sub:m("metaHome.zhiSub"),children:[u.shelf&&u.shelf.items.length>0&&t.jsx(hs,{topic:{key:"shelf",label:u.shelf.label,shelf:!0,items:u.shelf.items},links:x,showTitle:!1,legendCount:u.shelf.items.some(C=>C.records)?m("metaHome.shelfLegendCount"):null,legendExtra:[m("metaHome.shelfLegendClick")]}),(u.catalog_progress.length>0||u.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:(z=u.shelf)!=null&&z.items.length?void 0:{marginTop:0},children:[t.jsx(Ap,{rows:u.catalog_progress,links:n}),t.jsx(Pp,{works:u.related_catalogs,links:n})]})]}),S.sibu&&t.jsx(xt,{id:j.sibu,title:w("sibu"),sub:m("metaHome.sibuSub"),more:v(s,m("metaHome.toCatalog")),children:t.jsx(fs,{bu:u.bu,unclassified:u.unclassified,links:x,unclassifiedNote:m("metaHome.unclassifiedNote")})}),S.cong&&t.jsx(xt,{id:j.cong,title:w("cong"),sub:m("metaHome.congSub"),more:v(a,m("metaHome.allNKindsMore",{n:it(u.counts.collections)})),children:t.jsx(Op,{groups:u.collection_groups,links:n})}),S.people&&t.jsx(xt,{id:j.people,title:w("people"),sub:m("metaHome.peopleSub"),more:v(l,m("metaHome.allNPeopleMore",{n:it(u.counts.entities)})),children:t.jsx(Wp,{people:u.bibliographers,links:n})}),S.lineage&&t.jsx(xt,{id:j.lineage,title:w("lineage"),sub:m("metaHome.lineageSub"),children:t.jsx(Fp,{works:u.lineage,links:n})}),S.sites&&t.jsx(xt,{id:j.sites,title:w("sites"),sub:m("metaHome.sitesSub"),children:t.jsx(Hp,{sites:u.sites})}),t.jsx(xt,{id:j.data,title:w("data"),sub:m("metaHome.dataSub"),children:t.jsx(Dp,{stats:u.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const Vp=["_related","_catalogs","_collections","_members","_children"],q0=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),ao=e=>q0(e)&&!!e.h;function K0(e){return e?Vp.some(n=>{const i=e[n];return Array.isArray(i)&&i.some(ao)}):!1}function X0(e,n){const i={...e};if(!n)return i;for(const o of Vp){const s=e[o];!Array.isArray(s)||!s.some(ao)||(i[o]=s.map(a=>{var c;if(!ao(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 Z0(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&&X0(d,K0(d)?await i():null)};const a=Reflect.get(o,s,o);return typeof a=="function"?a.bind(o):a}})}const lo=({style:e})=>{const n=f.useContext(Mt),{t:i}=re();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")})]})},co=({href:e,label:n,size:i=16,className:o,style:s})=>{const{t:a}=re(),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 Lr(e){const n=e.text_count;return typeof n=="number"&&n>0}function Ar(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function J0(e,n){if(!n)return!1;const i=n.id;return i===void 0||i===e}const Q0=({id:e,transport:n,initialDetail:i,initialEntry:o,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:h,onLineageCollectionChange:m,initialPage:u=1,selectedLineageNodeId:g,onNavigate:x,onBack:j,backLabel:y,renderLink:S,assetBase:b,enrichDetail:w,getSourceLink:v,readLink:k,railTop:z,extraTabs:C=[],showFeedbackTab:_=!0,feedbackApiUrl:R,height:T,footerExtra:N,hideHeaderControls:E=!1,className:W,style:F})=>{const A=f.useMemo(()=>Z0(n),[n]),V=Ae(),{t:ae,convert:xe}=re(),[me]=f.useState(()=>{if(!J0(e,i))return null;const Y={...i},H=o??Ar(e,Y);return w&&w(H,Y),{id:e,entry:H,detail:Y}}),[G,ye]=f.useState((me==null?void 0:me.entry)??null),[ne,U]=f.useState((me==null?void 0:me.detail)??null),[ee,q]=f.useState(!me),[je,I]=f.useState(!1),[oe,$e]=f.useState([]),[ve,Le]=f.useState(!1),[Te,Z]=f.useState(null),[ue,Pe]=f.useState(null),[Me,ke]=f.useState(null),[D,le]=f.useState(!1),ce=f.useRef(null),J=f.useRef(0),[we,Fe]=f.useState(null),Ve=l!==void 0?l:we,Ze=f.useCallback(Y=>{d?d(Y):Fe(Y)},[d]),O=f.useCallback(async Y=>{if(!A.getCollectionCatalogs&&!A.getCollectionCatalog){$e([]);return}Le(!0);try{if(A.getCollectionCatalogs)$e(await A.getCollectionCatalogs(Y)||[]);else if(A.getCollectionCatalog){const H=await A.getCollectionCatalog(Y);$e(H?[{resource_id:"",data:H}]:[])}}catch{$e([])}finally{Le(!1)}},[A]),de=f.useCallback(async Y=>{var H,fe;if(!A.getTextManifest||!A.getTextIndex){Z(null),Pe(Y);return}try{const Ce=ze.pickTextVersion(await A.getTextManifest(Y)),be=Ce?await A.getTextIndex(Y,Ce.key):null;Z(be&&be.chapters.length>0?{chapters:be.chapters.map(Q=>({n:Q.n,title:Q.title,file:Q.file})),source:{name:((H=be.source)==null?void 0:H.name)??(Ce==null?void 0:Ce.source_name),license:((fe=be.source)==null?void 0:fe.license)??(Ce==null?void 0:Ce.license)??void 0}}:null)}catch{Z(null)}finally{Pe(Y)}},[A]),Ie=f.useCallback(async(Y,H)=>{const fe=++J.current,Ce=()=>fe!==J.current;le(!0);try{if(A.getLineageGraph){const De=await A.getLineageGraph(Y);if(Ce())return;De&&ke(De)}const be=H.version_graph;if(!be||!be.enabled){Me||ke(null),ce.current=null;return}const Q=wo(H),ge=(await qi(Q,Yi,async De=>{try{return await A.getItem(De)}catch{return null}},Ce)).filter(Boolean);if(Ce())return;ce.current={work:H,books:ge};const Oe=h??be.default_collection??(be.core_books&&be.core_books.length>0?"core":"all"),Se=Oe==="core"&&Array.isArray(be.core_books)&&be.core_books.length>0?"core":Oe??"all";ke(Si(H,ge,Se))}catch{if(Ce())return;ke(null),ce.current=null}finally{Ce()||le(!1)}},[A]),B=f.useRef({initialDetail:i,initialEntry:o});B.current={initialDetail:i,initialEntry:o},f.useEffect(()=>{let Y=!1;J.current++,le(!1);const H=Q=>{Q.type==="collection"?O(e):Q.type==="work"?(Q.version_graph||A.getLineageGraph)&&Ie(e,Q):Q.type==="book"&&Lr(Q)&&de(e)},fe=B.current;let Ce=null;if(me&&me.id===e)Ce=me;else if(fe.initialDetail&&fe.initialDetail.id===e){const Q={...fe.initialDetail},Ee=fe.initialEntry??Ar(e,Q);w&&w(Ee,Q),Ce={entry:Ee,detail:Q}}return Ce?(I(!1),$e(Q=>Q.length?[]:Q),Z(null),ke(null),ce.current=null,ye(Ce.entry),U(Ce.detail),q(!1),H(Ce.detail),()=>{Y=!0}):((async()=>{q(!0),I(!1),ye(null),U(null),$e([]),Z(null),ke(null),ce.current=null;try{const Q=await A.getItem(e);if(Y)return;if(!Q){I(!0);return}const Ee=Q;let ge=null;if(A.getEntry&&(ge=await A.getEntry(e),Y))return;ge||(ge=Ar(e,Ee)),w&&w(ge,Ee),ye(ge),U(Ee),H(Ee)}catch{Y||I(!0)}finally{Y||q(!1)}})(),()=>{Y=!0})},[e,A,me,w,O,Ie,de]),f.useEffect(()=>{const Y=ce.current;!Y||!h||ke(Si(Y.work,Y.books,h))},[h]);const pe=[];if(ne){if(pe.push({key:"basic",label:V.detailTab.basicInfo}),ne.type==="collection"){ve&&oe.length===0&&pe.push({key:"catalog:loading",label:`${V.detailTab.catalog}…`});for(const Y of oe)pe.push({key:`catalog:${Y.resource_id}`,label:Y.short_name?`${xe(Y.short_name)}${V.detailTab.catalogSuffix}`:V.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&pe.push({key:s,label:V.detailTab.fullText}),ne.type==="work"&&(Me||D)&&pe.push({key:"lineage",label:D?`${V.detailTab.lineage}…`:V.detailTab.lineage});for(const Y of C)(Y.position??"before-feedback")==="before-feedback"&&Y.shouldShow(ne)&&pe.push({key:Y.key,label:Y.label});_&&s==="feedback"&&pe.push({key:"feedback",label:V.detailTab.feedback});for(const Y of C)Y.position==="after-feedback"&&Y.shouldShow(ne)&&pe.push({key:Y.key,label:Y.label})}f.useEffect(()=>{if(s!=="emendated"||!ne)return;a("basic");const Y=setTimeout(()=>{var H;(H=document.getElementById("studies"))==null||H.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(Y)},[s,ne,a]);const ie=G&&ne&&v?v({activeTab:s,activeJuan:Ve,entry:G,detail:ne}):null,_e=f.useMemo(()=>{var be,Q,Ee,ge,Oe;if(!ne)return null;const H=(ne.authors??[]).map(Se=>{const De=ko(Se.role);return`${Se.dynasty?`〔${xe(Se.dynasty)}〕`:""}${xe(Se.name)}${De?` ${xe(De)}`:""}`}).join(" · ");let fe=!1;try{fe=ze.extractStatus(ne.id)==="draft"}catch{}if(ne.type==="book"){const Se=ne;return{title:xe(Se.title),subtitle:Se.edition?xe(Se.edition):H||void 0,aside:[fe?V.status.draft:"",H&&Se.edition?H:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(ne.type==="collection"){const Se=ne;return{title:xe(Se.title),subtitle:xe(Gt(Se,V.unit.juan))||void 0,aside:[(be=Se.publication_info)==null?void 0:be.year,fe?V.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:H||void 0}}if(ne.type==="entity"){const Se=ne,De=lt=>lt==null?"":lt<0?ae("detail.bce",{n:-lt}):String(lt),pt=((Q=Se.dates)==null?void 0:Q.birth)!=null||((Ee=Se.dates)==null?void 0:Ee.death)!=null?`${De(((ge=Se.dates)==null?void 0:ge.birth)??void 0)||"?"}—${De(((Oe=Se.dates)==null?void 0:Oe.death)??void 0)||"?"}`:"";return{title:xe(Se.primary_name||Se.title),subtitle:[Se.dynasty?`〔${xe(Se.dynasty)}〕`:"",pt].filter(Boolean).join(" ")||void 0,aside:fe?V.status.draft:void 0,secondLine:void 0}}const Ce=xe(Gt(ne,V.unit.juan));return{title:xe(ne.title),subtitle:[Ce,H].filter(Boolean).join(" · ")||void 0,aside:[t1(V,ne.subtype),fe?V.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[ne,xe,V,ae]),Re=ne&&Lr(ne)?"text":null,He=()=>{Ze(null),a("fulltext")};let Ye=null;if(ne&&k){const Y=k({detail:ne,kind:Re});Y&&(Ye=t.jsx(Gr,{href:Y}))}else Re&&(Ye=t.jsx(Gr,{onClick:He}));const tt=Y=>{if(!ne)return null;const H=Y.replace(/\.[^.]+$/,"");if(k){const fe=k({detail:ne,kind:Re,juan:H});return fe?{href:fe}:null}return{onClick:()=>{Ze(H),a("fulltext")}}},Qe=new Set(C.map(Y=>Y.key)),$=pe.filter(Y=>Y.key.startsWith("catalog:")&&Y.key!=="catalog:loading"||Y.key==="lineage"&&!!Me&&!D||Qe.has(Y.key)).map(Y=>({key:Y.key,label:Y.label,onClick:()=>a(Y.key)})),M=()=>{var Y;return ne?ne.type==="work"?t.jsx(qd,{data:ne,transport:A,onNavigate:x,renderLink:S,readAction:Ye,railTop:z,railLinks:$}):ne.type==="book"?t.jsx(Jd,{data:ne,transport:A,onNavigate:x,renderLink:S,readAction:Ye,fullText:Te,fullTextPending:Lr(ne)&&!!A.getTextManifest&&ue!==ne.id,chapterLink:tt,railTop:z,railLinks:$}):ne.type==="collection"?t.jsx(Qd,{data:ne,catalog:(Y=oe[0])==null?void 0:Y.data,transport:A,onNavigate:x,renderLink:S,readAction:Ye,railTop:z,railLinks:$,catalogAction:oe.length>0?t.jsxs("a",{href:"#catalog",onClick:H=>{H.preventDefault(),a(`catalog:${oe[0].resource_id}`)},children:[xe(V.detailTab.collectionCatalog)," →"]}):null}):t.jsx(tp,{data:ne,transport:A,onNavigate:x,renderLink:S,railTop:z,railLinks:$,assetBase:b}):null},P=()=>{var H,fe,Ce;if(!G||!ne)return null;if(s==="basic"||s==="emendated")return M();if(typeof s=="string"&&s.startsWith("catalog:")){const be=(H=oe.find(Q=>`catalog:${Q.resource_id}`===s))==null?void 0:H.data;return t.jsx(No,{data:be,onNavigate:x,renderLink:S})}if(s==="collated"||s==="fulltext")return t.jsx(is,{id:e,transport:A,chapter:Ve,onLocationChange:be=>Ze(be.chapter),onNavigate:x});if(s==="lineage"){if(!Me)return t.jsx("div",{style:{color:r("label-fg"),padding:"24px 0"},children:ae(D?"detail.loading":"detail.noLineageGraph")});const be=ne.type==="work"?ne:null;return t.jsx(ls,{graph:Me,renderLink:S,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:g,collection:h??((fe=be==null?void 0:be.version_graph)==null?void 0:fe.default_collection),onCollectionChange:m,collectionsAvailable:(Ce=be==null?void 0:be.version_graph)==null?void 0:Ce.collections,collectionCounts:(()=>{var Oe,Se,De,pt,lt,Ke,et;if(!be)return;const Q={},Ee=((Oe=ce.current)==null?void 0:Oe.books)??[];Q.all=(((Se=be._books)==null?void 0:Se.length)??0)-(((pt=(De=be.version_graph)==null?void 0:De.excluded_books)==null?void 0:pt.length)??0);const ge=(lt=be.version_graph)==null?void 0:lt.collections;if(ge)for(const yt of Object.keys(ge))Q[yt]=Si(be,Ee,yt).nodes.filter(K=>K.kind==="book"&&!K.bridge).length;return Q.core==null&&((et=(Ke=be.version_graph)==null?void 0:Ke.core_books)!=null&&et.length)&&(Q.core=be.version_graph.core_books.length),Q})()})}if(s==="feedback"&&_)return t.jsx(Ud,{resourceId:e,apiUrl:R});const Y=C.find(be=>be.key===s);return Y?Y.render({detail:ne,entry:G,transport:A,onNavigate:x}):null};if(ee)return t.jsx(Hn,{style:{minHeight:T,...F},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((Y,H)=>t.jsx("div",{style:{height:H===1?40:16,width:Y,opacity:.35,background:r("rule")}},H))})});if(je||!ne||!G||!_e)return t.jsx(Hn,{style:{minHeight:T,...F},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:r("label-fg"),fontSize:14},children:ae("detail.notFound")})});const X=s==="basic"||s==="emendated",he=[{label:y??V.detailTab.backToIndex,onClick:j}];if(ne.type==="book"&&ne.work_id){const Y=ne.work_id;he.push({label:V.indexType.work,id:Y,onClick:()=>x==null?void 0:x(Y)})}he.push({label:V.indexType[ne.type]});const se=s==="collated"||s==="fulltext",We=typeof N=="string"?V.status[N.trim()]??N:N,Be=t.jsx(Yc,{left:t.jsxs(t.Fragment,{children:[We,We?" · ":"",t.jsx(e1,{id:ne.id,label:V.label.id,copied:V.action.copied,copyLabel:V.action.copy})]}),right:t.jsxs(t.Fragment,{children:[_&&!X&&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:V.detailTab.submitVersion}),ie&&t.jsx("a",{href:ie.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:r("meta-fg")},children:V.detailTab.dataLicense})]})});return X?t.jsx("div",{className:W,children:t.jsxs(Hn,{grid:!0,style:{minHeight:T,...F},children:[t.jsx(Yr,{breadcrumb:t.jsx(qr,{items:he}),actions:t.jsxs(t.Fragment,{children:[!E&&t.jsx(lo,{style:{border:"none",background:"transparent"}}),!E&&ie&&t.jsx(co,{...ie})]})}),M(),Be]})}):t.jsx("div",{className:W,children:t.jsxs(Hn,{wide:se,style:{minHeight:T,...F},children:[t.jsx(Yr,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(Ao,{char:"籍"}),t.jsx(qr,{items:he})]}),actions:t.jsxs(t.Fragment,{children:[!E&&t.jsx(lo,{}),_&&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:V.detailTab.feedback}),!E&&ie&&t.jsx(co,{...ie})]})}),t.jsx(Bc,{..._e,aside:se?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:[ae("detail.workInfo")," →"]}):_e.aside}),!se&&pe.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:pe.map(Y=>t.jsx(Oc,{label:Y.label,active:Y.key===s||X&&Y.key==="basic",onClick:()=>a(Y.key)},Y.key))}),t.jsx("div",{style:{marginTop:!se&&pe.length>1?8:0},children:P()}),Be]})})};function e1({id:e,label:n,copied:i,copyLabel:o}){const[s,a]=f.useState(!1);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[t.jsxs("span",{children:[n," ",e]}),t.jsx("button",{type:"button",onClick:()=>{var l;(l=navigator.clipboard)==null||l.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},title:s?i:o,"aria-label":s?i:o,className:"bim-d-hit",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:14,minWidth:32,minHeight:32,display:"inline-flex",alignItems:"center",justifyContent:"center",color:r("aux-fg")},children:s?"✓":"⧉"})]})}function t1(e,n){return n?e.workSubtype[n]??n:""}const Gp=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],Zi="zhusha",Ji="bim-theme";function Yp(e){return e==="zhusha"||e==="indigo"||e==="ink"}function Qi(e){return Yp(e)?e:Zi}function n1(){try{return Qi(window.localStorage.getItem(Ji))}catch{return Zi}}function qp(e){try{window.localStorage.setItem(Ji,e)}catch{}}function Kp(e){const n=Qi(e);return document.documentElement.setAttribute("data-theme",n),n}function Xp(){return Qi(document.documentElement.getAttribute("data-theme"))}const i1=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],xs="airy",er="bim-layout";function Zp(e){return e==="airy"||e==="boxed"}function tr(e){return Zp(e)?e:xs}function r1(){try{return tr(window.localStorage.getItem(er))}catch{return xs}}function o1(e){try{window.localStorage.setItem(er,e)}catch{}}function s1(e){const n=tr(e);return document.documentElement.setAttribute("data-layout",n),n}function a1(){return tr(document.documentElement.getAttribute("data-layout"))}const l1=`try{var t=localStorage.getItem(${JSON.stringify(Ji)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(er)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,c1={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},d1=({onChange:e,style:n})=>{const{t:i}=re(),[o,s]=f.useState(Zi);f.useEffect(()=>{s(Xp())},[]);const a=l=>{s(Kp(l)),qp(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":i("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:Gp.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(c1[l.name]),boxShadow:d?`0 0 0 2px ${r("page-bg")}, 0 0 0 3.5px ${r("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=ze.BidLink;exports.BookIndexError=ze.BookIndexError;exports.BookIndexManager=ze.BookIndexManager;exports.BookIndexStorage=ze.BookIndexStorage;exports.BundleStorage=ze.BundleStorage;exports.ConfigError=ze.ConfigError;exports.GithubStorage=ze.GithubStorage;exports.IdGenerationError=ze.IdGenerationError;exports.IdGenerator=ze.IdGenerator;exports.LocalStorage=ze.LocalStorage;exports.MigrationError=ze.MigrationError;exports.StorageError=ze.StorageError;exports.VARIANT_CHARS=ze.VARIANT_CHARS;exports.base36Decode=ze.base36Decode;exports.base36Encode=ze.base36Encode;exports.base58Decode=ze.base58Decode;exports.buildId=ze.buildId;exports.buildPromotionMap=ze.buildPromotionMap;exports.cleanName=ze.cleanName;exports.decodeId=ze.decodeId;exports.decodeIdString=ze.decodeIdString;exports.encodeId=ze.encodeId;exports.extractIdFromUrl=ze.extractIdFromUrl;exports.extractStatus=ze.extractStatus;exports.extractType=ze.extractType;exports.isChapterSegment=ze.isChapterSegment;exports.isTextKey=ze.isTextKey;exports.matchChapterAcrossVersions=ze.matchChapterAcrossVersions;exports.normalizeCatalog=ze.normalizeCatalog;exports.normalizeVariants=ze.normalizeVariants;exports.parseId=ze.parseId;exports.pickTextVersion=ze.pickTextVersion;exports.shardOf=ze.shardOf;exports.smartDecode=ze.smartDecode;exports.textVersionLabel=ze.textVersionLabel;exports.validateResource=ze.validateResource;exports.VARIANT_SUPPLEMENT=Sl.VARIANT_SUPPLEMENT;exports.Badge=Ti;exports.BidUrlProvider=_u;exports.BookDetailLayout=Q0;exports.BookPage=Jd;exports.Breadcrumb=qr;exports.CATALOG_ALL_ID=Dt;exports.CATALOG_CSS=np;exports.CATALOG_NARROW_QUERY=cs;exports.CATALOG_PAGE_SIZE=ds;exports.CATALOG_UNCLASSIFIED_ID=cn;exports.CLASSIFICATIONS=Fi;exports.COMMON_TRADITIONAL_CHARS=Al;exports.CardFoot=Qn;exports.CatalogPage=E0;exports.CatalogPager=cp;exports.CatalogTree=rp;exports.CheckFilter=Ac;exports.Chip=Wc;exports.ChipWall=Nf;exports.CollectionCatalog=No;exports.CollectionPage=Qd;exports.CreateEntityDialog=Md;exports.DEFAULT_LAYOUT=xs;exports.DEFAULT_META_HOME_LINKS=Cp;exports.DEFAULT_READER_PREFS=Io;exports.DEFAULT_READ_HOME_LINKS=pp;exports.DEFAULT_THEME=Zi;exports.DETAIL_CSS=Pc;exports.DYNASTY_GROUPS=Wi;exports.Dash=Af;exports.DataTable=If;exports.DetailFooter=Yc;exports.DetailGrid=Zn;exports.DetailHeader=Bc;exports.EMPTY_FILTERS=Oi;exports.ENTITY_TEXT_CSS=Zo;exports.EmendatedBySection=uc;exports.EmptyNote=Hf;exports.EntityDetail=ac;exports.EntityMark=Qo;exports.EntityPage=tp;exports.EntityPickerDialog=Bd;exports.EntitySelector=Ad;exports.EntityText=px;exports.ExpandRow=Mf;exports.ExtLink=Df;exports.FEEDBACK_FAB_OFFSET_VAR=io;exports.FILTER_SUPPORT=Jl;exports.FONT_SIZE_STEPS=Ht;exports.FactList=_f;exports.FeedbackButton=fy;exports.FeedbackDialog=Hd;exports.FeedbackForm=Dd;exports.FeedbackList=rs;exports.FeedbackTab=Ud;exports.FilterChip=Oc;exports.FormInput=kt;exports.FormTextArea=pn;exports.GUJI_MARKDOWN_FIELD=df;exports.GUJI_TABLE_NOTATION=qc;exports.GlyphBadge=Ao;exports.GujiInteractiveReader=lb;exports.GujiTable=Bo;exports.GujiTextViewer=es;exports.GujiWarpCanvas=Xo;exports.HomePage=to;exports.ImagePanel=Hr;exports.IndexApp=ab;exports.IndexBrowser=Wr;exports.IndexDetail=zo;exports.IndexEditor=Od;exports.IndexView=ty;exports.IntroGrid=Sf;exports.LAYOUTS=i1;exports.LAYOUT_STORAGE_KEY=er;exports.LOSS_OPTIONS=Zl;exports.LocaleContext=Mt;exports.LocaleProvider=Qu;exports.LocaleToggle=lo;exports.META_HOME_CSS=$p;exports.META_HOME_SECTION_IDS=Up;exports.MetaCatalogTable=Ap;exports.MetaCollectionGroups=Op;exports.MetaDataLicense=Dp;exports.MetaHomeView=Y0;exports.MetaLine=dt;exports.MetaLineageCards=Fp;exports.MetaOnlineSites=Hp;exports.MetaPeopleTimeline=Wp;exports.MetaRecentPanel=Ep;exports.MetaRelatedCatalogs=Pp;exports.MetaTypeChips=Tp;exports.ModeIndicator=Pl;exports.MoreButton=zf;exports.MoreLink=Eo;exports.PAGE_MAX_WIDTH=vi;exports.PERIOD_NARROW_SHARE=fp;exports.PageFrame=Hn;exports.Quote=Bf;exports.READER_CSS=bc;exports.READ_HOME_CSS=us;exports.READ_HOME_NARROW_QUERY=ni;exports.READ_HOME_SECTION_IDS=_p;exports.READ_PERIOD_LABELS=P0;exports.RECENT_IDS_STORAGE_KEY=Sn;exports.ROLE_CLASS_ORDER=Vl;exports.ReadButton=Gr;exports.ReadFamousWorks=kp;exports.ReadHomeView=O0;exports.ReadPeriodBand=wp;exports.ReadPicks=bp;exports.ReadPieces=Sp;exports.ReadSection=xt;exports.ReadShelf=hs;exports.ReadSibu=fs;exports.ReadStats=xp;exports.ReadTopicGroup=jp;exports.ReadTopics=vp;exports.ReaderMdText=Ho;exports.ReaderShell=$c;exports.ReaderToc=yc;exports.RelationPanel=Ed;exports.RepoSourceLink=co;exports.ResourceEditor=Mr;exports.ResourceGroup=Of;exports.ResourceLine=Wf;exports.ResourceList=xo;exports.ResourceRow=Vc;exports.SEARCH_VIEW_STORAGE_KEY=_o;exports.SEVEN_PAVILIONS_KEY=Bp;exports.SNIPPET_MARK_END=Cl;exports.SNIPPET_MARK_START=$l;exports.SORTABLE_TYPES=Xl;exports.SearchInput=Ol;exports.SearchResults=rc;exports.Sec=ut;exports.Section=Tt;exports.SectionHead=$f;exports.SideList=dn;exports.SmartBidInput=wi;exports.SourceEditor=Td;exports.StripWarpRenderer=Zr;exports.SummaryCard=Jn;exports.THEMES=Gp;exports.THEME_INIT_SCRIPT=l1;exports.THEME_STORAGE_KEY=Ji;exports.TRADITIONAL_ALLOWLIST=Ml;exports.TabFilter=Di;exports.TableHead=Rf;exports.TableRow=Ef;exports.TagRow=Gc;exports.TagRows=Ff;exports.TextButton=Cf;exports.TextReader=is;exports.ThemeToggle=d1;exports.TopStrip=Yr;exports.VersionLineageGraph=Zd;exports.VersionLineageList=Xd;exports.VersionLineageView=ls;exports.VolumeChips=Tf;exports.VolumeLinks=Mo;exports.WorkCard=ap;exports.WorkCardGrid=dp;exports.WorkCatalog=jb;exports.WorkPage=qd;exports.WorkRow=lp;exports.adaptCharCord=yb;exports.adaptEntityJson=sd;exports.adaptNorm=Nd;exports.adaptNormDetailed=zd;exports.adaptPunctJson=ub;exports.applyLayout=s1;exports.applyTheme=Kp;exports.authorsLine=Xi;exports.bookIndexUriToId=Xr;exports.bookMarkingOf=Fo;exports.bucketResources=jo;exports.buildCatalogTree=S0;exports.buildCollectionTable=ql;exports.buildLineageGraph=Si;exports.buildMeiliFilter=Bm;exports.buildPageUrl=fo;exports.buildParagraphBlocks=td;exports.buildVersionRow=Dl;exports.buildVersionTable=Ul;exports.canParagraphize=zi;exports.catalogNodeIdOf=k0;exports.catalogNodeIdsOf=w0;exports.catalogPageCount=z0;exports.catalogTotal=ps;exports.classificationPath=ti;exports.clearAllRecentIds=$o;exports.compareCatalogCards=C0;exports.computeVersionPartition=Nm;exports.countActiveFilters=Hi;exports.createTextApi=hc;exports.currentLayout=a1;exports.currentTheme=Xp;exports.defaultEntityHref=fd;exports.defaultWorkLink=op;exports.deriveDating=km;exports.deriveEditionType=Kl;exports.deriveEra=Xn;exports.deriveYear=Mi;exports.deriveYearRange=yo;exports.detailToEditor=Fd;exports.detectGenre=Vi;exports.displayAuthorRole=ko;exports.editorToDetail=ey;exports.eraRank=Br;exports.filtersFromParams=Om;exports.filtersToParams=Ci;exports.findCatalogPath=vn;exports.findTraditionalChars=nm;exports.firstAuthorText=ms;exports.flattenTitles=Kr;exports.flattenToc=_c;exports.fmtCount=it;exports.formatHitCount=bi;exports.formatTemplate=wt;exports.formatVolumeRange=Bi;exports.getDisplayNameFromUrl=$n;exports.getMessages=zn;exports.getStartPage=ho;exports.getT=Nn;exports.getTypeGroupKey=uo;exports.groupRelatedWorks=wm;exports.gujiInlineToPlain=Ec;exports.hasActiveFilters=Ql;exports.hasGujiMarkdownV02=pf;exports.hasGujiTableNotation=Uf;exports.hasSearchOptions=Am;exports.headingKey=ns;exports.headingsFromPunct=yd;exports.iiifVolumeOf=mb;exports.isCountedChar=Do;exports.isDuiduChapter=eo;exports.isLayoutName=Zp;exports.isThemeName=Yp;exports.lineageHref=zp;exports.loadRecentIds=Qt;exports.measureText=Gt;exports.mergeVolumeResources=mo;exports.nestHeadings=kd;exports.normalizeEra=ct;exports.normalizeLayout=tr;exports.normalizeRole=vo;exports.normalizeTheme=Qi;exports.normalizeVolumeIndex=Un;exports.normalizeVolumes=Tl;exports.numberToChinese=In;exports.paginationItems=ip;exports.parseChineseNumber=_i;exports.parseGujiInline=Rc;exports.parseGujiTable=Xc;exports.parseHeadingKey=vd;exports.parseSourceString=Id;exports.pct=gs;exports.periodLevel=hp;exports.pickReaderVersion=Sc;exports.readStoredLayout=r1;exports.readStoredTheme=n1;exports.readerVersionOptionLabel=Ur;exports.remapPlainOffsets=ad;exports.removeRecentId=oc;exports.renderFullTextBody=eg;exports.renderProperNames=rd;exports.renderReaderInline=Gi;exports.resolveRecentEntry=Co;exports.resourceHref=Cn;exports.resourceNote=Pi;exports.resultTabFromParam=Km;exports.resultTabToParam=Xm;exports.roleFacets=Gl;exports.rowNo=Lf;exports.sameFilters=Wm;exports.sanitizeHeadings=jd;exports.saveRecentId=Or;exports.segmentEntities=ld;exports.shelfColumns=up;exports.sortFor=Mm;exports.sortYear=$i;exports.spineHeight=mp;exports.splitFullTextTables=Po;exports.splitHighlightSnippet=po;exports.splitTableRow=Kc;exports.storeLayout=o1;exports.storeTheme=qp;exports.stringifySources=Rd;exports.summaryFromEntry=md;exports.summaryFromItem=ud;exports.timelineLayout=Np;exports.toCatalogWorkCard=$0;exports.transportSummaryLoader=hd;exports.typeSupportsFilters=ec;exports.useBidUrl=at;exports.useChapterWarpData=bd;exports.useConvert=Ue;exports.useEntitySummaryLoader=Jo;exports.useI18n=re;exports.useReaderPrefs=wc;exports.useRecentEntries=Ip;exports.useT=Ae;exports.validateLineageGraph=Wy;exports.volumeStats=Ri;exports.withDefaultLinks=en;exports.withMetaLinks=tn;exports.yearText=Ii;
|