book-index-ui 0.46.0 → 0.46.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +73 -71
- package/dist/index.js +2934 -2923
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Od=Object.create;var Or=Object.defineProperty;var Hd=Object.getOwnPropertyDescriptor;var Fd=Object.getOwnPropertyNames;var Dd=Object.getPrototypeOf,Ud=Object.prototype.hasOwnProperty;var Vd=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Fd(n))!Ud.call(e,s)&&s!==o&&Or(e,s,{get:()=>n[s],enumerable:!(r=Hd(n,s))||r.enumerable});return e};var Vn=(e,n,o)=>(o=e!=null?Od(Dd(e)):{},Vd(n||!e||!e.__esModule?Or(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const we=require("./storage-entry-C9uAfe4i.cjs"),t=require("react/jsx-runtime"),g=require("react"),Gd=require("opencc-js/t2cn"),Yd=require("react-markdown"),Kd=require("remark-gfm"),qd=e=>`/book-index?id=${e}`,ga=g.createContext(qd);function Xd({buildUrl:e,children:n}){const o=g.useMemo(()=>e,[e]);return t.jsx(ga.Provider,{value:o,children:n})}function Xe(){return g.useContext(ga)}const fa="",xa="";function _o(e){const n=[];let o=!1,r=e;for(;r.length;){const s=o?xa:fa,a=r.indexOf(s);if(a===-1){n.push({text:r,marked:o});break}a>0&&n.push({text:r.slice(0,a),marked:o}),r=r.slice(a+1),o=!o}return n}function it(e,n){return{title:e,tokens:n}}const Hr='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',Zd=[it("基础(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"}}),it("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),it("提示与警告",{"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)"}}),it("遮罩与阴影",{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)"}}),it("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),it("资源",{"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"}}),it("整理本(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-published":{value:"#1b5e20",note:"文本质量等级(出版 / 精校 / 粗校 / OCR)"},"quality-fine":{value:"#2e7d32"},"quality-rough":{value:"#1565c0"},"quality-ocr":{value:"#e65100"}}),it("版本传承(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"}}),it("编辑器视图(主要在 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")'}}),it("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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}}),it('版式(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"}}),it("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"},"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:"版心外边线"}}),it("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),it("字体(全站无衬线,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:Hr,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:Hr,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],Jd=Object.assign({},...Zd.map(e=>e.tokens)),ba={};for(const[e,n]of Object.entries(Jd))ba[e]=`var(--bim-${e}, ${n.value})`;function i(e){const n=ba[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function Gt(e){return e.types&&e.types.length>0?e.types:e.type?e.type==="text+image"?["text","image"]:[e.type]:[]}function Qd(e,n){return Gt(e).includes(n)}const ep={published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"};i("quality-published"),i("quality-fine"),i("quality-rough"),i("quality-ocr");const Yt=g.createContext(null),ya=["曹霑"];function tp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function np(e,n=ya){const o=[...new Set(n.filter(Boolean))].sort((a,l)=>l.length-a.length);if(!o.length)return e;const r=new RegExp(`(${o.map(tp).join("|")})`,"g"),s=new Set(o);return a=>{if(!a)return e(a);const l=a.split(r);return l.length===1?e(a):l.map((d,c)=>c%2===1&&s.has(d)?d:d&&e(d)).join("")}}let fn=null;function ip(){if(fn)return fn;try{const e=Gd.Converter({from:"t",to:"cn"});fn=np(n=>e(we.normalizeVariants(n)))}catch{fn=e=>e}return fn}const op={indexType:{work:"作品",book:"書籍",collection:"叢編",entity:"人物"},resourceType:{text:"文字資源",image:"圖片資源",textImage:"文字+圖片資源",physical:"館藏"},resourceTypeShort:{text:"文字",image:"圖片",textImage:"文字+圖片",physical:"館藏"},rootType:{catalog:"目錄式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:i("check-fine-bg"),fg:i("check-fine-fg")},粗校:{label:"粗校",bg:i("check-rough-bg"),fg:i("check-rough-fg")},AI整理:{label:"AI整理",bg:i("check-ai-bg"),fg:i("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:"圖片資源"}},rp={indexType:{work:"作品",book:"书籍",collection:"丛编",entity:"人物"},resourceType:{text:"文字资源",image:"图片资源",textImage:"文字+图片资源",physical:"馆藏"},resourceTypeShort:{text:"文字",image:"图片",textImage:"文字+图片",physical:"馆藏"},rootType:{catalog:"目录式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:i("check-fine-bg"),fg:i("check-fine-fg")},粗校:{label:"粗校",bg:i("check-rough-bg"),fg:i("check-rough-fg")},AI整理:{label:"AI整理",bg:i("check-ai-bg"),fg:i("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 rt(e,n,o){return{"zh-Hant":e,"zh-Hans":n}}const sp=rt({toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主題",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加載中",repoSourceLink:"在 GitHub 查看本條目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分冊",expandVolumes:"展開分冊",collapseArrow:"收起 ▲",expandArrow:"展開 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",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:"朝代",anonymous:"佚名",collective:"集体"},cbdbTitle:"CBDB 中国历代人物传记数据库",entityPlaceholderNote:"人物信息暂缺。该 Entity 仅作为作者占位,详细生平资料尚待补充。",otherVersions:"其他版本",switchToEdit:"切换到编辑模式",switchToView:"切换到查看模式",modeEdit:"✏️ 编辑",modeView:"👁 查看",noData:"无数据"}),li=rt({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:"作品信息"}),ap=rt({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:"附记"}}),lp=rt({fact:{written:"成書",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考證",alias:"又名",attached:"附載",appendix:"附錄"},inferredFromEdition:"據版本題名推斷",loading:"載入中",emendationCount:"{n} 條",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著錄"},classifiedBy:"據《{source}》",sec:{versions:"版本",catalogs:"著錄",collected:"收入叢編",related:"相關書目",resources:"在線資源"},versionsTotal:"共 {n} 種",versionsWithImage:"{n} 種有影印",versionsCurrent:"當前 {n} 種",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著錄順序",col:{edition:"版本",era:"年代",holder:"館藏",image:"影印"},noVersionsFiltered:"當前篩選下沒有版本",noVersions:"暫無版本著錄",moreUnit:"種版本",inferredEraNote:"部分年代據版本題名推斷,非著錄原文",empty:"尚未著錄該作品的版本與書目收錄。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"歷代書目 {n} 家",tablist:"著錄書目",titleOnly:"僅著錄書名,無提要。",prev:"上一家:{name}",next:"下一家:{name}"}},{fact:{written:"成书",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考证",alias:"又名",attached:"附载",appendix:"附录"},inferredFromEdition:"据版本题名推断",loading:"载入中",emendationCount:"{n} 条",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著录"},classifiedBy:"据《{source}》",sec:{versions:"版本",catalogs:"著录",collected:"收入丛编",related:"相关书目",resources:"在线资源"},versionsTotal:"共 {n} 种",versionsWithImage:"{n} 种有影印",versionsCurrent:"当前 {n} 种",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著录顺序",col:{edition:"版本",era:"年代",holder:"馆藏",image:"影印"},noVersionsFiltered:"当前筛选下没有版本",noVersions:"暂无版本著录",moreUnit:"种版本",inferredEraNote:"部分年代据版本题名推断,非著录原文",empty:"尚未著录该作品的版本与书目收录。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"历代书目 {n} 家",tablist:"著录书目",titleOnly:"仅著录书名,无提要。",prev:"上一家:{name}",next:"下一家:{name}"}}),cp=rt({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:"上级丛编"}),dp=rt({subtype:{people:"人物",place:"地名",dynasty:"朝代",anonymous:"佚名",collective:"群體"},bce:"前{n}",floruit:"活躍於 {from}—{to}",zi:"字{name}",hao:"號{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 種",moreNames:"更多別名({n})",dist:"著作分佈",autoMatch:"自動匹配",sec:{featured:"著作舉要",allWorks:"全部著作",works:"著作",external:"站外資料"},featuredSub:"存世版本最多的三部",versionsUnit:"種版本",hasImage:"有影印",empty:"尚未著錄該人物的關聯作品。",total:"共 {n} 種",current:"當前 {n} 種",sortByVersions:"按版本數排列",sortByCatalog:"按著錄順序",col:{work:"作品",section:"部類",role:"職任",versions:"存世版本",image:"影印"},notRecorded:"未著錄",emptyRole:"該職任下的著作尚未著錄。",moreUnit:"種著作",cbdbAuto:"CBDB 為自動匹配,未經人工核對"},{subtype:{people:"人物",place:"地名",dynasty:"朝代",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 为自动匹配,未经人工核对"}),pp=rt({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",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:"專名線",vertical:"豎排",closeToc:"收起目錄",sourceLabel:"出處",licenseOf:"授權 {license}",revisedAt:"最近校訂 {date}",reportError:"報告錯字",pagerNav:"翻卷",rail:"本卷",bottomBar:"閱讀工具",tocShort:"卷目",fontSize:"字號",close:"關閉",loading:"加載中…",noText:"暫無文本",tocFailed:"無法加載目錄",tocLoading:"加載目錄…",viewEntry:"查看條目",defaultRole:"撰",tocCaption:"目錄 · {n} {unit}",searchChapters:"搜索全部章節",searchChaptersPlaceholder:"搜索全部章節…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"來源",upstream:"上游",chapterFailed:"無法加載章節內容",references:"參考文獻"},{imagesLoading:"加载书影…",noImages:"暂无书影",noImagesHint:"这一卷还没有配上影像;接入后在此与正文逐页对看",imageAlt:"书影 第 {label} 页",prevImage:"上一页书影",nextImage:"下一页书影",back:"阅读",backAria:"返回{label}首页",skipToText:"跳到正文",settings:"阅读设置",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:"专名线",vertical:"竖排",closeToc:"收起目录",sourceLabel:"出处",licenseOf:"授权 {license}",revisedAt:"最近校订 {date}",reportError:"报告错字",pagerNav:"翻卷",rail:"本卷",bottomBar:"阅读工具",tocShort:"卷目",fontSize:"字号",close:"关闭",loading:"加载中…",noText:"暂无文本",tocFailed:"无法加载目录",tocLoading:"加载目录…",viewEntry:"查看条目",defaultRole:"撰",tocCaption:"目录 · {n} {unit}",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献"}),up=rt({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:{published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"},qualityCriteria:{published:"達到出版、學術研究標準,錯誤率在萬分之一以內",fine:"通讀無障礙,錯誤率在百分之一以內",rough:"保證文意基本正確,錯誤率在百分之三以內",ocr:"保持大意和結構,錯誤率在百分之十以內"},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:{published:"出版",fine:"精校",rough:"粗校",ocr:"机器识别"},qualityCriteria:{published:"达到出版、学术研究标准,错误率在万分之一以内",fine:"通读无障碍,错误率在百分之一以内",rough:"保证文意基本正确,错误率在百分之三以内",ocr:"保持大意和结构,错误率在百分之十以内"},originalSource:"原文来源",viewsGroup:"看法",viewText:"正文",viewEntries:"条目",rowHeadNo:"序",rowHeadTitle:"书名",rowHeadWork:"作品",railCap:"本卷",railUnitPoems:"首",railUnitBooks:"部书",linkedN:"已关联 {n}",linkedOf:"已关联 {n} / {total}",railEntriesNav:"本卷条目"}),mp=rt({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:"规模、存佚、许可与版本"}),$o=rt({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:"按作者浏览全部 →"}),hp=rt({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} 条"}),gp=rt({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:"搜索"}),fp=rt({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:"回复"}),xp=rt({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:"有争议"}}),bp={common:sp,detail:li,bookPage:ap,workPage:lp,collectionPage:cp,entityPage:dp,reader:pp,collated:up,metaHome:mp,readHome:$o,catalogPage:hp,searchPage:gp,feedback:fp,lineage:xp};function yp(e){const n={};for(const[o,r]of Object.entries(bp))n[o]=r[e];return n}function dt(e,n){return e.replace(/\{(\w+)\}/g,(o,r)=>String(n[r]??""))}const Fr=new Map;function ln(e){let n=Fr.get(e);return n||(n={...e==="zh-Hans"?rp:op,...yp(e)},Fr.set(e,n)),n}function Dr(e,n){let o=e;for(const r of n.split(".")){if(o==null||typeof o!="object")return;o=o[r]}return typeof o=="string"?o:void 0}function ja(e){return(n,o)=>{const r=Dr(e,n)??Dr(ln("zh-Hant"),n)??n;return o?dt(r,o):r}}const Ur=new Map;function cn(e){let n=Ur.get(e);return n||(n=ja(ln(e)),Ur.set(e,n)),n}const va="bim-locale";function jp(){try{const e=localStorage.getItem(va);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function vp(e){try{localStorage.setItem(va,e)}catch{}}const kp="zh-Hans",wp=({locale:e,onLocaleChange:n,converter:o,children:r})=>{const[s,a]=g.useState(e??kp),l=e??s;g.useEffect(()=>{if(e)return;const u=jp();u&&u!==s&&a(u)},[]);const d=g.useMemo(()=>l==="zh-Hans"?o??ip():null,[l,o]),c=g.useCallback(u=>{a(u),vp(u),n==null||n(u)},[n]),p=g.useMemo(()=>({locale:l,setLocale:c,messages:ln(l),converter:d}),[l,c,d]);return t.jsx(Yt.Provider,{value:p,children:r})};function $e(){const e=g.useContext(Yt);return(e==null?void 0:e.messages)??ln("zh-Hant")}const Sp=2e3;function Re(){const e=g.useContext(Yt),n=(e==null?void 0:e.locale)??"zh-Hant",o=(e==null?void 0:e.converter)??null,r=g.useRef(new Map),s=g.useRef(n);s.current!==n&&(r.current.clear(),s.current=n);const a=g.useCallback(l=>{if(!l)return"";if(!o)return l;const d=r.current.get(l);if(d!==void 0)return d;const c=o(l);if(r.current.size>=Sp){const p=r.current.keys().next().value;p!==void 0&&r.current.delete(p)}return r.current.set(l,c),c},[o]);return g.useMemo(()=>({convert:a,locale:n,isSimplified:n==="zh-Hans"}),[a,n])}function J(){const e=g.useContext(Yt),{convert:n,locale:o,isSimplified:r}=Re(),s=(e==null?void 0:e.messages)??ln("zh-Hant"),a=g.useMemo(()=>e?ja(s):cn("zh-Hant"),[e,s]);return g.useMemo(()=>({t:a,convert:n,locale:o,isSimplified:r,messages:s}),[a,n,o,r,s])}const ka=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),_p=new Set([...ka,...Object.keys(we.VARIANT_CHARS)]),wa=[...ya,"切換為繁體","漢籍リポジトリ"];function $p(e,n=wa){let o=e;for(const a of n)a&&(o=o.split(a).join(" "));const r=[],s=Array.from(o);return s.forEach((a,l)=>{_p.has(a)&&r.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),r}function Cp(e){if(!e)return"";try{const n=new URL(e).hostname,o={"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(o[n])return o[n];const r=n.split(".");return r.length>=2?r[r.length-2]:n}catch{return""}}function zp(){return{id:"",name:"",url:"",type:"text",details:""}}const eo=({items:e,onChange:n,onDownload:o,downloadStatuses:r,filterType:s})=>{const a=$e(),[l,d]=g.useState(null),c=[{value:"text",label:a.resourceTypeShort.text},{value:"image",label:a.resourceTypeShort.image},{value:"text+image",label:a.resourceTypeShort.textImage},{value:"physical",label:a.resourceTypeShort.physical}],p=[{value:"catalog",label:a.rootType.catalog},{value:"search",label:a.rootType.search}],u=b=>{if(!s)return!0;const j=Gt(b);return s==="text"?j.includes("text"):s==="image"?j.includes("image")||j.includes("physical"):s==="physical"?j.includes("physical"):j.includes(s)},m=e.map((b,j)=>({item:b,originalIndex:j})).filter(({item:b})=>u(b)),h=()=>{const b=zp();s&&(b.type=s),n([...e,b]),d(e.length)},f=b=>{n(e.filter((j,S)=>S!==b)),d(null)},x=(b,j,S)=>{const v=[...e];if(v[b]={...v[b],[j]:S},j==="url"&&!v[b].id){const $=Cp(S);$&&(v[b].id=$)}n(v)},k=(b,j,S)=>{const $={...e[b].metadata||{}};S?$[j]=S:delete $[j],x(b,"metadata",Object.keys($).length>0?$:void 0)},y=(b,j)=>{const S=j.trim()?j.split(/[,,、]/).map(v=>v.trim()).filter(Boolean):void 0;x(b,"structure",S)},w=(b,j,S)=>{const $=e[b].coverage||{level:1,ranges:""};j==="level"?$.level=parseInt(S)||1:$.ranges=S,x(b,"coverage",$.ranges?$:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[m.map(({item:b,originalIndex:j})=>{var S,v,$;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>d(l===j?null:j),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:l===j?"▼":"▶"}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:Tp(b.type??"text"),color:i("on-color-fg")},children:(()=>{var C,M;const _=Gt(b);return _.length===0?b.type??"text":_.length===1?((C=c.find(T=>T.value===_[0]))==null?void 0:C.label)??_[0]:_.includes("text")&&_.includes("image")?((M=c.find(T=>T.value==="text+image"))==null?void 0:M.label)??"text+image":_.join("+")})()}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:b.name||`${a.editor.resourcePlaceholder} ${j+1}`}),b.id&&t.jsx("span",{style:{fontSize:"11px",opacity:.5},children:b.id}),b.url&&t.jsx("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),o&&b.url&&Np(j,r==null?void 0:r[j],o,a),t.jsx("button",{onClick:_=>{_.stopPropagation(),f(j)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:a.editor.deleteThisResource,children:"✕"})]}),l===j&&t.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:[Qd(b,"image")&&b.url&&Ep(b,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:xn,children:[t.jsx("span",{style:bn,children:a.label.type}),t.jsx("select",{value:b.type,onChange:_=>x(j,"type",_.target.value),style:{...bt,flex:1},children:c.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]}),t.jsxs("label",{style:xn,children:[t.jsx("span",{style:bn,children:a.label.rootType}),t.jsx("select",{value:b.root_type||"catalog",onChange:_=>x(j,"root_type",_.target.value),style:{...bt,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:b.id,onChange:_=>x(j,"id",_.target.value),placeholder:a.editor.idAutoExtract,style:{...bt,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:b.name,onChange:_=>x(j,"name",_.target.value),placeholder:a.editor.resourceName,style:{...bt,flex:1}})]}),t.jsx("input",{type:"text",value:b.url,onChange:_=>x(j,"url",_.target.value),placeholder:a.editor.resourceUrl,style:bt}),t.jsx("input",{type:"text",value:((S=b.structure)==null?void 0:S.join("、"))||"",onChange:_=>y(j,_.target.value),placeholder:a.editor.structurePlaceholder,style:bt}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:xn,children:[t.jsx("span",{style:bn,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((v=b.coverage)==null?void 0:v.level)??"",onChange:_=>w(j,"level",_.target.value),placeholder:"1",style:{...bt,width:"60px"}})]}),t.jsxs("label",{style:{...xn,flex:1},children:[t.jsx("span",{style:bn,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:(($=b.coverage)==null?void 0:$.ranges)||"",onChange:_=>w(j,"ranges",_.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...bt,flex:1}})]})]}),t.jsx("textarea",{value:b.details||"",onChange:_=>x(j,"details",_.target.value),placeholder:a.editor.detailsPlaceholder,style:{...bt,minHeight:"60px",resize:"vertical"}}),t.jsxs("div",{style:{borderTop:`1px solid ${i("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"6px"},children:a.label.metadata}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(a.metadata).map(([_,C])=>{var M;return t.jsxs("label",{style:{...xn,gap:"4px"},children:[t.jsx("span",{style:{...bn,minWidth:"56px"},children:C}),t.jsx("input",{type:"text",value:((M=b.metadata)==null?void 0:M[_])||"",onChange:T=>k(j,_,T.target.value),placeholder:C,style:{...bt,flex:1}})]},_)})})]})]})]})]},j)}),t.jsxs("button",{onClick:h,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:a.action.addResource})]})]})};function Tp(e){switch(e){case"text":return i("restype-text");case"image":return i("restype-image");case"text+image":return i("restype-text-image");case"physical":return i("restype-physical")}}function Np(e,n,o,r){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||o(e,"")},disabled:s,style:{background:"transparent",border:"none",color:i(a?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:a?r.download.completed:s?`${r.download.downloading} ${(n==null?void 0:n.progress)||0}%`:r.download.downloadThis,children:a?"✓":s?"⏳":"⬇"})}function Ep(e,n){const o=/\.(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:o?t.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:i("overlay-bg")},children:t.jsx("img",{src:e.url,alt:e.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:r=>{r.target.style.display="none"}})}):t.jsx("div",{style:{padding:"12px",background:i("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:i("desc-fg")},children:n.editor.imageResourceLink})})}const bt={width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},xn={display:"flex",alignItems:"center",gap:"6px"},bn={fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap"},Ip={"commons.wikimedia.org":"維基共享","zh.wikisource.org":"維基文庫","taiwanebook.ncl.edu.tw":"臺灣華文電子書庫","ctext.org":"中國哲學書電子化計劃","www.shidianguji.com":"識典古籍","shidianguji.com":"識典古籍","archive.org":"Internet Archive","www.shuge.org":"書格","shuge.org":"書格","pan.baidu.com":"百度網盤"};function dn(e){try{return Ip[new URL(e).hostname]}catch{return}}const Vr={text:0,image:1,physical:2};function Co(e){return e.length===0?"physical":[...e].sort((n,o)=>(Vr[n]??99)-(Vr[o]??99)).join("+")}function zo(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},o=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[u,m]=p,h=`${u}|${Co(Gt(c))}`;o.has(h)||o.set(h,{base:{...c,name:u,url:"",volumes:[]},volumes:[],indices:[]});const f=o.get(h);f.volumes.push({volume:m,url:c.url||void 0,status:"found"}),f.indices.push(d)}const r=[],s=new Set;for(const d of o.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)??""),r.push(d.base);for(const c of d.indices)s.add(c)}const a=[...r];for(let d=0;d<e.length;d++)s.has(d)||a.push(e[d]);return a}function Sa(e){if(e.url)return e.url;for(const[n,o]of Object.entries(e))if(n.endsWith("_url")&&typeof o=="string")return o}function _a(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||Sa(n)}))}function ci(e){const n=_a(e);if(!n)return null;const o=new Set(n.filter(s=>s.status!=="missing").map(s=>s.volume)).size,r=new Set(n.filter(s=>s.status==="missing").map(s=>s.volume)).size;return{found:o,missing:r,expected:e.expected_volumes??o+r}}function To(e){if(!e)return;const n=e.file_page_range||e.page_range;if(!n||typeof n!="string")return;const o=n.match(/^(\d+)/);return o?parseInt(o[1],10):void 0}function No(e,n){try{if(new URL(e).hostname.includes("wikimedia.org")){const r=e.match(/\/wiki\/File:(.+?)(?:#|$)/);if(r)return`https://commons.wikimedia.org/w/index.php?title=File%3A${encodeURIComponent(decodeURIComponent(r[1]))}&page=${n}`;const s=new URL(e);return s.searchParams.set("page",String(n)),s.toString()}return e}catch{return e}}function pn(e){if(!e.url)return;const n=To(e.metadata);return n?No(e.url,n):e.url}const Gr={text:i("restype-text"),image:i("restype-image"),"text+image":i("restype-text-image"),physical:i("restype-physical")};function Rp(e){return e.includes("text")&&e.includes("image")?Gr["text+image"]:Gr[e[0]||"physical"]}const Eo=({items:e,groupByType:n=!0,resourceGroups:o,onNavigate:r,renderLink:s})=>{const a=$e(),{convert:l}=Re(),d=g.useMemo(()=>zo(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=g.useMemo(()=>{const y=new Map,w=[];for(const b of d){const j=b.group;j?(y.has(j)||y.set(j,[]),y.get(j).push(b)):w.push(b)}for(const b of y.values())b.sort((j,S)=>{const v=$=>$.group_role==="origin"?0:$.group_role==="mirror"?1:2;return v(j)-v(S)});return{mirrorGroups:y,ungroupedItems:w}},[d]),u={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},m=y=>u[y]?u[y]:y.split("+").map(w=>u[w]||w).join("+");if(!d||d.length===0)return t.jsx("div",{style:{padding:"16px",color:i("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,w)=>t.jsx(Pi,{item:y},y.id||w))});const h=(y,w)=>{const b=o==null?void 0:o[y],j=(b==null?void 0:b.label)||y,S=b==null?void 0:b.description;return t.jsxs("div",{style:{padding:"10px 12px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:i("input-bg"),display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:l(j)}),S&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.5},children:l(S)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:w.map((v,$)=>t.jsx(Pi,{item:v,onNavigate:r,renderLink:s},v.id||$))})]},`group-${y}`)},f=new Map;for(const y of p){const w=Co(Gt(y));f.has(w)||f.set(w,[]),f.get(w).push(y)}const x=["text","image","text+image","physical"],k=[...x.filter(y=>f.has(y)),...[...f.keys()].filter(y=>!x.includes(y)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,w])=>h(y,w)),k.map(y=>{const w=f.get(y),b=Rp(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:w.map((j,S)=>t.jsx(Pi,{item:j,onNavigate:r,renderLink:s},j.id||S))})]},y)})]})},Lp={bw:{label:"",bg:i("colormode-bw-bg"),fg:i("colormode-bw-fg")},color:{label:"",bg:i("colormode-color-bg"),fg:i("colormode-color-fg")}},Pi=({item:e})=>{const n=$e(),{convert:o}=Re(),[r,s]=g.useState(!1),a=g.useMemo(()=>(e.url?dn(e.url):void 0)||o(e.name),[e.url,e.name,o]),l=g.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||Sa(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,u=e.expected_volumes??(d?c+p:0),m=e.color_mode?{...Lp[e.color_mode],label:n.colorMode[e.color_mode]}:null,h=e.details&&!d?o(e.details):null,f={display:"inline-flex",alignItems:"center",gap:"5px",padding:"4px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",background:i("input-bg"),fontSize:"12px",color:i("fg"),lineHeight:1.4,verticalAlign:"middle"};return t.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[t.jsxs("div",{style:f,children:[t.jsx("span",{style:{fontWeight:500},children:a}),m&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:m.bg,color:m.fg},children:m.label}),h&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:h}),d&&t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[c,"/",u,n.unit.volume,p>0&&t.jsx("span",{style:{color:i("missing-fg"),marginLeft:"3px"},children:dt(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=To(e.metadata);return x?No(e.url,x):e.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:i("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),d&&t.jsx("button",{onClick:()=>s(!r),style:{padding:"0 6px",fontSize:"11px",border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",lineHeight:1.4},children:r?"▲":"▼"})]}),d&&r&&t.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:l.map(x=>{const k=x.status==="missing";return x.url&&!k?t.jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",borderRadius:"3px",border:`1px solid ${i("widget-border")}`,color:i("link-fg"),textDecoration:"none"},children:x.volume},x.volume):t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:i(k?"missing-fg":"desc-fg"),textDecoration:k?"line-through":"none",opacity:k?.6:1},children:x.volume},x.volume)})})]})},$a=({indexSource:e,syncConfig:n,variant:o="index-browser",onSwitchMode:r,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=$e(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,u=(n==null?void 0:n.repoPath)||"",m=u?u.split(/[/\\]/).pop()||u:"",h={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:i("primary-soft"),color:i("primary")},f={onMouseOver:k=>k.currentTarget.style.opacity="0.8",onMouseOut:k=>k.currentTarget.style.opacity="1"},x=t.jsxs("div",{onClick:s,title:p?d.mode.switchToOfficial:d.mode.switchToDraft,style:{...h,background:i(p?"warning":"success"),color:i("on-color-fg")},...f,children:[t.jsx("span",{children:p?"📝":"📚"}),t.jsx("span",{children:p?"draft":"official"})]});return o==="index-browser"?c?t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[x,t.jsxs("div",{onClick:r,title:d.mode.switchToSync,style:h,...f,children:[t.jsx("span",{children:"📁"}),t.jsx("span",{children:d.mode.localMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsxs("div",{onClick:l,title:u||d.mode.selectFolder,style:{...h,paddingLeft:"8px",paddingRight:"8px"},...f,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:r,title:d.mode.switchToLocal,style:h,...f,children:[t.jsx("span",{children:"🌐"}),t.jsx("span",{children:d.mode.syncMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsx("div",{onClick:a,title:m||d.mode.configurePath,style:{...h,background:"transparent",padding:"6px",fontSize:"12px"},...f,children:t.jsx("span",{children:"⚙️"})})]})]}):t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[t.jsxs("div",{onClick:r,title:c?d.mode.switchToGithub:d.mode.switchToLocal,style:h,...f,children:[t.jsx("span",{children:c?"📁":"🌐"}),t.jsx("span",{children:c?d.mode.localMode:d.mode.githubSync}),t.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&t.jsxs("div",{onClick:l,title:u||d.mode.selectFolder,style:{...h,paddingLeft:"8px",paddingRight:"8px",minWidth:u?"100px":"auto",justifyContent:"space-between"},...f,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]}),!c&&m&&t.jsxs("div",{style:{...h,background:i("mode-active-bg"),color:i("on-color-fg"),cursor:"default"},title:u,children:[t.jsx("span",{children:"📂"}),t.jsx("span",{style:{fontSize:"11px"},children:m})]})]})},di="bim-search-history",Yr=10,Kr=8;function $n(){try{const e=localStorage.getItem(di);return e?JSON.parse(e):[]}catch{return[]}}function Ca(e){try{const n=$n().filter(o=>o!==e);n.unshift(e),n.length>Yr&&(n.length=Yr),localStorage.setItem(di,JSON.stringify(n))}catch{}}function Ap(e){try{const n=$n().filter(o=>o!==e);localStorage.setItem(di,JSON.stringify(n))}catch{}}function Pp(){try{localStorage.removeItem(di)}catch{}}const za=({transport:e,value:n,onChange:o,onSearch:r,onEntrySelect:s,placeholder:a})=>{const l=$e(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,u]=g.useState(!1),[m,h]=g.useState([]),[f,x]=g.useState(-1),[k,y]=g.useState($n),w=g.useRef(null),b=g.useRef(null),j=g.useRef(null),S=g.useRef(!1);g.useEffect(()=>{x(-1);const z=n.trim();if(!z){h(k.map(R=>({type:"history",text:R})));return}if(!e.searchAll){h([]);return}let F=!1;const N=setTimeout(()=>{e.searchAll(z,Kr).then(R=>{if(F)return;const O=[...R.works,...R.books,...R.collections,...R.entities??[]];h(O.slice(0,Kr).map(I=>({type:"entry",text:I.title||I.id,entry:I})))}).catch(()=>{F||h([])})},80);return()=>{F=!0,clearTimeout(N)}},[n,k,e]),g.useEffect(()=>{const z=F=>{j.current&&!j.current.contains(F.target)&&u(!1)};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]),g.useEffect(()=>{const z=F=>{var N,R;if(F.key==="/"&&document.activeElement!==w.current){const O=(N=document.activeElement)==null?void 0:N.tagName;if(O==="INPUT"||O==="TEXTAREA"||O==="SELECT")return;F.preventDefault(),(R=w.current)==null||R.focus()}};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[]);const v=g.useCallback(z=>{z.trim()&&(Ca(z.trim()),y($n())),r(z),u(!1)},[r]),$=g.useCallback(z=>{z.type==="history"?(o(z.text),v(z.text)):z.entry&&(s?(s(z.entry),u(!1)):(o(z.text),v(z.text)))},[o,v,s]),_=g.useCallback(z=>{if(!p||m.length===0){z.key==="Enter"&&v(n);return}switch(z.key){case"ArrowDown":z.preventDefault(),x(F=>(F+1)%m.length);break;case"ArrowUp":z.preventDefault(),x(F=>(F-1+m.length)%m.length);break;case"Enter":z.preventDefault(),f>=0&&f<m.length?$(m[f]):v(n);break;case"Escape":z.preventDefault(),u(!1);break}},[p,m,f,n,v,$]),C=g.useCallback((z,F)=>{F.stopPropagation(),Ap(z),y($n()),h(N=>N.filter(R=>!(R.type==="history"&&R.text===z)))},[]),M=g.useCallback(z=>{z.stopPropagation(),Pp(),y([]),h([])},[]);g.useEffect(()=>{if(f>=0&&b.current){const z=b.current.children;z[f]&&z[f].scrollIntoView({block:"nearest"})}},[f]);const T=!n.trim()&&k.length>0;return t.jsxs("div",{ref:j,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:w,type:"text",placeholder:d,value:n,onChange:z=>{o(z.target.value),u(!0)},onCompositionStart:()=>{S.current=!0},onCompositionEnd:()=>{S.current=!1},onFocus:()=>{u(!0)},onKeyDown:_,style:{width:"100%",padding:"8px 12px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("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:i("input-bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"6px",boxShadow:i("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:i("desc-fg"),borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsx("span",{children:l.search.history}),t.jsx("button",{onClick:M,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),m.map((z,F)=>t.jsxs("div",{onClick:()=>$(z),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:i("fg"),background:F===f?i("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:z.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.text}),z.entry&&t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:[c[z.entry.type],z.entry.edition&&` · ${z.entry.edition}`,z.entry.author&&` · ${z.entry.author}`]}),z.type==="history"&&t.jsx("button",{onClick:N=>C(z.text,N),style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:l.action.remove,children:"×"})]},`${z.type}-${z.text}-${F}`))]})]})},un=({type:e,size:n=9})=>t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:i(`type-${e}`),verticalAlign:"middle"}}),pi={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},Ta=new Set(["work","book","entity"]);function Mp(e){return Ia(e)||!!e.sort}function Bp(e,n){return n.sort&&Ta.has(e)?n.sort:void 0}const ui=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],mi=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],Na=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],Ea={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 Ia(e){return hi(e)>0}function Wp(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 Ra(e,n){const o=Ea[e];return Wp(n).every(r=>o.has(r))}const yn=e=>JSON.stringify(e);function Op(e,n){if(!Ra(n,e))return null;const o=[];if(e.dynasty.length){const r=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=ui.find(l=>l.key===s))==null?void 0:a.values)??[]})));r.length===1?o.push(`dynasty = ${yn(r[0])}`):r.length>1&&o.push(`dynasty IN [${r.map(yn).join(", ")}]`)}return e.classification.length&&o.push(e.classification.length===1?`classification = ${yn(e.classification[0])}`:`classification IN [${e.classification.map(yn).join(", ")}]`),e.hasImage&&o.push("has_image = true"),e.hasText&&o.push("has_text = true"),e.hasCollated&&o.push("has_collated = true"),e.loss&&o.push(`loss_status = ${yn(e.loss)}`),o.join(" AND ")}const nt={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},La="_";function ti(e,n=new URLSearchParams){for(const o of Object.values(nt))n.delete(o);return e.dynasty.length&&n.set(nt.dynasty,e.dynasty.join(",")),e.classification.length&&n.set(nt.classification,e.classification.map(o=>o||La).join(",")),e.hasImage&&n.set(nt.hasImage,"1"),e.hasText&&n.set(nt.hasText,"1"),e.hasCollated&&n.set(nt.hasCollated,"1"),e.loss&&n.set(nt.loss,e.loss),e.sort&&n.set(nt.sort,e.sort),n}function Hp(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),o=new Set(ui.map(a=>a.key)),r=new Set(mi.map(a=>a.value)),s=e.get(nt.loss);return{dynasty:Array.from(new Set(n(nt.dynasty).filter(a=>o.has(a)))),classification:Array.from(new Set(n(nt.classification).map(a=>a===La?"":a).filter(a=>r.has(a)))),hasImage:e.get(nt.hasImage)==="1",hasText:e.get(nt.hasText)==="1"||e.get(nt.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(nt.sort))??""}}function Fp(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 qr(e,n){return e.includes(n)?e.filter(o=>o!==n):[...e,n]}const Dp=({filters:e,onChange:n})=>{const o=$e(),r=o.searchV4,{convert:s}=Re(),[a,l]=g.useState(!1),d=g.useId(),c=hi(e),p=u=>n({...e,...u});return t.jsxs("aside",{className:"bim-sr-aside","aria-label":s(r.filterTitle),children:[t.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":a,"aria-controls":d,onClick:()=>l(u=>!u),children:[t.jsxs("span",{children:[s(r.filterButton),c>0&&t.jsx("span",{className:"bim-sr-fn",children:s(dt(r.filterSelected,{n:c}))})]}),t.jsxs("span",{className:"bim-sr-fa","aria-hidden":"true",children:[s(a?r.collapse:r.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(r.dynasty)}),t.jsx("div",{className:"bim-sr-chips",children:ui.map(u=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(u.key),onClick:()=>p({dynasty:qr(e.dynasty,u.key)}),children:s(u.key)},u.key))})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(r.classification)}),mi.map(u=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(u.value),onChange:()=>p({classification:qr(e.classification,u.value)})}),u.value?s(u.label):o.searchPage.unclassified]},u.value||"_"))]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(r.resources)}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasImage,onChange:u=>p({hasImage:u.target.checked})}),s(r.hasImage)]}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasText,onChange:u=>p({hasText:u.target.checked})}),s(r.hasText)]})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{id:`${d}-loss`,children:s(r.extant)}),t.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${d}-loss`,children:Na.map(u=>t.jsx("button",{type:"button","aria-pressed":e.loss===u.value,onClick:()=>p({loss:u.value}),children:o.searchPage.loss[u.value||"all"]},u.value||"all"))})]}),c>0&&t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...pi,sort:e.sort}),children:s(r.clearAllFilters)})]})]})};function Aa({text:e,query:n}){const o=(n??"").trim();if(!o||!e)return t.jsx(t.Fragment,{children:e});const r=e.toLowerCase(),s=o.toLowerCase(),a=[];let l=0,d=0;for(;l<e.length;){const c=r.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 Xr=({entries:e,query:n,onEntryLinkClick:o,typeName:r})=>{const s=$e(),a=s.searchV4,{convert:l}=Re(),d=Xe();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),u=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)}`:""}`:"",h=c.type==="book"?c.era??c.dynasty:c.dynasty,f=h?l(h):"",x=c.classification?l(c.classification):"",k=[];c.has_image&&k.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&k.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&k.push({label:a.tagLost,cls:"bim-sr-tag--lost"});const y=[m,f,x].filter(Boolean).join(" · ");return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-sr-c-title",children:[t.jsxs("div",{className:"bim-sr-tl",children:[t.jsx("a",{href:d(c.id),onClick:w=>o(c,w),children:t.jsx(Aa,{text:p,query:n?l(n):void 0})}),u&&t.jsx("span",{className:"bim-sr-measure",children:u})]}),y&&t.jsx("span",{className:"bim-sr-sub",children:y})]}),t.jsxs("td",{className:"bim-sr-c-type",children:[t.jsx(un,{type:c.type,size:6})," ",r(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:m||"—"}),t.jsx("td",{className:"bim-sr-c-era",children:f||"—"}),t.jsx("td",{className:"bim-sr-c-cls",children:x||"—"}),t.jsx("td",{className:"bim-sr-c-res",children:k.map(w=>t.jsx("span",{className:`bim-sr-tag ${w.cls}`,children:l(w.label)},w.label))})]},c.id)})})]})})},Up=`
|
|
1
|
+
"use strict";var Ud=Object.create;var Ur=Object.defineProperty;var Vd=Object.getOwnPropertyDescriptor;var Gd=Object.getOwnPropertyNames;var Yd=Object.getPrototypeOf,Kd=Object.prototype.hasOwnProperty;var qd=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Gd(n))!Kd.call(e,s)&&s!==o&&Ur(e,s,{get:()=>n[s],enumerable:!(r=Vd(n,s))||r.enumerable});return e};var Yn=(e,n,o)=>(o=e!=null?Ud(Yd(e)):{},qd(n||!e||!e.__esModule?Ur(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const we=require("./storage-entry-C9uAfe4i.cjs"),t=require("react/jsx-runtime"),g=require("react"),Xd=require("opencc-js/t2cn"),Zd=require("react-markdown"),Jd=require("remark-gfm"),Qd=e=>`/book-index?id=${e}`,ya=g.createContext(Qd);function ep({buildUrl:e,children:n}){const o=g.useMemo(()=>e,[e]);return t.jsx(ya.Provider,{value:o,children:n})}function Xe(){return g.useContext(ya)}const ja="",va="";function zo(e){const n=[];let o=!1,r=e;for(;r.length;){const s=o?va:ja,a=r.indexOf(s);if(a===-1){n.push({text:r,marked:o});break}a>0&&n.push({text:r.slice(0,a),marked:o}),r=r.slice(a+1),o=!o}return n}function ot(e,n){return{title:e,tokens:n}}const Vr='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',tp=[ot("基础(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"}}),ot("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),ot("提示与警告",{"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)"}}),ot("遮罩与阴影",{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)"}}),ot("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),ot("资源",{"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"}}),ot("整理本(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-published":{value:"#1b5e20",note:"文本质量等级(出版 / 精校 / 粗校 / OCR)"},"quality-fine":{value:"#2e7d32"},"quality-rough":{value:"#1565c0"},"quality-ocr":{value:"#e65100"}}),ot("版本传承(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"}}),ot("编辑器视图(主要在 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")'}}),ot("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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}}),ot('版式(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"}}),ot("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"},"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:"版心外边线"}}),ot("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),ot("字体(全站无衬线,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:Vr,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:Vr,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],np=Object.assign({},...tp.map(e=>e.tokens)),ka={};for(const[e,n]of Object.entries(np))ka[e]=`var(--bim-${e}, ${n.value})`;function i(e){const n=ka[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:e.type?e.type==="text+image"?["text","image"]:[e.type]:[]}function ip(e,n){return Vt(e).includes(n)}const op={published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"};i("quality-published"),i("quality-fine"),i("quality-rough"),i("quality-ocr");const Gt=g.createContext(null),wa=["曹霑"];function rp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sp(e,n=wa){const o=[...new Set(n.filter(Boolean))].sort((a,l)=>l.length-a.length);if(!o.length)return e;const r=new RegExp(`(${o.map(rp).join("|")})`,"g"),s=new Set(o);return a=>{if(!a)return e(a);const l=a.split(r);return l.length===1?e(a):l.map((d,c)=>c%2===1&&s.has(d)?d:d&&e(d)).join("")}}let xn=null;function ap(){if(xn)return xn;try{const e=Xd.Converter({from:"t",to:"cn"});xn=sp(n=>e(we.normalizeVariants(n)))}catch{xn=e=>e}return xn}const lp={indexType:{work:"作品",book:"書籍",collection:"叢編",entity:"人物"},resourceType:{text:"文字資源",image:"圖片資源",textImage:"文字+圖片資源",physical:"館藏"},resourceTypeShort:{text:"文字",image:"圖片",textImage:"文字+圖片",physical:"館藏"},rootType:{catalog:"目錄式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:i("check-fine-bg"),fg:i("check-fine-fg")},粗校:{label:"粗校",bg:i("check-rough-bg"),fg:i("check-rough-fg")},AI整理:{label:"AI整理",bg:i("check-ai-bg"),fg:i("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:"圖片資源"}},cp={indexType:{work:"作品",book:"书籍",collection:"丛编",entity:"人物"},resourceType:{text:"文字资源",image:"图片资源",textImage:"文字+图片资源",physical:"馆藏"},resourceTypeShort:{text:"文字",image:"图片",textImage:"文字+图片",physical:"馆藏"},rootType:{catalog:"目录式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:i("check-fine-bg"),fg:i("check-fine-fg")},粗校:{label:"粗校",bg:i("check-rough-bg"),fg:i("check-rough-fg")},AI整理:{label:"AI整理",bg:i("check-ai-bg"),fg:i("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 st(e,n,o){return{"zh-Hant":e,"zh-Hans":n}}const dp=st({toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主題",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加載中",repoSourceLink:"在 GitHub 查看本條目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分冊",expandVolumes:"展開分冊",collapseArrow:"收起 ▲",expandArrow:"展開 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",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:"朝代",anonymous:"佚名",collective:"集体"},cbdbTitle:"CBDB 中国历代人物传记数据库",entityPlaceholderNote:"人物信息暂缺。该 Entity 仅作为作者占位,详细生平资料尚待补充。",otherVersions:"其他版本",switchToEdit:"切换到编辑模式",switchToView:"切换到查看模式",modeEdit:"✏️ 编辑",modeView:"👁 查看",noData:"无数据"}),di=st({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:"作品信息"}),pp=st({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:"附记"}}),up=st({fact:{written:"成書",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考證",alias:"又名",attached:"附載",appendix:"附錄"},inferredFromEdition:"據版本題名推斷",loading:"載入中",emendationCount:"{n} 條",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著錄"},classifiedBy:"據《{source}》",sec:{versions:"版本",catalogs:"著錄",collected:"收入叢編",related:"相關書目",resources:"在線資源"},versionsTotal:"共 {n} 種",versionsWithImage:"{n} 種有影印",versionsCurrent:"當前 {n} 種",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著錄順序",col:{edition:"版本",era:"年代",holder:"館藏",image:"影印"},noVersionsFiltered:"當前篩選下沒有版本",noVersions:"暫無版本著錄",moreUnit:"種版本",inferredEraNote:"部分年代據版本題名推斷,非著錄原文",empty:"尚未著錄該作品的版本與書目收錄。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"歷代書目 {n} 家",tablist:"著錄書目",titleOnly:"僅著錄書名,無提要。",prev:"上一家:{name}",next:"下一家:{name}"}},{fact:{written:"成书",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考证",alias:"又名",attached:"附载",appendix:"附录"},inferredFromEdition:"据版本题名推断",loading:"载入中",emendationCount:"{n} 条",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著录"},classifiedBy:"据《{source}》",sec:{versions:"版本",catalogs:"著录",collected:"收入丛编",related:"相关书目",resources:"在线资源"},versionsTotal:"共 {n} 种",versionsWithImage:"{n} 种有影印",versionsCurrent:"当前 {n} 种",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著录顺序",col:{edition:"版本",era:"年代",holder:"馆藏",image:"影印"},noVersionsFiltered:"当前筛选下没有版本",noVersions:"暂无版本著录",moreUnit:"种版本",inferredEraNote:"部分年代据版本题名推断,非著录原文",empty:"尚未著录该作品的版本与书目收录。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"历代书目 {n} 家",tablist:"著录书目",titleOnly:"仅著录书名,无提要。",prev:"上一家:{name}",next:"下一家:{name}"}}),mp=st({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:"上级丛编"}),hp=st({subtype:{people:"人物",place:"地名",dynasty:"朝代",anonymous:"佚名",collective:"群體"},bce:"前{n}",floruit:"活躍於 {from}—{to}",zi:"字{name}",hao:"號{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 種",moreNames:"更多別名({n})",dist:"著作分佈",autoMatch:"自動匹配",sec:{featured:"著作舉要",allWorks:"全部著作",works:"著作",external:"站外資料"},featuredSub:"存世版本最多的三部",versionsUnit:"種版本",hasImage:"有影印",empty:"尚未著錄該人物的關聯作品。",total:"共 {n} 種",current:"當前 {n} 種",sortByVersions:"按版本數排列",sortByCatalog:"按著錄順序",col:{work:"作品",section:"部類",role:"職任",versions:"存世版本",image:"影印"},notRecorded:"未著錄",emptyRole:"該職任下的著作尚未著錄。",moreUnit:"種著作",cbdbAuto:"CBDB 為自動匹配,未經人工核對"},{subtype:{people:"人物",place:"地名",dynasty:"朝代",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 为自动匹配,未经人工核对"}),gp=st({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",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:"專名線",vertical:"豎排",closeToc:"收起目錄",sourceLabel:"出處",licenseOf:"授權 {license}",revisedAt:"最近校訂 {date}",reportError:"報告錯字",pagerNav:"翻卷",rail:"本卷",bottomBar:"閱讀工具",tocShort:"卷目",fontSize:"字號",close:"關閉",loading:"加載中…",noText:"暫無文本",tocFailed:"無法加載目錄",tocLoading:"加載目錄…",viewEntry:"查看條目",defaultRole:"撰",tocCaption:"目錄 · {n} {unit}",searchChapters:"搜索全部章節",searchChaptersPlaceholder:"搜索全部章節…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"來源",upstream:"上游",chapterFailed:"無法加載章節內容",references:"參考文獻"},{imagesLoading:"加载书影…",noImages:"暂无书影",noImagesHint:"这一卷还没有配上影像;接入后在此与正文逐页对看",imageAlt:"书影 第 {label} 页",prevImage:"上一页书影",nextImage:"下一页书影",back:"阅读",backAria:"返回{label}首页",skipToText:"跳到正文",settings:"阅读设置",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:"专名线",vertical:"竖排",closeToc:"收起目录",sourceLabel:"出处",licenseOf:"授权 {license}",revisedAt:"最近校订 {date}",reportError:"报告错字",pagerNav:"翻卷",rail:"本卷",bottomBar:"阅读工具",tocShort:"卷目",fontSize:"字号",close:"关闭",loading:"加载中…",noText:"暂无文本",tocFailed:"无法加载目录",tocLoading:"加载目录…",viewEntry:"查看条目",defaultRole:"撰",tocCaption:"目录 · {n} {unit}",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献"}),fp=st({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:{published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"},qualityCriteria:{published:"達到出版、學術研究標準,錯誤率在萬分之一以內",fine:"通讀無障礙,錯誤率在百分之一以內",rough:"保證文意基本正確,錯誤率在百分之三以內",ocr:"保持大意和結構,錯誤率在百分之十以內"},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:{published:"出版",fine:"精校",rough:"粗校",ocr:"机器识别"},qualityCriteria:{published:"达到出版、学术研究标准,错误率在万分之一以内",fine:"通读无障碍,错误率在百分之一以内",rough:"保证文意基本正确,错误率在百分之三以内",ocr:"保持大意和结构,错误率在百分之十以内"},originalSource:"原文来源",viewsGroup:"看法",viewText:"正文",viewEntries:"条目",rowHeadNo:"序",rowHeadTitle:"书名",rowHeadWork:"作品",railCap:"本卷",railUnitPoems:"首",railUnitBooks:"部书",linkedN:"已关联 {n}",linkedOf:"已关联 {n} / {total}",railEntriesNav:"本卷条目"}),xp=st({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:"规模、存佚、许可与版本"}),To=st({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:"按作者浏览全部 →"}),bp=st({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} 条"}),yp=st({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:"搜索"}),jp=st({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:"回复"}),vp=st({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:"有争议"}}),kp={common:dp,detail:di,bookPage:pp,workPage:up,collectionPage:mp,entityPage:hp,reader:gp,collated:fp,metaHome:xp,readHome:To,catalogPage:bp,searchPage:yp,feedback:jp,lineage:vp};function wp(e){const n={};for(const[o,r]of Object.entries(kp))n[o]=r[e];return n}function pt(e,n){return e.replace(/\{(\w+)\}/g,(o,r)=>String(n[r]??""))}const Gr=new Map;function ln(e){let n=Gr.get(e);return n||(n={...e==="zh-Hans"?cp:lp,...wp(e)},Gr.set(e,n)),n}function Yr(e,n){let o=e;for(const r of n.split(".")){if(o==null||typeof o!="object")return;o=o[r]}return typeof o=="string"?o:void 0}function Sa(e){return(n,o)=>{const r=Yr(e,n)??Yr(ln("zh-Hant"),n)??n;return o?pt(r,o):r}}const Kr=new Map;function cn(e){let n=Kr.get(e);return n||(n=Sa(ln(e)),Kr.set(e,n)),n}const _a="bim-locale";function Sp(){try{const e=localStorage.getItem(_a);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function _p(e){try{localStorage.setItem(_a,e)}catch{}}const $p="zh-Hans",Cp=({locale:e,onLocaleChange:n,converter:o,children:r})=>{const[s,a]=g.useState(e??$p),l=e??s;g.useEffect(()=>{if(e)return;const u=Sp();u&&u!==s&&a(u)},[]);const d=g.useMemo(()=>l==="zh-Hans"?o??ap():null,[l,o]),c=g.useCallback(u=>{a(u),_p(u),n==null||n(u)},[n]),p=g.useMemo(()=>({locale:l,setLocale:c,messages:ln(l),converter:d}),[l,c,d]);return t.jsx(Gt.Provider,{value:p,children:r})};function $e(){const e=g.useContext(Gt);return(e==null?void 0:e.messages)??ln("zh-Hant")}const zp=2e3;function Ie(){const e=g.useContext(Gt),n=(e==null?void 0:e.locale)??"zh-Hant",o=(e==null?void 0:e.converter)??null,r=g.useRef(new Map),s=g.useRef(n);s.current!==n&&(r.current.clear(),s.current=n);const a=g.useCallback(l=>{if(!l)return"";if(!o)return l;const d=r.current.get(l);if(d!==void 0)return d;const c=o(l);if(r.current.size>=zp){const p=r.current.keys().next().value;p!==void 0&&r.current.delete(p)}return r.current.set(l,c),c},[o]);return g.useMemo(()=>({convert:a,locale:n,isSimplified:n==="zh-Hans"}),[a,n])}function Q(){const e=g.useContext(Gt),{convert:n,locale:o,isSimplified:r}=Ie(),s=(e==null?void 0:e.messages)??ln("zh-Hant"),a=g.useMemo(()=>e?Sa(s):cn("zh-Hant"),[e,s]);return g.useMemo(()=>({t:a,convert:n,locale:o,isSimplified:r,messages:s}),[a,n,o,r,s])}const $a=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),Tp=new Set([...$a,...Object.keys(we.VARIANT_CHARS)]),Ca=[...wa,"切換為繁體","漢籍リポジトリ"];function Np(e,n=Ca){let o=e;for(const a of n)a&&(o=o.split(a).join(" "));const r=[],s=Array.from(o);return s.forEach((a,l)=>{Tp.has(a)&&r.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),r}function Ep(e){if(!e)return"";try{const n=new URL(e).hostname,o={"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(o[n])return o[n];const r=n.split(".");return r.length>=2?r[r.length-2]:n}catch{return""}}function Ip(){return{id:"",name:"",url:"",type:"text",details:""}}const io=({items:e,onChange:n,onDownload:o,downloadStatuses:r,filterType:s})=>{const a=$e(),[l,d]=g.useState(null),c=[{value:"text",label:a.resourceTypeShort.text},{value:"image",label:a.resourceTypeShort.image},{value:"text+image",label:a.resourceTypeShort.textImage},{value:"physical",label:a.resourceTypeShort.physical}],p=[{value:"catalog",label:a.rootType.catalog},{value:"search",label:a.rootType.search}],u=b=>{if(!s)return!0;const j=Vt(b);return s==="text"?j.includes("text"):s==="image"?j.includes("image")||j.includes("physical"):s==="physical"?j.includes("physical"):j.includes(s)},m=e.map((b,j)=>({item:b,originalIndex:j})).filter(({item:b})=>u(b)),h=()=>{const b=Ip();s&&(b.type=s),n([...e,b]),d(e.length)},f=b=>{n(e.filter((j,S)=>S!==b)),d(null)},x=(b,j,S)=>{const v=[...e];if(v[b]={...v[b],[j]:S},j==="url"&&!v[b].id){const $=Ep(S);$&&(v[b].id=$)}n(v)},k=(b,j,S)=>{const $={...e[b].metadata||{}};S?$[j]=S:delete $[j],x(b,"metadata",Object.keys($).length>0?$:void 0)},y=(b,j)=>{const S=j.trim()?j.split(/[,,、]/).map(v=>v.trim()).filter(Boolean):void 0;x(b,"structure",S)},w=(b,j,S)=>{const $=e[b].coverage||{level:1,ranges:""};j==="level"?$.level=parseInt(S)||1:$.ranges=S,x(b,"coverage",$.ranges?$:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[m.map(({item:b,originalIndex:j})=>{var S,v,$;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>d(l===j?null:j),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:l===j?"▼":"▶"}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:Rp(b.type??"text"),color:i("on-color-fg")},children:(()=>{var C,M;const _=Vt(b);return _.length===0?b.type??"text":_.length===1?((C=c.find(T=>T.value===_[0]))==null?void 0:C.label)??_[0]:_.includes("text")&&_.includes("image")?((M=c.find(T=>T.value==="text+image"))==null?void 0:M.label)??"text+image":_.join("+")})()}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:b.name||`${a.editor.resourcePlaceholder} ${j+1}`}),b.id&&t.jsx("span",{style:{fontSize:"11px",opacity:.5},children:b.id}),b.url&&t.jsx("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),o&&b.url&&Lp(j,r==null?void 0:r[j],o,a),t.jsx("button",{onClick:_=>{_.stopPropagation(),f(j)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:a.editor.deleteThisResource,children:"✕"})]}),l===j&&t.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:[ip(b,"image")&&b.url&&Ap(b,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:bn,children:[t.jsx("span",{style:yn,children:a.label.type}),t.jsx("select",{value:b.type,onChange:_=>x(j,"type",_.target.value),style:{...yt,flex:1},children:c.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]}),t.jsxs("label",{style:bn,children:[t.jsx("span",{style:yn,children:a.label.rootType}),t.jsx("select",{value:b.root_type||"catalog",onChange:_=>x(j,"root_type",_.target.value),style:{...yt,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:b.id,onChange:_=>x(j,"id",_.target.value),placeholder:a.editor.idAutoExtract,style:{...yt,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:b.name,onChange:_=>x(j,"name",_.target.value),placeholder:a.editor.resourceName,style:{...yt,flex:1}})]}),t.jsx("input",{type:"text",value:b.url,onChange:_=>x(j,"url",_.target.value),placeholder:a.editor.resourceUrl,style:yt}),t.jsx("input",{type:"text",value:((S=b.structure)==null?void 0:S.join("、"))||"",onChange:_=>y(j,_.target.value),placeholder:a.editor.structurePlaceholder,style:yt}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:bn,children:[t.jsx("span",{style:yn,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((v=b.coverage)==null?void 0:v.level)??"",onChange:_=>w(j,"level",_.target.value),placeholder:"1",style:{...yt,width:"60px"}})]}),t.jsxs("label",{style:{...bn,flex:1},children:[t.jsx("span",{style:yn,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:(($=b.coverage)==null?void 0:$.ranges)||"",onChange:_=>w(j,"ranges",_.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...yt,flex:1}})]})]}),t.jsx("textarea",{value:b.details||"",onChange:_=>x(j,"details",_.target.value),placeholder:a.editor.detailsPlaceholder,style:{...yt,minHeight:"60px",resize:"vertical"}}),t.jsxs("div",{style:{borderTop:`1px solid ${i("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"6px"},children:a.label.metadata}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(a.metadata).map(([_,C])=>{var M;return t.jsxs("label",{style:{...bn,gap:"4px"},children:[t.jsx("span",{style:{...yn,minWidth:"56px"},children:C}),t.jsx("input",{type:"text",value:((M=b.metadata)==null?void 0:M[_])||"",onChange:T=>k(j,_,T.target.value),placeholder:C,style:{...yt,flex:1}})]},_)})})]})]})]})]},j)}),t.jsxs("button",{onClick:h,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:a.action.addResource})]})]})};function Rp(e){switch(e){case"text":return i("restype-text");case"image":return i("restype-image");case"text+image":return i("restype-text-image");case"physical":return i("restype-physical")}}function Lp(e,n,o,r){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||o(e,"")},disabled:s,style:{background:"transparent",border:"none",color:i(a?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:a?r.download.completed:s?`${r.download.downloading} ${(n==null?void 0:n.progress)||0}%`:r.download.downloadThis,children:a?"✓":s?"⏳":"⬇"})}function Ap(e,n){const o=/\.(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:o?t.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:i("overlay-bg")},children:t.jsx("img",{src:e.url,alt:e.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:r=>{r.target.style.display="none"}})}):t.jsx("div",{style:{padding:"12px",background:i("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:i("desc-fg")},children:n.editor.imageResourceLink})})}const yt={width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},bn={display:"flex",alignItems:"center",gap:"6px"},yn={fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap"},Pp={"commons.wikimedia.org":"維基共享","zh.wikisource.org":"維基文庫","taiwanebook.ncl.edu.tw":"臺灣華文電子書庫","ctext.org":"中國哲學書電子化計劃","www.shidianguji.com":"識典古籍","shidianguji.com":"識典古籍","archive.org":"Internet Archive","www.shuge.org":"書格","shuge.org":"書格","pan.baidu.com":"百度網盤"};function dn(e){try{return Pp[new URL(e).hostname]}catch{return}}const qr={text:0,image:1,physical:2};function No(e){return e.length===0?"physical":[...e].sort((n,o)=>(qr[n]??99)-(qr[o]??99)).join("+")}function Eo(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},o=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[u,m]=p,h=`${u}|${No(Vt(c))}`;o.has(h)||o.set(h,{base:{...c,name:u,url:"",volumes:[]},volumes:[],indices:[]});const f=o.get(h);f.volumes.push({volume:m,url:c.url||void 0,status:"found"}),f.indices.push(d)}const r=[],s=new Set;for(const d of o.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)??""),r.push(d.base);for(const c of d.indices)s.add(c)}const a=[...r];for(let d=0;d<e.length;d++)s.has(d)||a.push(e[d]);return a}function za(e){if(e.url)return e.url;for(const[n,o]of Object.entries(e))if(n.endsWith("_url")&&typeof o=="string")return o}function Ta(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||za(n)}))}function pi(e){const n=Ta(e);if(!n)return null;const o=new Set(n.filter(s=>s.status!=="missing").map(s=>s.volume)).size,r=new Set(n.filter(s=>s.status==="missing").map(s=>s.volume)).size;return{found:o,missing:r,expected:e.expected_volumes??o+r}}function Io(e){if(!e)return;const n=e.file_page_range||e.page_range;if(!n||typeof n!="string")return;const o=n.match(/^(\d+)/);return o?parseInt(o[1],10):void 0}function Ro(e,n){try{if(new URL(e).hostname.includes("wikimedia.org")){const r=e.match(/\/wiki\/File:(.+?)(?:#|$)/);if(r)return`https://commons.wikimedia.org/w/index.php?title=File%3A${encodeURIComponent(decodeURIComponent(r[1]))}&page=${n}`;const s=new URL(e);return s.searchParams.set("page",String(n)),s.toString()}return e}catch{return e}}function pn(e){if(!e.url)return;const n=Io(e.metadata);return n?Ro(e.url,n):e.url}const Xr={text:i("restype-text"),image:i("restype-image"),"text+image":i("restype-text-image"),physical:i("restype-physical")};function Mp(e){return e.includes("text")&&e.includes("image")?Xr["text+image"]:Xr[e[0]||"physical"]}const Lo=({items:e,groupByType:n=!0,resourceGroups:o,onNavigate:r,renderLink:s})=>{const a=$e(),{convert:l}=Ie(),d=g.useMemo(()=>Eo(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=g.useMemo(()=>{const y=new Map,w=[];for(const b of d){const j=b.group;j?(y.has(j)||y.set(j,[]),y.get(j).push(b)):w.push(b)}for(const b of y.values())b.sort((j,S)=>{const v=$=>$.group_role==="origin"?0:$.group_role==="mirror"?1:2;return v(j)-v(S)});return{mirrorGroups:y,ungroupedItems:w}},[d]),u={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},m=y=>u[y]?u[y]:y.split("+").map(w=>u[w]||w).join("+");if(!d||d.length===0)return t.jsx("div",{style:{padding:"16px",color:i("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,w)=>t.jsx(Wi,{item:y},y.id||w))});const h=(y,w)=>{const b=o==null?void 0:o[y],j=(b==null?void 0:b.label)||y,S=b==null?void 0:b.description;return t.jsxs("div",{style:{padding:"10px 12px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:i("input-bg"),display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:l(j)}),S&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.5},children:l(S)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:w.map((v,$)=>t.jsx(Wi,{item:v,onNavigate:r,renderLink:s},v.id||$))})]},`group-${y}`)},f=new Map;for(const y of p){const w=No(Vt(y));f.has(w)||f.set(w,[]),f.get(w).push(y)}const x=["text","image","text+image","physical"],k=[...x.filter(y=>f.has(y)),...[...f.keys()].filter(y=>!x.includes(y)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,w])=>h(y,w)),k.map(y=>{const w=f.get(y),b=Mp(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:w.map((j,S)=>t.jsx(Wi,{item:j,onNavigate:r,renderLink:s},j.id||S))})]},y)})]})},Bp={bw:{label:"",bg:i("colormode-bw-bg"),fg:i("colormode-bw-fg")},color:{label:"",bg:i("colormode-color-bg"),fg:i("colormode-color-fg")}},Wi=({item:e})=>{const n=$e(),{convert:o}=Ie(),[r,s]=g.useState(!1),a=g.useMemo(()=>(e.url?dn(e.url):void 0)||o(e.name),[e.url,e.name,o]),l=g.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||za(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,u=e.expected_volumes??(d?c+p:0),m=e.color_mode?{...Bp[e.color_mode],label:n.colorMode[e.color_mode]}:null,h=e.details&&!d?o(e.details):null,f={display:"inline-flex",alignItems:"center",gap:"5px",padding:"4px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",background:i("input-bg"),fontSize:"12px",color:i("fg"),lineHeight:1.4,verticalAlign:"middle"};return t.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[t.jsxs("div",{style:f,children:[t.jsx("span",{style:{fontWeight:500},children:a}),m&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:m.bg,color:m.fg},children:m.label}),h&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:h}),d&&t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[c,"/",u,n.unit.volume,p>0&&t.jsx("span",{style:{color:i("missing-fg"),marginLeft:"3px"},children:pt(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=Io(e.metadata);return x?Ro(e.url,x):e.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:i("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),d&&t.jsx("button",{onClick:()=>s(!r),style:{padding:"0 6px",fontSize:"11px",border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",lineHeight:1.4},children:r?"▲":"▼"})]}),d&&r&&t.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:l.map(x=>{const k=x.status==="missing";return x.url&&!k?t.jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",borderRadius:"3px",border:`1px solid ${i("widget-border")}`,color:i("link-fg"),textDecoration:"none"},children:x.volume},x.volume):t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:i(k?"missing-fg":"desc-fg"),textDecoration:k?"line-through":"none",opacity:k?.6:1},children:x.volume},x.volume)})})]})},Na=({indexSource:e,syncConfig:n,variant:o="index-browser",onSwitchMode:r,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=$e(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,u=(n==null?void 0:n.repoPath)||"",m=u?u.split(/[/\\]/).pop()||u:"",h={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:i("primary-soft"),color:i("primary")},f={onMouseOver:k=>k.currentTarget.style.opacity="0.8",onMouseOut:k=>k.currentTarget.style.opacity="1"},x=t.jsxs("div",{onClick:s,title:p?d.mode.switchToOfficial:d.mode.switchToDraft,style:{...h,background:i(p?"warning":"success"),color:i("on-color-fg")},...f,children:[t.jsx("span",{children:p?"📝":"📚"}),t.jsx("span",{children:p?"draft":"official"})]});return o==="index-browser"?c?t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[x,t.jsxs("div",{onClick:r,title:d.mode.switchToSync,style:h,...f,children:[t.jsx("span",{children:"📁"}),t.jsx("span",{children:d.mode.localMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsxs("div",{onClick:l,title:u||d.mode.selectFolder,style:{...h,paddingLeft:"8px",paddingRight:"8px"},...f,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:r,title:d.mode.switchToLocal,style:h,...f,children:[t.jsx("span",{children:"🌐"}),t.jsx("span",{children:d.mode.syncMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsx("div",{onClick:a,title:m||d.mode.configurePath,style:{...h,background:"transparent",padding:"6px",fontSize:"12px"},...f,children:t.jsx("span",{children:"⚙️"})})]})]}):t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[t.jsxs("div",{onClick:r,title:c?d.mode.switchToGithub:d.mode.switchToLocal,style:h,...f,children:[t.jsx("span",{children:c?"📁":"🌐"}),t.jsx("span",{children:c?d.mode.localMode:d.mode.githubSync}),t.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&t.jsxs("div",{onClick:l,title:u||d.mode.selectFolder,style:{...h,paddingLeft:"8px",paddingRight:"8px",minWidth:u?"100px":"auto",justifyContent:"space-between"},...f,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]}),!c&&m&&t.jsxs("div",{style:{...h,background:i("mode-active-bg"),color:i("on-color-fg"),cursor:"default"},title:u,children:[t.jsx("span",{children:"📂"}),t.jsx("span",{style:{fontSize:"11px"},children:m})]})]})},ui="bim-search-history",Zr=10,Jr=8;function Cn(){try{const e=localStorage.getItem(ui);return e?JSON.parse(e):[]}catch{return[]}}function Ea(e){try{const n=Cn().filter(o=>o!==e);n.unshift(e),n.length>Zr&&(n.length=Zr),localStorage.setItem(ui,JSON.stringify(n))}catch{}}function Wp(e){try{const n=Cn().filter(o=>o!==e);localStorage.setItem(ui,JSON.stringify(n))}catch{}}function Op(){try{localStorage.removeItem(ui)}catch{}}const Ia=({transport:e,value:n,onChange:o,onSearch:r,onEntrySelect:s,placeholder:a})=>{const l=$e(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,u]=g.useState(!1),[m,h]=g.useState([]),[f,x]=g.useState(-1),[k,y]=g.useState(Cn),w=g.useRef(null),b=g.useRef(null),j=g.useRef(null),S=g.useRef(!1);g.useEffect(()=>{x(-1);const z=n.trim();if(!z){h(k.map(R=>({type:"history",text:R})));return}if(!e.searchAll){h([]);return}let F=!1;const N=setTimeout(()=>{e.searchAll(z,Jr).then(R=>{if(F)return;const O=[...R.works,...R.books,...R.collections,...R.entities??[]];h(O.slice(0,Jr).map(I=>({type:"entry",text:I.title||I.id,entry:I})))}).catch(()=>{F||h([])})},80);return()=>{F=!0,clearTimeout(N)}},[n,k,e]),g.useEffect(()=>{const z=F=>{j.current&&!j.current.contains(F.target)&&u(!1)};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]),g.useEffect(()=>{const z=F=>{var N,R;if(F.key==="/"&&document.activeElement!==w.current){const O=(N=document.activeElement)==null?void 0:N.tagName;if(O==="INPUT"||O==="TEXTAREA"||O==="SELECT")return;F.preventDefault(),(R=w.current)==null||R.focus()}};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[]);const v=g.useCallback(z=>{z.trim()&&(Ea(z.trim()),y(Cn())),r(z),u(!1)},[r]),$=g.useCallback(z=>{z.type==="history"?(o(z.text),v(z.text)):z.entry&&(s?(s(z.entry),u(!1)):(o(z.text),v(z.text)))},[o,v,s]),_=g.useCallback(z=>{if(!p||m.length===0){z.key==="Enter"&&v(n);return}switch(z.key){case"ArrowDown":z.preventDefault(),x(F=>(F+1)%m.length);break;case"ArrowUp":z.preventDefault(),x(F=>(F-1+m.length)%m.length);break;case"Enter":z.preventDefault(),f>=0&&f<m.length?$(m[f]):v(n);break;case"Escape":z.preventDefault(),u(!1);break}},[p,m,f,n,v,$]),C=g.useCallback((z,F)=>{F.stopPropagation(),Wp(z),y(Cn()),h(N=>N.filter(R=>!(R.type==="history"&&R.text===z)))},[]),M=g.useCallback(z=>{z.stopPropagation(),Op(),y([]),h([])},[]);g.useEffect(()=>{if(f>=0&&b.current){const z=b.current.children;z[f]&&z[f].scrollIntoView({block:"nearest"})}},[f]);const T=!n.trim()&&k.length>0;return t.jsxs("div",{ref:j,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:w,type:"text",placeholder:d,value:n,onChange:z=>{o(z.target.value),u(!0)},onCompositionStart:()=>{S.current=!0},onCompositionEnd:()=>{S.current=!1},onFocus:()=>{u(!0)},onKeyDown:_,style:{width:"100%",padding:"8px 12px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("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:i("input-bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"6px",boxShadow:i("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:i("desc-fg"),borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsx("span",{children:l.search.history}),t.jsx("button",{onClick:M,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),m.map((z,F)=>t.jsxs("div",{onClick:()=>$(z),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:i("fg"),background:F===f?i("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:z.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.text}),z.entry&&t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:[c[z.entry.type],z.entry.edition&&` · ${z.entry.edition}`,z.entry.author&&` · ${z.entry.author}`]}),z.type==="history"&&t.jsx("button",{onClick:N=>C(z.text,N),style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:l.action.remove,children:"×"})]},`${z.type}-${z.text}-${F}`))]})]})},un=({type:e,size:n=9})=>t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:i(`type-${e}`),verticalAlign:"middle"}}),mi={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},Ra=new Set(["work","book","entity"]);function Hp(e){return Pa(e)||!!e.sort}function Fp(e,n){return n.sort&&Ra.has(e)?n.sort:void 0}const hi=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],gi=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],La=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],Aa={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 Pa(e){return fi(e)>0}function Dp(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 Ma(e,n){const o=Aa[e];return Dp(n).every(r=>o.has(r))}const jn=e=>JSON.stringify(e);function Up(e,n){if(!Ma(n,e))return null;const o=[];if(e.dynasty.length){const r=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=hi.find(l=>l.key===s))==null?void 0:a.values)??[]})));r.length===1?o.push(`dynasty = ${jn(r[0])}`):r.length>1&&o.push(`dynasty IN [${r.map(jn).join(", ")}]`)}return e.classification.length&&o.push(e.classification.length===1?`classification = ${jn(e.classification[0])}`:`classification IN [${e.classification.map(jn).join(", ")}]`),e.hasImage&&o.push("has_image = true"),e.hasText&&o.push("has_text = true"),e.hasCollated&&o.push("has_collated = true"),e.loss&&o.push(`loss_status = ${jn(e.loss)}`),o.join(" AND ")}const nt={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},Ba="_";function ii(e,n=new URLSearchParams){for(const o of Object.values(nt))n.delete(o);return e.dynasty.length&&n.set(nt.dynasty,e.dynasty.join(",")),e.classification.length&&n.set(nt.classification,e.classification.map(o=>o||Ba).join(",")),e.hasImage&&n.set(nt.hasImage,"1"),e.hasText&&n.set(nt.hasText,"1"),e.hasCollated&&n.set(nt.hasCollated,"1"),e.loss&&n.set(nt.loss,e.loss),e.sort&&n.set(nt.sort,e.sort),n}function Vp(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),o=new Set(hi.map(a=>a.key)),r=new Set(gi.map(a=>a.value)),s=e.get(nt.loss);return{dynasty:Array.from(new Set(n(nt.dynasty).filter(a=>o.has(a)))),classification:Array.from(new Set(n(nt.classification).map(a=>a===Ba?"":a).filter(a=>r.has(a)))),hasImage:e.get(nt.hasImage)==="1",hasText:e.get(nt.hasText)==="1"||e.get(nt.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(nt.sort))??""}}function Gp(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 Qr(e,n){return e.includes(n)?e.filter(o=>o!==n):[...e,n]}const Yp=({filters:e,onChange:n})=>{const o=$e(),r=o.searchV4,{convert:s}=Ie(),[a,l]=g.useState(!1),d=g.useId(),c=fi(e),p=u=>n({...e,...u});return t.jsxs("aside",{className:"bim-sr-aside","aria-label":s(r.filterTitle),children:[t.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":a,"aria-controls":d,onClick:()=>l(u=>!u),children:[t.jsxs("span",{children:[s(r.filterButton),c>0&&t.jsx("span",{className:"bim-sr-fn",children:s(pt(r.filterSelected,{n:c}))})]}),t.jsxs("span",{className:"bim-sr-fa","aria-hidden":"true",children:[s(a?r.collapse:r.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(r.dynasty)}),t.jsx("div",{className:"bim-sr-chips",children:hi.map(u=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(u.key),onClick:()=>p({dynasty:Qr(e.dynasty,u.key)}),children:s(u.key)},u.key))})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(r.classification)}),gi.map(u=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(u.value),onChange:()=>p({classification:Qr(e.classification,u.value)})}),u.value?s(u.label):o.searchPage.unclassified]},u.value||"_"))]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(r.resources)}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasImage,onChange:u=>p({hasImage:u.target.checked})}),s(r.hasImage)]}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasText,onChange:u=>p({hasText:u.target.checked})}),s(r.hasText)]})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{id:`${d}-loss`,children:s(r.extant)}),t.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${d}-loss`,children:La.map(u=>t.jsx("button",{type:"button","aria-pressed":e.loss===u.value,onClick:()=>p({loss:u.value}),children:o.searchPage.loss[u.value||"all"]},u.value||"all"))})]}),c>0&&t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...mi,sort:e.sort}),children:s(r.clearAllFilters)})]})]})};function Wa({text:e,query:n}){const o=(n??"").trim();if(!o||!e)return t.jsx(t.Fragment,{children:e});const r=e.toLowerCase(),s=o.toLowerCase(),a=[];let l=0,d=0;for(;l<e.length;){const c=r.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 es=({entries:e,query:n,onEntryLinkClick:o,typeName:r})=>{const s=$e(),a=s.searchV4,{convert:l}=Ie(),d=Xe();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),u=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)}`:""}`:"",h=c.type==="book"?c.era??c.dynasty:c.dynasty,f=h?l(h):"",x=c.classification?l(c.classification):"",k=[];c.has_image&&k.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&k.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&k.push({label:a.tagLost,cls:"bim-sr-tag--lost"});const y=[m,f,x].filter(Boolean).join(" · ");return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-sr-c-title",children:[t.jsxs("div",{className:"bim-sr-tl",children:[t.jsx("a",{href:d(c.id),onClick:w=>o(c,w),children:t.jsx(Wa,{text:p,query:n?l(n):void 0})}),u&&t.jsx("span",{className:"bim-sr-measure",children:u})]}),y&&t.jsx("span",{className:"bim-sr-sub",children:y})]}),t.jsxs("td",{className:"bim-sr-c-type",children:[t.jsx(un,{type:c.type,size:6})," ",r(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:m||"—"}),t.jsx("td",{className:"bim-sr-c-era",children:f||"—"}),t.jsx("td",{className:"bim-sr-c-cls",children:x||"—"}),t.jsx("td",{className:"bim-sr-c-res",children:k.map(w=>t.jsx("span",{className:`bim-sr-tag ${w.cls}`,children:l(w.label)},w.label))})]},c.id)})})]})})},Kp=`
|
|
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 ${i("rule")}; background: ${i("card-bg")}; color: inherit; text-decoration: none; }
|
|
4
4
|
.bim-sc:hover { border-color: ${i("rule-dashed")}; box-shadow: ${i("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: ${i("aux-fg")}; }
|
|
13
13
|
.bim-sc-tags { display: flex; gap: 4px; flex: none; }
|
|
14
14
|
:root[data-layout="boxed"] .bim-sc { box-shadow: none; }
|
|
15
|
-
`,
|
|
15
|
+
`,ts=({entries:e,query:n,onEntryLinkClick:o,typeName:r})=>{const s=$e(),a=s.searchV4,{convert:l}=Ie(),d=Xe();return t.jsxs("div",{className:"bim-sc-grid",children:[t.jsx("style",{children:Kp}),e.map(c=>{const p=l(c.title||c.primary_name||c.id),u=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",h=[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):"",u].filter(Boolean).join(" · "),f=[r(c.type),c.classification?l(c.classification):""].filter(Boolean).join(" · "),x=[];return c.has_image&&x.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&x.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&x.push({label:a.tagLost,cls:"bim-sr-tag--lost"}),t.jsxs("a",{className:"bim-sc",href:d(c.id),onClick:k=>o(c,k),children:[t.jsx("span",{className:"bim-sc-t",children:t.jsx(Wa,{text:p,query:n?l(n):void 0})}),h&&t.jsx("span",{className:"bim-sc-m",children:h}),c.descriptionSnippet&&t.jsx("p",{className:"bim-sc-s",children:zo(c.descriptionSnippet).map((k,y)=>k.marked?t.jsx("mark",{children:l(k.text)},y):t.jsx(g.Fragment,{children:l(k.text)},y))}),t.jsx("span",{className:"bim-sc-sp"}),t.jsxs("div",{className:"bim-sc-f",children:[t.jsx("span",{className:"bim-sc-fl",children:f}),t.jsx("span",{className:"bim-sc-tags",children:x.map(k=>t.jsx("span",{className:`bim-sr-tag ${k.cls}`,children:l(k.label)},k.label))})]})]},c.id)})]})};function qp(e,n){const o=new Set([1,n,e-1,e,e+1].filter(a=>a>=1&&a<=n)),r=Array.from(o).sort((a,l)=>a-l),s=[];return r.forEach((a,l)=>{l>0&&a-r[l-1]>1&&s.push("gap"),s.push(a)}),s}function Xp(e,n,o){const r=Math.max(1,Math.ceil(n/o));return Math.min(Math.max(1,e),r)}const Zp=({page:e,pageSize:n,total:o,totalLabel:r,onPage:s})=>{const a=$e().searchV4,{convert:l}=Ie(),d=Math.max(1,Math.ceil(o/n));return o<=0?null:t.jsxs("nav",{className:"bim-sr-pager","aria-label":l(a.pagerLabel),children:[t.jsx("span",{className:"bim-sr-info",children:l(pt(a.pageInfo,{total:r??o.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)})}),qp(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)})})]})]})},Oa="(max-width: 719px)",Jp=`${Oa}, (pointer: coarse)`,Qp=`
|
|
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(${i("reader-top")} + 16px); padding-top: 2px; }
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
.bim-sr-pager .bim-sr-gap { color: ${i("aux-fg")}; padding: 0 2px; }
|
|
82
82
|
.bim-sr-empty { padding: 60px 0; text-align: center; font-size: 14px; color: ${i("meta-fg")}; }
|
|
83
83
|
|
|
84
|
-
@media ${
|
|
84
|
+
@media ${Oa} {
|
|
85
85
|
.bim-sr-layout { grid-template-columns: minmax(0, 1fr); row-gap: 16px; padding: 0 16px; }
|
|
86
86
|
.bim-sr-aside { position: static; }
|
|
87
87
|
.bim-sr-fbtn {
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
.bim-sr-table td.bim-sr-c-res { text-align: left; padding-bottom: 2px; }
|
|
103
103
|
.bim-sr-table td.bim-sr-c-res:empty { display: none; }
|
|
104
104
|
}
|
|
105
|
-
@media ${
|
|
105
|
+
@media ${Jp} {
|
|
106
106
|
.bim-sr-chip { min-height: 36px; }
|
|
107
107
|
.bim-sr-opt { min-height: 44px; }
|
|
108
108
|
.bim-sr-seg button { min-height: 44px; }
|
|
@@ -117,10 +117,10 @@
|
|
|
117
117
|
:root[data-layout="boxed"] .bim-sr-table th { background: ${i("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
|
-
`,Io="bim-search-view",Mi=50,Jr=5,Cn=1e3;function Xn(e){return e>=Cn?`${Cn.toLocaleString()}+`:e.toLocaleString()}const Xp={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function Zp(e){return e&&Xp[e.toLowerCase()]||"all"}function Jp(e){return e==="all"?null:e}const Qr=["work","collection","book","entity"],Qp={work:"works",collection:"collections",book:"books",entity:"entities"},eu={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function tu(){try{return window.localStorage.getItem(Io)==="card"?"card":"table"}catch{return"table"}}function nu(e){try{window.localStorage.setItem(Io,e)}catch{}}const Jt=(e,n)=>(e==null?void 0:e[eu[n]])??0,Bi=(e,n)=>(e==null?void 0:e[Qp[n]])??[],Ma=({transport:e,query:n,filters:o,onFiltersChange:r,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const u=$e(),m=u.searchV4,{convert:h}=Re(),f=!!e.supportsSearchFilters,x=g.useMemo(()=>f?o:pi,[f,o]),[k,y]=g.useState("table");g.useEffect(()=>{y(tu())},[]);const w=q=>{y(q),nu(q)},[b,j]=g.useState(l??"all"),S=g.useRef(b);S.current=b,g.useEffect(()=>{l!==void 0&&l!==S.current&&(j(l),$(1))},[l]);const[v,$]=g.useState(c&&c>0?c:1),_=g.useRef(v);_.current=v,g.useEffect(()=>{c!==void 0&&c>0&&c!==_.current&&$(c)},[c]);const C=g.useRef(null),M=g.useCallback(q=>{var fe;$(q),p==null||p(q);const Q=C.current;Q&&Q.getBoundingClientRect().top<0&&((fe=Q.scrollIntoView)==null||fe.call(Q,{block:"start",behavior:"instant"}))},[p]),[T,z]=g.useState(null),[F,N]=g.useState(null),[R,O]=g.useState(!1),[I,P]=g.useState(""),U=ti(x).toString(),K=hi(x)>0,L=ti({...x,sort:""}).toString(),Z=g.useRef({query:n,filterOnlyKey:L,sort:x.sort});g.useEffect(()=>{const q=Z.current;q.query!==n||q.filterOnlyKey!==L?(j("all"),$(1)):q.sort!==x.sort&&$(1),Z.current={query:n,filterOnlyKey:L,sort:x.sort}},[n,L,x.sort]),g.useEffect(()=>{let q=!1;return O(!0),P(""),(async()=>{try{let Q;if(e.searchAll)Q=await e.searchAll(n,Jr,x);else{const fe=["work","book","collection","entity"],ze=await Promise.all(fe.map(Y=>e.search(n,Y,{page:1,pageSize:Jr,filters:x})));Q={works:ze[0].entries,books:ze[1].entries,collections:ze[2].entries,entities:ze[3].entries,totalWorks:ze[0].total,totalBooks:ze[1].total,totalCollections:ze[2].total,totalEntities:ze[3].total}}q||z(Q)}catch(Q){q||(P(Q instanceof Error?Q.message:String(Q)),z(null))}finally{q||O(!1)}})(),()=>{q=!0}},[e,n,U]);const A=b;g.useEffect(()=>{if(b==="all"){N(null);return}let q=!1;return O(!0),(async()=>{try{const Q=await e.search(n,b,{page:v,pageSize:Mi,filters:x});q||N({key:A,entries:Q.entries,total:Q.total})}catch(Q){q||(P(Q instanceof Error?Q.message:String(Q)),N(null))}finally{q||O(!1)}})(),()=>{q=!0}},[e,n,U,b,v]);const V=F&&F.key===A?F:null;g.useEffect(()=>{if(b==="all"||!V||R)return;const q=Math.min(V.total,Cn),Q=Gp(v,q,Mi);V.entries.length===0&&q>0&&Q!==v&&($(Q),p==null||p(Q))},[b,V,R,v]);const ce=g.useMemo(()=>Qr.filter(q=>Jt(T,q)>0),[T]),ne=ce.reduce((q,Q)=>q+Jt(T,Q),0),de=ce.some(q=>Jt(T,q)>=Cn)?`${ne.toLocaleString()}+`:ne.toLocaleString(),pe=!R&&!I&&T!==null&&ne===0,be=g.useCallback(q=>{j(q),$(1),d==null||d(q)},[d]),Oe=g.useMemo(()=>{const q=[];return x.dynasty.forEach(Q=>q.push({name:Q,remove:()=>r({...x,dynasty:x.dynasty.filter(fe=>fe!==Q)})})),x.classification.forEach(Q=>{var fe;return q.push({name:Q?((fe=mi.find(ze=>ze.value===Q))==null?void 0:fe.label)??Q:u.searchPage.unclassified,remove:()=>r({...x,classification:x.classification.filter(ze=>ze!==Q)})})}),x.hasImage&&q.push({name:m.hasImage,remove:()=>r({...x,hasImage:!1})}),x.hasText&&q.push({name:m.hasText,remove:()=>r({...x,hasText:!1})}),x.hasCollated&&q.push({name:m.hasCollated,remove:()=>r({...x,hasCollated:!1})}),x.loss&&q.push({name:`${m.extant}:${u.searchPage.loss[x.loss]}`,remove:()=>r({...x,loss:""})}),q},[x,r,m,u]),ie={query:n,onEntryLinkClick:s,typeName:a},Le=q=>k==="table"?t.jsx(Xr,{entries:q,...ie}):t.jsx(Zr,{entries:q,...ie}),Ae=Qr.flatMap(q=>Bi(T,q));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":f?void 0:"true",children:[t.jsx("style",{children:qp}),f&&t.jsx(Dp,{filters:x,onChange:r}),t.jsxs("div",{className:"bim-sr-main","aria-busy":R,ref:C,children:[ce.length>0&&t.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":u.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${i("rule")}`},children:[t.jsxs(es,{on:b==="all",onClick:()=>be("all"),children:[u.search.allTab," ",t.jsx("small",{children:de})]}),ce.map(q=>t.jsxs(es,{on:b===q,onClick:()=>be(q),children:[a(q)," ",t.jsx("small",{children:Xn(Jt(T,q))})]},q))]}),t.jsxs("div",{className:"bim-sr-tools",children:[f&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":h(m.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>r({...x,sort:""}),children:h(m.sortRelevance)}),["era","title"].map(q=>{const Q=x.sort.startsWith(`${q}:`)?x.sort.endsWith("desc")?"desc":"asc":null,fe=q==="era"?m.sortEra:m.sortTitle,ze=q==="era"?Q==="desc"?m.sortEraDesc:m.sortEraAsc:Q==="desc"?m.sortTitleDesc:m.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":Q!==null,title:h(ze),onClick:()=>r({...x,sort:`${q}:${Q==="asc"?"desc":"asc"}`}),children:[h(fe),Q?t.jsxs("span",{"aria-hidden":"true",children:[" ",Q==="asc"?"↑":"↓"]}):null]},q)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":h(m.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":k==="table",onClick:()=>w("table"),children:h(m.viewTable)}),t.jsx("button",{type:"button","aria-pressed":k==="card",onClick:()=>w("card"),children:h(m.viewCard)})]})]}),K&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:h(dt(m.filteredCount,{n:de}))}),Oe.map(q=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":h(dt(m.removeFilter,{name:q.name})),onClick:q.remove,children:[h(q.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},q.name))]}),I&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:I}),pe&&t.jsx("div",{className:"bim-sr-empty",children:h(K?m.emptyFiltered:dt(u.search.noResultsFor,{query:n}))}),!I&&!pe&&b==="all"&&T&&(k==="table"?t.jsxs(t.Fragment,{children:[t.jsx(Xr,{entries:Ae,...ie}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:h(m.limitedNote)})]}):t.jsx(t.Fragment,{children:ce.map(q=>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(un,{type:q,size:8}),a(q),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:i("meta-fg")},children:[Xn(Jt(T,q))," ",u.unit.items]})]}),Jt(T,q)>Bi(T,q).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>be(q),children:u.action.viewAll})]}),t.jsx(Zr,{entries:Bi(T,q),...ie})]},q))})),!I&&b!=="all"&&!V&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:u.search.loading}),!I&&b!=="all"&&V&&V.entries.length>0&&t.jsxs(t.Fragment,{children:[Le(V.entries),t.jsx(Yp,{page:v,pageSize:Mi,total:Math.min(V.total,Cn),totalLabel:Xn(V.total),onPage:M})]}),!I&&b!=="all"&&V&&V.entries.length===0&&!R&&t.jsxs("div",{className:"bim-sr-empty",children:[h(K?m.emptyFiltered:dt(u.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>be("all"),children:u.search.allTab})})]})]})]})};function es({on:e,onClick:n,children:o}){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:i(e?"ink":"meta-fg"),fontWeight:e?700:400,boxShadow:e?`inset 0 -2px 0 ${i("accent")}`:"none"},children:o})}const on="bim-recent-ids",ts="bim-recent-entries",ns=50;function Lt(){try{const e=localStorage.getItem(on);if(e)return JSON.parse(e);const n=localStorage.getItem(ts);if(n){const o=JSON.parse(n).map(r=>r.id);return localStorage.setItem(on,JSON.stringify(o)),localStorage.removeItem(ts),o}return[]}catch{return[]}}function to(e){try{const n=Lt().filter(o=>o!==e);n.unshift(e),n.length>ns&&(n.length=ns),localStorage.setItem(on,JSON.stringify(n))}catch{}}function Ba(e){try{const n=Lt().filter(o=>o!==e);localStorage.setItem(on,JSON.stringify(n))}catch{}}function Ro(){try{localStorage.removeItem(on)}catch{}}async function Lo(e,n){var o,r,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:(o=l==null?void 0:l[0])==null?void 0:o.name,dynasty:(r=l==null?void 0:l[0])==null?void 0:r.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 Wi=5,iu=50,ou=200,is={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},no=({transport:e,indexSource:n="local",syncConfig:o,onEntryClick:r,onNewEntry:s,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c,hideModeIndicator:p,resultVariant:u="compact",renderEntry:m,initialQuery:h,onQueryChange:f,headerRight:x,reserveViewportHeight:k=!1,filtersEnabled:y=!1,filters:w=pi,onFiltersChange:b,resultTab:j,onResultTabChange:S,resultPage:v,onResultPageChange:$})=>{const _=$e(),C=[{type:"work",name:_.indexType.work,key:"works"},{type:"book",name:_.indexType.book,key:"books"},{type:"collection",name:_.indexType.collection,key:"collections"},{type:"entity",name:_.indexType.entity,key:"entities"}],M=["work","collection","book","entity"],[T,z]=g.useState(h??""),[F,N]=g.useState(null),[R,O]=g.useState(h??""),I=ti(w).toString(),[P,U]=g.useState(w);g.useEffect(()=>{U(w)},[I]);const K=E=>{U(E),b==null||b(E)},[L,Z]=g.useState(null),[A,V]=g.useState("all"),[ce,ne]=g.useState(!1),[de,pe]=g.useState(null),[be,Oe]=g.useState(""),[ie,Le]=g.useState(!(h!=null&&h.trim())),[Ae,q]=g.useState(Lt),[Q,fe]=g.useState([]),[ze,Y]=g.useState(!1),[ve,le]=g.useState(!1),[Se,X]=g.useState(null),[Ce,Me]=g.useState(null),B=g.useRef(void 0),ee=g.useRef(!1),ye=g.useCallback(async(E,oe)=>{if(!E.trim()){Le(!0),N(null),Z(null);return}if(Le(!1),y){O(E);return}ne(!0),Oe("");try{if(e.searchAll){const ae=await e.searchAll(E,oe??Wi);N(ae)}else{const ae=["work","book","collection","entity"],je=await Promise.all(ae.map(ke=>e.search(E,ke,{page:1,pageSize:oe??Wi})));N({works:je[0].entries,books:je[1].entries,collections:je[2].entries,entities:je[3].entries,totalWorks:je[0].total,totalBooks:je[1].total,totalCollections:je[2].total,totalEntities:je[3].total})}}catch(ae){Oe(ae instanceof Error?ae.message:String(ae)),N(null)}finally{ne(!1)}},[e,y]);g.useEffect(()=>{let E=!1;const oe=()=>{var G,ue;const ae=["work","book","collection","entity"],je=Promise.all(ae.map(Te=>e.loadEntries(Te,{page:1,pageSize:1}).catch(()=>({total:0})))),ke=((G=e.getResourceCounts)==null?void 0:G.call(e).catch(()=>null))??Promise.resolve(null),xe=((ue=e.getSubtypeStats)==null?void 0:ue.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([je,ke,xe]).then(([Te,Ee,D])=>{E||(X({works:Te[0].total,books:Te[1].total,collections:Te[2].total,entities:Te[3].total,hasText:Ee==null?void 0:Ee.hasText,hasImage:Ee==null?void 0:Ee.hasImage}),D&&Me(D))})};return e.getCounts?e.getCounts().then(ae=>{var je,ke;E||(X({works:ae.works,books:ae.books,collections:ae.collections,entities:ae.entities,hasText:(je=ae.resourceCounts)==null?void 0:je.hasText,hasImage:(ke=ae.resourceCounts)==null?void 0:ke.hasImage}),ae.subtypeStats&&Me(ae.subtypeStats))}).catch(()=>{E||oe()}):oe(),()=>{E=!0}},[e]),g.useEffect(()=>{ee.current||!(h!=null&&h.trim())||(ee.current=!0,ye(h))},[h,ye]);const H=g.useCallback(E=>{if(z(E),!E.trim()){f==null||f(E),Le(!0),N(null),Z(null),V("all");return}B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{Z(null),V("all"),f==null||f(E),ye(E)},ou)},[ye,f]),se=g.useCallback(E=>{B.current&&clearTimeout(B.current),V("all"),f==null||f(E),ye(E)},[ye,f]),te=g.useCallback(E=>{Z(E),ye(T,iu)},[T,ye]);g.useEffect(()=>{if(!Ae.length){fe([]);return}let E=!1;return Y(!0),Promise.all(Ae.slice(0,10).map(oe=>Lo(e,oe))).then(oe=>{E||(fe(oe),Y(!1))}),()=>{E=!0}},[Ae,e]);const ge=E=>{pe(E.id),to(E.id),q(Lt()),r==null||r(E)},Ne=(E,oe)=>{if(r&&su(oe)){oe.preventDefault(),ge(E);return}to(E.id),q(Lt())},Be=E=>{Ba(E),q(Lt())},We=()=>{Ro(),q([])},Ue=E=>C.find(oe=>oe.type===E),Qe=!ie&&!F&&!be,me=F&&(F.works.length>0||F.books.length>0||F.collections.length>0),tt=t.jsxs(t.Fragment,{children:[t.jsx(za,{transport:e,value:T,onChange:H,onSearch:se,onEntrySelect:ge}),y&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const E=T.trim();E&&Ca(E),se(T)},children:_.searchPage.submit}),s&&t.jsx("button",{onClick:()=>s("work"),style:{padding:"8px 14px",border:`1px solid ${i("primary")}`,borderRadius:"6px",background:"transparent",color:i("primary"),cursor:"pointer",fontSize:"13px"},children:_.action.newEntry})]});return t.jsxs("div",{className:"bim-browser-container",style:k?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:au+(y?lu:"")}),(!y||x||!p)&&t.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${i("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:i("fg")},children:_.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!p&&t.jsx($a,{variant:"index-browser",indexSource:n,syncConfig:o,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:tt})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:tt}),ie&&t.jsx("div",{className:"bim-ib-stats",style:{padding:"0 20px 8px",fontSize:"12px",color:i("desc-fg"),display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:"4px"},children:Se&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:Ce?t.jsxs(t.Fragment,{children:[(Ce.book??0)>0&&t.jsxs(t.Fragment,{children:[_.searchPage.statBook," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.book.toLocaleString()})," ",_.unit.bu,_.searchPage.statComma,t.jsx("strong",{style:{color:i("fg")},children:Se.books.toLocaleString()})," ",_.searchPage.statBookCopies]}),Ce.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statArticle," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.article.toLocaleString()})," ",_.searchPage.statArticleUnit]}):null,Ce.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statPoem," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.poem.toLocaleString()})," ",_.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statCollection," ",t.jsx("strong",{style:{color:i("fg")},children:Se.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[_.indexType.work," ",t.jsx("strong",{style:{color:i("fg")},children:Se.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.book," ",t.jsx("strong",{style:{color:i("fg")},children:Se.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.collection," ",t.jsx("strong",{style:{color:i("fg")},children:Se.collections.toLocaleString()}),Se.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.entity," ",t.jsx("strong",{style:{color:i("fg")},children:Se.entities.toLocaleString()})]})]})}),Se.hasImage!=null&&Se.hasText!=null&&t.jsxs("span",{children:[_.resourceType.image," ",t.jsx("strong",{style:{color:i("fg")},children:Se.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.resourceType.text," ",t.jsx("strong",{style:{color:i("fg")},children:Se.hasText.toLocaleString()})]})]})}),y&&!ie&&t.jsx(Ma,{transport:e,query:R,filters:P,onFiltersChange:K,onEntryLinkClick:Ne,typeName:E=>Ue(E).name,tab:j,onTabChange:S,page:v,onPageChange:$}),!(y&&!ie)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:ce||Qe?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg"),minHeight:ru,boxSizing:"border-box"},children:_.search.searching}):be?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:i("desc-fg")},children:be})}):ie?t.jsx("div",{style:{flex:1},children:ze?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg")},children:_.search.loading}):Q.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:i("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{children:_.search.recentBrowse}),t.jsx("button",{onClick:We,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:_.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:Q.slice(0,ve?10:3).map(E=>E.notFound?t.jsx(uu,{id:E.id,onRemove:Be,t:_},E.id):t.jsx(os,{entry:E,selected:de===E.id,onClick:Ne,getConfig:Ue,onRemove:Be},E.id))}),!ve&&Q.length>3&&t.jsx("button",{onClick:()=>le(!0),style:{display:"block",margin:"8px auto 0",padding:"4px 16px",fontSize:"12px",color:i("primary"),background:"transparent",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:_.action.expandMore})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:_.search.searchTitle}),t.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:_.search.searchSubtitle})]})}):me?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:cu}),(()=>{const E=xe=>F[is[xe]]??0,oe=M.map(xe=>C.find(G=>G.type===xe)).filter(xe=>E(xe.key)>0);if(oe.length<2)return null;const ae=oe.reduce((xe,G)=>xe+E(G.key),0),je=xe=>{if(V(xe),xe!=="all"&&L!==xe){const G=C.find(Te=>Te.type===xe),ue=(F[G.key]??[]).length;E(G.key)>ue&&te(xe)}},ke=xe=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:i(xe?"fg":"desc-fg"),fontWeight:xe?700:400,boxShadow:xe?`inset 0 -2px 0 ${i("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":_.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":A==="all",style:ke(A==="all"),onClick:()=>je("all"),children:[_.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:ae.toLocaleString()})]}),oe.map(xe=>t.jsxs("button",{type:"button","aria-pressed":A===xe.type,style:ke(A===xe.type),onClick:()=>je(xe.type),children:[xe.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:E(xe.key).toLocaleString()})]},xe.type))]})})(),C.map(({type:E,name:oe,key:ae})=>{const je=F[ae]??[],ke=is[ae],xe=F[ke]??0;if(je.length===0||A!=="all"&&A!==E)return null;const ue=A==="all"&&!(L===E)&&xe>Wi;return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"6px"},children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:[t.jsx(un,{type:E})," ",oe,t.jsxs("span",{style:{fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:[xe," ",_.unit.items]})]}),ue&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>te(E),style:{border:"none",background:"transparent",color:i("primary"),cursor:"pointer",fontSize:"12px"},children:_.action.viewAll})]}),t.jsx("div",{style:u==="list"?{display:"flex",flexDirection:"column",gap:0}:u==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:je.map(Te=>{if(m)return t.jsx(g.Fragment,{children:m(Te)},Te.id);const Ee=u==="card"?pu:os;return t.jsx(Ee,{entry:Te,selected:de===Te.id,onClick:Ne,getConfig:Ue,query:T},Te.id)})})]},E)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:dt(_.search.noResultsFor,{query:T})}),t.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:_.search.tryOther})]})})]})},ru=240;function su(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const au=`
|
|
120
|
+
`,Ao="bim-search-view",Oi=50,ns=5,zn=1e3;function Jn(e){return e>=zn?`${zn.toLocaleString()}+`:e.toLocaleString()}const eu={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function tu(e){return e&&eu[e.toLowerCase()]||"all"}function nu(e){return e==="all"?null:e}const is=["work","collection","book","entity"],iu={work:"works",collection:"collections",book:"books",entity:"entities"},ou={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function ru(){try{return window.localStorage.getItem(Ao)==="card"?"card":"table"}catch{return"table"}}function su(e){try{window.localStorage.setItem(Ao,e)}catch{}}const Jt=(e,n)=>(e==null?void 0:e[ou[n]])??0,Hi=(e,n)=>(e==null?void 0:e[iu[n]])??[],Ha=({transport:e,query:n,filters:o,onFiltersChange:r,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const u=$e(),m=u.searchV4,{convert:h}=Ie(),f=!!e.supportsSearchFilters,x=g.useMemo(()=>f?o:mi,[f,o]),[k,y]=g.useState("table");g.useEffect(()=>{y(ru())},[]);const w=q=>{y(q),su(q)},[b,j]=g.useState(l??"all"),S=g.useRef(b);S.current=b,g.useEffect(()=>{l!==void 0&&l!==S.current&&(j(l),$(1))},[l]);const[v,$]=g.useState(c&&c>0?c:1),_=g.useRef(v);_.current=v,g.useEffect(()=>{c!==void 0&&c>0&&c!==_.current&&$(c)},[c]);const C=g.useRef(null),M=g.useCallback(q=>{var fe;$(q),p==null||p(q);const J=C.current;J&&J.getBoundingClientRect().top<0&&((fe=J.scrollIntoView)==null||fe.call(J,{block:"start",behavior:"instant"}))},[p]),[T,z]=g.useState(null),[F,N]=g.useState(null),[R,O]=g.useState(!1),[I,P]=g.useState(""),U=ii(x).toString(),K=fi(x)>0,L=ii({...x,sort:""}).toString(),Z=g.useRef({query:n,filterOnlyKey:L,sort:x.sort});g.useEffect(()=>{const q=Z.current;q.query!==n||q.filterOnlyKey!==L?(j("all"),$(1)):q.sort!==x.sort&&$(1),Z.current={query:n,filterOnlyKey:L,sort:x.sort}},[n,L,x.sort]),g.useEffect(()=>{let q=!1;return O(!0),P(""),(async()=>{try{let J;if(e.searchAll)J=await e.searchAll(n,ns,x);else{const fe=["work","book","collection","entity"],ze=await Promise.all(fe.map(Y=>e.search(n,Y,{page:1,pageSize:ns,filters:x})));J={works:ze[0].entries,books:ze[1].entries,collections:ze[2].entries,entities:ze[3].entries,totalWorks:ze[0].total,totalBooks:ze[1].total,totalCollections:ze[2].total,totalEntities:ze[3].total}}q||z(J)}catch(J){q||(P(J instanceof Error?J.message:String(J)),z(null))}finally{q||O(!1)}})(),()=>{q=!0}},[e,n,U]);const A=b;g.useEffect(()=>{if(b==="all"){N(null);return}let q=!1;return O(!0),(async()=>{try{const J=await e.search(n,b,{page:v,pageSize:Oi,filters:x});q||N({key:A,entries:J.entries,total:J.total})}catch(J){q||(P(J instanceof Error?J.message:String(J)),N(null))}finally{q||O(!1)}})(),()=>{q=!0}},[e,n,U,b,v]);const V=F&&F.key===A?F:null;g.useEffect(()=>{if(b==="all"||!V||R)return;const q=Math.min(V.total,zn),J=Xp(v,q,Oi);V.entries.length===0&&q>0&&J!==v&&($(J),p==null||p(J))},[b,V,R,v]);const pe=g.useMemo(()=>is.filter(q=>Jt(T,q)>0),[T]),ee=pe.reduce((q,J)=>q+Jt(T,J),0),ue=pe.some(q=>Jt(T,q)>=zn)?`${ee.toLocaleString()}+`:ee.toLocaleString(),me=!R&&!I&&T!==null&&ee===0,be=g.useCallback(q=>{j(q),$(1),d==null||d(q)},[d]),Oe=g.useMemo(()=>{const q=[];return x.dynasty.forEach(J=>q.push({name:J,remove:()=>r({...x,dynasty:x.dynasty.filter(fe=>fe!==J)})})),x.classification.forEach(J=>{var fe;return q.push({name:J?((fe=gi.find(ze=>ze.value===J))==null?void 0:fe.label)??J:u.searchPage.unclassified,remove:()=>r({...x,classification:x.classification.filter(ze=>ze!==J)})})}),x.hasImage&&q.push({name:m.hasImage,remove:()=>r({...x,hasImage:!1})}),x.hasText&&q.push({name:m.hasText,remove:()=>r({...x,hasText:!1})}),x.hasCollated&&q.push({name:m.hasCollated,remove:()=>r({...x,hasCollated:!1})}),x.loss&&q.push({name:`${m.extant}:${u.searchPage.loss[x.loss]}`,remove:()=>r({...x,loss:""})}),q},[x,r,m,u]),ie={query:n,onEntryLinkClick:s,typeName:a},Re=q=>k==="table"?t.jsx(es,{entries:q,...ie}):t.jsx(ts,{entries:q,...ie}),Le=is.flatMap(q=>Hi(T,q));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":f?void 0:"true",children:[t.jsx("style",{children:Qp}),f&&t.jsx(Yp,{filters:x,onChange:r}),t.jsxs("div",{className:"bim-sr-main","aria-busy":R,ref:C,children:[pe.length>0&&t.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":u.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${i("rule")}`},children:[t.jsxs(os,{on:b==="all",onClick:()=>be("all"),children:[u.search.allTab," ",t.jsx("small",{children:ue})]}),pe.map(q=>t.jsxs(os,{on:b===q,onClick:()=>be(q),children:[a(q)," ",t.jsx("small",{children:Jn(Jt(T,q))})]},q))]}),t.jsxs("div",{className:"bim-sr-tools",children:[f&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":h(m.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>r({...x,sort:""}),children:h(m.sortRelevance)}),["era","title"].map(q=>{const J=x.sort.startsWith(`${q}:`)?x.sort.endsWith("desc")?"desc":"asc":null,fe=q==="era"?m.sortEra:m.sortTitle,ze=q==="era"?J==="desc"?m.sortEraDesc:m.sortEraAsc:J==="desc"?m.sortTitleDesc:m.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":J!==null,title:h(ze),onClick:()=>r({...x,sort:`${q}:${J==="asc"?"desc":"asc"}`}),children:[h(fe),J?t.jsxs("span",{"aria-hidden":"true",children:[" ",J==="asc"?"↑":"↓"]}):null]},q)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":h(m.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":k==="table",onClick:()=>w("table"),children:h(m.viewTable)}),t.jsx("button",{type:"button","aria-pressed":k==="card",onClick:()=>w("card"),children:h(m.viewCard)})]})]}),K&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:h(pt(m.filteredCount,{n:ue}))}),Oe.map(q=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":h(pt(m.removeFilter,{name:q.name})),onClick:q.remove,children:[h(q.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},q.name))]}),I&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:I}),me&&t.jsx("div",{className:"bim-sr-empty",children:h(K?m.emptyFiltered:pt(u.search.noResultsFor,{query:n}))}),!I&&!me&&b==="all"&&T&&(k==="table"?t.jsxs(t.Fragment,{children:[t.jsx(es,{entries:Le,...ie}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:h(m.limitedNote)})]}):t.jsx(t.Fragment,{children:pe.map(q=>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(un,{type:q,size:8}),a(q),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:i("meta-fg")},children:[Jn(Jt(T,q))," ",u.unit.items]})]}),Jt(T,q)>Hi(T,q).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>be(q),children:u.action.viewAll})]}),t.jsx(ts,{entries:Hi(T,q),...ie})]},q))})),!I&&b!=="all"&&!V&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:u.search.loading}),!I&&b!=="all"&&V&&V.entries.length>0&&t.jsxs(t.Fragment,{children:[Re(V.entries),t.jsx(Zp,{page:v,pageSize:Oi,total:Math.min(V.total,zn),totalLabel:Jn(V.total),onPage:M})]}),!I&&b!=="all"&&V&&V.entries.length===0&&!R&&t.jsxs("div",{className:"bim-sr-empty",children:[h(K?m.emptyFiltered:pt(u.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>be("all"),children:u.search.allTab})})]})]})]})};function os({on:e,onClick:n,children:o}){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:i(e?"ink":"meta-fg"),fontWeight:e?700:400,boxShadow:e?`inset 0 -2px 0 ${i("accent")}`:"none"},children:o})}const on="bim-recent-ids",rs="bim-recent-entries",ss=50;function Rt(){try{const e=localStorage.getItem(on);if(e)return JSON.parse(e);const n=localStorage.getItem(rs);if(n){const o=JSON.parse(n).map(r=>r.id);return localStorage.setItem(on,JSON.stringify(o)),localStorage.removeItem(rs),o}return[]}catch{return[]}}function oo(e){try{const n=Rt().filter(o=>o!==e);n.unshift(e),n.length>ss&&(n.length=ss),localStorage.setItem(on,JSON.stringify(n))}catch{}}function Fa(e){try{const n=Rt().filter(o=>o!==e);localStorage.setItem(on,JSON.stringify(n))}catch{}}function Po(){try{localStorage.removeItem(on)}catch{}}async function Mo(e,n){var o,r,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:(o=l==null?void 0:l[0])==null?void 0:o.name,dynasty:(r=l==null?void 0:l[0])==null?void 0:r.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 Fi=5,au=50,lu=200,as={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},ro=({transport:e,indexSource:n="local",syncConfig:o,onEntryClick:r,onNewEntry:s,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c,hideModeIndicator:p,resultVariant:u="compact",renderEntry:m,initialQuery:h,onQueryChange:f,headerRight:x,reserveViewportHeight:k=!1,filtersEnabled:y=!1,filters:w=mi,onFiltersChange:b,resultTab:j,onResultTabChange:S,resultPage:v,onResultPageChange:$})=>{const _=$e(),C=[{type:"work",name:_.indexType.work,key:"works"},{type:"book",name:_.indexType.book,key:"books"},{type:"collection",name:_.indexType.collection,key:"collections"},{type:"entity",name:_.indexType.entity,key:"entities"}],M=["work","collection","book","entity"],[T,z]=g.useState(h??""),[F,N]=g.useState(null),[R,O]=g.useState(h??""),I=ii(w).toString(),[P,U]=g.useState(w);g.useEffect(()=>{U(w)},[I]);const K=E=>{U(E),b==null||b(E)},[L,Z]=g.useState(null),[A,V]=g.useState("all"),[pe,ee]=g.useState(!1),[ue,me]=g.useState(null),[be,Oe]=g.useState(""),[ie,Re]=g.useState(!(h!=null&&h.trim())),[Le,q]=g.useState(Rt),[J,fe]=g.useState([]),[ze,Y]=g.useState(!1),[ve,le]=g.useState(!1),[Se,X]=g.useState(null),[Ce,Me]=g.useState(null),B=g.useRef(void 0),te=g.useRef(!1),ye=g.useCallback(async(E,oe)=>{if(!E.trim()){Re(!0),N(null),Z(null);return}if(Re(!1),y){O(E);return}ee(!0),Oe("");try{if(e.searchAll){const ae=await e.searchAll(E,oe??Fi);N(ae)}else{const ae=["work","book","collection","entity"],je=await Promise.all(ae.map(ke=>e.search(E,ke,{page:1,pageSize:oe??Fi})));N({works:je[0].entries,books:je[1].entries,collections:je[2].entries,entities:je[3].entries,totalWorks:je[0].total,totalBooks:je[1].total,totalCollections:je[2].total,totalEntities:je[3].total})}}catch(ae){Oe(ae instanceof Error?ae.message:String(ae)),N(null)}finally{ee(!1)}},[e,y]);g.useEffect(()=>{let E=!1;const oe=()=>{var G,de;const ae=["work","book","collection","entity"],je=Promise.all(ae.map(Te=>e.loadEntries(Te,{page:1,pageSize:1}).catch(()=>({total:0})))),ke=((G=e.getResourceCounts)==null?void 0:G.call(e).catch(()=>null))??Promise.resolve(null),xe=((de=e.getSubtypeStats)==null?void 0:de.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([je,ke,xe]).then(([Te,Ee,D])=>{E||(X({works:Te[0].total,books:Te[1].total,collections:Te[2].total,entities:Te[3].total,hasText:Ee==null?void 0:Ee.hasText,hasImage:Ee==null?void 0:Ee.hasImage}),D&&Me(D))})};return e.getCounts?e.getCounts().then(ae=>{var je,ke;E||(X({works:ae.works,books:ae.books,collections:ae.collections,entities:ae.entities,hasText:(je=ae.resourceCounts)==null?void 0:je.hasText,hasImage:(ke=ae.resourceCounts)==null?void 0:ke.hasImage}),ae.subtypeStats&&Me(ae.subtypeStats))}).catch(()=>{E||oe()}):oe(),()=>{E=!0}},[e]),g.useEffect(()=>{te.current||!(h!=null&&h.trim())||(te.current=!0,ye(h))},[h,ye]);const H=g.useCallback(E=>{if(z(E),!E.trim()){f==null||f(E),Re(!0),N(null),Z(null),V("all");return}B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{Z(null),V("all"),f==null||f(E),ye(E)},lu)},[ye,f]),se=g.useCallback(E=>{B.current&&clearTimeout(B.current),V("all"),f==null||f(E),ye(E)},[ye,f]),ne=g.useCallback(E=>{Z(E),ye(T,au)},[T,ye]);g.useEffect(()=>{if(!Le.length){fe([]);return}let E=!1;return Y(!0),Promise.all(Le.slice(0,10).map(oe=>Mo(e,oe))).then(oe=>{E||(fe(oe),Y(!1))}),()=>{E=!0}},[Le,e]);const ge=E=>{me(E.id),oo(E.id),q(Rt()),r==null||r(E)},Ne=(E,oe)=>{if(r&&du(oe)){oe.preventDefault(),ge(E);return}oo(E.id),q(Rt())},Be=E=>{Fa(E),q(Rt())},We=()=>{Po(),q([])},Ue=E=>C.find(oe=>oe.type===E),Qe=!ie&&!F&&!be,ce=F&&(F.works.length>0||F.books.length>0||F.collections.length>0),tt=t.jsxs(t.Fragment,{children:[t.jsx(Ia,{transport:e,value:T,onChange:H,onSearch:se,onEntrySelect:ge}),y&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const E=T.trim();E&&Ea(E),se(T)},children:_.searchPage.submit}),s&&t.jsx("button",{onClick:()=>s("work"),style:{padding:"8px 14px",border:`1px solid ${i("primary")}`,borderRadius:"6px",background:"transparent",color:i("primary"),cursor:"pointer",fontSize:"13px"},children:_.action.newEntry})]});return t.jsxs("div",{className:"bim-browser-container",style:k?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:pu+(y?uu:"")}),(!y||x||!p)&&t.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${i("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:i("fg")},children:_.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!p&&t.jsx(Na,{variant:"index-browser",indexSource:n,syncConfig:o,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:tt})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:tt}),ie&&t.jsx("div",{className:"bim-ib-stats",style:{padding:"0 20px 8px",fontSize:"12px",color:i("desc-fg"),display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:"4px"},children:Se&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:Ce?t.jsxs(t.Fragment,{children:[(Ce.book??0)>0&&t.jsxs(t.Fragment,{children:[_.searchPage.statBook," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.book.toLocaleString()})," ",_.unit.bu,_.searchPage.statComma,t.jsx("strong",{style:{color:i("fg")},children:Se.books.toLocaleString()})," ",_.searchPage.statBookCopies]}),Ce.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statArticle," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.article.toLocaleString()})," ",_.searchPage.statArticleUnit]}):null,Ce.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statPoem," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.poem.toLocaleString()})," ",_.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statCollection," ",t.jsx("strong",{style:{color:i("fg")},children:Se.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[_.indexType.work," ",t.jsx("strong",{style:{color:i("fg")},children:Se.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.book," ",t.jsx("strong",{style:{color:i("fg")},children:Se.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.collection," ",t.jsx("strong",{style:{color:i("fg")},children:Se.collections.toLocaleString()}),Se.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.entity," ",t.jsx("strong",{style:{color:i("fg")},children:Se.entities.toLocaleString()})]})]})}),Se.hasImage!=null&&Se.hasText!=null&&t.jsxs("span",{children:[_.resourceType.image," ",t.jsx("strong",{style:{color:i("fg")},children:Se.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.resourceType.text," ",t.jsx("strong",{style:{color:i("fg")},children:Se.hasText.toLocaleString()})]})]})}),y&&!ie&&t.jsx(Ha,{transport:e,query:R,filters:P,onFiltersChange:K,onEntryLinkClick:Ne,typeName:E=>Ue(E).name,tab:j,onTabChange:S,page:v,onPageChange:$}),!(y&&!ie)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:pe||Qe?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg"),minHeight:cu,boxSizing:"border-box"},children:_.search.searching}):be?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:i("desc-fg")},children:be})}):ie?t.jsx("div",{style:{flex:1},children:ze?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg")},children:_.search.loading}):J.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:i("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{children:_.search.recentBrowse}),t.jsx("button",{onClick:We,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:_.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:J.slice(0,ve?10:3).map(E=>E.notFound?t.jsx(fu,{id:E.id,onRemove:Be,t:_},E.id):t.jsx(ls,{entry:E,selected:ue===E.id,onClick:Ne,getConfig:Ue,onRemove:Be},E.id))}),!ve&&J.length>3&&t.jsx("button",{onClick:()=>le(!0),style:{display:"block",margin:"8px auto 0",padding:"4px 16px",fontSize:"12px",color:i("primary"),background:"transparent",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:_.action.expandMore})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:_.search.searchTitle}),t.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:_.search.searchSubtitle})]})}):ce?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:mu}),(()=>{const E=xe=>F[as[xe]]??0,oe=M.map(xe=>C.find(G=>G.type===xe)).filter(xe=>E(xe.key)>0);if(oe.length<2)return null;const ae=oe.reduce((xe,G)=>xe+E(G.key),0),je=xe=>{if(V(xe),xe!=="all"&&L!==xe){const G=C.find(Te=>Te.type===xe),de=(F[G.key]??[]).length;E(G.key)>de&&ne(xe)}},ke=xe=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:i(xe?"fg":"desc-fg"),fontWeight:xe?700:400,boxShadow:xe?`inset 0 -2px 0 ${i("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":_.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":A==="all",style:ke(A==="all"),onClick:()=>je("all"),children:[_.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:ae.toLocaleString()})]}),oe.map(xe=>t.jsxs("button",{type:"button","aria-pressed":A===xe.type,style:ke(A===xe.type),onClick:()=>je(xe.type),children:[xe.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:E(xe.key).toLocaleString()})]},xe.type))]})})(),C.map(({type:E,name:oe,key:ae})=>{const je=F[ae]??[],ke=as[ae],xe=F[ke]??0;if(je.length===0||A!=="all"&&A!==E)return null;const de=A==="all"&&!(L===E)&&xe>Fi;return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"6px"},children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:[t.jsx(un,{type:E})," ",oe,t.jsxs("span",{style:{fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:[xe," ",_.unit.items]})]}),de&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>ne(E),style:{border:"none",background:"transparent",color:i("primary"),cursor:"pointer",fontSize:"12px"},children:_.action.viewAll})]}),t.jsx("div",{style:u==="list"?{display:"flex",flexDirection:"column",gap:0}:u==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:je.map(Te=>{if(m)return t.jsx(g.Fragment,{children:m(Te)},Te.id);const Ee=u==="card"?gu:ls;return t.jsx(Ee,{entry:Te,selected:ue===Te.id,onClick:Ne,getConfig:Ue,query:T},Te.id)})})]},E)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:pt(_.search.noResultsFor,{query:T})}),t.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:_.search.tryOther})]})})]})},cu=240;function du(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const pu=`
|
|
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
|
+
`,uu=`
|
|
124
124
|
.bim-ib-bar { display: grid; grid-template-columns: 208px minmax(0, 1fr); column-gap: 40px; padding: 0 20px 16px; }
|
|
125
125
|
.bim-ib-bar[data-nofilters] { grid-template-columns: minmax(0, 1fr); }
|
|
126
126
|
.bim-ib-bar[data-nofilters] > [aria-hidden] { display: none; }
|
|
@@ -135,26 +135,26 @@
|
|
|
135
135
|
.bim-ib-bar-main { max-width: none; }
|
|
136
136
|
.bim-ib-submit { min-height: 44px; padding: 0 16px; }
|
|
137
137
|
}
|
|
138
|
-
`,
|
|
138
|
+
`,mu=`
|
|
139
139
|
@media (max-width: 719px), (pointer: coarse) {
|
|
140
140
|
.bim-ib-viewall { position: relative; }
|
|
141
141
|
.bim-ib-viewall::after {
|
|
142
142
|
content: ""; position: absolute; left: 50%; top: 50%;
|
|
143
143
|
width: max(calc(100% + 8px), 44px); height: max(100%, 44px); transform: translate(-50%, -50%);
|
|
144
144
|
}
|
|
145
|
-
}`,Wa={color:"inherit",textDecoration:"none"},du=({snippet:e})=>{const{convert:n}=Re();return t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.6},children:_o(e).map((o,r)=>o.marked?t.jsx("mark",{style:{background:i("highlight-bg"),color:i("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(o.text)},r):t.jsx(g.Fragment,{children:n(o.text)},r))})},pu=({entry:e,selected:n,onClick:o,getConfig:r,query:s})=>{const a=$e(),{convert:l}=Re(),d=l(e.title||e.primary_name||e.id),c=e.measure_info?l(e.measure_info):e.juan_count!=null&&e.juan_count>0?`${e.juan_count}${a.unit.juan}`:"",p=[...e.additional_titles||[],...e.attached_texts||[]],u=s&&p.length?p.find(f=>{const x=typeof f=="string"?f:f==null?void 0:f.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,m=i("cover-accent"),h=Xe();return t.jsxs("a",{href:h(e.id),onClick:f=>o(e,f),className:"bim-result-card",style:{...Wa,display:"flex",gap:"1.2rem",alignItems:"stretch",padding:"1.1rem 1.3rem",borderRadius:"12px",cursor:"pointer",background:i("bg"),border:n?`1px solid ${i("primary")}`:`1px solid ${i("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%, ${i("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${m} 14%, ${i("bg")}), color-mix(in srgb, ${m} 7%, ${i("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((f,x)=>t.jsx("span",{children:f},x))})]}),t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"17px",fontWeight:600,color:i("fg")},children:d}),c&&t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:c})]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"13px",color:i("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:i("desc-fg")},children:[e.era&&t.jsxs("span",{children:["〔",l(e.era),"〕"]}),e.edition&&t.jsx("span",{children:l(e.edition)})]}),u&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[a.search.alias,":",l(typeof u=="string"?u:u.book_title||"")]}),e.descriptionSnippet&&t.jsx(du,{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:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:[t.jsx(un,{type:e.type,size:8})," ",r(e.type).name]}),e.has_text&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:a.misc.textResource}),e.has_image&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:a.misc.imageResource})]})]})]})},os=({entry:e,selected:n,onClick:o,getConfig:r,query:s,onRemove:a})=>{const l=$e(),{convert:d}=Re(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(m=>{const h=typeof m=="string"?m:m==null?void 0:m.book_title;return h==null?void 0:h.toLowerCase().includes(s.toLowerCase())}):void 0,u=Xe();return t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",borderRadius:"6px",border:n?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[t.jsxs("a",{href:u(e.id),onClick:m=>o(e,m),className:"bim-result-card",style:{...Wa,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(un,{type:e.type,size:12}),t.jsx("span",{style:{fontSize:"9px",color:i("desc-fg"),lineHeight:1},children:r(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:i("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:i("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:i("desc-fg")},children:d(e.measure_info)}):e.juan_count!=null&&e.juan_count>0?t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[e.juan_count,l.unit.juan]}):null]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"12px",color:i("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:i("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:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"12px 12px 12px 8px",lineHeight:1,opacity:.5},children:"×"})]})},uu=({id:e,onRemove:n,t:o})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${i("widget-border")}`,background:i("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:i("fg"),fontFamily:"monospace"},children:e}),t.jsx("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:o.search.itemNotFound})]}),t.jsx("button",{onClick:()=>n(e),title:o.search.removeFromRecent,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"2px 4px",lineHeight:1},children:"×"})]});function mu(e){var n;return!e.dynasty&&!e.birth_year&&!e.death_year&&(!e.alt_names||e.alt_names.length===0)&&!((n=e.description)!=null&&n.text)}function hu({data:e}){const{convert:n}=Re(),{dynasty:o,birth_year:r,death_year:s}=e,a=[];return o&&a.push(`〔${n(o)}〕`),r!==void 0&&s!==void 0?a.push(`${r}—${s}`):r!==void 0?a.push(`${r}—?`):s!==void 0&&a.push(`?—${s}`),a.length===0?null:t.jsx("span",{style:{fontSize:"14px",color:i("desc-fg"),marginLeft:"8px",fontWeight:"normal"},children:a.join(" ")})}function gu({alt_names:e}){const{convert:n}=Re(),o=new Map;for(const a of e){const l=a.type||"別名";o.has(l)||o.set(l,[]),o.get(l).push(a.name)}const r=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...o.keys()].sort((a,l)=>{const d=r.indexOf(a),c=r.indexOf(l);return d===-1&&c===-1?0:d===-1?1:c===-1?-1:d-c});return t.jsx("div",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(a=>{const l=o.get(a);return t.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[t.jsx("span",{style:{color:i("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:i("desc-fg"),margin:"0 4px"},children:"·"}),n(d)]},c))})]},a)})})}function fu({data:e}){const n=$e(),o=e.external_ids;if(!o)return null;const r=[];return o.cbdb_id&&r.push(t.jsxs("a",{href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${o.cbdb_id}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"2px 8px",fontSize:"12px",color:i("link-fg"),border:`1px solid ${i("link-fg")}40`,borderRadius:"3px",textDecoration:"none",background:`${i("link-fg")}08`},title:n.common.cbdbTitle,children:["CBDB ",o.cbdb_id]},"cbdb")),r.length===0?null:t.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:r})}function xu({works:e,transport:n,onNavigate:o,renderLink:r}){const s=$e(),{convert:a}=Re(),l=Xe(),[d,c]=g.useState(new Map);g.useEffect(()=>{if(!n)return;let h=!1;const f=e.map(k=>k.work_id);return(async()=>{const k=new Map;if(n.getEntriesByIds)try{const j=await n.getEntriesByIds(f);let S=!0;for(let v=0;v<f.length;v++){const $=j[v];$!=null&&$.title?k.set(f[v],$.title):$!=null&&$.primary_name?k.set(f[v],$.primary_name):S=!1}if(S)return k}catch{}const y=[...f],w=8,b=new Array(w).fill(0).map(async()=>{for(;y.length;){const j=y.shift();if(!j)break;if(!k.has(j))try{if(n.getEntry){const $=await n.getEntry(j);if($!=null&&$.title){k.set(j,$.title);continue}}const S=await n.getItem(j),v=S&&(S.title||S.primary_name)||j;k.set(j,v)}catch{k.set(j,j)}}});return await Promise.all(b),k})().then(k=>{h||c(k)}),()=>{h=!0}},[e,n]);const p=new Map;for(const h of e){const f=h.role||"";p.has(f)||p.set(f,[]),p.get(f).push(h)}const u=["撰","編","注","輯","集","校","評","譯","述","作",""],m=[...p.keys()].sort((h,f)=>{const x=u.indexOf(h),k=u.indexOf(f);return x===-1&&k===-1?h.localeCompare(f):x===-1?1:k===-1?-1:x-k});return t.jsxs("div",{style:{marginTop:"12px"},children:[t.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:i("fg"),margin:"0 0 8px",paddingBottom:"4px",borderBottom:`1px solid ${i("widget-border")}`},children:[s.label.relatedWorks," ",t.jsxs("span",{style:{color:i("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",e.length,")"]})]}),m.map(h=>{const f=p.get(h);return t.jsxs("div",{style:{marginBottom:"8px"},children:[h&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"2px"},children:[a(h)," ",t.jsxs("span",{style:{color:i("desc-fg")},children:["(",f.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:h?"16px":"0",listStyle:h?"disc":"none",fontSize:"14px",lineHeight:1.8},children:f.map((x,k)=>{const y=a(d.get(x.work_id)||x.work_id);return r?t.jsx("li",{children:r(x.work_id,y)},k):o?t.jsx("li",{children:t.jsx("a",{href:l(x.work_id),onClick:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),o(x.work_id))},style:{color:i("link-fg"),textDecoration:"underline",cursor:"pointer"},children:y})},k):t.jsx("li",{children:y},k)})})]},h)})]})}const Oa=({data:e,transport:n,onNavigate:o,renderLink:r,headerExtra:s,hideHeader:a})=>{var m;const l=$e(),{convert:d}=Re();let c=!1;try{c=we.extractStatus(e.id)==="draft"}catch{}const p=mu(e),u=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:i("fg")},children:[d(e.primary_name),t.jsx(hu,{data:e})]}),s]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:i("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:i("type-entity"),border:`1px solid color-mix(in srgb, ${i("type-entity")} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${i("type-entity")} 3%, transparent)`},children:l.indexType.entity}),u&&e.subtype!=="people"&&t.jsx("span",{children:u}),c&&t.jsx("span",{style:{padding:"1px 6px",background:i("warn-bg"),border:`1px solid ${i("warn-border")}`,borderRadius:"2px",color:i("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:i("desc-fg"),fontStyle:"italic",padding:"8px 12px",background:i("widget-bg"),border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",margin:"8px 0"},children:l.common.entityPlaceholderNote}),e.alt_names&&e.alt_names.length>0&&t.jsx(gu,{alt_names:e.alt_names}),t.jsx(fu,{data:e}),((m=e.description)==null?void 0:m.text)&&t.jsx("p",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:d(e.description.text)}),e.works&&e.works.length>0&&t.jsx(xu,{works:e.works,transport:n,onNavigate:o,renderLink:r})]})},bu=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function yu(e){const n=e.search(bu);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const Ha={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 o=e,r="",s=n;if(e&&typeof n=="string"&&(n===e||n===ju(e))){const[a,l]=yu(n);l&&(o=encodeURI(a),s=a,r=l)}return t.jsxs(t.Fragment,{children:[t.jsx("a",{href:o,target:o!=null&&o.startsWith("http")?"_blank":void 0,rel:o!=null&&o.startsWith("http")?"noopener noreferrer":void 0,style:{color:i("link")},children:s}),r]})},code:({children:e})=>t.jsx("code",{style:{background:i("bg-subtle"),padding:"1px 4px",borderRadius:3,fontSize:"0.92em"},children:e})};function ju(e){try{return decodeURI(e)}catch{return e}}const vu={...Ha,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},$t=({text:e,plainStrong:n,style:o,className:r})=>{const{convert:s}=Re(),a=n?vu:Ha;return t.jsx("div",{className:r,style:o,children:t.jsx(Yd,{remarkPlugins:[Kd],components:a,children:s(e)})})},ku=["〇","一","二","三","四","五","六","七","八","九"],rs=["","十","百","千"];function Fa(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),o=n.length;let r="",s=!1;for(let a=0;a<o;a++){const l=parseInt(n[a]),d=o-1-a;l===0?s=!0:(s&&r&&(r+="〇"),s=!1,l===1&&d===1&&a===0?r+=rs[d]:r+=ku[l]+rs[d])}return r}function Da(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 wu={book:i("type-book"),work:i("type-work"),collection:i("type-collection"),entity:i("type-entity")};function Su({type:e}){const n=$e();return t.jsx("span",{style:Da(wu[e]),children:n.indexType[e]})}function _u({isDraft:e}){const n=$e(),o=i(e?"status-draft":"status-official");return t.jsx("span",{style:Da(o),children:e?n.status.draft:n.status.official})}function $u({id:e}){const n=$e(),[o,r]=g.useState(!1),s=()=>{navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})};return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:i("desc-fg"),background:i("bg-subtle"),border:`1px solid ${i("widget-border")}`,borderRadius:"2px"},children:[t.jsx("span",{children:n.label.id}),t.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:i("fg")},children:e}),t.jsx("span",{onClick:s,title:o?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"11px",opacity:o?1:.5,transition:"opacity 0.15s"},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity=o?"1":"0.5",children:o?"✓":"⧉"})]})}function mt({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:i("desc-fg"),letterSpacing:"1px"},children:e}),t.jsx("span",{style:{flex:1}}),n]})}function yt({label:e,children:n}){return t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[t.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:e}),t.jsx("span",{style:{color:i("fg")},children:n})]})}function Ua({authors:e,type:n,onNavigate:o,renderLink:r}){const{convert:s}=Re();return t.jsx("span",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.6},children:e.map((a,l)=>{const d=s(a.name),c=a.entity_id?t.jsx(xt,{id:a.entity_id,label:d,onNavigate:o,renderLink:r}):t.jsx("span",{style:{fontWeight:500},children:d});return t.jsxs("span",{children:[l>0&&t.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),a.dynasty&&t.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:["〔",s(a.dynasty),"〕"]}),c,a.role&&t.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px",marginLeft:"2px"},children:[" ",s(a.role)]})]},l)})})}function xt({id:e,label:n,onNavigate:o,renderLink:r}){const s=Xe();return r?t.jsx(t.Fragment,{children:r(e,n)}):o?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),o(e))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("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 Cu({id:e,title:n,edition:o,type:r,isDraft:s,authors:a,volumeText:l,meta:d,headerExtra:c,onNavigate:p,renderLink:u}){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:i("fg"),margin:"0 0 6px",lineHeight:1.4,letterSpacing:"0.5px",wordBreak:"break-word",flex:1,minWidth:0},children:[n,o&&t.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:o}),l&&t.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:i("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(Su,{type:r}),t.jsx(_u,{isDraft:s}),t.jsx($u,{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(Ua,{authors:a,type:r,onNavigate:p,renderLink:u}),d]})]})}function Va({items:e,label:n,showMeta:o,onNavigate:r,renderLink:s}){const a=$e(),{convert:l}=Re();if(!e.length)return null;const[d,c]=g.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(mt,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((p,u)=>{const m=d===u;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...m?{boxShadow:i("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(m?null:u),style:{padding:"8px 12px",background:i("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[t.jsx("span",{style:{fontSize:"10px",color:i("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:i("fg")},children:l(p.source)}),!m&&o&&p.title_info&&t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l(p.title_info)}),p.source_bid&&t.jsx("span",{onClick:h=>h.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(xt,{id:p.source_bid,label:a.action.view,onNavigate:r,renderLink:s})})]}),m&&t.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${i("widget-border")}`},children:[o&&(p.title_info||p.author_info||p.edition)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[p.title_info&&t.jsx(yt,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx(yt,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx(yt,{label:a.label.edition,children:l(p.edition)})]}),p.summary&&t.jsxs("div",{style:{marginTop:"6px",padding:"10px 14px",borderLeft:`3px solid ${i("primary")}`,background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.summary}),t.jsx("p",{style:{fontSize:"13px",color:i("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 ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.comment}),t.jsx("p",{style:{fontSize:"13px",color:i("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 ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.additionalComment}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.additional_comment)})]})]})]},u)})})]})}function zu({items:e,onNavigate:n,renderLink:o}){const r=$e();return t.jsx(Va,{items:e,label:r.section.indexed,showMeta:!0,onNavigate:n,renderLink:o})}function Ga({items:e,onNavigate:n,renderLink:o}){const r=$e();return t.jsx(Va,{items:e,label:r.section.emendated,onNavigate:n,renderLink:o})}function Ya({label:e,items:n}){const{convert:o}=Re();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(mt,{children:e}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:n.map((r,s)=>{const a=typeof r=="string"?r:r.book_title;return t.jsx("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:i("fg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:o(a)},s)})})]}):null}function Tu({items:e}){const n=$e();return t.jsx(Ya,{label:n.section.aliases,items:e})}function Nu({items:e}){const n=$e();return t.jsx(Ya,{label:n.section.attachedTexts,items:e})}function Eu({items:e}){const n=$e(),{convert:o}=Re();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(mt,{children:n.section.appendix}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:e.map((r,s)=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:i("fg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:["《",o(r.book_title),"》",r.n_juan!=null&&t.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:[r.n_juan,n.unit.juan]})]},s))})]}):null}function Iu({items:e}){const n=$e(),{convert:o}=Re();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(mt,{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:i("widget-border")}}),e.map((r,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:i("primary"),border:`1.5px solid ${i("input-bg")}`}}),t.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:i("fg")},children:o(r.name)}),r.description&&t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),marginLeft:"8px"},children:o(r.description)})]},s))]})]}):null}function Ru({items:e}){const n=$e(),{convert:o}=Re();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(mt,{children:n.section.historyOverview}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map((r,s)=>t.jsxs("div",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[t.jsx("span",{style:{position:"absolute",left:0,top:0,color:i("desc-fg")},children:"·"}),o(r)]},s))})]}):null}function ss({title:e,ids:n,transport:o,onNavigate:r,renderLink:s}){const{convert:a}=Re(),[l,d]=g.useState([]);return g.useEffect(()=>{if(!n.length){d([]);return}if(!o){d(n.map(p=>({id:p})));return}let c=!1;return Promise.all(n.map(p=>o.getItem(p).then(u=>({id:p,title:u?u.title:void 0,edition:u?u.edition:void 0,type:u?u.type:void 0})).catch(()=>({id:p})))).then(p=>{c||d(p)}),()=>{c=!0}},[n,o]),n.length?t.jsxs(t.Fragment,{children:[t.jsxs(mt,{children:[e,t.jsxs("span",{style:{fontSize:"12px",color:i("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 ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),transition:"border-color 0.15s"},children:t.jsx(xt,{id:c.id,label:p,onNavigate:r,renderLink:s})},c.id)})})]}):null}function Oi({book:e,onNavigate:n,renderLink:o}){const r=$e(),{convert:s}=Re(),[a,l]=g.useState(!1),d=e.resources&&e.resources.length>0,c=e.edition?s(e.edition):s(e.title)||void 0;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:i("input-bg")},children:[t.jsxs("div",{style:{padding:"6px 12px",borderBottom:d&&!a?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:t.jsx(xt,{id:e.id,label:c,onNavigate:n,renderLink:o})}),d&&t.jsx("span",{onClick:()=>l(p=>!p),style:{cursor:"pointer",fontSize:"10px",color:i("desc-fg"),userSelect:"none",transition:"transform 0.15s",transform:a?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:a?r.action.expand:r.action.collapse,children:"▼"})]}),d&&!a&&t.jsx("div",{style:{padding:"10px 14px"},children:t.jsx(Eo,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:o})})]})}function Lu({ids:e,workData:n,transport:o,onNavigate:r,renderLink:s,footer:a}){const l=$e(),{convert:d}=Re(),[c,p]=g.useState([]);if(g.useEffect(()=>{if(!e.length){p([]);return}if(!o){p(e.map(k=>({id:k})));return}let x=!1;return Promise.all(e.map(k=>o.getItem(k).then(y=>({id:k,title:y?y.title:void 0,edition:y?y.edition:void 0,resources:y?y.resources:void 0,resource_groups:y?y.resource_groups:void 0})).catch(()=>({id:k})))).then(k=>{x||p(k)}),()=>{x=!0}},[e,o]),!e.length)return null;const u=c.length?c:e.map(x=>({id:x})),m=new Map(u.map(x=>[x.id,x])),h=n==null?void 0:n.version_graph,f=Au(e,h,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(mt,{children:[l.section.relatedVersions,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",e.length,")"]})]}),a,f.useGrouping?t.jsxs(t.Fragment,{children:[f.coreIds.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:f.coreIds.map(x=>{const k=m.get(x);return k?t.jsx(Oi,{book:k,onNavigate:r,renderLink:s},x):null})}),f.groupedIds.map(x=>t.jsxs("details",{style:{marginTop:12,border:`1px solid ${i("widget-border")}`,borderRadius:6,background:i("bg-subtle")},children:[t.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:i("fg"),userSelect:"none"},children:[d(x.label),t.jsxs("span",{style:{marginLeft:6,fontSize:12,color:i("desc-fg"),fontWeight:400},children:["(",x.ids.length,")"]}),x.description&&t.jsx("span",{style:{marginLeft:8,fontSize:12,color:i("desc-fg"),fontWeight:400},children:d(x.description)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"0 12px 12px"},children:x.ids.map(k=>{const y=m.get(k);return y?t.jsx(Oi,{book:y,onNavigate:r,renderLink:s},k):null})})]},x.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:u.map(x=>t.jsx(Oi,{book:x,onNavigate:r,renderLink:s},x.id))})]})}function Au(e,n,o){var w,b;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const r=(w=n.collections)==null?void 0:w[n.default_collection],s=(r==null?void 0:r.groups)??[],a=(r==null?void 0:r.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]),u=j=>{if(p.has(j))return!0;const S=n.node_groups[j];return S!=null&&c.has(S)},m=[],h=new Map,f=[];for(const j of e)if(!((b=n.excluded_books)!=null&&b.includes(j)))if(u(j))m.push(j);else{const S=n.node_groups[j];S?(h.has(S)||h.set(S,[]),h.get(S).push(j)):f.push(j)}if(f.length+[...h.values()].reduce((j,S)=>j+S.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const k=new Map((n.groups??[]).map(j=>[j.id,j])),y=[...h.entries()].map(([j,S])=>{const v=k.get(j);return{id:j,label:(v==null?void 0:v.label)??j,description:v==null?void 0:v.description,ids:S}});return f.length>0&&y.push({id:"__other__",label:o,description:void 0,ids:f}),{useGrouping:!0,coreIds:m,groupedIds:y}}function Pu({workData:e,onNavigate:n,renderLink:o}){var l,d,c,p;const r=$e(),{convert:s}=Re(),a=!!((l=e.description)!=null&&l.text)||!!e.parent_work;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:i("input-bg"),marginTop:"4px"},children:[t.jsxs("div",{style:{padding:"6px 14px",borderBottom:a?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`},children:[t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:t.jsx(xt,{id:e.id,label:s(e.title),onNavigate:n,renderLink:o})}),e.measure_info?t.jsx("span",{style:{fontSize:"12px",color:i("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:i("desc-fg")},children:[Fa(e.juan_count.number),r.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(Ua,{authors:e.authors,type:"work",onNavigate:n,renderLink:o})})]}),a&&t.jsxs("div",{style:{padding:"8px 14px"},children:[((c=e.description)==null?void 0:c.text)&&t.jsx($t,{text:e.description.text,style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,textAlign:"justify"}}),e.parent_work&&t.jsx("div",{style:{marginTop:(p=e.description)!=null&&p.text?"8px":0,fontSize:"13px"},children:t.jsx(yt,{label:r.label.parentWork,children:t.jsx(xt,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:o})})})]})]})}function Mu({items:e,onNavigate:n,renderLink:o}){const r=$e(),{convert:s}=Re();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, ${i("type-collection")} 25%, transparent)`,borderRadius:"4px",background:`color-mix(in srgb, ${i("type-collection")} 3%, transparent)`},children:[t.jsx("span",{style:{fontSize:"11px",color:i("type-collection")},children:r.indexType.collection}),t.jsx(xt,{id:a.id,label:s(a.title)||a.id,onNavigate:n,renderLink:o}),a.volume_index!=null&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"2px"},children:dt(r.catalog.volume,{n:a.volume_index})})]},a.id))}):null}const Ao=({data:e,id:n,transport:o,onNavigate:r,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var F,N,R,O,I,P,U,K;const p=$e(),{convert:u}=Re(),[m,h]=g.useState(null),[f,x]=g.useState(!1),[k,y]=g.useState(null),[w,b]=g.useState(null),[j,S]=g.useState([]),v=e||m;if(g.useEffect(()=>{if(e||!n||!o)return;let L=!1;return x(!0),y(null),o.getItem(n).then(Z=>{L||(Z?h(Z):y(p.misc.notFoundEntry))}).catch(Z=>{L||y(Z instanceof Error?Z.message:p.misc.loadFailed)}).finally(()=>{L||x(!1)}),()=>{L=!0}},[e,n,o]),g.useEffect(()=>{if(!v||!o){b(null),S([]);return}let L=!1;const Z=v.type==="book"||v.type==="collection"?v.work_id:void 0;if(Z?o.getItem(Z).then(A=>{!L&&A&&A.type==="work"&&b(A)}).catch(()=>{}):b(null),v.type==="book"){const A=v;A.contained_in&&A.contained_in.length>0?Promise.all(A.contained_in.map(V=>{const ce=typeof V=="string"?V:V.id,ne=typeof V=="string"?void 0:V.volume_index;return o.getItem(ce).then(de=>({id:ce,title:de&&de.title||ce,volume_index:ne})).catch(()=>({id:ce,title:ce,volume_index:ne}))})).then(V=>{L||S(V)}):S([])}else S([]);return()=>{L=!0}},[v,o]),f)return t.jsx("div",{className:d,style:{...c,padding:"24px"},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((L,Z)=>t.jsx("div",{style:{height:Z===1?"32px":"16px",width:`${L}px`,background:i("widget-border"),borderRadius:"4px",opacity:.4}},Z))})});if(k)return t.jsx("div",{className:d,style:{...c,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:k});if(!v)return null;if(v.type==="entity")return t.jsx("div",{className:d,style:c,children:t.jsx(Oa,{data:v,transport:o,onNavigate:r,renderLink:s,headerExtra:a})});const $=v.type==="book"?v:null,_=v.type==="collection"?v:null,C=v.type==="work"?v:null;let M=!1;try{M=we.extractStatus(v.id)==="draft"}catch{}let T="";v.measure_info?T=u(v.measure_info):(F=v.juan_count)!=null&&F.number?T=Fa(v.juan_count.number)+p.unit.juan:(N=v.juan_count)!=null&&N.description&&(T=u(v.juan_count.description));const z=[];return(R=v.publication_info)!=null&&R.year&&z.push(t.jsx(yt,{label:p.label.year,children:v.publication_info.year},"year")),(O=v.current_location)!=null&&O.name&&z.push(t.jsx(yt,{label:p.label.currentLocation,children:u(v.current_location.name)},"loc")),(I=v.page_count)!=null&&I.description&&z.push(t.jsx(yt,{label:p.label.pageCount,children:v.page_count.description},"page")),$!=null&&$.edition&&z.push(t.jsx(yt,{label:p.label.edition,children:u($.edition)},"ver")),C!=null&&C.parent_work&&z.push(t.jsx(yt,{label:p.label.parentWork,children:t.jsx(xt,{id:C.parent_work.id,label:u(C.parent_work.title),onNavigate:r,renderLink:s})},"pw")),C!=null&&C.parent_works&&C.parent_works.length>0&&!C.parent_work&&z.push(t.jsx(yt,{label:p.label.parentWork,children:C.parent_works.map((L,Z)=>t.jsxs("span",{children:[Z>0&&"、",t.jsx(xt,{id:L,onNavigate:r,renderLink:s})]},L))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(Cu,{id:v.id,title:u(v.title),edition:v.edition?u(v.edition):void 0,type:v.type,isDraft:M,authors:v.authors,volumeText:T,meta:z,headerExtra:a,onNavigate:r,renderLink:s}),((P=v.description)==null?void 0:P.text)&&t.jsx($t,{text:v.description.text,style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),v.appendix&&v.appendix.length>0&&t.jsx("div",{style:{marginTop:8,marginBottom:4},children:v.appendix.map((L,Z)=>t.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:i("bg-subtle"),borderRadius:4,border:`1px solid ${i("widget-border")}`},children:[t.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:i("muted")},children:u(L.title)}),t.jsx($t,{text:L.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:i("fg")}})]},Z))}),j.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(mt,{children:p.section.containedIn}),t.jsx(Mu,{items:j,onNavigate:r,renderLink:s})]}),w&&t.jsxs(t.Fragment,{children:[t.jsx(mt,{children:p.section.belongsToWork}),t.jsx(Pu,{workData:w,onNavigate:r,renderLink:s})]}),v.additional_works&&v.additional_works.length>0&&t.jsx(Eu,{items:v.additional_works}),v.additional_titles&&v.additional_titles.length>0&&t.jsx(Tu,{items:v.additional_titles}),v.attached_texts&&v.attached_texts.length>0&&t.jsx(Nu,{items:v.attached_texts}),v.indexed_by&&v.indexed_by.length>0&&t.jsx(zu,{items:v.indexed_by,onNavigate:r,renderLink:s}),v.emendated_by&&v.emendated_by.length>0&&t.jsx(Ga,{items:v.emendated_by,onNavigate:r,renderLink:s}),v.resources&&v.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(mt,{children:p.section.resources}),t.jsx(Eo,{items:v.resources,resourceGroups:v.resource_groups,groupByType:!0,onNavigate:r,renderLink:s})]}),($==null?void 0:$.location_history)&&$.location_history.length>0&&t.jsx(Iu,{items:$.location_history}),(_==null?void 0:_.history)&&_.history.length>0&&t.jsx(Ru,{items:_.history}),($==null?void 0:$.related_books)&&$.related_books.length>0&&t.jsx(ss,{title:p.section.relatedVersions,ids:$.related_books,transport:o,onNavigate:r,renderLink:s}),(_==null?void 0:_.books)&&_.books.length>0&&t.jsx(ss,{title:p.section.containedBooks,ids:_.books,transport:o,onNavigate:r,renderLink:s}),(_==null?void 0:_.contained_works)&&_.contained_works.length>0&&t.jsxs("div",{children:[t.jsxs(mt,{children:[p.section.containedWorks,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",_.contained_works.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:_.contained_works.map(L=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:t.jsx(xt,{id:L.id,label:u(L.title),onNavigate:r,renderLink:s})},L.id))})]}),(((U=C==null?void 0:C.books)==null?void 0:U.length)||0)+(((K=C==null?void 0:C.collections)==null?void 0:K.length)||0)>0&&t.jsx(Lu,{ids:[...(C==null?void 0:C.books)||[],...(C==null?void 0:C.collections)||[]],workData:C??void 0,transport:o,onNavigate:r,renderLink:s,footer:l}),(C==null?void 0:C.related_works)&&C.related_works.length>0&&(()=>{const L=[],Z=C.related_works.filter(pe=>pe.relation==="part_of"),A=C.related_works.filter(pe=>pe.relation==="has_part"),V=C.related_works.filter(pe=>pe.relation==="has_adaptation"),ce=C.related_works.filter(pe=>pe.relation==="text_carried_by"),ne=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),de=C.related_works.filter(pe=>!pe.relation||!ne.has(pe.relation));return Z.length>0&&L.push({label:p.section.belongsToWork,items:Z}),A.length>0&&L.push({label:p.section.containedWorks,items:A}),V.length>0&&L.push({label:p.section.adaptations,items:V}),ce.length>0&&L.push({label:p.section.derivativeWorks,items:ce}),de.length>0&&L.push({label:p.section.relatedWorks,items:de}),L.map(pe=>t.jsxs("div",{children:[t.jsxs(mt,{children:[pe.label,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",pe.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:pe.items.map(be=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:t.jsx(xt,{id:be.id,label:u(be.title),onNavigate:r,renderLink:s})},be.id))})]},pe.label))})()]})};function Bu({data:e}){const n=$e(),{convert:o}=Re(),{stats:r}=e,s=r.processed_volumes??r.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:i("fg"),margin:"0 0 8px"},children:o(e.title)}),e.resource_name&&t.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"6px"},children:o(e.resource_name)}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:i("desc-fg")},children:[t.jsxs("span",{children:[n.catalog.totalVolumes," ",t.jsx("strong",{style:{color:i("fg")},children:e.total_volumes})," ",n.unit.volume]}),a!=null&&t.jsxs("span",{children:[n.catalog.processed," ",t.jsx("strong",{style:{color:i("fg")},children:s})," ",n.unit.volume," (",a,"%)"]}),t.jsxs("span",{children:[n.catalog.contains," ",t.jsx("strong",{style:{color:i("fg")},children:r.total_books})," ",n.unit.bu]}),r.matched_works!=null&&r.matched_works>0&&t.jsxs("span",{children:[n.catalog.matched," ",t.jsx("strong",{style:{color:i("fg")},children:r.matched_works})," ",n.unit.bu]}),r.unmatched_works!=null&&r.unmatched_works>0&&t.jsxs("span",{children:[n.catalog.unmatched," ",t.jsx("strong",{style:{color:i("missing-fg")},children:r.unmatched_works})," ",n.unit.bu]})]}),e.source&&t.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:i("desc-fg")},children:[n.catalog.source," ",e.source]})]})}function Wu({sections:e,activeSection:n,onSelect:o}){const r=$e();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>o(null),style:as(n===null),children:r.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>o(s.name),style:as(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 as(e){return{padding:"4px 12px",border:e?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:e?`color-mix(in srgb, ${i("primary")} 8%, transparent)`:"transparent",color:i(e?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}function Ou({id:e,label:n,onNavigate:o,renderLink:r}){const s=Xe();return r?t.jsx(t.Fragment,{children:r(e,n)}):o?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),o(e))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("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:i("desc-fg")},children:n||e})}function Hu(e,n){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const o=e[0],r=e[e.length-1];return r-o+1===e.length?`${o}–${r}`:e.length<=3?e.join(", "):`${o}–${r} (${e.length}${n})`}function ls({book:e,onNavigate:n,renderLink:o,showVolumes:r}){const s=$e(),{convert:a}=Re(),l=e.book_id||e.work_id,d=r&&e.volumes.length>0?Hu(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 ${i("widget-border")}`,fontSize:"14px",lineHeight:1.8},children:[r&&t.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:i("desc-fg"),textAlign:"right"},children:d}),t.jsxs("span",{style:{flex:1,fontWeight:500,color:i("fg")},children:[a(e.title),e.sub_items&&e.sub_items.length>0&&t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400,marginLeft:"6px"},children:["(",e.sub_items.map(p=>a(p)).join("、"),")"]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),fontWeight:400,marginLeft:"8px"},children:a(e.edition)})]}),e.expected_volumes!=null&&t.jsxs("span",{style:{fontSize:"11px",color:i(c?"missing-fg":"desc-fg"),flexShrink:0},children:[e.found_volumes??0,"/",e.expected_volumes,s.unit.volume]}),l&&t.jsx(Ou,{id:l,label:e.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:o}),!l&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const Po=({data:e,collectionId:n,transport:o,onNavigate:r,renderLink:s,className:a,style:l})=>{const d=$e(),[c,p]=g.useState(null),[u,m]=g.useState(!1),[h,f]=g.useState(null),[x,k]=g.useState(null),[y,w]=g.useState(""),b=e||c;g.useEffect(()=>{if(e||!n||!(o!=null&&o.getCollectionCatalog))return;let _=!1;return m(!0),f(null),o.getCollectionCatalog(n).then(C=>{_||(C?p(C):f(d.catalog.notFound))}).catch(C=>{_||f(C instanceof Error?C.message:d.catalog.loadFailed)}).finally(()=>{_||m(!1)}),()=>{_=!0}},[e,n,o,d]);const j=(b==null?void 0:b.sections)&&b.sections.length>0,S=g.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const _=b.books.map(M=>M.volumes[0]).filter(M=>M!=null);return new Set(_).size<_.length},[b]),v=g.useMemo(()=>{if(!b)return[];let _=b.books;if(x&&(_=_.filter(C=>C.section===x)),y.trim()){const C=y.trim().toLowerCase();_=_.filter(M=>M.title.toLowerCase().includes(C)||M.sub_items&&M.sub_items.some(T=>T.toLowerCase().includes(C))||M.edition&&M.edition.toLowerCase().includes(C))}return _},[b,x,y]),$=g.useMemo(()=>{if(!S)return null;const _=[],C=new Map;for(const T of v){if(!T.volumes||T.volumes.length===0)continue;const z=T.volumes[0];C.has(z)||C.set(z,[]),C.get(z).push(T)}const M=[...C.keys()].sort((T,z)=>T-z);for(const T of M)_.push({volume:T,books:C.get(T)});return _},[v,S]);return u?t.jsx("div",{className:a,style:{...l,padding:"24px"},children:t.jsx("div",{style:{color:i("desc-fg"),fontSize:"13px"},children:d.catalog.loading})}):h?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:h}):b?t.jsxs("div",{className:a,style:l,children:[t.jsx(Bu,{data:b}),j&&t.jsx(Wu,{sections:b.sections,activeSection:x,onSelect:k}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:d.search.searchBookName,value:y,onChange:_=>w(_.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"}}),t.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:i("desc-fg")},children:[v.length," ",d.unit.bu]})]}),t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[$?$.map((_,C)=>t.jsxs("div",{children:[t.jsx("div",{style:{padding:"4px 12px",background:i("bg"),borderBottom:`1px solid ${i("widget-border")}`,fontSize:"12px",fontWeight:600,color:i("desc-fg"),position:"sticky",top:0,zIndex:1},children:dt(d.catalog.volume,{n:_.volume})}),_.books.map((M,T)=>t.jsx(ls,{book:M,onNavigate:r,renderLink:s,showVolumes:M.volumes.length>1},`${_.volume}-${T}`))]},`${_.volume}-${C}`)):v.map((_,C)=>t.jsx(ls,{book:_,onNavigate:r,renderLink:s,showVolumes:!0},C)),v.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},Fu="guji_markdown";function io(e){const n=e==null?void 0:e.guji_markdown;if(typeof n!="string")return!1;const o=/^(\d+)\.(\d+)(?:\.\d+)?$/.exec(n.trim());if(!o)return!1;const r=parseInt(o[1],10),s=parseInt(o[2],10);return r>0||s>=2}const Du=/^□\{guess=([^\s{}]+)\}/;function Uu(e,n){const o=e[n+1];return o!==void 0&&!/[A-Za-z/!?>\s]/.test(o)}function Ka(e,n){let o=0;for(let r=n;r<e.length;r++){const s=e[r];if(s===`
|
|
146
|
-
`)return-1;if(s==="\\"){r++;continue}if(s==="[")o++;else if(s==="]"&&(o--,o===0))return r}return-1}function
|
|
147
|
-
`)<0?{node:{type:"qw",label:e.slice(n+2,r)},end:r+2}:null}if(o===":"&&e.startsWith(":zi[",n)){const r=
|
|
148
|
-
`)return null}const c=
|
|
145
|
+
}`,Da={color:"inherit",textDecoration:"none"},hu=({snippet:e})=>{const{convert:n}=Ie();return t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.6},children:zo(e).map((o,r)=>o.marked?t.jsx("mark",{style:{background:i("highlight-bg"),color:i("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(o.text)},r):t.jsx(g.Fragment,{children:n(o.text)},r))})},gu=({entry:e,selected:n,onClick:o,getConfig:r,query:s})=>{const a=$e(),{convert:l}=Ie(),d=l(e.title||e.primary_name||e.id),c=e.measure_info?l(e.measure_info):e.juan_count!=null&&e.juan_count>0?`${e.juan_count}${a.unit.juan}`:"",p=[...e.additional_titles||[],...e.attached_texts||[]],u=s&&p.length?p.find(f=>{const x=typeof f=="string"?f:f==null?void 0:f.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,m=i("cover-accent"),h=Xe();return t.jsxs("a",{href:h(e.id),onClick:f=>o(e,f),className:"bim-result-card",style:{...Da,display:"flex",gap:"1.2rem",alignItems:"stretch",padding:"1.1rem 1.3rem",borderRadius:"12px",cursor:"pointer",background:i("bg"),border:n?`1px solid ${i("primary")}`:`1px solid ${i("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%, ${i("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${m} 14%, ${i("bg")}), color-mix(in srgb, ${m} 7%, ${i("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((f,x)=>t.jsx("span",{children:f},x))})]}),t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"17px",fontWeight:600,color:i("fg")},children:d}),c&&t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:c})]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"13px",color:i("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:i("desc-fg")},children:[e.era&&t.jsxs("span",{children:["〔",l(e.era),"〕"]}),e.edition&&t.jsx("span",{children:l(e.edition)})]}),u&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[a.search.alias,":",l(typeof u=="string"?u:u.book_title||"")]}),e.descriptionSnippet&&t.jsx(hu,{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:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:[t.jsx(un,{type:e.type,size:8})," ",r(e.type).name]}),e.has_text&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:a.misc.textResource}),e.has_image&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:a.misc.imageResource})]})]})]})},ls=({entry:e,selected:n,onClick:o,getConfig:r,query:s,onRemove:a})=>{const l=$e(),{convert:d}=Ie(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(m=>{const h=typeof m=="string"?m:m==null?void 0:m.book_title;return h==null?void 0:h.toLowerCase().includes(s.toLowerCase())}):void 0,u=Xe();return t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",borderRadius:"6px",border:n?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[t.jsxs("a",{href:u(e.id),onClick:m=>o(e,m),className:"bim-result-card",style:{...Da,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(un,{type:e.type,size:12}),t.jsx("span",{style:{fontSize:"9px",color:i("desc-fg"),lineHeight:1},children:r(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:i("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:i("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:i("desc-fg")},children:d(e.measure_info)}):e.juan_count!=null&&e.juan_count>0?t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[e.juan_count,l.unit.juan]}):null]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"12px",color:i("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:i("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:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"12px 12px 12px 8px",lineHeight:1,opacity:.5},children:"×"})]})},fu=({id:e,onRemove:n,t:o})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${i("widget-border")}`,background:i("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:i("fg"),fontFamily:"monospace"},children:e}),t.jsx("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:o.search.itemNotFound})]}),t.jsx("button",{onClick:()=>n(e),title:o.search.removeFromRecent,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"2px 4px",lineHeight:1},children:"×"})]});function xu(e){var n;return!e.dynasty&&!e.birth_year&&!e.death_year&&(!e.alt_names||e.alt_names.length===0)&&!((n=e.description)!=null&&n.text)}function bu({data:e}){const{convert:n}=Ie(),{dynasty:o,birth_year:r,death_year:s}=e,a=[];return o&&a.push(`〔${n(o)}〕`),r!==void 0&&s!==void 0?a.push(`${r}—${s}`):r!==void 0?a.push(`${r}—?`):s!==void 0&&a.push(`?—${s}`),a.length===0?null:t.jsx("span",{style:{fontSize:"14px",color:i("desc-fg"),marginLeft:"8px",fontWeight:"normal"},children:a.join(" ")})}function yu({alt_names:e}){const{convert:n}=Ie(),o=new Map;for(const a of e){const l=a.type||"別名";o.has(l)||o.set(l,[]),o.get(l).push(a.name)}const r=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...o.keys()].sort((a,l)=>{const d=r.indexOf(a),c=r.indexOf(l);return d===-1&&c===-1?0:d===-1?1:c===-1?-1:d-c});return t.jsx("div",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(a=>{const l=o.get(a);return t.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[t.jsx("span",{style:{color:i("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:i("desc-fg"),margin:"0 4px"},children:"·"}),n(d)]},c))})]},a)})})}function ju({data:e}){const n=$e(),o=e.external_ids;if(!o)return null;const r=[];return o.cbdb_id&&r.push(t.jsxs("a",{href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${o.cbdb_id}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"2px 8px",fontSize:"12px",color:i("link-fg"),border:`1px solid ${i("link-fg")}40`,borderRadius:"3px",textDecoration:"none",background:`${i("link-fg")}08`},title:n.common.cbdbTitle,children:["CBDB ",o.cbdb_id]},"cbdb")),r.length===0?null:t.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:r})}function vu({works:e,transport:n,onNavigate:o,renderLink:r}){const s=$e(),{convert:a}=Ie(),l=Xe(),[d,c]=g.useState(new Map);g.useEffect(()=>{if(!n)return;let h=!1;const f=e.map(k=>k.work_id);return(async()=>{const k=new Map;if(n.getEntriesByIds)try{const j=await n.getEntriesByIds(f);let S=!0;for(let v=0;v<f.length;v++){const $=j[v];$!=null&&$.title?k.set(f[v],$.title):$!=null&&$.primary_name?k.set(f[v],$.primary_name):S=!1}if(S)return k}catch{}const y=[...f],w=8,b=new Array(w).fill(0).map(async()=>{for(;y.length;){const j=y.shift();if(!j)break;if(!k.has(j))try{if(n.getEntry){const $=await n.getEntry(j);if($!=null&&$.title){k.set(j,$.title);continue}}const S=await n.getItem(j),v=S&&(S.title||S.primary_name)||j;k.set(j,v)}catch{k.set(j,j)}}});return await Promise.all(b),k})().then(k=>{h||c(k)}),()=>{h=!0}},[e,n]);const p=new Map;for(const h of e){const f=h.role||"";p.has(f)||p.set(f,[]),p.get(f).push(h)}const u=["撰","編","注","輯","集","校","評","譯","述","作",""],m=[...p.keys()].sort((h,f)=>{const x=u.indexOf(h),k=u.indexOf(f);return x===-1&&k===-1?h.localeCompare(f):x===-1?1:k===-1?-1:x-k});return t.jsxs("div",{style:{marginTop:"12px"},children:[t.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:i("fg"),margin:"0 0 8px",paddingBottom:"4px",borderBottom:`1px solid ${i("widget-border")}`},children:[s.label.relatedWorks," ",t.jsxs("span",{style:{color:i("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",e.length,")"]})]}),m.map(h=>{const f=p.get(h);return t.jsxs("div",{style:{marginBottom:"8px"},children:[h&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"2px"},children:[a(h)," ",t.jsxs("span",{style:{color:i("desc-fg")},children:["(",f.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:h?"16px":"0",listStyle:h?"disc":"none",fontSize:"14px",lineHeight:1.8},children:f.map((x,k)=>{const y=a(d.get(x.work_id)||x.work_id);return r?t.jsx("li",{children:r(x.work_id,y)},k):o?t.jsx("li",{children:t.jsx("a",{href:l(x.work_id),onClick:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),o(x.work_id))},style:{color:i("link-fg"),textDecoration:"underline",cursor:"pointer"},children:y})},k):t.jsx("li",{children:y},k)})})]},h)})]})}const Ua=({data:e,transport:n,onNavigate:o,renderLink:r,headerExtra:s,hideHeader:a})=>{var m;const l=$e(),{convert:d}=Ie();let c=!1;try{c=we.extractStatus(e.id)==="draft"}catch{}const p=xu(e),u=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:i("fg")},children:[d(e.primary_name),t.jsx(bu,{data:e})]}),s]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:i("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:i("type-entity"),border:`1px solid color-mix(in srgb, ${i("type-entity")} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${i("type-entity")} 3%, transparent)`},children:l.indexType.entity}),u&&e.subtype!=="people"&&t.jsx("span",{children:u}),c&&t.jsx("span",{style:{padding:"1px 6px",background:i("warn-bg"),border:`1px solid ${i("warn-border")}`,borderRadius:"2px",color:i("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:i("desc-fg"),fontStyle:"italic",padding:"8px 12px",background:i("widget-bg"),border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",margin:"8px 0"},children:l.common.entityPlaceholderNote}),e.alt_names&&e.alt_names.length>0&&t.jsx(yu,{alt_names:e.alt_names}),t.jsx(ju,{data:e}),((m=e.description)==null?void 0:m.text)&&t.jsx("p",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:d(e.description.text)}),e.works&&e.works.length>0&&t.jsx(vu,{works:e.works,transport:n,onNavigate:o,renderLink:r})]})},ku=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function wu(e){const n=e.search(ku);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const Va={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 o=e,r="",s=n;if(e&&typeof n=="string"&&(n===e||n===Su(e))){const[a,l]=wu(n);l&&(o=encodeURI(a),s=a,r=l)}return t.jsxs(t.Fragment,{children:[t.jsx("a",{href:o,target:o!=null&&o.startsWith("http")?"_blank":void 0,rel:o!=null&&o.startsWith("http")?"noopener noreferrer":void 0,style:{color:i("link")},children:s}),r]})},code:({children:e})=>t.jsx("code",{style:{background:i("bg-subtle"),padding:"1px 4px",borderRadius:3,fontSize:"0.92em"},children:e})};function Su(e){try{return decodeURI(e)}catch{return e}}const _u={...Va,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},Ct=({text:e,plainStrong:n,style:o,className:r})=>{const{convert:s}=Ie(),a=n?_u:Va;return t.jsx("div",{className:r,style:o,children:t.jsx(Zd,{remarkPlugins:[Jd],components:a,children:s(e)})})},$u=["〇","一","二","三","四","五","六","七","八","九"],cs=["","十","百","千"];function Ga(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),o=n.length;let r="",s=!1;for(let a=0;a<o;a++){const l=parseInt(n[a]),d=o-1-a;l===0?s=!0:(s&&r&&(r+="〇"),s=!1,l===1&&d===1&&a===0?r+=cs[d]:r+=$u[l]+cs[d])}return r}function Ya(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 Cu={book:i("type-book"),work:i("type-work"),collection:i("type-collection"),entity:i("type-entity")};function zu({type:e}){const n=$e();return t.jsx("span",{style:Ya(Cu[e]),children:n.indexType[e]})}function Tu({isDraft:e}){const n=$e(),o=i(e?"status-draft":"status-official");return t.jsx("span",{style:Ya(o),children:e?n.status.draft:n.status.official})}function Nu({id:e}){const n=$e(),[o,r]=g.useState(!1),s=()=>{navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})};return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:i("desc-fg"),background:i("bg-subtle"),border:`1px solid ${i("widget-border")}`,borderRadius:"2px"},children:[t.jsx("span",{children:n.label.id}),t.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:i("fg")},children:e}),t.jsx("span",{onClick:s,title:o?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"11px",opacity:o?1:.5,transition:"opacity 0.15s"},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity=o?"1":"0.5",children:o?"✓":"⧉"})]})}function ht({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:i("desc-fg"),letterSpacing:"1px"},children:e}),t.jsx("span",{style:{flex:1}}),n]})}function jt({label:e,children:n}){return t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[t.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:e}),t.jsx("span",{style:{color:i("fg")},children:n})]})}function Ka({authors:e,type:n,onNavigate:o,renderLink:r}){const{convert:s}=Ie();return t.jsx("span",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.6},children:e.map((a,l)=>{const d=s(a.name),c=a.entity_id?t.jsx(bt,{id:a.entity_id,label:d,onNavigate:o,renderLink:r}):t.jsx("span",{style:{fontWeight:500},children:d});return t.jsxs("span",{children:[l>0&&t.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),a.dynasty&&t.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:["〔",s(a.dynasty),"〕"]}),c,a.role&&t.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px",marginLeft:"2px"},children:[" ",s(a.role)]})]},l)})})}function bt({id:e,label:n,onNavigate:o,renderLink:r}){const s=Xe();return r?t.jsx(t.Fragment,{children:r(e,n)}):o?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),o(e))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("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 Eu({id:e,title:n,edition:o,type:r,isDraft:s,authors:a,volumeText:l,meta:d,headerExtra:c,onNavigate:p,renderLink:u}){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:i("fg"),margin:"0 0 6px",lineHeight:1.4,letterSpacing:"0.5px",wordBreak:"break-word",flex:1,minWidth:0},children:[n,o&&t.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:o}),l&&t.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:i("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(zu,{type:r}),t.jsx(Tu,{isDraft:s}),t.jsx(Nu,{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(Ka,{authors:a,type:r,onNavigate:p,renderLink:u}),d]})]})}function qa({items:e,label:n,showMeta:o,onNavigate:r,renderLink:s}){const a=$e(),{convert:l}=Ie();if(!e.length)return null;const[d,c]=g.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(ht,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((p,u)=>{const m=d===u;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...m?{boxShadow:i("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(m?null:u),style:{padding:"8px 12px",background:i("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[t.jsx("span",{style:{fontSize:"10px",color:i("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:i("fg")},children:l(p.source)}),!m&&o&&p.title_info&&t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l(p.title_info)}),p.source_bid&&t.jsx("span",{onClick:h=>h.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(bt,{id:p.source_bid,label:a.action.view,onNavigate:r,renderLink:s})})]}),m&&t.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${i("widget-border")}`},children:[o&&(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(jt,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx(jt,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx(jt,{label:a.label.edition,children:l(p.edition)})]}),p.summary&&t.jsxs("div",{style:{marginTop:"6px",padding:"10px 14px",borderLeft:`3px solid ${i("primary")}`,background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.summary}),t.jsx("p",{style:{fontSize:"13px",color:i("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 ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.comment}),t.jsx("p",{style:{fontSize:"13px",color:i("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 ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.additionalComment}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.additional_comment)})]})]})]},u)})})]})}function Iu({items:e,onNavigate:n,renderLink:o}){const r=$e();return t.jsx(qa,{items:e,label:r.section.indexed,showMeta:!0,onNavigate:n,renderLink:o})}function Xa({items:e,onNavigate:n,renderLink:o}){const r=$e();return t.jsx(qa,{items:e,label:r.section.emendated,onNavigate:n,renderLink:o})}function Za({label:e,items:n}){const{convert:o}=Ie();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(ht,{children:e}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:n.map((r,s)=>{const a=typeof r=="string"?r:r.book_title;return t.jsx("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:i("fg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:o(a)},s)})})]}):null}function Ru({items:e}){const n=$e();return t.jsx(Za,{label:n.section.aliases,items:e})}function Lu({items:e}){const n=$e();return t.jsx(Za,{label:n.section.attachedTexts,items:e})}function Au({items:e}){const n=$e(),{convert:o}=Ie();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(ht,{children:n.section.appendix}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:e.map((r,s)=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:i("fg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:["《",o(r.book_title),"》",r.n_juan!=null&&t.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:[r.n_juan,n.unit.juan]})]},s))})]}):null}function Pu({items:e}){const n=$e(),{convert:o}=Ie();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(ht,{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:i("widget-border")}}),e.map((r,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:i("primary"),border:`1.5px solid ${i("input-bg")}`}}),t.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:i("fg")},children:o(r.name)}),r.description&&t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),marginLeft:"8px"},children:o(r.description)})]},s))]})]}):null}function Mu({items:e}){const n=$e(),{convert:o}=Ie();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(ht,{children:n.section.historyOverview}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map((r,s)=>t.jsxs("div",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[t.jsx("span",{style:{position:"absolute",left:0,top:0,color:i("desc-fg")},children:"·"}),o(r)]},s))})]}):null}function ds({title:e,ids:n,transport:o,onNavigate:r,renderLink:s}){const{convert:a}=Ie(),[l,d]=g.useState([]);return g.useEffect(()=>{if(!n.length){d([]);return}if(!o){d(n.map(p=>({id:p})));return}let c=!1;return Promise.all(n.map(p=>o.getItem(p).then(u=>({id:p,title:u?u.title:void 0,edition:u?u.edition:void 0,type:u?u.type:void 0})).catch(()=>({id:p})))).then(p=>{c||d(p)}),()=>{c=!0}},[n,o]),n.length?t.jsxs(t.Fragment,{children:[t.jsxs(ht,{children:[e,t.jsxs("span",{style:{fontSize:"12px",color:i("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 ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),transition:"border-color 0.15s"},children:t.jsx(bt,{id:c.id,label:p,onNavigate:r,renderLink:s})},c.id)})})]}):null}function Di({book:e,onNavigate:n,renderLink:o}){const r=$e(),{convert:s}=Ie(),[a,l]=g.useState(!1),d=e.resources&&e.resources.length>0,c=e.edition?s(e.edition):s(e.title)||void 0;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:i("input-bg")},children:[t.jsxs("div",{style:{padding:"6px 12px",borderBottom:d&&!a?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:t.jsx(bt,{id:e.id,label:c,onNavigate:n,renderLink:o})}),d&&t.jsx("span",{onClick:()=>l(p=>!p),style:{cursor:"pointer",fontSize:"10px",color:i("desc-fg"),userSelect:"none",transition:"transform 0.15s",transform:a?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:a?r.action.expand:r.action.collapse,children:"▼"})]}),d&&!a&&t.jsx("div",{style:{padding:"10px 14px"},children:t.jsx(Lo,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:o})})]})}function Bu({ids:e,workData:n,transport:o,onNavigate:r,renderLink:s,footer:a}){const l=$e(),{convert:d}=Ie(),[c,p]=g.useState([]);if(g.useEffect(()=>{if(!e.length){p([]);return}if(!o){p(e.map(k=>({id:k})));return}let x=!1;return Promise.all(e.map(k=>o.getItem(k).then(y=>({id:k,title:y?y.title:void 0,edition:y?y.edition:void 0,resources:y?y.resources:void 0,resource_groups:y?y.resource_groups:void 0})).catch(()=>({id:k})))).then(k=>{x||p(k)}),()=>{x=!0}},[e,o]),!e.length)return null;const u=c.length?c:e.map(x=>({id:x})),m=new Map(u.map(x=>[x.id,x])),h=n==null?void 0:n.version_graph,f=Wu(e,h,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(ht,{children:[l.section.relatedVersions,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",e.length,")"]})]}),a,f.useGrouping?t.jsxs(t.Fragment,{children:[f.coreIds.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:f.coreIds.map(x=>{const k=m.get(x);return k?t.jsx(Di,{book:k,onNavigate:r,renderLink:s},x):null})}),f.groupedIds.map(x=>t.jsxs("details",{style:{marginTop:12,border:`1px solid ${i("widget-border")}`,borderRadius:6,background:i("bg-subtle")},children:[t.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:i("fg"),userSelect:"none"},children:[d(x.label),t.jsxs("span",{style:{marginLeft:6,fontSize:12,color:i("desc-fg"),fontWeight:400},children:["(",x.ids.length,")"]}),x.description&&t.jsx("span",{style:{marginLeft:8,fontSize:12,color:i("desc-fg"),fontWeight:400},children:d(x.description)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"0 12px 12px"},children:x.ids.map(k=>{const y=m.get(k);return y?t.jsx(Di,{book:y,onNavigate:r,renderLink:s},k):null})})]},x.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:u.map(x=>t.jsx(Di,{book:x,onNavigate:r,renderLink:s},x.id))})]})}function Wu(e,n,o){var w,b;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const r=(w=n.collections)==null?void 0:w[n.default_collection],s=(r==null?void 0:r.groups)??[],a=(r==null?void 0:r.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]),u=j=>{if(p.has(j))return!0;const S=n.node_groups[j];return S!=null&&c.has(S)},m=[],h=new Map,f=[];for(const j of e)if(!((b=n.excluded_books)!=null&&b.includes(j)))if(u(j))m.push(j);else{const S=n.node_groups[j];S?(h.has(S)||h.set(S,[]),h.get(S).push(j)):f.push(j)}if(f.length+[...h.values()].reduce((j,S)=>j+S.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const k=new Map((n.groups??[]).map(j=>[j.id,j])),y=[...h.entries()].map(([j,S])=>{const v=k.get(j);return{id:j,label:(v==null?void 0:v.label)??j,description:v==null?void 0:v.description,ids:S}});return f.length>0&&y.push({id:"__other__",label:o,description:void 0,ids:f}),{useGrouping:!0,coreIds:m,groupedIds:y}}function Ou({workData:e,onNavigate:n,renderLink:o}){var l,d,c,p;const r=$e(),{convert:s}=Ie(),a=!!((l=e.description)!=null&&l.text)||!!e.parent_work;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:i("input-bg"),marginTop:"4px"},children:[t.jsxs("div",{style:{padding:"6px 14px",borderBottom:a?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`},children:[t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:t.jsx(bt,{id:e.id,label:s(e.title),onNavigate:n,renderLink:o})}),e.measure_info?t.jsx("span",{style:{fontSize:"12px",color:i("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:i("desc-fg")},children:[Ga(e.juan_count.number),r.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(Ka,{authors:e.authors,type:"work",onNavigate:n,renderLink:o})})]}),a&&t.jsxs("div",{style:{padding:"8px 14px"},children:[((c=e.description)==null?void 0:c.text)&&t.jsx(Ct,{text:e.description.text,style:{fontSize:"13px",color:i("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(jt,{label:r.label.parentWork,children:t.jsx(bt,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:o})})})]})]})}function Hu({items:e,onNavigate:n,renderLink:o}){const r=$e(),{convert:s}=Ie();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, ${i("type-collection")} 25%, transparent)`,borderRadius:"4px",background:`color-mix(in srgb, ${i("type-collection")} 3%, transparent)`},children:[t.jsx("span",{style:{fontSize:"11px",color:i("type-collection")},children:r.indexType.collection}),t.jsx(bt,{id:a.id,label:s(a.title)||a.id,onNavigate:n,renderLink:o}),a.volume_index!=null&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"2px"},children:pt(r.catalog.volume,{n:a.volume_index})})]},a.id))}):null}const Bo=({data:e,id:n,transport:o,onNavigate:r,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var F,N,R,O,I,P,U,K;const p=$e(),{convert:u}=Ie(),[m,h]=g.useState(null),[f,x]=g.useState(!1),[k,y]=g.useState(null),[w,b]=g.useState(null),[j,S]=g.useState([]),v=e||m;if(g.useEffect(()=>{if(e||!n||!o)return;let L=!1;return x(!0),y(null),o.getItem(n).then(Z=>{L||(Z?h(Z):y(p.misc.notFoundEntry))}).catch(Z=>{L||y(Z instanceof Error?Z.message:p.misc.loadFailed)}).finally(()=>{L||x(!1)}),()=>{L=!0}},[e,n,o]),g.useEffect(()=>{if(!v||!o){b(null),S([]);return}let L=!1;const Z=v.type==="book"||v.type==="collection"?v.work_id:void 0;if(Z?o.getItem(Z).then(A=>{!L&&A&&A.type==="work"&&b(A)}).catch(()=>{}):b(null),v.type==="book"){const A=v;A.contained_in&&A.contained_in.length>0?Promise.all(A.contained_in.map(V=>{const pe=typeof V=="string"?V:V.id,ee=typeof V=="string"?void 0:V.volume_index;return o.getItem(pe).then(ue=>({id:pe,title:ue&&ue.title||pe,volume_index:ee})).catch(()=>({id:pe,title:pe,volume_index:ee}))})).then(V=>{L||S(V)}):S([])}else S([]);return()=>{L=!0}},[v,o]),f)return t.jsx("div",{className:d,style:{...c,padding:"24px"},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((L,Z)=>t.jsx("div",{style:{height:Z===1?"32px":"16px",width:`${L}px`,background:i("widget-border"),borderRadius:"4px",opacity:.4}},Z))})});if(k)return t.jsx("div",{className:d,style:{...c,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:k});if(!v)return null;if(v.type==="entity")return t.jsx("div",{className:d,style:c,children:t.jsx(Ua,{data:v,transport:o,onNavigate:r,renderLink:s,headerExtra:a})});const $=v.type==="book"?v:null,_=v.type==="collection"?v:null,C=v.type==="work"?v:null;let M=!1;try{M=we.extractStatus(v.id)==="draft"}catch{}let T="";v.measure_info?T=u(v.measure_info):(F=v.juan_count)!=null&&F.number?T=Ga(v.juan_count.number)+p.unit.juan:(N=v.juan_count)!=null&&N.description&&(T=u(v.juan_count.description));const z=[];return(R=v.publication_info)!=null&&R.year&&z.push(t.jsx(jt,{label:p.label.year,children:v.publication_info.year},"year")),(O=v.current_location)!=null&&O.name&&z.push(t.jsx(jt,{label:p.label.currentLocation,children:u(v.current_location.name)},"loc")),(I=v.page_count)!=null&&I.description&&z.push(t.jsx(jt,{label:p.label.pageCount,children:v.page_count.description},"page")),$!=null&&$.edition&&z.push(t.jsx(jt,{label:p.label.edition,children:u($.edition)},"ver")),C!=null&&C.parent_work&&z.push(t.jsx(jt,{label:p.label.parentWork,children:t.jsx(bt,{id:C.parent_work.id,label:u(C.parent_work.title),onNavigate:r,renderLink:s})},"pw")),C!=null&&C.parent_works&&C.parent_works.length>0&&!C.parent_work&&z.push(t.jsx(jt,{label:p.label.parentWork,children:C.parent_works.map((L,Z)=>t.jsxs("span",{children:[Z>0&&"、",t.jsx(bt,{id:L,onNavigate:r,renderLink:s})]},L))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(Eu,{id:v.id,title:u(v.title),edition:v.edition?u(v.edition):void 0,type:v.type,isDraft:M,authors:v.authors,volumeText:T,meta:z,headerExtra:a,onNavigate:r,renderLink:s}),((P=v.description)==null?void 0:P.text)&&t.jsx(Ct,{text:v.description.text,style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),v.appendix&&v.appendix.length>0&&t.jsx("div",{style:{marginTop:8,marginBottom:4},children:v.appendix.map((L,Z)=>t.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:i("bg-subtle"),borderRadius:4,border:`1px solid ${i("widget-border")}`},children:[t.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:i("muted")},children:u(L.title)}),t.jsx(Ct,{text:L.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:i("fg")}})]},Z))}),j.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(ht,{children:p.section.containedIn}),t.jsx(Hu,{items:j,onNavigate:r,renderLink:s})]}),w&&t.jsxs(t.Fragment,{children:[t.jsx(ht,{children:p.section.belongsToWork}),t.jsx(Ou,{workData:w,onNavigate:r,renderLink:s})]}),v.additional_works&&v.additional_works.length>0&&t.jsx(Au,{items:v.additional_works}),v.additional_titles&&v.additional_titles.length>0&&t.jsx(Ru,{items:v.additional_titles}),v.attached_texts&&v.attached_texts.length>0&&t.jsx(Lu,{items:v.attached_texts}),v.indexed_by&&v.indexed_by.length>0&&t.jsx(Iu,{items:v.indexed_by,onNavigate:r,renderLink:s}),v.emendated_by&&v.emendated_by.length>0&&t.jsx(Xa,{items:v.emendated_by,onNavigate:r,renderLink:s}),v.resources&&v.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(ht,{children:p.section.resources}),t.jsx(Lo,{items:v.resources,resourceGroups:v.resource_groups,groupByType:!0,onNavigate:r,renderLink:s})]}),($==null?void 0:$.location_history)&&$.location_history.length>0&&t.jsx(Pu,{items:$.location_history}),(_==null?void 0:_.history)&&_.history.length>0&&t.jsx(Mu,{items:_.history}),($==null?void 0:$.related_books)&&$.related_books.length>0&&t.jsx(ds,{title:p.section.relatedVersions,ids:$.related_books,transport:o,onNavigate:r,renderLink:s}),(_==null?void 0:_.books)&&_.books.length>0&&t.jsx(ds,{title:p.section.containedBooks,ids:_.books,transport:o,onNavigate:r,renderLink:s}),(_==null?void 0:_.contained_works)&&_.contained_works.length>0&&t.jsxs("div",{children:[t.jsxs(ht,{children:[p.section.containedWorks,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",_.contained_works.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:_.contained_works.map(L=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:t.jsx(bt,{id:L.id,label:u(L.title),onNavigate:r,renderLink:s})},L.id))})]}),(((U=C==null?void 0:C.books)==null?void 0:U.length)||0)+(((K=C==null?void 0:C.collections)==null?void 0:K.length)||0)>0&&t.jsx(Bu,{ids:[...(C==null?void 0:C.books)||[],...(C==null?void 0:C.collections)||[]],workData:C??void 0,transport:o,onNavigate:r,renderLink:s,footer:l}),(C==null?void 0:C.related_works)&&C.related_works.length>0&&(()=>{const L=[],Z=C.related_works.filter(me=>me.relation==="part_of"),A=C.related_works.filter(me=>me.relation==="has_part"),V=C.related_works.filter(me=>me.relation==="has_adaptation"),pe=C.related_works.filter(me=>me.relation==="text_carried_by"),ee=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),ue=C.related_works.filter(me=>!me.relation||!ee.has(me.relation));return Z.length>0&&L.push({label:p.section.belongsToWork,items:Z}),A.length>0&&L.push({label:p.section.containedWorks,items:A}),V.length>0&&L.push({label:p.section.adaptations,items:V}),pe.length>0&&L.push({label:p.section.derivativeWorks,items:pe}),ue.length>0&&L.push({label:p.section.relatedWorks,items:ue}),L.map(me=>t.jsxs("div",{children:[t.jsxs(ht,{children:[me.label,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",me.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:me.items.map(be=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:t.jsx(bt,{id:be.id,label:u(be.title),onNavigate:r,renderLink:s})},be.id))})]},me.label))})()]})};function Fu({data:e}){const n=$e(),{convert:o}=Ie(),{stats:r}=e,s=r.processed_volumes??r.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:i("fg"),margin:"0 0 8px"},children:o(e.title)}),e.resource_name&&t.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"6px"},children:o(e.resource_name)}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:i("desc-fg")},children:[t.jsxs("span",{children:[n.catalog.totalVolumes," ",t.jsx("strong",{style:{color:i("fg")},children:e.total_volumes})," ",n.unit.volume]}),a!=null&&t.jsxs("span",{children:[n.catalog.processed," ",t.jsx("strong",{style:{color:i("fg")},children:s})," ",n.unit.volume," (",a,"%)"]}),t.jsxs("span",{children:[n.catalog.contains," ",t.jsx("strong",{style:{color:i("fg")},children:r.total_books})," ",n.unit.bu]}),r.matched_works!=null&&r.matched_works>0&&t.jsxs("span",{children:[n.catalog.matched," ",t.jsx("strong",{style:{color:i("fg")},children:r.matched_works})," ",n.unit.bu]}),r.unmatched_works!=null&&r.unmatched_works>0&&t.jsxs("span",{children:[n.catalog.unmatched," ",t.jsx("strong",{style:{color:i("missing-fg")},children:r.unmatched_works})," ",n.unit.bu]})]}),e.source&&t.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:i("desc-fg")},children:[n.catalog.source," ",e.source]})]})}function Du({sections:e,activeSection:n,onSelect:o}){const r=$e();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>o(null),style:ps(n===null),children:r.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>o(s.name),style:ps(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 ps(e){return{padding:"4px 12px",border:e?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:e?`color-mix(in srgb, ${i("primary")} 8%, transparent)`:"transparent",color:i(e?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}function Uu({id:e,label:n,onNavigate:o,renderLink:r}){const s=Xe();return r?t.jsx(t.Fragment,{children:r(e,n)}):o?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),o(e))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("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:i("desc-fg")},children:n||e})}function Vu(e,n){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const o=e[0],r=e[e.length-1];return r-o+1===e.length?`${o}–${r}`:e.length<=3?e.join(", "):`${o}–${r} (${e.length}${n})`}function us({book:e,onNavigate:n,renderLink:o,showVolumes:r}){const s=$e(),{convert:a}=Ie(),l=e.book_id||e.work_id,d=r&&e.volumes.length>0?Vu(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 ${i("widget-border")}`,fontSize:"14px",lineHeight:1.8},children:[r&&t.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:i("desc-fg"),textAlign:"right"},children:d}),t.jsxs("span",{style:{flex:1,fontWeight:500,color:i("fg")},children:[a(e.title),e.sub_items&&e.sub_items.length>0&&t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400,marginLeft:"6px"},children:["(",e.sub_items.map(p=>a(p)).join("、"),")"]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),fontWeight:400,marginLeft:"8px"},children:a(e.edition)})]}),e.expected_volumes!=null&&t.jsxs("span",{style:{fontSize:"11px",color:i(c?"missing-fg":"desc-fg"),flexShrink:0},children:[e.found_volumes??0,"/",e.expected_volumes,s.unit.volume]}),l&&t.jsx(Uu,{id:l,label:e.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:o}),!l&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const Wo=({data:e,collectionId:n,transport:o,onNavigate:r,renderLink:s,className:a,style:l})=>{const d=$e(),[c,p]=g.useState(null),[u,m]=g.useState(!1),[h,f]=g.useState(null),[x,k]=g.useState(null),[y,w]=g.useState(""),b=e||c;g.useEffect(()=>{if(e||!n||!(o!=null&&o.getCollectionCatalog))return;let _=!1;return m(!0),f(null),o.getCollectionCatalog(n).then(C=>{_||(C?p(C):f(d.catalog.notFound))}).catch(C=>{_||f(C instanceof Error?C.message:d.catalog.loadFailed)}).finally(()=>{_||m(!1)}),()=>{_=!0}},[e,n,o,d]);const j=(b==null?void 0:b.sections)&&b.sections.length>0,S=g.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const _=b.books.map(M=>M.volumes[0]).filter(M=>M!=null);return new Set(_).size<_.length},[b]),v=g.useMemo(()=>{if(!b)return[];let _=b.books;if(x&&(_=_.filter(C=>C.section===x)),y.trim()){const C=y.trim().toLowerCase();_=_.filter(M=>M.title.toLowerCase().includes(C)||M.sub_items&&M.sub_items.some(T=>T.toLowerCase().includes(C))||M.edition&&M.edition.toLowerCase().includes(C))}return _},[b,x,y]),$=g.useMemo(()=>{if(!S)return null;const _=[],C=new Map;for(const T of v){if(!T.volumes||T.volumes.length===0)continue;const z=T.volumes[0];C.has(z)||C.set(z,[]),C.get(z).push(T)}const M=[...C.keys()].sort((T,z)=>T-z);for(const T of M)_.push({volume:T,books:C.get(T)});return _},[v,S]);return u?t.jsx("div",{className:a,style:{...l,padding:"24px"},children:t.jsx("div",{style:{color:i("desc-fg"),fontSize:"13px"},children:d.catalog.loading})}):h?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:h}):b?t.jsxs("div",{className:a,style:l,children:[t.jsx(Fu,{data:b}),j&&t.jsx(Du,{sections:b.sections,activeSection:x,onSelect:k}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:d.search.searchBookName,value:y,onChange:_=>w(_.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"}}),t.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:i("desc-fg")},children:[v.length," ",d.unit.bu]})]}),t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[$?$.map((_,C)=>t.jsxs("div",{children:[t.jsx("div",{style:{padding:"4px 12px",background:i("bg"),borderBottom:`1px solid ${i("widget-border")}`,fontSize:"12px",fontWeight:600,color:i("desc-fg"),position:"sticky",top:0,zIndex:1},children:pt(d.catalog.volume,{n:_.volume})}),_.books.map((M,T)=>t.jsx(us,{book:M,onNavigate:r,renderLink:s,showVolumes:M.volumes.length>1},`${_.volume}-${T}`))]},`${_.volume}-${C}`)):v.map((_,C)=>t.jsx(us,{book:_,onNavigate:r,renderLink:s,showVolumes:!0},C)),v.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},Gu="guji_markdown";function so(e){const n=e==null?void 0:e.guji_markdown;if(typeof n!="string")return!1;const o=/^(\d+)\.(\d+)(?:\.\d+)?$/.exec(n.trim());if(!o)return!1;const r=parseInt(o[1],10),s=parseInt(o[2],10);return r>0||s>=2}const Yu=/^□\{guess=([^\s{}]+)\}/;function Ku(e,n){const o=e[n+1];return o!==void 0&&!/[A-Za-z/!?>\s]/.test(o)}function Ja(e,n){let o=0;for(let r=n;r<e.length;r++){const s=e[r];if(s===`
|
|
146
|
+
`)return-1;if(s==="\\"){r++;continue}if(s==="[")o++;else if(s==="]"&&(o--,o===0))return r}return-1}function qu(e){return e.replace(/\\([\\[\]<>|{}])/g,"$1")}function Xu(e,n){const o=e[n];if(o==="["&&e[n+1]==="["){const r=e.indexOf("]]",n+2);return r>=0&&e.slice(n+2,r).indexOf(`
|
|
147
|
+
`)<0?{node:{type:"qw",label:e.slice(n+2,r)},end:r+2}:null}if(o===":"&&e.startsWith(":zi[",n)){const r=Ja(e,n+3);return r>n+4?{node:{type:"zi",label:qu(e.slice(n+4,r))},end:r+1}:null}if(o==="□"&&e[n+1]==="{"){const r=Yu.exec(e.slice(n,n+64));if(r)return{node:{type:"qz",guess:r[1]},end:n+r[0].length}}return null}function Qa(e,n,o,r){const s=[];let a="";const l=()=>{if(!a)return;const d=r?a.replace(/\\?\|/g,""):a;d&&s.push({type:"text",text:d}),a=""};for(;n<e.length;){const d=e[n];if(o!==null){if(d===o)return l(),{nodes:s,end:n};if(d===`
|
|
148
|
+
`)return null}const c=Xu(e,n);if(c){l(),s.push(c.node),n=c.end;continue}let p=null;if(d==="⟨"?p="⟩":d==="<"&&Ku(e,n)&&(p=">"),p){const u=Qa(e,n+1,p,!0);if(u){l(),s.push({type:"jz",children:u.nodes}),n=u.end+1;continue}}a+=d,n++}return o!==null?null:(l(),{nodes:s,end:n})}function el(e){return Qa(e,0,null,!1).nodes}function Zu(e){return/[<⟨□]|\[\[|:zi\[/.test(e)}function tl(e){return e.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${tl(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const nl="guji-table-v1";function il(e){return!!e&&e.table_notation===nl}const Ju=/^:::table(?:\{[^}]*\})?[ \t]*$/,Qu=/^:::[ \t]*$/;function ol(e){const n=[];let o="";for(let r=0;r<e.length;r++){const s=e[r];if(s===":"&&e.startsWith(":zi[",r)){const l=Ja(e,r+3);if(l>r+4){o+=e.slice(r,l+1),r=l;continue}}let a=null;if(s==="⟨")a="⟩";else if(s==="<"){const l=e[r+1];l!==void 0&&!/[A-Za-z/!?>\s]/.test(l)&&(a=">")}if(a){const l=e.indexOf(a,r+1);if(l>0){o+=e.slice(r,l+1),r=l;continue}}s==="|"?(n.push(o),o=""):o+=s}return n.push(o),n.map(r=>r.trim())}const em=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function tm(e){if(e==="^")return{cont:!0};const n=em.exec(e),o=n[1].trim(),r=n[2]?Math.max(1,parseInt(n[2],10)):1,s=n[3]?Math.max(1,parseInt(n[3],10)):1,a=o==="_";return{cont:!1,cell:{text:a?"":o,empty:a,colspan:r,rowspan:s}}}function rl(e,n=1){const o=[],r=[],s=[];let a=[];e.forEach((d,c)=>{const p=c+n+1;let u=d.trim();if(!u)return;let m=!1;u.startsWith("!")&&(m=!0,u=u.slice(1));const h=ol(u).map(tm),f=a.map(w=>w>0),x=a.map(w=>w>0?w-1:0),k=[];let y=0;for(const w of h){if(w.cont){f[y]||o.push(`第 ${p} 行第 ${y+1} 列:续格 ^ 上方没有跨行格`),y+=1;continue}const{cell:b}=w;for(let j=y;j<y+b.colspan;j++)if(f[j]){o.push(`第 ${p} 行第 ${j+1} 列:此处被上方跨行格占住,应写 ^`);break}if(b.rowspan>1)for(let j=y;j<y+b.colspan;j++)x[j]=b.rowspan-1;k.push(b),y+=b.colspan}for(let w=y;w<f.length;w++)f[w]&&o.push(`第 ${p} 行第 ${w+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let w=0;w<x.length;w++)x[w]===void 0&&(x[w]=0);a=x,r.push({header:m,cells:k}),s.push({width:y,line:p})});const l=s.reduce((d,c)=>Math.max(d,c.width),0);for(const d of s)d.width!==l&&o.push(`第 ${d.line} 行:占 ${d.width} 列,与总列数 ${l} 不符`);return a.some(d=>d>0)&&o.push("表尾:有跨行格超出了表的最后一行"),r.length===0&&o.push("空表"),{rows:r,columns:l,warnings:o}}function Oo(e){const n=e.split(`
|
|
149
149
|
`),o=[];let r=[];const s=()=>{if(r.length===0)return;const l=r.join(`
|
|
150
|
-
`);r=[],o.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(
|
|
151
|
-
`)}),a=l+1;continue}}r.push(n[a]),a++}return s(),o.map((l,d)=>{var p,u;if(l.type!=="text")return l;let c=l.text;return((p=o[d-1])==null?void 0:p.type)==="table"&&(c=c.replace(/^\n+/,"")),((u=o[d+1])==null?void 0:u.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(l=>l.type!=="text"||l.text!=="")}const
|
|
150
|
+
`);r=[],o.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(Ju.test(n[a].trim())){let l=a+1;for(;l<n.length&&!Qu.test(n[l].trim());)l++;if(l<n.length){s();const d=n.slice(a+1,l);o.push({type:"table",table:rl(d,a+1),source:n.slice(a,l+1).join(`
|
|
151
|
+
`)}),a=l+1;continue}}r.push(n[a]),a++}return s(),o.map((l,d)=>{var p,u;if(l.type!=="text")return l;let c=l.text;return((p=o[d-1])==null?void 0:p.type)==="table"&&(c=c.replace(/^\n+/,"")),((u=o[d+1])==null?void 0:u.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(l=>l.type!=="text"||l.text!=="")}const Ui=e=>e?e.catch(()=>null):Promise.resolve(null);function sl(e){const n=new Map;function o(r){var a;let s=n.get(r);return s||(s=Ui((a=e.getTextManifest)==null?void 0:a.call(e,r)).then(l=>{const d=l&&Array.isArray(l.versions)&&l.versions.length>0?l:null;return d||n.delete(r),d}),n.set(r,s)),s}return{getManifest(r){return we.isSafeSegment(r)?o(r):Promise.resolve(null)},async getIndex(r,s){return!we.isSafeSegment(r)||!we.isSafeSegment(s)||!e.getTextIndex?null:Ui(e.getTextIndex(r,s))},async getChapter(r,s,a,l){return!we.isSafeSegment(r)||!we.isSafeSegment(s)||!we.isSafeSegment(a)||!e.getChapter?null:Ui(e.getChapter(r,s,a,l))}}}const Yt=()=>{const{t:e}=Q(),[n,o]=g.useState(1);return g.useEffect(()=>{const r=setInterval(()=>o(s=>s>=3?1:s+1),500);return()=>clearInterval(r)},[]),t.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:i("desc-fg"),fontSize:"14px"},children:e("common.loading")+".".repeat(n)})},Vi=String.raw`https?:\/\/[^\s()()<>"]+`,nm=new RegExp(String.raw`\[([^\]\n]+)\]\((${Vi})\)`+String.raw`|(《[^》\n]+》)\s?[((](${Vi})[))]`+`|(${Vi})`,"g");function im(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function om(e){const n=[];let o=0;for(const r of e.matchAll(nm)){const s=r.index??0;s>o&&n.push({text:e.slice(o,s)}),r[1]!==void 0?n.push({text:r[1],url:r[2]}):r[3]!==void 0?n.push({text:r[3],url:r[4]}):n.push({text:im(r[5]),url:r[5]}),o=s+r[0].length}return o<e.length&&n.push({text:e.slice(o)}),n}function al({text:e,convert:n,className:o="bim-rd-link"}){return t.jsx(t.Fragment,{children:om(e).map((r,s)=>r.url?t.jsx("a",{className:o,href:r.url,target:"_blank",rel:"noopener noreferrer",children:n(r.text)},s):t.jsx(g.Fragment,{children:n(r.text)},s))})}const ll="(min-width: 1100px)",cl="(max-width: 719px)",dl="(max-width: 859px)",rm=`${cl}, (pointer: coarse)`,Nt=i("reader-top"),sm="48px",pl=`
|
|
152
152
|
.bim-rd {
|
|
153
153
|
position: relative;
|
|
154
154
|
background: ${i("page-bg")};
|
|
155
155
|
color: ${i("ink")};
|
|
156
156
|
font-family: ${i("font-ui")};
|
|
157
|
-
--bimrd-bar-h: ${
|
|
157
|
+
--bimrd-bar-h: ${sm};
|
|
158
158
|
}
|
|
159
159
|
.bim-rd *, .bim-rd *::before, .bim-rd *::after { box-sizing: border-box; }
|
|
160
160
|
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
|
|
181
181
|
/* ── 工具条:文字 + 图标,不画按钮外框 ── */
|
|
182
182
|
.bim-rd-bar {
|
|
183
|
-
position: sticky; top: ${
|
|
183
|
+
position: sticky; top: ${Nt}; z-index: 30;
|
|
184
184
|
height: var(--bimrd-bar-h);
|
|
185
185
|
display: flex; align-items: center; gap: 16px;
|
|
186
186
|
padding: 0 20px;
|
|
@@ -235,14 +235,14 @@
|
|
|
235
235
|
display: grid;
|
|
236
236
|
grid-template-columns: auto auto minmax(0, 1fr);
|
|
237
237
|
align-items: start;
|
|
238
|
-
min-height: calc(100vh - ${
|
|
238
|
+
min-height: calc(100vh - ${Nt} - var(--bimrd-bar-h));
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
/* 目录:宽屏是侧栏 */
|
|
242
242
|
.bim-rd-toc {
|
|
243
243
|
grid-column: 1;
|
|
244
|
-
position: sticky; top: calc(${
|
|
245
|
-
width: 248px; height: calc(100vh - ${
|
|
244
|
+
position: sticky; top: calc(${Nt} + var(--bimrd-bar-h));
|
|
245
|
+
width: 248px; height: calc(100vh - ${Nt} - var(--bimrd-bar-h));
|
|
246
246
|
overflow-y: auto; overscroll-behavior: contain;
|
|
247
247
|
padding: 0 10px 40px;
|
|
248
248
|
background: ${i("sidebar-bg")};
|
|
@@ -279,8 +279,8 @@
|
|
|
279
279
|
/* 书影:正文左侧 */
|
|
280
280
|
.bim-rd-img {
|
|
281
281
|
grid-column: 2;
|
|
282
|
-
position: sticky; top: calc(${
|
|
283
|
-
width: clamp(300px, 32vw, 560px); height: calc(100vh - ${
|
|
282
|
+
position: sticky; top: calc(${Nt} + var(--bimrd-bar-h));
|
|
283
|
+
width: clamp(300px, 32vw, 560px); height: calc(100vh - ${Nt} - var(--bimrd-bar-h));
|
|
284
284
|
padding: 16px 0 16px 20px;
|
|
285
285
|
display: flex; flex-direction: column; gap: 8px;
|
|
286
286
|
}
|
|
@@ -291,7 +291,7 @@
|
|
|
291
291
|
display: flex; align-items: center; justify-content: center; overflow: hidden;
|
|
292
292
|
}
|
|
293
293
|
.bim-rd-img-fig { position: relative; margin: 0; max-width: 100%; max-height: 100%; }
|
|
294
|
-
.bim-rd-img-fig img { display: block; max-width: 100%; max-height: calc(100vh - ${
|
|
294
|
+
.bim-rd-img-fig img { display: block; max-width: 100%; max-height: calc(100vh - ${Nt} - var(--bimrd-bar-h) - 80px); object-fit: contain; }
|
|
295
295
|
.bim-rd-img-fig svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
|
|
296
296
|
.bim-rd-img-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px; text-align: center; font-size: 13px; color: ${i("meta-fg")}; }
|
|
297
297
|
.bim-rd-img-empty b { font-size: 15px; font-weight: 500; color: ${i("quiet-fg")}; }
|
|
@@ -387,7 +387,7 @@
|
|
|
387
387
|
|
|
388
388
|
/* 竖排(预留):只在宿主打开 allowVertical 时可切换 */
|
|
389
389
|
.bim-rd-vertical .bim-rd-prose {
|
|
390
|
-
writing-mode: vertical-rl; max-height: calc(100vh - ${
|
|
390
|
+
writing-mode: vertical-rl; max-height: calc(100vh - ${Nt} - var(--bimrd-bar-h) - 120px);
|
|
391
391
|
overflow-x: auto; text-align: start;
|
|
392
392
|
}
|
|
393
393
|
|
|
@@ -444,7 +444,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
444
444
|
.bim-rd-sheet-img .bim-rd-img-fig img { max-height: 60vh; }
|
|
445
445
|
.bim-rd-sheet-fs { display: flex; align-items: center; justify-content: center; gap: 24px; padding: 8px 0 12px; font-size: 15px; color: ${i("ink")}; }
|
|
446
446
|
.bim-rd-sheet-fs .bim-rd-t { min-width: 56px; min-height: 44px; justify-content: center; font-size: 17px; border: 1px solid ${i("rule")}; }
|
|
447
|
-
@media ${
|
|
447
|
+
@media ${dl} {
|
|
448
448
|
.bim-rd[data-bb] .bim-rd-text { padding-bottom: calc(56px + 64px + env(safe-area-inset-bottom, 0px)); }
|
|
449
449
|
/* 底栏上已有的,工具条上不再重复(目录、字号) */
|
|
450
450
|
.bim-rd[data-bb] .bim-rd-bb-dup { display: none !important; }
|
|
@@ -454,7 +454,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
454
454
|
|
|
455
455
|
/* ── 点击区 ≥44×44(INT Q4):伪元素向外扩,按钮外观与排布不变;
|
|
456
456
|
A− A+ 挨着,两边各扩约 10px 会叠在一起,所以二者之间多留 12px ── */
|
|
457
|
-
@media ${
|
|
457
|
+
@media ${rm} {
|
|
458
458
|
.bim-rd-tools .bim-rd-t, .bim-rd-toc-head .bim-rd-t { position: relative; }
|
|
459
459
|
.bim-rd-tools .bim-rd-t::after, .bim-rd-toc-head .bim-rd-t::after {
|
|
460
460
|
content: ""; position: absolute; left: 50%; top: 50%;
|
|
@@ -467,7 +467,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
467
467
|
}
|
|
468
468
|
|
|
469
469
|
/* ── 中屏以下:目录改抽屉 ── */
|
|
470
|
-
@media not all and ${
|
|
470
|
+
@media not all and ${ll} {
|
|
471
471
|
.bim-rd-toc {
|
|
472
472
|
position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; height: auto;
|
|
473
473
|
width: min(86vw, 320px);
|
|
@@ -481,7 +481,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
481
481
|
}
|
|
482
482
|
|
|
483
483
|
/* ── 窄屏:书影收起,只留正文 ── */
|
|
484
|
-
@media ${
|
|
484
|
+
@media ${cl} {
|
|
485
485
|
.bim-rd-bar { padding: 0 12px; gap: 10px; }
|
|
486
486
|
.bim-rd-ttl span, .bim-rd-hide-narrow { display: none !important; }
|
|
487
487
|
/* 工具条放不下时(版本、自然段、标出作品链接都在)在条内左右滑,不撑宽页面 */
|
|
@@ -634,12 +634,12 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
634
634
|
letter-spacing: 0.05em;
|
|
635
635
|
margin-left: 6px;
|
|
636
636
|
}
|
|
637
|
-
`;function Bo(e,n){var o;return n?e.key===n?!0:!!((o=e.children)!=null&&o.some(r=>Bo(r,n))):!1}const im=()=>t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:t.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function om({item:e,activeKey:n,onSelect:o,tabKey:r}){const s=Bo(e,n),[a,l]=g.useState(s||!!e.defaultExpanded);return g.useEffect(()=>{s&&l(!0)},[s]),g.useEffect(()=>{e.defaultExpanded&&l(!0)},[e.defaultExpanded]),t.jsxs("li",{children:[t.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":a,"data-rd-toc-key":e.key,tabIndex:r===e.key?0:-1,onClick:()=>l(d=>!d),children:[t.jsx(im,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),a&&t.jsx(ll,{items:e.children,activeKey:n,onSelect:o,tabKey:r})]})}function ll({items:e,activeKey:n,onSelect:o,tabKey:r}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(om,{item:s,activeKey:n,onSelect:o,tabKey:r},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:r===s.key?0:-1,onClick:()=>o(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 cs(e,n){var o;for(const r of e)if(r.key===n||Bo(r,n))return r.key;return((o=e[0])==null?void 0:o.key)??null}function cl({items:e,activeKey:n,onSelect:o,label:r}){const{t:s}=J(),a=r??s("reader.toc"),l=g.useRef(null),[d,c]=g.useState(null);g.useEffect(()=>{c(null)},[n]);const p=g.useMemo(()=>d||(n??cs(e,n)),[d,n,e]);g.useEffect(()=>{const m=l.current;if(!m)return;const h=Array.from(m.querySelectorAll("[data-rd-toc-key]"));if(h.length===0)return;const f=h.find(x=>x.dataset.rdTocKey===p)??h.find(x=>x.dataset.rdTocKey===cs(e,n))??h.find(x=>!x.disabled)??h[0];for(const x of h)x.tabIndex=x===f?0:-1}),g.useEffect(()=>{const m=l.current,h=m==null?void 0:m.closest(".bim-rd-toc");if(!m||!h||!n)return;const f=Array.from(m.querySelectorAll("[data-rd-toc-key]")).find(k=>k.dataset.rdTocKey===n);if(!f)return;const x=f.getBoundingClientRect().top-h.getBoundingClientRect().top+h.scrollTop;(x<h.scrollTop+80||x>h.scrollTop+h.clientHeight-40)&&(h.scrollTop=Math.max(0,x-h.clientHeight/3))},[n]);const u=g.useCallback(m=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(m.key))return;const f=l.current;if(!f)return;const x=Array.from(f.querySelectorAll("[data-rd-toc-key]")).filter(b=>!b.disabled),k=x.indexOf(document.activeElement);let y=k;if(m.key==="ArrowDown"?y=Math.min(x.length-1,k+1):m.key==="ArrowUp"?y=Math.max(0,k-1):m.key==="Home"?y=0:m.key==="End"&&(y=x.length-1),y<0||y===k)return;m.preventDefault();const w=x[y];for(const b of x)b.tabIndex=-1;w.tabIndex=0,w.focus(),c(w.dataset.rdTocKey??null)},[]);return t.jsx("div",{ref:l,role:"navigation","aria-label":a,onKeyDown:u,children:t.jsx(ll,{items:e,activeKey:n,onSelect:o,tabKey:p})})}function rm({page:e}){var n;return!((n=e.boxes)!=null&&n.length)||!e.width||!e.height||e.boxFormat&&e.boxFormat!=="bim-charbox-v0"?null:t.jsx("svg",{viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:e.boxes.map((o,r)=>t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:"none",stroke:i("accent"),strokeOpacity:.55,vectorEffect:"non-scaling-stroke",strokeWidth:1},r))})}function oo({pages:e,loading:n,page:o,onPageChange:r,renderOverlay:s}){const{t:a}=J(),[l,d]=g.useState(0),c=o??l,p=f=>{r?r(f):d(f)};if(g.useEffect(()=>{o===void 0&&d(0)},[e,o]),n)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsx("div",{className:"bim-rd-img-empty",children:a("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:a("reader.noImages")}),t.jsx("span",{children:a("reader.noImagesHint")})]})});const u=Math.max(0,Math.min(e.length-1,c)),m=e[u],h=m.label??`${u+1}`;return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-img-box",children:t.jsxs("figure",{className:"bim-rd-img-fig",children:[t.jsx("img",{src:m.url,alt:m.alt??a("reader.imageAlt",{label:h}),width:m.width,height:m.height,loading:"lazy",decoding:"async"}),t.jsx(rm,{page:m}),s==null?void 0:s(m,u)]})}),e.length>1&&t.jsxs("div",{className:"bim-rd-img-pager",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":a("reader.prevImage"),disabled:u===0,onClick:()=>p(u-1),children:"‹"}),t.jsx("span",{"aria-live":"polite",children:m.label??`${u+1} / ${e.length}`}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":a("reader.nextImage"),disabled:u===e.length-1,onClick:()=>p(u+1),children:"›"})]})]})}const Wo={fontSize:null,readingMode:"line",properNames:!1,writingMode:"horizontal",workLinks:!0},wt=[15,16,17,18,20,22,24],ro=18,dl="bim-reader-prefs",sm="bim-reading-mode";function am(){const e={...Wo};try{const n=localStorage.getItem(dl),o=n?JSON.parse(n):{};typeof o.fontSize=="number"&&wt.includes(o.fontSize)&&(e.fontSize=o.fontSize),(o.readingMode??localStorage.getItem(sm))==="paragraph"&&(e.readingMode="paragraph"),o.properNames===!0&&(e.properNames=!0),o.writingMode==="vertical"&&(e.writingMode="vertical"),o.workLinks===!1&&(e.workLinks=!1)}catch{}return e}function lm(e){try{localStorage.setItem(dl,JSON.stringify(e))}catch{}}function Gn(e,n){const o=e??ro,r=wt;let s=r.indexOf(o);return s<0&&(s=r.indexOf(ro)),r[Math.max(0,Math.min(r.length-1,s+n))]}function pl(){const[e,n]=g.useState(Wo);g.useEffect(()=>{n(am())},[]);const o=g.useCallback(r=>{n(s=>{const a={...s,...r};return lm(a),a})},[]);return[e,o]}function so(e){if(e.optionLabel)return e.optionLabel;const n=e.label||e.key;return!e.sourceName||n.includes(e.sourceName)?n:`${n} · ${e.sourceName}`}function ul(e,n){if(!(!e||e.length===0))return(n!=null?e.find(o=>o.key===n):void 0)??e.find(o=>o.primary)??e[0]}function ml(e){const n=[],o=r=>{for(const s of r)s.children&&s.children.length>0?o(s.children):n.push(s)};return o(e),n}const ds=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:t.jsx("path",{d:"M4 6h16M4 12h10M4 18h16"})}),cm=()=>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"})}),dm=()=>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"})}),ps=()=>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 us(e,n){if(!n)return;const o=Array.from(n.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(l=>l.tabIndex>=0);if(o.length===0)return;const r=o[0],s=o[o.length-1],a=document.activeElement;e.shiftKey&&(a===r||!n.contains(a))?(e.preventDefault(),s.focus()):!e.shiftKey&&(a===s||!n.contains(a))&&(e.preventDefault(),r.focus())}function ms(e,n){const[o,r]=g.useState(n);return g.useEffect(()=>{var l;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(e);r(s.matches);const a=()=>r(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]),o}function pm(){const e=g.useContext(Yt),{t:n}=J();if(!e)return null;const o=e.locale==="zh-Hant";return t.jsxs("button",{type:"button",className:"bim-rd-t",title:n(o?"common.toHans":"common.toHant"),"aria-label":n(o?"common.toHans":"common.toHant"),onClick:()=>e.setLocale(o?"zh-Hans":"zh-Hant"),children:[t.jsx("span",{className:o?"bim-rd-on":"bim-rd-off",children:n("common.localeShortHant")}),t.jsx("span",{className:"bim-rd-off",children:"|"}),t.jsx("span",{className:o?"bim-rd-off":"bim-rd-on",children:n("common.localeShortHans")})]})}function um(e,n){if(!e)return;let o;for(const r of Array.from(e.querySelectorAll('[id^="rd-e-"]')))if(r.getBoundingClientRect().top<=n+8)o=r.id;else break;return o}function mm(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 o=e.querySelector(".bim-rd-col"),r=l=>{const d=(l==null?void 0:l.nodeType)===1?l:l==null?void 0:l.parentElement;return!!l&&!!(o!=null&&o.contains(l))&&!(d!=null&&d.closest(".bim-rd-src, .bim-rd-pager"))};if(!r(n.anchorNode)||!r(n.focusNode))return;const s=n.toString().replace(/\s+/g," ").trim();return s?s.slice(0,500):void 0}function hl({title:e,subtitle:n,toc:o,activeKey:r,onSelect:s,tocHeader:a,tocCaption:l,images:d,imagesLoading:c,renderImageOverlay:p,imagePanel:u="auto",prefs:m,onPrefsChange:h,paragraphToggle:f,properNameToggle:x=!0,allowVertical:k,byline:y,current:w,workLinkToggle:b,rail:j,onReportError:S,revisedAt:v,backHref:$,backLabel:_,bottomBar:C=!0,pager:M=!0,pagerUnit:T,versions:z,currentVersionKey:F,onVersionChange:N,versionSource:R=!0,keepChapterOnVersionChange:O=!1,customImagePanel:I,toolbarExtra:P,isWarpMode:U,children:K,className:L,style:Z}){const{t:A,convert:V}=J(),ce=_??A("reader.back"),ne=V(T??A("reader.unitJuan")),de=g.useId().replace(/:/g,""),pe=`bim-rd-toc-${de}`,be=`bim-rd-text-${de}`,Oe=g.useRef(null),ie=g.useRef(null),Le=g.useRef(null),Ae=g.useRef(null),q=ms(ol,!0),Q=ms(sl,!1),fe=C&&Q,[ze,Y]=g.useState(null),ve=g.useRef(null),le=g.useRef(null),Se=(D,re)=>{le.current=re,Y(Pe=>Pe===D?null:D)},X=g.useCallback(()=>{var D;Y(null),(D=le.current)==null||D.focus()},[]);g.useEffect(()=>{fe||Y(null)},[fe]),g.useEffect(()=>{var D,re;ze&&((re=(D=ve.current)==null?void 0:D.querySelector("button:not([disabled])"))==null||re.focus())},[ze]);const[Ce,Me]=g.useState("auto"),B=Ce==="auto"?q:Ce==="open",ee=!q,ye=!!I||!!d&&d.length>0,[H,se]=g.useState(u);g.useEffect(()=>{se(u)},[u]);const te=H==="auto"?ye||!!c:H==="open",ge=g.useCallback(D=>{var re;Me("auto"),D&&((re=Ae.current)==null||re.focus())},[]),Ne=()=>Me(B?"closed":"open");g.useEffect(()=>{if(!ee||Ce!=="open")return;const D=Le.current,re=D==null?void 0:D.querySelector('input, [data-rd-toc-key][tabindex="0"]');re==null||re.focus()},[ee,Ce]);const Be=g.useCallback(D=>{s(D),ee&&ge(!1);const re=ie.current,Pe=Oe.current;if(re&&Pe&&typeof window<"u"){const _e=re.getBoundingClientRect().top-Pe.getBoundingClientRect().bottom;_e<0&&window.scrollBy({top:_e})}},[s,ee,ge]),We=g.useMemo(()=>ml(o),[o]),[Ue,Qe]=g.useState(null),me=ul(z,F!==void 0?F:Ue),tt=(me==null?void 0:me.key)??null,E=g.useMemo(()=>We.map(D=>D.key).join(`
|
|
638
|
-
`),[We]),oe=g.useRef(null),ae=D=>{D!==tt&&(O||(oe.current={key:D,sig:E,done:!1}),F===void 0&&Qe(D),N==null||N(D))};g.useEffect(()=>{const D=oe.current;if(!D||D.key!==tt)return;const re=We.find(_e=>!_e.disabled);if(!re)return;const Pe=E!==D.sig;!Pe&&D.done||(Pe?oe.current=null:D.done=!0,re.key!==r&&Be(re.key))},[tt,E,We,r,Be]);const je=We.find(D=>D.key===r),ke=()=>{var D;S==null||S({chapterKey:r,chapterLabel:typeof(je==null?void 0:je.label)=="string"?je.label:void 0,anchor:um(ie.current,((D=Oe.current)==null?void 0:D.getBoundingClientRect().bottom)??0),selectedText:mm(ie.current)})},xe=We.findIndex(D=>D.key===r),G=xe>0?We.slice(0,xe).reverse().find(D=>!D.disabled):void 0,ue=xe>=0?We.slice(xe+1).find(D=>!D.disabled):void 0,Te=m.fontSize??ro,Ee={...Z,...m.fontSize?{"--bimrd-fs":`${m.fontSize}px`}:null};return t.jsxs("div",{className:["bim-rd",m.writingMode==="vertical"&&k?"bim-rd-vertical":"",L].filter(Boolean).join(" "),"data-toc":Ce,"data-img":te?"open":"closed","data-bb":fe?"":void 0,"data-warp":U?"true":void 0,style:Ee,children:[t.jsx("style",{children:al}),t.jsx("a",{className:"bim-rd-skip",href:`#${be}`,onClick:D=>{var re,Pe,_e;D.preventDefault(),(re=ie.current)==null||re.focus(),(_e=(Pe=ie.current)==null?void 0:Pe.scrollIntoView)==null||_e.call(Pe,{block:"start"})},children:A("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:Oe,children:[$&&t.jsxs("a",{className:"bim-rd-back",href:$,"aria-label":A("reader.backAria",{label:ce}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:ce})]}),(e||n||y||w)&&t.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[e&&t.jsx("b",{children:e}),y&&t.jsx("span",{className:"bim-rd-by",children:y}),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",{children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":A("reader.settings"),children:[z&&z.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:me?V(so(me)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:A("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:A("reader.versionShort")}),t.jsx("select",{"aria-label":A("reader.version"),value:tt??"",onChange:D=>ae(D.target.value),children:z.map(D=>t.jsx("option",{value:D.key,children:V(so(D))},D.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),M&&(G||ue)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":A("reader.pagerGroup",{unit:ne}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.prevUnit",{unit:ne}),title:G?typeof G.label=="string"&&G.label?A("reader.prevUnitTitle",{unit:ne,label:G.label}):A("reader.prevUnit",{unit:ne}):A("reader.firstUnit",{unit:ne}),disabled:!G,onClick:()=>G&&Be(G.key),children:t.jsx(cm,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.nextUnit",{unit:ne}),title:ue?typeof ue.label=="string"&&ue.label?A("reader.nextUnitTitle",{unit:ne,label:ue.label}):A("reader.nextUnit",{unit:ne}):A("reader.lastUnit",{unit:ne}),disabled:!ue,onClick:()=>ue&&Be(ue.key),children:t.jsx(dm,{})})]}),M&&(G||ue)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:Ae,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":B,"aria-controls":pe,onClick:Ne,children:[t.jsx(ds,{}),t.jsx("span",{className:"bim-rd-tlabel",children:A("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":te,onClick:()=>se(te?"closed":"open"),children:[t.jsx(ps,{}),A("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(pm,{}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":A("reader.fontSmaller"),disabled:Te<=wt[0],onClick:()=>h({fontSize:Gn(m.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":A("reader.fontLarger"),disabled:Te>=wt[wt.length-1],onClick:()=>h({fontSize:Gn(m.fontSize,1)}),children:"A+"}),(f||x||k)&&t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),f&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":m.readingMode==="paragraph",title:A("reader.paragraphTitle"),onClick:()=>h({readingMode:m.readingMode==="paragraph"?"line":"paragraph"}),children:A("reader.paragraph")}),b&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk",children:[t.jsx("input",{type:"checkbox",checked:m.workLinks,onChange:D=>h({workLinks:D.target.checked})}),t.jsx("span",{children:A("reader.workLinks")})]}),x&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":m.properNames,title:A("reader.properNameTitle"),onClick:()=>h({properNames:!m.properNames}),children:A("reader.properName")}),k&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":m.writingMode==="vertical",onClick:()=>h({writingMode:m.writingMode==="vertical"?"horizontal":"vertical"}),children:A("reader.vertical")}),P]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:pe,ref:Le,role:ee&&B?"dialog":void 0,"aria-modal":ee&&B?!0:void 0,"aria-label":ee&&B?A("reader.toc"):void 0,onKeyDown:D=>{if(!(!ee||!B)){if(D.key==="Escape"){D.stopPropagation(),ge(!0);return}D.key==="Tab"&&us(D,Le.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:l??A("reader.toc")}),ee&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.closeToc"),onClick:()=>ge(!0),children:"✕"})]}),a]}),t.jsx(cl,{items:o,activeKey:r,onSelect:Be})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>ge(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":A("reader.images"),children:te&&(I||t.jsx(oo,{pages:d??null,loading:c,renderOverlay:p}))}),t.jsxs("div",{className:"bim-rd-text",id:be,ref:ie,tabIndex:-1,"data-rail":(j||S)&&!U?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[K,R&&me&&(me.sourceName||me.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":me.key,children:[me.sourceName&&t.jsxs(t.Fragment,{children:[A("reader.sourceLabel")," ",me.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:me.sourceUrl,target:"_blank",rel:"noreferrer",children:V(me.sourceName)}):V(me.sourceName)]}),me.sourceName&&me.license&&t.jsx("span",{className:"bim-rd-dot"}),me.license&&t.jsx(t.Fragment,{children:A("reader.licenseOf",{license:me.license})})]}),v&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:A("reader.revisedAt",{date:v})}),S&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:D=>D.preventDefault(),onClick:ke,children:A("reader.reportError")})}),M&&(G||ue)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":A("reader.pagerNav"),children:[G?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>Be(G.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),A("reader.prevUnit",{unit:ne})]}),t.jsx("span",{className:"bim-rd-pglabel",children:G.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",A("reader.firstUnit",{unit:ne})]}),ue?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>Be(ue.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[A("reader.nextUnit",{unit:ne}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:ue.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[A("reader.lastUnit",{unit:ne})," →"]})]})]}),(j||S)&&!U&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":A("reader.rail"),children:[j,S&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:D=>D.preventDefault(),onClick:ke,children:A("reader.reportError")})})]})]})]}),fe&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":A("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":B,"aria-controls":pe,onClick:()=>{Y(null),Ne()},children:[t.jsx(ds,{}),t.jsx("span",{children:A("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":ze==="img","aria-haspopup":"dialog",onClick:D=>Se("img",D.currentTarget),children:[t.jsx(ps,{}),t.jsx("span",{children:A("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":ze==="fs","aria-haspopup":"dialog",onClick:D=>Se("fs",D.currentTarget),children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"A"}),t.jsx("span",{children:A("reader.fontSize")})]}),S&&t.jsxs("button",{type:"button",onMouseDown:D=>D.preventDefault(),onClick:()=>{Y(null),ke()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:A("reader.reportError")})]})]}),fe&&ze&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:X}),t.jsxs("div",{className:"bim-rd-sheet",ref:ve,role:"dialog","aria-modal":"true","aria-label":A(ze==="img"?"reader.images":"reader.fontSize"),onKeyDown:D=>{if(D.key==="Escape"){D.stopPropagation(),X();return}D.key==="Tab"&&us(D,ve.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:A(ze==="img"?"reader.images":"reader.fontSize")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.close"),onClick:X,children:"✕"})]}),ze==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(oo,{pages:d??null,loading:c,renderOverlay:p})}):t.jsxs("div",{className:"bim-rd-sheet-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.fontSmaller"),disabled:Te<=wt[0],onClick:()=>h({fontSize:Gn(m.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[Te,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.fontLarger"),disabled:Te>=wt[wt.length-1],onClick:()=>h({fontSize:Gn(m.fontSize,1)}),children:"A+"})]})]})]})]})}const gl=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],hm={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function Ze(e){return hm[e]??e}const rn=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],sn={熹平: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 gi(e){const n=e.match(/^\s*(\d{3,4})(?:\s*[-–—~至]\s*(\d{3,4}))?/);if(!n)return;const o=parseInt(n[1],10);if(o<100||o>2100)return;const r=n[2]?parseInt(n[2],10):void 0;return{from:o,to:r!=null&&r>=o&&r<=2100?r:void 0}}function gm(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 fm=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,hs={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function Oo(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(hs))if(n.startsWith(s))return hs[s];const o=Ze(n);if(Ht[o]!=null)return o;const r=_t(n);if(r&&n.length<=r.length+1)return Ze(r)}function Ot(e,n){if(n){const o=fl[`${n}|${e}`];if(o!=null)return o}return sn[e]}const xm=1911;function bm(e){const n=sn[e];if(n==null)return;const o=jt[e];let r;for(const[s,a]of Object.entries(sn))jt[s]===o&&a>n&&(r==null||a<r)&&(r=a);return r!=null?r-1:void 0}const ym={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function ni(e){if(!e)return;if(/^\d+$/.test(e))return parseInt(e,10);let n=0,o=0,r=!1;for(const a of e){const l=ym[a];if(l===void 0)return;r=!0,a==="十"?o=(o||1)*10:a==="廿"||a==="卅"?(n+=l,o=0):o>=10?(n+=o+l,o=0):o=o*10+l}const s=n+o;return r&&s>0?s:void 0}function _t(e){for(const n of gl)if(e.startsWith(n))return n}const jt={};{const e=(n,o)=>{for(const r of o)jt[r]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function Ft(e,n){const o=n==="北宋"||n==="南宋"?"宋":n;for(const r of Object.keys(sn))if(e.includes(r)&&!(o&&jt[r]&&jt[r]!==o&&fl[`${o}|${r}`]==null))return r}function In(e){var l,d,c;const n={era:"",reign:"",source:"none"},o=e.dating;if(o!=null&&o.era||o!=null&&o.reign)return{era:o.era??"",reign:o.reign??"",source:o.certainty==="attested"?"catalog":"edition"};const r=(l=e.lineage)==null?void 0:l.year_text;if(r){const p=_t(r)??"";return{era:Ze(p),reign:Ft(r,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=gi(s);if(p)return{era:gm(p.from),reign:"",source:"publication"};const u=_t(s)??Oo(s)??((c=rn.find(f=>f.pattern.test(s)))==null?void 0:c.era)??"",m=Ft(s,u)??"",h=u||(m?jt[m]??"":"");if(h||m)return{era:Ze(h),reign:m,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=_t(a);if(p)return{era:Ze(p),reign:Ft(a,p)??"",source:"edition"};const u=rn.find(m=>m.pattern.test(a));if(u)return{era:Ze(u.era),reign:Ft(a,u.era)??u.reign??"",source:"edition"}}return n}function fi(e){var r,s,a,l,d,c,p,u,m;if(((r=e.dating)==null?void 0:r.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 h=gi(n);if(h)return h.from}const o=[(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 h of o){const f=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(f&&h!==f&&(_t(f)||Oo(f)))break;const x=h.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??h.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(x){const j=parseInt(x[1],10);if(j>=100&&j<=2100)return j}const k=h.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(k){const j=_t(h);if(!j||Ze(j)==="民國"){const v=ni(k[1]);if(v!=null&&v>=1&&v<=120)return xm+v}}const y=_t(h)??((u=rn.find(j=>j.pattern.test(h)))==null?void 0:u.era),w=y?Ze(y):void 0,b=Ft(h,w)??(_t(h)||(m=rn.find(j=>j.pattern.test(h)))==null?void 0:m.reign);if(b){const j=Ot(b,w);if(j==null)continue;const S=h.indexOf(b),v=S>=0?h.slice(S+b.length):"",$=v.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??v.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),_=$?ni($[1]):void 0;return j+(_?_-1:0)}}}function Ho(e){var l,d,c,p,u,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 o=(d=e.lineage)==null?void 0:d.year_range;if(o&&o.length===2)return{from:o[0],to:o[1]};const r=(c=e.lineage)==null?void 0:c.year_text;if(r){const h=r.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(h){const f=ao[Ze(h[1])],x=Ht[Ze(h[2])];if(f!=null&&x!=null)return{from:Math.min(f,x)-20,to:Math.max(f,x)+40}}}const s=(p=e.publication_info)==null?void 0:p.year;if(s){const h=gi(s);if((h==null?void 0:h.to)!=null)return{from:h.from,to:h.to};const f=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(f){const x=ao[Ze(f[1])],k=Ht[Ze(f[2])];if(x!=null&&k!=null)return{from:Math.min(x,k)-20,to:Math.max(x,k)+40}}}const a=[(u=e.publication_info)==null?void 0:u.year,e.edition,e.title].filter(Boolean);for(const h of a){if(!/[間间]/.test(h))continue;const f=_t(h)??Oo(h)??((m=rn.find(y=>y.pattern.test(h)))==null?void 0:m.era),x=f?Ze(f):void 0,k=[];for(const y of Object.keys(sn))h.includes(y)&&(x&&jt[y]&&jt[y]!==x||Ot(y,x)!=null&&k.push(y));if(k.length===0){const y=h.match(/([一-鿿])([一-鿿])[間间]/);if(y&&x){for(const w of[y[1],y[2]])for(const b of Object.keys(sn))if(jt[b]===x&&!(b[0]!==w&&b[b.length-1]!==w)&&Ot(b,x)!=null){k.push(b);break}}}if(k.length>0){const y=k.map(S=>Ot(S,x)).filter(S=>S!=null),w=Math.min(...y),b=k.reduce((S,v)=>Ot(S,x)>=Ot(v,x)?S:v),j=bm(b)??Di(x??"")??Math.max(...y);return{from:w,to:j>w?j:Di(x??jt[b]??"")??w}}if(x&&Ht[x]!=null)return{from:Ht[x],to:Di(x)??Ht[x]}}}const Ht={漢:-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=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,gs=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function fs(e,n){for(const o of gl){const r=e.indexOf(o);if(r<0)continue;if(o.length===1){const c=e[r+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!Ft(e.slice(r),Ze(o)))continue}const s=Ze(o);if(s===n)continue;const a=e.slice(r),l=Ft(a,s)??"";let d;if(l){const c=Ot(l,s);if(c!=null){const u=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),m=u?ni(u[1]):void 0;d=c+(m?m-1:0)}}return{era:s,reign:l,year:d}}for(const o of rn)if(o.pattern.test(e))return{era:Ze(o.era),reign:o.reign??""}}function km(e){var w,b,j,S,v;const n=In(e),o=((w=e.publication_info)==null?void 0:w.year)??"",r=o?gi(o):void 0;if(!n.era&&!n.reign&&!r)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"&&fm.test(o),p=n.source==="publication"&&/[間间]/.test(o),u=l.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let m;a||d||c||p?m=void 0:u?m=parseInt(u[2],10):m=fi(e);const h=m==null?Ho(e):void 0;let f;n.source==="publication"&&(c||gs.test(o))?f="uncertain":n.source==="lineage"||n.source==="publication"?f="attested":gs.test(s)||!n.reign&&m==null?f="uncertain":f="inferred";const x=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((j=e.lineage)==null?void 0:j.year_text)??((S=e.lineage)==null?void 0:S.year)??""}」`:`出版著錄「${((v=e.publication_info)==null?void 0:v.year)??""}」`,k={era:n.era,reign:n.reign,year:m,yearRange:h,certainty:f,source:n.source==="edition"?"edition":"catalog",basis:x};if(u){const $=l.match(/[、,,]\s*([宋元明清])/);$&&$[1]!==k.era&&(k.laterRepair={era:$[1]})}if(!k.laterRepair&&vm.test(s)){const $=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);$&&$[1]!==n.era&&(k.laterRepair={era:$[1]})}const y=jm.find($=>$.re.test(s));if(y){const $=s.search(y.re),_=s.slice($),C=fs(_,n.era)??fs(s,n.era);C&&(k.basedOn={era:C.era,reign:C.reign,year:C.year,relation:y.relation})}return k}const ao={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function Di(e){return ao[e]}function ii(e){const n=fi(e);if(n!=null)return n;const o=Ho(e);if(o)return o.from;const r=In(e).era;return r?Ht[r]:void 0}const xs=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function lo(e){const n=xs.indexOf(e);return n===-1?xs.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 o=[],r=(s,a)=>{n[s].length&&o.push({key:s,labelKey:a,items:n[s]})};return r("belongsTo","belongsToWork"),r("collected","collectedIn"),r("contains","containedWorks"),r("derivative","derivativeWorks"),r("studies","studies"),r("related","relatedWorks"),o}function Fo(e,n){const o=zo(e||[]),r=new Map,s=[];for(const p of o)p.group?(r.has(p.group)||r.set(p.group,[]),r.get(p.group).push(p)):s.push(p);for(const p of r.values())p.sort((u,m)=>{const h=f=>f.group_role==="origin"?0:f.group_role==="mirror"?1:2;return h(u)-h(m)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const u=Gt(p),m=u.includes("text"),h=u.includes("image");m&&h?a.textImage.push(p):m?a.text.push(p):h?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=[...r.entries()].map(([p,u])=>{var m,h;return{key:p,label:((m=n==null?void 0:n[p])==null?void 0:m.label)||p,description:(h=n==null?void 0:n[p])==null?void 0:h.description,items:u}});return{buckets:d,mirrors:c,total:o.length}}function xi(e,n=cn("zh-Hant")){const o=[],r=e.metadata||{};r.edition&&o.push(String(r.edition)),e.source_label&&o.push(e.source_label),e.details&&o.push(e.details);const s=ci(e);return s&&s.expected>0&&o.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})),r.version&&o.push(String(r.version)),o.join(" · ")}function xl(e,n){if(xi(e)||n.filter(r=>r.name===e.name).length<2)return"";try{const r=new URL(e.url),s=r.searchParams.get("res")||r.searchParams.get("id");if(s)return s;const a=r.pathname.split("/").filter(Boolean).pop();if(a)return decodeURIComponent(a)}catch{}return""}function bl(e,n){var a,l;const o=e.resources||[],r=[],s=[];for(const d of o){const c=Gt(d);c.includes("image")&&r.push(d),c.includes("physical")&&s.push(d)}return{id:e.id,name:e.edition||e.title||e.id,era:In(e),year:fi(e),sortYear:ii(e),images:r,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,important:Sm(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:r.length>0}}function Sm(e,n){var d,c;if(!n)return!1;const o=n.default_collection;if(!o)return!1;const r=(d=n.collections)==null?void 0:d[o];if(((r==null?void 0:r.book_ids)??(o==="core"?n.core_books??[]:[])).includes(e))return!0;const a=(r==null?void 0:r.groups)??[],l=(c=n.node_groups)==null?void 0:c[e];return!!l&&a.includes(l)}function yl(e,n,o={}){const r=new Set((n==null?void 0:n.excluded_books)??[]),s=e.filter(c=>!r.has(c.id)).map(c=>bl(c,n));let a=s;o.era&&(a=a.filter(c=>c.era.era===o.era)),o.scanOnly&&(a=a.filter(c=>c.hasImage)),o.sort==="year"?a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const u=c.r.sortYear,m=p.r.sortYear;return u!=null&&m!=null?u-m||c.i-p.i:u!=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 u=m=>(m.important?0:1)*2+(m.hasImage?0:1);return u(c.r)-u(p.r)||c.i-p.i}).map(c=>c.r);const d=[...new Set(s.map(c=>c.era.era).filter(Boolean))].sort((c,p)=>lo(c)-lo(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function _m(e,n){var y,w;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const o=(y=n.collections)==null?void 0:y[n.default_collection],r=(o==null?void 0:o.groups)??[],s=(o==null?void 0:o.book_ids)??[],a=r.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(r),c=new Set([...s,...l]),p=b=>{if(c.has(b))return!0;const j=n.node_groups[b];return j!=null&&d.has(j)},u=[],m=new Map,h=[];for(const b of e)if(!((w=n.excluded_books)!=null&&w.includes(b)))if(p(b))u.push(b);else{const j=n.node_groups[b];j?(m.has(j)||m.set(j,[]),m.get(j).push(b)):h.push(b)}if(h.length+[...m.values()].reduce((b,j)=>b+j.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const x=new Map((n.groups??[]).map(b=>[b.id,b])),k=[...m.entries()].map(([b,j])=>{const S=x.get(b);return{id:b,label:(S==null?void 0:S.label)??b,description:S==null?void 0:S.description,ids:j}});return h.length>0&&k.push({id:"__other__",label:"其他版本",description:void 0,ids:h}),{useGrouping:!0,coreIds:u,groupedIds:k}}const jl=["撰","編","注","校","譯","繪","其他"],$m=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function Do(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n||n==="author")return"撰";for(const{cls:o,re:r}of $m)if(r.test(n))return o;return"其他"}function Uo(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function vl(e,n="全部"){const o=new Map;for(const s of e){const a=Do(s);o.set(a,(o.get(a)??0)+1)}const r=[{cls:"全部",label:n,count:e.length}];for(const s of jl){const a=o.get(s);a&&r.push({cls:s,label:s,count:a})}return r.length>2?r:[]}function kl(e,n,o){if(n&&n.books&&n.books.length>0){const s=n.books.map(l=>({id:l.work_id||l.book_id||void 0,title:l.title,section:l.section,volumes:l.volumes||[],subItems:l.sub_items,edition:l.edition,found:l.found_volumes,expected:l.expected_volumes})),a=[...new Set(s.map(l=>l.section).filter(Boolean))];return{rows:s,source:"catalog",sections:a,totalVolumes:n.total_volumes}}return e.contained_works&&e.contained_works.length>0?{rows:e.contained_works.map(a=>({id:a.id,title:a.title,volumes:zn(a.volume_index)})),source:"works",sections:[]}:{rows:(e.books||[]).map(s=>{var a,l;return{id:s,title:((a=o==null?void 0:o.get(s))==null?void 0:a.title)||s,edition:(l=o==null?void 0:o.get(s))==null?void 0:l.edition,volumes:[]}}),source:"books",sections:[]}}function zn(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[o,r]=[parseInt(n[1]),parseInt(n[2])];return Array.from({length:Math.max(0,r-o+1)},(s,a)=>o+a)}return e.split(/[,、]/).map(o=>parseInt(o.trim())).filter(o=>!isNaN(o))}return[]}function bi(e,n="冊"){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const o=[...e].sort((a,l)=>a-l),r=o[0],s=o[o.length-1];return s-r+1===o.length?`${r}–${s}`:o.length<=3?o.join(", "):`${r}–${s} (${o.length}${n})`}const Cm=["〇","一","二","三","四","五","六","七","八","九"],bs=["","十","百","千"];function wl(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),o=n.length;let r="",s=!1;for(let a=0;a<o;a++){const l=parseInt(n[a]),d=o-1-a;l===0?s=!0:(s&&r&&(r+="〇"),s=!1,l===1&&d===1&&a===0?r+=bs[d]:r+=Cm[l]+bs[d])}return r}function zm(e){return e==null?"":typeof e=="string"?e:e.title??""}function Ct(e,n="卷"){var r,s;const o=e;return o.measure_info?o.measure_info:(r=o.juan_count)!=null&&r.number?wl(o.juan_count.number)+n:(s=o.juan_count)!=null&&s.description?o.juan_count.description:""}function Sl(e){var r;if(e.edition_type)return e.edition_type;if((r=e.lineage)!=null&&r.category)return e.lineage.category;const n=e.edition||e.title||"",o=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,a]of o)if(s.test(n))return a;return""}const Tm=216,ys="clamp(280px, 23vw, 360px)",Nm=1440,co="(max-width: 719px)",Em=`${co}, (pointer: coarse)`,Im=`
|
|
639
|
-
.bim-d-main.bim-d-main-grid { max-width: ${
|
|
637
|
+
`;function Ho(e,n){var o;return n?e.key===n?!0:!!((o=e.children)!=null&&o.some(r=>Ho(r,n))):!1}const am=()=>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 lm({item:e,activeKey:n,onSelect:o,tabKey:r}){const s=Ho(e,n),[a,l]=g.useState(s||!!e.defaultExpanded);return g.useEffect(()=>{s&&l(!0)},[s]),g.useEffect(()=>{e.defaultExpanded&&l(!0)},[e.defaultExpanded]),t.jsxs("li",{children:[t.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":a,"data-rd-toc-key":e.key,tabIndex:r===e.key?0:-1,onClick:()=>l(d=>!d),children:[t.jsx(am,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),a&&t.jsx(ul,{items:e.children,activeKey:n,onSelect:o,tabKey:r})]})}function ul({items:e,activeKey:n,onSelect:o,tabKey:r}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(lm,{item:s,activeKey:n,onSelect:o,tabKey:r},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:r===s.key?0:-1,onClick:()=>o(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 ms(e,n){var o;for(const r of e)if(r.key===n||Ho(r,n))return r.key;return((o=e[0])==null?void 0:o.key)??null}function ml({items:e,activeKey:n,onSelect:o,label:r}){const{t:s}=Q(),a=r??s("reader.toc"),l=g.useRef(null),[d,c]=g.useState(null);g.useEffect(()=>{c(null)},[n]);const p=g.useMemo(()=>d||(n??ms(e,n)),[d,n,e]);g.useEffect(()=>{const m=l.current;if(!m)return;const h=Array.from(m.querySelectorAll("[data-rd-toc-key]"));if(h.length===0)return;const f=h.find(x=>x.dataset.rdTocKey===p)??h.find(x=>x.dataset.rdTocKey===ms(e,n))??h.find(x=>!x.disabled)??h[0];for(const x of h)x.tabIndex=x===f?0:-1}),g.useEffect(()=>{const m=l.current,h=m==null?void 0:m.closest(".bim-rd-toc");if(!m||!h||!n)return;const f=Array.from(m.querySelectorAll("[data-rd-toc-key]")).find(k=>k.dataset.rdTocKey===n);if(!f)return;const x=f.getBoundingClientRect().top-h.getBoundingClientRect().top+h.scrollTop;(x<h.scrollTop+80||x>h.scrollTop+h.clientHeight-40)&&(h.scrollTop=Math.max(0,x-h.clientHeight/3))},[n]);const u=g.useCallback(m=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(m.key))return;const f=l.current;if(!f)return;const x=Array.from(f.querySelectorAll("[data-rd-toc-key]")).filter(b=>!b.disabled),k=x.indexOf(document.activeElement);let y=k;if(m.key==="ArrowDown"?y=Math.min(x.length-1,k+1):m.key==="ArrowUp"?y=Math.max(0,k-1):m.key==="Home"?y=0:m.key==="End"&&(y=x.length-1),y<0||y===k)return;m.preventDefault();const w=x[y];for(const b of x)b.tabIndex=-1;w.tabIndex=0,w.focus(),c(w.dataset.rdTocKey??null)},[]);return t.jsx("div",{ref:l,role:"navigation","aria-label":a,onKeyDown:u,children:t.jsx(ul,{items:e,activeKey:n,onSelect:o,tabKey:p})})}function cm({page:e}){var n;return!((n=e.boxes)!=null&&n.length)||!e.width||!e.height||e.boxFormat&&e.boxFormat!=="bim-charbox-v0"?null:t.jsx("svg",{viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:e.boxes.map((o,r)=>t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:"none",stroke:i("accent"),strokeOpacity:.55,vectorEffect:"non-scaling-stroke",strokeWidth:1},r))})}function ao({pages:e,loading:n,page:o,onPageChange:r,renderOverlay:s}){const{t:a}=Q(),[l,d]=g.useState(0),c=o??l,p=f=>{r?r(f):d(f)};if(g.useEffect(()=>{o===void 0&&d(0)},[e,o]),n)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsx("div",{className:"bim-rd-img-empty",children:a("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:a("reader.noImages")}),t.jsx("span",{children:a("reader.noImagesHint")})]})});const u=Math.max(0,Math.min(e.length-1,c)),m=e[u],h=m.label??`${u+1}`;return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-img-box",children:t.jsxs("figure",{className:"bim-rd-img-fig",children:[t.jsx("img",{src:m.url,alt:m.alt??a("reader.imageAlt",{label:h}),width:m.width,height:m.height,loading:"lazy",decoding:"async"}),t.jsx(cm,{page:m}),s==null?void 0:s(m,u)]})}),e.length>1&&t.jsxs("div",{className:"bim-rd-img-pager",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":a("reader.prevImage"),disabled:u===0,onClick:()=>p(u-1),children:"‹"}),t.jsx("span",{"aria-live":"polite",children:m.label??`${u+1} / ${e.length}`}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":a("reader.nextImage"),disabled:u===e.length-1,onClick:()=>p(u+1),children:"›"})]})]})}const Fo={fontSize:null,readingMode:"line",properNames:!1,writingMode:"horizontal",workLinks:!0},St=[15,16,17,18,20,22,24],lo=18,hl="bim-reader-prefs",dm="bim-reading-mode";function pm(){const e={...Fo};try{const n=localStorage.getItem(hl),o=n?JSON.parse(n):{};typeof o.fontSize=="number"&&St.includes(o.fontSize)&&(e.fontSize=o.fontSize),(o.readingMode??localStorage.getItem(dm))==="paragraph"&&(e.readingMode="paragraph"),o.properNames===!0&&(e.properNames=!0),o.writingMode==="vertical"&&(e.writingMode="vertical"),o.workLinks===!1&&(e.workLinks=!1)}catch{}return e}function um(e){try{localStorage.setItem(hl,JSON.stringify(e))}catch{}}function Kn(e,n){const o=e??lo,r=St;let s=r.indexOf(o);return s<0&&(s=r.indexOf(lo)),r[Math.max(0,Math.min(r.length-1,s+n))]}function gl(){const[e,n]=g.useState(Fo);g.useEffect(()=>{n(pm())},[]);const o=g.useCallback(r=>{n(s=>{const a={...s,...r};return um(a),a})},[]);return[e,o]}function co(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 fl(e,n){if(!(!e||e.length===0))return(n!=null?e.find(o=>o.key===n):void 0)??e.find(o=>o.primary)??e[0]}function xl(e){const n=[],o=r=>{for(const s of r)s.children&&s.children.length>0?o(s.children):n.push(s)};return o(e),n}const hs=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:t.jsx("path",{d:"M4 6h16M4 12h10M4 18h16"})}),mm=()=>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"})}),hm=()=>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"})}),gs=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"4",y:"3",width:"16",height:"18",rx:"1.5"}),t.jsx("path",{d:"M9 3v18M13 7v10M16.5 7v10"})]});function fs(e,n){if(!n)return;const o=Array.from(n.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(l=>l.tabIndex>=0);if(o.length===0)return;const r=o[0],s=o[o.length-1],a=document.activeElement;e.shiftKey&&(a===r||!n.contains(a))?(e.preventDefault(),s.focus()):!e.shiftKey&&(a===s||!n.contains(a))&&(e.preventDefault(),r.focus())}function xs(e,n){const[o,r]=g.useState(n);return g.useEffect(()=>{var l;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(e);r(s.matches);const a=()=>r(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]),o}function gm(){const e=g.useContext(Gt),{t:n}=Q();if(!e)return null;const o=e.locale==="zh-Hant";return t.jsxs("button",{type:"button",className:"bim-rd-t",title:n(o?"common.toHans":"common.toHant"),"aria-label":n(o?"common.toHans":"common.toHant"),onClick:()=>e.setLocale(o?"zh-Hans":"zh-Hant"),children:[t.jsx("span",{className:o?"bim-rd-on":"bim-rd-off",children:n("common.localeShortHant")}),t.jsx("span",{className:"bim-rd-off",children:"|"}),t.jsx("span",{className:o?"bim-rd-off":"bim-rd-on",children:n("common.localeShortHans")})]})}function fm(e,n){if(!e)return;let o;for(const r of Array.from(e.querySelectorAll('[id^="rd-e-"]')))if(r.getBoundingClientRect().top<=n+8)o=r.id;else break;return o}function xm(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 o=e.querySelector(".bim-rd-col"),r=l=>{const d=(l==null?void 0:l.nodeType)===1?l:l==null?void 0:l.parentElement;return!!l&&!!(o!=null&&o.contains(l))&&!(d!=null&&d.closest(".bim-rd-src, .bim-rd-pager"))};if(!r(n.anchorNode)||!r(n.focusNode))return;const s=n.toString().replace(/\s+/g," ").trim();return s?s.slice(0,500):void 0}function bl({title:e,subtitle:n,toc:o,activeKey:r,onSelect:s,tocHeader:a,tocCaption:l,images:d,imagesLoading:c,renderImageOverlay:p,imagePanel:u="auto",prefs:m,onPrefsChange:h,paragraphToggle:f,properNameToggle:x=!0,allowVertical:k,byline:y,current:w,workLinkToggle:b,rail:j,onReportError:S,revisedAt:v,backHref:$,backLabel:_,bottomBar:C=!0,pager:M=!0,pagerUnit:T,versions:z,currentVersionKey:F,onVersionChange:N,versionSource:R=!0,keepChapterOnVersionChange:O=!1,customImagePanel:I,toolbarExtra:P,isWarpMode:U,children:K,className:L,style:Z}){const{t:A,convert:V}=Q(),pe=_??A("reader.back"),ee=V(T??A("reader.unitJuan")),ue=g.useId().replace(/:/g,""),me=`bim-rd-toc-${ue}`,be=`bim-rd-text-${ue}`,Oe=g.useRef(null),ie=g.useRef(null),Re=g.useRef(null),Le=g.useRef(null),q=xs(ll,!0),J=xs(dl,!1),fe=C&&J,[ze,Y]=g.useState(null),ve=g.useRef(null),le=g.useRef(null),Se=(D,re)=>{le.current=re,Y(Pe=>Pe===D?null:D)},X=g.useCallback(()=>{var D;Y(null),(D=le.current)==null||D.focus()},[]);g.useEffect(()=>{fe||Y(null)},[fe]),g.useEffect(()=>{var D,re;ze&&((re=(D=ve.current)==null?void 0:D.querySelector("button:not([disabled])"))==null||re.focus())},[ze]);const[Ce,Me]=g.useState("auto"),B=Ce==="auto"?q:Ce==="open",te=!q,ye=!!I||!!d&&d.length>0,[H,se]=g.useState(u);g.useEffect(()=>{se(u)},[u]);const ne=H==="auto"?ye||!!c:H==="open",ge=g.useCallback(D=>{var re;Me("auto"),D&&((re=Le.current)==null||re.focus())},[]),Ne=()=>Me(B?"closed":"open");g.useEffect(()=>{if(!te||Ce!=="open")return;const D=Re.current,re=D==null?void 0:D.querySelector('input, [data-rd-toc-key][tabindex="0"]');re==null||re.focus()},[te,Ce]);const Be=g.useCallback(D=>{s(D),te&&ge(!1);const re=ie.current,Pe=Oe.current;if(re&&Pe&&typeof window<"u"){const _e=re.getBoundingClientRect().top-Pe.getBoundingClientRect().bottom;_e<0&&window.scrollBy({top:_e})}},[s,te,ge]),We=g.useMemo(()=>xl(o),[o]),[Ue,Qe]=g.useState(null),ce=fl(z,F!==void 0?F:Ue),tt=(ce==null?void 0:ce.key)??null,E=g.useMemo(()=>We.map(D=>D.key).join(`
|
|
638
|
+
`),[We]),oe=g.useRef(null),ae=D=>{D!==tt&&(O||(oe.current={key:D,sig:E,done:!1}),F===void 0&&Qe(D),N==null||N(D))};g.useEffect(()=>{const D=oe.current;if(!D||D.key!==tt)return;const re=We.find(_e=>!_e.disabled);if(!re)return;const Pe=E!==D.sig;!Pe&&D.done||(Pe?oe.current=null:D.done=!0,re.key!==r&&Be(re.key))},[tt,E,We,r,Be]);const je=We.find(D=>D.key===r),ke=()=>{var D;S==null||S({chapterKey:r,chapterLabel:typeof(je==null?void 0:je.label)=="string"?je.label:void 0,anchor:fm(ie.current,((D=Oe.current)==null?void 0:D.getBoundingClientRect().bottom)??0),selectedText:xm(ie.current)})},xe=We.findIndex(D=>D.key===r),G=xe>0?We.slice(0,xe).reverse().find(D=>!D.disabled):void 0,de=xe>=0?We.slice(xe+1).find(D=>!D.disabled):void 0,Te=m.fontSize??lo,Ee={...Z,...m.fontSize?{"--bimrd-fs":`${m.fontSize}px`}:null};return t.jsxs("div",{className:["bim-rd",m.writingMode==="vertical"&&k?"bim-rd-vertical":"",L].filter(Boolean).join(" "),"data-toc":Ce,"data-img":ne?"open":"closed","data-bb":fe?"":void 0,"data-warp":U?"true":void 0,style:Ee,children:[t.jsx("style",{children:pl}),t.jsx("a",{className:"bim-rd-skip",href:`#${be}`,onClick:D=>{var re,Pe,_e;D.preventDefault(),(re=ie.current)==null||re.focus(),(_e=(Pe=ie.current)==null?void 0:Pe.scrollIntoView)==null||_e.call(Pe,{block:"start"})},children:A("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:Oe,children:[$&&t.jsxs("a",{className:"bim-rd-back",href:$,"aria-label":A("reader.backAria",{label:pe}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:pe})]}),(e||n||y||w)&&t.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[e&&t.jsx("b",{children:e}),y&&t.jsx("span",{className:"bim-rd-by",children:y}),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",{children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":A("reader.settings"),children:[z&&z.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:ce?V(co(ce)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:A("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:A("reader.versionShort")}),t.jsx("select",{"aria-label":A("reader.version"),value:tt??"",onChange:D=>ae(D.target.value),children:z.map(D=>t.jsx("option",{value:D.key,children:V(co(D))},D.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),M&&(G||de)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":A("reader.pagerGroup",{unit:ee}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.prevUnit",{unit:ee}),title:G?typeof G.label=="string"&&G.label?A("reader.prevUnitTitle",{unit:ee,label:G.label}):A("reader.prevUnit",{unit:ee}):A("reader.firstUnit",{unit:ee}),disabled:!G,onClick:()=>G&&Be(G.key),children:t.jsx(mm,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.nextUnit",{unit:ee}),title:de?typeof de.label=="string"&&de.label?A("reader.nextUnitTitle",{unit:ee,label:de.label}):A("reader.nextUnit",{unit:ee}):A("reader.lastUnit",{unit:ee}),disabled:!de,onClick:()=>de&&Be(de.key),children:t.jsx(hm,{})})]}),M&&(G||de)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:Le,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":B,"aria-controls":me,onClick:Ne,children:[t.jsx(hs,{}),t.jsx("span",{className:"bim-rd-tlabel",children:A("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":ne,onClick:()=>se(ne?"closed":"open"),children:[t.jsx(gs,{}),A("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(gm,{}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":A("reader.fontSmaller"),disabled:Te<=St[0],onClick:()=>h({fontSize:Kn(m.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":A("reader.fontLarger"),disabled:Te>=St[St.length-1],onClick:()=>h({fontSize:Kn(m.fontSize,1)}),children:"A+"}),(f||x||k)&&t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),f&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":m.readingMode==="paragraph",title:A("reader.paragraphTitle"),onClick:()=>h({readingMode:m.readingMode==="paragraph"?"line":"paragraph"}),children:A("reader.paragraph")}),b&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk",children:[t.jsx("input",{type:"checkbox",checked:m.workLinks,onChange:D=>h({workLinks:D.target.checked})}),t.jsx("span",{children:A("reader.workLinks")})]}),x&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":m.properNames,title:A("reader.properNameTitle"),onClick:()=>h({properNames:!m.properNames}),children:A("reader.properName")}),k&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":m.writingMode==="vertical",onClick:()=>h({writingMode:m.writingMode==="vertical"?"horizontal":"vertical"}),children:A("reader.vertical")}),P]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:me,ref:Re,role:te&&B?"dialog":void 0,"aria-modal":te&&B?!0:void 0,"aria-label":te&&B?A("reader.toc"):void 0,onKeyDown:D=>{if(!(!te||!B)){if(D.key==="Escape"){D.stopPropagation(),ge(!0);return}D.key==="Tab"&&fs(D,Re.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:l??A("reader.toc")}),te&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.closeToc"),onClick:()=>ge(!0),children:"✕"})]}),a]}),t.jsx(ml,{items:o,activeKey:r,onSelect:Be})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>ge(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":A("reader.images"),children:ne&&(I||t.jsx(ao,{pages:d??null,loading:c,renderOverlay:p}))}),t.jsxs("div",{className:"bim-rd-text",id:be,ref:ie,tabIndex:-1,"data-rail":(j||S)&&!U?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[K,R&&ce&&(ce.sourceName||ce.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":ce.key,children:[ce.sourceName&&t.jsxs(t.Fragment,{children:[A("reader.sourceLabel")," ",ce.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:ce.sourceUrl,target:"_blank",rel:"noreferrer",children:V(ce.sourceName)}):V(ce.sourceName)]}),ce.sourceName&&ce.license&&t.jsx("span",{className:"bim-rd-dot"}),ce.license&&t.jsx(t.Fragment,{children:A("reader.licenseOf",{license:ce.license})})]}),v&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:A("reader.revisedAt",{date:v})}),S&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:D=>D.preventDefault(),onClick:ke,children:A("reader.reportError")})}),M&&(G||de)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":A("reader.pagerNav"),children:[G?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>Be(G.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),A("reader.prevUnit",{unit:ee})]}),t.jsx("span",{className:"bim-rd-pglabel",children:G.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",A("reader.firstUnit",{unit:ee})]}),de?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>Be(de.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[A("reader.nextUnit",{unit:ee}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:de.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[A("reader.lastUnit",{unit:ee})," →"]})]})]}),(j||S)&&!U&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":A("reader.rail"),children:[j,S&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:D=>D.preventDefault(),onClick:ke,children:A("reader.reportError")})})]})]})]}),fe&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":A("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":B,"aria-controls":me,onClick:()=>{Y(null),Ne()},children:[t.jsx(hs,{}),t.jsx("span",{children:A("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":ze==="img","aria-haspopup":"dialog",onClick:D=>Se("img",D.currentTarget),children:[t.jsx(gs,{}),t.jsx("span",{children:A("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":ze==="fs","aria-haspopup":"dialog",onClick:D=>Se("fs",D.currentTarget),children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"A"}),t.jsx("span",{children:A("reader.fontSize")})]}),S&&t.jsxs("button",{type:"button",onMouseDown:D=>D.preventDefault(),onClick:()=>{Y(null),ke()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:A("reader.reportError")})]})]}),fe&&ze&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:X}),t.jsxs("div",{className:"bim-rd-sheet",ref:ve,role:"dialog","aria-modal":"true","aria-label":A(ze==="img"?"reader.images":"reader.fontSize"),onKeyDown:D=>{if(D.key==="Escape"){D.stopPropagation(),X();return}D.key==="Tab"&&fs(D,ve.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:A(ze==="img"?"reader.images":"reader.fontSize")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.close"),onClick:X,children:"✕"})]}),ze==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(ao,{pages:d??null,loading:c,renderOverlay:p})}):t.jsxs("div",{className:"bim-rd-sheet-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.fontSmaller"),disabled:Te<=St[0],onClick:()=>h({fontSize:Kn(m.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[Te,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.fontLarger"),disabled:Te>=St[St.length-1],onClick:()=>h({fontSize:Kn(m.fontSize,1)}),children:"A+"})]})]})]})]})}const yl=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],bm={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function Ze(e){return bm[e]??e}const rn=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],sn={熹平:172,建安:196,黃初:220,正始:240,廣政:938,太康:280,永和:345,開皇:581,貞觀:627,開元:713,天寶:742,貞元:785,元和:806,開成:836,會昌:841,咸通:860,建隆:960,太平興國:976,咸平:998,天禧:1017,慶曆:1041,皇祐:1049,嘉祐:1056,治平:1064,熙寧:1068,元豐:1078,元祐:1086,紹聖:1094,崇寧:1102,大觀:1107,政和:1111,宣和:1119,建炎:1127,紹興:1131,隆興:1163,乾道:1165,淳熙:1174,紹熙:1190,慶元:1195,嘉泰:1201,開禧:1205,嘉定:1208,寶慶:1225,紹定:1228,端平:1234,嘉熙:1237,淳祐:1241,寶祐:1253,開慶:1259,景定:1260,咸淳:1265,大定:1161,明昌:1190,至元:1264,大德:1297,皇慶:1312,延祐:1314,泰定:1324,天曆:1328,至順:1330,至正:1341,洪武:1368,永樂:1403,宣德:1426,正統:1436,景泰:1450,天順:1457,成化:1465,弘治:1488,正德:1506,嘉靖:1522,隆慶:1567,萬曆:1573,泰昌:1620,天啟:1621,崇禎:1628,弘光:1645,隆武:1645,紹武:1646,永曆:1647,順治:1644,康熙:1662,雍正:1723,乾隆:1736,嘉慶:1796,道光:1821,咸豐:1851,同治:1862,光緒:1875,宣統:1909,慶長:1596,寬永:1624,正保:1644,慶安:1648,承應:1652,明曆:1655,萬治:1658,寬文:1661,延寶:1673,天和:1681,貞享:1684,元祿:1688,寶永:1704,享保:1716,元文:1736,寬保:1741,延享:1744,寬延:1748,寶曆:1751,明和:1764,安永:1772,天明:1781,寬政:1789,享和:1801,文化:1804,文政:1818,天保:1830,弘化:1844,嘉永:1848,安政:1854,萬延:1860,文久:1861,元治:1864,慶應:1865,明治:1868,大正:1912,昭和:1926,天正:1573,文祿:1592,永祿:1558,天文:1532},jl={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function xi(e){const n=e.match(/^\s*(\d{3,4})(?:\s*[-–—~至]\s*(\d{3,4}))?/);if(!n)return;const o=parseInt(n[1],10);if(o<100||o>2100)return;const r=n[2]?parseInt(n[2],10):void 0;return{from:o,to:r!=null&&r>=o&&r<=2100?r:void 0}}function ym(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 jm=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,bs={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function Do(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(bs))if(n.startsWith(s))return bs[s];const o=Ze(n);if(Ot[o]!=null)return o;const r=$t(n);if(r&&n.length<=r.length+1)return Ze(r)}function Wt(e,n){if(n){const o=jl[`${n}|${e}`];if(o!=null)return o}return sn[e]}const vm=1911;function km(e){const n=sn[e];if(n==null)return;const o=vt[e];let r;for(const[s,a]of Object.entries(sn))vt[s]===o&&a>n&&(r==null||a<r)&&(r=a);return r!=null?r-1:void 0}const wm={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function oi(e){if(!e)return;if(/^\d+$/.test(e))return parseInt(e,10);let n=0,o=0,r=!1;for(const a of e){const l=wm[a];if(l===void 0)return;r=!0,a==="十"?o=(o||1)*10:a==="廿"||a==="卅"?(n+=l,o=0):o>=10?(n+=o+l,o=0):o=o*10+l}const s=n+o;return r&&s>0?s:void 0}function $t(e){for(const n of yl)if(e.startsWith(n))return n}const vt={};{const e=(n,o)=>{for(const r of o)vt[r]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function Ht(e,n){const o=n==="北宋"||n==="南宋"?"宋":n;for(const r of Object.keys(sn))if(e.includes(r)&&!(o&&vt[r]&&vt[r]!==o&&jl[`${o}|${r}`]==null))return r}function Rn(e){var l,d,c;const n={era:"",reign:"",source:"none"},o=e.dating;if(o!=null&&o.era||o!=null&&o.reign)return{era:o.era??"",reign:o.reign??"",source:o.certainty==="attested"?"catalog":"edition"};const r=(l=e.lineage)==null?void 0:l.year_text;if(r){const p=$t(r)??"";return{era:Ze(p),reign:Ht(r,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=xi(s);if(p)return{era:ym(p.from),reign:"",source:"publication"};const u=$t(s)??Do(s)??((c=rn.find(f=>f.pattern.test(s)))==null?void 0:c.era)??"",m=Ht(s,u)??"",h=u||(m?vt[m]??"":"");if(h||m)return{era:Ze(h),reign:m,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=$t(a);if(p)return{era:Ze(p),reign:Ht(a,p)??"",source:"edition"};const u=rn.find(m=>m.pattern.test(a));if(u)return{era:Ze(u.era),reign:Ht(a,u.era)??u.reign??"",source:"edition"}}return n}function bi(e){var r,s,a,l,d,c,p,u,m;if(((r=e.dating)==null?void 0:r.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 h=xi(n);if(h)return h.from}const o=[(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 h of o){const f=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(f&&h!==f&&($t(f)||Do(f)))break;const x=h.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??h.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(x){const j=parseInt(x[1],10);if(j>=100&&j<=2100)return j}const k=h.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(k){const j=$t(h);if(!j||Ze(j)==="民國"){const v=oi(k[1]);if(v!=null&&v>=1&&v<=120)return vm+v}}const y=$t(h)??((u=rn.find(j=>j.pattern.test(h)))==null?void 0:u.era),w=y?Ze(y):void 0,b=Ht(h,w)??($t(h)||(m=rn.find(j=>j.pattern.test(h)))==null?void 0:m.reign);if(b){const j=Wt(b,w);if(j==null)continue;const S=h.indexOf(b),v=S>=0?h.slice(S+b.length):"",$=v.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??v.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),_=$?oi($[1]):void 0;return j+(_?_-1:0)}}}function Uo(e){var l,d,c,p,u,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 o=(d=e.lineage)==null?void 0:d.year_range;if(o&&o.length===2)return{from:o[0],to:o[1]};const r=(c=e.lineage)==null?void 0:c.year_text;if(r){const h=r.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(h){const f=po[Ze(h[1])],x=Ot[Ze(h[2])];if(f!=null&&x!=null)return{from:Math.min(f,x)-20,to:Math.max(f,x)+40}}}const s=(p=e.publication_info)==null?void 0:p.year;if(s){const h=xi(s);if((h==null?void 0:h.to)!=null)return{from:h.from,to:h.to};const f=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(f){const x=po[Ze(f[1])],k=Ot[Ze(f[2])];if(x!=null&&k!=null)return{from:Math.min(x,k)-20,to:Math.max(x,k)+40}}}const a=[(u=e.publication_info)==null?void 0:u.year,e.edition,e.title].filter(Boolean);for(const h of a){if(!/[間间]/.test(h))continue;const f=$t(h)??Do(h)??((m=rn.find(y=>y.pattern.test(h)))==null?void 0:m.era),x=f?Ze(f):void 0,k=[];for(const y of Object.keys(sn))h.includes(y)&&(x&&vt[y]&&vt[y]!==x||Wt(y,x)!=null&&k.push(y));if(k.length===0){const y=h.match(/([一-鿿])([一-鿿])[間间]/);if(y&&x){for(const w of[y[1],y[2]])for(const b of Object.keys(sn))if(vt[b]===x&&!(b[0]!==w&&b[b.length-1]!==w)&&Wt(b,x)!=null){k.push(b);break}}}if(k.length>0){const y=k.map(S=>Wt(S,x)).filter(S=>S!=null),w=Math.min(...y),b=k.reduce((S,v)=>Wt(S,x)>=Wt(v,x)?S:v),j=km(b)??Gi(x??"")??Math.max(...y);return{from:w,to:j>w?j:Gi(x??vt[b]??"")??w}}if(x&&Ot[x]!=null)return{from:Ot[x],to:Gi(x)??Ot[x]}}}const Ot={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},Sm=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],_m=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,ys=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function js(e,n){for(const o of yl){const r=e.indexOf(o);if(r<0)continue;if(o.length===1){const c=e[r+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!Ht(e.slice(r),Ze(o)))continue}const s=Ze(o);if(s===n)continue;const a=e.slice(r),l=Ht(a,s)??"";let d;if(l){const c=Wt(l,s);if(c!=null){const u=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),m=u?oi(u[1]):void 0;d=c+(m?m-1:0)}}return{era:s,reign:l,year:d}}for(const o of rn)if(o.pattern.test(e))return{era:Ze(o.era),reign:o.reign??""}}function $m(e){var w,b,j,S,v;const n=Rn(e),o=((w=e.publication_info)==null?void 0:w.year)??"",r=o?xi(o):void 0;if(!n.era&&!n.reign&&!r)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"&&jm.test(o),p=n.source==="publication"&&/[間间]/.test(o),u=l.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let m;a||d||c||p?m=void 0:u?m=parseInt(u[2],10):m=bi(e);const h=m==null?Uo(e):void 0;let f;n.source==="publication"&&(c||ys.test(o))?f="uncertain":n.source==="lineage"||n.source==="publication"?f="attested":ys.test(s)||!n.reign&&m==null?f="uncertain":f="inferred";const x=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((j=e.lineage)==null?void 0:j.year_text)??((S=e.lineage)==null?void 0:S.year)??""}」`:`出版著錄「${((v=e.publication_info)==null?void 0:v.year)??""}」`,k={era:n.era,reign:n.reign,year:m,yearRange:h,certainty:f,source:n.source==="edition"?"edition":"catalog",basis:x};if(u){const $=l.match(/[、,,]\s*([宋元明清])/);$&&$[1]!==k.era&&(k.laterRepair={era:$[1]})}if(!k.laterRepair&&_m.test(s)){const $=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);$&&$[1]!==n.era&&(k.laterRepair={era:$[1]})}const y=Sm.find($=>$.re.test(s));if(y){const $=s.search(y.re),_=s.slice($),C=js(_,n.era)??js(s,n.era);C&&(k.basedOn={era:C.era,reign:C.reign,year:C.year,relation:y.relation})}return k}const po={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function Gi(e){return po[e]}function ri(e){const n=bi(e);if(n!=null)return n;const o=Uo(e);if(o)return o.from;const r=Rn(e).era;return r?Ot[r]:void 0}const vs=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function uo(e){const n=vs.indexOf(e);return n===-1?vs.length:n}function Cm(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 o=[],r=(s,a)=>{n[s].length&&o.push({key:s,labelKey:a,items:n[s]})};return r("belongsTo","belongsToWork"),r("collected","collectedIn"),r("contains","containedWorks"),r("derivative","derivativeWorks"),r("studies","studies"),r("related","relatedWorks"),o}function Vo(e,n){const o=Eo(e||[]),r=new Map,s=[];for(const p of o)p.group?(r.has(p.group)||r.set(p.group,[]),r.get(p.group).push(p)):s.push(p);for(const p of r.values())p.sort((u,m)=>{const h=f=>f.group_role==="origin"?0:f.group_role==="mirror"?1:2;return h(u)-h(m)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const u=Vt(p),m=u.includes("text"),h=u.includes("image");m&&h?a.textImage.push(p):m?a.text.push(p):h?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=[...r.entries()].map(([p,u])=>{var m,h;return{key:p,label:((m=n==null?void 0:n[p])==null?void 0:m.label)||p,description:(h=n==null?void 0:n[p])==null?void 0:h.description,items:u}});return{buckets:d,mirrors:c,total:o.length}}function yi(e,n=cn("zh-Hant")){const o=[],r=e.metadata||{};r.edition&&o.push(String(r.edition)),e.source_label&&o.push(e.source_label),e.details&&o.push(e.details);const s=pi(e);return s&&s.expected>0&&o.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})),r.version&&o.push(String(r.version)),o.join(" · ")}function vl(e,n){if(yi(e)||n.filter(r=>r.name===e.name).length<2)return"";try{const r=new URL(e.url),s=r.searchParams.get("res")||r.searchParams.get("id");if(s)return s;const a=r.pathname.split("/").filter(Boolean).pop();if(a)return decodeURIComponent(a)}catch{}return""}function kl(e,n){var a,l;const o=e.resources||[],r=[],s=[];for(const d of o){const c=Vt(d);c.includes("image")&&r.push(d),c.includes("physical")&&s.push(d)}return{id:e.id,name:e.edition||e.title||e.id,era:Rn(e),year:bi(e),sortYear:ri(e),images:r,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,important:zm(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:r.length>0}}function zm(e,n){var d,c;if(!n)return!1;const o=n.default_collection;if(!o)return!1;const r=(d=n.collections)==null?void 0:d[o];if(((r==null?void 0:r.book_ids)??(o==="core"?n.core_books??[]:[])).includes(e))return!0;const a=(r==null?void 0:r.groups)??[],l=(c=n.node_groups)==null?void 0:c[e];return!!l&&a.includes(l)}function wl(e,n,o={}){const r=new Set((n==null?void 0:n.excluded_books)??[]),s=e.filter(c=>!r.has(c.id)).map(c=>kl(c,n));let a=s;o.era&&(a=a.filter(c=>c.era.era===o.era)),o.scanOnly&&(a=a.filter(c=>c.hasImage)),o.sort==="year"?a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const u=c.r.sortYear,m=p.r.sortYear;return u!=null&&m!=null?u-m||c.i-p.i:u!=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 u=m=>(m.important?0:1)*2+(m.hasImage?0:1);return u(c.r)-u(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)=>uo(c)-uo(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function Tm(e,n){var y,w;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const o=(y=n.collections)==null?void 0:y[n.default_collection],r=(o==null?void 0:o.groups)??[],s=(o==null?void 0:o.book_ids)??[],a=r.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(r),c=new Set([...s,...l]),p=b=>{if(c.has(b))return!0;const j=n.node_groups[b];return j!=null&&d.has(j)},u=[],m=new Map,h=[];for(const b of e)if(!((w=n.excluded_books)!=null&&w.includes(b)))if(p(b))u.push(b);else{const j=n.node_groups[b];j?(m.has(j)||m.set(j,[]),m.get(j).push(b)):h.push(b)}if(h.length+[...m.values()].reduce((b,j)=>b+j.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const x=new Map((n.groups??[]).map(b=>[b.id,b])),k=[...m.entries()].map(([b,j])=>{const S=x.get(b);return{id:b,label:(S==null?void 0:S.label)??b,description:S==null?void 0:S.description,ids:j}});return h.length>0&&k.push({id:"__other__",label:"其他版本",description:void 0,ids:h}),{useGrouping:!0,coreIds:u,groupedIds:k}}const Sl=["撰","編","注","校","譯","繪","其他"],Nm=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function Go(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n||n==="author")return"撰";for(const{cls:o,re:r}of Nm)if(r.test(n))return o;return"其他"}function Yo(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function _l(e,n="全部"){const o=new Map;for(const s of e){const a=Go(s);o.set(a,(o.get(a)??0)+1)}const r=[{cls:"全部",label:n,count:e.length}];for(const s of Sl){const a=o.get(s);a&&r.push({cls:s,label:s,count:a})}return r.length>2?r:[]}function $l(e,n,o){if(n&&n.books&&n.books.length>0){const s=n.books.map(l=>({id:l.work_id||l.book_id||void 0,title:l.title,section:l.section,volumes:l.volumes||[],subItems:l.sub_items,edition:l.edition,found:l.found_volumes,expected:l.expected_volumes})),a=[...new Set(s.map(l=>l.section).filter(Boolean))];return{rows:s,source:"catalog",sections:a,totalVolumes:n.total_volumes}}return e.contained_works&&e.contained_works.length>0?{rows:e.contained_works.map(a=>({id:a.id,title:a.title,volumes:Tn(a.volume_index)})),source:"works",sections:[]}:{rows:(e.books||[]).map(s=>{var a,l;return{id:s,title:((a=o==null?void 0:o.get(s))==null?void 0:a.title)||s,edition:(l=o==null?void 0:o.get(s))==null?void 0:l.edition,volumes:[]}}),source:"books",sections:[]}}function Tn(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[o,r]=[parseInt(n[1]),parseInt(n[2])];return Array.from({length:Math.max(0,r-o+1)},(s,a)=>o+a)}return e.split(/[,、]/).map(o=>parseInt(o.trim())).filter(o=>!isNaN(o))}return[]}function ji(e,n="冊"){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const o=[...e].sort((a,l)=>a-l),r=o[0],s=o[o.length-1];return s-r+1===o.length?`${r}–${s}`:o.length<=3?o.join(", "):`${r}–${s} (${o.length}${n})`}const Em=["〇","一","二","三","四","五","六","七","八","九"],ks=["","十","百","千"];function Cl(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),o=n.length;let r="",s=!1;for(let a=0;a<o;a++){const l=parseInt(n[a]),d=o-1-a;l===0?s=!0:(s&&r&&(r+="〇"),s=!1,l===1&&d===1&&a===0?r+=ks[d]:r+=Em[l]+ks[d])}return r}function Im(e){return e==null?"":typeof e=="string"?e:e.title??""}function zt(e,n="卷"){var r,s;const o=e;return o.measure_info?o.measure_info:(r=o.juan_count)!=null&&r.number?Cl(o.juan_count.number)+n:(s=o.juan_count)!=null&&s.description?o.juan_count.description:""}function zl(e){var r;if(e.edition_type)return e.edition_type;if((r=e.lineage)!=null&&r.category)return e.lineage.category;const n=e.edition||e.title||"",o=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,a]of o)if(s.test(n))return a;return""}const Rm=216,ws="clamp(280px, 23vw, 360px)",Lm=1440,mo="(max-width: 719px)",Am=`${mo}, (pointer: coarse)`,Pm=`
|
|
639
|
+
.bim-d-main.bim-d-main-grid { max-width: ${Lm}px; padding: 16px 32px 0; }
|
|
640
640
|
.bim-d-grid {
|
|
641
641
|
display: grid;
|
|
642
|
-
grid-template-columns: ${
|
|
642
|
+
grid-template-columns: ${Rm}px minmax(0, 1fr) ${ws};
|
|
643
643
|
grid-template-rows: auto 1fr;
|
|
644
644
|
grid-template-areas: "rail main card" "rail main side";
|
|
645
645
|
column-gap: 32px; row-gap: 28px; align-items: start;
|
|
@@ -975,7 +975,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
975
975
|
.bim-d-side li .bim-d-meta { font-size: 12px; flex: none; }
|
|
976
976
|
|
|
977
977
|
/* 点击目标 ≥44px(Q5):触屏与窄屏 */
|
|
978
|
-
@media ${
|
|
978
|
+
@media ${Am} {
|
|
979
979
|
.bim-d-tab, .bim-d-check, .bim-d-more, .bim-d-rail-back,
|
|
980
980
|
.bim-d-card-foot summary, .bim-d-card-toggle, .bim-d-card details.bim-d-more-names summary,
|
|
981
981
|
.bim-d-tl summary, .bim-d-chap a { min-height: 44px; }
|
|
@@ -1013,7 +1013,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1013
1013
|
/* 中等宽度:左栏折到顶部一行 */
|
|
1014
1014
|
@media (max-width: 1100px) {
|
|
1015
1015
|
.bim-d-grid {
|
|
1016
|
-
grid-template-columns: minmax(0, 1fr) ${
|
|
1016
|
+
grid-template-columns: minmax(0, 1fr) ${ws};
|
|
1017
1017
|
grid-template-rows: auto auto 1fr;
|
|
1018
1018
|
grid-template-areas: "rail rail" "main card" "main side";
|
|
1019
1019
|
}
|
|
@@ -1027,7 +1027,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1027
1027
|
}
|
|
1028
1028
|
|
|
1029
1029
|
/* 手机:左栏收起,提要卡 → 正文 → 旁栏 */
|
|
1030
|
-
@media ${
|
|
1030
|
+
@media ${mo} {
|
|
1031
1031
|
.bim-d-main.bim-d-main-grid { padding: 8px 16px 0; }
|
|
1032
1032
|
.bim-d-grid {
|
|
1033
1033
|
grid-template-columns: minmax(0, 1fr);
|
|
@@ -1102,7 +1102,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1102
1102
|
:root[data-layout="boxed"] .bim-d-g-rail { border: ${i("fr-bd")}; background: ${i("fr-bg")}; padding: 14px 8px; }
|
|
1103
1103
|
:root[data-layout="boxed"] .bim-d-filters { border-bottom: 1px solid ${i("fr-tab-bd")}; }
|
|
1104
1104
|
:root[data-layout="boxed"] .bim-d-filters .bim-d-tab { margin-bottom: -1px; }
|
|
1105
|
-
@media ${
|
|
1105
|
+
@media ${mo} {
|
|
1106
1106
|
:root[data-layout="boxed"] .bim-d-card { padding: 16px; }
|
|
1107
1107
|
:root[data-layout="boxed"] .bim-d-g-rail { border: 0; background: transparent; padding: 0; }
|
|
1108
1108
|
}
|
|
@@ -1117,7 +1117,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1117
1117
|
: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 {
|
|
1118
1118
|
text-decoration-color: currentColor; text-decoration-thickness: 2px;
|
|
1119
1119
|
}
|
|
1120
|
-
`;function
|
|
1120
|
+
`;function Ln({railTop:e,back:n,up:o,nav:r,railLinks:s,main:a,card:l,side:d}){const{t:c,convert:p}=Q(),u=(r||[]).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}),o,u.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:u.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:h=>{h.metaKey||h.ctrlKey||(h.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 Tl({caption:e,children:n}){const{convert:o}=Q();return t.jsxs("div",{className:"bim-d-up bim-d-ui",children:[t.jsx("span",{className:"bim-d-up-cap",children:o(e)}),n]})}function et({id:e,title:n,meta:o,action:r,children:s}){const{convert:a}=Q();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)}),o!=null&&o!==""&&t.jsx("span",{className:"bim-d-meta",children:o}),r&&t.jsx("span",{className:"bim-d-sec-act",children:r})]}),t.jsx("div",{className:"bim-d-sec-body",children:s})]})}function Je({items:e,className:n,style:o}){const r=e.filter(s=>s!=null&&s!==""&&s!==!1);return r.length?t.jsx("span",{className:`bim-d-meta${n?` ${n}`:""}`,style:o,children:r.map((s,a)=>t.jsxs(g.Fragment,{children:[a>0&&t.jsx("span",{className:"bim-d-dot"}),t.jsx("span",{children:s})]},a))}):null}function vi({items:e,value:n,onChange:o}){const{convert:r}=Q();return t.jsx(t.Fragment,{children:e.map(s=>t.jsx("button",{type:"button",className:[...r(s.label)].length===1?"bim-d-tab bim-d-tab-1":"bim-d-tab","aria-pressed":s.key===n,onClick:()=>o(s.key),children:r(s.label)},s.key))})}function Nl({label:e,checked:n,onChange:o}){const{convert:r}=Q();return t.jsxs("label",{className:"bim-d-check",children:[t.jsx("input",{type:"checkbox",checked:n,onChange:s=>o(s.target.checked)}),r(e)]})}const El=6,ki=e=>e>El+1;function Ko({total:e,shown:n,unit:o,onClick:r}){const{t:s,convert:a}=Q(),l=e-n,d=ki(e)?e-Math.min(n,El):l;return d<=0?null:t.jsxs("button",{type:"button",className:`bim-d-more bim-d-ui${l>0?"":" bim-d-more-ncap"}`,onClick:r,children:[l>0&&t.jsx("span",{className:"bim-d-more-w",children:s("detail.expandRest",{n:l,unit:a(o)})}),t.jsx("span",{className:"bim-d-more-n",children:s("detail.expandRest",{n:d,unit:a(o)})})]})}function qo({label:e,onClick:n}){const{convert:o}=Q();return t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:o(e)})}function An({kind:e,title:n,subtitle:o,byline:r,meta:s,description:a,clampDescription:l,facts:d,stats:c,readAction:p,secondaryAction:u,children:m,foot:h}){const{t:f,convert:x}=Q(),k=(d||[]).filter(S=>S.value!=null&&S.value!==""),y=(c||[]).filter(S=>S.value!=null&&S.value!==""&&S.value!==0),[w,b]=g.useState(!1),j=!!l&&!w;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}),o&&t.jsx("div",{className:"bim-d-card-sub",children:o}),r&&t.jsx("p",{className:"bim-d-card-byline",style:{marginBottom:0},children:r}),s&&t.jsx("div",{className:"bim-d-card-cls bim-d-ui",children:s}),a&&t.jsx("div",{className:j?"bim-d-card-desc bim-d-clamp":"bim-d-card-desc",style:j?{"--detail-clamp":l}:void 0,children:a}),a&&!!l&&t.jsx("button",{type:"button",className:"bim-d-card-toggle bim-d-ui","aria-expanded":w,onClick:()=>b(S=>!S),children:f(w?"action.collapse":"action.expand")}),y.length>0&&t.jsx("div",{className:"bim-d-stats bim-d-ui",children:y.map((S,v)=>t.jsxs("div",{children:[t.jsx("b",{children:S.value}),t.jsx("span",{children:x(S.label)})]},v))}),k.length>0&&t.jsx("dl",{className:"bim-d-ui",children:k.map((S,v)=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:x(S.label)}),t.jsx("dd",{title:S.title,children:S.value})]},v))}),m,p,u,h&&t.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:h})]})}function Xo(e){return!!e&&[...e.replace(/\s+/g,"")].length>110}function ho({href:e,onClick:n,label:o}){const{t:r,convert:s}=Q(),a=o??r("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 Dt({id:e,title:n,meta:o,items:r,metas:s,currentIndex:a,cap:l=8,moreLabel:d,foot:c,sub:p,timeline:u}){const{t:m,convert:h}=Q(),[f,x]=g.useState(!1);if(!r.length)return null;const k=f?r:r.slice(0,l),y=r.length-k.length;return t.jsxs("div",{id:e,className:u?"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:[h(n),o!=null&&o!==""&&t.jsx("span",{className:"bim-d-meta",children:o})]}),p&&t.jsx("p",{className:"bim-d-side-sub bim-d-ui",children:p}),t.jsx("ul",{children:k.map((w,b)=>t.jsxs("li",{className:b===a?"bim-d-side-cur":void 0,"aria-current":b===a?"page":void 0,children:[w,s!=null&&s[b]?t.jsx("span",{className:"bim-d-meta",style:{marginLeft:"auto"},children:s[b]}):null]},b))}),y>0&&t.jsx(qo,{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 Mm=new Set(["reviewed","disputed","unreviewed","draft"]);function Pn({revision:e,revisedAt:n,review:o,todo:r}){const{t:s,convert:a}=Q(),l=o&&Mm.has(o.status)?s(`detail.review.${o.status}`):void 0,d=o&&o.status!=="unreviewed"&&l?[l,o.by,o.date].filter(Boolean).join(" "):"",c=[e!=null&&e!==""?`${s("detail.dataVersion")} ${e}`:"",n??"",a(d)].filter(Boolean),p=(r||[]).filter(u=>u&&u.what);return!c.length&&!p.length?null:t.jsxs(t.Fragment,{children:[c.length>0&&t.jsx(Je,{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((u,m)=>t.jsxs("li",{children:[a(u.what),(u.by||u.date)&&t.jsxs("span",{style:{marginLeft:6},children:["(",[u.by&&a(u.by),u.date].filter(Boolean).join(" · "),")"]})]},m))})]})]})}const Qn=1e3,Ss=208,Bm=1440,Wm="(max-width: 719px)",Il=`
|
|
1121
1121
|
.bim-d-page {
|
|
1122
1122
|
background: ${i("page-bg")};
|
|
1123
1123
|
color: ${i("ink")};
|
|
@@ -1126,7 +1126,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1126
1126
|
padding-bottom: 64px;
|
|
1127
1127
|
}
|
|
1128
1128
|
.bim-d-main {
|
|
1129
|
-
max-width: ${
|
|
1129
|
+
max-width: ${Qn}px;
|
|
1130
1130
|
margin: 0 auto;
|
|
1131
1131
|
padding: 24px clamp(16px, 4vw, 28px) 0;
|
|
1132
1132
|
}
|
|
@@ -1137,7 +1137,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1137
1137
|
* PAGE_MAX_WIDTH,读者的行宽体验不变。
|
|
1138
1138
|
*/
|
|
1139
1139
|
.bim-d-main.bim-d-main-wide {
|
|
1140
|
-
max-width: ${
|
|
1140
|
+
max-width: ${Bm}px;
|
|
1141
1141
|
}
|
|
1142
1142
|
.bim-d-ui { font-family: var(--bim-font-ui, system-ui, sans-serif); }
|
|
1143
1143
|
|
|
@@ -1169,9 +1169,9 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1169
1169
|
*/
|
|
1170
1170
|
.bim-d-reader {
|
|
1171
1171
|
display: grid;
|
|
1172
|
-
grid-template-columns: ${
|
|
1172
|
+
grid-template-columns: ${Ss}px minmax(0, ${Qn}px);
|
|
1173
1173
|
gap: 32px;
|
|
1174
|
-
max-width: ${
|
|
1174
|
+
max-width: ${Ss+Qn+32}px;
|
|
1175
1175
|
margin: 0 auto;
|
|
1176
1176
|
align-items: start;
|
|
1177
1177
|
}
|
|
@@ -1194,7 +1194,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1194
1194
|
align-items: start; margin-bottom: 48px; }
|
|
1195
1195
|
.bim-d-pair-wide { grid-template-columns: 1fr 1.2fr; }
|
|
1196
1196
|
|
|
1197
|
-
@media ${
|
|
1197
|
+
@media ${Wm} {
|
|
1198
1198
|
.bim-d-intro { grid-template-columns: 1fr; gap: 20px; margin-bottom: 32px; }
|
|
1199
1199
|
.bim-d-pair, .bim-d-pair-wide { grid-template-columns: 1fr; gap: 40px; }
|
|
1200
1200
|
/* 表格:meta 列折到第二行,表头隐藏 */
|
|
@@ -1212,16 +1212,16 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1212
1212
|
padding-right: 0; padding-bottom: 12px;
|
|
1213
1213
|
}
|
|
1214
1214
|
}
|
|
1215
|
-
${
|
|
1216
|
-
`)||(n.push({start:o,end:a+1,inner:l}),o=a)}return n}function
|
|
1217
|
-
`).map(n=>n.trim()).filter(n=>n&&!
|
|
1218
|
-
`)){const s=r.trim();if(!s||
|
|
1215
|
+
${Pm}`;function $n({children:e,style:n,wide:o,grid:r}){return t.jsxs("div",{className:"bim-d-page",style:n,children:[t.jsx("style",{children:Il}),t.jsx("div",{className:r?"bim-d-main bim-d-main-grid":o?"bim-d-main bim-d-main-wide":"bim-d-main",children:e})]})}function go({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:i("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 Zo({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:i(n==="accent"?"accent":"ink"),color:i("page-bg")},children:e})}function fo({items:e}){const n=Xe();return t.jsx(t.Fragment,{children:e.map((o,r)=>{const s=r===e.length-1,a=r>0&&t.jsx("span",{style:{color:i("hint-fg")},children:"/"},`s${r}`),l=o.id?n(o.id):o.href,d=s||!o.onClick&&!l?t.jsx("span",{style:{color:i("ink")},children:o.label},r):t.jsx("a",{href:l??"#",onClick:o.onClick?c=>{c.metaKey||c.ctrlKey||(c.preventDefault(),o.onClick())}:void 0,style:{color:i("meta-fg")},children:o.label},r);return t.jsxs(g.Fragment,{children:[a,d]},r)})})}function Rl({title:e,subtitle:n,aside:o,secondLine:r}){return t.jsxs("header",{style:{borderBottom:`2px solid ${i("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:i("meta-fg"),letterSpacing:".06em"},children:n})]}),o&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:i("label-fg"),letterSpacing:".06em"},children:o})]}),r&&t.jsx("div",{style:{marginTop:12,fontSize:13.5,color:i("quiet-fg")},children:r})]})}function Om({children:e,facts:n}){return!e&&n?t.jsx("div",{style:{padding:"20px 0 26px",borderBottom:`1px solid ${i("rule")}`,marginBottom:40},children:n}):t.jsxs("div",{className:"bim-d-intro",children:[t.jsx("div",{style:{minWidth:0},children:e}),n]})}function Hm({items:e,horizontal:n}){const{convert:o}=Ie();return e.length?t.jsx("div",{style:{borderLeft:`2px solid ${i("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((r,s)=>t.jsxs("div",{title:r.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:i("label-fg"),letterSpacing:".08em",flex:"none"},children:o(r.label)}),t.jsx("span",{style:{color:i("body-fg"),textAlign:n?"left":"right",minWidth:0},children:r.value})]},s))}):null}function Fm({glyph:e,tone:n,title:o,count:r,actions:s,id:a}){const{convert:l}=Ie();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(Zo,{char:e,tone:n}),t.jsx("h2",{style:{margin:0,fontSize:19,fontWeight:600,letterSpacing:".1em"},children:l(o)}),r!=null&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:i("label-fg")},children:r})]}),s&&t.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:14,fontSize:12},children:s})]})}function Ll({label:e,active:n,onClick:o,dashed:r}){const{convert:s}=Ie();return t.jsx("button",{type:"button",onClick:o,"aria-pressed":n,className:"bim-d-ui",style:{padding:"5px 13px",border:`1px ${r&&!n?"dashed":"solid"} ${i(n?"accent":"rule")}`,background:n?i("accent"):"transparent",color:i(n?"page-bg":"meta-fg"),fontSize:12,cursor:"pointer",letterSpacing:".04em",lineHeight:1.4},children:s(e)})}function Dm({label:e,onClick:n}){const{convert:o}=Ie();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:i("meta-fg"),borderBottom:`1px solid ${i("rule")}`},children:o(e)})}function Um({label:e,onClick:n,inline:o}){const{convert:r}=Ie();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{marginTop:o?0:12,width:o?void 0:"100%",padding:o?"4px 12px":9,background:"none",border:`1px dashed ${i("rule-dashed")}`,cursor:"pointer",fontSize:12,color:i("meta-fg"),letterSpacing:o?void 0:".08em"},children:r(e)})}function Al({children:e,href:n,onClick:o,title:r}){const s={display:"inline-block",padding:"4px 10px",border:`1px solid ${i("rule")}`,fontSize:13,color:i("body-fg"),lineHeight:1.5};return n||o?t.jsx("a",{href:n??"#",title:r,onClick:o?a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),o())}:void 0,style:s,children:e}):t.jsx("span",{title:r,style:s,children:e})}function Vm({children:e}){return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e})}function Gm({volumes:e,unit:n,max:o=60}){const{t:r}=Q(),s=n??r("unit.volume"),[a,l]=g.useState(!1);if(!e.length)return null;const d=a?e:e.slice(0,o);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 ${i("rule")}`,color:i("meta-fg")},children:c},c)),!a&&e.length>o&&t.jsxs("button",{type:"button",onClick:()=>l(!0),style:{padding:"2px 8px",background:"none",cursor:"pointer",border:`1px dashed ${i("rule-dashed")}`,fontFamily:"inherit",fontSize:11.5,color:i("meta-fg")},children:["+",e.length-o]}),t.jsx("span",{style:{padding:"2px 6px",color:i("hint-fg")},children:s})]})}function Ym({children:e}){return t.jsx("div",{style:{borderTop:`1px solid ${i("rule-strong")}`},children:e})}function Km({spec:e}){const{convert:n}=Ie();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 ${i("rule-strong")}`,fontSize:11,color:i("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(o=>o.width).join(" "),gap:12},children:e.columns.map(o=>t.jsx("span",{children:n(o.label)},o.label))})]})}function qm({no:e,main:n,meta:o,spec:r}){return t.jsxs("div",{className:"bim-d-row",style:{gridTemplateColumns:`${r.leadWidth}px 1fr ${r.metaWidth}px`,gap:12},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:i("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:r.columns.map(s=>s.width).join(" "),gap:12,alignItems:"center",fontSize:12},children:o})]})}function Xm(e){return String(e+1).padStart(2,"0")}function Zm(){return t.jsx("span",{style:{color:i("hint-fg")},children:"—"})}function Jm({open:e,onToggle:n,main:o,action:r,children:s}){return t.jsxs("div",{style:{borderBottom:`1px solid ${i("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 ${i(e?"accent":"rule-dashed")}`,background:e?i("accent"):"transparent",color:i(e?"page-bg":"accent")},children:e?"-":"+"}),t.jsx("span",{style:{fontSize:14,minWidth:0},children:o}),r]}),e&&s&&t.jsx("div",{style:{padding:"2px 4px 14px 38px",borderLeft:`2px solid ${i("rule-accent-soft")}`,marginLeft:12},children:s})]})}function Pl(e){const n=[];for(let o=0;o<e.length;o++){const r=e[o];let s;if(r==="⟨")s="⟩";else if(r==="<"){const d=e[o+1];if(d===void 0||/[A-Za-z/!?>\s]/.test(d))continue;s=">"}else continue;const a=e.indexOf(s,o+1);if(a<0)continue;const l=e.slice(o+1,a);l.includes(`
|
|
1216
|
+
`)||(n.push({start:o,end:a+1,inner:l}),o=a)}return n}function Ml(e,n){if(e.length<=n)return e;let o=n;for(const r of Pl(e)){if(r.start>=o)break;if(r.end>o){o=r.start>0?r.start:r.end;break}}return e.slice(0,o)}const Bl={fontSize:".78em",color:i("meta-fg"),lineHeight:1.55},Qm={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 Wl(e,n,o,r){return e.map((s,a)=>{switch(s.type){case"text":return t.jsx(g.Fragment,{children:n(s.text)},a);case"jz":return t.jsx("span",{className:"bim-jiazhu",style:o===0?Bl:void 0,children:Wl(s.children,n,o+1,r)},a);case"qw":return t.jsx("span",{className:"bim-qw guji-qw",title:s.label?r("detail.lacunaWith",{label:s.label}):r("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:r("detail.composedChar",{label:s.label}),style:Qm,children:s.label},a)}})}function ut(e,n=r=>r,o){if(!e)return"";if(o!=null&&o.gujiMarkdown)return Zu(e)?Wl(el(e),n,0,o.t??cn("zh-Hant")):n(e);if(e.indexOf("⟨")<0&&e.indexOf("<")<0)return n(e);const r=[];let s=0,a=0;for(const l of Pl(e))l.start>s&&r.push(t.jsx(g.Fragment,{children:n(e.slice(s,l.start))},a++)),r.push(t.jsx("span",{className:"bim-jiazhu",style:Bl,children:n(l.inner)},a++)),s=l.end;return s<e.length&&r.push(t.jsx(g.Fragment,{children:n(e.slice(s))},a++)),r}function eh({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:i("label-fg"),marginBottom:4},children:e}),t.jsx("div",{style:{fontSize:13.5,lineHeight:2,color:i("quiet-fg"),textAlign:"justify"},children:n})]})}function th({title:e,tag:n,children:o}){const{convert:r}=Ie();return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,paddingBottom:7,borderBottom:`1px solid ${i("rule-strong")}`,marginBottom:2},children:[t.jsx("span",{style:{fontSize:14.5,letterSpacing:".08em"},children:r(e)}),n&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:i("accent"),letterSpacing:".06em"},children:r(n)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column"},children:o})]})}function Ol({name:e,note:n,href:o,extra:r}){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:i("hint-fg"),flex:"none"},children:o?"↗":""}),n&&t.jsx("span",{className:"bim-d-ui",style:{gridColumn:"1 / -1",fontSize:11.5,color:i("label-fg")},children:n})]}),a={display:"grid",gridTemplateColumns:"1fr auto",gap:"4px 12px",padding:"9px 4px",borderBottom:`1px solid ${i("rule")}`,color:i("body-fg"),alignItems:"baseline"};return t.jsxs(t.Fragment,{children:[o?t.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:a,children:s}):t.jsx("div",{style:a,children:s}),r]})}function nh({item:e,siblings:n,showVolumes:o=!0,fallbackNote:r}){const{t:s,convert:a}=Q(),[l,d]=g.useState(!1),c=pi(e),p=o&&!!c&&c.expected>0,u=(e.url?dn(e.url):void 0)||a(e.name),m=n?vl(e,n):"",h=m?`${u}(${m})`:u;return t.jsx(Ol,{name:h,note:yi(e,s)||r,href:pn(e),extra:p?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>d(f=>!f),className:"bim-d-ui",style:{alignSelf:"flex-start",padding:"2px 0",marginTop:4,background:"none",border:"none",cursor:"pointer",fontSize:11,color:i("meta-fg"),borderBottom:`1px solid ${i("rule")}`},children:l?s("detail.collapseVolumes"):s("detail.expandVolumes",{n:c.expected})}),l&&t.jsx(Jo,{item:e})]}):void 0})}function Jo({item:e}){return t.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,padding:"6px 0 10px",fontSize:11},children:(e.volumes||[]).map((n,o)=>{const r=n.status==="missing";return n.url&&!r?t.jsx("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{padding:"4px 8px",borderRadius:4,background:i("zebra-bg")},children:n.volume},o):t.jsx("span",{style:{padding:"1px 5px",color:i(r?"missing-fg":"hint-fg"),textDecoration:r?"line-through":void 0},children:n.volume},o)})})}function Hl({label:e,items:n}){const{convert:o}=Ie();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:i("label-fg"),letterSpacing:".08em"},children:e}),n.map((r,s)=>t.jsx(Al,{children:o(r)},s))]}):null}function ih({rows:e}){const n=e.filter(o=>o.items.length>0);return n.length?t.jsx("div",{style:{marginTop:16,display:"flex",flexDirection:"column",gap:8},children:n.map(o=>t.jsx(Hl,{label:o.label,items:o.items},o.label))}):null}function xo(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Fl({left:e,right:n}){return t.jsxs("footer",{className:"bim-d-ui",style:{marginTop:52,paddingTop:14,borderTop:`1px solid ${i("rule")}`,display:"flex",flexWrap:"wrap",justifyContent:"space-between",gap:"8px 16px",fontSize:11.5,color:i("aux-fg")},children:[t.jsx("span",{children:e}),n&&t.jsx("span",{style:{display:"flex",gap:16},children:n})]})}function oh({children:e,action:n}){return t.jsxs("div",{className:"bim-d-ui",style:{padding:"18px 4px",fontSize:12.5,color:i("aux-fg"),borderBottom:`1px solid ${i("rule")}`,display:"flex",flexWrap:"wrap",alignItems:"center",gap:12},children:[t.jsx("span",{children:e}),n]})}function qe({id:e,label:n,onNavigate:o,renderLink:r,style:s,dense:a}){const l=Xe();return r?t.jsx(t.Fragment,{children:r(e,typeof n=="string"?n:void 0,{dense:a})}):t.jsx("a",{href:l(e),onClick:o?d=>{d.metaKey||d.ctrlKey||(d.preventDefault(),o(e))}:void 0,style:s,children:n??e})}function rh({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 sh={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},ah={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},lh=`1px solid ${i("table-border")}`,Dl={border:lh,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},ch={...Dl,background:i("table-head-bg"),fontWeight:600};function Qo({table:e,opts:n}){return t.jsx("div",{className:"bim-guji-table-wrap",style:sh,children:t.jsx("table",{className:"bim-guji-table",style:ah,children:t.jsx("tbody",{children:e.rows.map((o,r)=>t.jsx("tr",{children:o.cells.map((s,a)=>{const l=o.header?"th":"td";return t.jsx(l,{colSpan:s.colspan>1?s.colspan:void 0,rowSpan:s.rowspan>1?s.rowspan:void 0,style:o.header?ch:Dl,children:s.empty?null:ut(s.text,void 0,n)},a)})},r))})})})}function dh(e,n){return e.indexOf("**")<0?ut(e,void 0,n):e.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((r,s)=>s%2===1?t.jsx("strong",{children:ut(r.trim().slice(2,-2),void 0,n)},s):t.jsx(g.Fragment,{children:ut(r,void 0,n)},s))}function ph(e,n,o=!1){const r=o?{gujiMarkdown:!0}:void 0;return n?Oo(e).map((s,a)=>s.type==="table"?t.jsx(Qo,{table:s.table,opts:r},a):t.jsx(g.Fragment,{children:dh(s.text,r)},a)):ut(e,void 0,r)}const uh=/^(#{1,6})\s+(.*)$/,mh=/^\*\*([^*\n]+)\*\*\s*$/;function er(e){const n=e.match(uh);if(n)return{level:n[1].length,text:n[2].trim()};const o=e.trim().match(mh);return o?{level:3,text:o[1].trim()}:null}const tr=/^<!--.*-->$/;function Ul(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function Vl(e){return e.split(`
|
|
1217
|
+
`).map(n=>n.trim()).filter(n=>n&&!tr.test(n))}const hh=60;function Gl(e){let n=0,o=0;for(const r of e.split(`
|
|
1218
|
+
`)){const s=r.trim();if(!s||tr.test(s)||er(s))continue;const a=s.replace(/<[^<>\n]*>|\u27e8[^\u27e9\n]*\u27e9/g,"").replace(/\s/g,"").length;n+=a,a>hh&&(o+=a)}return n>0&&o*2>=n}function gh(e){return e.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function wi(e){if(e=gh(e),Gl(e))return"unknown";const n=Ul(e);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const o=n.map(s=>Vl(s).length).filter(s=>s>0);if(o.length===0)return"unknown";const r=o.reduce((s,a)=>s+a,0)/o.length;return r<=4?"record":r>=8?"catalog":"unknown"}function fh(e){const n=e.split(`
|
|
1219
1219
|
`),o=[];let r=null,s=[];const a=()=>{o.push({heading:r,body:s.join(`
|
|
1220
|
-
`)}),s=[]};for(const l of n){const d=
|
|
1221
|
-
`)){const r=
|
|
1222
|
-
`)?"":n)}function
|
|
1223
|
-
`);let c=0;return t.jsx(t.Fragment,{children:d.map((p,u)=>{const m=p.match(Ui);if(m){const f=c++;if(a(m[1].length,m[2],f))return null;const{Tag:x,className:k}=l(m[1].length);return t.jsx(x,{className:k,children:o(m[2])},u)}if(!p.trim())return u>=2&&!!d[u-1].trim()&&!!d[u-2].trim()&&!Ui.test(d[u-1])&&!Ui.test(d[u-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},u):null;if(mh.test(p))return null;if(c++,/^\*\*[^*]+\*\*\s*$/.test(p.trim())){const{Tag:f,className:x}=l(3);return t.jsx(f,{className:x,children:o(p.trim().slice(2,-2))},u)}return t.jsx("p",{className:ws(p),children:ks(p,o,u)},u)})})}function xh(e){const{convert:n}=Re();return g.useMemo(()=>e?n(e):"",[e,n])}function er({text:e,mode:n,tables:o=!1,gujiMarkdown:r=!1,properNames:s=!1,renderText:a,dropTitle:l}){const d=xh(e),{t:c,convert:p}=J(),u=f=>Qo(f,{renderText:a,properNames:s,gujiMarkdown:r,t:c}),m=r?{gujiMarkdown:!0,t:c}:void 0,h=l?p(l):void 0;return!o||d.indexOf(":::")<0?t.jsx(Ss,{text:d,mode:n,inline:u,dropTitle:h}):t.jsx(t.Fragment,{children:Mo(d).map((f,x)=>f.type==="table"?t.jsx(Xo,{table:f.table,opts:m},x):t.jsx(Ss,{text:f.text,mode:n,inline:u,dropTitle:x===0?h:void 0},x))})}function bh(e,n,o){const[r,s]=g.useState(null),[a,l]=g.useState(!1),d=g.useRef(0);return g.useEffect(()=>{const c=++d.current;if(!e||!n){s(null),l(!1);return}let p;try{p=e(n,o)}catch{s(null),l(!1);return}if(!p||typeof p.then!="function"){s(p??null),l(!1);return}l(!0),p.then(u=>{c===d.current&&s(u??null)}).catch(()=>{c===d.current&&s(null)}).finally(()=>{c===d.current&&l(!1)})},[e,n,o]),{images:r,loading:a}}const _s={A:"fine",B:"rough",C:"rough",D:"ocr"};function yh(e){return typeof e!="string"?null:e in ep?e:e in _s?_s[e]:null}const jh={書:"书",類:"类",結語:"结语",結语:"结语",考證:"考证",詩:"诗"},vh={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释"},Yl="\0";function kh(e,n,o){const[r,s=""]=e.split(Yl);return t.jsxs(t.Fragment,{children:[r,t.jsx(il,{text:n,convert:o}),s]})}function ht(e){return typeof e!="string"?"":jh[e]??vh[e]??e}const wh=["〇","一","二","三","四","五","六","七","八","九"],$s=["","十","百","千"],Sh=["","萬","億"];function tr(e){if(e===0)return"〇";if(e<0)return`負${tr(-e)}`;const n=[];let o=e,r=0;for(;o>0;){const s=o%1e4;s>0?n.unshift(_h(s,r>0)+Sh[r]):n.length>0&&n.unshift("〇"),o=Math.floor(o/1e4),r++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function _h(e,n){const o=[];let r=e;for(;r>0;)o.unshift(r%10),r=Math.floor(r/10);let s="";for(let a=0;a<o.length;a++){const l=o[a],d=o.length-1-a;l===0?s&&!s.endsWith("〇")&&(s+="〇"):l===1&&d===1&&a===0&&!n?s+=$s[d]:s+=wh[l]+$s[d]}return s.replace(/〇$/,"")}let Tn=null,Yn=null;const ri=new Set;function $h(){return Tn?Promise.resolve():Yn||(Yn=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});Tn=o=>n(we.normalizeVariants(o)),ri.forEach(o=>o())}).catch(()=>{Tn=e=>e,ri.forEach(e=>e())}),Yn)}const Ch=e=>e;function qt(){const[,e]=g.useState(0);return g.useEffect(()=>{if(Tn)return;const n=()=>e(o=>o+1);return ri.add(n),$h(),()=>{ri.delete(n)}},[]),Tn??Ch}function an(e,n){return n(e).toLowerCase()}const zh=i("highlight-bg");function Pn(e,n,o){if(!n)return e;const r=an(n,o);if(!r)return e;const s=an(e,o);if(s.length!==e.length)return e;const a=[];let l=0,d=0;for(;l<e.length;){const c=s.indexOf(r,l);if(c===-1){a.push(e.slice(l));break}c>l&&a.push(e.slice(l,c)),a.push(t.jsx("mark",{style:{background:zh,padding:0,color:"inherit"},children:e.slice(c,c+r.length)},d++)),l=c+r.length}return t.jsx(t.Fragment,{children:a})}function nr(e,n,o,r){if(!n)return!0;const s=an(n,r);return(o?[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"&&an(l,r).includes(s))}function Th(e,n,o){return n?an(e,o).includes(an(n,o)):!0}const ir={类:i("section-lei"),书:i("section-shu"),序:i("section-xu"),结语:i("section-jieyu"),注释:i("section-zhushi")},Nh={考证:i("section-kaozhen")};function or(e,n,o){return e.collated.sectionType[n]??o(n)}function Kl(e){var r;const n=e.files.length,o=((r=e.children)==null?void 0:r.reduce((s,a)=>s+Kl(a),0))||0;return n+o}function Eh(e,n){const o=[],r=l=>{var d;o.push(...l.files),(d=l.children)==null||d.forEach(r)};if(r(e),o.length===0)return;const s=o.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 Ih={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function rr({enabled:e,expanded:n,onClick:o,style:r,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:o,style:{...Ih,...r},children:s}):t.jsx("span",{style:r,children:s})}function Rh({type:e}){const{convert:n,messages:o}=J(),r=ht(e),s=ir[r]||i("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:or(o,r,n)})}function Lh({section:e,onNavigate:n,highlightQuery:o="",no:r,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=J(),c=Xe(),p=qt(),u=j=>j?pt(d(j),S=>o?Pn(S,o,p):S,{t:l}):"",[m,h]=g.useState(!1),f=!!e.summary,x=!!e.comment,k=!!e.additional_comment,y=!!(e.content&&e.content.length>60),w=f||x||k||y;g.useEffect(()=>{o&&h(!0)},[o]);const b=!m&&y?Rl(e.content.replace(/\n/g," "),80)+"…":null;return t.jsxs("div",{className:"bim-rd-row",id:a,style:{borderBottom:`1px solid ${i("rule")}`,overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>w&&h(!m),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:w?"pointer":"default",userSelect:"none"},children:[r!=null&&t.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:i("label-fg")},children:r}),t.jsxs(rr,{enabled:w,expanded:m,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[w&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("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:i("fg")},children:[e.book_title?t.jsxs(t.Fragment,{children:["《",u(e.book_title),"》"]}):u(e.title),e.n_juan!=null&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:l("collated.nJuan",{n:d(tr(e.n_juan))})}),(e.author_info||e.author)&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:u(e.author_info||e.author)})]}),!m&&b&&t.jsx("span",{style:{display:"block",fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:u(b)})]})]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u(e.edition)}),e.tag&&t.jsx("span",{style:{fontSize:"11px",color:i("section-tag-fg")},children:e.tag==="triangle"?"△":e.tag}),e.work_id&&n&&t.jsx("a",{href:c(e.work_id),onClick:j=>{j.metaKey||j.ctrlKey||(j.preventDefault(),j.stopPropagation(),n(e.work_id))},style:{fontSize:"11px",color:i("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:i("label-fg"),flexShrink:0},children:l("collated.unlinked")})]}),m&&w&&t.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${i("widget-border")}`,background:i("bg")},children:[e.author_info&&t.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"8px"},children:u(e.author_info)}),e.summary&&t.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:`3px solid ${i("primary")}`,background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.summary")}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:u(e.summary)})]}),e.comment&&t.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.comment")}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(e.comment)})]}),e.additional_comment&&t.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.additionalComment")}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(e.additional_comment)})]}),y&&!f&&!x&&!k&&t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(e.content)})]})]})}function Ah({section:e,highlightQuery:n=""}){const{t:o,convert:r}=J(),s=qt(),a=p=>p?pt(r(p),u=>n?Pn(u,n,s):u,{t:o}):"",[l,d]=g.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(rr,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(Rh,{type:e.type}),t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:a(e.title)}),c&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("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, ${ir[ht(e.type)]||i("desc-fg")} 25%, transparent)`,borderRadius:"0 4px 4px 0",background:i("bg")},children:t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:a(e.content)})})]})}const Ph=100;function sr(e){return ht(e.type)!=="page_header"?!1:(e.content||"").length>=Ph}function Mh({section:e,highlightQuery:n=""}){const{t:o,convert:r,messages:s}=J(),a=qt();if(ht(e.type)==="page_header"&&!sr(e)||!e.content&&!e.title)return null;const l=r((e.content||e.title||"").replace(/\n{2,}/g,`
|
|
1224
|
-
`)),d=pt(l,m=>n?Pn(m,n,a):m,{t:o}),c=ht(e.type),p=ir[c]||i("desc-fg"),u=c==="序"||c==="结语"||c==="注释";return t.jsxs("div",{style:{padding:u?"10px 12px":"6px 0",margin:u?"8px 0":void 0,fontSize:"13px",color:i("desc-fg"),lineHeight:1.8,whiteSpace:"pre-line",borderLeft:u?`3px solid ${p}40`:void 0,background:u?i("bg"):void 0,borderRadius:u?"0 4px 4px 0":void 0,position:"relative"},children:[u&&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:or(s,c,r)}),d]})}function Bh(e,n,o){const[r,s]=g.useState({});return g.useEffect(()=>{var p;if(!n||e.length===0)return;let a=!1;const l=e.filter(u=>{var m;return!((m=o==null?void 0:o.current)!=null&&m.has(u))}),d={};for(const u of e)(p=o==null?void 0:o.current)!=null&&p.has(u)&&(d[u]=o.current.get(u));if(Object.keys(d).length>0&&s(d),l.length===0)return;const c=async u=>{var m;try{if(n.getEntry){const y=await n.getEntry(u);if(y)return{title:y.title,author:y.author}}const h=await n.getItem(u);if(!h)return null;const f=h.title||u,x=h.authors,k=(m=x==null?void 0:x[0])==null?void 0:m.name;return{title:f,author:k}}catch{return null}};return Promise.all(l.map(async u=>{var h;const m=await c(u);return(h=o==null?void 0:o.current)==null||h.set(u,m),[u,m]})).then(u=>{a||s(m=>{const h={...m};for(const[f,x]of u)h[f]=x;return h})}),()=>{a=!0}},[e.join(","),n]),r}function Wh({section:e,onNavigate:n,transport:o,workLabelCache:r,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=J(),c=Xe(),p=qt(),u=S=>S?pt(l(S),v=>s?Pn(v,s,p):v,{t:a}):"",[m,h]=g.useState(!1);g.useEffect(()=>{s&&h(!0)},[s]);const f=ht(e.type),x=Nh[f]||i("desc-fg"),k=!!e.content,y=e.work_ids||[],w=y.length>1,b=Bh(w?y:[],o,r),j=k&&!m&&e.content.length>80?Rl(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${i("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>k&&h(!m),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:k?"pointer":"default",userSelect:"none"},children:[t.jsxs(rr,{enabled:k,expanded:m,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[k&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("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:i("fg"),lineHeight:1.6},children:e.header_line?u(e.header_line):u(e.title)}),!m&&j&&t.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:i("desc-fg"),lineHeight:1.7},children:u(j)})]})]}),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:S=>{S.metaKey||S.ctrlKey||(S.preventDefault(),S.stopPropagation(),n(y[0]))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:a("collated.viewWork"),children:a("collated.arrowWork")}),w&&t.jsx("span",{style:{fontSize:"11px",color:i("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:or(d,f,l)})]})]}),w&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:y.map(S=>{const v=b[S],$=v?`${l(v.title)}${v.author?`(${l(v.author)})`:""}`:S.slice(0,8)+"…";return t.jsxs("a",{href:c(S),onClick:_=>{_.metaKey||_.ctrlKey||(_.preventDefault(),_.stopPropagation(),n(S))},style:{fontSize:"12px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:S,children:["→",$]},S)})}),m&&k&&t.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${x}40`,borderRadius:"0 4px 4px 0",background:i("bg")},children:[t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(e.content)}),e.comment&&t.jsx("div",{style:{marginTop:"10px",paddingTop:"8px",borderTop:`1px solid ${i("widget-border")}`,fontSize:"12px",color:i("desc-fg"),lineHeight:1.8,fontStyle:"italic"},children:u(e.comment)})]})]})}function Oh({juan:e,searchQuery:n,onNavigate:o,transport:r,workLabelCache:s}){const{t:a}=J(),l=qt(),d=n.trim(),c=g.useMemo(()=>d?e.sections.filter(p=>nr(p,d,!0,l)):e.sections,[e.sections,d,l]);return t.jsxs("div",{children:[t.jsx("div",{children:c.map((p,u)=>t.jsx(Wh,{section:p,onNavigate:o,transport:r,workLabelCache:s,highlightQuery:d},u))}),c.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:a("collated.noMatch")})]})}function Hh(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function Fh({sections:e,onNavigate:n,inline:o,workLinks:r=!0}){const s=Xe(),{t:a,convert:l}=J(),d=Hh();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const u=ht(c.type);if(u==="page_header"&&!sr(c))return null;if(u==="类")return t.jsxs(g.Fragment,{children:[g.createElement(d("类"),null,o(l(c.title))),c.content&&t.jsx("p",{children:o(l(c.content))})]},p);if(u==="书"||u==="诗"||u==="考证"||u==="注释"){const m=c.book_title?`《${c.book_title}》${c.n_juan!=null?a("collated.nJuan",{n:tr(c.n_juan)}):""}`:c.title,h=o(l(m));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[g.createElement(d("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&r?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},title:a("collated.viewWork"),children:h}),t.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},"aria-label":a("collated.viewWorkOf",{title:l(m)}),children:a("collated.workArrow")})]}):h),c.author_info&&t.jsx("p",{className:"bim-rd-sub",children:o(l(c.author_info))}),c.content&&c.content.split(/\n+/).map((f,x)=>t.jsx("p",{children:o(l(f))},x)),c.summary&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.summary")}),o(l(c.summary))]}),c.comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.comment")}),o(l(c.comment))]}),c.additional_comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.additionalComment")}),o(l(c.additional_comment))]})]},p)}return c.content?t.jsx("p",{children:o(l(c.content))},p):null})})}function ql(e){return e.some(n=>{const o=ht(n.type);return o==="书"||o==="诗"||o==="考证"||o==="注释"||o==="类"||(o==="序"||o==="结语")&&!!n.content||o==="page_header"&&sr(n)})}function Dh({juan:e,rawText:n,positionLabel:o,groupLabel:r,index:s,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c,prefs:p,view:u,onViewChange:m}){var Z;const{t:h,convert:f,messages:x}=J(),k=qt(),[y,w]=g.useState("text"),b=u??y,j=A=>{w(A),m==null||m(A)},S=a.trim(),v=(s==null?void 0:s.type)==="kaozhen",$=g.useCallback(A=>S?Pn(A,S,k):A,[S,k]),_=A=>Qo(A,{renderText:$,properNames:p.properNames,t:h}),C=g.useMemo(()=>S?e.sections.filter(A=>nr(A,S,v,k)):e.sections,[e.sections,S,v,k]),M=(A,V)=>V.filter(ce=>ht(ce.type)===A).length,T=M("书",e.sections),z=M("诗",e.sections),F=M("考证",e.sections);let N="";v?N=S?h("collated.countTiaoOf",{m:M("考证",C),n:F}):h("collated.countTiao",{n:F}):z>0?N=S?h("collated.countPoemsOf",{m:M("诗",C),n:z}):h("collated.countPoems",{n:z}):T>0&&(N=S?h("collated.countBooksOf",{m:M("书",C),n:T}):h("collated.countBooks",{n:T}));const R=s!=null&&s.text_quality?yh(s.text_quality.grade):null,O=[];N&&O.push(N),v&&(s!=null&&s.target_source)&&O.push(t.jsx(t.Fragment,{children:h("collated.kaozhenTarget",{target:f(s.target_source)})})),R&&O.push(t.jsx("span",{title:x.collated.qualityCriteria[R],children:(Z=s==null?void 0:s.text_quality)!=null&&Z.source_note?t.jsxs(t.Fragment,{children:[kh(h("collated.baseText",{note:Yl}),s.text_quality.source_note,f),t.jsx("span",{className:"bim-rd-grade",children:x.collated.qualityLabel[R]})]}):t.jsxs(t.Fragment,{children:[h("collated.textQuality"),t.jsx("span",{className:"bim-rd-grade",children:x.collated.qualityLabel[R]})]})})),e.source_url&&O.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:h("collated.originalSource")}));const I=!v&&ql(e.sections),P=!!n&&(!I||p.readingMode==="paragraph"&&oi(n)),U=!v&&(I||!!n),K=v||!U?"entries":b;let L=0;return t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[(o||r)&&t.jsxs("p",{className:"bim-rd-kicker",children:[o,o&&r&&t.jsx("span",{className:"bim-rd-dot"}),r&&f(r)]}),t.jsx("h1",{className:"bim-rd-h1",children:f(e.title)}),O.length>0&&t.jsx("p",{className:"bim-rd-meta",children:O.map((A,V)=>t.jsxs(g.Fragment,{children:[V>0&&t.jsx("span",{className:"bim-rd-dot"}),A]},V))}),U&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":h("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":K==="text",onClick:()=>j("text"),children:h("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":K==="entries",onClick:()=>j("entries"),children:h("collated.viewEntries")})]})]}),K==="text"&&t.jsx("article",{className:"bim-rd-prose",children:P?t.jsx(er,{text:n,mode:p.readingMode,properNames:p.properNames,renderText:$,dropTitle:e.title}):t.jsx(Fh,{sections:e.sections,onNavigate:l,inline:_,workLinks:p.workLinks})}),K==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:v?t.jsx(Oh,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[C.some(A=>["书","诗","考证"].includes(ht(A.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:h("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:h("collated.rowHeadTitle")}),t.jsx("span",{children:h("collated.rowHeadWork")})]}),C.map((A,V)=>{const ce=ht(A.type);return ce==="书"||ce==="诗"||ce==="考证"?(L+=1,t.jsx(Lh,{domId:`rd-e-${e.sections.indexOf(A)}`,section:A,onNavigate:p.workLinks?l:void 0,highlightQuery:S,no:L,showUnlinked:p.workLinks&&!!l},V)):ce==="类"?t.jsx(Ah,{section:A,highlightQuery:S},V):t.jsx(Mh,{section:A,highlightQuery:S},V)}),C.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:h("collated.noMatch")})]})})]})}function Uh(e){const{resetKey:n,load:o,files:r,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=qt(),u=g.useRef(new Map),[m,h]=g.useState({}),[f,x]=g.useState({}),k=g.useCallback((w,b)=>{const j=b==null?void 0:b.title;j&&x(S=>S[w]===j?S:{...S,[w]:j})},[]);g.useEffect(()=>{s&&a&&(u.current.set(s,{juan:a,rawText:l}),k(s,a))},[s,a,l,k]),g.useEffect(()=>{u.current.clear(),h({}),x({})},[n]);const y=g.useCallback((w,b)=>{let j=0;if(w.juan)for(const S of w.juan.sections)nr(S,b,c,p)&&j++;return j===0&&w.rawText&&Th(w.rawText,b,p)&&(j=1),j},[c,p]);return g.useEffect(()=>{const w=d.trim();if(!w){h({});return}if(!o||r.length===0)return;let b=!1;const j={},S=[];for(const M of r){const T=u.current.get(M);T?j[M]=y(T,w):(j[M]="loading",S.push(M))}h(j);const v=8;let $=0;const _=async()=>{for(;$<S.length;){if(b)return;const M=$++,T=S[M];try{const z=await o(T),F=z.juan;if(u.current.set(T,z),k(T,F),b)return;h(N=>({...N,[T]:y(z,w)}))}catch{if(b)return;h(z=>({...z,[T]:0}))}}},C=Array.from({length:Math.min(v,S.length)},()=>_());return Promise.all(C),()=>{b=!0}},[d,n,o,r.join(","),y,p,k]),{matchStates:m,titles:f}}function Vh({juan:e,view:n,onView:o,textHasEntries:r}){const{t:s,convert:a}=J(),l=e.sections.map((u,m)=>({s:u,i:m,t:ht(u.type)})).filter(u=>u.t==="书"||u.t==="诗");if(l.length===0)return null;const d=l.filter(u=>!!u.s.work_id).length,c=l.every(u=>u.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),p=u=>{const m=()=>{var h,f;return(f=(h=document.getElementById(`rd-e-${u}`))==null?void 0:h.scrollIntoView)==null?void 0:f.call(h,{block:"start",behavior:"smooth"})};n==="text"&&!r&&o("entries"),n==="text"&&!r?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:u,i:m})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${m}`,onClick:h=>{h.preventDefault(),p(m)},children:[t.jsx("span",{className:`bim-rd-rail-dot${u.work_id?" on":""}`,"aria-hidden":"true"}),t.jsx("span",{children:a(u.book_title||u.title)})]})},m))})]})]})}const Gh=`
|
|
1220
|
+
`)}),s=[]};for(const l of n){const d=er(l);if(d){a(),r={kind:"heading",level:d.level,text:d.text};continue}s.push(l)}return a(),o}function _s(e){const n=[];for(const o of e.split(`
|
|
1221
|
+
`)){const r=er(o);if(r){n.push({kind:"heading",level:r.level,text:r.text});continue}const s=o.trim();!s||tr.test(s)||n.push({kind:"body",text:o})}return n}function Yl(e){if(!e)return[];const n=wi(e);if(n==="unknown")return _s(e);const o=[];for(const{heading:r,body:s}of fh(e)){r&&o.push(r);const a=Ul(s);if(a.length!==0){if(Gl(s)){o.push(..._s(s));continue}if(n==="record"){const l=a.join(" ");l&&o.push({kind:"body",text:l})}else for(const l of a){const d=Vl(l);d.length&&o.push({kind:"body",text:d.join(" ")})}}}return o}const Kl=e=>e;function ql(e,n=Kl){if(e.indexOf("《")<0)return n(e);const o=[],r=/《([^《》\n]+)》/g;let s=0,a=0,l;for(;l=r.exec(e);)l.index>s&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s,l.index))},a++)),o.push(t.jsxs("span",{className:"bim-rd-pn",children:[t.jsx("span",{className:"bim-rd-sr",children:"《"}),n(l[1]),t.jsx("span",{className:"bim-rd-sr",children:"》"})]},a++)),s=l.index+l[0].length;return s===0?n(e):(s<e.length&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s))},a++)),o)}function nr(e,n={}){const o=n.renderText??Kl,r=n.properNames?a=>ql(a,o):o,s=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return ut(e,r,s)}function $s(e,n,o){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))},`${o}-${a}`):t.jsx(g.Fragment,{children:n(s)},`${o}-${a}`))}const Yi=/^(#{1,6})\s+(.*)$/,xh=/^\s*<!--.*-->\s*$/;function Xl(e){return e.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
|
|
1222
|
+
`)?"":n)}function bh(e){return e<=1?2:e===2?3:4}function yh(){let e=1;return n=>{const o=bh(n),r=Math.min(o,e+1);return e=r,{Tag:`h${r}`,className:`bim-rd-hl${o}`}}}function si(e){return e?wi(Xl(e))!=="unknown":!1}function jh(e){return/^\u3000{2}/.test(e)}const Cs=e=>jh(e)?"bim-rd-noindent":void 0;function zs({text:e,mode:n,inline:o,dropTitle:r}){const s=Xl(e),a=(p,u,m)=>!!r&&m<=1&&p<=2&&u.trim()===r.trim(),l=yh();if(n==="paragraph"&&wi(s)!=="unknown"){const p=Yl(s);return t.jsx(t.Fragment,{children:p.map((u,m)=>{if(u.kind==="heading"){if(a(u.level??1,u.text,m))return null;const{Tag:h,className:f}=l(u.level??1);return t.jsx(h,{className:f,children:o(u.text)},m)}return t.jsx("p",{className:Cs(u.text),children:$s(u.text,o,m)},m)})})}const d=s.split(`
|
|
1223
|
+
`);let c=0;return t.jsx(t.Fragment,{children:d.map((p,u)=>{const m=p.match(Yi);if(m){const f=c++;if(a(m[1].length,m[2],f))return null;const{Tag:x,className:k}=l(m[1].length);return t.jsx(x,{className:k,children:o(m[2])},u)}if(!p.trim())return u>=2&&!!d[u-1].trim()&&!!d[u-2].trim()&&!Yi.test(d[u-1])&&!Yi.test(d[u-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},u):null;if(xh.test(p))return null;if(c++,/^\*\*[^*]+\*\*\s*$/.test(p.trim())){const{Tag:f,className:x}=l(3);return t.jsx(f,{className:x,children:o(p.trim().slice(2,-2))},u)}return t.jsx("p",{className:Cs(p),children:$s(p,o,u)},u)})})}function vh(e){const{convert:n}=Ie();return g.useMemo(()=>e?n(e):"",[e,n])}function ir({text:e,mode:n,tables:o=!1,gujiMarkdown:r=!1,properNames:s=!1,renderText:a,dropTitle:l}){const d=vh(e),{t:c,convert:p}=Q(),u=f=>nr(f,{renderText:a,properNames:s,gujiMarkdown:r,t:c}),m=r?{gujiMarkdown:!0,t:c}:void 0,h=l?p(l):void 0;return!o||d.indexOf(":::")<0?t.jsx(zs,{text:d,mode:n,inline:u,dropTitle:h}):t.jsx(t.Fragment,{children:Oo(d).map((f,x)=>f.type==="table"?t.jsx(Qo,{table:f.table,opts:m},x):t.jsx(zs,{text:f.text,mode:n,inline:u,dropTitle:x===0?h:void 0},x))})}function kh(e,n,o){const[r,s]=g.useState(null),[a,l]=g.useState(!1),d=g.useRef(0);return g.useEffect(()=>{const c=++d.current;if(!e||!n){s(null),l(!1);return}let p;try{p=e(n,o)}catch{s(null),l(!1);return}if(!p||typeof p.then!="function"){s(p??null),l(!1);return}l(!0),p.then(u=>{c===d.current&&s(u??null)}).catch(()=>{c===d.current&&s(null)}).finally(()=>{c===d.current&&l(!1)})},[e,n,o]),{images:r,loading:a}}const Ts={A:"fine",B:"rough",C:"rough",D:"ocr"};function wh(e){return typeof e!="string"?null:e in op?e:e in Ts?Ts[e]:null}const Sh={書:"书",類:"类",結語:"结语",結语:"结语",考證:"考证",詩:"诗"},_h={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释"},Zl="\0";function $h(e,n,o){const[r,s=""]=e.split(Zl);return t.jsxs(t.Fragment,{children:[r,t.jsx(al,{text:n,convert:o}),s]})}function gt(e){return typeof e!="string"?"":Sh[e]??_h[e]??e}const Ch=["〇","一","二","三","四","五","六","七","八","九"],Ns=["","十","百","千"],zh=["","萬","億"];function or(e){if(e===0)return"〇";if(e<0)return`負${or(-e)}`;const n=[];let o=e,r=0;for(;o>0;){const s=o%1e4;s>0?n.unshift(Th(s,r>0)+zh[r]):n.length>0&&n.unshift("〇"),o=Math.floor(o/1e4),r++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Th(e,n){const o=[];let r=e;for(;r>0;)o.unshift(r%10),r=Math.floor(r/10);let s="";for(let a=0;a<o.length;a++){const l=o[a],d=o.length-1-a;l===0?s&&!s.endsWith("〇")&&(s+="〇"):l===1&&d===1&&a===0&&!n?s+=Ns[d]:s+=Ch[l]+Ns[d]}return s.replace(/〇$/,"")}let Nn=null,qn=null;const ai=new Set;function Nh(){return Nn?Promise.resolve():qn||(qn=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});Nn=o=>n(we.normalizeVariants(o)),ai.forEach(o=>o())}).catch(()=>{Nn=e=>e,ai.forEach(e=>e())}),qn)}const Eh=e=>e;function Kt(){const[,e]=g.useState(0);return g.useEffect(()=>{if(Nn)return;const n=()=>e(o=>o+1);return ai.add(n),Nh(),()=>{ai.delete(n)}},[]),Nn??Eh}function an(e,n){return n(e).toLowerCase()}const Ih=i("highlight-bg");function Mn(e,n,o){if(!n)return e;const r=an(n,o);if(!r)return e;const s=an(e,o);if(s.length!==e.length)return e;const a=[];let l=0,d=0;for(;l<e.length;){const c=s.indexOf(r,l);if(c===-1){a.push(e.slice(l));break}c>l&&a.push(e.slice(l,c)),a.push(t.jsx("mark",{style:{background:Ih,padding:0,color:"inherit"},children:e.slice(c,c+r.length)},d++)),l=c+r.length}return t.jsx(t.Fragment,{children:a})}function rr(e,n,o,r){if(!n)return!0;const s=an(n,r);return(o?[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"&&an(l,r).includes(s))}function Rh(e,n,o){return n?an(e,o).includes(an(n,o)):!0}const sr={类:i("section-lei"),书:i("section-shu"),序:i("section-xu"),结语:i("section-jieyu"),注释:i("section-zhushi")},Lh={考证:i("section-kaozhen")};function ar(e,n,o){return e.collated.sectionType[n]??o(n)}function Jl(e){var r;const n=e.files.length,o=((r=e.children)==null?void 0:r.reduce((s,a)=>s+Jl(a),0))||0;return n+o}function Ah(e,n){const o=[],r=l=>{var d;o.push(...l.files),(d=l.children)==null||d.forEach(r)};if(r(e),o.length===0)return;const s=o.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 Ph={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function lr({enabled:e,expanded:n,onClick:o,style:r,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:o,style:{...Ph,...r},children:s}):t.jsx("span",{style:r,children:s})}function Mh({type:e}){const{convert:n,messages:o}=Q(),r=gt(e),s=sr[r]||i("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:ar(o,r,n)})}function Bh({section:e,onNavigate:n,highlightQuery:o="",no:r,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=Q(),c=Xe(),p=Kt(),u=j=>j?ut(d(j),S=>o?Mn(S,o,p):S,{t:l}):"",[m,h]=g.useState(!1),f=!!e.summary,x=!!e.comment,k=!!e.additional_comment,y=!!(e.content&&e.content.length>60),w=f||x||k||y;g.useEffect(()=>{o&&h(!0)},[o]);const b=!m&&y?Ml(e.content.replace(/\n/g," "),80)+"…":null;return t.jsxs("div",{className:"bim-rd-row",id:a,style:{borderBottom:`1px solid ${i("rule")}`,overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>w&&h(!m),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:w?"pointer":"default",userSelect:"none"},children:[r!=null&&t.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:i("label-fg")},children:r}),t.jsxs(lr,{enabled:w,expanded:m,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[w&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("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:i("fg")},children:[e.book_title?t.jsxs(t.Fragment,{children:["《",u(e.book_title),"》"]}):u(e.title),e.n_juan!=null&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:l("collated.nJuan",{n:d(or(e.n_juan))})}),(e.author_info||e.author)&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:u(e.author_info||e.author)})]}),!m&&b&&t.jsx("span",{style:{display:"block",fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:u(b)})]})]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u(e.edition)}),e.tag&&t.jsx("span",{style:{fontSize:"11px",color:i("section-tag-fg")},children:e.tag==="triangle"?"△":e.tag}),e.work_id&&n&&t.jsx("a",{href:c(e.work_id),onClick:j=>{j.metaKey||j.ctrlKey||(j.preventDefault(),j.stopPropagation(),n(e.work_id))},style:{fontSize:"11px",color:i("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:i("label-fg"),flexShrink:0},children:l("collated.unlinked")})]}),m&&w&&t.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${i("widget-border")}`,background:i("bg")},children:[e.author_info&&t.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"8px"},children:u(e.author_info)}),e.summary&&t.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:`3px solid ${i("primary")}`,background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.summary")}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:u(e.summary)})]}),e.comment&&t.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.comment")}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(e.comment)})]}),e.additional_comment&&t.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.additionalComment")}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(e.additional_comment)})]}),y&&!f&&!x&&!k&&t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(e.content)})]})]})}function Wh({section:e,highlightQuery:n=""}){const{t:o,convert:r}=Q(),s=Kt(),a=p=>p?ut(r(p),u=>n?Mn(u,n,s):u,{t:o}):"",[l,d]=g.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(lr,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(Mh,{type:e.type}),t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:a(e.title)}),c&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("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, ${sr[gt(e.type)]||i("desc-fg")} 25%, transparent)`,borderRadius:"0 4px 4px 0",background:i("bg")},children:t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:a(e.content)})})]})}const Oh=100;function cr(e){return gt(e.type)!=="page_header"?!1:(e.content||"").length>=Oh}function Hh({section:e,highlightQuery:n=""}){const{t:o,convert:r,messages:s}=Q(),a=Kt();if(gt(e.type)==="page_header"&&!cr(e)||!e.content&&!e.title)return null;const l=r((e.content||e.title||"").replace(/\n{2,}/g,`
|
|
1224
|
+
`)),d=ut(l,m=>n?Mn(m,n,a):m,{t:o}),c=gt(e.type),p=sr[c]||i("desc-fg"),u=c==="序"||c==="结语"||c==="注释";return t.jsxs("div",{style:{padding:u?"10px 12px":"6px 0",margin:u?"8px 0":void 0,fontSize:"13px",color:i("desc-fg"),lineHeight:1.8,whiteSpace:"pre-line",borderLeft:u?`3px solid ${p}40`:void 0,background:u?i("bg"):void 0,borderRadius:u?"0 4px 4px 0":void 0,position:"relative"},children:[u&&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:ar(s,c,r)}),d]})}function Fh(e,n,o){const[r,s]=g.useState({});return g.useEffect(()=>{var p;if(!n||e.length===0)return;let a=!1;const l=e.filter(u=>{var m;return!((m=o==null?void 0:o.current)!=null&&m.has(u))}),d={};for(const u of e)(p=o==null?void 0:o.current)!=null&&p.has(u)&&(d[u]=o.current.get(u));if(Object.keys(d).length>0&&s(d),l.length===0)return;const c=async u=>{var m;try{if(n.getEntry){const y=await n.getEntry(u);if(y)return{title:y.title,author:y.author}}const h=await n.getItem(u);if(!h)return null;const f=h.title||u,x=h.authors,k=(m=x==null?void 0:x[0])==null?void 0:m.name;return{title:f,author:k}}catch{return null}};return Promise.all(l.map(async u=>{var h;const m=await c(u);return(h=o==null?void 0:o.current)==null||h.set(u,m),[u,m]})).then(u=>{a||s(m=>{const h={...m};for(const[f,x]of u)h[f]=x;return h})}),()=>{a=!0}},[e.join(","),n]),r}function Dh({section:e,onNavigate:n,transport:o,workLabelCache:r,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=Q(),c=Xe(),p=Kt(),u=S=>S?ut(l(S),v=>s?Mn(v,s,p):v,{t:a}):"",[m,h]=g.useState(!1);g.useEffect(()=>{s&&h(!0)},[s]);const f=gt(e.type),x=Lh[f]||i("desc-fg"),k=!!e.content,y=e.work_ids||[],w=y.length>1,b=Fh(w?y:[],o,r),j=k&&!m&&e.content.length>80?Ml(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${i("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>k&&h(!m),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:k?"pointer":"default",userSelect:"none"},children:[t.jsxs(lr,{enabled:k,expanded:m,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[k&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("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:i("fg"),lineHeight:1.6},children:e.header_line?u(e.header_line):u(e.title)}),!m&&j&&t.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:i("desc-fg"),lineHeight:1.7},children:u(j)})]})]}),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:S=>{S.metaKey||S.ctrlKey||(S.preventDefault(),S.stopPropagation(),n(y[0]))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:a("collated.viewWork"),children:a("collated.arrowWork")}),w&&t.jsx("span",{style:{fontSize:"11px",color:i("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:ar(d,f,l)})]})]}),w&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:y.map(S=>{const v=b[S],$=v?`${l(v.title)}${v.author?`(${l(v.author)})`:""}`:S.slice(0,8)+"…";return t.jsxs("a",{href:c(S),onClick:_=>{_.metaKey||_.ctrlKey||(_.preventDefault(),_.stopPropagation(),n(S))},style:{fontSize:"12px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:S,children:["→",$]},S)})}),m&&k&&t.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${x}40`,borderRadius:"0 4px 4px 0",background:i("bg")},children:[t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(e.content)}),e.comment&&t.jsx("div",{style:{marginTop:"10px",paddingTop:"8px",borderTop:`1px solid ${i("widget-border")}`,fontSize:"12px",color:i("desc-fg"),lineHeight:1.8,fontStyle:"italic"},children:u(e.comment)})]})]})}function Uh({juan:e,searchQuery:n,onNavigate:o,transport:r,workLabelCache:s}){const{t:a}=Q(),l=Kt(),d=n.trim(),c=g.useMemo(()=>d?e.sections.filter(p=>rr(p,d,!0,l)):e.sections,[e.sections,d,l]);return t.jsxs("div",{children:[t.jsx("div",{children:c.map((p,u)=>t.jsx(Dh,{section:p,onNavigate:o,transport:r,workLabelCache:s,highlightQuery:d},u))}),c.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:a("collated.noMatch")})]})}function Vh(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function Gh({sections:e,onNavigate:n,inline:o,workLinks:r=!0}){const s=Xe(),{t:a,convert:l}=Q(),d=Vh();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const u=gt(c.type);if(u==="page_header"&&!cr(c))return null;if(u==="类")return t.jsxs(g.Fragment,{children:[g.createElement(d("类"),null,o(l(c.title))),c.content&&t.jsx("p",{children:o(l(c.content))})]},p);if(u==="书"||u==="诗"||u==="考证"||u==="注释"){const m=c.book_title?`《${c.book_title}》${c.n_juan!=null?a("collated.nJuan",{n:or(c.n_juan)}):""}`:c.title,h=o(l(m));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[g.createElement(d("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&r?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},title:a("collated.viewWork"),children:h}),t.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},"aria-label":a("collated.viewWorkOf",{title:l(m)}),children:a("collated.workArrow")})]}):h),c.author_info&&t.jsx("p",{className:"bim-rd-sub",children:o(l(c.author_info))}),c.content&&c.content.split(/\n+/).map((f,x)=>t.jsx("p",{children:o(l(f))},x)),c.summary&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.summary")}),o(l(c.summary))]}),c.comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.comment")}),o(l(c.comment))]}),c.additional_comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.additionalComment")}),o(l(c.additional_comment))]})]},p)}return c.content?t.jsx("p",{children:o(l(c.content))},p):null})})}function Ql(e){return e.some(n=>{const o=gt(n.type);return o==="书"||o==="诗"||o==="考证"||o==="注释"||o==="类"||(o==="序"||o==="结语")&&!!n.content||o==="page_header"&&cr(n)})}function Yh({juan:e,rawText:n,positionLabel:o,groupLabel:r,index:s,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c,prefs:p,view:u,onViewChange:m}){var Z;const{t:h,convert:f,messages:x}=Q(),k=Kt(),[y,w]=g.useState("text"),b=u??y,j=A=>{w(A),m==null||m(A)},S=a.trim(),v=(s==null?void 0:s.type)==="kaozhen",$=g.useCallback(A=>S?Mn(A,S,k):A,[S,k]),_=A=>nr(A,{renderText:$,properNames:p.properNames,t:h}),C=g.useMemo(()=>S?e.sections.filter(A=>rr(A,S,v,k)):e.sections,[e.sections,S,v,k]),M=(A,V)=>V.filter(pe=>gt(pe.type)===A).length,T=M("书",e.sections),z=M("诗",e.sections),F=M("考证",e.sections);let N="";v?N=S?h("collated.countTiaoOf",{m:M("考证",C),n:F}):h("collated.countTiao",{n:F}):z>0?N=S?h("collated.countPoemsOf",{m:M("诗",C),n:z}):h("collated.countPoems",{n:z}):T>0&&(N=S?h("collated.countBooksOf",{m:M("书",C),n:T}):h("collated.countBooks",{n:T}));const R=s!=null&&s.text_quality?wh(s.text_quality.grade):null,O=[];N&&O.push(N),v&&(s!=null&&s.target_source)&&O.push(t.jsx(t.Fragment,{children:h("collated.kaozhenTarget",{target:f(s.target_source)})})),R&&O.push(t.jsx("span",{title:x.collated.qualityCriteria[R],children:(Z=s==null?void 0:s.text_quality)!=null&&Z.source_note?t.jsxs(t.Fragment,{children:[$h(h("collated.baseText",{note:Zl}),s.text_quality.source_note,f),t.jsx("span",{className:"bim-rd-grade",children:x.collated.qualityLabel[R]})]}):t.jsxs(t.Fragment,{children:[h("collated.textQuality"),t.jsx("span",{className:"bim-rd-grade",children:x.collated.qualityLabel[R]})]})})),e.source_url&&O.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:h("collated.originalSource")}));const I=!v&&Ql(e.sections),P=!!n&&(!I||p.readingMode==="paragraph"&&si(n)),U=!v&&(I||!!n),K=v||!U?"entries":b;let L=0;return t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[(o||r)&&t.jsxs("p",{className:"bim-rd-kicker",children:[o,o&&r&&t.jsx("span",{className:"bim-rd-dot"}),r&&f(r)]}),t.jsx("h1",{className:"bim-rd-h1",children:f(e.title)}),O.length>0&&t.jsx("p",{className:"bim-rd-meta",children:O.map((A,V)=>t.jsxs(g.Fragment,{children:[V>0&&t.jsx("span",{className:"bim-rd-dot"}),A]},V))}),U&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":h("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":K==="text",onClick:()=>j("text"),children:h("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":K==="entries",onClick:()=>j("entries"),children:h("collated.viewEntries")})]})]}),K==="text"&&t.jsx("article",{className:"bim-rd-prose",children:P?t.jsx(ir,{text:n,mode:p.readingMode,properNames:p.properNames,renderText:$,dropTitle:e.title}):t.jsx(Gh,{sections:e.sections,onNavigate:l,inline:_,workLinks:p.workLinks})}),K==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:v?t.jsx(Uh,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[C.some(A=>["书","诗","考证"].includes(gt(A.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:h("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:h("collated.rowHeadTitle")}),t.jsx("span",{children:h("collated.rowHeadWork")})]}),C.map((A,V)=>{const pe=gt(A.type);return pe==="书"||pe==="诗"||pe==="考证"?(L+=1,t.jsx(Bh,{domId:`rd-e-${e.sections.indexOf(A)}`,section:A,onNavigate:p.workLinks?l:void 0,highlightQuery:S,no:L,showUnlinked:p.workLinks&&!!l},V)):pe==="类"?t.jsx(Wh,{section:A,highlightQuery:S},V):t.jsx(Hh,{section:A,highlightQuery:S},V)}),C.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:h("collated.noMatch")})]})})]})}function Kh(e){const{resetKey:n,load:o,files:r,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=Kt(),u=g.useRef(new Map),[m,h]=g.useState({}),[f,x]=g.useState({}),k=g.useCallback((w,b)=>{const j=b==null?void 0:b.title;j&&x(S=>S[w]===j?S:{...S,[w]:j})},[]);g.useEffect(()=>{s&&a&&(u.current.set(s,{juan:a,rawText:l}),k(s,a))},[s,a,l,k]),g.useEffect(()=>{u.current.clear(),h({}),x({})},[n]);const y=g.useCallback((w,b)=>{let j=0;if(w.juan)for(const S of w.juan.sections)rr(S,b,c,p)&&j++;return j===0&&w.rawText&&Rh(w.rawText,b,p)&&(j=1),j},[c,p]);return g.useEffect(()=>{const w=d.trim();if(!w){h({});return}if(!o||r.length===0)return;let b=!1;const j={},S=[];for(const M of r){const T=u.current.get(M);T?j[M]=y(T,w):(j[M]="loading",S.push(M))}h(j);const v=8;let $=0;const _=async()=>{for(;$<S.length;){if(b)return;const M=$++,T=S[M];try{const z=await o(T),F=z.juan;if(u.current.set(T,z),k(T,F),b)return;h(N=>({...N,[T]:y(z,w)}))}catch{if(b)return;h(z=>({...z,[T]:0}))}}},C=Array.from({length:Math.min(v,S.length)},()=>_());return Promise.all(C),()=>{b=!0}},[d,n,o,r.join(","),y,p,k]),{matchStates:m,titles:f}}function qh({juan:e,view:n,onView:o,textHasEntries:r}){const{t:s,convert:a}=Q(),l=e.sections.map((u,m)=>({s:u,i:m,t:gt(u.type)})).filter(u=>u.t==="书"||u.t==="诗");if(l.length===0)return null;const d=l.filter(u=>!!u.s.work_id).length,c=l.every(u=>u.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),p=u=>{const m=()=>{var h,f;return(f=(h=document.getElementById(`rd-e-${u}`))==null?void 0:h.scrollIntoView)==null?void 0:f.call(h,{block:"start",behavior:"smooth"})};n==="text"&&!r&&o("entries"),n==="text"&&!r?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:u,i:m})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${m}`,onClick:h=>{h.preventDefault(),p(m)},children:[t.jsx("span",{className:`bim-rd-rail-dot${u.work_id?" on":""}`,"aria-hidden":"true"}),t.jsx("span",{children:a(u.book_title||u.title)})]})},m))})]})]})}const Xh=`
|
|
1225
1225
|
attribute vec2 a_position; // 目标画布像素坐标 [0, canvasWidth] x [0, canvasHeight]
|
|
1226
1226
|
attribute vec2 a_texCoord; // 原图像素坐标 [0, imgWidth] x [0, imgHeight]
|
|
1227
1227
|
|
|
@@ -1239,7 +1239,7 @@ ${Im}`;function _n({children:e,style:n,wide:o,grid:r}){return t.jsxs("div",{clas
|
|
|
1239
1239
|
// 纹理坐标归一化 [0, 1]
|
|
1240
1240
|
v_texCoord = a_texCoord / u_imgResolution;
|
|
1241
1241
|
}
|
|
1242
|
-
`,
|
|
1242
|
+
`,Zh=`
|
|
1243
1243
|
precision mediump float;
|
|
1244
1244
|
uniform sampler2D u_image;
|
|
1245
1245
|
uniform float u_alpha;
|
|
@@ -1249,8 +1249,8 @@ ${Im}`;function _n({children:e,style:n,wide:o,grid:r}){return t.jsxs("div",{clas
|
|
|
1249
1249
|
vec4 tex = texture2D(u_image, v_texCoord);
|
|
1250
1250
|
gl_FragColor = vec4(tex.rgb, tex.a * u_alpha);
|
|
1251
1251
|
}
|
|
1252
|
-
`;function Cs(e,n,o){const r=e.createShader(n);return r?(e.shaderSource(r,o),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(console.error("Shader compile error:",e.getShaderInfoLog(r)),e.deleteShader(r),null)):null}class go{constructor(n){const o=n.getContext("webgl",{alpha:!0,antialias:!0,preserveDrawingBuffer:!0,premultipliedAlpha:!1});if(!o)throw new Error("WebGL not supported");this.gl=o;const r=Cs(o,o.VERTEX_SHADER,Gh),s=Cs(o,o.FRAGMENT_SHADER,Yh);if(!r||!s)throw new Error("Failed to create shaders");const a=o.createProgram();if(!a)throw new Error("Failed to create program");if(o.attachShader(a,r),o.attachShader(a,s),o.linkProgram(a),!o.getProgramParameter(a,o.LINK_STATUS))throw new Error("Program link error: "+o.getProgramInfoLog(a));this.program=a,this.positionBuffer=o.createBuffer(),this.texCoordBuffer=o.createBuffer(),this.uResolutionLoc=o.getUniformLocation(a,"u_resolution"),this.uImgResolutionLoc=o.getUniformLocation(a,"u_imgResolution"),this.uAlphaLoc=o.getUniformLocation(a,"u_alpha"),this.aPositionLoc=o.getAttribLocation(a,"a_position"),this.aTexCoordLoc=o.getAttribLocation(a,"a_texCoord"),o.enable(o.BLEND),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA),this.clear(n.width,n.height)}clear(n,o){const r=this.gl;r.viewport(0,0,n,o),r.clearColor(.98,.97,.95,1),r.clear(r.COLOR_BUFFER_BIT)}createTexture(n){const o=this.gl,r=o.createTexture();return o.bindTexture(o.TEXTURE_2D,r),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,n),r}renderStripsWithTexture(n,o,r,s,a,l,d=1){if(l.length===0)return;const c=this.gl;c.viewport(0,0,o,r),c.useProgram(this.program),c.uniform2f(this.uResolutionLoc,o,r),c.uniform2f(this.uImgResolutionLoc,s,a),c.uniform1f(this.uAlphaLoc,d);const p=[],u=[],m=8;for(const h of l){const f=h.colOffsetX||0,x=h.colOffsetY||0,{srcQuad:k,dstRect:y}=h.strip,[w,b,j,S]=y,v=f+w,$=x+b,[_,C,M,T]=k;for(let z=0;z<m;z++){const F=z/m,N=(z+1)/m,R=$+S*F,O=$+S*N,I=[_[0]+(T[0]-_[0])*F,_[1]+(T[1]-_[1])*F],P=[_[0]+(T[0]-_[0])*N,_[1]+(T[1]-_[1])*N],U=[C[0]+(M[0]-C[0])*F,C[1]+(M[1]-C[1])*F],K=[C[0]+(M[0]-C[0])*N,C[1]+(M[1]-C[1])*N],L=[v,R],Z=[v+j,R],A=[v,O],V=[v+j,O];p.push(L[0],L[1],Z[0],Z[1],A[0],A[1]),u.push(I[0],I[1],U[0],U[1],P[0],P[1]),p.push(Z[0],Z[1],V[0],V[1],A[0],A[1]),u.push(U[0],U[1],K[0],K[1],P[0],P[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(u),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)}}const It=new Map,Kh=24;function fo(e){let n=It.get(e);if(n)return It.delete(e),It.set(e,n),n;for(n=new Promise(o=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>{(r.decode?r.decode().catch(()=>{}):Promise.resolve()).then(()=>o(r))},r.onerror=()=>{It.delete(e),o(null)},r.src=e}),It.set(e,n);It.size>Kh;)It.delete(It.keys().next().value);return n}const ar=({imageUrl:e,pageData:n,selectedCharIds:o,hoveredCharId:r,preserveMargins:s=!1,onCharClick:a,onCharHover:l})=>{const d=g.useRef(null),c=g.useRef(null),p=g.useRef(null),u=g.useRef(null),m=g.useRef(null),h=g.useRef(null),[f,x]=g.useState(0),[k,y]=g.useState(0),w=g.useRef(""),b=g.useMemo(()=>Math.max(...n.columns.map(N=>N.warped_h),2440),[n]),j=n.total_warped_w,S=n.banxin,v=g.useMemo(()=>{var K;if(!s)return{top:0,bottom:0,left:0,right:0};const[N,R]=n.image_size||[2386,3082];let O=1/0,I=-1/0,P=1/0,U=-1/0;for(const L of n.columns)for(const Z of L.strips||[])for(const A of Z.srcQuad)A[0]<O&&(O=A[0]),A[0]>I&&(I=A[0]),A[1]<P&&(P=A[1]),A[1]>U&&(U=A[1]);if((K=n.banxin)!=null&&K.current_page_strips)for(const L of n.banxin.current_page_strips)for(const Z of L.srcQuad)Z[0]<O&&(O=Z[0]),Z[0]>I&&(I=Z[0]),Z[1]<P&&(P=Z[1]),Z[1]>U&&(U=Z[1]);return isFinite(O)||(O=0),isFinite(I)||(I=N),isFinite(P)||(P=0),isFinite(U)||(U=R),{top:Math.max(0,Math.round(P)),bottom:Math.max(0,Math.round(R-U)),left:Math.max(0,Math.round(O)),right:Math.max(0,Math.round(N-I)),rawMinX:O,rawMaxX:I,rawMinY:P,rawMaxY:U,imgW:N,imgH:R}},[n,s]),$=j+(S?S.total_w:0),_=$+v.left+v.right,C=b+v.top+v.bottom,M=g.useCallback(()=>{const N=c.current;if(!(!N||!d.current)&&!(e&&w.current!==e)){if(N.clear(_,C),s&&v.rawMinX!==void 0&&m.current&&p.current){const{rawMinX:R,rawMaxX:O,rawMinY:I,rawMaxY:P,imgW:U,imgH:K,top:L,bottom:Z,left:A,right:V}=v,ce=[];A>0&&ce.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[R,0],[R,K],[0,K]],dstRect:[0,0,A,C]}}),L>0&&ce.push({colOffsetX:A,colOffsetY:0,strip:{srcQuad:[[R,0],[O,0],[O,I],[R,I]],dstRect:[0,0,$,L]}}),Z>0&&ce.push({colOffsetX:A,colOffsetY:L+b,strip:{srcQuad:[[R,P],[O,P],[O,K],[R,K]],dstRect:[0,0,$,Z]}}),V>0&&ce.push({colOffsetX:A+$,colOffsetY:0,strip:{srcQuad:[[O,0],[U,0],[U,K],[O,K]],dstRect:[0,0,V,C]}}),N.renderStripsWithTexture(m.current,_,C,n.image_size[0],n.image_size[1],ce,1)}if(m.current&&p.current){const R=n.columns.flatMap(O=>(O.strips||[]).map(I=>({colOffsetX:v.left+O.offset_x,colOffsetY:v.top,strip:I})));if(R.length>0?N.renderStripsWithTexture(m.current,_,C,n.image_size[0],n.image_size[1],R,1):N.renderStripsWithTexture(m.current,_,C,n.image_size[0],n.image_size[1],[{colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[n.image_size[0],0],[n.image_size[0],n.image_size[1]],[0,n.image_size[1]]],dstRect:[0,0,_,C]}}],1),S&&S.current_page_strips.length>0){const O=S.current_page_strips.map(I=>({colOffsetX:v.left+j,colOffsetY:v.top,strip:I}));N.renderStripsWithTexture(m.current,_,C,n.image_size[0],n.image_size[1],O,1)}}if(S&&h.current&&u.current&&S.mate_page_strips.length>0){const R=S.mate_page_strips.map(O=>({colOffsetX:v.left+j+S.half_w,colOffsetY:v.top,strip:O}));N.renderStripsWithTexture(h.current,_,C,S.mate_img_size[0],S.mate_img_size[1],R,.65)}}},[e,n,S,_,C,j,b,$,v,s]),T=g.useRef(M);T.current=M,g.useEffect(()=>{const N=d.current;if(!N)return;const R=P=>{m.current=p.current?P.createTexture(p.current):null,h.current=u.current?P.createTexture(u.current):null,T.current()};try{const P=new go(N);c.current=P,R(P)}catch(P){console.error("Failed to init WebGL renderer:",P)}const O=P=>{P.preventDefault(),console.warn("WebGL context lost")},I=()=>{console.info("WebGL context restored, re-initializing..."),d.current&&(c.current=new go(d.current),R(c.current))};return N.addEventListener("webglcontextlost",O,!1),N.addEventListener("webglcontextrestored",I,!1),()=>{N.removeEventListener("webglcontextlost",O),N.removeEventListener("webglcontextrestored",I),c.current&&(c.current.deleteTexture(m.current),c.current.deleteTexture(h.current),c.current.destroy(),c.current=null)}},[]),g.useEffect(()=>{if(!e)return;let N=!0;return fo(e).then(R=>{if(!N||!R)return;p.current=R,w.current=e;const O=c.current;O&&(O.deleteTexture(m.current),m.current=O.createTexture(R)),x(I=>I+1)}),()=>{N=!1}},[e]);const z=S==null?void 0:S.mate_image_url;g.useEffect(()=>{if(!z)return;let N=!0;return fo(z).then(R=>{if(!N||!R)return;u.current=R;const O=c.current;O&&(O.deleteTexture(h.current),h.current=O.createTexture(R)),y(I=>I+1)}),()=>{N=!1}},[z]),g.useEffect(()=>{M()},[M,f,k]);const F=g.useMemo(()=>{const N=[];for(const R of n.columns)for(const O of R.chars){const[I,P,U,K]=O.bbox_col;N.push({id:O.id,char:O.char,x:v.left+R.offset_x+I,y:v.top+P,w:Math.max(U-I,1),h:Math.max(K-P,1)})}return N},[n,v]);return t.jsxs("div",{className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${_} / ${C}`,backgroundColor:i("warp-bg"),boxShadow:i("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("canvas",{ref:d,width:_,height:C,style:{width:"100%",height:"100%",display:"block",backgroundColor:i("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${_} ${C}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[F.map(N=>{const R=o.has(N.id),O=r===N.id;return t.jsx("rect",{"data-selected":R?"true":void 0,x:N.x,y:N.y,width:N.w,height:N.h,fill:R?i("warp-sel-bg"):O?i("warp-hover-bg"):"transparent",stroke:R?i("warp-sel-stroke"):O?i("warp-hover-stroke"):"transparent",strokeWidth:R?3.5:O?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>a==null?void 0:a(N.id),onMouseEnter:()=>l==null?void 0:l(N.id),onMouseLeave:()=>l==null?void 0:l(null),children:t.jsx("title",{children:N.char})},N.id)}),S&&t.jsxs("g",{children:[t.jsx("line",{x1:v.left+j,y1:v.top,x2:v.left+j,y2:v.top+b,stroke:i("warp-banxin-border"),strokeWidth:1.5}),t.jsx("line",{x1:v.left+j+S.half_w,y1:v.top,x2:v.left+j+S.half_w,y2:v.top+b,stroke:i("warp-banxin-fold"),strokeWidth:1.5,strokeDasharray:"8 6"}),t.jsx("line",{x1:v.left+$,y1:v.top,x2:v.left+$,y2:v.top+b,stroke:i("warp-banxin-outer"),strokeWidth:1})]})]})]})},qh={work:"work",book:"work",people:"person",person:"person",place:"place",office:"office",dynasty:"dynasty"};function Xh(e){return typeof e=="string"&&qh[e]||"other"}function xo(e){if(!e)return null;const n=e.trim(),o=/^book-index:\/\/(?:[A-Za-z]+\/)*([0-9A-Za-z]+)\/?$/.exec(n);if(o)return o[1];const r=/^bid:\\{1,2}([0-9A-Za-z]+)$/.exec(n);return r?r[1]:/^[0-9A-Za-z]+$/.test(n)?n:null}function jn(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Rt(e){return typeof e=="string"&&e?e:void 0}function Xl(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.entities)?e.entities:[],o=[];return n.forEach((r,s)=>{if(!r||typeof r!="object")return;const a=r,l=a.span??{},d=a.target??{},c=jn(l.start_offset)??jn(a.start_offset),p=jn(l.end_offset)??jn(a.end_offset);if(c===void 0||p===void 0||c<0||p<=c)return;const u=Rt(d.status),m=u===void 0||u==="matched"?xo(Rt(d.entity_id))??xo(Rt(d.href))??void 0:void 0,h=a.anchor??{},f=Rt(h.start),x=Rt(h.end);o.push({...f&&x?{anchor:{start:f,end:x}}:{},key:Rt(a.id)??`e${s}`,kind:Xh(a.type),start:c,end:p,text:Rt(a.text),targetId:m,canonicalName:Rt(d.canonical_name),confidence:jn(a.confidence)})}),o.sort((r,s)=>r.start-s.start||s.end-r.end)}const Zh=new Set(Array.from(`《》/<>\r
|
|
1253
|
-
,。、;:?!「」『』()…—·`));function
|
|
1252
|
+
`;function Es(e,n,o){const r=e.createShader(n);return r?(e.shaderSource(r,o),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(console.error("Shader compile error:",e.getShaderInfoLog(r)),e.deleteShader(r),null)):null}class bo{constructor(n){const o=n.getContext("webgl",{alpha:!0,antialias:!0,preserveDrawingBuffer:!0,premultipliedAlpha:!1});if(!o)throw new Error("WebGL not supported");this.gl=o;const r=Es(o,o.VERTEX_SHADER,Xh),s=Es(o,o.FRAGMENT_SHADER,Zh);if(!r||!s)throw new Error("Failed to create shaders");const a=o.createProgram();if(!a)throw new Error("Failed to create program");if(o.attachShader(a,r),o.attachShader(a,s),o.linkProgram(a),!o.getProgramParameter(a,o.LINK_STATUS))throw new Error("Program link error: "+o.getProgramInfoLog(a));this.program=a,this.positionBuffer=o.createBuffer(),this.texCoordBuffer=o.createBuffer(),this.uResolutionLoc=o.getUniformLocation(a,"u_resolution"),this.uImgResolutionLoc=o.getUniformLocation(a,"u_imgResolution"),this.uAlphaLoc=o.getUniformLocation(a,"u_alpha"),this.aPositionLoc=o.getAttribLocation(a,"a_position"),this.aTexCoordLoc=o.getAttribLocation(a,"a_texCoord"),o.enable(o.BLEND),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA),this.clear(n.width,n.height)}clear(n,o){const r=this.gl;r.viewport(0,0,n,o),r.clearColor(.98,.97,.95,1),r.clear(r.COLOR_BUFFER_BIT)}createTexture(n){const o=this.gl,r=o.createTexture();return o.bindTexture(o.TEXTURE_2D,r),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,n),r}renderStripsWithTexture(n,o,r,s,a,l,d=1){if(l.length===0)return;const c=this.gl;c.viewport(0,0,o,r),c.useProgram(this.program),c.uniform2f(this.uResolutionLoc,o,r),c.uniform2f(this.uImgResolutionLoc,s,a),c.uniform1f(this.uAlphaLoc,d);const p=[],u=[],m=8;for(const h of l){const f=h.colOffsetX||0,x=h.colOffsetY||0,{srcQuad:k,dstRect:y}=h.strip,[w,b,j,S]=y,v=f+w,$=x+b,[_,C,M,T]=k;for(let z=0;z<m;z++){const F=z/m,N=(z+1)/m,R=$+S*F,O=$+S*N,I=[_[0]+(T[0]-_[0])*F,_[1]+(T[1]-_[1])*F],P=[_[0]+(T[0]-_[0])*N,_[1]+(T[1]-_[1])*N],U=[C[0]+(M[0]-C[0])*F,C[1]+(M[1]-C[1])*F],K=[C[0]+(M[0]-C[0])*N,C[1]+(M[1]-C[1])*N],L=[v,R],Z=[v+j,R],A=[v,O],V=[v+j,O];p.push(L[0],L[1],Z[0],Z[1],A[0],A[1]),u.push(I[0],I[1],U[0],U[1],P[0],P[1]),p.push(Z[0],Z[1],V[0],V[1],A[0],A[1]),u.push(U[0],U[1],K[0],K[1],P[0],P[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(u),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)}}const Et=new Map,Jh=24;function yo(e){let n=Et.get(e);if(n)return Et.delete(e),Et.set(e,n),n;for(n=new Promise(o=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>{(r.decode?r.decode().catch(()=>{}):Promise.resolve()).then(()=>o(r))},r.onerror=()=>{Et.delete(e),o(null)},r.src=e}),Et.set(e,n);Et.size>Jh;)Et.delete(Et.keys().next().value);return n}const dr=({imageUrl:e,pageData:n,selectedCharIds:o,hoveredCharId:r,preserveMargins:s=!1,onCharClick:a,onCharHover:l})=>{const d=g.useRef(null),c=g.useRef(null),p=g.useRef(null),u=g.useRef(null),m=g.useRef(null),h=g.useRef(null),[f,x]=g.useState(0),[k,y]=g.useState(0),w=g.useRef(""),b=g.useMemo(()=>Math.max(...n.columns.map(N=>N.warped_h),2440),[n]),j=n.total_warped_w,S=n.banxin,v=g.useMemo(()=>{var K;if(!s)return{top:0,bottom:0,left:0,right:0};const[N,R]=n.image_size||[2386,3082];let O=1/0,I=-1/0,P=1/0,U=-1/0;for(const L of n.columns)for(const Z of L.strips||[])for(const A of Z.srcQuad)A[0]<O&&(O=A[0]),A[0]>I&&(I=A[0]),A[1]<P&&(P=A[1]),A[1]>U&&(U=A[1]);if((K=n.banxin)!=null&&K.current_page_strips)for(const L of n.banxin.current_page_strips)for(const Z of L.srcQuad)Z[0]<O&&(O=Z[0]),Z[0]>I&&(I=Z[0]),Z[1]<P&&(P=Z[1]),Z[1]>U&&(U=Z[1]);return isFinite(O)||(O=0),isFinite(I)||(I=N),isFinite(P)||(P=0),isFinite(U)||(U=R),{top:Math.max(0,Math.round(P)),bottom:Math.max(0,Math.round(R-U)),left:Math.max(0,Math.round(O)),right:Math.max(0,Math.round(N-I)),rawMinX:O,rawMaxX:I,rawMinY:P,rawMaxY:U,imgW:N,imgH:R}},[n,s]),$=j+(S?S.total_w:0),_=$+v.left+v.right,C=b+v.top+v.bottom,M=g.useCallback(()=>{const N=c.current;if(!(!N||!d.current)&&!(e&&w.current!==e)){if(N.clear(_,C),s&&v.rawMinX!==void 0&&m.current&&p.current){const{rawMinX:R,rawMaxX:O,rawMinY:I,rawMaxY:P,imgW:U,imgH:K,top:L,bottom:Z,left:A,right:V}=v,pe=[];A>0&&pe.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[R,0],[R,K],[0,K]],dstRect:[0,0,A,C]}}),L>0&&pe.push({colOffsetX:A,colOffsetY:0,strip:{srcQuad:[[R,0],[O,0],[O,I],[R,I]],dstRect:[0,0,$,L]}}),Z>0&&pe.push({colOffsetX:A,colOffsetY:L+b,strip:{srcQuad:[[R,P],[O,P],[O,K],[R,K]],dstRect:[0,0,$,Z]}}),V>0&&pe.push({colOffsetX:A+$,colOffsetY:0,strip:{srcQuad:[[O,0],[U,0],[U,K],[O,K]],dstRect:[0,0,V,C]}}),N.renderStripsWithTexture(m.current,_,C,n.image_size[0],n.image_size[1],pe,1)}if(m.current&&p.current){const R=n.columns.flatMap(O=>(O.strips||[]).map(I=>({colOffsetX:v.left+O.offset_x,colOffsetY:v.top,strip:I})));if(R.length>0?N.renderStripsWithTexture(m.current,_,C,n.image_size[0],n.image_size[1],R,1):N.renderStripsWithTexture(m.current,_,C,n.image_size[0],n.image_size[1],[{colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[n.image_size[0],0],[n.image_size[0],n.image_size[1]],[0,n.image_size[1]]],dstRect:[0,0,_,C]}}],1),S&&S.current_page_strips.length>0){const O=S.current_page_strips.map(I=>({colOffsetX:v.left+j,colOffsetY:v.top,strip:I}));N.renderStripsWithTexture(m.current,_,C,n.image_size[0],n.image_size[1],O,1)}}if(S&&h.current&&u.current&&S.mate_page_strips.length>0){const R=S.mate_page_strips.map(O=>({colOffsetX:v.left+j+S.half_w,colOffsetY:v.top,strip:O}));N.renderStripsWithTexture(h.current,_,C,S.mate_img_size[0],S.mate_img_size[1],R,.65)}}},[e,n,S,_,C,j,b,$,v,s]),T=g.useRef(M);T.current=M,g.useEffect(()=>{const N=d.current;if(!N)return;const R=P=>{m.current=p.current?P.createTexture(p.current):null,h.current=u.current?P.createTexture(u.current):null,T.current()};try{const P=new bo(N);c.current=P,R(P)}catch(P){console.error("Failed to init WebGL renderer:",P)}const O=P=>{P.preventDefault(),console.warn("WebGL context lost")},I=()=>{console.info("WebGL context restored, re-initializing..."),d.current&&(c.current=new bo(d.current),R(c.current))};return N.addEventListener("webglcontextlost",O,!1),N.addEventListener("webglcontextrestored",I,!1),()=>{N.removeEventListener("webglcontextlost",O),N.removeEventListener("webglcontextrestored",I),c.current&&(c.current.deleteTexture(m.current),c.current.deleteTexture(h.current),c.current.destroy(),c.current=null)}},[]),g.useEffect(()=>{if(!e)return;let N=!0;return yo(e).then(R=>{if(!N||!R)return;p.current=R,w.current=e;const O=c.current;O&&(O.deleteTexture(m.current),m.current=O.createTexture(R)),x(I=>I+1)}),()=>{N=!1}},[e]);const z=S==null?void 0:S.mate_image_url;g.useEffect(()=>{if(!z)return;let N=!0;return yo(z).then(R=>{if(!N||!R)return;u.current=R;const O=c.current;O&&(O.deleteTexture(h.current),h.current=O.createTexture(R)),y(I=>I+1)}),()=>{N=!1}},[z]),g.useEffect(()=>{M()},[M,f,k]);const F=g.useMemo(()=>{const N=[];for(const R of n.columns)for(const O of R.chars){const[I,P,U,K]=O.bbox_col;N.push({id:O.id,char:O.char,x:v.left+R.offset_x+I,y:v.top+P,w:Math.max(U-I,1),h:Math.max(K-P,1)})}return N},[n,v]);return t.jsxs("div",{className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${_} / ${C}`,backgroundColor:i("warp-bg"),boxShadow:i("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("canvas",{ref:d,width:_,height:C,style:{width:"100%",height:"100%",display:"block",backgroundColor:i("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${_} ${C}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[F.map(N=>{const R=o.has(N.id),O=r===N.id;return t.jsx("rect",{"data-selected":R?"true":void 0,x:N.x,y:N.y,width:N.w,height:N.h,fill:R?i("warp-sel-bg"):O?i("warp-hover-bg"):"transparent",stroke:R?i("warp-sel-stroke"):O?i("warp-hover-stroke"):"transparent",strokeWidth:R?3.5:O?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>a==null?void 0:a(N.id),onMouseEnter:()=>l==null?void 0:l(N.id),onMouseLeave:()=>l==null?void 0:l(null),children:t.jsx("title",{children:N.char})},N.id)}),S&&t.jsxs("g",{children:[t.jsx("line",{x1:v.left+j,y1:v.top,x2:v.left+j,y2:v.top+b,stroke:i("warp-banxin-border"),strokeWidth:1.5}),t.jsx("line",{x1:v.left+j+S.half_w,y1:v.top,x2:v.left+j+S.half_w,y2:v.top+b,stroke:i("warp-banxin-fold"),strokeWidth:1.5,strokeDasharray:"8 6"}),t.jsx("line",{x1:v.left+$,y1:v.top,x2:v.left+$,y2:v.top+b,stroke:i("warp-banxin-outer"),strokeWidth:1})]})]})]})},Qh={work:"work",book:"work",people:"person",person:"person",place:"place",office:"office",dynasty:"dynasty"};function eg(e){return typeof e=="string"&&Qh[e]||"other"}function jo(e){if(!e)return null;const n=e.trim(),o=/^book-index:\/\/(?:[A-Za-z]+\/)*([0-9A-Za-z]+)\/?$/.exec(n);if(o)return o[1];const r=/^bid:\\{1,2}([0-9A-Za-z]+)$/.exec(n);return r?r[1]:/^[0-9A-Za-z]+$/.test(n)?n:null}function vn(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function It(e){return typeof e=="string"&&e?e:void 0}function ec(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.entities)?e.entities:[],o=[];return n.forEach((r,s)=>{if(!r||typeof r!="object")return;const a=r,l=a.span??{},d=a.target??{},c=vn(l.start_offset)??vn(a.start_offset),p=vn(l.end_offset)??vn(a.end_offset);if(c===void 0||p===void 0||c<0||p<=c)return;const u=It(d.status),m=u===void 0||u==="matched"?jo(It(d.entity_id))??jo(It(d.href))??void 0:void 0,h=a.anchor??{},f=It(h.start),x=It(h.end);o.push({...f&&x?{anchor:{start:f,end:x}}:{},key:It(a.id)??`e${s}`,kind:eg(a.type),start:c,end:p,text:It(a.text),targetId:m,canonicalName:It(d.canonical_name),confidence:vn(a.confidence)})}),o.sort((r,s)=>r.start-s.start||s.end-r.end)}const tg=new Set(Array.from(`《》/<>\r
|
|
1253
|
+
,。、;:?!「」『』()…—·`));function pr(e){return!tg.has(e)}function tc(e,n,o=0){const r=[],s=Array.from(e);let a=0;for(const d of s)pr(d)&&r.push(a),a+=d.length;const l=[];for(const d of n){const c=d.start-o,p=d.end-o;if(c<0||p>r.length||p<=c)continue;const u=r[p-1],m=e.codePointAt(u)>65535?2:1;l.push({...d,start:r[c],end:u+m})}return l}function ng(e,n){return n.text?Array.from(e.slice(n.start,n.end)).filter(pr).join("")===n.text:!0}function ig(e,n,o){if(!n.text)return null;let r=-1,s=Math.max(0,n.start-o);const a=n.start+o;for(;s<=a;){const l=e.indexOf(n.text,s);if(l<0||l>a)break;(r<0||Math.abs(l-n.start)<Math.abs(r-n.start))&&(r=l),s=l+1}return r<0?null:{...n,start:r,end:r+n.text.length}}function nc(e,n,o=16){const r=[];for(const l of n){let d={...l,start:Math.max(0,l.start),end:Math.min(e.length,l.end)};(d.end<=d.start||!ng(e,d))&&(d=ig(e,l,o)),d&&r.push(d)}r.sort((l,d)=>l.start-d.start||d.end-l.end);const s=[];let a=0;for(const l of r)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 ur=`
|
|
1254
1254
|
.bim-et-w { position: relative; display: inline; }
|
|
1255
1255
|
.bim-et {
|
|
1256
1256
|
color: inherit; text-decoration-line: underline;
|
|
@@ -1290,13 +1290,15 @@ a.bim-et:focus-visible { outline: 2px solid ${i("accent")}; outline-offset: 2px;
|
|
|
1290
1290
|
.bim-et-card { animation: bim-et-in 120ms ease-out; }
|
|
1291
1291
|
@keyframes bim-et-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
|
|
1292
1292
|
}
|
|
1293
|
-
`,eg=120;function lt(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function tg(e,n=eg){if(!e)return;const o=e.replace(/\s+/g," ").trim(),r=Array.from(o);return r.length>n?r.slice(0,n).join("")+"…":o}function ng(e){const n=typeof e.birth_year=="number"?e.birth_year:void 0,o=typeof e.death_year=="number"?e.death_year:void 0;if(!(n===void 0&&o===void 0))return`${n??"?"}–${o??"?"}`}function ig(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(o=>{if(!o||typeof o!="object")return"";const r=o,s=lt(r.name);return s?[lt(r.dynasty)&&`〔${lt(r.dynasty)}〕`,s,lt(r.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function Ql(e,n){const o=lt(n.type),r=lt(n.primary_name)??lt(n.title)??e,s=o==="entity"?[lt(n.dynasty),ng(n),lt(n.native_place)].filter(Boolean).join(" · "):[ig(n),lt(n.edition),lt(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?lt(n.description.text):lt(n.description);return{id:e,type:o,title:r,meta:s||void 0,description:tg(a)}}function ec(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 tc(e){return async n=>{const o=await e.getItem(n);if(o)return Ql(n,o);if(e.getEntry){const r=await e.getEntry(n);if(r)return ec(r)}return null}}const zs=new WeakMap;function og(e,n,o){let r=zs.get(e);r||(r=new Map,zs.set(e,r));const s=r.get(o);if(s)return s;const a=n(o);return r.set(o,a),a.catch(()=>r.delete(o)),a}const nc=e=>`/item/${encodeURIComponent(e)}`,rg={work:"書名",person:"人名",place:"地名",office:"官職",dynasty:"朝代",other:"專名"},sg=typeof window>"u"?g.useEffect:g.useLayoutEffect;function dr(e,n){return g.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:tc(e)}:null,[n,e])}const ag=e=>e,lg=({text:e,entities:n,offsets:o="text",plainBase:r=0,transport:s,loadSummary:a,buildHref:l=nc,onNavigate:d,renderText:c=ag,hoverDelayMs:p=250,injectStyles:u=!0,className:m})=>{const h=g.useMemo(()=>{const x=o==="plain"?Zl(e,n,r):n;return Jl(e,x)},[e,n,o,r]),f=dr(s,a);return t.jsxs("span",{className:m?`bim-et-root ${m}`:"bim-et-root",children:[u&&t.jsx("style",{children:cr}),h.map(x=>x.type==="text"?t.jsx(g.Fragment,{children:c(x.text)},`t${x.start}`):t.jsx(pr,{span:x.span,label:x.text,hasBrackets:e[x.start-1]==="《"&&e[x.start+x.text.length]==="》",loader:f,buildHref:l,onNavigate:d,renderText:c,hoverDelayMs:p},`${x.span.key}@${x.start}`))]})},pr=({span:e,label:n,hasBrackets:o,loader:r,buildHref:s,onNavigate:a,renderText:l,hoverDelayMs:d})=>{const c=g.useId(),[p,u]=g.useState(!1),m=g.useRef(null),h=`bim-et bim-et-${e.kind}`,f=e.kind==="work"&&!o,x=t.jsxs(t.Fragment,{children:[f&&t.jsx("span",{className:"bim-et-sr",children:"《"}),l(n),f&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),k=()=>{m.current&&(clearTimeout(m.current),m.current=null)};g.useEffect(()=>k,[]);const y=g.useCallback(j=>{k(),j<=0?u(!0):m.current=setTimeout(()=>u(!0),j)},[]),w=g.useCallback(()=>{k(),u(!1)},[]);if(!e.targetId)return t.jsx("span",{className:h,children:x});const b=e.targetId;return t.jsxs("span",{className:"bim-et-w",onMouseEnter:()=>y(d),onMouseLeave:w,onKeyDown:j=>{j.key==="Escape"&&p&&(j.stopPropagation(),w())},children:[t.jsx("a",{className:h,href:s(b),"data-entity-id":b,"aria-describedby":p?c:void 0,onFocus:()=>y(0),onBlur:w,onClick:a?j=>a(b,j):void 0,children:x}),p&&t.jsx(cg,{id:c,entityId:b,span:e,loader:r})]})},cg=({id:e,entityId:n,span:o,loader:r})=>{const{convert:s}=J(),a=g.useRef(null),[l,d]=g.useState("start"),[c,p]=g.useState(r?{status:"loading"}:{status:"ready",summary:null});g.useEffect(()=>{if(!r)return;let h=!1;return p({status:"loading"}),og(r.owner,r.load,n).then(f=>{h||p({status:"ready",summary:f})}).catch(()=>{h||p({status:"error"})}),()=>{h=!0}},[r,n]),sg(()=>{const h=a.current;if(!h||typeof window>"u")return;const f=h.getBoundingClientRect(),x=document.documentElement.clientWidth||window.innerWidth;f.right>x-8&&l==="start"&&d("end")},[c,l]);const u=c.status==="ready"?c.summary:null,m=(u==null?void 0:u.title)??o.canonicalName??o.text;return t.jsxs("span",{ref:a,id:e,role:"tooltip",className:"bim-et-card","data-align":l,children:[t.jsx("span",{className:"bim-et-card-k",children:s(rg[o.kind])}),m&&t.jsx("span",{className:"bim-et-card-t",children:s(m)}),(u==null?void 0:u.meta)&&t.jsx("span",{className:"bim-et-card-m",children:s(u.meta)}),(u==null?void 0:u.description)&&t.jsx("span",{className:"bim-et-card-d",children:s(u.description)}),c.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:s("載入中…")}),c.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:s("摘要載入失敗")})]})},dg=e=>`/item/${encodeURIComponent(e)}`;function pg(e){const n=e.filter(o=>o.kind!=="break");return{before:n.filter(o=>o.pos==="before"),after:n.filter(o=>o.pos!=="before")}}function ug(e,n){const o=[];for(const r of e){const s=n.get(r.charData.id)??null,a=o[o.length-1];a&&a.entity===s?a.chars.push(r):o.push({entity:s,chars:[r]})}return o}const ur=({pageData:e,pages:n,punctuations:o=hg,selectedCharIds:r,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:u,convert:m,scrollToPage:h,entities:f,entityTransport:x,loadEntitySummary:k,buildEntityHref:y,onEntityNavigate:w})=>{const b=g.useRef(null),j=g.useRef(0),S=g.useMemo(()=>{const I=new Map;return p&&o.forEach((P,U)=>{const K=P.id?P:{...P,id:`${P.anchor}#${U}`},L=I.get(K.anchor)||[];L.push(K),I.set(K.anchor,L)}),I},[o,p]),v=g.useMemo(()=>(n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}]).filter(P=>P.columns.some(U=>U.chars.length>0)).map(P=>{const U=[...P.columns].sort((Z,A)=>Z.col-A.col),K=[];let L=[];for(const Z of U)for(const A of Z.chars){const{before:V,after:ce}=pg(S.get(A.id)||[]),ne=(S.get(A.id)||[]).some(de=>de.kind==="break");L.push({charData:A,col:Z.col,beforePuncts:V,afterPuncts:ce}),ne&&(K.push({id:`para-p${P.page}-${K.length}`,chars:L}),L=[])}return L.length>0&&K.push({id:`para-p${P.page}-${K.length}`,chars:L}),{page:P.page,paragraphs:K}}),[n,e,S]),$=g.useMemo(()=>{const I=[];for(const P of v)for(const U of P.paragraphs)for(const K of U.chars)I.push(K.charData.id);return I},[v]),_=g.useMemo(()=>{const I=new Map;if(!f||f.length===0)return I;const P=new Map($.map((U,K)=>[U,K]));for(const U of f){if(!U.anchor)continue;const K=P.get(U.anchor.start),L=P.get(U.anchor.end);if(!(K===void 0||L===void 0||L<K))for(let Z=K;Z<=L;Z++)I.has($[Z])||I.set($[Z],U)}return I},[f,$]),C=dr(x,k),M=_.size>0,T=g.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:u,onEntityNavigate:w});T.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:u,onEntityNavigate:w};const z=g.useMemo(()=>({click:I=>{var P,U;j.current=Date.now()+1200,(U=(P=T.current).onCharClick)==null||U.call(P,I)},enter:I=>{var P,U;return(U=(P=T.current).onCharHover)==null?void 0:U.call(P,I)},leave:()=>{var I,P;return(P=(I=T.current).onCharHover)==null?void 0:P.call(I,null)},navigate:(I,P)=>{var K,L;if(!(P.detail===0||P.ctrlKey||P.metaKey||P.shiftKey)){P.preventDefault();return}(L=(K=T.current).onEntityNavigate)==null||L.call(K,I,P)}}),[]),F=gg(r),N=g.useRef(null);g.useEffect(()=>{var P,U;if((P=N.current)==null||P.classList.remove("is-hovered"),N.current=null,!s)return;const I=(U=b.current)==null?void 0:U.querySelector(`span[data-char-id="${s}"]`);I&&(I.classList.add("is-hovered"),N.current=I)},[s]),g.useEffect(()=>{let I=null;const P=()=>{var ie,Le;I=null;const K=window.getSelection(),L=b.current;if(!K||K.isCollapsed||K.rangeCount===0||!L)return;const Z=K.getRangeAt(0),A=Z.commonAncestorContainer,V=A.nodeType===3?A.parentElement:A;if(!V||!L.contains(V))return;const ce=L.querySelectorAll("span[data-char-id]");let ne=0,de=ce.length;for(;ne<de;){const Ae=ne+de>>1;Z.comparePoint(ce[Ae],0)<0?ne=Ae+1:de=Ae}const pe=ne;for(de=ce.length;ne<de;){const Ae=ne+de>>1;Z.comparePoint(ce[Ae],0)<=0?ne=Ae+1:de=Ae}const be=ne-1;if(be<pe)return;const Oe=[];for(let Ae=pe;Ae<=be;Ae++)Oe.push(ce[Ae].getAttribute("data-char-id"));Oe.length>0&&(j.current=Date.now()+1200,(Le=(ie=T.current).onSelectionChange)==null||Le.call(ie,Oe))},U=()=>{I&&clearTimeout(I),I=setTimeout(P,120)};return document.addEventListener("selectionchange",U),()=>{document.removeEventListener("selectionchange",U),I&&clearTimeout(I)}},[]),g.useEffect(()=>{var I;if(r.size===1){const P=Array.from(r)[0],U=(I=b.current)==null?void 0:I.querySelector(`span[data-char-id="${P}"]`);U&&U.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[r]);const R=h==null?void 0:h.nonce;g.useEffect(()=>{var P;if(!h)return;const I=(P=b.current)==null?void 0:P.querySelector(`[data-page-section="${h.page}"]`);I&&(j.current=Date.now()+800,I.scrollIntoView({behavior:"auto",block:"start"}))},[R]);const O=!!u;return g.useEffect(()=>{var Z;if(!O)return;const I=Array.from(((Z=b.current)==null?void 0:Z.querySelectorAll("[data-page-section]"))??[]);if(I.length===0)return;const P=120;let U=0;const K=()=>{var ne,de;if(U=0,Date.now()<j.current)return;let A=0,V=I.length-1;for(;A<V;){const pe=A+V+1>>1;I[pe].getBoundingClientRect().top<=P?A=pe:V=pe-1}const ce=parseInt(I[A].getAttribute("data-page-section")||"",10);isNaN(ce)||(de=(ne=T.current).onVisiblePageChange)==null||de.call(ne,ce)},L=()=>{U||(U=requestAnimationFrame(K))};return window.addEventListener("scroll",L,{passive:!0}),K(),()=>{window.removeEventListener("scroll",L),U&&cancelAnimationFrame(U)}},[O,v]),t.jsxs("div",{ref:b,className:"guji-text-pane-content",children:[M&&t.jsx("style",{children:cr}),t.jsx("div",{className:"guji-text-reflow-view",children:v.map((I,P)=>t.jsx(xg,{pGroup:I,first:P===0,selected:F.get(I.page)??mg,entityOfChar:_,entityLoader:C,convert:m,buildHref:y??dg,handlers:z},`page-sec-${I.page}`))})]})},mg=new Set,hg=[];function gg(e){const n=g.useRef(new Map);return g.useMemo(()=>{const o=new Map;e.forEach(s=>{const a=parseInt(s.split(":")[0],10);let l=o.get(a);l||o.set(a,l=new Set),l.add(s)});const r=new Map;return o.forEach((s,a)=>{const l=n.current.get(a),d=l&&l.size===s.size&&Array.from(s).every(c=>l.has(c));r.set(a,d?l:s)}),n.current=r,r},[e])}function fg(e,n){const o=Array.from(n(e.join("")));return o.length===e.length&&e.every(r=>Array.from(r).length===1)?o:e.map(r=>n(r))}const xg=g.memo(function({pGroup:n,first:o,selected:r,entityOfChar:s,entityLoader:a,convert:l,buildHref:d,handlers:c}){const p=g.useMemo(()=>{const m=new Map;if(!l)return m;for(const h of n.paragraphs){const f=fg(h.chars.map(x=>x.charData.char),l);h.chars.forEach((x,k)=>m.set(x.charData.id,f[k]))}return m},[n,l]),u=m=>p.get(m.id)??m.char;return t.jsxs("section",{"data-page-section":n.page,className:"guji-page-section",style:{position:"relative",scrollMarginTop:96},children:[!o&&t.jsxs("div",{className:"guji-page-divider",style:{display:"flex",alignItems:"center",margin:"2rem 0 1.2rem",color:i("meta-fg"),fontSize:"0.82rem",letterSpacing:"0.08em",userSelect:"none"},children:[t.jsx("div",{style:{flex:1,height:"1px",background:i("rule")}}),t.jsxs("span",{style:{padding:"0 12px",fontWeight:500},children:["第 ",n.page," 葉"]}),t.jsx("div",{style:{flex:1,height:"1px",background:i("rule")}})]}),n.paragraphs.map(m=>t.jsx("p",{className:"guji-reflow-paragraph",children:ug(m.chars,s).map((h,f)=>{const x=h.chars.map(({charData:w,col:b,beforePuncts:j,afterPuncts:S},v)=>{const $=!!h.entity&&v===0,_=!!h.entity&&v===h.chars.length-1,C=$?[]:j,M=_?[]:S;return t.jsxs(g.Fragment,{children:[C.map(T=>t.jsx("span",{className:"guji-text-punct","data-punct-id":T.id,children:T.mark},T.id)),t.jsx("span",{"data-char-id":w.id,onClick:()=>c.click(w.id),onMouseEnter:()=>c.enter(w.id),onMouseLeave:c.leave,className:`guji-text-char${r.has(w.id)?" is-selected":""}${w.sub?" is-sub":""}`,title:`[第${n.page}葉·第${b}列·第${w.slot||w.pos}字] ${u(w)}`,children:u(w)}),M.map(T=>t.jsx("span",{className:"guji-text-punct","data-punct-id":T.id,children:T.mark},T.id))]},w.id)});if(!h.entity)return t.jsx(g.Fragment,{children:x},`r${f}`);const k=h.chars[0].beforePuncts.map(w=>t.jsx("span",{className:"guji-text-punct","data-punct-id":w.id,children:w.mark},w.id)),y=h.chars[h.chars.length-1].afterPuncts.map(w=>t.jsx("span",{className:"guji-text-punct","data-punct-id":w.id,children:w.mark},w.id));return t.jsxs(g.Fragment,{children:[k,t.jsx(pr,{span:h.entity,label:h.chars.map(w=>u(w.charData)).join(""),hasBrackets:!0,loader:a,buildHref:d,onNavigate:c.navigate,renderText:()=>x,hoverDelayMs:250}),y]},`${h.entity.key}@${f}`)})},m.id))]})}),ic=1,oc=6,Kn={s:1,x:0,y:0},Jn=(e,n,o)=>Math.min(o,Math.max(n,e));function mr(e,n,o){const r=Jn(e.s,ic,oc);return{s:r,x:Jn(e.x,n*(1-r),0),y:Jn(e.y,o*(1-r),0)}}function Vi(e,n,o,r,s,a){const l=Jn(e.s*r,ic,oc),d=l/e.s;return mr({s:l,x:n-(n-e.x)*d,y:o-(o-e.y)*d},s,a)}function bg(e,n,o,r,s){return mr({s:e.s,x:e.x+n,y:e.y+o},r,s)}function yg(e,n,o){const r=n===1?e*16:n===2?e*400:e;return Math.exp(-r*(o?.01:.0015))}const Ts=4,jg=g.forwardRef(function({children:n,onScaleChange:o,resetKey:r,style:s},a){const l=g.useRef(null),[d,c]=g.useState(Kn),p=g.useRef(d),u=g.useRef(o);u.current=o;const m=b=>{var S;const j=p.current;p.current=b,c(b),b.s!==j.s&&((S=u.current)==null||S.call(u,b.s))},h=()=>{var j;const b=(j=l.current)==null?void 0:j.getBoundingClientRect();return{w:(b==null?void 0:b.width)??0,h:(b==null?void 0:b.height)??0,left:(b==null?void 0:b.left)??0,top:(b==null?void 0:b.top)??0}};g.useImperativeHandle(a,()=>({zoomBy(b){const{w:j,h:S}=h();m(Vi(p.current,j/2,S/2,b,j,S))},reset(){m(Kn)}})),g.useEffect(()=>{m(Kn)},[r]),g.useEffect(()=>{const b=l.current;if(!b||typeof ResizeObserver>"u")return;const j=new ResizeObserver(()=>{const{w:S,h:v}=h(),$=mr(p.current,S,v);($.x!==p.current.x||$.y!==p.current.y)&&m($)});return j.observe(b),()=>j.disconnect()},[]),g.useEffect(()=>{const b=l.current;if(!b)return;const j=S=>{const v=yg(S.deltaY,S.deltaMode,S.ctrlKey);if(p.current.s<=1&&v<1)return;S.preventDefault();const{w:$,h:_,left:C,top:M}=h();m(Vi(p.current,S.clientX-C,S.clientY-M,v,$,_))};return b.addEventListener("wheel",j,{passive:!1}),()=>b.removeEventListener("wheel",j)},[]);const f=g.useRef(new Map),x=g.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),k=b=>{if(b.pointerType==="mouse"&&b.button!==0)return;f.current.set(b.pointerId,{x:b.clientX,y:b.clientY});const j=x.current;if(j.swallowClick=!1,f.current.size===1&&(j.moved=0,j.dragging=!1),f.current.size===2){const[S,v]=[...f.current.values()];j.pinchDist=Math.hypot(S.x-v.x,S.y-v.y),j.moved=Ts+1}},y=b=>{var F;const j=f.current.get(b.pointerId);if(!j)return;const S={x:b.clientX,y:b.clientY};f.current.set(b.pointerId,S);const v=x.current,{w:$,h:_,left:C,top:M}=h();if(f.current.size>=2){const[N,R]=[...f.current.values()],O=Math.hypot(N.x-R.x,N.y-R.y);if(v.pinchDist>0&&O>0){const I=(N.x+R.x)/2-C,P=(N.y+R.y)/2-M;m(Vi(p.current,I,P,O/v.pinchDist,$,_))}v.pinchDist=O,v.swallowClick=!0;return}const T=S.x-j.x,z=S.y-j.y;if(v.moved+=Math.abs(T)+Math.abs(z),!(v.moved<=Ts)){if(!v.dragging){v.dragging=!0;try{(F=l.current)==null||F.setPointerCapture(b.pointerId)}catch{}}v.swallowClick=!0,p.current.s>1&&m(bg(p.current,T,z,$,_))}},w=b=>{f.current.delete(b.pointerId);const j=x.current;j.pinchDist=0,f.current.size===0&&(j.dragging=!1)};return t.jsx("div",{ref:l,className:"bim-zp","data-zoom":d.s.toFixed(2),onPointerDown:k,onPointerMove:y,onPointerUp:w,onPointerCancel:w,onClickCapture:b=>{x.current.swallowClick&&(x.current.swallowClick=!1,b.stopPropagation(),b.preventDefault())},onDoubleClick:()=>m(Kn),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 rc(e,n,o,r,s){const[a,l]=g.useState(n??null),[d,c]=g.useState(!1),p=g.useRef(0);return g.useEffect(()=>{if(n!==void 0){l(n);return}const u=++p.current;if(!o){l(null),c(!1);return}if(e){let m;try{m=e(o,s)}catch{l(null),c(!1);return}if(!m||typeof m.then!="function"){l(m??null),c(!1);return}c(!0),m.then(h=>{u===p.current&&l(h??null)}).catch(()=>{u===p.current&&l(null)}).finally(()=>{u===p.current&&c(!1)});return}if(r!=null&&r.warp_data){if(typeof r.warp_data=="object"){l(r.warp_data);return}if(typeof r.warp_data=="string"){c(!0),fetch(r.warp_data).then(m=>m.ok?m.json():null).then(m=>{u===p.current&&l(m)}).catch(()=>{u===p.current&&l(null)}).finally(()=>{u===p.current&&c(!1)});return}}l(null),c(!1)},[e,n,o,r,s]),{warpData:a,loading:d}}function vg(e,n,o){const[r,s]=g.useState([]),a=g.useRef(0);return g.useEffect(()=>{const l=++a.current;if(!e||!n){s([]);return}let d;try{d=e(n,o)}catch{s([]);return}Promise.resolve(d).then(c=>{l===a.current&&s(c?Xl(c):[])}).catch(()=>{l===a.current&&s([])})},[e,n,o]),r}const Ns={padding:24,color:i("desc-fg"),fontSize:14};function Es({title:e,label:n,className:o,style:r}){const s=(a,l=14,d=14)=>({width:a,height:l,marginTop:d,borderRadius:3,background:i("rule")});return t.jsxs("div",{className:o,style:{...r,padding:"20px 24px",maxWidth:760,margin:"0 auto"},"aria-busy":"true",children:[e&&t.jsx("div",{style:{fontSize:15,color:i("ink"),fontFamily:i("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:i("desc-fg"),fontSize:14,fontFamily:i("font-ui")},children:n})]})}const Is=/^https?:\/\//i;function kg(e){if(!e||typeof e!="object")return null;const n=a=>typeof a=="string"&&a.trim()?a.trim():void 0,o=n(e.url),r=n(e.license_url),s={name:n(e.name),url:o&&Is.test(o)?o:void 0,license:n(e.license),license_url:r&&Is.test(r)?r:void 0,note:n(e.note)};return s.name||s.license||s.note?s:null}function wg(e,n){return{work_id:n.work_id??e,title:n.title,type:n.type,juan_files:n.chapters.map(o=>o.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 Sg(e,n){return(n==null?void 0:n.type)==="kaozhen"?"章":n!=null&&n.juan_metadata&&Object.values(n.juan_metadata).some(o=>o.vol_label)?"冊":(e==null?void 0:e.kind)==="collated"?"卷":"章"}function sc(e,n,o,r=!1){const s=o(`${n}${e.n}`);if(!e.title)return s;const a=o(e.title);return r&&!/^[卷冊册章篇回第]/.test(e.title)?`${s} ${a}`:a}function _g(e,n,o,r,s){var p;const a=new Map(e.chapters.map(u=>[u.file,u])),l=u=>u==="loading"?"…":typeof u=="number"&&u>0?u:void 0,d=(u,m)=>{const h=a.get(u);return{key:u,label:m??(h?sc(h,o,r,s):u),hint:l(n[u]),disabled:n[u]===0}},c=(p=e.juan_groups)==null?void 0:p.filter(u=>{var m;return u.files.some(h=>a.has(h))||((m=u.children)==null?void 0:m.length)});if(c&&c.length>0){const u=(m,h)=>{var x;if(m.files.length===1&&!((x=m.children)!=null&&x.length))return d(m.files[0],r(m.label));const f=Eh(m,n);return{key:`group:${h}`,label:r(m.label),hint:f==="loading"?"…":typeof f=="number"&&f>0?`${f}`:Kl(m),defaultExpanded:typeof f=="number"&&f>0,children:[...m.files.filter(k=>a.has(k)).map(k=>d(k)),...(m.children??[]).map((k,y)=>u(k,`${h}.${y}`))]}};return c.map((m,h)=>u(m,`${h}`))}return e.chapters.map(u=>d(u.file))}const hr=({id:e,transport:n,versionKey:o,chapter:r,onLocationChange:s,onNavigate:a,title:l,subtitle:d,resolveImages:c,renderImageOverlay:p,imagePanel:u,allowVertical:m,onReportError:h,revisedAt:f,backHref:x,backLabel:k,resolveWarpData:y,warpData:w,resolveEntities:b,onEntityNavigate:j,className:S,style:v})=>{var Rr,Lr,Ar;const{t:$,convert:_}=J(),C=g.useMemo(()=>nl(n),[n]),[M,T]=pl(),z=Xe(),F=g.useRef(s);F.current=s;const[N,R]=g.useState(null),[O,I]=g.useState("loading");g.useEffect(()=>{let W=!1;return R(null),I("loading"),C.getManifest(e).then(he=>{W||(he?(R(he),I("ready")):I("missing"))}).catch(()=>{W||I("missing")}),()=>{W=!0}},[C,e]);const P=o!==void 0,U=r!==void 0,[K,L]=g.useState(null),[Z,A]=g.useState(null);g.useEffect(()=>{L(null),A(null)},[e]);const V=we.pickTextVersion(N,P?o:K),ce=((Rr=N==null?void 0:N.versions.find(W=>W.key==="default"))==null?void 0:Rr.key)??((Lr=N==null?void 0:N.versions[0])==null?void 0:Lr.key)??"default",ne=(V==null?void 0:V.key)??null,de=U?r:Z,pe=g.useCallback((W,he,Ie)=>{var De;(De=F.current)==null||De.call(F,{key:W,chapter:he,isDefault:W===ce},Ie)},[ce]);g.useEffect(()=>{!N||!P||o==null||N.versions.some(W=>W.key===o)||pe(ce,null,"auto")},[N,P,o,ce,pe]);const be=g.useRef(new Map);g.useEffect(()=>{be.current.clear()},[C,e]);const Oe=g.useCallback(async W=>{const he=`${e}
|
|
1294
|
-
${W}`;if(be.current.has(he))return be.current.get(he)??null;const
|
|
1295
|
-
${
|
|
1296
|
-
${fe.file}`:null,[Ce,Me]=g.useState(null),B=X!==null&&Ce!==X,
|
|
1297
|
-
${
|
|
1298
|
-
${fe.file}`;Se(null),C.getChapter(e,
|
|
1299
|
-
${ne??""}`,load:te,files:Ne,activeFile:Q??null,activeJuan:(le==null?void 0:le.json)??null,activeRawText:(le==null?void 0:le.md)??null,query:H,isKaozhen:ge}),We=g.useRef(new Map);g.useEffect(()=>{We.current.clear()},[e]);const Ue=g.useMemo(()=>({versionKey:ne,chapter:fe??null}),[ne,fe]),Qe=bh(c,Q??null,Ue),{warpData:me,loading:tt}=rc(y,w,Q??null,fe,Ue),E=vg(b,Q??null,Ue),[oe,ae]=g.useState(new Set),[je,ke]=g.useState(null),[xe,G]=g.useState(!0),[ue,Te]=g.useState(!0),Ee=g.useRef(null),[D,re]=g.useState(1),[Pe,_e]=g.useState(null),Ye=W=>{var Ie;const he=parseInt(((Ie=W==null?void 0:W.page_id)==null?void 0:Ie.split(":")[1])??"",10);return isNaN(he)?null:he},He=W=>{var Ie,De;const he=(W==null?void 0:W.pages)??[];return Ye(W)??((Ie=he.find(Ve=>Ve.columns.some(Nt=>Nt.chars.length>0)))==null?void 0:Ie.page)??((De=he[0])==null?void 0:De.page)??1},[Fe,zt]=g.useState(()=>He(me));g.useEffect(()=>{me&&zt(He(me))},[me]),g.useEffect(()=>{ae(new Set),ke(null)},[Q,ne]);const Wn=g.useCallback(W=>{if(ae(new Set(W)),W.length>0){const he=W[0],Ie=parseInt(he.split(":")[0],10);isNaN(Ie)||zt(Ie)}},[]),gt=g.useMemo(()=>{const W=new Map;for(const he of(me==null?void 0:me.pages)??[])W.set(he.page,he);return W},[me]),Tt=Ye(me),Mt=g.useCallback(W=>{var De;const he=Qe.images;if(!he||he.length===0)return;const Ie=(De=gt.get(W))==null?void 0:De.seq;return(Ie?he.find(Ve=>Ve.seq===Ie):void 0)??he.find(Ve=>Ve.pageNo===W)??he[W-1]},[Qe.images,gt]),mn=D>1.5,On=g.useCallback((W,he=!1)=>{const Ie=Mt(W);return Ie?W===Tt||he?Ie.hiresUrl??Ie.url:Ie.url:W===Tt?(me==null?void 0:me.imageUrl)??"":""},[Mt,me,Tt]),Td=g.useMemo(()=>On(Fe,mn),[On,Fe,mn]),hn=g.useMemo(()=>[...gt.keys()].sort((W,he)=>W-he),[gt]),gn=g.useCallback(W=>{var De;const he=hn.indexOf(Fe),Ie=hn[he<0?0:he+W];Ie===void 0||Ie===Fe||(zt(Ie),(De=gt.get(Ie))!=null&&De.columns.some(Ve=>Ve.chars.length>0)&&_e(Ve=>({page:Ie,nonce:((Ve==null?void 0:Ve.nonce)??0)+1})))},[hn,gt,Fe]),Ti=hn.indexOf(Fe),Nd=g.useCallback(W=>{if(W.altKey||W.ctrlKey||W.metaKey)return;const he=W.target.tagName;he==="INPUT"||he==="TEXTAREA"||he==="SELECT"||(W.key==="ArrowLeft"||W.key==="PageUp"?(W.preventDefault(),gn(-1)):(W.key==="ArrowRight"||W.key==="PageDown")&&(W.preventDefault(),gn(1)))},[gn]);g.useEffect(()=>{if(me)for(const W of[1,-1,2,3]){const he=On(Fe+W);he&&fo(he)}},[me,Fe,On]);const Tr=g.useMemo(()=>{var Wr;if(!me)return null;if(Fe===Tt)return me;const W=gt.get(Fe);if(W&&W.width>0&&W.height>0)return{page_id:`p:${Fe}`,title:`第${Fe}葉`,image_size:[W.width,W.height],total_warped_w:W.width,columns:[{col:1,warped_w:W.width,warped_h:W.height,offset_x:0,strips:[],chars:W.columns.flatMap(Ke=>Ke.chars).map(Ke=>({id:Ke.id,char:Ke.char,slot:Ke.slot,pos:Ke.pos,sub:Ke.sub,bbox_col:Ke.bbox??[0,0,0,0]}))}]};const he=(Wr=me.pages)==null?void 0:Wr.find(Ke=>Ke.page===Fe),[Ie,De]=me.image_size||[2386,3082],Ve=Mt(Fe),Nt=(Ve==null?void 0:Ve.width)??Ie,Li=(Ve==null?void 0:Ve.height)??De,Pr=Nt/Ie,Mr=Li/De,Br=new Map;for(const Ke of me.columns){const at=(Ke.strips||[]).flatMap(Dn=>Dn.srcQuad.map(Un=>Un[0]));if(at.length===0)continue;const vt=Ke.top_y??0,Ai=Ke.bottom_y??vt+Ke.warped_h;Br.set(Ke.col,{x0:Math.min(...at),x1:Math.max(...at),top:vt,slotH:(Ai-vt)/21})}return{page_id:`p:${Fe}`,title:`第${Fe}葉`,image_size:[Nt,Li],total_warped_w:Nt,columns:he?he.columns.map(Ke=>{const at=Br.get(Ke.col)??{x0:0,x1:0,top:0,slotH:118};return{col:Ke.col,warped_w:Nt,warped_h:Li,offset_x:0,strips:[],chars:Ke.chars.map(vt=>{const Ai=vt.slot??vt.pos??0,Dn=(at.top+(Ai-1)*at.slotH)*Mr,Un=(at.x0+at.x1)/2,[Bd,Wd]=vt.sub==="a"?[Un,at.x1]:vt.sub==="b"?[at.x0,Un]:[at.x0,at.x1];return{...vt,bbox_col:[Bd*Pr,Dn,Wd*Pr,Dn+at.slotH*Mr]}})}}):[]}},[me,Fe,Tt,gt,Mt]),{entryTitle:Hn,authors:Nr}=zg(e,n,l===void 0),[Er,Ni]=g.useState("text");if(g.useEffect(()=>{Ni("text")},[Q,ne]),O==="loading")return t.jsx(Es,{className:S,style:v,title:l??Hn,label:$("reader.loading")});if(O==="missing"||!N||!V)return t.jsx("div",{className:S,style:{...v,...Ns},children:$("reader.noText")});if(Ae==="failed")return t.jsx("div",{className:S,style:{...v,...Ns},children:$("reader.tocFailed")});if(!ie)return t.jsx(Es,{className:S,style:v,title:l??Hn,label:$("reader.tocLoading")});const Bt=Sg(V,ie),Ed=_g(ie,Be,Bt,_,ye),Ei=N.versions.map(W=>({key:W.key,label:we.textVersionLabel(W),optionLabel:_(we.textVersionLabel(W)),sourceName:W.source_name?_(W.source_name):void 0,license:W.license??void 0,sourceUrl:W.source_url??void 0,primary:W.key===ce})),st=kg((Ar=ie.source)==null?void 0:Ar.upstream),Fn=(typeof l=="string"?_(l):l)??(ie.title?_(ie.title):Hn?_(Hn):void 0),Id=Fn?t.jsx("a",{href:z(e),title:$("reader.viewEntry"),onClick:a?W=>{W.metaKey||W.ctrlKey||(W.preventDefault(),a(e))}:void 0,children:Fn}):void 0,Rd=Nr.length>0?_(Nr.slice(0,2).map(W=>`${W.dynasty?`〔${W.dynasty}〕`:""}${W.name}${` ${W.role||$("reader.defaultRole")}`}`).join("、")):void 0,Ii=fe?sc(fe,Bt,_,ye):void 0,Xt=ye&&!!(le!=null&&le.json),Wt=(le==null?void 0:le.json)??null,Zt=(le==null?void 0:le.md)??null,Ir=Xt&&!ge&&ql(Wt.sections),Ld=Ir&&!(Zt&&M.readingMode==="paragraph"&&oi(Zt)),Ad=Xt&&Ir?t.jsx(Vh,{juan:Wt,view:Er,onView:Ni,textHasEntries:Ld}):void 0,Pd=Qa(ie)||io(ie),Ri=Zt?Zt.replace(/^##\s+[^\n]+\n+/,""):null,Md=(typeof d=="string"?_(d):d)??(V.source_name?_(V.source_name):_(we.textVersionLabel(V)));return t.jsxs(hl,{className:S,style:v,title:Id,subtitle:Md,byline:Rd,current:Ii,pagerUnit:Bt,rail:Ad,revisedAt:f,backHref:x,backLabel:k,onReportError:h?W=>h({...W,bookTitle:typeof Fn=="string"?Fn:void 0,entryId:e}):void 0,workLinkToggle:Xt&&!ge&&!!a&&!!(Wt!=null&&Wt.sections.some(W=>W.work_id)),toc:Ed,tocCaption:$("reader.tocCaption",{n:ie.chapters.length,unit:_(Bt)}),tocHeader:ye&&ie.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:ge?$("reader.searchChaptersPlaceholder"):$("reader.searchUnitPlaceholder",{unit:_(Bt)}),"aria-label":ge?$("reader.searchChapters"):$("reader.searchUnit",{unit:_(Bt)}),value:H,onChange:W=>se(W.target.value)}):void 0,activeKey:Q??null,onSelect:ve,images:Qe.images,imagesLoading:Qe.loading||tt,renderImageOverlay:p,imagePanel:me?"open":u,isWarpMode:!!me,customImagePanel:me&&Tr?t.jsxs("div",{className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:Nd,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:i("meta-fg"),gap:8,flexWrap:"wrap"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[t.jsx("span",{style:{fontWeight:600,marginRight:4},children:"底本书影"}),t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-prev","aria-label":"上一葉",disabled:Ti<=0,onClick:()=>gn(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":Fe,style:{fontSize:11,padding:"1px 6px",background:i("rule"),borderRadius:10},children:["第 ",Fe," 葉"]}),t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-next","aria-label":"下一葉",disabled:Ti<0||Ti>=hn.length-1,onClick:()=>gn(1),children:"›"})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[oe.size>0&&t.jsxs("button",{type:"button",onClick:()=>ae(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${i("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",oe.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:D<=1,onClick:()=>{var W;return(W=Ee.current)==null?void 0:W.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(D*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:D>=6,onClick:()=>{var W;return(W=Ee.current)==null?void 0:W.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:D===1,onClick:()=>{var W;return(W=Ee.current)==null?void 0:W.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(jg,{ref:Ee,resetKey:Fe,onScaleChange:re,style:{flex:1,minHeight:0},children:t.jsx(ar,{imageUrl:Td,pageData:Tr,selectedCharIds:oe,hoveredCharId:je,preserveMargins:ue,onCharClick:W=>{ae(Ie=>{const De=new Set(Ie);return De.has(W)?De.delete(W):(De.clear(),De.add(W)),De});const he=document.querySelector(`[data-char-id="${W}"]`);he&&he.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:ke})}),t.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 0 2px"},children:t.jsxs("div",{style:{display:"inline-flex",border:`1px solid ${i("rule")}`,borderRadius:4,overflow:"hidden"},children:[t.jsx("button",{type:"button",onClick:()=>Te(!1),className:`bim-rd-t ${ue?"":"bim-rd-on"}`,style:{fontSize:11,padding:"2px 10px",lineHeight:"18px",border:"none",borderRadius:0,cursor:"pointer",background:ue?"transparent":i("accent-bg"),color:ue?"inherit":i("accent")},title:"去空白:紧凑裁切版心",children:"去空白"}),t.jsx("button",{type:"button",onClick:()=>Te(!0),className:`bim-rd-t ${ue?"bim-rd-on":""}`,style:{fontSize:11,padding:"2px 10px",lineHeight:"18px",border:"none",borderRadius:0,cursor:"pointer",background:ue?i("accent-bg"):"transparent",color:ue?i("accent"):"inherit"},title:"保留空白:完整呈现古籍天头地脚与白边",children:"保留空白"})]})})]}):void 0,toolbarExtra:me?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-badge-warp",children:"图文对读"}),t.jsx("button",{type:"button",className:`bim-rd-t ${xe?"bim-rd-on":""}`,title:"切换外挂现代断句标点",onClick:()=>G(W=>!W),children:xe?"标点":"无标点"})]}):void 0,prefs:M,onPrefsChange:T,versions:Ei.length>1?Ei:void 0,currentVersionKey:Ei.length>1?V.key:void 0,onVersionChange:Y,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:oi(Zt),allowVertical:m,children:[B&&t.jsx(Kt,{}),!B&&me&&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:fe!=null&&fe.title?_(fe.title):Ii}),(V.source_name||V.license)&&t.jsxs("p",{className:"bim-rd-meta",children:[V.source_name&&_(V.source_name),V.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),V.license]})]})]}),t.jsx(ur,{pageData:me,pages:me.pages,punctuations:me.punctuations||[],selectedCharIds:oe,hoveredCharId:je,onSelectionChange:Wn,onCharClick:W=>{ae(Ie=>{const De=new Set(Ie);return De.has(W)?De.delete(W):(De.clear(),De.add(W)),De});const he=parseInt(W.split(":")[0],10);isNaN(he)||zt(he)},onCharHover:ke,mode:"horizontal",showPunctuation:xe,entities:M.properNames?E:void 0,entityTransport:n,onEntityNavigate:j,onVisiblePageChange:W=>zt(W),convert:_,scrollToPage:Pe})]}),!B&&!me&&Xt&&Wt&&t.jsx(Dh,{juan:Wt,rawText:Zt,positionLabel:$g(fe,ie,Bt,_),groupLabel:Cg(ie,Q??null),index:wg(e,ie),searchQuery:H,onNavigate:a,transport:n,workLabelCache:We,prefs:M,view:Er,onViewChange:Ni},`${ne}/${Q}`),!B&&!me&&!Xt&&Ri!=null&&fe&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:fe.title?_(fe.title):Ii}),(V.source_name||V.license)&&t.jsxs("p",{className:"bim-rd-meta",children:[V.source_name&&t.jsxs(t.Fragment,{children:[$("reader.textSource")," ",V.source_url?t.jsx("a",{className:"bim-rd-link",href:V.source_url,target:"_blank",rel:"noreferrer",children:_(V.source_name)}):_(V.source_name)]}),V.source_name&&V.license&&t.jsx("span",{className:"bim-rd-dot"}),V.license]}),st&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[$("reader.upstream")," ",st.url?t.jsx("a",{className:"bim-rd-link",href:st.url,target:"_blank",rel:"noreferrer",children:_(st.name??st.url)}):_(st.name??""),st.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),st.license_url?t.jsx("a",{className:"bim-rd-link",href:st.license_url,target:"_blank",rel:"noreferrer",children:st.license}):st.license]}),st.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(il,{text:st.note,convert:_})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(er,{text:Ri,mode:M.readingMode,tables:Pd,gujiMarkdown:io(ie),properNames:M.properNames})})]}),!B&&!me&&!Xt&&Ri==null&&fe&&t.jsx("div",{className:"bim-rd-state",children:$("reader.chapterFailed")}),ie.references&&ie.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:$("reader.references")}),t.jsx("ol",{children:ie.references.map((W,he)=>t.jsxs("li",{children:[W.url?t.jsx("a",{className:"bim-rd-link",href:W.url,target:"_blank",rel:"noopener noreferrer",children:_(W.title)}):t.jsx("span",{children:_(W.title)}),W.author&&t.jsxs("span",{children:[",",_(W.author)]}),W.note&&t.jsxs("span",{children:["。",_(W.note)]})]},he))})]})]})};function $g(e,n,o,r){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 r(s?`${s}冊`:`${o}${e.n}`)}function Cg(e,n){if(!n)return;const o=r=>{var s;for(const a of r??[]){const l=o(a.children);if(l)return l;if((s=a.files)!=null&&s.includes(n))return a.label}};return o(e.juan_groups)}function zg(e,n,o){const[r,s]=g.useState({entryTitle:void 0,authors:[]});return g.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let a=!1;return Promise.resolve(n.getItem(e)).then(l=>{if(a||!l)return;const d=(l.authors??[]).filter(c=>c&&c.name);s({entryTitle:o&&typeof l.title=="string"?l.title:void 0,authors:d})}).catch(()=>{}),()=>{a=!0}},[e,n,o]),r}const ac={bug:{key:"bug",color:i("danger")},resource:{key:"resource",color:i("primary")},suggestion:{key:"suggestion",color:i("primary")},other:{key:"other",color:i("desc-fg")}},Tg=ac.other,lc={pending:{key:"pending",color:i("warning")},in_progress:{key:"in_progress",color:i("primary")},resolved:{key:"resolved",color:i("success")},wontfix:{key:"wontfix",color:i("desc-fg")},duplicate:{key:"duplicate",color:i("desc-fg")}},Ng=lc.pending;function Eg(e){try{const n=new Date(e),o=r=>String(r).padStart(2,"0");return`${n.getFullYear()}-${o(n.getMonth()+1)}-${o(n.getDate())} ${o(n.getHours())}:${o(n.getMinutes())}`}catch{return e}}function Ig(e,n){if(!e)return!1;try{const o=new URL(e,n);if(o.protocol!=="http:"&&o.protocol!=="https:")return!1;const r=new URL(n);return o.hostname===r.hostname}catch{return!1}}const gr=({items:e,loading:n})=>{const o=Xe(),{t:r,convert:s}=J();return n?t.jsx(Kt,{}):e.length===0?t.jsx("div",{style:Rg,children:r("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=ac[a.type]||Tg,d=lc[a.status]||Ng,c=typeof window<"u"&&Ig(a.pageUrl,window.location.href);return t.jsxs("div",{style:Lg,children:[t.jsxs("div",{style:Ag,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...Rs,background:l.color},children:r(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...Rs,background:d.color},children:r(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:Pg,children:Eg(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:Mg,children:[a.resourceId&&t.jsx("a",{href:o(a.resourceId),style:Gi,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:Gi,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:Gi,children:a.pageUrl}))]}),t.jsx("div",{style:Bg,children:s(a.content)}),a.reply&&t.jsxs("div",{style:Wg,children:[t.jsx("div",{style:Og,children:r("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},Rg={textAlign:"center",padding:"40px 0",color:i("desc-fg"),fontSize:"14px"},Lg={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"16px"},Ag={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},Rs={fontSize:"12px",color:i("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},Pg={fontSize:"12px",color:i("desc-fg")},Mg={fontSize:"12px",marginBottom:"6px"},Gi={color:i("primary"),textDecoration:"none",borderBottom:`1px dashed ${i("primary")}`},Bg={fontSize:"14px",lineHeight:"1.6",color:i("fg"),whiteSpace:"pre-wrap"},Wg={marginTop:"12px",padding:"10px 12px",background:i("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:i("fg")},Og={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:i("primary")},bo=({transport:e,onNavigate:n,recommendedIds:o,activeTab:r,onTabChange:s,feedbackApiUrl:a})=>{const l=$e(),[d,c]=g.useState(null),[p,u]=g.useState([]),[m,h]=g.useState("recommend"),[f,x]=g.useState([]),[k,y]=g.useState(!1),w=r??m,b=O=>{h(O),s==null||s(O)},[j,S]=g.useState(!0),[v,$]=g.useState(null),[_,C]=g.useState(null),[M,T]=g.useState(null);g.useEffect(()=>{let O=!1;if(e.getCounts)return e.getCounts().then(I=>{O||c({works:I.works,books:I.books,collections:I.collections})}).catch(()=>{}),()=>{O=!0}},[e]),g.useEffect(()=>{let O=!1;return(async()=>{if(o)return o;if(e.getRecommended)try{const P=await e.getRecommended();if(P!=null&&P.groups)return P.groups.flatMap(U=>U.items.map(K=>({...K,group:U.name})))}catch{}return[]})().then(async P=>{if(O)return;const U=P.filter(L=>L.id);if(U.length===0){S(!1);return}const K=await Promise.all(U.map(async L=>{if(L.type)return{id:L.id,title:L.title,type:L.type,author:L.author,dynasty:L.dynasty,role:L.role,edition:L.edition,has_text:L.has_text,has_image:L.has_image,has_collated:L.has_collated,subtype:L.subtype,primary_name:L.primary_name,group:L.group,fallbackDescription:L.description};try{let Z=null;if(e.getEntry)Z=await e.getEntry(L.id);else{const A=await e.getItem(L.id);A&&(Z={id:L.id,title:A.title||L.id,type:A.type||"work"})}if(Z)return{...Z,group:L.group,fallbackDescription:L.description}}catch{}return{id:L.id,title:L.title,type:we.extractType(L.id),group:L.group,fallbackDescription:L.description}}));O||(u(K.filter(L=>L!==null)),S(!1))}),()=>{O=!0}},[e,o]);const z=g.useRef(!1),F=g.useRef(!1),N=g.useRef(!1);g.useEffect(()=>{if(w!=="catalog"||z.current)return;const O=e.getCatalogProgress??e.getResourceProgress;if(!O)return;z.current=!0;let I=!1;return O.call(e).then(P=>{I||$(P)}).catch(()=>{z.current=!1}),()=>{I=!0}},[e,w]),g.useEffect(()=>{if(w!=="collection"||F.current||!e.getCollectionProgress)return;F.current=!0;let O=!1;return e.getCollectionProgress().then(I=>{O||C(I)}).catch(()=>{F.current=!1}),()=>{O=!0}},[e,w]),g.useEffect(()=>{if(w!=="site"||N.current||!e.getSiteProgress)return;N.current=!0;let O=!1;return e.getSiteProgress().then(I=>{O||T(I)}).catch(()=>{N.current=!1}),()=>{O=!0}},[e,w]),g.useEffect(()=>{if(!a||w!=="feedback")return;let O=!1;return y(!0),fetch(a).then(I=>I.json()).then(I=>{!O&&I.success&&x(I.items||[])}).catch(()=>{}).finally(()=>{O||y(!1)}),()=>{O=!0}},[a,w]);const R=O=>t.jsx(un,{type:O,size:12});return t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:i("fg")},children:t.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[t.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"16px"},children:[t.jsx(vn,{label:l.home.recommendTab,active:w==="recommend",onClick:()=>b("recommend")}),t.jsx(vn,{label:l.home.catalogTab,active:w==="catalog",onClick:()=>b("catalog")}),t.jsx(vn,{label:l.home.collectionTab,active:w==="collection",onClick:()=>b("collection")}),t.jsx(vn,{label:l.home.siteTab,active:w==="site",onClick:()=>b("site")}),a&&t.jsx(vn,{label:l.home.feedbackTab,active:w==="feedback",onClick:()=>b("feedback")})]}),w==="recommend"&&t.jsx(Hg,{recommended:p,loading:j,onNavigate:n,getIcon:R,t:l}),w==="catalog"&&t.jsx(Ls,{progress:v,t:l,onNavigate:n}),w==="collection"&&t.jsx(Ls,{progress:_,t:l,onNavigate:n}),w==="site"&&t.jsx(Dg,{progress:M,t:l,totalWorks:(d==null?void 0:d.works)??0}),w==="feedback"&&a&&t.jsx(gr,{items:f,loading:k})]})})},vn=({label:e,active:n,onClick:o})=>t.jsx("button",{onClick:o,style:{padding:"8px 16px",fontSize:"14px",fontWeight:n?600:400,color:i(n?"primary":"desc-fg"),background:"none",border:"none",borderBottom:n?`2px solid ${i("primary")}`:"2px solid transparent",cursor:"pointer",marginBottom:"-1px"},children:e}),Hg=({recommended:e,loading:n,onNavigate:o,getIcon:r,t:s})=>{const a=Xe();if(n)return t.jsx(Kt,{});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:i("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 u=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(),o==null||o(p.id))},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,cursor:"pointer",background:i("input-bg"),textDecoration:"none",color:"inherit"},children:[t.jsx("span",{style:{fontSize:"20px"},children:r(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:i("desc-fg"),marginLeft:"4px"},children:p.edition})]}),u&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u})]})]},p.id)})})]},d))})},Ls=({progress:e,t:n,onNavigate:o})=>{if(!e)return t.jsx(Kt,{});const r=[...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:i("progress-active"),done:i("progress-done"),todo:i("progress-todo")};return t.jsx("div",{children:s.map(d=>{const c=r.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:i("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(Fg,{item:p,t:n,statusColor:l[d],onNavigate:o},p.id))})]},d)})})},Fg=({item:e,t:n,statusColor:o,onNavigate:r})=>{const s=Xe(),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 ${i("widget-border")}`,background:i("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&&r?t.jsx("a",{href:s(c),onClick:p=>{p.metaKey||p.ctrlKey||(p.preventDefault(),r(c))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${i("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:i("widget-border"),color:i("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:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.total>0?dt(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:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${a}%`,borderRadius:"2px",background:o,transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:e.description})]})},Dg=({progress:e,t:n,totalWorks:o})=>{if(!e)return t.jsx(Kt,{});const r=[...e.resources].sort((c,p)=>c.priority-p.priority),s=r.filter(c=>c.imported>0),a=r.filter(c=>c.imported===0),l=s.reduce((c,p)=>Math.max(c,p.imported),0),d=o>0?Math.round(l/o*100):0;return t.jsxs("div",{children:[o>0&&t.jsxs("div",{style:{padding:"12px 16px",marginBottom:"16px",borderRadius:"8px",background:`color-mix(in srgb, ${i("primary")} 6%, transparent)`,fontSize:"13px",color:i("fg")},children:[n.home.siteCoverage,": ",t.jsx("strong",{children:l.toLocaleString()})," / ",o.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:i("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-done")}}),n.home.statusInProgress," (",s.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(c=>t.jsx(As,{item:c,t:n,totalWorks:o},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:i("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-todo")}}),n.home.statusTodo," (",a.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:a.map(c=>t.jsx(As,{item:c,t:n,totalWorks:o},c.id))})]})]})},As=({item:e,t:n,totalWorks:o})=>{const r=o>0?Math.round(e.imported/o*100):0;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("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:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.imported>0?`${e.imported.toLocaleString()} ${n.indexType.work} (${r}%)`:n.home.statusTodo})]}),e.imported>0&&o>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${r}%`,borderRadius:"2px",background:i("progress-done"),transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:e.description})]})},Ps="(max-width: 768px)";function Ug(){const[e,n]=g.useState(()=>typeof window>"u"?!1:window.matchMedia(Ps).matches);return g.useEffect(()=>{const o=window.matchMedia(Ps),r=s=>n(s.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[]),e}const Vg=({transport:e,hideModeIndicator:n=!0,onEntryClick:o,recommendedIds:r,headerRight:s})=>{var F;const a=$e(),{convert:l}=Re(),d=Ug(),[c,p]=g.useState(null),[u,m]=g.useState(null),[h,f]=g.useState(!1),[x,k]=g.useState("detail"),[y,w]=g.useState([]),[b,j]=g.useState(!1),S=g.useCallback(async N=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){w([]);return}j(!0);try{if(e.getCollectionCatalogs){const R=await e.getCollectionCatalogs(N);w(R||[])}else if(e.getCollectionCatalog){const R=await e.getCollectionCatalog(N);w(R?[{resource_id:"",data:R}]:[])}}catch{w([])}finally{j(!1)}},[e]),v=g.useCallback(async N=>{if(o){o(N);return}p(N),m(null),w([]),k("detail"),f(!0);try{const R=await e.getItem(N.id);R&&(m(R),R.type==="collection"&&S(N.id))}catch(R){console.error("加载详情失败:",R)}finally{f(!1)}},[e,o,S]),$=g.useCallback(async N=>{m(null),w([]),k("detail"),f(!0);try{const R=await e.getItem(N);R&&(m(R),p({id:N,title:R.title||N,type:R.type||"book"}),R.type==="collection"&&S(N))}catch(R){console.error("导航失败:",R)}finally{f(!1)}},[e,S]),_=typeof(u==null?void 0:u.text_count)=="number"&&u.text_count>0,C=(u==null?void 0:u.type)==="collection"&&(y.length>0||b)||(u==null?void 0:u.type)==="work"&&_,M=d&&(h||u),T=g.useCallback(()=>{p(null),m(null),w([]),k("detail")},[]),z=t.jsx(t.Fragment,{children:h?t.jsx(Kt,{}):u?t.jsxs(t.Fragment,{children:[(C||s)&&t.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${i("widget-border")}`,padding:d?"0 12px":"0 48px",background:i("input-bg"),flexShrink:0,overflowX:d?"auto":void 0},children:[C&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>k("detail"),style:qn(x==="detail"),children:a.detailTab.basicInfo}),u.type==="collection"&&b&&y.length===0&&t.jsxs("button",{onClick:()=>{},style:qn(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),u.type==="collection"&&y.map(N=>t.jsx("button",{onClick:()=>k(`catalog:${N.resource_id}`),style:qn(x===`catalog:${N.resource_id}`),children:N.short_name?`${l(N.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},N.resource_id)),u.type==="work"&&_&&t.jsx("button",{onClick:()=>k("collated"),style:qn(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(Ao,{data:u,transport:e,onNavigate:$}):x.startsWith("catalog:")?t.jsx(Po,{data:(F=y.find(N=>`catalog:${N.resource_id}`===x))==null?void 0:F.data,onNavigate:$}):x==="collated"?t.jsx(hr,{id:u.id,transport:e,onNavigate:$}):null})]}):t.jsx(bo,{transport:e,onNavigate:$,recommendedIds:r})});return d?t.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:i("bg"),color:i("fg")},children:M?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${i("widget-border")}`,background:i("input-bg"),flexShrink:0},children:t.jsxs("button",{onClick:T,style:{padding:"4px 12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px"},children:["← ",a.detailTab.basicInfo]})}),t.jsx("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:z})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(no,{transport:e,onEntryClick:v,hideModeIndicator:n}),!u&&t.jsx(bo,{transport:e,onNavigate:$,recommendedIds:r})]})}):t.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:i("bg"),color:i("fg")},children:[t.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:`1px solid ${i("widget-border")}`,display:"flex",flexDirection:"column",background:i("input-bg"),overflow:"hidden"},children:t.jsx("div",{style:{flex:1,overflow:"auto"},children:t.jsx(no,{transport:e,onEntryClick:v,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:i("bg"),display:"flex",flexDirection:"column"},children:z})]})};function qn(e){return{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(e?"primary":"desc-fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}const Gg=({pageData:e,rawImageUrl:n="",punctuations:o=[],title:r,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=g.useState(new Set),[u,m]=g.useState(null),[h,f]=g.useState("horizontal"),[x,k]=g.useState(!0),y=g.useRef(null),w=g.useCallback(v=>{p(new Set(v))},[]),b=g.useCallback(v=>{if(p($=>{const _=new Set($);return _.has(v)?_.delete(v):(_.clear(),_.add(v)),_}),y.current){const $=y.current.querySelector(`[data-char-id="${v}"]`);$&&$.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),j=()=>{var v;p(new Set),window.getSelection&&((v=window.getSelection())==null||v.removeAllRanges())},S=o.length>0?o: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:r||e.title}),s&&t.jsx("span",{style:{fontSize:"0.85rem",color:i("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:i("body-fg")},children:["已选字数: ",t.jsx("strong",{style:{color:i("accent")},children:c.size})]}),c.size>0&&t.jsx("button",{type:"button",onClick:j,className:"guji-reader-btn",children:"清除选中"}),t.jsx("button",{type:"button",onClick:()=>k(v=>!v),className:`guji-reader-btn ${x?"active":""}`,title:"独立外挂标点 (guji-punct v0.1)",children:x?"✓ 标点":"底本文本"}),t.jsx("button",{type:"button",onClick:()=>f(v=>v==="horizontal"?"vertical":"horizontal"),className:"guji-reader-btn primary",children:h==="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(ar,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:u,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:h==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(ur,{pageData:e,punctuations:S,selectedCharIds:c,hoveredCharId:u,onSelectionChange:w,onCharClick:b,onCharHover:m,mode:h,showPunctuation:x})]})]})]})},Yg=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function Qt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Kg(e){var r,s,a,l,d,c;const n=e&&typeof e=="object"?e.pages:void 0;if(!Array.isArray(n))return[];const o=[];for(const p of n){if(!p||typeof p!="object")continue;const u=p,m=Qt((r=u.page)==null?void 0:r.index),h=Array.isArray(u.cells)?u.cells:[];if(m===void 0||h.length===0)continue;const f=new Map;for(const x of h){if(!x||typeof x!="object")continue;const k=x,y=Yg.exec(String(k.a??""));if(!y||typeof k.c!="string")continue;const w=parseInt(y[2],10),b=parseInt(y[3],10),j=Array.isArray(k.box)&&k.box.length===4&&k.box.every($=>Qt($)!==void 0)?k.box:null,S={id:String(k.a),char:k.c,slot:b,pos:b,sub:y[4]||null,bbox:j?[j[0],j[1],j[0]+j[2],j[1]+j[3]]:null};let v=f.get(w);v||f.set(w,v=[]),v.push(S)}o.push({page:m,seq:String(((s=u.canvas)==null?void 0:s.seq)??""),width:Qt((a=u.canvas)==null?void 0:a.width)??Qt((l=u.image)==null?void 0:l.width)??0,height:Qt((d=u.canvas)==null?void 0:d.height)??Qt((c=u.image)==null?void 0:c.height)??0,columns:Array.from(f.entries()).sort((x,k)=>x[0]-k[0]).map(([x,k])=>({col:x,chars:k}))})}return o}function qg(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.punctuations)?e.punctuations:[],o=[];for(const r of n){if(!r||typeof r!="object")continue;const s=r;typeof s.anchor!="string"||typeof s.mark!="string"||o.push({id:typeof s.id=="string"?s.id:void 0,anchor:s.anchor,mark:s.mark,kind:s.kind,pos:s.pos,pre_char:s.pre_char})}return o}function Xg(e){var o;const n=e&&typeof e=="object"?e.pages:void 0;if(!Array.isArray(n))return null;for(const r of n){const s=/\/iiif\/([^/]+)\/canvas\/([^/]+)\//.exec(String(((o=r==null?void 0:r.canvas)==null?void 0:o.id)??""));if(s)return{bookId:s[1],vol:s[2]}}return null}const Zg=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function ut(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Ms(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(o=>!!o&&typeof o=="object"):[]}function Jg(e,n){var l,d,c,p,u,m,h,f,x,k;const o=new Map,r=new Map;for(const y of Ms(n)){const w=ut(y.page);if(w!==void 0){o.set(w,y);for(const b of Array.isArray(y.cells)?y.cells:[]){const j=b==null?void 0:b.box;typeof(b==null?void 0:b.a)=="string"&&Array.isArray(j)&&j.length===4&&j.every(S=>ut(S)!==void 0)&&r.set(b.a,[j[0],j[1],j[0]+j[2],j[1]+j[3]])}}}const s=[];for(const y of Ms(e)){const w=ut(y.page);if(w===void 0)continue;const b=[];for(const S of Array.isArray(y.columns)?y.columns:[]){const v=ut(S==null?void 0:S.col);if(v===void 0)continue;const $=[];for(const _ of Array.isArray(S.cells)?S.cells:[]){const C=Zg.exec(String((_==null?void 0:_.a)??""));if(!C||typeof _.c!="string")continue;const M=parseInt(C[3],10);$.push({id:_.a,char:_.c,slot:M,pos:M,sub:C[4]||null,bbox:r.get(_.a)??null})}$.length>0&&b.push({col:v,chars:$})}if(b.length===0)continue;b.sort((S,v)=>S.col-v.col);const j=o.get(w);s.push({page:w,seq:String(((l=j==null?void 0:j.canvas)==null?void 0:l.seq)??""),width:ut((d=j==null?void 0:j.canvas)==null?void 0:d.width)??ut((c=j==null?void 0:j.image)==null?void 0:c.width)??0,height:ut((p=j==null?void 0:j.canvas)==null?void 0:p.height)??ut((u=j==null?void 0:j.image)==null?void 0:u.height)??0,columns:b})}const a=new Set(s.map(y=>y.page));for(const[y,w]of o){const b=(m=w==null?void 0:w.canvas)==null?void 0:m.seq;a.has(y)||typeof b!="string"&&typeof b!="number"||String(b)===""||s.push({page:y,seq:String(b),width:ut((h=w.canvas)==null?void 0:h.width)??ut((f=w.image)==null?void 0:f.width)??0,height:ut((x=w.canvas)==null?void 0:x.height)??ut((k=w.image)==null?void 0:k.height)??0,columns:[]})}return s.sort((y,w)=>y.page-w.page)}const Qg=({data:e,onNavigate:n,className:o,style:r})=>{var u;const{t:s,convert:a}=J(),[l,d]=g.useState(((u=e.divisions[0])==null?void 0:u.name)??null),[c,p]=g.useState(null);return t.jsxs("div",{className:o,style:r,children:[t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:a(e.title)}),e.stats&&t.jsxs("div",{style:{fontSize:"13px",color:i("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(ef,{division:m,expanded:l===m.name,onToggle:()=>d(l===m.name?null:m.name),expandedCat:c,onCatToggle:h=>p(c===h?null:h),onNavigate:n},m.name))})]})},ef=({division:e,expanded:n,onToggle:o,expandedCat:r,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=J(),c=e.categories.reduce((p,u)=>{const m=u.stats||{zhulu:0,cunmu:0};return p+(m.zhulu||0)+(m.cunmu||0)},0);return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("button",{onClick:o,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:"none",background:n?`color-mix(in srgb, ${i("primary")} 6%, transparent)`:i("bg"),cursor:"pointer",fontSize:"15px",fontWeight:600,color:i("fg"),textAlign:"left"},children:[t.jsx("span",{children:d(e.name)}),t.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:i("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 u=`${e.name}/${p.name}`;return t.jsx(tf,{category:p,expanded:r===u,onToggle:()=>s(u),onNavigate:a},p.name)})})]})},tf=({category:e,expanded:n,onToggle:o,onNavigate:r})=>{var p,u,m,h;const{t:s,convert:a}=J(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((u=e.books)==null?void 0:u.cunmu)||[],c=(((m=e.stats)==null?void 0:m.zhulu)||l.length)+(((h=e.stats)==null?void 0:h.cunmu)||d.length);return t.jsxs("div",{children:[t.jsxs("button",{onClick:o,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px 6px 28px",border:"none",background:n?i("input-bg"):"transparent",cursor:"pointer",fontSize:"13px",color:i("fg"),textAlign:"left"},children:[t.jsxs("span",{style:{fontWeight:500},children:[a(e.name),e.volumes&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:a(e.volumes)})})]}),t.jsxs("span",{style:{fontSize:"11px",color:i("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(Bs,{label:s("catalogPage.zhulu"),books:l,onNavigate:r}),d.length>0&&t.jsx(Bs,{label:s("catalogPage.cunmu"),books:d,onNavigate:r})]})]})},Bs=({label:e,books:n,onNavigate:o})=>{const{t:r,convert:s}=J(),a=Xe(),[l,d]=g.useState(n.length<=20),c=l?n:n.slice(0,10);return t.jsxs("div",{style:{marginBottom:"8px"},children:[t.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:[e," (",n.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((p,u)=>t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[t.jsx("span",{style:{fontWeight:500,color:i("fg")},children:p.work_id&&o?t.jsx("a",{href:a(p.work_id),onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),o(p.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`},children:s(p.title)}):s(p.title)}),p.volumes&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(p.volumes)}),p.author&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(p.author).slice(0,20)})]},u))}),!l&&t.jsx("button",{onClick:()=>d(!0),style:{marginTop:"4px",padding:"2px 12px",fontSize:"11px",color:i("primary"),background:"transparent",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:r("catalogPage.expandAllN",{n:n.length})})]})},ft=({title:e,onSave:n,onAskAI:o,extraButtons:r,children:s})=>{const a=$e();return t.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("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 ${i("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:i("fg")},children:e}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[r,o&&t.jsx("button",{onClick:o,style:of,children:"AI"}),n&&t.jsx("button",{onClick:n,style:nf,children:a.action.save})]})]}),s]})},nf={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},of={padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},ct=({label:e,value:n,onChange:o,placeholder:r,disabled:s})=>t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:{display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:e}),t.jsx("input",{type:"text",value:n,onChange:a=>o(a.target.value),placeholder:r,disabled:s,style:{width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]}),Vt=({value:e,onChange:n,placeholder:o})=>{const r=g.useRef(null);return g.useEffect(()=>{r.current&&(r.current.style.height="auto",r.current.style.height=`${r.current.scrollHeight}px`)},[e]),t.jsx("textarea",{ref:r,value:e||"",onChange:s=>n(s.target.value),placeholder:o,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},si=({children:e,color:n,style:o})=>t.jsx("span",{style:{display:"inline-block",padding:"2px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",background:n||i("primary-soft"),color:i(n?"on-color-fg":"fg"),...o},children:e});function rf(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const Qn=({value:e,onChange:n,label:o})=>{const[r,s]=g.useState(!1),a=g.useRef(null),l=rf(e||"");return g.useEffect(()=>{r&&a.current&&a.current.focus()},[r]),!r&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Ws,children:o}),t.jsxs("div",{onClick:()=>s(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:`1px solid ${i("input-border")}`,borderRadius:"2px",background:i("input-bg"),cursor:"pointer",minHeight:"30px"},children:[t.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:i("fg")},children:l.name}),t.jsx(si,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Ws,children:o}),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:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},Ws={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500};function sf(e){switch(e){case"url":return i("source-url");case"bookID":return i("source-bookid");default:return i("desc-fg")}}function af(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const cc=({items:e,onChange:n,onOpenEntityPicker:o})=>{const r=$e(),[s,a]=g.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=m=>{n(e.filter((h,f)=>f!==m)),s===m&&a(null)},c=(m,h,f)=>{const x=[...e];x[m]={...x[m],[h]:f},n(x)},p=(m,h)=>{const f=[...e];f[m]={...f[m],type:h,id:"",name:""},n(f),h==="bookID"&&o&&o(x=>{const k=[...e];k[m]={...k[m],id:x.id,name:x.title,type:"bookID"},n(k)})},u=m=>{o&&o(h=>{const f=[...e];f[m]={...f[m],id:h.id,name:h.title,type:"bookID"},n(f)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((m,h)=>t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>a(s===h?null:h),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===h?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:i("fg")},children:m.name||`${r.editor.sourcePlaceholder} ${h+1}`}),m.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:sf(m.type),color:i("on-color-fg"),borderRadius:"3px",fontWeight:500},children:af(m.type)}),t.jsx("button",{onClick:f=>{f.stopPropagation(),d(h)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:r.editor.deleteThisSource,children:"✕"})]}),s===h&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!m.type&&t.jsxs("div",{children:[t.jsx("label",{style:kt,children:r.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(h,"bookID"),style:{...Os,borderColor:i("source-bookid"),color:i("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:r.editor.fromExistingBook})]}),t.jsxs("button",{onClick:()=>p(h,"url"),style:{...Os,borderColor:i("source-url"),color:i("source-url")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),t.jsx("span",{children:"URL"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.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:kt,children:r.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const f=[...e];f[h]={...f[h],type:"",id:"",name:""},n(f)},style:Hs,children:r.action.changeType})]}),m.id&&m.name?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:i("bg"),border:`1px solid ${i("source-bookid")}`,borderRadius:"6px"},children:[t.jsx("span",{style:{color:i("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:i("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:m.id})]}),t.jsx("button",{onClick:()=>u(h),style:{background:"transparent",border:`1px solid ${i("widget-border")}`,color:i("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:r.action.reselect})]}):t.jsxs("button",{onClick:()=>u(h),style:{width:"100%",padding:"14px",border:`2px dashed ${i("widget-border")}`,borderRadius:"6px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[t.jsx("span",{children:"🔍"}),t.jsx("span",{children:r.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:kt,children:r.label.sourceName}),t.jsx("button",{onClick:()=>{const f=[...e];f[h]={...f[h],type:"",id:"",name:""},n(f)},style:Hs,children:r.action.changeType})]}),t.jsx("input",{type:"text",value:m.name,onChange:f=>c(h,"name",f.target.value),placeholder:r.editor.sourceNamePlaceholder,style:en})]}),t.jsxs("div",{children:[t.jsx("label",{style:kt,children:r.label.urlAddress}),t.jsx("input",{type:"text",value:m.id,onChange:f=>c(h,"id",f.target.value),placeholder:"https://...",style:en})]})]}),m.type&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{borderTop:`1px dashed ${i("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:t.jsx("label",{style:{...kt,opacity:.7},children:r.label.optionalInfo})}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:kt,children:r.label.detailsOptional}),t.jsx("input",{type:"text",value:m.details,onChange:f=>c(h,"details",f.target.value),placeholder:r.editor.detailsPlaceholder,style:en})]}),t.jsxs("div",{children:[t.jsx("label",{style:kt,children:r.label.positionOptional}),t.jsx("input",{type:"text",value:m.position,onChange:f=>c(h,"position",f.target.value),placeholder:"如: 卷三, p.52",style:en})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:kt,children:r.label.dataVersionOptional}),t.jsx("input",{type:"text",value:m.version,onChange:f=>c(h,"version",f.target.value),placeholder:"如: v1.0, 2024-01",style:en})]}),t.jsxs("div",{children:[t.jsx("label",{style:kt,children:r.label.processorVersionOptional}),t.jsx("input",{type:"text",value:m.processor_version,onChange:f=>c(h,"processor_version",f.target.value),placeholder:"如: v0.1",style:en})]})]})]})]})})]},h)),t.jsxs("button",{onClick:l,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:r.action.addSource})]})]})},kt={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},en={width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},Os={flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",padding:"16px 12px",background:i("bg"),border:"2px solid",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:500,transition:"all 0.2s"},Hs={background:"transparent",border:"none",color:i("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function dc(e){if(!e||!e.trim())return[];try{const n=JSON.parse(e);if(Array.isArray(n))return n.map(o=>({id:o.id||"",name:o.name||"",type:o.type||"",details:o.details||"",position:o.position||"",version:o.version||"",processor_version:o.processor_version||""}))}catch{}return[]}function pc(e){return!e||e.length===0?"":JSON.stringify(e)}const uc=({entityType:e,entityId:n,entityTitle:o,parentWork:r,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:u,onLinkEntity:m,onUnlinkEntity:h,onViewEntity:f,onCreateAndLink:x,onSaveRelations:k})=>{const y=$e();return t.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:"🔗"}),t.jsx("span",{children:y.section.relations})]}),k&&t.jsx("button",{onClick:k,style:lf,children:y.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(kn,{direction:"up",title:y.relation.belongsToWork,entity:a,onView:f,onUnlink:()=>h("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(kn,{direction:"up",title:y.relation.containedInCollection,entity:l,onView:f,onUnlink:()=>h("collectionId"),onLink:()=>m("collectionId","collection"),onCreate:()=>x("collectionId","collection",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),a&&u&&u.length>0&&t.jsx(tn,{direction:"horizontal",title:`${y.relation.siblingVersions} (${u.length})`,entities:u,onView:f,onAdd:()=>x("siblingBook","book",{workId:a.id}),addLabel:y.relation.addVersionForWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="work"&&t.jsxs(t.Fragment,{children:[t.jsx(kn,{direction:"up",title:y.relation.parentWork,entity:r,onView:f,onUnlink:()=>h("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(tn,{direction:"down",title:`${y.relation.childWorks} (${d.length})`,entities:d,onView:f,onAdd:()=>x("childWork","work",{parentWorkId:n}),addLabel:y.action.addSubWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),c&&c.length>0&&t.jsx(tn,{direction:"down",title:`${y.relation.collectionImpl} (${c.length})`,entities:c,onView:f,onAdd:()=>x("childCollection","collection",{workId:n}),addLabel:y.action.addCollectionImpl,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(tn,{direction:"down",title:`${y.relation.allVersions} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{workId:n}),addLabel:y.action.addVersion,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="collection"&&t.jsxs(t.Fragment,{children:[t.jsx(kn,{direction:"up",title:y.relation.correspondingWork,entity:a,onView:f,onUnlink:()=>h("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(kn,{direction:"up",title:y.relation.parentCollection,entity:s,onView:f,onUnlink:()=>h("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(tn,{direction:"down",title:`${y.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:f,onAdd:()=>x("childCollection","collection",{parentCollectionId:n}),addLabel:y.action.addSubCollection,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(tn,{direction:"down",title:`${y.relation.containedBooks} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{collectionId:n}),addLabel:y.action.addBook,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]})]})]})},kn=({direction:e,title:n,entity:o,onView:r,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:u,unlinkLabel:m})=>{const h=i(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),f=e==="up"?"⬆️":e==="down"?"⬇️":"↔️";return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("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:f}),t.jsx("span",{children:n})]}),o?t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:i("bg"),borderRadius:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:mc(o.type)}),t.jsx("span",{style:{fontWeight:500},children:o.title}),t.jsx("span",{style:{fontSize:"11px",opacity:.6},children:o.id})]}),t.jsxs("div",{style:{display:"flex",gap:"4px"},children:[t.jsx(Fs,{onClick:()=>r(o),title:u,children:"👁️"}),t.jsx(Fs,{onClick:s,title:m,danger:!0,children:"✕"})]})]}):t.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:p}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsx(yo,{onClick:a,children:d}),t.jsx(yo,{onClick:l,primary:!0,children:c})]})]})},tn=({direction:e,title:n,entities:o,onView:r,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=g.useState(!1),u=i(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),m=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",h=c?o:o.slice(0,5);return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("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:m}),t.jsx("span",{children:n})]}),o.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[h.map(f=>t.jsxs("div",{onClick:()=>r(f),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:i("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[t.jsx("span",{children:mc(f.type)}),t.jsx("span",{children:f.title})]},f.id)),o.length>5&&!c&&t.jsxs("div",{onClick:()=>p(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:i("link-fg"),cursor:"pointer"},children:[d," (",o.length-5,")"]})]}):t.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:l}),t.jsx("div",{style:{marginTop:"8px"},children:t.jsxs(yo,{onClick:s,primary:!0,children:["+ ",a]})})]})},Fs=({onClick:e,title:n,danger:o,children:r})=>t.jsx("button",{onClick:s=>{s.stopPropagation(),e()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:o?i("danger"):"inherit",opacity:.7},children:r}),yo=({onClick:e,primary:n,children:o})=>t.jsx("button",{onClick:e,style:{padding:"4px 10px",fontSize:"11px",border:n?"none":`1px solid ${i("widget-border")}`,borderRadius:"4px",background:n?i("primary"):"transparent",color:n?i("primary-fg"):"inherit",cursor:"pointer"},children:o});function mc(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const lf={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},hc=({isOpen:e,entityType:n,title:o,onSelect:r,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[u,m]=g.useState(""),h=p?l.filter(y=>y.id!==p):l;g.useEffect(()=>{e&&(m(""),d(""))},[e]);const f=y=>{m(y),d(y)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",k=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:cf,children:t.jsxs("div",{style:df,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:o}),t.jsx("button",{onClick:s,style:pf,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:u,onChange:y=>f(y.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:uf})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:Yi,children:"搜索中..."}):h.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:h.map(y=>t.jsxs("div",{onClick:()=>r(y),style:mf,children:[t.jsx("span",{style:{fontSize:"16px"},children:k}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[y.title,y.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:y.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[y.id,y.author&&` · ${y.author}`,y.dynasty&&` · ${y.dynasty}`]})]})]},y.id))}):u?t.jsxs("div",{style:Yi,children:["未找到匹配的",x]}):t.jsxs("div",{style:Yi,children:["输入关键词搜索",x]})}),t.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsxs("button",{onClick:a,style:hf,children:["创建新",x,"并关联"]})]})]})})},cf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},df={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",width:"500px",maxWidth:"calc(100vw - 32px)",maxHeight:"70vh",display:"flex",flexDirection:"column",boxShadow:i("shadow-dialog")},pf={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},uf={width:"100%",padding:"10px 12px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"},mf={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:i("primary-soft")},Yi={padding:"20px",textAlign:"center",color:i("desc-fg")},hf={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Ds={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},gf={work:"📜",book:"📖",collection:"📚",entity:"👤"},gc=({isOpen:e,entityType:n,relationField:o,inheritData:r,onConfirm:s,onCancel:a})=>{const[l,d]=g.useState(""),c=g.useRef(null);g.useEffect(()=>{e&&(d((r==null?void 0:r.title)||""),setTimeout(()=>{var h,f;(h=c.current)==null||h.focus(),(f=c.current)==null||f.select()},100))},[e,r==null?void 0:r.title]);const p=h=>{h.key==="Enter"&&l.trim()?u():h.key==="Escape"&&a()},u=()=>{l.trim()&&s(l.trim(),{...r,title:l.trim()})};if(!e)return null;const m=()=>{switch(o){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`创建新${Ds[n]}`}};return t.jsx("div",{style:ff,onClick:h=>{h.target===h.currentTarget&&a()},children:t.jsxs("div",{style:xf,onClick:h=>h.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:gf[n]}),t.jsx("span",{children:m()})]}),t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:i("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",t.jsx("span",{style:{color:i("danger"),marginLeft:"4px"},children:"*"})]}),t.jsx("input",{ref:c,type:"text",value:l,onChange:h=>d(h.target.value),onKeyDown:p,placeholder:`请输入${Ds[n]}名称...`,style:bf})]}),((r==null?void 0:r.author)||(r==null?void 0:r.dynasty))&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),background:i("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[t.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(r==null?void 0:r.author)&&t.jsxs("div",{children:["作者: ",r.author]}),(r==null?void 0:r.dynasty)&&t.jsxs("div",{children:["朝代/年份: ",r.dynasty]})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[t.jsx("button",{onClick:a,style:yf,children:"取消"}),t.jsx("button",{onClick:u,disabled:!l.trim(),style:{...jf,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},ff={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},xf={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:i("shadow-dialog")},bf={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box"},yf={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},jf={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg")};function vf(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function fc(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function kf(e){switch(e){case"work":return i("editor-type-work");case"collection":return i("editor-type-collection");case"book":return i("editor-type-book");default:return i("desc-fg")}}const xc=({isOpen:e,title:n,filterType:o="all",recentEntities:r=[],excludeId:s,showCreateButton:a=!1,createButtonText:l,onSelect:d,onCancel:c,onCreate:p,onSearch:u})=>{const[m,h]=g.useState(""),[f,x]=g.useState([]),[k,y]=g.useState(!1),[w,b]=g.useState("recent");g.useEffect(()=>{e&&(h(""),x([]),b(r.length>0?"recent":"search"))},[e,r.length]),g.useEffect(()=>{if(!m.trim()){x([]);return}const C=setTimeout(async()=>{y(!0);try{x(await u(m,o))}catch{x([])}finally{y(!1)}},300);return()=>clearTimeout(C)},[m,o,u]);const j=g.useCallback(C=>{h(C.target.value),C.target.value.trim()&&b("search")},[]),S=g.useCallback(C=>s?C.filter(M=>M.id!==s):C,[s]);if(!e)return null;const v=n||(o==="all"?"选择实体":`选择${fc(o)}`),$=S(r),_=S(f);return t.jsx("div",{style:Sf,children:t.jsxs("div",{style:_f,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:v}),t.jsx("button",{onClick:c,style:$f,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:j,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Cf}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),k&&t.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),$.length>0&&t.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsxs(Us,{active:w==="recent",onClick:()=>b("recent"),children:["最近使用 (",$.length,")"]}),t.jsxs(Us,{active:w==="search",onClick:()=>b("search"),children:["搜索结果 ",_.length>0&&`(${_.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:w==="recent"&&$.length>0?t.jsx(Vs,{entities:$,onSelect:d}):m.trim()?k?t.jsx(Ki,{message:"搜索中..."}):_.length>0?t.jsx(Vs,{entities:_,onSelect:d}):t.jsx(Ki,{message:"未找到匹配的结果"}):t.jsx(Ki,{message:"输入关键词开始搜索"})}),a&&p&&t.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsx("button",{onClick:p,style:zf,children:l||"创建新实体"})]})]})})},Us=({active:e,onClick:n,children:o})=>t.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(e?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:e?600:400,marginBottom:"-1px"},children:o}),Vs=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(o=>t.jsx(wf,{entity:o,onClick:()=>n(o)},o.id))}),wf=({entity:e,onClick:n})=>{const[o,r]=g.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:i("primary-soft"),transition:"background 0.1s"},children:[t.jsx("span",{style:{fontSize:"18px"},children:vf(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:i("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:i("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:kf(e.type),color:i("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:fc(e.type)})]})},Ki=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:e}),Sf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},_f={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",width:"550px",maxWidth:"calc(100vw - 32px)",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:i("shadow-dialog")},$f={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Cf={width:"100%",padding:"12px 16px",paddingLeft:"40px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"},zf={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Tf={work:i("editor-type-work"),collection:i("editor-type-collection"),book:i("editor-type-book"),entity:i("editor-type-entity")},Nf={work:"📜",collection:"📚",book:"📖",entity:"👤"},bc=({data:e,onChange:n,onSave:o,transport:r,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:u,relations:m,onRelationsChange:h})=>{var Se;const f=$e(),[x,k]=g.useState(!1),[y,w]=g.useState("work"),[b,j]=g.useState(""),[S,v]=g.useState(""),[$,_]=g.useState([]),[C,M]=g.useState(!1),[T,z]=g.useState(!1),[F,N]=g.useState("work"),[R,O]=g.useState(""),[I,P]=g.useState(),[U,K]=g.useState(!1),[L,Z]=g.useState(null),[A,V]=g.useState([]);g.useRef(null);const ce=e.type,ne=ce==="work",de=ce==="collection",pe=ce==="book",be=g.useCallback((X,Ce)=>{n({...e,[X]:Ce})},[e,n]),Oe=g.useCallback((X,Ce)=>{j(X),w(Ce),v(f.editor.selectToLink+f.indexType[Ce]),_([]),k(!0)},[f]),ie=g.useCallback(X=>{r!=null&&r.unlinkEntity&&r.unlinkEntity(e.id,X)},[r,e.id]),Le=g.useCallback(X=>{s==null||s(X.id,X.type)},[s]),Ae=g.useCallback((X,Ce,Me)=>{const B={...Me,author:(Me==null?void 0:Me.author)||e.author,dynasty:Me==null?void 0:Me.dynasty};N(Ce),O(X),P(B),z(!0)},[e.author]),q=g.useCallback((X,Ce)=>{r!=null&&r.createAndLink&&r.createAndLink(e.id,R,{type:F,title:X,inheritData:Ce}),z(!1)},[r,e.id,R,F]),Q=g.useCallback(X=>{if(!X.trim()){_([]);return}M(!0),r!=null&&r.searchEntities&&r.searchEntities(X,y).then(Ce=>{_(Ce),M(!1)}).catch(()=>{_([]),M(!1)})},[r,y]),fe=g.useCallback(X=>{r!=null&&r.linkEntity&&r.linkEntity(e.id,b,X.id),k(!1)},[r,e.id,b]),ze=g.useCallback(()=>{o()},[o]),Y=g.useCallback(X=>{Z(()=>X),K(!0),r!=null&&r.getRecentEntities&&r.getRecentEntities().then(V).catch(()=>{})},[r]),ve=g.useCallback((X,Ce)=>r!=null&&r.searchEntities?r.searchEntities(X,Ce==="all"?void 0:Ce):Promise.resolve([]),[r]),le=g.useCallback(X=>{r!=null&&r.addRecentEntity&&r.addRecentEntity(X),V(Ce=>[X,...Ce.filter(Me=>Me.id!==X.id)].slice(0,10)),L==null||L(X),K(!1),Z(null)},[r,L]);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 ${i("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:Nf[ce]}),t.jsx("span",{children:e.title||f.editor.untitled}),t.jsx(si,{children:e.id}),t.jsx(si,{color:Tf[ce],children:f.indexType[ce]})]})}),t.jsx(ft,{title:f.section.basicInfo,onSave:o,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(Qn,{label:ne?f.editor.workTitle:de?f.editor.collectionTitle:f.editor.bookTitle,value:e.title,onChange:X=>be("title",X)}),pe&&t.jsx(Qn,{label:f.editor.belongsToWork,value:e.workName||"",onChange:X=>be("workName",X)}),t.jsx(ct,{label:f.editor.authorLabel,value:e.author||"",onChange:X=>be("author",X)}),t.jsx(ct,{label:f.editor.publicationYearLabel,value:e.publicationYear||"",onChange:X=>be("publicationYear",X)}),(pe||de)&&t.jsx(Qn,{label:f.editor.containedIn,value:e.collection||"",onChange:X=>be("collection",X)}),(pe||de)&&t.jsx(ct,{label:f.editor.holderLabel,value:e.holder||"",onChange:X=>be("holder",X)}),(pe||de)&&t.jsx(ct,{label:pe?f.editor.pageLabel:f.editor.volumeLabel,value:e.pages||"",onChange:X=>be("pages",X)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(ct,{label:f.editor.firstImageLabel,value:e.firstImage||"",onChange:X=>be("firstImage",X)})})]})}),t.jsx(ft,{title:f.section.description,onSave:o,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(Vt,{value:e.description||"",onChange:X=>be("description",X),placeholder:f.editor.descriptionPlaceholder})}),(((Se=e.additional_works)==null?void 0:Se.length)||0)>0&&t.jsx(ft,{title:f.section.additionalWorks,onSave:o,children:t.jsx(Ef,{items:e.additional_works||[],onChange:X=>be("additional_works",X)})}),t.jsx(ft,{title:f.section.indexedBy,onSave:o,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(If,{items:e.indexed_by||[],onChange:X=>be("indexed_by",X)})}),t.jsx(ft,{title:f.section.emendatedBy,onSave:o,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(Rf,{items:e.emendated_by||[],onChange:X=>be("emendated_by",X)})}),t.jsx(ft,{title:f.section.textResources,onSave:o,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(eo,{items:e.resources||[],onChange:X=>be("resources",X),onDownload:p,downloadStatuses:u,filterType:"text"})}),t.jsx(ft,{title:f.section.imageResources,onSave:o,children:t.jsx(eo,{items:e.resources||[],onChange:X=>be("resources",X),onDownload:p,downloadStatuses:u,filterType:"image"})}),t.jsx(ft,{title:f.section.sources,onSave:o,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(cc,{items:dc(e.sources||""),onChange:X=>be("sources",pc(X)),onOpenEntityPicker:Y})}),(pe||de)&&t.jsx(ft,{title:f.section.provenance,onSave:o,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(Vt,{value:e.provenance||"",onChange:X=>be("provenance",X),placeholder:f.editor.provenancePlaceholder})}),pe&&t.jsx(ft,{title:f.section.otherEditions,onSave:o,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(Vt,{value:e.otherEditions||"",onChange:X=>be("otherEditions",X),placeholder:f.editor.otherEditionsPlaceholder})}),t.jsx(uc,{entityType:ce,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:Oe,onUnlinkEntity:ie,onViewEntity:Le,onCreateAndLink:Ae,onSaveRelations:ze}),a&&l&&t.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${i("danger-soft-border")}`,background:i("danger-soft-bg"),borderRadius:"4px"},children:[t.jsx("div",{style:{color:i("danger"),fontWeight:600,marginBottom:"8px"},children:f.section.dangerZone}),t.jsx("p",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"12px"},children:f.editor.dangerZoneDesc}),t.jsx("button",{onClick:l,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("danger")}`,borderRadius:"4px",background:"transparent",color:i("danger"),cursor:"pointer"},children:f.editor.deleteEntity})]}),t.jsx(hc,{isOpen:x,entityType:y,title:S,onSelect:fe,onCancel:()=>k(!1),onCreate:()=>{k(!1),Ae(b,y)},searchResults:$,onSearch:Q,isLoading:C,excludeId:e.id}),t.jsx(gc,{isOpen:T,entityType:F,relationField:R,inheritData:I,onConfirm:q,onCancel:()=>z(!1)}),t.jsx(xc,{isOpen:U,title:f.action.selectBookOrWork,filterType:"all",recentEntities:A,excludeId:e.id,onSelect:le,onCancel:()=>{K(!1),Z(null)},onSearch:ve})]})};function Ef({items:e,onChange:n}){const o=$e(),r=(l,d,c)=>{const p=e.map((u,m)=>m===l?{...u,[d]:c}:u);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(ct,{label:o.editor.bookNameLabel,value:l.book_title,onChange:c=>r(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(ct,{label:o.label.juanCount,value:l.n_juan!=null?String(l.n_juan):"",onChange:c=>r(d,"n_juan",c&&parseInt(c,10)||void 0)})}),t.jsx("button",{onClick:()=>s(d),style:{padding:"4px 8px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("muted"),marginTop:"18px"},children:"✕"})]},d)),t.jsx("button",{onClick:a,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${i("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("desc-fg"),alignSelf:"flex-start"},children:o.action.addAdditionalWork})]})}function yc({items:e,onChange:n,showMeta:o,addLabel:r}){const s=$e(),[a,l]=g.useState(null),d=(u,m,h)=>{const f=e.map((x,k)=>k===u?{...x,[m]:h||void 0}:x);n(f)},c=u=>{n(e.filter((m,h)=>h!==u)),a===u&&l(null)},p=()=>{n([...e,{source:""}]),l(e.length)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((u,m)=>{const h=a===m;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:h?`color-mix(in srgb, ${i("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(h?null:m),children:[t.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.2s",transform:h?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:u.source||s.editor.unnamedSource}),u.source_bid&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u.source_bid}),t.jsx("button",{onClick:f=>{f.stopPropagation(),c(m)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${i("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:i("muted")},children:"✕"})]}),!h&&o&&(u.title_info||u.author_info)&&t.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:i("desc-fg")},children:[u.title_info,u.title_info&&u.author_info&&" — ",u.author_info]}),h&&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(ct,{label:s.label.sourceName,value:u.source,onChange:f=>d(m,"source",f)}),t.jsx(ct,{label:s.label.sourceBid,value:u.source_bid||"",onChange:f=>d(m,"source_bid",f)})]}),o&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(ct,{label:s.label.titleInfo,value:u.title_info||"",onChange:f=>d(m,"title_info",f)}),t.jsx(ct,{label:s.label.authorInfo,value:u.author_info||"",onChange:f=>d(m,"author_info",f)})]}),t.jsx(ct,{label:s.label.edition,value:u.edition||"",onChange:f=>d(m,"edition",f)})]}),t.jsx(Vt,{value:u.summary||"",onChange:f=>d(m,"summary",f),placeholder:s.editor.summaryPlaceholder}),t.jsx(Vt,{value:u.comment||"",onChange:f=>d(m,"comment",f),placeholder:s.editor.commentPlaceholder}),t.jsx(Vt,{value:u.additional_comment||"",onChange:f=>d(m,"additional_comment",f),placeholder:s.editor.additionalCommentPlaceholder})]})]},m)}),t.jsx("button",{onClick:p,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${i("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("desc-fg"),alignSelf:"flex-start"},children:r})]})}function If({items:e,onChange:n}){const o=$e();return t.jsx(yc,{items:e,onChange:n,showMeta:!0,addLabel:o.action.addIndexedBy})}function Rf({items:e,onChange:n}){const o=$e();return t.jsx(yc,{items:e,onChange:n,addLabel:o.action.addEmendatedBy})}function jc(e){var d,c,p,u,m,h,f;const n=((c=(d=e.authors)==null?void 0:d[0])==null?void 0:c.name)||"",o=((p=e.publication_info)==null?void 0:p.year)||"",r=((u=e.current_location)==null?void 0:u.name)||"",s=(m=e.page_count)!=null&&m.number?String(e.page_count.number):((h=e.page_count)==null?void 0:h.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:o,holder:r,pages:s,description:a,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};if(e.type==="work"){const x=e;if(Array.isArray(x.related_works)){const k=x.related_works.find(y=>y.relation==="part_of");k&&(l.parentWorkId=k.id,l.parentWorkName=k.title)}}if(e.type==="book"){const x=e;l.workId=x.work_id,Array.isArray(x.contained_in)&&x.contained_in.length>0&&(l.collectionId=(f=x.contained_in[0])==null?void 0:f.id)}return l}function Lf(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 Af=e=>{const{data:n,id:o,transport:r,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:u,onAskAI:m,renderSectionActions:h,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y,headerExtra:w,className:b,style:j}=e,S=$e(),[v,$]=g.useState(s),_=a?s:v;g.useEffect(()=>{s!==v&&$(s)},[s]);const C=g.useCallback(()=>{const O=_==="view"?"edit":"view";a?a(O):$(O)},[_,a]),[M,T]=g.useState(null);g.useEffect(()=>{o&&r&&r.getItem(o).then(O=>{O&&T(O)})},[o,r]);const z=n||M,F=g.useMemo(()=>z?jc(z):null,[z]),N=a||!n?t.jsx("button",{onClick:C,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:_==="edit"?i("accent-bg"):"transparent",color:i(_==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:_==="view"?S.common.switchToEdit:S.common.switchToView,children:_==="view"?S.common.modeEdit:S.common.modeView}):null,R=t.jsxs(t.Fragment,{children:[N,w]});return!z&&!F?t.jsx(Kt,{}):_==="view"?t.jsx(Ao,{data:z,transport:r,onNavigate:p?O=>p(O):void 0,renderLink:u,headerExtra:R,className:b,style:j}):F?t.jsxs("div",{className:b,style:j,children:[R&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:R}),t.jsx(bc,{data:F,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:r,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:m,renderSectionActions:h,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:i("muted")},children:S.common.noData})},Pf=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],vc=({isOpen:e,onClose:n,onSubmit:o,feedbackListUrl:r})=>{const{t:s}=J(),[a,l]=g.useState(null),[d,c]=g.useState(""),[p,u]=g.useState(""),[m,h]=g.useState("idle"),[f,x]=g.useState(""),k=g.useRef(null);g.useEffect(()=>{e&&(l(null),c(""),u(""),h("idle"),x(""))},[e]),g.useEffect(()=>{a&&setTimeout(()=>{var b;return(b=k.current)==null?void 0:b.focus()},100)},[a]),g.useEffect(()=>{if(m==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[m,n]),g.useEffect(()=>{if(!e)return;const b=j=>{j.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,n]);const y=async()=>{if(!(!a||!d.trim())){h("submitting"),x("");try{await o({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),h("success")}catch(b){h("error"),x(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const w=a&&d.trim()&&m!=="submitting";return t.jsx("div",{style:Mf,onClick:b=>{b.target===b.currentTarget&&n()},children:t.jsxs("div",{style:Bf,onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{style:Wf,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:Of,"aria-label":s("feedback.close"),children:"✕"})]}),m==="success"?t.jsxs("div",{style:Vf,children:[t.jsx("span",{style:{fontSize:"32px"},children:"✓"}),t.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:s("feedback.thanks")}),r&&t.jsx("a",{href:r,style:{fontSize:"13px",color:i("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:Pf.map(b=>t.jsxs("button",{onClick:()=>l(b.value),style:{...Hf,...a===b.value?Ff:{}},children:[t.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),t.jsx("textarea",{ref:k,value:d,onChange:b=>c(b.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||m==="submitting",style:{...Df,opacity:a?1:.6}}),t.jsx("input",{type:"text",value:p,onChange:b=>u(b.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!a||m==="submitting","aria-label":s("feedback.contactLabel"),style:Yf}),t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),m==="error"&&t.jsx("div",{style:Gf,children:f}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:y,disabled:!w,style:{...Uf,opacity:w?1:.6,cursor:w?"pointer":"not-allowed"},children:s(m==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},Mf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Bf={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:i("shadow-dialog")},Wf={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},Of={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:i("desc-fg"),padding:"4px 8px",borderRadius:"4px"},Hf={flex:"1 1 calc(50% - 4px)",padding:"10px 12px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},Ff={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},Df={width:"100%",minHeight:"120px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},Uf={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},Vf={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:i("success")},Gf={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginBottom:"12px"},Yf={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"},jo="--bim-feedback-fab-offset",vo=48,Kf=16,qf=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:o,hidden:r=!1,zIndex:s})=>{const{t:a}=J(),[l,d]=g.useState(!1),c=n.bottom??24;return g.useEffect(()=>{if(r||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(jo,`calc(${c+vo+Kf}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(jo)}},[r,c]),t.jsxs(t.Fragment,{children:[!r&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...Xf,zIndex:s??i("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(vc,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:o})]})},Xf={position:"fixed",width:`${vo}px`,height:`${vo}px`,borderRadius:"50%",border:"none",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:i("shadow-fab"),transition:"transform 0.2s, box-shadow 0.2s"},Zf=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],kc=({onSubmit:e})=>{const{t:n}=J(),[o,r]=g.useState("bug"),[s,a]=g.useState(""),[l,d]=g.useState(""),[c,p]=g.useState("idle"),[u,m]=g.useState(""),h=g.useRef(null);g.useEffect(()=>{o&&setTimeout(()=>{var k;return(k=h.current)==null?void 0:k.focus()},100)},[o]);const f=async()=>{if(!(!o||!s.trim())){p("submitting"),m("");try{await e({type:o,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),r("bug")}catch(k){p("error"),m(k instanceof Error?k.message:n("feedback.submitFailedRetry"))}}},x=o&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:Gs,children:t.jsxs("div",{style:nx,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:ix,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:Gs,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:Zf.map(k=>t.jsxs("button",{onClick:()=>r(k.value),style:{...Jf,...o===k.value?Qf:{}},children:[t.jsx("span",{children:k.icon})," ",n(`feedback.submitType.${k.value}`)]},k.value))}),t.jsx("textarea",{ref:h,value:s,onChange:k=>a(k.target.value),placeholder:n(o?`feedback.placeholder.${o}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...ex}}),t.jsx("input",{type:"text",value:l,onChange:k=>d(k.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:rx}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[s.length," / 2000"]}),t.jsx("button",{onClick:f,disabled:!x,style:{...tx,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:ox,children:u})]})},Gs={padding:"16px",border:`1px solid ${i("widget-border")}`,borderRadius:"8px",background:i("input-bg")},Jf={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:"transparent",color:i("fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},Qf={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},ex={width:"100%",minHeight:"100px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},tx={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},nx={display:"flex",alignItems:"center",gap:"12px",color:i("success"),fontSize:"14px"},ix={background:"none",border:"none",color:i("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},ox={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginTop:"8px"},rx={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"};function Ys(e){return typeof e=="function"?e():e??"/api/feedback"}const wc=({resourceId:e,apiUrl:n})=>{const{t:o}=J(),[r,s]=g.useState([]),[a,l]=g.useState(!0),d=g.useCallback(async()=>{const p=Ys(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]);g.useEffect(()=>{d()},[d]);const c=async p=>{const u=Ys(n),m=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!m.ok){const h=await m.json().catch(()=>null);throw new Error((h==null?void 0:h.error)||o("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(gr,{items:r,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(kc,{onSubmit:c})})]})},sx=li["zh-Hant"].relation,ax=li["zh-Hant"].lossStatus,lx=li["zh-Hant"].resourceKind,ki=cn("zh-Hant"),fr=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function Ks(e,n=ki){return e?fr(sx,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function cx(e,n=ki){return fr(ax,e)?n(`detail.lossStatus.${e}`):e}function dx(e,n=ki){return fr(lx,e)?n(`detail.resourceKind.${e}`):""}function xr({authors:e,onNavigate:n,renderLink:o}){const{convert:r}=J(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=Uo(a.role);return t.jsxs(g.Fragment,{children:[l>0&&" ",a.dynasty&&t.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",r(a.dynasty),"〕"]}),a.entity_id?t.jsx(qe,{id:a.entity_id,label:r(a.name),onNavigate:n,renderLink:o,dense:!0}):r(a.name),d&&t.jsx("span",{style:{marginLeft:4},children:r(d)})]},l)})}):null}function Sc(e,n,o=ki){var c,p;const r=Fo(e,n),s=r.mirrors.map(u=>({key:u.key,label:u.label,description:u.description,rows:u.items.filter(m=>m.group_role!=="mirror"),mirrors:u.items.filter(m=>m.group_role==="mirror")})),a=r.buckets.filter(u=>u.key==="image"||u.key==="textImage").flatMap(u=>u.items);a.length&&s.push({key:"_images",label:s.length?o("detail.otherImages"):void 0,rows:a,mirrors:[]});const l=((c=r.buckets.find(u=>u.key==="physical"))==null?void 0:c.items)??[];return l.length&&s.push({key:"_physical",label:o("detail.resourceKind.physical"),rows:l,mirrors:[]}),{text:((p=r.buckets.find(u=>u.key==="text"))==null?void 0:p.items)??[],groups:s}}function _c(e,n){const o=(e.url?dn(e.url):void 0)||e.name,r=xl(e,n);return r?`${o}(${r})`:o}function br({item:e,siblings:n,listedVolumeCounts:o}){const{t:r,convert:s}=J(),[a,l]=g.useState(!1),d=ci(e),c=!!d&&d.expected>0&&!(o!=null&&o.has(d.expected)),p=s(_c(e,n)),u=pn(e),m=xi(e,r)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var f,x;const h=(f=e.metadata)!=null&&f.fragment||e.color_mode?t.jsxs("span",{className:"bim-d-tags bim-d-ui",style:{display:"inline-flex",margin:"0 0 0 8px",verticalAlign:"middle"},children:[((x=e.metadata)==null?void 0:x.fragment)&&t.jsx("span",{className:"bim-d-tag",children:r("detail.fragmentTag")}),e.color_mode&&t.jsx("span",{className:"bim-d-tag",children:e.color_mode==="color"?r("colorMode.color"):r("colorMode.bw")})]}):null;return u?t.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:[p," ",t.jsx("span",{"aria-hidden":"true",children:"↗"}),h]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,h]})})(),m&&t.jsx("span",{className:"bim-d-meta",children:s(m)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(qo,{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(h=>!h),children:a?r("detail.collapseVolumes"):r("detail.expandVolumes",{n:d.expected})})})]})}function $c({groups:e,listedVolumeCounts:n}){const{t:o,convert:r}=J();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:r(s.label)}),s.description&&t.jsx("p",{className:"bim-d-rg-d",children:r(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(br,{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:o("detail.mirror")}),s.mirrors.map((a,l)=>{const d=pn(a),c=r(_c(a,s.mirrors));return d?t.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",title:a.details?r(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 Nn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function ko(e){var o;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(o=Nn.find(r=>n.startsWith(r.key[0])))==null?void 0:o.key}const qs=12,px=60,Cc=({data:e,transport:n,onNavigate:o,renderLink:r,readAction:s,railTop:a,back:l,railLinks:d})=>{var Q,fe,ze;const{t:c,convert:p,messages:u}=J(),m=g.useMemo(()=>[...e.books||[],...e.collections||[]],[e.books,e.collections]),[h,f]=g.useState(new Map),[x,k]=g.useState(!1),[y,w]=g.useState(""),[b,j]=g.useState(!1),S=m.length<=px,v=S||x||!!y||b,$=g.useMemo(()=>v?m:m.slice(0,qs),[m,v]);g.useEffect(()=>{if(!n||$.length===0)return;const Y=$.filter(le=>!h.has(le));if(Y.length===0)return;let ve=!1;return Promise.all(Y.map(le=>n.getItem(le).then(Se=>{const X=Se??{};return[le,{id:le,title:X.title,edition:X.edition,resources:X.resources,publication_info:X.publication_info,current_location:X.current_location,lineage:X.lineage,measure_info:X.measure_info}]}).catch(()=>[le,{id:le}]))).then(le=>{ve||f(Se=>{const X=new Map(Se);for(const[Ce,Me]of le)X.set(Ce,Me);return X})}),()=>{ve=!0}},[n,$,h]);const _=g.useMemo(()=>m.map(Y=>h.get(Y)??{id:Y}),[m,h]),C=m.length>0&&m.every(Y=>h.has(Y)),M=!!n&&$.some(Y=>!h.has(Y)),T=S||v,z=g.useMemo(()=>yl(_,e.version_graph,{era:y,scanOnly:b,sort:T?"year":"default"}),[_,e.version_graph,y,b,T]),F=x?z.rows:z.rows.slice(0,qs),N=z.allRows.filter(Y=>Y.hasImage).length,R=e.related_works||[],O=R.filter(Y=>Y.relation==="collected_in"),I=g.useMemo(()=>{const Y=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],ve=le=>{const Se=Y.indexOf(le??"");return Se<0?Y.length:Se};return R.filter(le=>le.relation!=="collected_in").map((le,Se)=>({r:le,i:Se})).sort((le,Se)=>ve(le.r.relation)-ve(Se.r.relation)||le.i-Se.i).map(le=>le.r)},[R]),P=g.useMemo(()=>{const Y=Fo(e.resources,e.resource_groups);return[...Y.mirrors.flatMap(ve=>ve.items.map(le=>({r:le,kind:p(ve.label)}))),...Y.buckets.flatMap(ve=>ve.items.map(le=>({r:le,kind:p(dx(ve.key,c))})))]},[e.resources,e.resource_groups,p,c]),U=e.indexed_by||[],K=e.emendated_by||[],L=g.useMemo(()=>{var ee,ye,H;const Y=[],ve=(ye=(ee=e.authors)==null?void 0:ee[0])==null?void 0:ye.dynasty;ve&&Y.push({label:c("workPage.fact.written"),value:p(ve)});const le=Ct(e,u.unit.juan);if(le){const se=(H=e.juan_count)==null?void 0:H.description;Y.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(le),se&&se!==le?t.jsxs("span",{className:"bim-d-meta",children:["(",p(se),")"]}):null]})})}e.loss_status&&Y.push({label:c("workPage.fact.loss"),value:p(cx(e.loss_status,c))});const Se=z.allRows.filter(se=>se.sortYear!=null),X=Se.length>0?Se.reduce((se,te)=>se.sortYear<=te.sortYear?se:te):null;X!=null&&X.era.era?Y.push({label:c("workPage.fact.earliest"),value:p([X.era.era,X.era.reign].filter(Boolean).join(" ")),title:X.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):M&&Y.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),K.length&&Y.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:K.length})});const Ce=Xs(e.additional_titles);Ce.length&&Y.push({label:c("workPage.fact.alias"),value:Ce.map(p).join("、")});const Me=Xs(e.attached_texts);Me.length&&Y.push({label:c("workPage.fact.attached"),value:Me.map(p).join("、")});const B=(e.additional_works||[]).map(se=>p(se.book_title)+(se.n_juan!=null?` ${se.n_juan}${u.unit.juan}`:""));return B.length&&Y.push({label:c("workPage.fact.appendix"),value:B.join("、")}),Y},[e,p,c,u,M,z.allRows,K.length]),A=[{value:e._edition_count??m.length,label:c("workPage.stat.editions")},{value:C?N:0,label:c("workPage.stat.hasImage")},{value:U.length,label:c("workPage.stat.catalogs")}],V=e.classification,ce=V?[V.l1,V.l2,V.l3,V.l4].filter(Boolean).map(Y=>p(Y)):[],ne=e.subtype?u.workSubtype[e.subtype]??p(e.subtype):"",de=t.jsx(Ln,{title:p(e.title),byline:t.jsx(xr,{authors:e.authors,onNavigate:o,renderLink:r}),meta:t.jsx(Je,{items:[...ce,V!=null&&V.source?c("workPage.classifiedBy",{source:p(V.source.split("/")[0])}):"",ne]}),description:(Q=e.description)!=null&&Q.text?t.jsxs(t.Fragment,{children:[t.jsx($t,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(fe=e.description.sources)!=null&&fe.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(Y=>p(zm(Y))).filter(Boolean).join(" · ")}):null]}):void 0,stats:A,facts:L,readAction:s,foot:t.jsx(An,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(ze=e.appendix)==null?void 0:ze.map((Y,ve)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(Y.title)}),t.jsx($t,{text:Y.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},ve))}),pe=z.eras.length>=2?[{key:"",label:c("catalog.all")},...z.eras.map(Y=>({key:Y,label:`${Y} ${z.allRows.filter(ve=>ve.era.era===Y).length}`}))]:[],be=[];m.length&&be.push({id:"versions",label:c("workPage.sec.versions"),count:m.length}),U.length&&be.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:U.length}),O.length&&be.push({id:"collected",label:c("workPage.sec.collected"),count:O.length}),I.length&&be.push({id:"related",label:c("workPage.sec.related"),count:I.length}),P.length&&be.push({id:"resources",label:c("workPage.sec.resources"),count:P.length});const Oe=m.length===0&&U.length===0,ie=t.jsxs(t.Fragment,{children:[m.length>0&&t.jsxs(et,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(Je,{items:[c("workPage.versionsTotal",{n:m.length}),C&&N?c("workPage.versionsWithImage",{n:N}):"",z.rows.length!==z.allRows.length?c("workPage.versionsCurrent",{n:z.rows.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":M&&pe.length===0&&m.length>1?"":void 0,children:[pe.length>0&&t.jsx(yi,{items:pe,value:y,onChange:Y=>{w(Y),k(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx($l,{label:c("workPage.scanOnly"),checked:b,onChange:Y=>{j(Y),k(!1)}}),t.jsx("span",{className:"bim-d-meta",children:c(T?"workPage.sortByYear":"workPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&ji(z.rows.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:c("workPage.col.edition")}),t.jsx("th",{children:c("workPage.col.era")}),t.jsx("th",{children:c("workPage.col.holder")}),t.jsx("th",{children:t.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:c("workPage.col.image")})})]})}),t.jsx("tbody",{children:F.map(Y=>{var ve;return t.jsx(ux,{row:Y,measure:(ve=h.get(Y.id))==null?void 0:ve.measure_info,loaded:h.has(Y.id),onNavigate:o,renderLink:r},`${Y.id}:${h.has(Y.id)?"r":"p"}`)})})]}),F.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(Vo,{total:z.rows.length,shown:F.length,unit:c("workPage.moreUnit"),onClick:()=>k(!0)}),z.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),U.length>0&&t.jsx(mx,{items:U,transport:n,onNavigate:o,renderLink:r}),Oe&&t.jsx(et,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),Le=(Y,ve)=>t.jsx(qe,{id:Y,label:p(ve),onNavigate:o,renderLink:r,dense:!0}),Ae=g.useMemo(()=>{const Y=new Map;for(const ve of I){const le=Ks(ve.relation,c);Y.set(le,(Y.get(le)??0)+1)}return Y.size>1?[...Y.entries()].sort((ve,le)=>le[1]-ve[1]).slice(0,4).map(([ve,le])=>`${p(ve)} ${le}`).join(" · "):void 0},[I,p,c]),q=t.jsxs(t.Fragment,{children:[t.jsx(Ut,{id:"collected",title:c("workPage.sec.collected"),items:O.map(Y=>Le(Y.id,Y.title))}),t.jsx(Ut,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:I.length}),sub:Ae,items:I.map(Y=>t.jsxs(t.Fragment,{children:[Le(Y.id,Y.title),t.jsx("span",{className:"bim-d-meta",title:Y.note?p(Y.note):void 0,children:p(Ks(Y.relation,c))})]}))}),t.jsx(Ut,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:P.map(({r:Y,kind:ve})=>{const le=p((Y.url?dn(Y.url):void 0)||Y.name),Se=pn(Y);return t.jsxs(t.Fragment,{children:[Se?t.jsxs("a",{href:Se,target:"_blank",rel:"noopener noreferrer",children:[le," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:le}),ve&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:ve})]})})})]});return t.jsx(Rn,{railTop:a,back:l,nav:be,railLinks:d,main:ie,card:de,side:q})};function Xs(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Zs(e,n){return n((e.url?dn(e.url):void 0)||e.name)}function ux({row:e,measure:n,loaded:o,onNavigate:r,renderLink:s}){const{t:a,convert:l}=J(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],u=p?Zs(p,l):e.locationName?l(e.locationName):"",m=e.images[0],h=m?pn(m):void 0,f=e.images.map(x=>Zs(x,l)).join("、");return t.jsxs("tr",{"data-loading":o?void 0:"",children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(qe,{id:e.id,label:l(e.name),onNavigate:r,renderLink:s,dense:!0}),n?t.jsx("span",{className:"bim-d-meta",children:l(n)}):t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${d?"":" bim-d-zt-blank"}`,title:c?a("workPage.inferredFromEdition"):void 0,children:d?l(d):o?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),t.jsxs("td",{className:`bim-d-zt-sub${u?"":" bim-d-zt-blank"}`,children:[u||(o?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),e.holders.length>1&&t.jsxs("span",{className:"bim-d-meta",children:[" +",e.holders.length-1]})]}),t.jsx("td",{className:e.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:e.hasImage&&(h?t.jsx("a",{className:"bim-d-flag",href:h,target:"_blank",rel:"noopener noreferrer",title:f,children:a("workPage.hasImage")}):t.jsx("span",{className:"bim-d-flag",title:f,children:a("workPage.hasImage")}))})]})}function mx({items:e,transport:n,onNavigate:o,renderLink:r}){const{t:s,convert:a}=J(),[l,d]=g.useState(0),c=Math.min(l,e.length-1),p=e[c],[u,m]=g.useState(new Map);return g.useEffect(()=>{if(!n)return;const h=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(h.length===0)return;let f=!1;return Promise.all(h.map(x=>n.getItem(x).then(k=>{var y,w;return[x,((w=(y=k==null?void 0:k.authors)==null?void 0:y[0])==null?void 0:w.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{f||m(new Map(x.filter(([,k])=>k)))}),()=>{f=!0}},[n,e]),t.jsx(et,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(Je,{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((h,f)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":f===c,"aria-label":a(h.source),onClick:()=>d(f),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:u.get(h.source_bid??"")?a(u.get(h.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(h.source)].slice(0,9).map((x,k)=>t.jsx("span",{children:x},k))})]})},f))}),t.jsxs("div",{className:"bim-d-lu-body",role:"tabpanel",children:[p.title_info&&t.jsx("div",{className:"bim-d-lu-title",children:a(p.title_info)}),t.jsx(Je,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(qe,{id:p.source_bid,label:a(p.source),onNavigate:o,renderLink:r,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:pt(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:pt(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:pt(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 hx(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 gx(e,n){if(!e.lineage)return null;const o=e.lineage;return{id:e.id,kind:"book",label:e.title,year:o.year,year_text:o.year_text,year_uncertain:o.year_uncertain,category:o.category,status:o.status,extant_juan:o.extant_juan,group:n[e.id],note:o.note}}function Js(e,n,o){return{id:`derive:${n.ref}->${e}:${o}`,source:n.ref,target:e,kind:"derive",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function fx(e,n,o){const[r,s]=[e,n.book_id].sort();return{id:`sibling:${r}-${s}:${o}`,source:r,target:s,kind:"sibling",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function xx(e,n){var p;if(n==="all")return null;const o=(p=e.collections)==null?void 0:p[n],r=Array.isArray(o==null?void 0:o.groups)&&o.groups.length>0,s=Array.isArray(o==null?void 0:o.book_ids)&&o.book_ids.length>0,a=r||s||!!(o!=null&&o.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(!o||!a)return null;const l=r?new Set(o.groups):null,d=new Set(o.book_ids??[]);if(l&&e.node_groups)for(const[u,m]of Object.entries(e.node_groups))l.has(m)&&d.add(u);let c=null;if(o.hypothetical_ids&&(c=new Set(o.hypothetical_ids)),l){c||(c=new Set);for(const u of e.hypothetical_nodes??[])u.group&&l.has(u.group)&&c.add(u.id)}return{books:d,hypos:c}}function ei(e,n,o){const r=e.version_graph,s={nodes:[],edges:[],groups:[],layout:"LR",excluded:[]};if(!r||!r.enabled)return s;const a=new Set(r.excluded_books??[]),l=r.node_groups??{},d=xx(r,o??r.default_collection??"all"),c=d!==null,p=(d==null?void 0:d.books)??null,u=(d==null?void 0:d.hypos)??null,m=new Set,h=new Set;if(c){const S=new Map(n.map(T=>[T.id,T])),v=new Map((r.hypothetical_nodes??[]).map(T=>[T.id,T])),$=T=>{const z=S.get(T);if(z&&z.lineage)return(z.lineage.derived_from??[]).map(N=>N.ref);const F=v.get(T);return F?(F.derived_from??[]).map(N=>N.ref):[]},_=T=>v.has(T)?!u||u.has(T):!p||p.has(T),C=new Set,M=T=>{if(!C.has(T)){C.add(T);for(const z of $(T))a.has(z)||(_(z)||(v.has(z)?h.add(z):S.has(z)&&m.add(z)),M(z))}};for(const T of n)p&&p.has(T.id)&&!a.has(T.id)&&M(T.id);for(const T of r.hypothetical_nodes??[])u&&u.has(T.id)&&M(T.id)}const f=n.filter(S=>!a.has(S.id)).filter(S=>!p||p.has(S.id)||m.has(S.id)).map(S=>{const v=gx(S,l);return v&&m.has(S.id)&&(v.bridge=!0),v}).filter(S=>S!==null),x=(r.hypothetical_nodes??[]).filter(S=>!u||u.has(S.id)||h.has(S.id)).map(S=>{const v=hx(S);return h.has(S.id)&&(v.bridge=!0),v}),k=[...f,...x],y=new Set(k.map(S=>S.id)),w=new Set,b=[],j=S=>{w.has(S.id)||!y.has(S.source)||!y.has(S.target)||(w.add(S.id),b.push(S))};for(const S of n)a.has(S.id)||!S.lineage||p&&!p.has(S.id)&&!m.has(S.id)||((S.lineage.derived_from??[]).forEach((v,$)=>{j(Js(S.id,v,$))}),(S.lineage.related_to??[]).forEach((v,$)=>{j(fx(S.id,v,$))}));for(const S of r.hypothetical_nodes??[])u&&!u.has(S.id)&&!h.has(S.id)||(S.derived_from??[]).forEach((v,$)=>{j(Js(S.id,v,$))});return{nodes:k,edges:b,groups:r.groups??[],title:r.title,description:r.description,layout:r.layout??"LR",excluded:Array.from(a)}}function zc(e,n,o){const r=(e??(n!=null?String(n):"")).trim();return r?!o||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(r)?r:`约 ${r}`:""}function bx(e,n){const o=[],r=e.version_graph;if(!r)return o;const s=new Set(n.map(c=>c.id)),a=new Set((r.hypothetical_nodes??[]).map(c=>c.id)),l=new Set([...s,...a]),d=(c,p)=>{l.has(p.ref)||o.push(`${c}: derived_from.ref "${p.ref}" 未在 books 或 hypothetical_nodes 中找到`),p.ref_type==="book"&&!s.has(p.ref)&&o.push(`${c}: derived_from.ref "${p.ref}" 标记为 book 但不在 books 列表中`),p.ref_type==="hypothetical"&&!a.has(p.ref)&&o.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(u=>d(p,u)),(c.lineage.related_to??[]).forEach(u=>{s.has(u.book_id)||o.push(`${p}: related_to.book_id "${u.book_id}" 不在 books 列表中`)})}for(const c of r.hypothetical_nodes??[]){const p=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(u=>d(p,u))}return o}const Tc=({graph:e,renderLink:n,className:o,style:r})=>{const{t:s,convert:a}=J();if(!e.nodes.length)return t.jsx("div",{style:{...Ix,...r},className:o,children:s("lineage.emptyGraph")});const l=new Map,d=new Map;for(const f of e.edges)if(f.kind==="derive"){const x=l.get(f.target)??[];x.push(f),l.set(f.target,x)}else for(const x of[f.source,f.target]){const k=d.get(x)??[];k.push(f),d.set(x,k)}const c=new Map(e.nodes.map(f=>[f.id,f])),p=new Map,u=[];for(const f of e.nodes)if(f.group){const x=p.get(f.group)??[];x.push(f),p.set(f.group,x)}else u.push(f);const m=(f,x)=>(f.year??9999)-(x.year??9999);p.forEach(f=>f.sort(m)),u.sort(m);const h=e.groups.filter(f=>p.has(f.id));return t.jsxs("div",{className:o,style:{...jx,...r},children:[e.title&&t.jsx("div",{style:vx,children:a(e.title)}),e.description&&t.jsx("div",{style:kx,children:a(e.description)}),h.map(f=>t.jsx(Qs,{label:f.label,color:f.color,nodes:p.get(f.id),incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n},f.id)),u.length>0&&t.jsx(Qs,{label:s("lineage.otherGroup"),nodes:u,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},Qs=({label:e,color:n,nodes:o,incomingMap:r,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=J();return t.jsxs("div",{style:wx,children:[t.jsx("div",{style:{...Sx,borderLeftColor:n??i("widget-border")},children:d(e)}),o.map(c=>t.jsx(yx,{node:c,incoming:r.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},yx=({node:e,incoming:n,siblings:o,nodeMap:r,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=J();return t.jsxs("div",{style:{..._x,borderStyle:a||l?"dashed":"solid",opacity:l?.55:e.status==="lost"?.7:1,background:l?i("bg-subtle"):void 0},title:l?d("lineage.bridgeTitle"):void 0,children:[t.jsxs("div",{style:$x,children:[t.jsx("span",{style:Cx,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:zx,children:zc(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:Tx,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:Nx,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:Ex,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:ta,children:[t.jsx("div",{style:na,children:d("lineage.sources")}),n.map(p=>{const u=r.get(p.source);return t.jsxs("div",{style:ia(p.confidence),children:[t.jsx("span",{style:oa,children:c(p.relation)}),t.jsx("span",{children:(u==null?void 0:u.kind)==="book"&&s?s(u.id,c(u.label)):c((u==null?void 0:u.label)??p.source)}),p.confidence!=="consensus"&&p.confidence!=="certain"&&t.jsx(ea,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:ra,children:["· ",c(p.evidence)]})]},p.id)})]}),o.length>0&&t.jsxs("div",{style:ta,children:[t.jsx("div",{style:na,children:d("lineage.related")}),o.map(p=>{const u=p.source===e.id?p.target:p.source,m=r.get(u);return t.jsxs("div",{style:ia(p.confidence),children:[t.jsx("span",{style:oa,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)??u)}),t.jsx(ea,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:ra,children:["· ",c(p.evidence)]})]},p.id)})]})]})},wn=({children:e,tone:n="default"})=>{const r={default:{bg:i("tag-bg"),fg:i("fg")},warn:{bg:i("warn-bg"),fg:i("warn-fg")},info:{bg:i("info-bg"),fg:i("info-fg")}}[n];return t.jsx("span",{style:{display:"inline-block",padding:"1px 8px",fontSize:"11px",borderRadius:"10px",background:r.bg,color:r.fg,marginRight:"4px"},children:e})},ea=({level:e})=>{const{t:n}=J(),r={certain:{key:"certain",color:i("confidence-certain")},consensus:{key:"consensus",color:i("confidence-consensus")},probable:{key:"probable",color:i("confidence-probable")},disputed:{key:"disputed",color:i("confidence-disputed")}}[e];return r?t.jsx("span",{style:{display:"inline-block",padding:"0 6px",fontSize:"10px",border:`1px solid ${r.color}`,color:r.color,borderRadius:"8px",marginLeft:"4px"},children:n(`lineage.confidence.${r.key}`)}):null},jx={fontSize:"14px",color:i("fg")},vx={fontSize:"16px",fontWeight:600,marginBottom:"8px"},kx={fontSize:"13px",color:i("muted"),marginBottom:"16px",lineHeight:1.6},wx={marginBottom:"16px"},Sx={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:i("fg")},_x={border:`1px solid ${i("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:i("bg")},$x={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Cx={fontSize:"15px",fontWeight:600},zx={fontSize:"12px",color:i("muted")},Tx={marginBottom:"6px"},Nx={fontSize:"12px",color:i("muted"),margin:"2px 0"},Ex={fontSize:"12px",color:i("muted"),fontStyle:"italic",margin:"4px 0"},ta={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${i("widget-border")}`},na={fontSize:"11px",color:i("muted"),marginBottom:"2px"},ia=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),oa={display:"inline-block",padding:"0 6px",fontSize:"11px",background:i("tag-bg"),color:i("fg"),borderRadius:"3px",marginRight:"6px"},ra={fontSize:"11px",color:i("muted")},Ix={padding:"20px",textAlign:"center",color:i("muted"),fontSize:"13px"},Nc=({selectedNodeId:e,...n})=>{const{t:o}=J(),[r,s]=g.useState("loading"),[a,l]=g.useState(null);return g.useEffect(()=>{let d=!1;return Rx().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),r==="loading"?t.jsx("div",{style:aa,children:o("lineage.graphLoading")}):r==="missing"||!a?t.jsxs("div",{style:aa,children:[t.jsx("div",{children:sa(o("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:sa(o("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(Lx,{modules:a,selectedNodeId:e,...n})};function sa(e,n){return e.split(/(\{\w+\})/).map((o,r)=>{const s=/^\{(\w+)\}$/.exec(o);return t.jsx(g.Fragment,{children:s&&s[1]in n?n[s[1]]:o},r)})}async function Rx(){try{const[e,n]=await Promise.all([import("@xyflow/react"),import("@dagrejs/dagre")]);let o=!1;try{await import("@xyflow/react/dist/style.css"),o=!0}catch{o=!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:o}}catch{return null}}const Lx=({graph:e,renderLink:n,height:o=600,className:r,style:s,selectedNodeId:a,modules:l})=>{const{ReactFlow:d,Background:c,Controls:p,Handle:u,Position:m,BaseEdge:h,EdgeLabelRenderer:f,getSmoothStepPath:x,dagre:k}=l,y=g.useMemo(()=>({lineage:$=>{var I,P,U,K;const _=((I=$.data)==null?void 0:I.stepPosition)??.85,[C,M,T]=x({sourceX:$.sourceX,sourceY:$.sourceY,sourcePosition:$.sourcePosition,targetX:$.targetX,targetY:$.targetY,targetPosition:$.targetPosition,stepPosition:_,borderRadius:5}),z=!!((P=$.data)!=null&&P.isSibling),F=z?M:$.targetX-18,N=z?T:$.targetY-12,R=(U=$.data)==null?void 0:U.labelStyle,O=(K=$.data)==null?void 0:K.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(h,{id:$.id,path:C,style:$.style,markerStart:$.markerStart,markerEnd:$.markerEnd}),$.label&&t.jsx(f,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${F}px,${N}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:i("bg"),border:`0.5px solid ${i("widget-border")}`,...O,...R},children:$.label})})]})}}),[h,f,x]),w=g.useMemo(()=>({version:$=>{const{t:_}=J(),C=$.data,M=C.kind==="hypothetical",T=C.status==="lost",z=C.isSelected,F=C.bridge,N=C.borderColor??i("muted"),R=F||M?"dashed":"solid",O=F?.5:T?.6:1;return t.jsxs("div",{style:{background:i(F?"bg-subtle":"bg"),border:`2px ${R} ${z?i("primary"):N}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:O,boxShadow:z?i("shadow-node-selected"):M||F?"none":i("shadow-node")},title:F?_("lineage.bridgeTitle"):void 0,children:[t.jsx(u,{type:"target",position:m.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:M||!C.renderLink?C.label:C.renderLink(C.bookId,C.label)}),C.description&&t.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.25,marginTop:1},children:C.description}),C.yearText&&t.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.2},children:zc(C.yearText,void 0,C.uncertain)}),T&&t.jsx("div",{style:{fontSize:9,color:i("lost-fg"),marginTop:1},children:_("lineage.lost")}),t.jsx(u,{type:"source",position:m.Right,style:{visibility:"hidden"}})]})}}),[u,m]),{convert:b}=J(),{rfNodes:j,rfEdges:S}=g.useMemo(()=>Ax(e,k,n,a,b),[e,k,n,a,b]);return t.jsx("div",{style:{width:"100%",height:o,...s},className:r,children:t.jsxs(d,{nodes:j,edges:S,nodeTypes:w,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 Ax(e,n,o,r,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(w=>[w.id,w.color??i("muted")]));for(const w of e.nodes)c.setNode(w.id,{width:160,height:90});const u=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const w of e.edges)w.kind==="derive"&&(u.has(w.relation)||c.setEdge(w.source,w.target));n.layout(c);const m=e.nodes.map(w=>{const b=c.node(w.id),j=r?w.id===r:void 0,S={kind:w.kind,label:s(w.label),bookId:w.kind==="book"?w.id:void 0,yearText:s(w.year_text??Mx(w)),uncertain:w.year_uncertain,category:w.category,status:w.status,borderColor:w.group?p.get(w.group):void 0,renderLink:o,isSelected:j,description:s(w.description),bridge:w.bridge};return{id:w.id,type:"version",position:{x:b.x-160/2,y:b.y-90/2},data:S,draggable:!1,selected:j}}),h=.78,f=.06,x=new Map;for(const w of e.edges)w.kind==="derive"&&(x.has(w.source)||x.set(w.source,[]),x.get(w.source).push(w));const k=new Map;for(const[w,b]of x){if(b.length<=1)continue;const j=[...b].sort((v,$)=>{var M,T;const _=((M=c.node(v.target))==null?void 0:M.y)??0,C=((T=c.node($.target))==null?void 0:T.y)??0;return _-C}),S=j.length;j.forEach((v,$)=>{const _=($-(S-1)/2)*f;k.set(v.id,h+_)})}const y=e.edges.map(w=>Px(w,k.get(w.id),s));return{rfNodes:m,rfEdges:y}}function Px(e,n,o=r=>r??""){const r=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=Bx(e.confidence),l={type:"arrowclosed",color:a,width:14,height:14};return{id:e.id,source:e.source,target:e.target,type:"lineage",label:o(e.relation),data:{labelStyle:{color:i("fg")},isSibling:s,stepPosition:n},style:{stroke:a,strokeWidth:s?1:1.5,strokeDasharray:s?"4 3":r?"6 4":void 0,opacity:r?.75:1},animated:!1,markerEnd:l,markerStart:s?l:void 0,zIndex:1e3}}function Mx(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function Bx(e){switch(e){case"certain":return i("confidence-certain");case"consensus":return i("lineage-edge-consensus");case"probable":return i("confidence-probable");case"disputed":return i("confidence-disputed");default:return i("muted")}}const aa={padding:"40px 20px",textAlign:"center",color:i("muted"),fontSize:"13px",border:`1px dashed ${i("widget-border")}`,borderRadius:8,background:i("bg")},yr=({graph:e,defaultMode:n="list",renderLink:o,graphHeight:r=600,selectedNodeId:s,onModeChange:a,collection:l,onCollectionChange:d,collectionsAvailable:c,collectionCounts:p,className:u,style:m})=>{var S;const{t:h,convert:f}=J(),[x,k]=g.useState(n),y=v=>{k(v),a==null||a(v)},w=(()=>{if(!c)return[];const v=Object.entries(c);return v.length===0||c.all?v:[...v,["all",{label:h("lineage.collectionAll"),description:h("lineage.collectionAllDesc")}]]})(),b=!!(d&&w.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:i("muted"),textAlign:"center"},children:h("lineage.empty")});const j=l?(S=c==null?void 0:c[l])==null?void 0:S.description:void 0;return t.jsxs("div",{className:u,style:m,children:[t.jsxs("div",{style:Wx,children:[t.jsx("button",{onClick:()=>y("list"),style:qi(x==="list"),children:h("lineage.modeList")}),t.jsx("button",{onClick:()=>y("graph"),style:qi(x==="graph"),children:h("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:i("muted"),marginRight:4},children:h("lineage.collectionLabel")}),w.map(([v,$])=>{const _=p==null?void 0:p[v];return t.jsxs("button",{onClick:()=>d==null?void 0:d(v),style:qi(l===v),title:$.description?f($.description):void 0,children:[f($.label),_!=null?` ${_}`:""]},v)})]})]}),b&&j&&t.jsx("div",{style:{fontSize:12,color:i("muted"),marginBottom:8,padding:"4px 8px",background:i("bg-subtle"),borderRadius:4},children:f(j)}),x==="list"?t.jsx(Tc,{graph:e,renderLink:o}):t.jsx(Nc,{graph:e,renderLink:o,height:r,selectedNodeId:s})]})},Wx={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},qi=e=>({padding:"4px 12px",fontSize:12,border:`1px solid ${i("widget-border")}`,borderRadius:4,background:e?i("primary"):"transparent",color:i(e?"primary-fg":"fg"),cursor:"pointer"}),la=40,ca=2,Ox=9,Hx=new Set(["certain","consensus","probable","disputed"]);function Xi(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const Ec=({data:e,transport:n,onNavigate:o,renderLink:r,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:u})=>{var H,se,te,ge,Ne,Be,We,Ue,Qe,me,tt;const m=$e(),{t:h,convert:f}=J(),[x,k]=g.useState(null),[y,w]=g.useState(new Map),[b,j]=g.useState([]),[S,v]=g.useState(new Map),[$,_]=g.useState(!1),[C,M]=g.useState("flow"),[T,z]=g.useState(null);g.useEffect(()=>{if(!n||!e.work_id){k(null);return}let E=!1;return n.getItem(e.work_id).then(oe=>{!E&&oe&&oe.type==="work"&&k(oe)}).catch(()=>{}),()=>{E=!0}},[n,e.work_id]),g.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){z(null);return}let E=!1;return n.getLineageGraph(e.work_id).then(oe=>{E||z(oe&&oe.nodes.length>1?oe:null)}).catch(()=>{E||z(null)}),()=>{E=!0}},[n,e.work_id]),g.useEffect(()=>{const E=e.contained_in||[];if(!n||E.length===0){w(new Map);return}let oe=!1;return Promise.all(E.map(ae=>{const je=typeof ae=="string"?ae:ae.id;return n.getItem(je).then(ke=>[je,ke]).catch(()=>[je,null])})).then(ae=>{if(oe)return;const je=new Map;for(const[ke,xe]of ae)xe&&je.set(ke,xe);w(je)}),()=>{oe=!0}},[n,e.contained_in]);const F=g.useMemo(()=>{const E=new Set([...(x==null?void 0:x.books)||[],...e.related_books||[]]);return E.add(e.id),[...E]},[x==null?void 0:x.books,e.related_books,e.id]),N=F.length-1;g.useEffect(()=>{if(!n||N<=0){j([]);return}const E=F.length<=la,oe=E?F:F.slice(0,8);let ae=!1;return Promise.all(oe.map(je=>je===e.id?Promise.resolve({id:je,title:e.title,edition:e.edition,year:ii(e)}):n.getItem(je).then(ke=>{const xe=ke??{};return{id:je,title:xe.title,edition:xe.edition,year:ke?ii(xe):void 0}}).catch(()=>({id:je})))).then(je=>{if(ae)return;const ke=je.filter(xe=>xe.id===e.id||xe.title||xe.edition);E&&ke.sort((xe,G)=>(xe.year??1/0)-(G.year??1/0)),j(ke)}),()=>{ae=!0}},[n,F,N,e]);const R=e.lineage,O=g.useMemo(()=>[...((R==null?void 0:R.derived_from)||[]).filter(E=>E.ref_type==="book").map(E=>E.ref),...((R==null?void 0:R.related_to)||[]).map(E=>E.book_id)].filter(Boolean),[R]);g.useEffect(()=>{if(!n||O.length===0){v(new Map);return}let E=!1;return Promise.all(O.map(oe=>n.getItem(oe).then(ae=>[oe,{id:oe,title:ae==null?void 0:ae.title,edition:ae==null?void 0:ae.edition}]).catch(()=>[oe,{id:oe}]))).then(oe=>{E||v(new Map(oe))}),()=>{E=!0}},[n,O]);const I=g.useMemo(()=>Sc(e.resources,e.resource_groups,h),[e.resources,e.resource_groups,h]),P=I.groups.reduce((E,oe)=>E+oe.rows.length+oe.mirrors.length,0),U=I.groups.length>0&&I.groups.every(E=>E.key==="_physical"),K=In(e),L=Sl(e),Z=Ct(e,m.unit.juan),A=new Set((e.contained_in||[]).map(E=>typeof E=="string"?0:zn(E.volume_index).length).filter(E=>E>0)),V=E=>{var je;const oe=(je=e.base_edition)==null?void 0:je.find(ke=>ke.book_id===E&&ke.name);if(oe!=null&&oe.name)return oe.name;const ae=S.get(E);return(ae==null?void 0:ae.edition)||(ae==null?void 0:ae.title)||""},ce=g.useMemo(()=>{var Te,Ee,D,re,Pe;const E=[];L&&E.push({label:h("bookPage.fact.editionType"),value:f(L),title:e.edition_type||(Te=e.lineage)!=null&&Te.category?void 0:h("bookPage.inferredFromEdition")}),(Ee=e.publication_info)!=null&&Ee.details?E.push({label:h("bookPage.fact.publication"),value:f(e.publication_info.details)}):(K.era||K.reign)&&E.push({label:h("bookPage.fact.era"),value:f([K.era,K.reign].filter(Boolean).join(" ")),title:K.source==="edition"?h("bookPage.inferredFromEdition"):void 0}),Z&&E.push({label:h("bookPage.fact.measure"),value:f(Z)});const oe=(e.contained_in||[]).flatMap(_e=>typeof _e=="string"?[]:zn(_e.volume_index));oe.length&&E.push({label:h("bookPage.fact.volumes"),value:h("bookPage.volumesValue",{range:bi(oe,m.unit.volume),unit:m.unit.volume,n:oe.length})});const ae=(((D=e.lineage)==null?void 0:D.derived_from)||[]).find(_e=>_e.relation==="底本"&&_e.ref_type==="book");ae&&V(ae.ref)&&E.push({label:h("bookPage.fact.baseEdition"),value:t.jsx(qe,{id:ae.ref,label:f(V(ae.ref)),onNavigate:o,renderLink:r,dense:!0})});const je=(e.base_edition||[]).filter(_e=>_e&&_e.name);for(const _e of["底本","配補","參校"]){if(_e==="底本"&&ae&&V(ae.ref))continue;const Ye=je.filter(He=>He.role===_e);Ye.length&&E.push({label:f(_e),value:Ye.map((He,Fe)=>t.jsxs(g.Fragment,{children:[Fe>0&&"、",He.book_id?t.jsx(qe,{id:He.book_id,label:f(He.name),onNavigate:o,renderLink:r,dense:!0}):f(He.name)]},Fe))})}const ke=(e.provenance||[]).filter(_e=>_e&&_e.institution),xe=(e.resources||[]).filter(_e=>(_e.types||(_e.type?[_e.type]:[])).includes("physical"));if(ke.length){E.push({label:h("bookPage.fact.holdings"),value:ke.slice(0,2).map(He=>f(He.institution)).join("、")+(ke.length>2?h("bookPage.andMorePlaces",{n:ke.length}):"")});const _e=ke.filter(He=>He.call_number).slice(0,2).map(He=>`${f(He.institution)} ${He.call_number}`);_e.length&&E.push({label:h("bookPage.fact.callNumber"),value:_e.join(";")+(ke.filter(He=>He.call_number).length>2?"…":"")});const Ye=ke.flatMap(He=>He.seals||[]).filter(Boolean);Ye.length&&E.push({label:h("bookPage.fact.seals"),value:f(Ye.join("、"))})}else xe.length?E.push({label:h("bookPage.fact.holdings"),value:xe.slice(0,2).map(_e=>f(_e.name)).join("、")+(xe.length>2?h("bookPage.andMorePlaces",{n:xe.length}):"")}):(re=e.current_location)!=null&&re.name&&E.push({label:h("bookPage.fact.holdings"),value:f(e.current_location.name)});const G=e.physical_description;if(G){const _e=[[h("bookPage.fact.leafStyle"),G.leaf_style],[h("bookPage.fact.binding"),G.binding],[h("bookPage.fact.dimensions"),G.dimensions],[h("bookPage.fact.condition"),G.condition]];for(const[Ye,He]of _e)He&&He.trim()&&E.push({label:Ye,value:f(He)})}(Pe=e.page_count)!=null&&Pe.description&&E.push({label:m.label.pageCount,value:f(e.page_count.description)});const ue=[...ho(e.additional_titles),...ho(e.attached_texts)];return ue.length&&E.push({label:h("bookPage.fact.aliases"),value:ue.map(f).join("、")}),E},[e,f,m,h,K,L,Z,S,o,r]),ne=f(e.title),de=e.edition?f(e.edition):void 0,pe=((H=e.lineage)==null?void 0:H.year_text)||"",be=t.jsx(Ln,{kind:h("bookPage.kind"),title:ne,subtitle:de,byline:t.jsx(xr,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:o,renderLink:r}),meta:(()=>{const E=[L?f(L):"",K.era?f([K.era,K.reign].filter(Boolean).join("")):"",Z?f(Z):""].filter(Boolean);return E.length?t.jsx("span",{className:"bim-d-tags",children:E.map((oe,ae)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(ae,2)}`,children:oe},ae))}):null})(),description:(se=e.description)!=null&&se.text?t.jsx($t,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:Yo((te=e.description)==null?void 0:te.text)?6:void 0,facts:ce,readAction:s,secondaryAction:s&&P>0&&!U?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:h("bookPage.viewImages")}):void 0,foot:t.jsx(An,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),Oe=e.contained_in||[],ie=(a==null?void 0:a.chapters)||[],Le=f(ie[0]&&Xi(ie[0].title)[0].slice(-1)||"")||h("bookPage.chapterUnit"),Ae=h("bookPage.chapterCount",{n:ie.length,unit:Le}),q=!!((ge=R==null?void 0:R.derived_from)!=null&&ge.length||(Ne=R==null?void 0:R.related_to)!=null&&Ne.length||(Be=e.appendix)!=null&&Be.length),Q=[],fe=h(U?"bookPage.sec.physical":"bookPage.sec.images");(ie.length||I.text.length||l)&&Q.push({id:"fulltext",label:h("bookPage.sec.fulltext"),count:ie.length?Ae:void 0}),I.groups.length&&Q.push({id:"images",label:fe,count:P}),q&&Q.push({id:"lineage",label:h("bookPage.sec.lineage")}),Oe.length&&Q.push({id:"collections",label:h("section.containedIn"),count:Oe.length}),(We=e.location_history)!=null&&We.length&&Q.push({id:"provenance",label:h("section.locationHistory")});const ze=E=>(d==null?void 0:d(E))??null,Y=ie[0],ve=Y?ze(Y.file):null,le=$?ie:ie.slice(0,Ox),Se=(E,oe,ae)=>E?t.jsx("a",{className:ae,href:E.href??"#",onClick:E.onClick?je=>{je.metaKey||je.ctrlKey||(je.preventDefault(),E.onClick())}:void 0,children:oe}):t.jsx("span",{className:ae,children:oe}),X=t.jsxs(t.Fragment,{children:[(ie.length>0||I.text.length>0||l)&&t.jsxs(et,{id:"fulltext",title:h("bookPage.sec.fulltext"),meta:ie.length>0?t.jsx(Je,{items:[Ae,(Ue=a==null?void 0:a.source)!=null&&Ue.name?h("bookPage.sourceBy",{src:f(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!Y&&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"})]}),Y&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:h("bookPage.readFrom",{ch:f(Xi(Y.title)[0])||h("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:f((Y.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),Se(ve,t.jsxs(t.Fragment,{children:[h("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),ie.length>1&&t.jsx("ul",{className:"bim-d-chap",children:le.map(E=>{const[oe,ae]=Xi(E.title);return t.jsx("li",{children:Se(ze(E.file),t.jsxs(t.Fragment,{children:[oe&&t.jsx("b",{children:f(oe)}),f(ae||E.file)]}))},E.file)})}),ie.length>le.length&&t.jsx(Go,{label:h("detail.expandRest",{n:ie.length-le.length,unit:Le}),onClick:()=>_(!0)}),I.text.length>0&&t.jsxs(t.Fragment,{children:[(ie.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:h("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:I.text.map((E,oe)=>t.jsx(br,{item:E,siblings:I.text,listedVolumeCounts:A},`${E.id||E.url||E.name}-${oe}`))})})]})]}),I.groups.length>0&&t.jsx(et,{id:"images",title:fe,meta:t.jsx(Je,{items:[I.groups.length>1?h("bookPage.groupCount",{n:I.groups.length}):"",h("bookPage.placeCount",{n:P})]}),children:t.jsx($c,{groups:I.groups,listedVolumeCounts:A})}),q&&t.jsx(et,{id:"lineage",title:h("bookPage.sec.lineage"),meta:(Qe=R==null?void 0:R.derived_from)!=null&&Qe.length?h("bookPage.lineageMeta"):void 0,action:T?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":h("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":C==="flow",onClick:()=>M("flow"),children:h("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":C==="graph",onClick:()=>M("graph"),children:h("bookPage.viewGraph")})]}):void 0,children:C==="graph"&&T?t.jsx(yr,{graph:T,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(E,oe)=>t.jsx(qe,{id:E,label:f(oe),onNavigate:o,renderLink:r,dense:!0})}):t.jsx(Dx,{data:e,heading:de||ne,yearText:pe,refName:V,onNavigate:o,renderLink:r})}),Oe.length>0&&t.jsx(et,{id:"collections",title:h("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:Oe.map((E,oe)=>{var G,ue;const ae=typeof E=="string"?E:E.id,je=typeof E=="string"?[]:zn(E.volume_index),ke=y.get(ae),xe=(ke==null?void 0:ke._member_count)||((G=ke==null?void 0:ke.books)==null?void 0:G.length)||((ue=ke==null?void 0:ke.contained_works)==null?void 0:ue.length)||0;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(qe,{id:ae,label:ke?f(ke.title):ae,onNavigate:o,renderLink:r,dense:!0}),je.length>0&&t.jsx(Fx,{volumes:je,unit:m.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${xe?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:xe>0&&h("bookPage.totalOf",{n:xe,unit:m.unit.bu})})]},`${ae}-${oe}`)})})})}),(me=e.location_history)!=null&&me.length?t.jsx(et,{id:"provenance",title:h("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((E,oe)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:f(E.name)}),([E.start_date,E.end_date].filter(Boolean).join("—")||E.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(Je,{items:[[E.start_date,E.end_date].filter(Boolean).join("—"),E.description?f(E.description):""]})})]},oe))})}):null,Q.length===0&&t.jsx(et,{title:h("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:h("bookPage.emptyText")})})]}),Ce=b.findIndex(E=>E.id===e.id),Me=F.length<=la,B=Me&&Ce>=0?b.slice(Math.max(0,Ce-ca),Ce+ca+1):b.filter(E=>E.id!==e.id),ee=t.jsxs(t.Fragment,{children:[x&&t.jsxs("div",{id:"work",className:"bim-d-side",style:{scrollMarginTop:16},children:[t.jsx("h2",{className:"bim-d-ui bim-d-side-h",children:f(m.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(qe,{id:x.id,label:f(x.title),onNavigate:o,renderLink:r})}),t.jsx(Je,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(E=>`${E.dynasty?`〔${f(E.dynasty)}〕`:""}${f(E.name)}`),f(Ct(x,m.unit.juan)),x._edition_count?h("bookPage.editionCount",{n:x._edition_count}):""]}),((tt=x.description)==null?void 0:tt.text)&&t.jsx("p",{style:{margin:"8px 0 0",fontSize:14,lineHeight:1.8,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},className:"bim-d-card-desc",children:f(x.description.text.replace(/[#*_>`[\]]/g,""))})]}),N>0&&B.length>0&&t.jsxs("div",{children:[t.jsx(Ut,{id:"siblings",timeline:!0,title:Me?h("bookPage.siblings"):m.relation.siblingVersions,meta:Me?h("bookPage.byEra"):h("bookPage.kindCount",{n:N}),cap:B.length,items:B.map(E=>E.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:f(E.edition||E.title||E.id)}):t.jsx(qe,{id:E.id,label:f(E.edition||E.title||E.id),onNavigate:o,renderLink:r,dense:!0})),metas:B.map(E=>[E.year!=null?E.year<0?h("detail.bce",{n:-E.year}):String(E.year):"",E.id===e.id?h("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:B.findIndex(E=>E.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(qe,{id:x.id,label:h("bookPage.viewAllInWork",{n:F.length}),onNavigate:o,renderLink:r,dense:!0})})]})]}),ye=e.work_id?t.jsx(_l,{caption:m.section.belongsToWork,children:t.jsx(qe,{id:e.work_id,label:x?f(x.title):" ",onNavigate:o,renderLink:r,dense:!0})}):void 0;return t.jsx(Rn,{railTop:c,back:p,up:ye,nav:Q,railLinks:u,main:X,card:be,side:ee})};function Fx({volumes:e,unit:n}){const{t:o}=J();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[o("bookPage.volumeRange",{range:bi(e,n),unit:n}),e.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-d-dot"}),o("bookPage.volumeCount",{n:e.length,unit:n})]})]})}function Dx({data:e,heading:n,yearText:o,refName:r,onNavigate:s,renderLink:a}){var w;const{t:l,convert:d}=J(),c=e.lineage,p=(c==null?void 0:c.derived_from)||[],u=p.filter(b=>b.ref_type!=="book"),m=p.filter(b=>b.ref_type==="book"&&b.relation==="底本"),h=p.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),f=(c==null?void 0:c.related_to)||[],x=p.length>0||f.length>0,k=b=>b&&Hx.has(b)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${b}`)}):"",y=(b,j)=>t.jsx(qe,{id:b,label:d(j||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:[u.map((b,j)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:b.relation?d(b.relation):l("bookPage.lineage.ancestor")}),t.jsx("span",{className:"bim-d-lf-name",children:l("bookPage.lineage.reconstructed")}),b.evidence&&t.jsxs("span",{className:"bim-d-meta",children:[d(b.evidence),k(b.confidence)]})]})},`a-${j}`)),m.map((b,j)=>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,r(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),k(b.confidence)]})]})},`b-${j}`)),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}),o&&t.jsx("span",{className:"bim-d-lf-yr",children:d(o)})]}),h.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:h.map((b,j)=>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,r(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),k(b.confidence)]})]},j))})]}),f.length>0&&t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-out",children:[t.jsx("span",{className:"bim-d-lf-out-h bim-d-ui",children:l("bookPage.lineage.derivatives")}),t.jsx("span",{className:"bim-d-lf-chips",children:f.map((b,j)=>t.jsxs("span",{className:"bim-d-lf-chip",title:b.evidence?d(b.evidence):void 0,children:[y(b.book_id,r(b.book_id)),t.jsx("span",{className:"bim-d-meta",children:d(b.relation)})]},j))})]})]}),(w=e.appendix)==null?void 0:w.map((b,j)=>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($t,{text:b.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${j}`)),(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 Sn=16,Ux=200,Vx=16,Ic=({data:e,catalog:n,transport:o,onNavigate:r,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var Se,X,Ce,Me,B,ee,ye;const{t:p,convert:u,messages:m}=J(),[h,f]=g.useState(""),[x,k]=g.useState(!1),[y,w]=g.useState(null),[b,j]=g.useState(""),[S,v]=g.useState(!1),$=g.useMemo(()=>kl(e,n),[e,n]),[_,C]=g.useState(new Map),M=!!o&&$.rows.length>0&&$.rows.length<=Ux,T=M&&($.rows.length<=Sn||S),z=T&&$.rows.every(H=>!H.id||_.has(H.id)),F=H=>{var se;return ko(H?(se=_.get(H))==null?void 0:se.l1:void 0)},N=g.useMemo(()=>{const H=h.trim(),se=H?u(H):"";return $.rows.filter(te=>{var Ne,Be;if(b&&ko(te.id?(Ne=_.get(te.id))==null?void 0:Ne.l1:void 0)!==b)return!1;if(!se)return!0;const ge=te.id&&((Be=_.get(te.id))==null?void 0:Be.title)||te.title;return u(ge).includes(se)||(te.subItems||[]).some(We=>u(We).includes(se))})},[$.rows,h,b,_,u]),R=x?N:N.slice(0,Sn),O=g.useMemo(()=>(T?$.rows:R).filter(H=>H.id&&!_.has(H.id)).map(H=>H.id),[T,$.rows,R,_]);g.useEffect(()=>{if(!o||O.length===0)return;let H=!1;const se=O.slice(0,Vx);return Promise.all(se.map(te=>o.getItem(te).then(ge=>{var We,Ue;const Ne=ge??{},Be={title:Ne.title,edition:Ne.edition,authors:Ne.authors,measure:ge?Ct(ge,m.unit.juan):void 0,versionCount:Ne._edition_count??((We=Ne.books)==null?void 0:We.length),l1:((Ue=Ne.classification)==null?void 0:Ue.l1)||void 0};return[te,Be]}).catch(()=>[te,{}]))).then(te=>{H||C(ge=>{const Ne=new Map(ge);for(const[Be,We]of te)Ne.set(Be,We);return Ne})}),()=>{H=!0}},[o,O,m.unit.juan]);const I=(e.contained_in||[])[0];g.useEffect(()=>{if(!I){w(null);return}if(w({id:I}),!o)return;let H=!1;return o.getItem(I).then(se=>{H||w({id:I,title:se==null?void 0:se.title})}).catch(()=>{}),()=>{H=!0}},[o,I]);const P=g.useMemo(()=>Sc(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),U=P.text.length+P.groups.reduce((H,se)=>H+se.rows.length+se.mirrors.length,0),K=e.contained_works||[],L=new Set($.rows.map(H=>H.id).filter(Boolean)),Z=K.length>0&&!K.every(H=>L.has(H.id)),A=(()=>{const H=$.rows.map(se=>se.edition).filter(Boolean);return H.length>1&&new Set(H).size===1})(),V=$.rows.some(H=>H.volumes.length>0||H.expected!=null),ce=e._member_count||((Se=e.books)==null?void 0:Se.length)||K.length,ne=Ct(e,m.unit.juan),de=e.count,pe=H=>typeof H=="number"&&Number.isFinite(H)?H:null,be=pe(de==null?void 0:de.juan)??pe((X=e.juan_count)==null?void 0:X.number),Oe=pe(de==null?void 0:de.ce)??($.totalVolumes||null),ie=[{value:$.rows.length,label:p("collectionPage.stat.titles")},{value:be??0,label:m.unit.juan},{value:Oe??0,label:m.unit.volume}],Le=g.useMemo(()=>{var te,ge;const H=[];if((te=e.publication_info)!=null&&te.details&&H.push({label:p("collectionPage.fact.publication"),value:u(e.publication_info.details)}),ce&&ce!==$.rows.length){const Ne=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");H.push({label:Ne,value:`${ce} ${m.unit.bu}`,title:p("collectionPage.memberNote")})}const se=[pe(de==null?void 0:de.zhong)!=null?p("collectionPage.nZhong",{n:de.zhong}):"",pe(de==null?void 0:de.han)!=null?p("collectionPage.nHan",{n:de.han}):""].filter(Boolean);return se.length&&H.push({label:p("collectionPage.fact.expected"),value:se.join(" ")}),be==null&&ne&&H.push({label:p("collectionPage.fact.measure"),value:u(ne),title:(ge=e.juan_count)!=null&&ge.description?u(e.juan_count.description):void 0}),H},[e,ce,$.rows.length,be,ne,de,u,p,m]),Ae=g.useMemo(()=>{if(!z)return[];const H=new Map;for(const te of $.rows){const ge=F(te.id);ge&&H.set(ge,(H.get(ge)??0)+1)}const se=Nn.filter(te=>(H.get(te.key)??0)>0);return se.length<2?[]:[{key:"",label:`${m.catalog.all} ${$.rows.length}`},...se.map(te=>({key:te.key,label:`${te.label} ${H.get(te.key)}`}))]},[z,$.rows,_,m]),q=g.useMemo(()=>{if(!z||!$.rows.some(ge=>ge.volumes.length>0))return null;const H=[],se=$.rows.filter(ge=>ge.volumes.length>0).map(ge=>({k:F(ge.id)??"",from:Math.min(...ge.volumes),to:Math.max(...ge.volumes)})).sort((ge,Ne)=>ge.from-Ne.from);for(const ge of se){const Ne=ge.to-ge.from+1,Be=H[H.length-1];Be&&Be.key===ge.k?(Be.to=Math.max(Be.to,ge.to),Be.n+=Ne):H.push({key:ge.k,from:ge.from,to:ge.to,n:Ne})}const te=se.reduce((ge,Ne)=>Math.max(ge,Ne.to),0);return H.length>1&&H.some(ge=>ge.key)?{segs:H,last:te}:null},[z,$.rows,_]),Q=(Ce=e.description)==null?void 0:Ce.text,fe=t.jsx(Ln,{kind:p("collectionPage.kind"),title:u(e.title),byline:t.jsx(xr,{authors:e.authors,onNavigate:r,renderLink:s}),meta:t.jsx(Je,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(Me=e.publication_info)!=null&&Me.year?u(e.publication_info.year):""]}),description:Q||(B=e.history)!=null&&B.length?t.jsxs(t.Fragment,{children:[Q&&t.jsx($t,{text:Q,style:{fontSize:15,lineHeight:1.85}}),(ee=e.history)!=null&&ee.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((H,se)=>t.jsx("li",{children:u(H)},se))}):null]}):void 0,clampDescription:Yo(Q)||(((ye=e.history)==null?void 0:ye.length)??0)>2?6:void 0,stats:ie,facts:Le,foot:t.jsx(An,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:q&&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:q.segs.map((H,se)=>{const te=Nn.find(ge=>ge.key===H.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!te,title:te?p("collectionPage.dist.segTitle",{section:u(te.label),from:H.from,to:H.to}):void 0,"aria-label":te?p("collectionPage.dist.only",{section:u(te.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!te&&b===H.key,style:{flexGrow:H.n,background:i(te?te.token:"rule")},onClick:()=>{te&&(j(b===H.key?"":H.key),k(!1))}},se)})}),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:q.last})})]})]})}),ze=[];$.rows.length&&ze.push({id:"titles",label:p("collectionPage.sec.titles"),count:$.rows.length}),U&&ze.push({id:"resources",label:p("collectionPage.sec.resources"),count:U}),Z&&ze.push({id:"works",label:m.section.containedWorks,count:K.length});const Y=t.jsxs(t.Fragment,{children:[$.rows.length>0&&t.jsxs(et,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(Je,{items:[`${$.rows.length} ${m.unit.items}`,$.totalVolumes?p("collectionPage.totalVolumes",{n:$.totalVolumes,unit:m.unit.volume}):"",N.length!==$.rows.length?p("collectionPage.currentN",{n:N.length,unit:m.unit.items}):""]}),action:a,children:[($.rows.length>Sn||Ae.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[Ae.length>0&&t.jsx(yi,{items:Ae,value:b,onChange:H=>{j(H),k(!1)}}),M&&$.rows.length>Sn&&!z&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:S,onClick:()=>v(!0),title:p("collectionPage.loadAllTitle",{n:$.rows.length,unit:m.unit.items}),children:p(S?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),$.rows.length>Sn&&t.jsx("input",{type:"search",className:"bim-d-find",value:h,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:H=>{f(H.target.value),k(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&ji(N.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[V&&t.jsx("th",{style:{width:"8.5em"},children:p("collectionPage.col.volumes")}),t.jsx("th",{children:p("collectionPage.col.title")}),t.jsx("th",{style:{textAlign:"right"},children:p("collectionPage.col.versions")})]})}),t.jsx("tbody",{children:R.map((H,se)=>{var Qe;const te=H.id?_.get(H.id):void 0,ge=te!=null&&te.title&&H.title===H.id?te.title:H.title,Ne=((te==null?void 0:te.authors)||[]).find(me=>me&&me.name),Be=[Ne?`${Ne.dynasty?`〔${u(Ne.dynasty)}〕`:""}${u(Ne.name)}${Ne.role?` ${u(Ne.role)}`:""}`:"",te!=null&&te.measure?u(te.measure):"",(Qe=H.subItems)!=null&&Qe.length?H.subItems.map(me=>u(me)).join("、"):"",(te!=null&&te.edition||H.edition)&&!A?u((te==null?void 0:te.edition)||H.edition||""):""].filter(Boolean),We=Nn.find(me=>me.key===F(H.id)),Ue=H.volumes.length>0?p("collectionPage.volumeRange",{range:bi(H.volumes,m.unit.volume),unit:m.unit.volume}):H.expected!=null?`${H.found??0}/${H.expected} ${m.unit.volume}`:"";return t.jsxs("tr",{children:[V&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Ue?"":" bim-d-zt-blank"}`,children:[We&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:i(We.token)}}),Ue||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[H.id?t.jsx(qe,{id:H.id,label:u(ge),onNavigate:r,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:u(ge)}),Be.length>0?t.jsx(Je,{items:Be}):H.id&&!te&&o?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${te!=null&&te.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:te!=null&&te.versionCount?p("collectionPage.nZhong",{n:te.versionCount}):""})]},`${H.id??H.title}-${se}`)})})]}),R.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!x&&t.jsx(Vo,{total:N.length,shown:R.length,unit:m.unit.items,onClick:()=>k(!0)})]}),U>0&&t.jsxs(et,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:U}),children:[P.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[P.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:P.text.map((H,se)=>t.jsx(br,{item:H,siblings:P.text},`${H.id||H.url||H.name}-${se}`))})})]}),t.jsx($c,{groups:P.groups})]}),$.rows.length===0&&U===0&&t.jsx(et,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),ve=Z?t.jsx(Ut,{id:"works",title:m.section.containedWorks,meta:p("collectionPage.nZhong",{n:K.length}),cap:12,items:K.map(H=>t.jsx(qe,{id:H.id,label:u(H.title),onNavigate:r,renderLink:s,dense:!0}))}):null,le=y?t.jsx(_l,{caption:p("collectionPage.parent"),children:t.jsx(qe,{id:y.id,label:u(y.title||y.id),onNavigate:r,renderLink:s,dense:!0})}):void 0;return t.jsx(Rn,{railTop:l,back:d,up:le,nav:ze,railLinks:c,main:Y,card:fe,side:ve})},Gx=16,Zi=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function da(e){if(!e)return Zi.length;const n=Zi.indexOf(e);return n===-1?Zi.length:n}function Yx(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const Kx={秦:[-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]},Rc=({data:e,transport:n,onNavigate:o,renderLink:r,railTop:s,back:a,railLinks:l})=>{var le,Se,X,Ce,Me;const{t:d,convert:c,messages:p}=J(),u=B=>Yx(B,d),[m,h]=g.useState("全部"),[f,x]=g.useState(!1),[k,y]=g.useState("default"),[w,b]=g.useState(new Map),j=g.useMemo(()=>(e.works||[]).map(B=>{const ee=w.get(B.work_id);return{id:B.work_id,title:(ee==null?void 0:ee.title)??B.title??B.work_id,role:B.role||"",cls:Do(B.role),versionCount:ee==null?void 0:ee.versionCount,section:ee==null?void 0:ee.cls,l1:ee==null?void 0:ee.l1,measure:ee==null?void 0:ee.measure,hasImage:ee==null?void 0:ee.hasImage,loaded:!!(ee!=null&&ee.loaded)}}),[e.works,w]),S=g.useMemo(()=>vl((e.works||[]).map(B=>B.role),d("detail.roleAll")),[e.works,d]),v=g.useMemo(()=>{const B=m==="全部"?j:j.filter(ee=>ee.cls===m);return k==="versions"?[...B].sort((ee,ye)=>(ye.versionCount??-1)-(ee.versionCount??-1)):B},[j,m,k]),$=f?v:v.slice(0,Gx),_=g.useMemo(()=>$.filter(B=>!w.has(B.id)).map(B=>B.id),[$,w]);g.useEffect(()=>{if(!n||_.length===0)return;let B=!1;return Promise.all(_.map(ee=>n.getItem(ee).then(ye=>{var ge,Ne,Be,We,Ue;const H=ye??{},se=H._edition_count??(((ge=H.books)==null?void 0:ge.length)??0)+(((Ne=H.collections)==null?void 0:Ne.length)??0),te=[(Be=H.classification)==null?void 0:Be.l1,(We=H.classification)==null?void 0:We.l2].filter(Boolean).join(" ");return[ee,{id:ee,title:H.title,versionCount:se,loaded:!0,cls:te||void 0,l1:((Ue=H.classification)==null?void 0:Ue.l1)||void 0,measure:ye&&Ct(ye,p.unit.juan)||void 0,hasImage:!!(H.has_image??H._has_image)}]}).catch(()=>[ee,{id:ee,loaded:!0}]))).then(ee=>{B||b(ye=>{const H=new Map(ye);for(const[se,te]of ee)H.set(se,te);return H})}),()=>{B=!0}},[n,_,p.unit.juan]);const C=g.useMemo(()=>{const B=new Map;for(const ee of e.alt_names||[]){const ye=ee.type||p.section.aliases;B.has(ye)||B.set(ye,[]),B.get(ye).push(ee.name)}return[...B.entries()].sort((ee,ye)=>da(ee[0])-da(ye[0])).map(([ee,ye])=>({label:ee,names:ye}))},[e.alt_names,p]),M=e.birth_year??((le=e.dates)==null?void 0:le.birth)??void 0,T=e.death_year??((Se=e.dates)==null?void 0:Se.death)??void 0,z=(X=e.dates)==null?void 0:X.floruit,F=M!=null||T!=null?`${u(M)||"?"}—${u(T)||"?"}`:Array.isArray(z)&&z.length===2&&z.every(B=>Number.isFinite(B))?d("entityPage.floruit",{from:u(z[0]),to:u(z[1])}):"",N=new Set(["本名","字","號","号"]),R=C.filter(B=>N.has(B.label)),O=C.filter(B=>!N.has(B.label)),I=O.reduce((B,ee)=>B+ee.names.length,0),P=g.useMemo(()=>{const B=[];for(const ye of R)B.push({label:ye.label,value:ye.names.map(H=>c(H)).join("、")});const ee=(e.works||[]).length;return ee&&B.push({label:d("entityPage.fact.works"),value:d("entityPage.nZhong",{n:ee})}),B},[e.works,R,c,d]),U=B=>{var ee;return(ee=C.find(ye=>B.includes(ye.label)))==null?void 0:ee.names[0]},K=U(["字"]),L=U(["號","号"]),Z=[K?d("entityPage.zi",{name:c(K)}):"",L?d("entityPage.hao",{name:c(L)}):""].filter(Boolean).join(","),A=e.native_place,V=e.dynasty?Kx[e.dynasty]:void 0,ce=(()=>{if(!V||M==null||T==null||T<M)return null;const[B,ee]=V,ye=Math.max(M,B),H=Math.min(T,ee);if(H<=ye)return null;const se=ee-B;return t.jsxs("div",{className:"bim-d-life bim-d-ui",children:[t.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":d("entityPage.lifeAria",{birth:u(M),death:u(T),years:T-M+1}),children:t.jsx("i",{style:{left:`${(ye-B)/se*100}%`,width:`${(H-ye)/se*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${u(B)} ${c(e.dynasty)}`}),t.jsx("span",{children:d("entityPage.lifeYears",{years:T-M+1})}),t.jsx("span",{children:u(ee)})]})]})})(),ne=g.useMemo(()=>{if(!n||j.length===0||j.some(ye=>!ye.loaded))return null;const B=new Map;for(const ye of j){const H=ko(ye.l1);H&&B.set(H,(B.get(H)??0)+1)}const ee=Nn.map(ye=>({...ye,n:B.get(ye.key)??0})).filter(ye=>ye.n>0);return ee.length?ee:null},[j,n]),de=t.jsxs(Ln,{kind:p.entityPage.subtype[e.subtype]??d("entityPage.subtype.people"),title:c(e.primary_name||e.title),subtitle:Z||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(Je,{items:[e.dynasty?c(e.dynasty):"",F,A?d("entityPage.nativePlace",{place:c(A)}):""]}),ce]}),description:(Ce=e.description)!=null&&Ce.text?t.jsx($t,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:Yo((Me=e.description)==null?void 0:Me.text)?6:void 0,facts:P,foot:t.jsx(An,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[I>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:d("entityPage.moreNames",{n:I})}),t.jsx("dl",{children:O.map(B=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:c(B.label)}),t.jsx("dd",{children:B.names.map(ee=>c(ee)).join("、")})]},B.label))})]}),ne&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:d("entityPage.dist")})}),t.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:ne.map(B=>t.jsx("i",{style:{flexGrow:B.n,background:i(B.token)}},B.key))}),t.jsx("div",{className:"bim-d-dist-key",children:ne.map(B=>t.jsxs("span",{children:[t.jsx("i",{style:{background:i(B.token)}}),c(B.label)," ",B.n]},B.key))})]})]}),pe=g.useMemo(()=>j.filter(B=>B.loaded&&(B.versionCount??0)>0).sort((B,ee)=>(ee.versionCount??0)-(B.versionCount??0)).slice(0,3),[j]),be=!!n&&j.length>=3&&$.some(B=>!B.loaded),Oe=m==="全部"&&(be||pe.length>=2),ie=e.external_ids||{},Le=[];ie.cbdb_id!=null&&Le.push({label:"CBDB",id:String(ie.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${ie.cbdb_id}`,note:ie.cbdb_match==="auto"?d("entityPage.autoMatch"):void 0});const Ae=ie.wikidata_id;Ae&&Le.push({label:"Wikidata",id:Ae,href:`https://www.wikidata.org/wiki/${Ae}`});const q=ie.viaf_id;q&&Le.push({label:"VIAF",id:q,href:`https://viaf.org/viaf/${q}`});const Q=S.map(B=>({key:B.cls,label:`${B.label} ${B.count}`})),fe=[...Oe&&!be?[{id:"featured",label:d("entityPage.sec.featured"),count:pe.length}]:[],...j.length?[{id:"works",label:d("entityPage.sec.allWorks"),count:j.length}]:[],...Le.length?[{id:"external",label:d("entityPage.sec.external"),count:Le.length}]:[]],ze=Oe?t.jsxs(et,{id:"featured",title:d("entityPage.sec.featured"),children:[t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:d("entityPage.featuredSub")}),t.jsxs("div",{className:"bim-d-picks","aria-busy":be||void 0,children:[be&&[0,1,2].map(B=>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:" "})]},B)),!be&&pe.map(B=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(qe,{id:B.id,label:c(B.title),onNavigate:o,renderLink:r,dense:!0})}),t.jsx(Je,{items:[B.section?c(B.section):"",B.measure?c(B.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:B.versionCount}),t.jsx("span",{children:d("entityPage.versionsUnit")}),B.hasImage&&t.jsx("span",{className:"bim-d-flag",children:d("entityPage.hasImage")})]})]},B.id))]})]}):null,Y=j.length===0?t.jsx(et,{title:d("entityPage.sec.works"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:d("entityPage.empty")})}):t.jsxs(t.Fragment,{children:[ze,t.jsxs(et,{id:"works",title:d("entityPage.sec.works"),meta:t.jsx(Je,{items:[d("entityPage.total",{n:j.length}),v.length!==j.length?d("entityPage.current",{n:v.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[Q.length>1&&t.jsx(yi,{items:Q,value:m,onChange:B=>{h(B),x(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":k==="versions",onClick:()=>{k==="default"&&x(!0),y(B=>B==="default"?"versions":"default")},children:d(k==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!f&&ji(v.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:d("entityPage.col.work")}),t.jsx("th",{children:d("entityPage.col.section")}),t.jsx("th",{children:d("entityPage.col.role")}),t.jsx("th",{children:d("entityPage.col.versions")}),t.jsx("th",{"aria-label":d("entityPage.col.image")})]})}),t.jsx("tbody",{children:$.map(B=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(qe,{id:B.id,label:c(B.title),onNavigate:o,renderLink:r,dense:!0}),B.measure?t.jsx(Je,{items:[c(B.measure)]}):!B.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${B.section||B.loaded?"":" bim-d-zt-blank"}`,children:B.section?c(B.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${B.role?"":" bim-d-zt-blank"}`,children:B.role?c(B.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${B.loaded?"":" bim-d-zt-blank"}`,children:B.loaded?B.versionCount?d("entityPage.nZhong",{n:B.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:d("entityPage.notRecorded")}):""}),t.jsx("td",{className:B.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:B.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:d("entityPage.hasImage")})})]},B.id))})]}),$.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:d("entityPage.emptyRole")}),!f&&t.jsx(Vo,{total:v.length,shown:$.length,unit:d("entityPage.moreUnit"),onClick:()=>x(!0)})]})]}),ve=Le.length>0?t.jsx(Ut,{id:"external",title:d("entityPage.sec.external"),items:Le.map(B=>t.jsxs("a",{href:B.href,target:"_blank",rel:"noopener noreferrer",children:[B.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:Le.map(B=>B.id),foot:ie.cbdb_id!=null&&ie.cbdb_match==="auto"?d("entityPage.cbdbAuto"):void 0}):null;return t.jsx(Rn,{railTop:s,back:a,nav:fe,railLinks:l,main:Y,card:de,side:ve})},jr="(max-width: 719px)",qx=`${jr}, (pointer: coarse)`,Lc=`
|
|
1293
|
+
`,og=120;function ct(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function rg(e,n=og){if(!e)return;const o=e.replace(/\s+/g," ").trim(),r=Array.from(o);return r.length>n?r.slice(0,n).join("")+"…":o}function sg(e){const n=typeof e.birth_year=="number"?e.birth_year:void 0,o=typeof e.death_year=="number"?e.death_year:void 0;if(!(n===void 0&&o===void 0))return`${n??"?"}–${o??"?"}`}function ag(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(o=>{if(!o||typeof o!="object")return"";const r=o,s=ct(r.name);return s?[ct(r.dynasty)&&`〔${ct(r.dynasty)}〕`,s,ct(r.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function ic(e,n){const o=ct(n.type),r=ct(n.primary_name)??ct(n.title)??e,s=o==="entity"?[ct(n.dynasty),sg(n),ct(n.native_place)].filter(Boolean).join(" · "):[ag(n),ct(n.edition),ct(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?ct(n.description.text):ct(n.description);return{id:e,type:o,title:r,meta:s||void 0,description:rg(a)}}function oc(e){const n=[e.dynasty,e.author,e.edition].filter(Boolean).join(" · ");return{id:e.id,type:e.type,title:e.title,meta:n||void 0}}function rc(e){return async n=>{const o=await e.getItem(n);if(o)return ic(n,o);if(e.getEntry){const r=await e.getEntry(n);if(r)return oc(r)}return null}}const Is=new WeakMap;function lg(e,n,o){let r=Is.get(e);r||(r=new Map,Is.set(e,r));const s=r.get(o);if(s)return s;const a=n(o);return r.set(o,a),a.catch(()=>r.delete(o)),a}const sc=e=>`/item/${encodeURIComponent(e)}`,cg={work:"書名",person:"人名",place:"地名",office:"官職",dynasty:"朝代",other:"專名"},dg=typeof window>"u"?g.useEffect:g.useLayoutEffect;function mr(e,n){return g.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:rc(e)}:null,[n,e])}const pg=e=>e,ug=({text:e,entities:n,offsets:o="text",plainBase:r=0,transport:s,loadSummary:a,buildHref:l=sc,onNavigate:d,renderText:c=pg,hoverDelayMs:p=250,injectStyles:u=!0,className:m})=>{const h=g.useMemo(()=>{const x=o==="plain"?tc(e,n,r):n;return nc(e,x)},[e,n,o,r]),f=mr(s,a);return t.jsxs("span",{className:m?`bim-et-root ${m}`:"bim-et-root",children:[u&&t.jsx("style",{children:ur}),h.map(x=>x.type==="text"?t.jsx(g.Fragment,{children:c(x.text)},`t${x.start}`):t.jsx(hr,{span:x.span,label:x.text,hasBrackets:e[x.start-1]==="《"&&e[x.start+x.text.length]==="》",loader:f,buildHref:l,onNavigate:d,renderText:c,hoverDelayMs:p},`${x.span.key}@${x.start}`))]})},hr=({span:e,label:n,hasBrackets:o,loader:r,buildHref:s,onNavigate:a,renderText:l,hoverDelayMs:d})=>{const c=g.useId(),[p,u]=g.useState(!1),m=g.useRef(null),h=`bim-et bim-et-${e.kind}`,f=e.kind==="work"&&!o,x=t.jsxs(t.Fragment,{children:[f&&t.jsx("span",{className:"bim-et-sr",children:"《"}),l(n),f&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),k=()=>{m.current&&(clearTimeout(m.current),m.current=null)};g.useEffect(()=>k,[]);const y=g.useCallback(j=>{k(),j<=0?u(!0):m.current=setTimeout(()=>u(!0),j)},[]),w=g.useCallback(()=>{k(),u(!1)},[]);if(!e.targetId)return t.jsx("span",{className:h,children:x});const b=e.targetId;return t.jsxs("span",{className:"bim-et-w",onMouseEnter:()=>y(d),onMouseLeave:w,onKeyDown:j=>{j.key==="Escape"&&p&&(j.stopPropagation(),w())},children:[t.jsx("a",{className:h,href:s(b),"data-entity-id":b,"aria-describedby":p?c:void 0,onFocus:()=>y(0),onBlur:w,onClick:a?j=>a(b,j):void 0,children:x}),p&&t.jsx(mg,{id:c,entityId:b,span:e,loader:r})]})},mg=({id:e,entityId:n,span:o,loader:r})=>{const{convert:s}=Q(),a=g.useRef(null),[l,d]=g.useState("start"),[c,p]=g.useState(r?{status:"loading"}:{status:"ready",summary:null});g.useEffect(()=>{if(!r)return;let h=!1;return p({status:"loading"}),lg(r.owner,r.load,n).then(f=>{h||p({status:"ready",summary:f})}).catch(()=>{h||p({status:"error"})}),()=>{h=!0}},[r,n]),dg(()=>{const h=a.current;if(!h||typeof window>"u")return;const f=h.getBoundingClientRect(),x=document.documentElement.clientWidth||window.innerWidth;f.right>x-8&&l==="start"&&d("end")},[c,l]);const u=c.status==="ready"?c.summary:null,m=(u==null?void 0:u.title)??o.canonicalName??o.text;return t.jsxs("span",{ref:a,id:e,role:"tooltip",className:"bim-et-card","data-align":l,children:[t.jsx("span",{className:"bim-et-card-k",children:s(cg[o.kind])}),m&&t.jsx("span",{className:"bim-et-card-t",children:s(m)}),(u==null?void 0:u.meta)&&t.jsx("span",{className:"bim-et-card-m",children:s(u.meta)}),(u==null?void 0:u.description)&&t.jsx("span",{className:"bim-et-card-d",children:s(u.description)}),c.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:s("載入中…")}),c.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:s("摘要載入失敗")})]})},hg=e=>`/item/${encodeURIComponent(e)}`;function gg(e){const n=e.filter(o=>o.kind!=="break");return{before:n.filter(o=>o.pos==="before"),after:n.filter(o=>o.pos!=="before")}}function fg(e,n){const o=[];for(const r of e){const s=n.get(r.charData.id)??null,a=o[o.length-1];a&&a.entity===s?a.chars.push(r):o.push({entity:s,chars:[r]})}return o}const gr=({pageData:e,pages:n,punctuations:o=bg,selectedCharIds:r,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:u,convert:m,scrollToPage:h,entities:f,entityTransport:x,loadEntitySummary:k,buildEntityHref:y,onEntityNavigate:w})=>{const b=g.useRef(null),j=g.useRef(0),S=g.useMemo(()=>{const I=new Map;return p&&o.forEach((P,U)=>{const K=P.id?P:{...P,id:`${P.anchor}#${U}`},L=I.get(K.anchor)||[];L.push(K),I.set(K.anchor,L)}),I},[o,p]),v=g.useMemo(()=>(n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}]).filter(P=>P.columns.some(U=>U.chars.length>0)).map(P=>{const U=[...P.columns].sort((Z,A)=>Z.col-A.col),K=[];let L=[];for(const Z of U)for(const A of Z.chars){const{before:V,after:pe}=gg(S.get(A.id)||[]),ee=(S.get(A.id)||[]).some(ue=>ue.kind==="break");L.push({charData:A,col:Z.col,beforePuncts:V,afterPuncts:pe}),ee&&(K.push({id:`para-p${P.page}-${K.length}`,chars:L}),L=[])}return L.length>0&&K.push({id:`para-p${P.page}-${K.length}`,chars:L}),{page:P.page,paragraphs:K}}),[n,e,S]),$=g.useMemo(()=>{const I=[];for(const P of v)for(const U of P.paragraphs)for(const K of U.chars)I.push(K.charData.id);return I},[v]),_=g.useMemo(()=>{const I=new Map;if(!f||f.length===0)return I;const P=new Map($.map((U,K)=>[U,K]));for(const U of f){if(!U.anchor)continue;const K=P.get(U.anchor.start),L=P.get(U.anchor.end);if(!(K===void 0||L===void 0||L<K))for(let Z=K;Z<=L;Z++)I.has($[Z])||I.set($[Z],U)}return I},[f,$]),C=mr(x,k),M=_.size>0,T=g.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:u,onEntityNavigate:w});T.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:u,onEntityNavigate:w};const z=g.useMemo(()=>({click:I=>{var P,U;j.current=Date.now()+1200,(U=(P=T.current).onCharClick)==null||U.call(P,I)},enter:I=>{var P,U;return(U=(P=T.current).onCharHover)==null?void 0:U.call(P,I)},leave:()=>{var I,P;return(P=(I=T.current).onCharHover)==null?void 0:P.call(I,null)},navigate:(I,P)=>{var K,L;if(!(P.detail===0||P.ctrlKey||P.metaKey||P.shiftKey)){P.preventDefault();return}(L=(K=T.current).onEntityNavigate)==null||L.call(K,I,P)}}),[]),F=yg(r),N=g.useRef(null);g.useEffect(()=>{var P,U;if((P=N.current)==null||P.classList.remove("is-hovered"),N.current=null,!s)return;const I=(U=b.current)==null?void 0:U.querySelector(`span[data-char-id="${s}"]`);I&&(I.classList.add("is-hovered"),N.current=I)},[s]),g.useEffect(()=>{let I=null;const P=()=>{var ie,Re;I=null;const K=window.getSelection(),L=b.current;if(!K||K.isCollapsed||K.rangeCount===0||!L)return;const Z=K.getRangeAt(0),A=Z.commonAncestorContainer,V=A.nodeType===3?A.parentElement:A;if(!V||!L.contains(V))return;const pe=L.querySelectorAll("span[data-char-id]");let ee=0,ue=pe.length;for(;ee<ue;){const Le=ee+ue>>1;Z.comparePoint(pe[Le],0)<0?ee=Le+1:ue=Le}const me=ee;for(ue=pe.length;ee<ue;){const Le=ee+ue>>1;Z.comparePoint(pe[Le],0)<=0?ee=Le+1:ue=Le}const be=ee-1;if(be<me)return;const Oe=[];for(let Le=me;Le<=be;Le++)Oe.push(pe[Le].getAttribute("data-char-id"));Oe.length>0&&(j.current=Date.now()+1200,(Re=(ie=T.current).onSelectionChange)==null||Re.call(ie,Oe))},U=()=>{I&&clearTimeout(I),I=setTimeout(P,120)};return document.addEventListener("selectionchange",U),()=>{document.removeEventListener("selectionchange",U),I&&clearTimeout(I)}},[]),g.useEffect(()=>{var I;if(r.size===1){const P=Array.from(r)[0],U=(I=b.current)==null?void 0:I.querySelector(`span[data-char-id="${P}"]`);U&&U.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[r]);const R=h==null?void 0:h.nonce;g.useEffect(()=>{var P;if(!h)return;const I=(P=b.current)==null?void 0:P.querySelector(`[data-page-section="${h.page}"]`);I&&(j.current=Date.now()+800,I.scrollIntoView({behavior:"auto",block:"start"}))},[R]);const O=!!u;return g.useEffect(()=>{var Z;if(!O)return;const I=Array.from(((Z=b.current)==null?void 0:Z.querySelectorAll("[data-page-section]"))??[]);if(I.length===0)return;const P=120;let U=0;const K=()=>{var ee,ue;if(U=0,Date.now()<j.current)return;let A=0,V=I.length-1;for(;A<V;){const me=A+V+1>>1;I[me].getBoundingClientRect().top<=P?A=me:V=me-1}const pe=parseInt(I[A].getAttribute("data-page-section")||"",10);isNaN(pe)||(ue=(ee=T.current).onVisiblePageChange)==null||ue.call(ee,pe)},L=()=>{U||(U=requestAnimationFrame(K))};return window.addEventListener("scroll",L,{passive:!0}),K(),()=>{window.removeEventListener("scroll",L),U&&cancelAnimationFrame(U)}},[O,v]),t.jsxs("div",{ref:b,className:"guji-text-pane-content",children:[M&&t.jsx("style",{children:ur}),t.jsx("div",{className:"guji-text-reflow-view",children:v.map((I,P)=>t.jsx(vg,{pGroup:I,first:P===0,selected:F.get(I.page)??xg,entityOfChar:_,entityLoader:C,convert:m,buildHref:y??hg,handlers:z},`page-sec-${I.page}`))})]})},xg=new Set,bg=[];function yg(e){const n=g.useRef(new Map);return g.useMemo(()=>{const o=new Map;e.forEach(s=>{const a=parseInt(s.split(":")[0],10);let l=o.get(a);l||o.set(a,l=new Set),l.add(s)});const r=new Map;return o.forEach((s,a)=>{const l=n.current.get(a),d=l&&l.size===s.size&&Array.from(s).every(c=>l.has(c));r.set(a,d?l:s)}),n.current=r,r},[e])}function jg(e,n){const o=Array.from(n(e.join("")));return o.length===e.length&&e.every(r=>Array.from(r).length===1)?o:e.map(r=>n(r))}const vg=g.memo(function({pGroup:n,first:o,selected:r,entityOfChar:s,entityLoader:a,convert:l,buildHref:d,handlers:c}){const p=g.useMemo(()=>{const m=new Map;if(!l)return m;for(const h of n.paragraphs){const f=jg(h.chars.map(x=>x.charData.char),l);h.chars.forEach((x,k)=>m.set(x.charData.id,f[k]))}return m},[n,l]),u=m=>p.get(m.id)??m.char;return t.jsxs("section",{"data-page-section":n.page,className:"guji-page-section",style:{position:"relative",scrollMarginTop:96},children:[!o&&t.jsxs("div",{className:"guji-page-divider",style:{display:"flex",alignItems:"center",margin:"2rem 0 1.2rem",color:i("meta-fg"),fontSize:"0.82rem",letterSpacing:"0.08em",userSelect:"none"},children:[t.jsx("div",{style:{flex:1,height:"1px",background:i("rule")}}),t.jsxs("span",{style:{padding:"0 12px",fontWeight:500},children:["第 ",n.page," 葉"]}),t.jsx("div",{style:{flex:1,height:"1px",background:i("rule")}})]}),n.paragraphs.map(m=>t.jsx("p",{className:"guji-reflow-paragraph",children:fg(m.chars,s).map((h,f)=>{const x=h.chars.map(({charData:w,col:b,beforePuncts:j,afterPuncts:S},v)=>{const $=!!h.entity&&v===0,_=!!h.entity&&v===h.chars.length-1,C=$?[]:j,M=_?[]:S;return t.jsxs(g.Fragment,{children:[C.map(T=>t.jsx("span",{className:"guji-text-punct","data-punct-id":T.id,children:T.mark},T.id)),t.jsx("span",{"data-char-id":w.id,onClick:()=>c.click(w.id),onMouseEnter:()=>c.enter(w.id),onMouseLeave:c.leave,className:`guji-text-char${r.has(w.id)?" is-selected":""}${w.sub?" is-sub":""}`,title:`[第${n.page}葉·第${b}列·第${w.slot||w.pos}字] ${u(w)}`,children:u(w)}),M.map(T=>t.jsx("span",{className:"guji-text-punct","data-punct-id":T.id,children:T.mark},T.id))]},w.id)});if(!h.entity)return t.jsx(g.Fragment,{children:x},`r${f}`);const k=h.chars[0].beforePuncts.map(w=>t.jsx("span",{className:"guji-text-punct","data-punct-id":w.id,children:w.mark},w.id)),y=h.chars[h.chars.length-1].afterPuncts.map(w=>t.jsx("span",{className:"guji-text-punct","data-punct-id":w.id,children:w.mark},w.id));return t.jsxs(g.Fragment,{children:[k,t.jsx(hr,{span:h.entity,label:h.chars.map(w=>u(w.charData)).join(""),hasBrackets:!0,loader:a,buildHref:d,onNavigate:c.navigate,renderText:()=>x,hoverDelayMs:250}),y]},`${h.entity.key}@${f}`)})},m.id))]})}),ac=1,lc=6,Xn={s:1,x:0,y:0},ei=(e,n,o)=>Math.min(o,Math.max(n,e));function fr(e,n,o){const r=ei(e.s,ac,lc);return{s:r,x:ei(e.x,n*(1-r),0),y:ei(e.y,o*(1-r),0)}}function Ki(e,n,o,r,s,a){const l=ei(e.s*r,ac,lc),d=l/e.s;return fr({s:l,x:n-(n-e.x)*d,y:o-(o-e.y)*d},s,a)}function kg(e,n,o,r,s){return fr({s:e.s,x:e.x+n,y:e.y+o},r,s)}function wg(e,n,o){const r=n===1?e*16:n===2?e*400:e;return Math.exp(-r*(o?.01:.0015))}const Rs=4,Sg=g.forwardRef(function({children:n,onScaleChange:o,resetKey:r,style:s},a){const l=g.useRef(null),[d,c]=g.useState(Xn),p=g.useRef(d),u=g.useRef(o);u.current=o;const m=b=>{var S;const j=p.current;p.current=b,c(b),b.s!==j.s&&((S=u.current)==null||S.call(u,b.s))},h=()=>{var j;const b=(j=l.current)==null?void 0:j.getBoundingClientRect();return{w:(b==null?void 0:b.width)??0,h:(b==null?void 0:b.height)??0,left:(b==null?void 0:b.left)??0,top:(b==null?void 0:b.top)??0}};g.useImperativeHandle(a,()=>({zoomBy(b){const{w:j,h:S}=h();m(Ki(p.current,j/2,S/2,b,j,S))},reset(){m(Xn)}})),g.useEffect(()=>{m(Xn)},[r]),g.useEffect(()=>{const b=l.current;if(!b||typeof ResizeObserver>"u")return;const j=new ResizeObserver(()=>{const{w:S,h:v}=h(),$=fr(p.current,S,v);($.x!==p.current.x||$.y!==p.current.y)&&m($)});return j.observe(b),()=>j.disconnect()},[]),g.useEffect(()=>{const b=l.current;if(!b)return;const j=S=>{const v=wg(S.deltaY,S.deltaMode,S.ctrlKey);if(p.current.s<=1&&v<1)return;S.preventDefault();const{w:$,h:_,left:C,top:M}=h();m(Ki(p.current,S.clientX-C,S.clientY-M,v,$,_))};return b.addEventListener("wheel",j,{passive:!1}),()=>b.removeEventListener("wheel",j)},[]);const f=g.useRef(new Map),x=g.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),k=b=>{if(b.pointerType==="mouse"&&b.button!==0)return;f.current.set(b.pointerId,{x:b.clientX,y:b.clientY});const j=x.current;if(j.swallowClick=!1,f.current.size===1&&(j.moved=0,j.dragging=!1),f.current.size===2){const[S,v]=[...f.current.values()];j.pinchDist=Math.hypot(S.x-v.x,S.y-v.y),j.moved=Rs+1}},y=b=>{var F;const j=f.current.get(b.pointerId);if(!j)return;const S={x:b.clientX,y:b.clientY};f.current.set(b.pointerId,S);const v=x.current,{w:$,h:_,left:C,top:M}=h();if(f.current.size>=2){const[N,R]=[...f.current.values()],O=Math.hypot(N.x-R.x,N.y-R.y);if(v.pinchDist>0&&O>0){const I=(N.x+R.x)/2-C,P=(N.y+R.y)/2-M;m(Ki(p.current,I,P,O/v.pinchDist,$,_))}v.pinchDist=O,v.swallowClick=!0;return}const T=S.x-j.x,z=S.y-j.y;if(v.moved+=Math.abs(T)+Math.abs(z),!(v.moved<=Rs)){if(!v.dragging){v.dragging=!0;try{(F=l.current)==null||F.setPointerCapture(b.pointerId)}catch{}}v.swallowClick=!0,p.current.s>1&&m(kg(p.current,T,z,$,_))}},w=b=>{f.current.delete(b.pointerId);const j=x.current;j.pinchDist=0,f.current.size===0&&(j.dragging=!1)};return t.jsx("div",{ref:l,className:"bim-zp","data-zoom":d.s.toFixed(2),onPointerDown:k,onPointerMove:y,onPointerUp:w,onPointerCancel:w,onClickCapture:b=>{x.current.swallowClick&&(x.current.swallowClick=!1,b.stopPropagation(),b.preventDefault())},onDoubleClick:()=>m(Xn),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 cc(e,n,o,r,s){const[a,l]=g.useState(n??null),[d,c]=g.useState(!1),p=g.useRef(0);return g.useEffect(()=>{if(n!==void 0){l(n);return}const u=++p.current;if(!o){l(null),c(!1);return}if(e){let m;try{m=e(o,s)}catch{l(null),c(!1);return}if(!m||typeof m.then!="function"){l(m??null),c(!1);return}c(!0),m.then(h=>{u===p.current&&l(h??null)}).catch(()=>{u===p.current&&l(null)}).finally(()=>{u===p.current&&c(!1)});return}if(r!=null&&r.warp_data){if(typeof r.warp_data=="object"){l(r.warp_data);return}if(typeof r.warp_data=="string"){c(!0),fetch(r.warp_data).then(m=>m.ok?m.json():null).then(m=>{u===p.current&&l(m)}).catch(()=>{u===p.current&&l(null)}).finally(()=>{u===p.current&&c(!1)});return}}l(null),c(!1)},[e,n,o,r,s]),{warpData:a,loading:d}}function _g(e,n,o){const[r,s]=g.useState([]),a=g.useRef(0);return g.useEffect(()=>{const l=++a.current;if(!e||!n){s([]);return}let d;try{d=e(n,o)}catch{s([]);return}Promise.resolve(d).then(c=>{l===a.current&&s(c?ec(c):[])}).catch(()=>{l===a.current&&s([])})},[e,n,o]),r}const Ls={padding:24,color:i("desc-fg"),fontSize:14};function As({title:e,label:n,className:o,style:r}){const s=(a,l=14,d=14)=>({width:a,height:l,marginTop:d,borderRadius:3,background:i("rule")});return t.jsxs("div",{className:o,style:{...r,padding:"20px 24px",maxWidth:760,margin:"0 auto"},"aria-busy":"true",children:[e&&t.jsx("div",{style:{fontSize:15,color:i("ink"),fontFamily:i("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:i("desc-fg"),fontSize:14,fontFamily:i("font-ui")},children:n})]})}const Ps=/^https?:\/\//i;function $g(e){if(!e||typeof e!="object")return null;const n=a=>typeof a=="string"&&a.trim()?a.trim():void 0,o=n(e.url),r=n(e.license_url),s={name:n(e.name),url:o&&Ps.test(o)?o:void 0,license:n(e.license),license_url:r&&Ps.test(r)?r:void 0,note:n(e.note)};return s.name||s.license||s.note?s:null}function Cg(e,n){return{work_id:n.work_id??e,title:n.title,type:n.type,juan_files:n.chapters.map(o=>o.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 zg(e,n){return(n==null?void 0:n.type)==="kaozhen"?"章":n!=null&&n.juan_metadata&&Object.values(n.juan_metadata).some(o=>o.vol_label)?"冊":(e==null?void 0:e.kind)==="collated"?"卷":"章"}function dc(e,n,o,r=!1){const s=o(`${n}${e.n}`);if(!e.title)return s;const a=o(e.title);return r&&!/^[卷冊册章篇回第]/.test(e.title)?`${s} ${a}`:a}function Tg(e,n,o,r,s){var p;const a=new Map(e.chapters.map(u=>[u.file,u])),l=u=>u==="loading"?"…":typeof u=="number"&&u>0?u:void 0,d=(u,m)=>{const h=a.get(u);return{key:u,label:m??(h?dc(h,o,r,s):u),hint:l(n[u]),disabled:n[u]===0}},c=(p=e.juan_groups)==null?void 0:p.filter(u=>{var m;return u.files.some(h=>a.has(h))||((m=u.children)==null?void 0:m.length)});if(c&&c.length>0){const u=(m,h)=>{var x;if(m.files.length===1&&!((x=m.children)!=null&&x.length))return d(m.files[0],r(m.label));const f=Ah(m,n);return{key:`group:${h}`,label:r(m.label),hint:f==="loading"?"…":typeof f=="number"&&f>0?`${f}`:Jl(m),defaultExpanded:typeof f=="number"&&f>0,children:[...m.files.filter(k=>a.has(k)).map(k=>d(k)),...(m.children??[]).map((k,y)=>u(k,`${h}.${y}`))]}};return c.map((m,h)=>u(m,`${h}`))}return e.chapters.map(u=>d(u.file))}const xr=({id:e,transport:n,versionKey:o,chapter:r,onLocationChange:s,onNavigate:a,title:l,subtitle:d,resolveImages:c,renderImageOverlay:p,imagePanel:u,allowVertical:m,onReportError:h,revisedAt:f,backHref:x,backLabel:k,resolveWarpData:y,warpData:w,resolveEntities:b,onEntityNavigate:j,className:S,style:v})=>{var Mr,Br,Wr;const{t:$,convert:_}=Q(),C=g.useMemo(()=>sl(n),[n]),[M,T]=gl(),z=Xe(),F=g.useRef(s);F.current=s;const[N,R]=g.useState(null),[O,I]=g.useState("loading");g.useEffect(()=>{let W=!1;return R(null),I("loading"),C.getManifest(e).then(he=>{W||(he?(R(he),I("ready")):I("missing"))}).catch(()=>{W||I("missing")}),()=>{W=!0}},[C,e]);const P=o!==void 0,U=r!==void 0,[K,L]=g.useState(null),[Z,A]=g.useState(null);g.useEffect(()=>{L(null),A(null)},[e]);const V=we.pickTextVersion(N,P?o:K),pe=((Mr=N==null?void 0:N.versions.find(W=>W.key==="default"))==null?void 0:Mr.key)??((Br=N==null?void 0:N.versions[0])==null?void 0:Br.key)??"default",ee=(V==null?void 0:V.key)??null,ue=U?r:Z,me=g.useCallback((W,he,Ae)=>{var Fe;(Fe=F.current)==null||Fe.call(F,{key:W,chapter:he,isDefault:W===pe},Ae)},[pe]);g.useEffect(()=>{!N||!P||o==null||N.versions.some(W=>W.key===o)||me(pe,null,"auto")},[N,P,o,pe,me]);const be=g.useRef(new Map);g.useEffect(()=>{be.current.clear()},[C,e]);const Oe=g.useCallback(async W=>{const he=`${e}
|
|
1294
|
+
${W}`;if(be.current.has(he))return be.current.get(he)??null;const Ae=await C.getIndex(e,W).catch(()=>null);return Ae&&be.current.set(he,Ae),Ae},[C,e]),[ie,Re]=g.useState(null),[Le,q]=g.useState("loading");g.useEffect(()=>{if(!ee)return;let W=!1;return Re(null),q("loading"),Oe(ee).then(he=>{W||(he&&he.chapters.length>0?(Re(he),q("ready")):q("failed"))}),()=>{W=!0}},[ee,Oe]),g.useEffect(()=>{if(!ie||!ee||ue!=null&&ie.chapters.some(Ae=>Ae.file===ue))return;const he=ie.chapters[0].file;U||A(he),me(ee,he,"auto")},[ie,ee,ue,U,me]);const J=ie?ue!=null&&ie.chapters.some(W=>W.file===ue)?ue:ie.chapters[0].file:ue,fe=g.useMemo(()=>ie&&J?ie.chapters.find(W=>W.file===J)??null:null,[ie,J]),ze=g.useRef(0),Y=g.useCallback(async W=>{if(!N||W===ee||!N.versions.some(it=>it.key===W))return;const he=++ze.current,Ae=await Oe(W);if(he!==ze.current)return;const Fe=fe??(J?{file:J}:null),Ke=we.matchChapterAcrossVersions(Fe,Ae);P||L(W),U||A(Ke),me(W,Ke,"version")},[N,ee,Oe,fe,J,P,U,me]),ve=g.useCallback(W=>{ee&&(U||A(W),me(ee,W,"chapter"))},[ee,U,me]),[le,Se]=g.useState(null),X=ee&&fe?`${e}
|
|
1295
|
+
${ee}
|
|
1296
|
+
${fe.file}`:null,[Ce,Me]=g.useState(null),B=X!==null&&Ce!==X,te=g.useRef(0);g.useEffect(()=>{if(!ee||!fe)return;const W=++te.current,he=`${e}
|
|
1297
|
+
${ee}
|
|
1298
|
+
${fe.file}`;Se(null),C.getChapter(e,ee,fe.file,{json:!!fe.has_json}).then(Ae=>{W===te.current&&Se(Ae)}).catch(()=>{W===te.current&&Se(null)}).finally(()=>{W===te.current&&Me(he)})},[C,e,ee,fe]);const ye=(V==null?void 0:V.kind)==="collated",[H,se]=g.useState("");g.useEffect(()=>{se("")},[e,ee]);const ne=g.useMemo(()=>ee&&ye?async W=>{const he=await C.getChapter(e,ee,W,{json:!0});return{juan:(he==null?void 0:he.json)??null,rawText:(he==null?void 0:he.md)??null}}:null,[C,e,ee,ye]),ge=(ie==null?void 0:ie.type)==="kaozhen",Ne=g.useMemo(()=>(ie==null?void 0:ie.chapters.map(W=>W.file))??[],[ie]),{matchStates:Be}=Kh({resetKey:`${e}
|
|
1299
|
+
${ee??""}`,load:ne,files:Ne,activeFile:J??null,activeJuan:(le==null?void 0:le.json)??null,activeRawText:(le==null?void 0:le.md)??null,query:H,isKaozhen:ge}),We=g.useRef(new Map);g.useEffect(()=>{We.current.clear()},[e]);const Ue=g.useMemo(()=>({versionKey:ee,chapter:fe??null}),[ee,fe]),Qe=kh(c,J??null,Ue),{warpData:ce,loading:tt}=cc(y,w,J??null,fe,Ue),E=_g(b,J??null,Ue),[oe,ae]=g.useState(new Set),[je,ke]=g.useState(null),[xe,G]=g.useState(!0),[de,Te]=g.useState(!0),Ee=g.useRef(null),[D,re]=g.useState(1),[Pe,_e]=g.useState(null),Ge=W=>{var Ae;const he=parseInt(((Ae=W==null?void 0:W.page_id)==null?void 0:Ae.split(":")[1])??"",10);return isNaN(he)?null:he},He=W=>{var Ae,Fe;const he=(W==null?void 0:W.pages)??[];return Ge(W)??((Ae=he.find(Ke=>Ke.columns.some(it=>it.chars.length>0)))==null?void 0:Ae.page)??((Fe=he[0])==null?void 0:Fe.page)??1},[De,Tt]=g.useState(()=>He(ce)),Pt=`${e}
|
|
1300
|
+
${ee}
|
|
1301
|
+
${J??""}`,[qt,mn]=g.useState({key:Pt,data:ce,started:!!ce});if(qt.key!==Pt)mn({key:Pt,data:ce,started:!1});else if(ce!==qt.data&&(mn({key:Pt,data:ce,started:!!ce}),ce)){const W=ce.pages??[];(!qt.started||!W.some(he=>he.page===De))&&Tt(He(ce))}g.useEffect(()=>{ae(new Set),ke(null)},[J,ee]);const On=g.useCallback(W=>{if(ae(new Set(W)),W.length>0){const he=W[0],Ae=parseInt(he.split(":")[0],10);isNaN(Ae)||Tt(Ae)}},[]),ft=g.useMemo(()=>{const W=new Map;for(const he of(ce==null?void 0:ce.pages)??[])W.set(he.page,he);return W},[ce]),hn=Ge(ce),Hn=g.useCallback(W=>{var Fe;const he=Qe.images;if(!he||he.length===0)return;const Ae=(Fe=ft.get(W))==null?void 0:Fe.seq;return(Ae?he.find(Ke=>Ke.seq===Ae):void 0)??he.find(Ke=>Ke.pageNo===W)??he[W-1]},[Qe.images,ft]),Ir=D>1.5,Fn=g.useCallback((W,he=!1)=>{const Ae=Hn(W);return Ae?W===hn||he?Ae.hiresUrl??Ae.url:Ae.url:W===hn?(ce==null?void 0:ce.imageUrl)??"":""},[Hn,ce,hn]),Rd=g.useMemo(()=>Fn(De,Ir),[Fn,De,Ir]),gn=g.useMemo(()=>[...ft.keys()].sort((W,he)=>W-he),[ft]),Ei=g.useRef(De);Ei.current=De;const fn=g.useCallback(W=>{var Ke;const he=Ei.current,Ae=gn.indexOf(he),Fe=gn[Ae<0?0:Ae+W];Fe===void 0||Fe===he||(Ei.current=Fe,Tt(Fe),(Ke=ft.get(Fe))!=null&&Ke.columns.some(it=>it.chars.length>0)&&_e(it=>({page:Fe,nonce:((it==null?void 0:it.nonce)??0)+1})))},[gn,ft]),Ii=gn.indexOf(De),Ld=g.useCallback(W=>{if(W.altKey||W.ctrlKey||W.metaKey)return;const he=W.target.tagName;he==="INPUT"||he==="TEXTAREA"||he==="SELECT"||(W.key==="ArrowLeft"||W.key==="PageUp"?(W.preventDefault(),fn(-1)):(W.key==="ArrowRight"||W.key==="PageDown")&&(W.preventDefault(),fn(1)))},[fn]);g.useEffect(()=>{if(ce)for(const W of[1,-1,2,3]){const he=Fn(De+W);he&&yo(he)}},[ce,De,Fn]);const Rr=g.useMemo(()=>{var Dr;if(!ce)return null;if(De===hn)return ce;const W=ft.get(De);if(W&&W.width>0&&W.height>0)return{page_id:`p:${De}`,title:`第${De}葉`,image_size:[W.width,W.height],total_warped_w:W.width,columns:[{col:1,warped_w:W.width,warped_h:W.height,offset_x:0,strips:[],chars:W.columns.flatMap(Ye=>Ye.chars).map(Ye=>({id:Ye.id,char:Ye.char,slot:Ye.slot,pos:Ye.pos,sub:Ye.sub,bbox_col:Ye.bbox??[0,0,0,0]}))}]};const he=(Dr=ce.pages)==null?void 0:Dr.find(Ye=>Ye.page===De),[Ae,Fe]=ce.image_size||[2386,3082],Ke=Hn(De),it=(Ke==null?void 0:Ke.width)??Ae,Mi=(Ke==null?void 0:Ke.height)??Fe,Or=it/Ae,Hr=Mi/Fe,Fr=new Map;for(const Ye of ce.columns){const lt=(Ye.strips||[]).flatMap(Vn=>Vn.srcQuad.map(Gn=>Gn[0]));if(lt.length===0)continue;const kt=Ye.top_y??0,Bi=Ye.bottom_y??kt+Ye.warped_h;Fr.set(Ye.col,{x0:Math.min(...lt),x1:Math.max(...lt),top:kt,slotH:(Bi-kt)/21})}return{page_id:`p:${De}`,title:`第${De}葉`,image_size:[it,Mi],total_warped_w:it,columns:he?he.columns.map(Ye=>{const lt=Fr.get(Ye.col)??{x0:0,x1:0,top:0,slotH:118};return{col:Ye.col,warped_w:it,warped_h:Mi,offset_x:0,strips:[],chars:Ye.chars.map(kt=>{const Bi=kt.slot??kt.pos??0,Vn=(lt.top+(Bi-1)*lt.slotH)*Hr,Gn=(lt.x0+lt.x1)/2,[Fd,Dd]=kt.sub==="a"?[Gn,lt.x1]:kt.sub==="b"?[lt.x0,Gn]:[lt.x0,lt.x1];return{...kt,bbox_col:[Fd*Or,Vn,Dd*Or,Vn+lt.slotH*Hr]}})}}):[]}},[ce,De,hn,ft,Hn]),{entryTitle:Dn,authors:Lr}=Ig(e,n,l===void 0),[Ar,Ri]=g.useState("text");if(g.useEffect(()=>{Ri("text")},[J,ee]),O==="loading")return t.jsx(As,{className:S,style:v,title:l??Dn,label:$("reader.loading")});if(O==="missing"||!N||!V)return t.jsx("div",{className:S,style:{...v,...Ls},children:$("reader.noText")});if(Le==="failed")return t.jsx("div",{className:S,style:{...v,...Ls},children:$("reader.tocFailed")});if(!ie)return t.jsx(As,{className:S,style:v,title:l??Dn,label:$("reader.tocLoading")});const Mt=zg(V,ie),Ad=Tg(ie,Be,Mt,_,ye),Li=N.versions.map(W=>({key:W.key,label:we.textVersionLabel(W),optionLabel:_(we.textVersionLabel(W)),sourceName:W.source_name?_(W.source_name):void 0,license:W.license??void 0,sourceUrl:W.source_url??void 0,primary:W.key===pe})),at=$g((Wr=ie.source)==null?void 0:Wr.upstream),Un=(typeof l=="string"?_(l):l)??(ie.title?_(ie.title):Dn?_(Dn):void 0),Pd=Un?t.jsx("a",{href:z(e),title:$("reader.viewEntry"),onClick:a?W=>{W.metaKey||W.ctrlKey||(W.preventDefault(),a(e))}:void 0,children:Un}):void 0,Md=Lr.length>0?_(Lr.slice(0,2).map(W=>`${W.dynasty?`〔${W.dynasty}〕`:""}${W.name}${` ${W.role||$("reader.defaultRole")}`}`).join("、")):void 0,Ai=fe?dc(fe,Mt,_,ye):void 0,Xt=ye&&!!(le!=null&&le.json),Bt=(le==null?void 0:le.json)??null,Zt=(le==null?void 0:le.md)??null,Pr=Xt&&!ge&&Ql(Bt.sections),Bd=Pr&&!(Zt&&M.readingMode==="paragraph"&&si(Zt)),Wd=Xt&&Pr?t.jsx(qh,{juan:Bt,view:Ar,onView:Ri,textHasEntries:Bd}):void 0,Od=il(ie)||so(ie),Pi=Zt?Zt.replace(/^##\s+[^\n]+\n+/,""):null,Hd=(typeof d=="string"?_(d):d)??(V.source_name?_(V.source_name):_(we.textVersionLabel(V)));return t.jsxs(bl,{className:S,style:v,title:Pd,subtitle:Hd,byline:Md,current:Ai,pagerUnit:Mt,rail:Wd,revisedAt:f,backHref:x,backLabel:k,onReportError:h?W=>h({...W,bookTitle:typeof Un=="string"?Un:void 0,entryId:e}):void 0,workLinkToggle:Xt&&!ge&&!!a&&!!(Bt!=null&&Bt.sections.some(W=>W.work_id)),toc:Ad,tocCaption:$("reader.tocCaption",{n:ie.chapters.length,unit:_(Mt)}),tocHeader:ye&&ie.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:ge?$("reader.searchChaptersPlaceholder"):$("reader.searchUnitPlaceholder",{unit:_(Mt)}),"aria-label":ge?$("reader.searchChapters"):$("reader.searchUnit",{unit:_(Mt)}),value:H,onChange:W=>se(W.target.value)}):void 0,activeKey:J??null,onSelect:ve,images:Qe.images,imagesLoading:Qe.loading||tt,renderImageOverlay:p,imagePanel:ce?"open":u,isWarpMode:!!ce,customImagePanel:ce&&Rr?t.jsxs("div",{className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:Ld,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:i("meta-fg"),gap:8,flexWrap:"wrap"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[t.jsx("span",{style:{fontWeight:600,marginRight:4},children:"底本书影"}),t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-prev","aria-label":"上一葉",disabled:Ii<=0,onClick:()=>fn(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":De,style:{fontSize:11,padding:"1px 6px",background:i("rule"),borderRadius:10},children:["第 ",De," 葉"]}),t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-next","aria-label":"下一葉",disabled:Ii<0||Ii>=gn.length-1,onClick:()=>fn(1),children:"›"})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[oe.size>0&&t.jsxs("button",{type:"button",onClick:()=>ae(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${i("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",oe.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:D<=1,onClick:()=>{var W;return(W=Ee.current)==null?void 0:W.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(D*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:D>=6,onClick:()=>{var W;return(W=Ee.current)==null?void 0:W.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:D===1,onClick:()=>{var W;return(W=Ee.current)==null?void 0:W.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(Sg,{ref:Ee,resetKey:De,onScaleChange:re,style:{flex:1,minHeight:0},children:t.jsx(dr,{imageUrl:Rd,pageData:Rr,selectedCharIds:oe,hoveredCharId:je,preserveMargins:de,onCharClick:W=>{ae(Ae=>{const Fe=new Set(Ae);return Fe.has(W)?Fe.delete(W):(Fe.clear(),Fe.add(W)),Fe});const he=document.querySelector(`[data-char-id="${W}"]`);he&&he.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:ke})}),t.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 0 2px"},children:t.jsxs("div",{style:{display:"inline-flex",border:`1px solid ${i("rule")}`,borderRadius:4,overflow:"hidden"},children:[t.jsx("button",{type:"button",onClick:()=>Te(!1),"aria-pressed":!de,className:`bim-rd-t ${de?"":"bim-rd-on"}`,style:{fontSize:11,padding:"2px 10px",lineHeight:"18px",border:"none",borderRadius:0,cursor:"pointer",background:de?"transparent":i("accent-bg"),color:de?"inherit":i("accent")},title:"去空白:紧凑裁切版心",children:"去空白"}),t.jsx("button",{type:"button",onClick:()=>Te(!0),"aria-pressed":de,className:`bim-rd-t ${de?"bim-rd-on":""}`,style:{fontSize:11,padding:"2px 10px",lineHeight:"18px",border:"none",borderRadius:0,cursor:"pointer",background:de?i("accent-bg"):"transparent",color:de?i("accent"):"inherit"},title:"保留空白:完整呈现古籍天头地脚与白边",children:"保留空白"})]})})]}):void 0,toolbarExtra:ce?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-badge-warp",children:"图文对读"}),t.jsx("button",{type:"button",className:`bim-rd-t ${xe?"bim-rd-on":""}`,"aria-pressed":xe,title:"切换外挂现代断句标点",onClick:()=>G(W=>!W),children:xe?"标点":"无标点"})]}):void 0,prefs:M,onPrefsChange:T,versions:Li.length>1?Li:void 0,currentVersionKey:Li.length>1?V.key:void 0,onVersionChange:Y,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:si(Zt),allowVertical:m,children:[B&&t.jsx(Yt,{}),!B&&ce&&t.jsxs("article",{className:"bim-rd-prose",style:{marginTop:0},children:[t.jsxs("header",{style:{marginBottom:16},children:[t.jsx("h1",{className:"bim-rd-h1",children:fe!=null&&fe.title?_(fe.title):Ai}),(V.source_name||V.license)&&t.jsxs("p",{className:"bim-rd-meta",children:[V.source_name&&_(V.source_name),V.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),V.license]})]})]}),t.jsx(gr,{pageData:ce,pages:ce.pages,punctuations:ce.punctuations||[],selectedCharIds:oe,hoveredCharId:je,onSelectionChange:On,onCharClick:W=>{ae(Ae=>{const Fe=new Set(Ae);return Fe.has(W)?Fe.delete(W):(Fe.clear(),Fe.add(W)),Fe});const he=parseInt(W.split(":")[0],10);isNaN(he)||Tt(he)},onCharHover:ke,mode:"horizontal",showPunctuation:xe,entities:M.properNames?E:void 0,entityTransport:n,onEntityNavigate:j,onVisiblePageChange:W=>Tt(W),convert:_,scrollToPage:Pe})]}),!B&&!ce&&Xt&&Bt&&t.jsx(Yh,{juan:Bt,rawText:Zt,positionLabel:Ng(fe,ie,Mt,_),groupLabel:Eg(ie,J??null),index:Cg(e,ie),searchQuery:H,onNavigate:a,transport:n,workLabelCache:We,prefs:M,view:Ar,onViewChange:Ri},`${ee}/${J}`),!B&&!ce&&!Xt&&Pi!=null&&fe&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:fe.title?_(fe.title):Ai}),(V.source_name||V.license)&&t.jsxs("p",{className:"bim-rd-meta",children:[V.source_name&&t.jsxs(t.Fragment,{children:[$("reader.textSource")," ",V.source_url?t.jsx("a",{className:"bim-rd-link",href:V.source_url,target:"_blank",rel:"noreferrer",children:_(V.source_name)}):_(V.source_name)]}),V.source_name&&V.license&&t.jsx("span",{className:"bim-rd-dot"}),V.license]}),at&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[$("reader.upstream")," ",at.url?t.jsx("a",{className:"bim-rd-link",href:at.url,target:"_blank",rel:"noreferrer",children:_(at.name??at.url)}):_(at.name??""),at.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),at.license_url?t.jsx("a",{className:"bim-rd-link",href:at.license_url,target:"_blank",rel:"noreferrer",children:at.license}):at.license]}),at.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(al,{text:at.note,convert:_})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(ir,{text:Pi,mode:M.readingMode,tables:Od,gujiMarkdown:so(ie),properNames:M.properNames})})]}),!B&&!ce&&!Xt&&Pi==null&&fe&&t.jsx("div",{className:"bim-rd-state",children:$("reader.chapterFailed")}),ie.references&&ie.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:$("reader.references")}),t.jsx("ol",{children:ie.references.map((W,he)=>t.jsxs("li",{children:[W.url?t.jsx("a",{className:"bim-rd-link",href:W.url,target:"_blank",rel:"noopener noreferrer",children:_(W.title)}):t.jsx("span",{children:_(W.title)}),W.author&&t.jsxs("span",{children:[",",_(W.author)]}),W.note&&t.jsxs("span",{children:["。",_(W.note)]})]},he))})]})]})};function Ng(e,n,o,r){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 r(s?`${s}冊`:`${o}${e.n}`)}function Eg(e,n){if(!n)return;const o=r=>{var s;for(const a of r??[]){const l=o(a.children);if(l)return l;if((s=a.files)!=null&&s.includes(n))return a.label}};return o(e.juan_groups)}function Ig(e,n,o){const[r,s]=g.useState({entryTitle:void 0,authors:[]});return g.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let a=!1;return Promise.resolve(n.getItem(e)).then(l=>{if(a||!l)return;const d=(l.authors??[]).filter(c=>c&&c.name);s({entryTitle:o&&typeof l.title=="string"?l.title:void 0,authors:d})}).catch(()=>{}),()=>{a=!0}},[e,n,o]),r}const pc={bug:{key:"bug",color:i("danger")},resource:{key:"resource",color:i("primary")},suggestion:{key:"suggestion",color:i("primary")},other:{key:"other",color:i("desc-fg")}},Rg=pc.other,uc={pending:{key:"pending",color:i("warning")},in_progress:{key:"in_progress",color:i("primary")},resolved:{key:"resolved",color:i("success")},wontfix:{key:"wontfix",color:i("desc-fg")},duplicate:{key:"duplicate",color:i("desc-fg")}},Lg=uc.pending;function Ag(e){try{const n=new Date(e),o=r=>String(r).padStart(2,"0");return`${n.getFullYear()}-${o(n.getMonth()+1)}-${o(n.getDate())} ${o(n.getHours())}:${o(n.getMinutes())}`}catch{return e}}function Pg(e,n){if(!e)return!1;try{const o=new URL(e,n);if(o.protocol!=="http:"&&o.protocol!=="https:")return!1;const r=new URL(n);return o.hostname===r.hostname}catch{return!1}}const br=({items:e,loading:n})=>{const o=Xe(),{t:r,convert:s}=Q();return n?t.jsx(Yt,{}):e.length===0?t.jsx("div",{style:Mg,children:r("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=pc[a.type]||Rg,d=uc[a.status]||Lg,c=typeof window<"u"&&Pg(a.pageUrl,window.location.href);return t.jsxs("div",{style:Bg,children:[t.jsxs("div",{style:Wg,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...Ms,background:l.color},children:r(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...Ms,background:d.color},children:r(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:Og,children:Ag(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:Hg,children:[a.resourceId&&t.jsx("a",{href:o(a.resourceId),style:qi,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:qi,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:qi,children:a.pageUrl}))]}),t.jsx("div",{style:Fg,children:s(a.content)}),a.reply&&t.jsxs("div",{style:Dg,children:[t.jsx("div",{style:Ug,children:r("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},Mg={textAlign:"center",padding:"40px 0",color:i("desc-fg"),fontSize:"14px"},Bg={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"16px"},Wg={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},Ms={fontSize:"12px",color:i("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},Og={fontSize:"12px",color:i("desc-fg")},Hg={fontSize:"12px",marginBottom:"6px"},qi={color:i("primary"),textDecoration:"none",borderBottom:`1px dashed ${i("primary")}`},Fg={fontSize:"14px",lineHeight:"1.6",color:i("fg"),whiteSpace:"pre-wrap"},Dg={marginTop:"12px",padding:"10px 12px",background:i("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:i("fg")},Ug={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:i("primary")},vo=({transport:e,onNavigate:n,recommendedIds:o,activeTab:r,onTabChange:s,feedbackApiUrl:a})=>{const l=$e(),[d,c]=g.useState(null),[p,u]=g.useState([]),[m,h]=g.useState("recommend"),[f,x]=g.useState([]),[k,y]=g.useState(!1),w=r??m,b=O=>{h(O),s==null||s(O)},[j,S]=g.useState(!0),[v,$]=g.useState(null),[_,C]=g.useState(null),[M,T]=g.useState(null);g.useEffect(()=>{let O=!1;if(e.getCounts)return e.getCounts().then(I=>{O||c({works:I.works,books:I.books,collections:I.collections})}).catch(()=>{}),()=>{O=!0}},[e]),g.useEffect(()=>{let O=!1;return(async()=>{if(o)return o;if(e.getRecommended)try{const P=await e.getRecommended();if(P!=null&&P.groups)return P.groups.flatMap(U=>U.items.map(K=>({...K,group:U.name})))}catch{}return[]})().then(async P=>{if(O)return;const U=P.filter(L=>L.id);if(U.length===0){S(!1);return}const K=await Promise.all(U.map(async L=>{if(L.type)return{id:L.id,title:L.title,type:L.type,author:L.author,dynasty:L.dynasty,role:L.role,edition:L.edition,has_text:L.has_text,has_image:L.has_image,has_collated:L.has_collated,subtype:L.subtype,primary_name:L.primary_name,group:L.group,fallbackDescription:L.description};try{let Z=null;if(e.getEntry)Z=await e.getEntry(L.id);else{const A=await e.getItem(L.id);A&&(Z={id:L.id,title:A.title||L.id,type:A.type||"work"})}if(Z)return{...Z,group:L.group,fallbackDescription:L.description}}catch{}return{id:L.id,title:L.title,type:we.extractType(L.id),group:L.group,fallbackDescription:L.description}}));O||(u(K.filter(L=>L!==null)),S(!1))}),()=>{O=!0}},[e,o]);const z=g.useRef(!1),F=g.useRef(!1),N=g.useRef(!1);g.useEffect(()=>{if(w!=="catalog"||z.current)return;const O=e.getCatalogProgress??e.getResourceProgress;if(!O)return;z.current=!0;let I=!1;return O.call(e).then(P=>{I||$(P)}).catch(()=>{z.current=!1}),()=>{I=!0}},[e,w]),g.useEffect(()=>{if(w!=="collection"||F.current||!e.getCollectionProgress)return;F.current=!0;let O=!1;return e.getCollectionProgress().then(I=>{O||C(I)}).catch(()=>{F.current=!1}),()=>{O=!0}},[e,w]),g.useEffect(()=>{if(w!=="site"||N.current||!e.getSiteProgress)return;N.current=!0;let O=!1;return e.getSiteProgress().then(I=>{O||T(I)}).catch(()=>{N.current=!1}),()=>{O=!0}},[e,w]),g.useEffect(()=>{if(!a||w!=="feedback")return;let O=!1;return y(!0),fetch(a).then(I=>I.json()).then(I=>{!O&&I.success&&x(I.items||[])}).catch(()=>{}).finally(()=>{O||y(!1)}),()=>{O=!0}},[a,w]);const R=O=>t.jsx(un,{type:O,size:12});return t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:i("fg")},children:t.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[t.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"16px"},children:[t.jsx(kn,{label:l.home.recommendTab,active:w==="recommend",onClick:()=>b("recommend")}),t.jsx(kn,{label:l.home.catalogTab,active:w==="catalog",onClick:()=>b("catalog")}),t.jsx(kn,{label:l.home.collectionTab,active:w==="collection",onClick:()=>b("collection")}),t.jsx(kn,{label:l.home.siteTab,active:w==="site",onClick:()=>b("site")}),a&&t.jsx(kn,{label:l.home.feedbackTab,active:w==="feedback",onClick:()=>b("feedback")})]}),w==="recommend"&&t.jsx(Vg,{recommended:p,loading:j,onNavigate:n,getIcon:R,t:l}),w==="catalog"&&t.jsx(Bs,{progress:v,t:l,onNavigate:n}),w==="collection"&&t.jsx(Bs,{progress:_,t:l,onNavigate:n}),w==="site"&&t.jsx(Yg,{progress:M,t:l,totalWorks:(d==null?void 0:d.works)??0}),w==="feedback"&&a&&t.jsx(br,{items:f,loading:k})]})})},kn=({label:e,active:n,onClick:o})=>t.jsx("button",{onClick:o,style:{padding:"8px 16px",fontSize:"14px",fontWeight:n?600:400,color:i(n?"primary":"desc-fg"),background:"none",border:"none",borderBottom:n?`2px solid ${i("primary")}`:"2px solid transparent",cursor:"pointer",marginBottom:"-1px"},children:e}),Vg=({recommended:e,loading:n,onNavigate:o,getIcon:r,t:s})=>{const a=Xe();if(n)return t.jsx(Yt,{});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:i("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 u=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(),o==null||o(p.id))},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,cursor:"pointer",background:i("input-bg"),textDecoration:"none",color:"inherit"},children:[t.jsx("span",{style:{fontSize:"20px"},children:r(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:i("desc-fg"),marginLeft:"4px"},children:p.edition})]}),u&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u})]})]},p.id)})})]},d))})},Bs=({progress:e,t:n,onNavigate:o})=>{if(!e)return t.jsx(Yt,{});const r=[...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:i("progress-active"),done:i("progress-done"),todo:i("progress-todo")};return t.jsx("div",{children:s.map(d=>{const c=r.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:i("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(Gg,{item:p,t:n,statusColor:l[d],onNavigate:o},p.id))})]},d)})})},Gg=({item:e,t:n,statusColor:o,onNavigate:r})=>{const s=Xe(),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 ${i("widget-border")}`,background:i("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&&r?t.jsx("a",{href:s(c),onClick:p=>{p.metaKey||p.ctrlKey||(p.preventDefault(),r(c))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${i("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:i("widget-border"),color:i("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:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.total>0?pt(n.home.progressFormat,{imported:String(e.imported),total:String(e.total)}):n.home.totalPending})]}),e.total>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${a}%`,borderRadius:"2px",background:o,transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:e.description})]})},Yg=({progress:e,t:n,totalWorks:o})=>{if(!e)return t.jsx(Yt,{});const r=[...e.resources].sort((c,p)=>c.priority-p.priority),s=r.filter(c=>c.imported>0),a=r.filter(c=>c.imported===0),l=s.reduce((c,p)=>Math.max(c,p.imported),0),d=o>0?Math.round(l/o*100):0;return t.jsxs("div",{children:[o>0&&t.jsxs("div",{style:{padding:"12px 16px",marginBottom:"16px",borderRadius:"8px",background:`color-mix(in srgb, ${i("primary")} 6%, transparent)`,fontSize:"13px",color:i("fg")},children:[n.home.siteCoverage,": ",t.jsx("strong",{children:l.toLocaleString()})," / ",o.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:i("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-done")}}),n.home.statusInProgress," (",s.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(c=>t.jsx(Ws,{item:c,t:n,totalWorks:o},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:i("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-todo")}}),n.home.statusTodo," (",a.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:a.map(c=>t.jsx(Ws,{item:c,t:n,totalWorks:o},c.id))})]})]})},Ws=({item:e,t:n,totalWorks:o})=>{const r=o>0?Math.round(e.imported/o*100):0;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("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:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.imported>0?`${e.imported.toLocaleString()} ${n.indexType.work} (${r}%)`:n.home.statusTodo})]}),e.imported>0&&o>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${r}%`,borderRadius:"2px",background:i("progress-done"),transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:e.description})]})},Os="(max-width: 768px)";function Kg(){const[e,n]=g.useState(()=>typeof window>"u"?!1:window.matchMedia(Os).matches);return g.useEffect(()=>{const o=window.matchMedia(Os),r=s=>n(s.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[]),e}const qg=({transport:e,hideModeIndicator:n=!0,onEntryClick:o,recommendedIds:r,headerRight:s})=>{var F;const a=$e(),{convert:l}=Ie(),d=Kg(),[c,p]=g.useState(null),[u,m]=g.useState(null),[h,f]=g.useState(!1),[x,k]=g.useState("detail"),[y,w]=g.useState([]),[b,j]=g.useState(!1),S=g.useCallback(async N=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){w([]);return}j(!0);try{if(e.getCollectionCatalogs){const R=await e.getCollectionCatalogs(N);w(R||[])}else if(e.getCollectionCatalog){const R=await e.getCollectionCatalog(N);w(R?[{resource_id:"",data:R}]:[])}}catch{w([])}finally{j(!1)}},[e]),v=g.useCallback(async N=>{if(o){o(N);return}p(N),m(null),w([]),k("detail"),f(!0);try{const R=await e.getItem(N.id);R&&(m(R),R.type==="collection"&&S(N.id))}catch(R){console.error("加载详情失败:",R)}finally{f(!1)}},[e,o,S]),$=g.useCallback(async N=>{m(null),w([]),k("detail"),f(!0);try{const R=await e.getItem(N);R&&(m(R),p({id:N,title:R.title||N,type:R.type||"book"}),R.type==="collection"&&S(N))}catch(R){console.error("导航失败:",R)}finally{f(!1)}},[e,S]),_=typeof(u==null?void 0:u.text_count)=="number"&&u.text_count>0,C=(u==null?void 0:u.type)==="collection"&&(y.length>0||b)||(u==null?void 0:u.type)==="work"&&_,M=d&&(h||u),T=g.useCallback(()=>{p(null),m(null),w([]),k("detail")},[]),z=t.jsx(t.Fragment,{children:h?t.jsx(Yt,{}):u?t.jsxs(t.Fragment,{children:[(C||s)&&t.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${i("widget-border")}`,padding:d?"0 12px":"0 48px",background:i("input-bg"),flexShrink:0,overflowX:d?"auto":void 0},children:[C&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>k("detail"),style:Zn(x==="detail"),children:a.detailTab.basicInfo}),u.type==="collection"&&b&&y.length===0&&t.jsxs("button",{onClick:()=>{},style:Zn(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),u.type==="collection"&&y.map(N=>t.jsx("button",{onClick:()=>k(`catalog:${N.resource_id}`),style:Zn(x===`catalog:${N.resource_id}`),children:N.short_name?`${l(N.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},N.resource_id)),u.type==="work"&&_&&t.jsx("button",{onClick:()=>k("collated"),style:Zn(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(Bo,{data:u,transport:e,onNavigate:$}):x.startsWith("catalog:")?t.jsx(Wo,{data:(F=y.find(N=>`catalog:${N.resource_id}`===x))==null?void 0:F.data,onNavigate:$}):x==="collated"?t.jsx(xr,{id:u.id,transport:e,onNavigate:$}):null})]}):t.jsx(vo,{transport:e,onNavigate:$,recommendedIds:r})});return d?t.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:i("bg"),color:i("fg")},children:M?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${i("widget-border")}`,background:i("input-bg"),flexShrink:0},children:t.jsxs("button",{onClick:T,style:{padding:"4px 12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px"},children:["← ",a.detailTab.basicInfo]})}),t.jsx("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:z})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(ro,{transport:e,onEntryClick:v,hideModeIndicator:n}),!u&&t.jsx(vo,{transport:e,onNavigate:$,recommendedIds:r})]})}):t.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:i("bg"),color:i("fg")},children:[t.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:`1px solid ${i("widget-border")}`,display:"flex",flexDirection:"column",background:i("input-bg"),overflow:"hidden"},children:t.jsx("div",{style:{flex:1,overflow:"auto"},children:t.jsx(ro,{transport:e,onEntryClick:v,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:i("bg"),display:"flex",flexDirection:"column"},children:z})]})};function Zn(e){return{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(e?"primary":"desc-fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}const Xg=({pageData:e,rawImageUrl:n="",punctuations:o=[],title:r,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=g.useState(new Set),[u,m]=g.useState(null),[h,f]=g.useState("horizontal"),[x,k]=g.useState(!0),y=g.useRef(null),w=g.useCallback(v=>{p(new Set(v))},[]),b=g.useCallback(v=>{if(p($=>{const _=new Set($);return _.has(v)?_.delete(v):(_.clear(),_.add(v)),_}),y.current){const $=y.current.querySelector(`[data-char-id="${v}"]`);$&&$.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),j=()=>{var v;p(new Set),window.getSelection&&((v=window.getSelection())==null||v.removeAllRanges())},S=o.length>0?o: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:r||e.title}),s&&t.jsx("span",{style:{fontSize:"0.85rem",color:i("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:i("body-fg")},children:["已选字数: ",t.jsx("strong",{style:{color:i("accent")},children:c.size})]}),c.size>0&&t.jsx("button",{type:"button",onClick:j,className:"guji-reader-btn",children:"清除选中"}),t.jsx("button",{type:"button",onClick:()=>k(v=>!v),className:`guji-reader-btn ${x?"active":""}`,title:"独立外挂标点 (guji-punct v0.1)",children:x?"✓ 标点":"底本文本"}),t.jsx("button",{type:"button",onClick:()=>f(v=>v==="horizontal"?"vertical":"horizontal"),className:"guji-reader-btn primary",children:h==="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(dr,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:u,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:h==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(gr,{pageData:e,punctuations:S,selectedCharIds:c,hoveredCharId:u,onSelectionChange:w,onCharClick:b,onCharHover:m,mode:h,showPunctuation:x})]})]})]})},Zg=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function Qt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Jg(e){var r,s,a,l,d,c;const n=e&&typeof e=="object"?e.pages:void 0;if(!Array.isArray(n))return[];const o=[];for(const p of n){if(!p||typeof p!="object")continue;const u=p,m=Qt((r=u.page)==null?void 0:r.index),h=Array.isArray(u.cells)?u.cells:[];if(m===void 0||h.length===0)continue;const f=new Map;for(const x of h){if(!x||typeof x!="object")continue;const k=x,y=Zg.exec(String(k.a??""));if(!y||typeof k.c!="string")continue;const w=parseInt(y[2],10),b=parseInt(y[3],10),j=Array.isArray(k.box)&&k.box.length===4&&k.box.every($=>Qt($)!==void 0)?k.box:null,S={id:String(k.a),char:k.c,slot:b,pos:b,sub:y[4]||null,bbox:j?[j[0],j[1],j[0]+j[2],j[1]+j[3]]:null};let v=f.get(w);v||f.set(w,v=[]),v.push(S)}o.push({page:m,seq:String(((s=u.canvas)==null?void 0:s.seq)??""),width:Qt((a=u.canvas)==null?void 0:a.width)??Qt((l=u.image)==null?void 0:l.width)??0,height:Qt((d=u.canvas)==null?void 0:d.height)??Qt((c=u.image)==null?void 0:c.height)??0,columns:Array.from(f.entries()).sort((x,k)=>x[0]-k[0]).map(([x,k])=>({col:x,chars:k}))})}return o}function Qg(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.punctuations)?e.punctuations:[],o=[];for(const r of n){if(!r||typeof r!="object")continue;const s=r;typeof s.anchor!="string"||typeof s.mark!="string"||o.push({id:typeof s.id=="string"?s.id:void 0,anchor:s.anchor,mark:s.mark,kind:s.kind,pos:s.pos,pre_char:s.pre_char})}return o}function ef(e){var o;const n=e&&typeof e=="object"?e.pages:void 0;if(!Array.isArray(n))return null;for(const r of n){const s=/\/iiif\/([^/]+)\/canvas\/([^/]+)\//.exec(String(((o=r==null?void 0:r.canvas)==null?void 0:o.id)??""));if(s)return{bookId:s[1],vol:s[2]}}return null}const tf=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function mt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Hs(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(o=>!!o&&typeof o=="object"):[]}function nf(e,n){var l,d,c,p,u,m,h,f,x,k;const o=new Map,r=new Map;for(const y of Hs(n)){const w=mt(y.page);if(w!==void 0){o.set(w,y);for(const b of Array.isArray(y.cells)?y.cells:[]){const j=b==null?void 0:b.box;typeof(b==null?void 0:b.a)=="string"&&Array.isArray(j)&&j.length===4&&j.every(S=>mt(S)!==void 0)&&r.set(b.a,[j[0],j[1],j[0]+j[2],j[1]+j[3]])}}}const s=[];for(const y of Hs(e)){const w=mt(y.page);if(w===void 0)continue;const b=[];for(const S of Array.isArray(y.columns)?y.columns:[]){const v=mt(S==null?void 0:S.col);if(v===void 0)continue;const $=[];for(const _ of Array.isArray(S.cells)?S.cells:[]){const C=tf.exec(String((_==null?void 0:_.a)??""));if(!C||typeof _.c!="string")continue;const M=parseInt(C[3],10);$.push({id:_.a,char:_.c,slot:M,pos:M,sub:C[4]||null,bbox:r.get(_.a)??null})}$.length>0&&b.push({col:v,chars:$})}if(b.length===0)continue;b.sort((S,v)=>S.col-v.col);const j=o.get(w);s.push({page:w,seq:String(((l=j==null?void 0:j.canvas)==null?void 0:l.seq)??""),width:mt((d=j==null?void 0:j.canvas)==null?void 0:d.width)??mt((c=j==null?void 0:j.image)==null?void 0:c.width)??0,height:mt((p=j==null?void 0:j.canvas)==null?void 0:p.height)??mt((u=j==null?void 0:j.image)==null?void 0:u.height)??0,columns:b})}const a=new Set(s.map(y=>y.page));for(const[y,w]of o){const b=(m=w==null?void 0:w.canvas)==null?void 0:m.seq;a.has(y)||typeof b!="string"&&typeof b!="number"||String(b)===""||s.push({page:y,seq:String(b),width:mt((h=w.canvas)==null?void 0:h.width)??mt((f=w.image)==null?void 0:f.width)??0,height:mt((x=w.canvas)==null?void 0:x.height)??mt((k=w.image)==null?void 0:k.height)??0,columns:[]})}return s.sort((y,w)=>y.page-w.page)}const of=({data:e,onNavigate:n,className:o,style:r})=>{var u;const{t:s,convert:a}=Q(),[l,d]=g.useState(((u=e.divisions[0])==null?void 0:u.name)??null),[c,p]=g.useState(null);return t.jsxs("div",{className:o,style:r,children:[t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:a(e.title)}),e.stats&&t.jsxs("div",{style:{fontSize:"13px",color:i("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(rf,{division:m,expanded:l===m.name,onToggle:()=>d(l===m.name?null:m.name),expandedCat:c,onCatToggle:h=>p(c===h?null:h),onNavigate:n},m.name))})]})},rf=({division:e,expanded:n,onToggle:o,expandedCat:r,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=Q(),c=e.categories.reduce((p,u)=>{const m=u.stats||{zhulu:0,cunmu:0};return p+(m.zhulu||0)+(m.cunmu||0)},0);return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("button",{onClick:o,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:"none",background:n?`color-mix(in srgb, ${i("primary")} 6%, transparent)`:i("bg"),cursor:"pointer",fontSize:"15px",fontWeight:600,color:i("fg"),textAlign:"left"},children:[t.jsx("span",{children:d(e.name)}),t.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:i("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 u=`${e.name}/${p.name}`;return t.jsx(sf,{category:p,expanded:r===u,onToggle:()=>s(u),onNavigate:a},p.name)})})]})},sf=({category:e,expanded:n,onToggle:o,onNavigate:r})=>{var p,u,m,h;const{t:s,convert:a}=Q(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((u=e.books)==null?void 0:u.cunmu)||[],c=(((m=e.stats)==null?void 0:m.zhulu)||l.length)+(((h=e.stats)==null?void 0:h.cunmu)||d.length);return t.jsxs("div",{children:[t.jsxs("button",{onClick:o,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px 6px 28px",border:"none",background:n?i("input-bg"):"transparent",cursor:"pointer",fontSize:"13px",color:i("fg"),textAlign:"left"},children:[t.jsxs("span",{style:{fontWeight:500},children:[a(e.name),e.volumes&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:a(e.volumes)})})]}),t.jsxs("span",{style:{fontSize:"11px",color:i("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(Fs,{label:s("catalogPage.zhulu"),books:l,onNavigate:r}),d.length>0&&t.jsx(Fs,{label:s("catalogPage.cunmu"),books:d,onNavigate:r})]})]})},Fs=({label:e,books:n,onNavigate:o})=>{const{t:r,convert:s}=Q(),a=Xe(),[l,d]=g.useState(n.length<=20),c=l?n:n.slice(0,10);return t.jsxs("div",{style:{marginBottom:"8px"},children:[t.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:[e," (",n.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((p,u)=>t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[t.jsx("span",{style:{fontWeight:500,color:i("fg")},children:p.work_id&&o?t.jsx("a",{href:a(p.work_id),onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),o(p.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`},children:s(p.title)}):s(p.title)}),p.volumes&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(p.volumes)}),p.author&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(p.author).slice(0,20)})]},u))}),!l&&t.jsx("button",{onClick:()=>d(!0),style:{marginTop:"4px",padding:"2px 12px",fontSize:"11px",color:i("primary"),background:"transparent",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:r("catalogPage.expandAllN",{n:n.length})})]})},xt=({title:e,onSave:n,onAskAI:o,extraButtons:r,children:s})=>{const a=$e();return t.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("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 ${i("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:i("fg")},children:e}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[r,o&&t.jsx("button",{onClick:o,style:lf,children:"AI"}),n&&t.jsx("button",{onClick:n,style:af,children:a.action.save})]})]}),s]})},af={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},lf={padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},dt=({label:e,value:n,onChange:o,placeholder:r,disabled:s})=>t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:{display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:e}),t.jsx("input",{type:"text",value:n,onChange:a=>o(a.target.value),placeholder:r,disabled:s,style:{width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]}),Ut=({value:e,onChange:n,placeholder:o})=>{const r=g.useRef(null);return g.useEffect(()=>{r.current&&(r.current.style.height="auto",r.current.style.height=`${r.current.scrollHeight}px`)},[e]),t.jsx("textarea",{ref:r,value:e||"",onChange:s=>n(s.target.value),placeholder:o,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},li=({children:e,color:n,style:o})=>t.jsx("span",{style:{display:"inline-block",padding:"2px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",background:n||i("primary-soft"),color:i(n?"on-color-fg":"fg"),...o},children:e});function cf(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const ti=({value:e,onChange:n,label:o})=>{const[r,s]=g.useState(!1),a=g.useRef(null),l=cf(e||"");return g.useEffect(()=>{r&&a.current&&a.current.focus()},[r]),!r&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Ds,children:o}),t.jsxs("div",{onClick:()=>s(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:`1px solid ${i("input-border")}`,borderRadius:"2px",background:i("input-bg"),cursor:"pointer",minHeight:"30px"},children:[t.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:i("fg")},children:l.name}),t.jsx(li,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Ds,children:o}),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:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},Ds={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500};function df(e){switch(e){case"url":return i("source-url");case"bookID":return i("source-bookid");default:return i("desc-fg")}}function pf(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const mc=({items:e,onChange:n,onOpenEntityPicker:o})=>{const r=$e(),[s,a]=g.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=m=>{n(e.filter((h,f)=>f!==m)),s===m&&a(null)},c=(m,h,f)=>{const x=[...e];x[m]={...x[m],[h]:f},n(x)},p=(m,h)=>{const f=[...e];f[m]={...f[m],type:h,id:"",name:""},n(f),h==="bookID"&&o&&o(x=>{const k=[...e];k[m]={...k[m],id:x.id,name:x.title,type:"bookID"},n(k)})},u=m=>{o&&o(h=>{const f=[...e];f[m]={...f[m],id:h.id,name:h.title,type:"bookID"},n(f)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((m,h)=>t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>a(s===h?null:h),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===h?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:i("fg")},children:m.name||`${r.editor.sourcePlaceholder} ${h+1}`}),m.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:df(m.type),color:i("on-color-fg"),borderRadius:"3px",fontWeight:500},children:pf(m.type)}),t.jsx("button",{onClick:f=>{f.stopPropagation(),d(h)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:r.editor.deleteThisSource,children:"✕"})]}),s===h&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!m.type&&t.jsxs("div",{children:[t.jsx("label",{style:wt,children:r.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(h,"bookID"),style:{...Us,borderColor:i("source-bookid"),color:i("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:r.editor.fromExistingBook})]}),t.jsxs("button",{onClick:()=>p(h,"url"),style:{...Us,borderColor:i("source-url"),color:i("source-url")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),t.jsx("span",{children:"URL"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.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:wt,children:r.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const f=[...e];f[h]={...f[h],type:"",id:"",name:""},n(f)},style:Vs,children:r.action.changeType})]}),m.id&&m.name?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:i("bg"),border:`1px solid ${i("source-bookid")}`,borderRadius:"6px"},children:[t.jsx("span",{style:{color:i("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:i("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:m.id})]}),t.jsx("button",{onClick:()=>u(h),style:{background:"transparent",border:`1px solid ${i("widget-border")}`,color:i("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:r.action.reselect})]}):t.jsxs("button",{onClick:()=>u(h),style:{width:"100%",padding:"14px",border:`2px dashed ${i("widget-border")}`,borderRadius:"6px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[t.jsx("span",{children:"🔍"}),t.jsx("span",{children:r.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:wt,children:r.label.sourceName}),t.jsx("button",{onClick:()=>{const f=[...e];f[h]={...f[h],type:"",id:"",name:""},n(f)},style:Vs,children:r.action.changeType})]}),t.jsx("input",{type:"text",value:m.name,onChange:f=>c(h,"name",f.target.value),placeholder:r.editor.sourceNamePlaceholder,style:en})]}),t.jsxs("div",{children:[t.jsx("label",{style:wt,children:r.label.urlAddress}),t.jsx("input",{type:"text",value:m.id,onChange:f=>c(h,"id",f.target.value),placeholder:"https://...",style:en})]})]}),m.type&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{borderTop:`1px dashed ${i("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:t.jsx("label",{style:{...wt,opacity:.7},children:r.label.optionalInfo})}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:wt,children:r.label.detailsOptional}),t.jsx("input",{type:"text",value:m.details,onChange:f=>c(h,"details",f.target.value),placeholder:r.editor.detailsPlaceholder,style:en})]}),t.jsxs("div",{children:[t.jsx("label",{style:wt,children:r.label.positionOptional}),t.jsx("input",{type:"text",value:m.position,onChange:f=>c(h,"position",f.target.value),placeholder:"如: 卷三, p.52",style:en})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:wt,children:r.label.dataVersionOptional}),t.jsx("input",{type:"text",value:m.version,onChange:f=>c(h,"version",f.target.value),placeholder:"如: v1.0, 2024-01",style:en})]}),t.jsxs("div",{children:[t.jsx("label",{style:wt,children:r.label.processorVersionOptional}),t.jsx("input",{type:"text",value:m.processor_version,onChange:f=>c(h,"processor_version",f.target.value),placeholder:"如: v0.1",style:en})]})]})]})]})})]},h)),t.jsxs("button",{onClick:l,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:r.action.addSource})]})]})},wt={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},en={width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},Us={flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",padding:"16px 12px",background:i("bg"),border:"2px solid",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:500,transition:"all 0.2s"},Vs={background:"transparent",border:"none",color:i("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function hc(e){if(!e||!e.trim())return[];try{const n=JSON.parse(e);if(Array.isArray(n))return n.map(o=>({id:o.id||"",name:o.name||"",type:o.type||"",details:o.details||"",position:o.position||"",version:o.version||"",processor_version:o.processor_version||""}))}catch{}return[]}function gc(e){return!e||e.length===0?"":JSON.stringify(e)}const fc=({entityType:e,entityId:n,entityTitle:o,parentWork:r,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:u,onLinkEntity:m,onUnlinkEntity:h,onViewEntity:f,onCreateAndLink:x,onSaveRelations:k})=>{const y=$e();return t.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:"🔗"}),t.jsx("span",{children:y.section.relations})]}),k&&t.jsx("button",{onClick:k,style:uf,children:y.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(wn,{direction:"up",title:y.relation.belongsToWork,entity:a,onView:f,onUnlink:()=>h("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(wn,{direction:"up",title:y.relation.containedInCollection,entity:l,onView:f,onUnlink:()=>h("collectionId"),onLink:()=>m("collectionId","collection"),onCreate:()=>x("collectionId","collection",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),a&&u&&u.length>0&&t.jsx(tn,{direction:"horizontal",title:`${y.relation.siblingVersions} (${u.length})`,entities:u,onView:f,onAdd:()=>x("siblingBook","book",{workId:a.id}),addLabel:y.relation.addVersionForWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="work"&&t.jsxs(t.Fragment,{children:[t.jsx(wn,{direction:"up",title:y.relation.parentWork,entity:r,onView:f,onUnlink:()=>h("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(tn,{direction:"down",title:`${y.relation.childWorks} (${d.length})`,entities:d,onView:f,onAdd:()=>x("childWork","work",{parentWorkId:n}),addLabel:y.action.addSubWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),c&&c.length>0&&t.jsx(tn,{direction:"down",title:`${y.relation.collectionImpl} (${c.length})`,entities:c,onView:f,onAdd:()=>x("childCollection","collection",{workId:n}),addLabel:y.action.addCollectionImpl,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(tn,{direction:"down",title:`${y.relation.allVersions} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{workId:n}),addLabel:y.action.addVersion,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="collection"&&t.jsxs(t.Fragment,{children:[t.jsx(wn,{direction:"up",title:y.relation.correspondingWork,entity:a,onView:f,onUnlink:()=>h("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(wn,{direction:"up",title:y.relation.parentCollection,entity:s,onView:f,onUnlink:()=>h("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(tn,{direction:"down",title:`${y.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:f,onAdd:()=>x("childCollection","collection",{parentCollectionId:n}),addLabel:y.action.addSubCollection,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(tn,{direction:"down",title:`${y.relation.containedBooks} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{collectionId:n}),addLabel:y.action.addBook,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]})]})]})},wn=({direction:e,title:n,entity:o,onView:r,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:u,unlinkLabel:m})=>{const h=i(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),f=e==="up"?"⬆️":e==="down"?"⬇️":"↔️";return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("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:f}),t.jsx("span",{children:n})]}),o?t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:i("bg"),borderRadius:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:xc(o.type)}),t.jsx("span",{style:{fontWeight:500},children:o.title}),t.jsx("span",{style:{fontSize:"11px",opacity:.6},children:o.id})]}),t.jsxs("div",{style:{display:"flex",gap:"4px"},children:[t.jsx(Gs,{onClick:()=>r(o),title:u,children:"👁️"}),t.jsx(Gs,{onClick:s,title:m,danger:!0,children:"✕"})]})]}):t.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:p}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsx(ko,{onClick:a,children:d}),t.jsx(ko,{onClick:l,primary:!0,children:c})]})]})},tn=({direction:e,title:n,entities:o,onView:r,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=g.useState(!1),u=i(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),m=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",h=c?o:o.slice(0,5);return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("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:m}),t.jsx("span",{children:n})]}),o.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[h.map(f=>t.jsxs("div",{onClick:()=>r(f),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:i("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[t.jsx("span",{children:xc(f.type)}),t.jsx("span",{children:f.title})]},f.id)),o.length>5&&!c&&t.jsxs("div",{onClick:()=>p(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:i("link-fg"),cursor:"pointer"},children:[d," (",o.length-5,")"]})]}):t.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:l}),t.jsx("div",{style:{marginTop:"8px"},children:t.jsxs(ko,{onClick:s,primary:!0,children:["+ ",a]})})]})},Gs=({onClick:e,title:n,danger:o,children:r})=>t.jsx("button",{onClick:s=>{s.stopPropagation(),e()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:o?i("danger"):"inherit",opacity:.7},children:r}),ko=({onClick:e,primary:n,children:o})=>t.jsx("button",{onClick:e,style:{padding:"4px 10px",fontSize:"11px",border:n?"none":`1px solid ${i("widget-border")}`,borderRadius:"4px",background:n?i("primary"):"transparent",color:n?i("primary-fg"):"inherit",cursor:"pointer"},children:o});function xc(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const uf={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},bc=({isOpen:e,entityType:n,title:o,onSelect:r,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[u,m]=g.useState(""),h=p?l.filter(y=>y.id!==p):l;g.useEffect(()=>{e&&(m(""),d(""))},[e]);const f=y=>{m(y),d(y)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",k=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:mf,children:t.jsxs("div",{style:hf,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:o}),t.jsx("button",{onClick:s,style:gf,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:u,onChange:y=>f(y.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:ff})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:Xi,children:"搜索中..."}):h.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:h.map(y=>t.jsxs("div",{onClick:()=>r(y),style:xf,children:[t.jsx("span",{style:{fontSize:"16px"},children:k}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[y.title,y.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:y.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[y.id,y.author&&` · ${y.author}`,y.dynasty&&` · ${y.dynasty}`]})]})]},y.id))}):u?t.jsxs("div",{style:Xi,children:["未找到匹配的",x]}):t.jsxs("div",{style:Xi,children:["输入关键词搜索",x]})}),t.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsxs("button",{onClick:a,style:bf,children:["创建新",x,"并关联"]})]})]})})},mf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},hf={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",width:"500px",maxWidth:"calc(100vw - 32px)",maxHeight:"70vh",display:"flex",flexDirection:"column",boxShadow:i("shadow-dialog")},gf={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},ff={width:"100%",padding:"10px 12px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"},xf={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:i("primary-soft")},Xi={padding:"20px",textAlign:"center",color:i("desc-fg")},bf={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Ys={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},yf={work:"📜",book:"📖",collection:"📚",entity:"👤"},yc=({isOpen:e,entityType:n,relationField:o,inheritData:r,onConfirm:s,onCancel:a})=>{const[l,d]=g.useState(""),c=g.useRef(null);g.useEffect(()=>{e&&(d((r==null?void 0:r.title)||""),setTimeout(()=>{var h,f;(h=c.current)==null||h.focus(),(f=c.current)==null||f.select()},100))},[e,r==null?void 0:r.title]);const p=h=>{h.key==="Enter"&&l.trim()?u():h.key==="Escape"&&a()},u=()=>{l.trim()&&s(l.trim(),{...r,title:l.trim()})};if(!e)return null;const m=()=>{switch(o){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`创建新${Ys[n]}`}};return t.jsx("div",{style:jf,onClick:h=>{h.target===h.currentTarget&&a()},children:t.jsxs("div",{style:vf,onClick:h=>h.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:yf[n]}),t.jsx("span",{children:m()})]}),t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:i("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",t.jsx("span",{style:{color:i("danger"),marginLeft:"4px"},children:"*"})]}),t.jsx("input",{ref:c,type:"text",value:l,onChange:h=>d(h.target.value),onKeyDown:p,placeholder:`请输入${Ys[n]}名称...`,style:kf})]}),((r==null?void 0:r.author)||(r==null?void 0:r.dynasty))&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),background:i("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[t.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(r==null?void 0:r.author)&&t.jsxs("div",{children:["作者: ",r.author]}),(r==null?void 0:r.dynasty)&&t.jsxs("div",{children:["朝代/年份: ",r.dynasty]})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[t.jsx("button",{onClick:a,style:wf,children:"取消"}),t.jsx("button",{onClick:u,disabled:!l.trim(),style:{...Sf,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},jf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},vf={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:i("shadow-dialog")},kf={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box"},wf={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},Sf={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg")};function _f(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function jc(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function $f(e){switch(e){case"work":return i("editor-type-work");case"collection":return i("editor-type-collection");case"book":return i("editor-type-book");default:return i("desc-fg")}}const vc=({isOpen:e,title:n,filterType:o="all",recentEntities:r=[],excludeId:s,showCreateButton:a=!1,createButtonText:l,onSelect:d,onCancel:c,onCreate:p,onSearch:u})=>{const[m,h]=g.useState(""),[f,x]=g.useState([]),[k,y]=g.useState(!1),[w,b]=g.useState("recent");g.useEffect(()=>{e&&(h(""),x([]),b(r.length>0?"recent":"search"))},[e,r.length]),g.useEffect(()=>{if(!m.trim()){x([]);return}const C=setTimeout(async()=>{y(!0);try{x(await u(m,o))}catch{x([])}finally{y(!1)}},300);return()=>clearTimeout(C)},[m,o,u]);const j=g.useCallback(C=>{h(C.target.value),C.target.value.trim()&&b("search")},[]),S=g.useCallback(C=>s?C.filter(M=>M.id!==s):C,[s]);if(!e)return null;const v=n||(o==="all"?"选择实体":`选择${jc(o)}`),$=S(r),_=S(f);return t.jsx("div",{style:zf,children:t.jsxs("div",{style:Tf,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:v}),t.jsx("button",{onClick:c,style:Nf,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:j,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Ef}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),k&&t.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),$.length>0&&t.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsxs(Ks,{active:w==="recent",onClick:()=>b("recent"),children:["最近使用 (",$.length,")"]}),t.jsxs(Ks,{active:w==="search",onClick:()=>b("search"),children:["搜索结果 ",_.length>0&&`(${_.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:w==="recent"&&$.length>0?t.jsx(qs,{entities:$,onSelect:d}):m.trim()?k?t.jsx(Zi,{message:"搜索中..."}):_.length>0?t.jsx(qs,{entities:_,onSelect:d}):t.jsx(Zi,{message:"未找到匹配的结果"}):t.jsx(Zi,{message:"输入关键词开始搜索"})}),a&&p&&t.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsx("button",{onClick:p,style:If,children:l||"创建新实体"})]})]})})},Ks=({active:e,onClick:n,children:o})=>t.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(e?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:e?600:400,marginBottom:"-1px"},children:o}),qs=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(o=>t.jsx(Cf,{entity:o,onClick:()=>n(o)},o.id))}),Cf=({entity:e,onClick:n})=>{const[o,r]=g.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:i("primary-soft"),transition:"background 0.1s"},children:[t.jsx("span",{style:{fontSize:"18px"},children:_f(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:i("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:i("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:$f(e.type),color:i("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:jc(e.type)})]})},Zi=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:e}),zf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Tf={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",width:"550px",maxWidth:"calc(100vw - 32px)",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:i("shadow-dialog")},Nf={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Ef={width:"100%",padding:"12px 16px",paddingLeft:"40px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"},If={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Rf={work:i("editor-type-work"),collection:i("editor-type-collection"),book:i("editor-type-book"),entity:i("editor-type-entity")},Lf={work:"📜",collection:"📚",book:"📖",entity:"👤"},kc=({data:e,onChange:n,onSave:o,transport:r,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:u,relations:m,onRelationsChange:h})=>{var Se;const f=$e(),[x,k]=g.useState(!1),[y,w]=g.useState("work"),[b,j]=g.useState(""),[S,v]=g.useState(""),[$,_]=g.useState([]),[C,M]=g.useState(!1),[T,z]=g.useState(!1),[F,N]=g.useState("work"),[R,O]=g.useState(""),[I,P]=g.useState(),[U,K]=g.useState(!1),[L,Z]=g.useState(null),[A,V]=g.useState([]);g.useRef(null);const pe=e.type,ee=pe==="work",ue=pe==="collection",me=pe==="book",be=g.useCallback((X,Ce)=>{n({...e,[X]:Ce})},[e,n]),Oe=g.useCallback((X,Ce)=>{j(X),w(Ce),v(f.editor.selectToLink+f.indexType[Ce]),_([]),k(!0)},[f]),ie=g.useCallback(X=>{r!=null&&r.unlinkEntity&&r.unlinkEntity(e.id,X)},[r,e.id]),Re=g.useCallback(X=>{s==null||s(X.id,X.type)},[s]),Le=g.useCallback((X,Ce,Me)=>{const B={...Me,author:(Me==null?void 0:Me.author)||e.author,dynasty:Me==null?void 0:Me.dynasty};N(Ce),O(X),P(B),z(!0)},[e.author]),q=g.useCallback((X,Ce)=>{r!=null&&r.createAndLink&&r.createAndLink(e.id,R,{type:F,title:X,inheritData:Ce}),z(!1)},[r,e.id,R,F]),J=g.useCallback(X=>{if(!X.trim()){_([]);return}M(!0),r!=null&&r.searchEntities&&r.searchEntities(X,y).then(Ce=>{_(Ce),M(!1)}).catch(()=>{_([]),M(!1)})},[r,y]),fe=g.useCallback(X=>{r!=null&&r.linkEntity&&r.linkEntity(e.id,b,X.id),k(!1)},[r,e.id,b]),ze=g.useCallback(()=>{o()},[o]),Y=g.useCallback(X=>{Z(()=>X),K(!0),r!=null&&r.getRecentEntities&&r.getRecentEntities().then(V).catch(()=>{})},[r]),ve=g.useCallback((X,Ce)=>r!=null&&r.searchEntities?r.searchEntities(X,Ce==="all"?void 0:Ce):Promise.resolve([]),[r]),le=g.useCallback(X=>{r!=null&&r.addRecentEntity&&r.addRecentEntity(X),V(Ce=>[X,...Ce.filter(Me=>Me.id!==X.id)].slice(0,10)),L==null||L(X),K(!1),Z(null)},[r,L]);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 ${i("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:Lf[pe]}),t.jsx("span",{children:e.title||f.editor.untitled}),t.jsx(li,{children:e.id}),t.jsx(li,{color:Rf[pe],children:f.indexType[pe]})]})}),t.jsx(xt,{title:f.section.basicInfo,onSave:o,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(ti,{label:ee?f.editor.workTitle:ue?f.editor.collectionTitle:f.editor.bookTitle,value:e.title,onChange:X=>be("title",X)}),me&&t.jsx(ti,{label:f.editor.belongsToWork,value:e.workName||"",onChange:X=>be("workName",X)}),t.jsx(dt,{label:f.editor.authorLabel,value:e.author||"",onChange:X=>be("author",X)}),t.jsx(dt,{label:f.editor.publicationYearLabel,value:e.publicationYear||"",onChange:X=>be("publicationYear",X)}),(me||ue)&&t.jsx(ti,{label:f.editor.containedIn,value:e.collection||"",onChange:X=>be("collection",X)}),(me||ue)&&t.jsx(dt,{label:f.editor.holderLabel,value:e.holder||"",onChange:X=>be("holder",X)}),(me||ue)&&t.jsx(dt,{label:me?f.editor.pageLabel:f.editor.volumeLabel,value:e.pages||"",onChange:X=>be("pages",X)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(dt,{label:f.editor.firstImageLabel,value:e.firstImage||"",onChange:X=>be("firstImage",X)})})]})}),t.jsx(xt,{title:f.section.description,onSave:o,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(Ut,{value:e.description||"",onChange:X=>be("description",X),placeholder:f.editor.descriptionPlaceholder})}),(((Se=e.additional_works)==null?void 0:Se.length)||0)>0&&t.jsx(xt,{title:f.section.additionalWorks,onSave:o,children:t.jsx(Af,{items:e.additional_works||[],onChange:X=>be("additional_works",X)})}),t.jsx(xt,{title:f.section.indexedBy,onSave:o,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(Pf,{items:e.indexed_by||[],onChange:X=>be("indexed_by",X)})}),t.jsx(xt,{title:f.section.emendatedBy,onSave:o,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(Mf,{items:e.emendated_by||[],onChange:X=>be("emendated_by",X)})}),t.jsx(xt,{title:f.section.textResources,onSave:o,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(io,{items:e.resources||[],onChange:X=>be("resources",X),onDownload:p,downloadStatuses:u,filterType:"text"})}),t.jsx(xt,{title:f.section.imageResources,onSave:o,children:t.jsx(io,{items:e.resources||[],onChange:X=>be("resources",X),onDownload:p,downloadStatuses:u,filterType:"image"})}),t.jsx(xt,{title:f.section.sources,onSave:o,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(mc,{items:hc(e.sources||""),onChange:X=>be("sources",gc(X)),onOpenEntityPicker:Y})}),(me||ue)&&t.jsx(xt,{title:f.section.provenance,onSave:o,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(Ut,{value:e.provenance||"",onChange:X=>be("provenance",X),placeholder:f.editor.provenancePlaceholder})}),me&&t.jsx(xt,{title:f.section.otherEditions,onSave:o,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(Ut,{value:e.otherEditions||"",onChange:X=>be("otherEditions",X),placeholder:f.editor.otherEditionsPlaceholder})}),t.jsx(fc,{entityType:pe,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:Oe,onUnlinkEntity:ie,onViewEntity:Re,onCreateAndLink:Le,onSaveRelations:ze}),a&&l&&t.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${i("danger-soft-border")}`,background:i("danger-soft-bg"),borderRadius:"4px"},children:[t.jsx("div",{style:{color:i("danger"),fontWeight:600,marginBottom:"8px"},children:f.section.dangerZone}),t.jsx("p",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"12px"},children:f.editor.dangerZoneDesc}),t.jsx("button",{onClick:l,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("danger")}`,borderRadius:"4px",background:"transparent",color:i("danger"),cursor:"pointer"},children:f.editor.deleteEntity})]}),t.jsx(bc,{isOpen:x,entityType:y,title:S,onSelect:fe,onCancel:()=>k(!1),onCreate:()=>{k(!1),Le(b,y)},searchResults:$,onSearch:J,isLoading:C,excludeId:e.id}),t.jsx(yc,{isOpen:T,entityType:F,relationField:R,inheritData:I,onConfirm:q,onCancel:()=>z(!1)}),t.jsx(vc,{isOpen:U,title:f.action.selectBookOrWork,filterType:"all",recentEntities:A,excludeId:e.id,onSelect:le,onCancel:()=>{K(!1),Z(null)},onSearch:ve})]})};function Af({items:e,onChange:n}){const o=$e(),r=(l,d,c)=>{const p=e.map((u,m)=>m===l?{...u,[d]:c}:u);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(dt,{label:o.editor.bookNameLabel,value:l.book_title,onChange:c=>r(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(dt,{label:o.label.juanCount,value:l.n_juan!=null?String(l.n_juan):"",onChange:c=>r(d,"n_juan",c&&parseInt(c,10)||void 0)})}),t.jsx("button",{onClick:()=>s(d),style:{padding:"4px 8px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("muted"),marginTop:"18px"},children:"✕"})]},d)),t.jsx("button",{onClick:a,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${i("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("desc-fg"),alignSelf:"flex-start"},children:o.action.addAdditionalWork})]})}function wc({items:e,onChange:n,showMeta:o,addLabel:r}){const s=$e(),[a,l]=g.useState(null),d=(u,m,h)=>{const f=e.map((x,k)=>k===u?{...x,[m]:h||void 0}:x);n(f)},c=u=>{n(e.filter((m,h)=>h!==u)),a===u&&l(null)},p=()=>{n([...e,{source:""}]),l(e.length)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((u,m)=>{const h=a===m;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:h?`color-mix(in srgb, ${i("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(h?null:m),children:[t.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.2s",transform:h?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:u.source||s.editor.unnamedSource}),u.source_bid&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u.source_bid}),t.jsx("button",{onClick:f=>{f.stopPropagation(),c(m)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${i("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:i("muted")},children:"✕"})]}),!h&&o&&(u.title_info||u.author_info)&&t.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:i("desc-fg")},children:[u.title_info,u.title_info&&u.author_info&&" — ",u.author_info]}),h&&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(dt,{label:s.label.sourceName,value:u.source,onChange:f=>d(m,"source",f)}),t.jsx(dt,{label:s.label.sourceBid,value:u.source_bid||"",onChange:f=>d(m,"source_bid",f)})]}),o&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(dt,{label:s.label.titleInfo,value:u.title_info||"",onChange:f=>d(m,"title_info",f)}),t.jsx(dt,{label:s.label.authorInfo,value:u.author_info||"",onChange:f=>d(m,"author_info",f)})]}),t.jsx(dt,{label:s.label.edition,value:u.edition||"",onChange:f=>d(m,"edition",f)})]}),t.jsx(Ut,{value:u.summary||"",onChange:f=>d(m,"summary",f),placeholder:s.editor.summaryPlaceholder}),t.jsx(Ut,{value:u.comment||"",onChange:f=>d(m,"comment",f),placeholder:s.editor.commentPlaceholder}),t.jsx(Ut,{value:u.additional_comment||"",onChange:f=>d(m,"additional_comment",f),placeholder:s.editor.additionalCommentPlaceholder})]})]},m)}),t.jsx("button",{onClick:p,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${i("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("desc-fg"),alignSelf:"flex-start"},children:r})]})}function Pf({items:e,onChange:n}){const o=$e();return t.jsx(wc,{items:e,onChange:n,showMeta:!0,addLabel:o.action.addIndexedBy})}function Mf({items:e,onChange:n}){const o=$e();return t.jsx(wc,{items:e,onChange:n,addLabel:o.action.addEmendatedBy})}function Sc(e){var d,c,p,u,m,h,f;const n=((c=(d=e.authors)==null?void 0:d[0])==null?void 0:c.name)||"",o=((p=e.publication_info)==null?void 0:p.year)||"",r=((u=e.current_location)==null?void 0:u.name)||"",s=(m=e.page_count)!=null&&m.number?String(e.page_count.number):((h=e.page_count)==null?void 0:h.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:o,holder:r,pages:s,description:a,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};if(e.type==="work"){const x=e;if(Array.isArray(x.related_works)){const k=x.related_works.find(y=>y.relation==="part_of");k&&(l.parentWorkId=k.id,l.parentWorkName=k.title)}}if(e.type==="book"){const x=e;l.workId=x.work_id,Array.isArray(x.contained_in)&&x.contained_in.length>0&&(l.collectionId=(f=x.contained_in[0])==null?void 0:f.id)}return l}function Bf(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 Wf=e=>{const{data:n,id:o,transport:r,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:u,onAskAI:m,renderSectionActions:h,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y,headerExtra:w,className:b,style:j}=e,S=$e(),[v,$]=g.useState(s),_=a?s:v;g.useEffect(()=>{s!==v&&$(s)},[s]);const C=g.useCallback(()=>{const O=_==="view"?"edit":"view";a?a(O):$(O)},[_,a]),[M,T]=g.useState(null);g.useEffect(()=>{o&&r&&r.getItem(o).then(O=>{O&&T(O)})},[o,r]);const z=n||M,F=g.useMemo(()=>z?Sc(z):null,[z]),N=a||!n?t.jsx("button",{onClick:C,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:_==="edit"?i("accent-bg"):"transparent",color:i(_==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:_==="view"?S.common.switchToEdit:S.common.switchToView,children:_==="view"?S.common.modeEdit:S.common.modeView}):null,R=t.jsxs(t.Fragment,{children:[N,w]});return!z&&!F?t.jsx(Yt,{}):_==="view"?t.jsx(Bo,{data:z,transport:r,onNavigate:p?O=>p(O):void 0,renderLink:u,headerExtra:R,className:b,style:j}):F?t.jsxs("div",{className:b,style:j,children:[R&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:R}),t.jsx(kc,{data:F,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:r,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:m,renderSectionActions:h,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:i("muted")},children:S.common.noData})},Of=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],_c=({isOpen:e,onClose:n,onSubmit:o,feedbackListUrl:r})=>{const{t:s}=Q(),[a,l]=g.useState(null),[d,c]=g.useState(""),[p,u]=g.useState(""),[m,h]=g.useState("idle"),[f,x]=g.useState(""),k=g.useRef(null);g.useEffect(()=>{e&&(l(null),c(""),u(""),h("idle"),x(""))},[e]),g.useEffect(()=>{a&&setTimeout(()=>{var b;return(b=k.current)==null?void 0:b.focus()},100)},[a]),g.useEffect(()=>{if(m==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[m,n]),g.useEffect(()=>{if(!e)return;const b=j=>{j.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,n]);const y=async()=>{if(!(!a||!d.trim())){h("submitting"),x("");try{await o({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),h("success")}catch(b){h("error"),x(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const w=a&&d.trim()&&m!=="submitting";return t.jsx("div",{style:Hf,onClick:b=>{b.target===b.currentTarget&&n()},children:t.jsxs("div",{style:Ff,onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{style:Df,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:Uf,"aria-label":s("feedback.close"),children:"✕"})]}),m==="success"?t.jsxs("div",{style:qf,children:[t.jsx("span",{style:{fontSize:"32px"},children:"✓"}),t.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:s("feedback.thanks")}),r&&t.jsx("a",{href:r,style:{fontSize:"13px",color:i("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:Of.map(b=>t.jsxs("button",{onClick:()=>l(b.value),style:{...Vf,...a===b.value?Gf:{}},children:[t.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),t.jsx("textarea",{ref:k,value:d,onChange:b=>c(b.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||m==="submitting",style:{...Yf,opacity:a?1:.6}}),t.jsx("input",{type:"text",value:p,onChange:b=>u(b.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!a||m==="submitting","aria-label":s("feedback.contactLabel"),style:Zf}),t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),m==="error"&&t.jsx("div",{style:Xf,children:f}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:y,disabled:!w,style:{...Kf,opacity:w?1:.6,cursor:w?"pointer":"not-allowed"},children:s(m==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},Hf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Ff={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:i("shadow-dialog")},Df={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},Uf={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:i("desc-fg"),padding:"4px 8px",borderRadius:"4px"},Vf={flex:"1 1 calc(50% - 4px)",padding:"10px 12px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},Gf={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},Yf={width:"100%",minHeight:"120px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},Kf={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},qf={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:i("success")},Xf={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginBottom:"12px"},Zf={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"},wo="--bim-feedback-fab-offset",So=48,Jf=16,Qf=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:o,hidden:r=!1,zIndex:s})=>{const{t:a}=Q(),[l,d]=g.useState(!1),c=n.bottom??24;return g.useEffect(()=>{if(r||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(wo,`calc(${c+So+Jf}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(wo)}},[r,c]),t.jsxs(t.Fragment,{children:[!r&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...ex,zIndex:s??i("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(_c,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:o})]})},ex={position:"fixed",width:`${So}px`,height:`${So}px`,borderRadius:"50%",border:"none",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:i("shadow-fab"),transition:"transform 0.2s, box-shadow 0.2s"},tx=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],$c=({onSubmit:e})=>{const{t:n}=Q(),[o,r]=g.useState("bug"),[s,a]=g.useState(""),[l,d]=g.useState(""),[c,p]=g.useState("idle"),[u,m]=g.useState(""),h=g.useRef(null);g.useEffect(()=>{o&&setTimeout(()=>{var k;return(k=h.current)==null?void 0:k.focus()},100)},[o]);const f=async()=>{if(!(!o||!s.trim())){p("submitting"),m("");try{await e({type:o,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),r("bug")}catch(k){p("error"),m(k instanceof Error?k.message:n("feedback.submitFailedRetry"))}}},x=o&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:Xs,children:t.jsxs("div",{style:sx,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:ax,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:Xs,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:tx.map(k=>t.jsxs("button",{onClick:()=>r(k.value),style:{...nx,...o===k.value?ix:{}},children:[t.jsx("span",{children:k.icon})," ",n(`feedback.submitType.${k.value}`)]},k.value))}),t.jsx("textarea",{ref:h,value:s,onChange:k=>a(k.target.value),placeholder:n(o?`feedback.placeholder.${o}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...ox}}),t.jsx("input",{type:"text",value:l,onChange:k=>d(k.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:cx}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[s.length," / 2000"]}),t.jsx("button",{onClick:f,disabled:!x,style:{...rx,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:lx,children:u})]})},Xs={padding:"16px",border:`1px solid ${i("widget-border")}`,borderRadius:"8px",background:i("input-bg")},nx={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:"transparent",color:i("fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},ix={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},ox={width:"100%",minHeight:"100px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},rx={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},sx={display:"flex",alignItems:"center",gap:"12px",color:i("success"),fontSize:"14px"},ax={background:"none",border:"none",color:i("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},lx={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginTop:"8px"},cx={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"};function Zs(e){return typeof e=="function"?e():e??"/api/feedback"}const Cc=({resourceId:e,apiUrl:n})=>{const{t:o}=Q(),[r,s]=g.useState([]),[a,l]=g.useState(!0),d=g.useCallback(async()=>{const p=Zs(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]);g.useEffect(()=>{d()},[d]);const c=async p=>{const u=Zs(n),m=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!m.ok){const h=await m.json().catch(()=>null);throw new Error((h==null?void 0:h.error)||o("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(br,{items:r,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx($c,{onSubmit:c})})]})},dx=di["zh-Hant"].relation,px=di["zh-Hant"].lossStatus,ux=di["zh-Hant"].resourceKind,Si=cn("zh-Hant"),yr=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function Js(e,n=Si){return e?yr(dx,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function mx(e,n=Si){return yr(px,e)?n(`detail.lossStatus.${e}`):e}function hx(e,n=Si){return yr(ux,e)?n(`detail.resourceKind.${e}`):""}function jr({authors:e,onNavigate:n,renderLink:o}){const{convert:r}=Q(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=Yo(a.role);return t.jsxs(g.Fragment,{children:[l>0&&" ",a.dynasty&&t.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",r(a.dynasty),"〕"]}),a.entity_id?t.jsx(qe,{id:a.entity_id,label:r(a.name),onNavigate:n,renderLink:o,dense:!0}):r(a.name),d&&t.jsx("span",{style:{marginLeft:4},children:r(d)})]},l)})}):null}function zc(e,n,o=Si){var c,p;const r=Vo(e,n),s=r.mirrors.map(u=>({key:u.key,label:u.label,description:u.description,rows:u.items.filter(m=>m.group_role!=="mirror"),mirrors:u.items.filter(m=>m.group_role==="mirror")})),a=r.buckets.filter(u=>u.key==="image"||u.key==="textImage").flatMap(u=>u.items);a.length&&s.push({key:"_images",label:s.length?o("detail.otherImages"):void 0,rows:a,mirrors:[]});const l=((c=r.buckets.find(u=>u.key==="physical"))==null?void 0:c.items)??[];return l.length&&s.push({key:"_physical",label:o("detail.resourceKind.physical"),rows:l,mirrors:[]}),{text:((p=r.buckets.find(u=>u.key==="text"))==null?void 0:p.items)??[],groups:s}}function Tc(e,n){const o=(e.url?dn(e.url):void 0)||e.name,r=vl(e,n);return r?`${o}(${r})`:o}function vr({item:e,siblings:n,listedVolumeCounts:o}){const{t:r,convert:s}=Q(),[a,l]=g.useState(!1),d=pi(e),c=!!d&&d.expected>0&&!(o!=null&&o.has(d.expected)),p=s(Tc(e,n)),u=pn(e),m=yi(e,r)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var f,x;const h=(f=e.metadata)!=null&&f.fragment||e.color_mode?t.jsxs("span",{className:"bim-d-tags bim-d-ui",style:{display:"inline-flex",margin:"0 0 0 8px",verticalAlign:"middle"},children:[((x=e.metadata)==null?void 0:x.fragment)&&t.jsx("span",{className:"bim-d-tag",children:r("detail.fragmentTag")}),e.color_mode&&t.jsx("span",{className:"bim-d-tag",children:e.color_mode==="color"?r("colorMode.color"):r("colorMode.bw")})]}):null;return u?t.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:[p," ",t.jsx("span",{"aria-hidden":"true",children:"↗"}),h]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,h]})})(),m&&t.jsx("span",{className:"bim-d-meta",children:s(m)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(Jo,{item:e})})]}),t.jsx("td",{className:c?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:c&&t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":a,onClick:()=>l(h=>!h),children:a?r("detail.collapseVolumes"):r("detail.expandVolumes",{n:d.expected})})})]})}function Nc({groups:e,listedVolumeCounts:n}){const{t:o,convert:r}=Q();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:r(s.label)}),s.description&&t.jsx("p",{className:"bim-d-rg-d",children:r(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(vr,{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:o("detail.mirror")}),s.mirrors.map((a,l)=>{const d=pn(a),c=r(Tc(a,s.mirrors));return d?t.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",title:a.details?r(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 En=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function _o(e){var o;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(o=En.find(r=>n.startsWith(r.key[0])))==null?void 0:o.key}const Qs=12,gx=60,Ec=({data:e,transport:n,onNavigate:o,renderLink:r,readAction:s,railTop:a,back:l,railLinks:d})=>{var J,fe,ze;const{t:c,convert:p,messages:u}=Q(),m=g.useMemo(()=>[...e.books||[],...e.collections||[]],[e.books,e.collections]),[h,f]=g.useState(new Map),[x,k]=g.useState(!1),[y,w]=g.useState(""),[b,j]=g.useState(!1),S=m.length<=gx,v=S||x||!!y||b,$=g.useMemo(()=>v?m:m.slice(0,Qs),[m,v]);g.useEffect(()=>{if(!n||$.length===0)return;const Y=$.filter(le=>!h.has(le));if(Y.length===0)return;let ve=!1;return Promise.all(Y.map(le=>n.getItem(le).then(Se=>{const X=Se??{};return[le,{id:le,title:X.title,edition:X.edition,resources:X.resources,publication_info:X.publication_info,current_location:X.current_location,lineage:X.lineage,measure_info:X.measure_info}]}).catch(()=>[le,{id:le}]))).then(le=>{ve||f(Se=>{const X=new Map(Se);for(const[Ce,Me]of le)X.set(Ce,Me);return X})}),()=>{ve=!0}},[n,$,h]);const _=g.useMemo(()=>m.map(Y=>h.get(Y)??{id:Y}),[m,h]),C=m.length>0&&m.every(Y=>h.has(Y)),M=!!n&&$.some(Y=>!h.has(Y)),T=S||v,z=g.useMemo(()=>wl(_,e.version_graph,{era:y,scanOnly:b,sort:T?"year":"default"}),[_,e.version_graph,y,b,T]),F=x?z.rows:z.rows.slice(0,Qs),N=z.allRows.filter(Y=>Y.hasImage).length,R=e.related_works||[],O=R.filter(Y=>Y.relation==="collected_in"),I=g.useMemo(()=>{const Y=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],ve=le=>{const Se=Y.indexOf(le??"");return Se<0?Y.length:Se};return R.filter(le=>le.relation!=="collected_in").map((le,Se)=>({r:le,i:Se})).sort((le,Se)=>ve(le.r.relation)-ve(Se.r.relation)||le.i-Se.i).map(le=>le.r)},[R]),P=g.useMemo(()=>{const Y=Vo(e.resources,e.resource_groups);return[...Y.mirrors.flatMap(ve=>ve.items.map(le=>({r:le,kind:p(ve.label)}))),...Y.buckets.flatMap(ve=>ve.items.map(le=>({r:le,kind:p(hx(ve.key,c))})))]},[e.resources,e.resource_groups,p,c]),U=e.indexed_by||[],K=e.emendated_by||[],L=g.useMemo(()=>{var te,ye,H;const Y=[],ve=(ye=(te=e.authors)==null?void 0:te[0])==null?void 0:ye.dynasty;ve&&Y.push({label:c("workPage.fact.written"),value:p(ve)});const le=zt(e,u.unit.juan);if(le){const se=(H=e.juan_count)==null?void 0:H.description;Y.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(le),se&&se!==le?t.jsxs("span",{className:"bim-d-meta",children:["(",p(se),")"]}):null]})})}e.loss_status&&Y.push({label:c("workPage.fact.loss"),value:p(mx(e.loss_status,c))});const Se=z.allRows.filter(se=>se.sortYear!=null),X=Se.length>0?Se.reduce((se,ne)=>se.sortYear<=ne.sortYear?se:ne):null;X!=null&&X.era.era?Y.push({label:c("workPage.fact.earliest"),value:p([X.era.era,X.era.reign].filter(Boolean).join(" ")),title:X.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):M&&Y.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),K.length&&Y.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:K.length})});const Ce=ea(e.additional_titles);Ce.length&&Y.push({label:c("workPage.fact.alias"),value:Ce.map(p).join("、")});const Me=ea(e.attached_texts);Me.length&&Y.push({label:c("workPage.fact.attached"),value:Me.map(p).join("、")});const B=(e.additional_works||[]).map(se=>p(se.book_title)+(se.n_juan!=null?` ${se.n_juan}${u.unit.juan}`:""));return B.length&&Y.push({label:c("workPage.fact.appendix"),value:B.join("、")}),Y},[e,p,c,u,M,z.allRows,K.length]),A=[{value:e._edition_count??m.length,label:c("workPage.stat.editions")},{value:C?N:0,label:c("workPage.stat.hasImage")},{value:U.length,label:c("workPage.stat.catalogs")}],V=e.classification,pe=V?[V.l1,V.l2,V.l3,V.l4].filter(Boolean).map(Y=>p(Y)):[],ee=e.subtype?u.workSubtype[e.subtype]??p(e.subtype):"",ue=t.jsx(An,{title:p(e.title),byline:t.jsx(jr,{authors:e.authors,onNavigate:o,renderLink:r}),meta:t.jsx(Je,{items:[...pe,V!=null&&V.source?c("workPage.classifiedBy",{source:p(V.source.split("/")[0])}):"",ee]}),description:(J=e.description)!=null&&J.text?t.jsxs(t.Fragment,{children:[t.jsx(Ct,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(fe=e.description.sources)!=null&&fe.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(Y=>p(Im(Y))).filter(Boolean).join(" · ")}):null]}):void 0,stats:A,facts:L,readAction:s,foot:t.jsx(Pn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(ze=e.appendix)==null?void 0:ze.map((Y,ve)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(Y.title)}),t.jsx(Ct,{text:Y.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},ve))}),me=z.eras.length>=2?[{key:"",label:c("catalog.all")},...z.eras.map(Y=>({key:Y,label:`${Y} ${z.allRows.filter(ve=>ve.era.era===Y).length}`}))]:[],be=[];m.length&&be.push({id:"versions",label:c("workPage.sec.versions"),count:m.length}),U.length&&be.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:U.length}),O.length&&be.push({id:"collected",label:c("workPage.sec.collected"),count:O.length}),I.length&&be.push({id:"related",label:c("workPage.sec.related"),count:I.length}),P.length&&be.push({id:"resources",label:c("workPage.sec.resources"),count:P.length});const Oe=m.length===0&&U.length===0,ie=t.jsxs(t.Fragment,{children:[m.length>0&&t.jsxs(et,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(Je,{items:[c("workPage.versionsTotal",{n:m.length}),C&&N?c("workPage.versionsWithImage",{n:N}):"",z.rows.length!==z.allRows.length?c("workPage.versionsCurrent",{n:z.rows.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":M&&me.length===0&&m.length>1?"":void 0,children:[me.length>0&&t.jsx(vi,{items:me,value:y,onChange:Y=>{w(Y),k(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(Nl,{label:c("workPage.scanOnly"),checked:b,onChange:Y=>{j(Y),k(!1)}}),t.jsx("span",{className:"bim-d-meta",children:c(T?"workPage.sortByYear":"workPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&ki(z.rows.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:c("workPage.col.edition")}),t.jsx("th",{children:c("workPage.col.era")}),t.jsx("th",{children:c("workPage.col.holder")}),t.jsx("th",{children:t.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:c("workPage.col.image")})})]})}),t.jsx("tbody",{children:F.map(Y=>{var ve;return t.jsx(fx,{row:Y,measure:(ve=h.get(Y.id))==null?void 0:ve.measure_info,loaded:h.has(Y.id),onNavigate:o,renderLink:r},`${Y.id}:${h.has(Y.id)?"r":"p"}`)})})]}),F.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(Ko,{total:z.rows.length,shown:F.length,unit:c("workPage.moreUnit"),onClick:()=>k(!0)}),z.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),U.length>0&&t.jsx(xx,{items:U,transport:n,onNavigate:o,renderLink:r}),Oe&&t.jsx(et,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),Re=(Y,ve)=>t.jsx(qe,{id:Y,label:p(ve),onNavigate:o,renderLink:r,dense:!0}),Le=g.useMemo(()=>{const Y=new Map;for(const ve of I){const le=Js(ve.relation,c);Y.set(le,(Y.get(le)??0)+1)}return Y.size>1?[...Y.entries()].sort((ve,le)=>le[1]-ve[1]).slice(0,4).map(([ve,le])=>`${p(ve)} ${le}`).join(" · "):void 0},[I,p,c]),q=t.jsxs(t.Fragment,{children:[t.jsx(Dt,{id:"collected",title:c("workPage.sec.collected"),items:O.map(Y=>Re(Y.id,Y.title))}),t.jsx(Dt,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:I.length}),sub:Le,items:I.map(Y=>t.jsxs(t.Fragment,{children:[Re(Y.id,Y.title),t.jsx("span",{className:"bim-d-meta",title:Y.note?p(Y.note):void 0,children:p(Js(Y.relation,c))})]}))}),t.jsx(Dt,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:P.map(({r:Y,kind:ve})=>{const le=p((Y.url?dn(Y.url):void 0)||Y.name),Se=pn(Y);return t.jsxs(t.Fragment,{children:[Se?t.jsxs("a",{href:Se,target:"_blank",rel:"noopener noreferrer",children:[le," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:le}),ve&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:ve})]})})})]});return t.jsx(Ln,{railTop:a,back:l,nav:be,railLinks:d,main:ie,card:ue,side:q})};function ea(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function ta(e,n){return n((e.url?dn(e.url):void 0)||e.name)}function fx({row:e,measure:n,loaded:o,onNavigate:r,renderLink:s}){const{t:a,convert:l}=Q(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],u=p?ta(p,l):e.locationName?l(e.locationName):"",m=e.images[0],h=m?pn(m):void 0,f=e.images.map(x=>ta(x,l)).join("、");return t.jsxs("tr",{"data-loading":o?void 0:"",children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(qe,{id:e.id,label:l(e.name),onNavigate:r,renderLink:s,dense:!0}),n?t.jsx("span",{className:"bim-d-meta",children:l(n)}):t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${d?"":" bim-d-zt-blank"}`,title:c?a("workPage.inferredFromEdition"):void 0,children:d?l(d):o?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),t.jsxs("td",{className:`bim-d-zt-sub${u?"":" bim-d-zt-blank"}`,children:[u||(o?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),e.holders.length>1&&t.jsxs("span",{className:"bim-d-meta",children:[" +",e.holders.length-1]})]}),t.jsx("td",{className:e.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:e.hasImage&&(h?t.jsx("a",{className:"bim-d-flag",href:h,target:"_blank",rel:"noopener noreferrer",title:f,children:a("workPage.hasImage")}):t.jsx("span",{className:"bim-d-flag",title:f,children:a("workPage.hasImage")}))})]})}function xx({items:e,transport:n,onNavigate:o,renderLink:r}){const{t:s,convert:a}=Q(),[l,d]=g.useState(0),c=Math.min(l,e.length-1),p=e[c],[u,m]=g.useState(new Map);return g.useEffect(()=>{if(!n)return;const h=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(h.length===0)return;let f=!1;return Promise.all(h.map(x=>n.getItem(x).then(k=>{var y,w;return[x,((w=(y=k==null?void 0:k.authors)==null?void 0:y[0])==null?void 0:w.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{f||m(new Map(x.filter(([,k])=>k)))}),()=>{f=!0}},[n,e]),t.jsx(et,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(Je,{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((h,f)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":f===c,"aria-label":a(h.source),onClick:()=>d(f),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:u.get(h.source_bid??"")?a(u.get(h.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(h.source)].slice(0,9).map((x,k)=>t.jsx("span",{children:x},k))})]})},f))}),t.jsxs("div",{className:"bim-d-lu-body",role:"tabpanel",children:[p.title_info&&t.jsx("div",{className:"bim-d-lu-title",children:a(p.title_info)}),t.jsx(Je,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(qe,{id:p.source_bid,label:a(p.source),onNavigate:o,renderLink:r,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:ut(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:ut(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:ut(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 bx(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 yx(e,n){if(!e.lineage)return null;const o=e.lineage;return{id:e.id,kind:"book",label:e.title,year:o.year,year_text:o.year_text,year_uncertain:o.year_uncertain,category:o.category,status:o.status,extant_juan:o.extant_juan,group:n[e.id],note:o.note}}function na(e,n,o){return{id:`derive:${n.ref}->${e}:${o}`,source:n.ref,target:e,kind:"derive",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function jx(e,n,o){const[r,s]=[e,n.book_id].sort();return{id:`sibling:${r}-${s}:${o}`,source:r,target:s,kind:"sibling",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function vx(e,n){var p;if(n==="all")return null;const o=(p=e.collections)==null?void 0:p[n],r=Array.isArray(o==null?void 0:o.groups)&&o.groups.length>0,s=Array.isArray(o==null?void 0:o.book_ids)&&o.book_ids.length>0,a=r||s||!!(o!=null&&o.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(!o||!a)return null;const l=r?new Set(o.groups):null,d=new Set(o.book_ids??[]);if(l&&e.node_groups)for(const[u,m]of Object.entries(e.node_groups))l.has(m)&&d.add(u);let c=null;if(o.hypothetical_ids&&(c=new Set(o.hypothetical_ids)),l){c||(c=new Set);for(const u of e.hypothetical_nodes??[])u.group&&l.has(u.group)&&c.add(u.id)}return{books:d,hypos:c}}function ni(e,n,o){const r=e.version_graph,s={nodes:[],edges:[],groups:[],layout:"LR",excluded:[]};if(!r||!r.enabled)return s;const a=new Set(r.excluded_books??[]),l=r.node_groups??{},d=vx(r,o??r.default_collection??"all"),c=d!==null,p=(d==null?void 0:d.books)??null,u=(d==null?void 0:d.hypos)??null,m=new Set,h=new Set;if(c){const S=new Map(n.map(T=>[T.id,T])),v=new Map((r.hypothetical_nodes??[]).map(T=>[T.id,T])),$=T=>{const z=S.get(T);if(z&&z.lineage)return(z.lineage.derived_from??[]).map(N=>N.ref);const F=v.get(T);return F?(F.derived_from??[]).map(N=>N.ref):[]},_=T=>v.has(T)?!u||u.has(T):!p||p.has(T),C=new Set,M=T=>{if(!C.has(T)){C.add(T);for(const z of $(T))a.has(z)||(_(z)||(v.has(z)?h.add(z):S.has(z)&&m.add(z)),M(z))}};for(const T of n)p&&p.has(T.id)&&!a.has(T.id)&&M(T.id);for(const T of r.hypothetical_nodes??[])u&&u.has(T.id)&&M(T.id)}const f=n.filter(S=>!a.has(S.id)).filter(S=>!p||p.has(S.id)||m.has(S.id)).map(S=>{const v=yx(S,l);return v&&m.has(S.id)&&(v.bridge=!0),v}).filter(S=>S!==null),x=(r.hypothetical_nodes??[]).filter(S=>!u||u.has(S.id)||h.has(S.id)).map(S=>{const v=bx(S);return h.has(S.id)&&(v.bridge=!0),v}),k=[...f,...x],y=new Set(k.map(S=>S.id)),w=new Set,b=[],j=S=>{w.has(S.id)||!y.has(S.source)||!y.has(S.target)||(w.add(S.id),b.push(S))};for(const S of n)a.has(S.id)||!S.lineage||p&&!p.has(S.id)&&!m.has(S.id)||((S.lineage.derived_from??[]).forEach((v,$)=>{j(na(S.id,v,$))}),(S.lineage.related_to??[]).forEach((v,$)=>{j(jx(S.id,v,$))}));for(const S of r.hypothetical_nodes??[])u&&!u.has(S.id)&&!h.has(S.id)||(S.derived_from??[]).forEach((v,$)=>{j(na(S.id,v,$))});return{nodes:k,edges:b,groups:r.groups??[],title:r.title,description:r.description,layout:r.layout??"LR",excluded:Array.from(a)}}function Ic(e,n,o){const r=(e??(n!=null?String(n):"")).trim();return r?!o||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(r)?r:`约 ${r}`:""}function kx(e,n){const o=[],r=e.version_graph;if(!r)return o;const s=new Set(n.map(c=>c.id)),a=new Set((r.hypothetical_nodes??[]).map(c=>c.id)),l=new Set([...s,...a]),d=(c,p)=>{l.has(p.ref)||o.push(`${c}: derived_from.ref "${p.ref}" 未在 books 或 hypothetical_nodes 中找到`),p.ref_type==="book"&&!s.has(p.ref)&&o.push(`${c}: derived_from.ref "${p.ref}" 标记为 book 但不在 books 列表中`),p.ref_type==="hypothetical"&&!a.has(p.ref)&&o.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(u=>d(p,u)),(c.lineage.related_to??[]).forEach(u=>{s.has(u.book_id)||o.push(`${p}: related_to.book_id "${u.book_id}" 不在 books 列表中`)})}for(const c of r.hypothetical_nodes??[]){const p=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(u=>d(p,u))}return o}const Rc=({graph:e,renderLink:n,className:o,style:r})=>{const{t:s,convert:a}=Q();if(!e.nodes.length)return t.jsx("div",{style:{...Px,...r},className:o,children:s("lineage.emptyGraph")});const l=new Map,d=new Map;for(const f of e.edges)if(f.kind==="derive"){const x=l.get(f.target)??[];x.push(f),l.set(f.target,x)}else for(const x of[f.source,f.target]){const k=d.get(x)??[];k.push(f),d.set(x,k)}const c=new Map(e.nodes.map(f=>[f.id,f])),p=new Map,u=[];for(const f of e.nodes)if(f.group){const x=p.get(f.group)??[];x.push(f),p.set(f.group,x)}else u.push(f);const m=(f,x)=>(f.year??9999)-(x.year??9999);p.forEach(f=>f.sort(m)),u.sort(m);const h=e.groups.filter(f=>p.has(f.id));return t.jsxs("div",{className:o,style:{...Sx,...r},children:[e.title&&t.jsx("div",{style:_x,children:a(e.title)}),e.description&&t.jsx("div",{style:$x,children:a(e.description)}),h.map(f=>t.jsx(ia,{label:f.label,color:f.color,nodes:p.get(f.id),incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n},f.id)),u.length>0&&t.jsx(ia,{label:s("lineage.otherGroup"),nodes:u,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},ia=({label:e,color:n,nodes:o,incomingMap:r,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=Q();return t.jsxs("div",{style:Cx,children:[t.jsx("div",{style:{...zx,borderLeftColor:n??i("widget-border")},children:d(e)}),o.map(c=>t.jsx(wx,{node:c,incoming:r.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},wx=({node:e,incoming:n,siblings:o,nodeMap:r,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=Q();return t.jsxs("div",{style:{...Tx,borderStyle:a||l?"dashed":"solid",opacity:l?.55:e.status==="lost"?.7:1,background:l?i("bg-subtle"):void 0},title:l?d("lineage.bridgeTitle"):void 0,children:[t.jsxs("div",{style:Nx,children:[t.jsx("span",{style:Ex,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:Ix,children:Ic(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:Rx,children:[e.category&&t.jsx(Sn,{children:c(e.category)}),e.status==="lost"&&t.jsx(Sn,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(Sn,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(Sn,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(Sn,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:Lx,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:Ax,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:ra,children:[t.jsx("div",{style:sa,children:d("lineage.sources")}),n.map(p=>{const u=r.get(p.source);return t.jsxs("div",{style:aa(p.confidence),children:[t.jsx("span",{style:la,children:c(p.relation)}),t.jsx("span",{children:(u==null?void 0:u.kind)==="book"&&s?s(u.id,c(u.label)):c((u==null?void 0:u.label)??p.source)}),p.confidence!=="consensus"&&p.confidence!=="certain"&&t.jsx(oa,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:ca,children:["· ",c(p.evidence)]})]},p.id)})]}),o.length>0&&t.jsxs("div",{style:ra,children:[t.jsx("div",{style:sa,children:d("lineage.related")}),o.map(p=>{const u=p.source===e.id?p.target:p.source,m=r.get(u);return t.jsxs("div",{style:aa(p.confidence),children:[t.jsx("span",{style:la,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)??u)}),t.jsx(oa,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:ca,children:["· ",c(p.evidence)]})]},p.id)})]})]})},Sn=({children:e,tone:n="default"})=>{const r={default:{bg:i("tag-bg"),fg:i("fg")},warn:{bg:i("warn-bg"),fg:i("warn-fg")},info:{bg:i("info-bg"),fg:i("info-fg")}}[n];return t.jsx("span",{style:{display:"inline-block",padding:"1px 8px",fontSize:"11px",borderRadius:"10px",background:r.bg,color:r.fg,marginRight:"4px"},children:e})},oa=({level:e})=>{const{t:n}=Q(),r={certain:{key:"certain",color:i("confidence-certain")},consensus:{key:"consensus",color:i("confidence-consensus")},probable:{key:"probable",color:i("confidence-probable")},disputed:{key:"disputed",color:i("confidence-disputed")}}[e];return r?t.jsx("span",{style:{display:"inline-block",padding:"0 6px",fontSize:"10px",border:`1px solid ${r.color}`,color:r.color,borderRadius:"8px",marginLeft:"4px"},children:n(`lineage.confidence.${r.key}`)}):null},Sx={fontSize:"14px",color:i("fg")},_x={fontSize:"16px",fontWeight:600,marginBottom:"8px"},$x={fontSize:"13px",color:i("muted"),marginBottom:"16px",lineHeight:1.6},Cx={marginBottom:"16px"},zx={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:i("fg")},Tx={border:`1px solid ${i("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:i("bg")},Nx={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Ex={fontSize:"15px",fontWeight:600},Ix={fontSize:"12px",color:i("muted")},Rx={marginBottom:"6px"},Lx={fontSize:"12px",color:i("muted"),margin:"2px 0"},Ax={fontSize:"12px",color:i("muted"),fontStyle:"italic",margin:"4px 0"},ra={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${i("widget-border")}`},sa={fontSize:"11px",color:i("muted"),marginBottom:"2px"},aa=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),la={display:"inline-block",padding:"0 6px",fontSize:"11px",background:i("tag-bg"),color:i("fg"),borderRadius:"3px",marginRight:"6px"},ca={fontSize:"11px",color:i("muted")},Px={padding:"20px",textAlign:"center",color:i("muted"),fontSize:"13px"},Lc=({selectedNodeId:e,...n})=>{const{t:o}=Q(),[r,s]=g.useState("loading"),[a,l]=g.useState(null);return g.useEffect(()=>{let d=!1;return Mx().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),r==="loading"?t.jsx("div",{style:pa,children:o("lineage.graphLoading")}):r==="missing"||!a?t.jsxs("div",{style:pa,children:[t.jsx("div",{children:da(o("lineage.graphMissing"),{xyflow:t.jsx("code",{children:"@xyflow/react"}),dagre:t.jsx("code",{children:"@dagrejs/dagre"})})}),t.jsx("div",{style:{fontSize:"12px",marginTop:"4px"},children:da(o("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(Bx,{modules:a,selectedNodeId:e,...n})};function da(e,n){return e.split(/(\{\w+\})/).map((o,r)=>{const s=/^\{(\w+)\}$/.exec(o);return t.jsx(g.Fragment,{children:s&&s[1]in n?n[s[1]]:o},r)})}async function Mx(){try{const[e,n]=await Promise.all([import("@xyflow/react"),import("@dagrejs/dagre")]);let o=!1;try{await import("@xyflow/react/dist/style.css"),o=!0}catch{o=!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:o}}catch{return null}}const Bx=({graph:e,renderLink:n,height:o=600,className:r,style:s,selectedNodeId:a,modules:l})=>{const{ReactFlow:d,Background:c,Controls:p,Handle:u,Position:m,BaseEdge:h,EdgeLabelRenderer:f,getSmoothStepPath:x,dagre:k}=l,y=g.useMemo(()=>({lineage:$=>{var I,P,U,K;const _=((I=$.data)==null?void 0:I.stepPosition)??.85,[C,M,T]=x({sourceX:$.sourceX,sourceY:$.sourceY,sourcePosition:$.sourcePosition,targetX:$.targetX,targetY:$.targetY,targetPosition:$.targetPosition,stepPosition:_,borderRadius:5}),z=!!((P=$.data)!=null&&P.isSibling),F=z?M:$.targetX-18,N=z?T:$.targetY-12,R=(U=$.data)==null?void 0:U.labelStyle,O=(K=$.data)==null?void 0:K.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(h,{id:$.id,path:C,style:$.style,markerStart:$.markerStart,markerEnd:$.markerEnd}),$.label&&t.jsx(f,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${F}px,${N}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:i("bg"),border:`0.5px solid ${i("widget-border")}`,...O,...R},children:$.label})})]})}}),[h,f,x]),w=g.useMemo(()=>({version:$=>{const{t:_}=Q(),C=$.data,M=C.kind==="hypothetical",T=C.status==="lost",z=C.isSelected,F=C.bridge,N=C.borderColor??i("muted"),R=F||M?"dashed":"solid",O=F?.5:T?.6:1;return t.jsxs("div",{style:{background:i(F?"bg-subtle":"bg"),border:`2px ${R} ${z?i("primary"):N}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:O,boxShadow:z?i("shadow-node-selected"):M||F?"none":i("shadow-node")},title:F?_("lineage.bridgeTitle"):void 0,children:[t.jsx(u,{type:"target",position:m.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:M||!C.renderLink?C.label:C.renderLink(C.bookId,C.label)}),C.description&&t.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.25,marginTop:1},children:C.description}),C.yearText&&t.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.2},children:Ic(C.yearText,void 0,C.uncertain)}),T&&t.jsx("div",{style:{fontSize:9,color:i("lost-fg"),marginTop:1},children:_("lineage.lost")}),t.jsx(u,{type:"source",position:m.Right,style:{visibility:"hidden"}})]})}}),[u,m]),{convert:b}=Q(),{rfNodes:j,rfEdges:S}=g.useMemo(()=>Wx(e,k,n,a,b),[e,k,n,a,b]);return t.jsx("div",{style:{width:"100%",height:o,...s},className:r,children:t.jsxs(d,{nodes:j,edges:S,nodeTypes:w,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 Wx(e,n,o,r,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(w=>[w.id,w.color??i("muted")]));for(const w of e.nodes)c.setNode(w.id,{width:160,height:90});const u=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const w of e.edges)w.kind==="derive"&&(u.has(w.relation)||c.setEdge(w.source,w.target));n.layout(c);const m=e.nodes.map(w=>{const b=c.node(w.id),j=r?w.id===r:void 0,S={kind:w.kind,label:s(w.label),bookId:w.kind==="book"?w.id:void 0,yearText:s(w.year_text??Hx(w)),uncertain:w.year_uncertain,category:w.category,status:w.status,borderColor:w.group?p.get(w.group):void 0,renderLink:o,isSelected:j,description:s(w.description),bridge:w.bridge};return{id:w.id,type:"version",position:{x:b.x-160/2,y:b.y-90/2},data:S,draggable:!1,selected:j}}),h=.78,f=.06,x=new Map;for(const w of e.edges)w.kind==="derive"&&(x.has(w.source)||x.set(w.source,[]),x.get(w.source).push(w));const k=new Map;for(const[w,b]of x){if(b.length<=1)continue;const j=[...b].sort((v,$)=>{var M,T;const _=((M=c.node(v.target))==null?void 0:M.y)??0,C=((T=c.node($.target))==null?void 0:T.y)??0;return _-C}),S=j.length;j.forEach((v,$)=>{const _=($-(S-1)/2)*f;k.set(v.id,h+_)})}const y=e.edges.map(w=>Ox(w,k.get(w.id),s));return{rfNodes:m,rfEdges:y}}function Ox(e,n,o=r=>r??""){const r=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=Fx(e.confidence),l={type:"arrowclosed",color:a,width:14,height:14};return{id:e.id,source:e.source,target:e.target,type:"lineage",label:o(e.relation),data:{labelStyle:{color:i("fg")},isSibling:s,stepPosition:n},style:{stroke:a,strokeWidth:s?1:1.5,strokeDasharray:s?"4 3":r?"6 4":void 0,opacity:r?.75:1},animated:!1,markerEnd:l,markerStart:s?l:void 0,zIndex:1e3}}function Hx(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function Fx(e){switch(e){case"certain":return i("confidence-certain");case"consensus":return i("lineage-edge-consensus");case"probable":return i("confidence-probable");case"disputed":return i("confidence-disputed");default:return i("muted")}}const pa={padding:"40px 20px",textAlign:"center",color:i("muted"),fontSize:"13px",border:`1px dashed ${i("widget-border")}`,borderRadius:8,background:i("bg")},kr=({graph:e,defaultMode:n="list",renderLink:o,graphHeight:r=600,selectedNodeId:s,onModeChange:a,collection:l,onCollectionChange:d,collectionsAvailable:c,collectionCounts:p,className:u,style:m})=>{var S;const{t:h,convert:f}=Q(),[x,k]=g.useState(n),y=v=>{k(v),a==null||a(v)},w=(()=>{if(!c)return[];const v=Object.entries(c);return v.length===0||c.all?v:[...v,["all",{label:h("lineage.collectionAll"),description:h("lineage.collectionAllDesc")}]]})(),b=!!(d&&w.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:i("muted"),textAlign:"center"},children:h("lineage.empty")});const j=l?(S=c==null?void 0:c[l])==null?void 0:S.description:void 0;return t.jsxs("div",{className:u,style:m,children:[t.jsxs("div",{style:Dx,children:[t.jsx("button",{onClick:()=>y("list"),style:Ji(x==="list"),children:h("lineage.modeList")}),t.jsx("button",{onClick:()=>y("graph"),style:Ji(x==="graph"),children:h("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:i("muted"),marginRight:4},children:h("lineage.collectionLabel")}),w.map(([v,$])=>{const _=p==null?void 0:p[v];return t.jsxs("button",{onClick:()=>d==null?void 0:d(v),style:Ji(l===v),title:$.description?f($.description):void 0,children:[f($.label),_!=null?` ${_}`:""]},v)})]})]}),b&&j&&t.jsx("div",{style:{fontSize:12,color:i("muted"),marginBottom:8,padding:"4px 8px",background:i("bg-subtle"),borderRadius:4},children:f(j)}),x==="list"?t.jsx(Rc,{graph:e,renderLink:o}):t.jsx(Lc,{graph:e,renderLink:o,height:r,selectedNodeId:s})]})},Dx={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},Ji=e=>({padding:"4px 12px",fontSize:12,border:`1px solid ${i("widget-border")}`,borderRadius:4,background:e?i("primary"):"transparent",color:i(e?"primary-fg":"fg"),cursor:"pointer"}),ua=40,ma=2,Ux=9,Vx=new Set(["certain","consensus","probable","disputed"]);function Qi(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const Ac=({data:e,transport:n,onNavigate:o,renderLink:r,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:u})=>{var H,se,ne,ge,Ne,Be,We,Ue,Qe,ce,tt;const m=$e(),{t:h,convert:f}=Q(),[x,k]=g.useState(null),[y,w]=g.useState(new Map),[b,j]=g.useState([]),[S,v]=g.useState(new Map),[$,_]=g.useState(!1),[C,M]=g.useState("flow"),[T,z]=g.useState(null);g.useEffect(()=>{if(!n||!e.work_id){k(null);return}let E=!1;return n.getItem(e.work_id).then(oe=>{!E&&oe&&oe.type==="work"&&k(oe)}).catch(()=>{}),()=>{E=!0}},[n,e.work_id]),g.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){z(null);return}let E=!1;return n.getLineageGraph(e.work_id).then(oe=>{E||z(oe&&oe.nodes.length>1?oe:null)}).catch(()=>{E||z(null)}),()=>{E=!0}},[n,e.work_id]),g.useEffect(()=>{const E=e.contained_in||[];if(!n||E.length===0){w(new Map);return}let oe=!1;return Promise.all(E.map(ae=>{const je=typeof ae=="string"?ae:ae.id;return n.getItem(je).then(ke=>[je,ke]).catch(()=>[je,null])})).then(ae=>{if(oe)return;const je=new Map;for(const[ke,xe]of ae)xe&&je.set(ke,xe);w(je)}),()=>{oe=!0}},[n,e.contained_in]);const F=g.useMemo(()=>{const E=new Set([...(x==null?void 0:x.books)||[],...e.related_books||[]]);return E.add(e.id),[...E]},[x==null?void 0:x.books,e.related_books,e.id]),N=F.length-1;g.useEffect(()=>{if(!n||N<=0){j([]);return}const E=F.length<=ua,oe=E?F:F.slice(0,8);let ae=!1;return Promise.all(oe.map(je=>je===e.id?Promise.resolve({id:je,title:e.title,edition:e.edition,year:ri(e)}):n.getItem(je).then(ke=>{const xe=ke??{};return{id:je,title:xe.title,edition:xe.edition,year:ke?ri(xe):void 0}}).catch(()=>({id:je})))).then(je=>{if(ae)return;const ke=je.filter(xe=>xe.id===e.id||xe.title||xe.edition);E&&ke.sort((xe,G)=>(xe.year??1/0)-(G.year??1/0)),j(ke)}),()=>{ae=!0}},[n,F,N,e]);const R=e.lineage,O=g.useMemo(()=>[...((R==null?void 0:R.derived_from)||[]).filter(E=>E.ref_type==="book").map(E=>E.ref),...((R==null?void 0:R.related_to)||[]).map(E=>E.book_id)].filter(Boolean),[R]);g.useEffect(()=>{if(!n||O.length===0){v(new Map);return}let E=!1;return Promise.all(O.map(oe=>n.getItem(oe).then(ae=>[oe,{id:oe,title:ae==null?void 0:ae.title,edition:ae==null?void 0:ae.edition}]).catch(()=>[oe,{id:oe}]))).then(oe=>{E||v(new Map(oe))}),()=>{E=!0}},[n,O]);const I=g.useMemo(()=>zc(e.resources,e.resource_groups,h),[e.resources,e.resource_groups,h]),P=I.groups.reduce((E,oe)=>E+oe.rows.length+oe.mirrors.length,0),U=I.groups.length>0&&I.groups.every(E=>E.key==="_physical"),K=Rn(e),L=zl(e),Z=zt(e,m.unit.juan),A=new Set((e.contained_in||[]).map(E=>typeof E=="string"?0:Tn(E.volume_index).length).filter(E=>E>0)),V=E=>{var je;const oe=(je=e.base_edition)==null?void 0:je.find(ke=>ke.book_id===E&&ke.name);if(oe!=null&&oe.name)return oe.name;const ae=S.get(E);return(ae==null?void 0:ae.edition)||(ae==null?void 0:ae.title)||""},pe=g.useMemo(()=>{var Te,Ee,D,re,Pe;const E=[];L&&E.push({label:h("bookPage.fact.editionType"),value:f(L),title:e.edition_type||(Te=e.lineage)!=null&&Te.category?void 0:h("bookPage.inferredFromEdition")}),(Ee=e.publication_info)!=null&&Ee.details?E.push({label:h("bookPage.fact.publication"),value:f(e.publication_info.details)}):(K.era||K.reign)&&E.push({label:h("bookPage.fact.era"),value:f([K.era,K.reign].filter(Boolean).join(" ")),title:K.source==="edition"?h("bookPage.inferredFromEdition"):void 0}),Z&&E.push({label:h("bookPage.fact.measure"),value:f(Z)});const oe=(e.contained_in||[]).flatMap(_e=>typeof _e=="string"?[]:Tn(_e.volume_index));oe.length&&E.push({label:h("bookPage.fact.volumes"),value:h("bookPage.volumesValue",{range:ji(oe,m.unit.volume),unit:m.unit.volume,n:oe.length})});const ae=(((D=e.lineage)==null?void 0:D.derived_from)||[]).find(_e=>_e.relation==="底本"&&_e.ref_type==="book");ae&&V(ae.ref)&&E.push({label:h("bookPage.fact.baseEdition"),value:t.jsx(qe,{id:ae.ref,label:f(V(ae.ref)),onNavigate:o,renderLink:r,dense:!0})});const je=(e.base_edition||[]).filter(_e=>_e&&_e.name);for(const _e of["底本","配補","參校"]){if(_e==="底本"&&ae&&V(ae.ref))continue;const Ge=je.filter(He=>He.role===_e);Ge.length&&E.push({label:f(_e),value:Ge.map((He,De)=>t.jsxs(g.Fragment,{children:[De>0&&"、",He.book_id?t.jsx(qe,{id:He.book_id,label:f(He.name),onNavigate:o,renderLink:r,dense:!0}):f(He.name)]},De))})}const ke=(e.provenance||[]).filter(_e=>_e&&_e.institution),xe=(e.resources||[]).filter(_e=>(_e.types||(_e.type?[_e.type]:[])).includes("physical"));if(ke.length){E.push({label:h("bookPage.fact.holdings"),value:ke.slice(0,2).map(He=>f(He.institution)).join("、")+(ke.length>2?h("bookPage.andMorePlaces",{n:ke.length}):"")});const _e=ke.filter(He=>He.call_number).slice(0,2).map(He=>`${f(He.institution)} ${He.call_number}`);_e.length&&E.push({label:h("bookPage.fact.callNumber"),value:_e.join(";")+(ke.filter(He=>He.call_number).length>2?"…":"")});const Ge=ke.flatMap(He=>He.seals||[]).filter(Boolean);Ge.length&&E.push({label:h("bookPage.fact.seals"),value:f(Ge.join("、"))})}else xe.length?E.push({label:h("bookPage.fact.holdings"),value:xe.slice(0,2).map(_e=>f(_e.name)).join("、")+(xe.length>2?h("bookPage.andMorePlaces",{n:xe.length}):"")}):(re=e.current_location)!=null&&re.name&&E.push({label:h("bookPage.fact.holdings"),value:f(e.current_location.name)});const G=e.physical_description;if(G){const _e=[[h("bookPage.fact.leafStyle"),G.leaf_style],[h("bookPage.fact.binding"),G.binding],[h("bookPage.fact.dimensions"),G.dimensions],[h("bookPage.fact.condition"),G.condition]];for(const[Ge,He]of _e)He&&He.trim()&&E.push({label:Ge,value:f(He)})}(Pe=e.page_count)!=null&&Pe.description&&E.push({label:m.label.pageCount,value:f(e.page_count.description)});const de=[...xo(e.additional_titles),...xo(e.attached_texts)];return de.length&&E.push({label:h("bookPage.fact.aliases"),value:de.map(f).join("、")}),E},[e,f,m,h,K,L,Z,S,o,r]),ee=f(e.title),ue=e.edition?f(e.edition):void 0,me=((H=e.lineage)==null?void 0:H.year_text)||"",be=t.jsx(An,{kind:h("bookPage.kind"),title:ee,subtitle:ue,byline:t.jsx(jr,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:o,renderLink:r}),meta:(()=>{const E=[L?f(L):"",K.era?f([K.era,K.reign].filter(Boolean).join("")):"",Z?f(Z):""].filter(Boolean);return E.length?t.jsx("span",{className:"bim-d-tags",children:E.map((oe,ae)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(ae,2)}`,children:oe},ae))}):null})(),description:(se=e.description)!=null&&se.text?t.jsx(Ct,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:Xo((ne=e.description)==null?void 0:ne.text)?6:void 0,facts:pe,readAction:s,secondaryAction:s&&P>0&&!U?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:h("bookPage.viewImages")}):void 0,foot:t.jsx(Pn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),Oe=e.contained_in||[],ie=(a==null?void 0:a.chapters)||[],Re=f(ie[0]&&Qi(ie[0].title)[0].slice(-1)||"")||h("bookPage.chapterUnit"),Le=h("bookPage.chapterCount",{n:ie.length,unit:Re}),q=!!((ge=R==null?void 0:R.derived_from)!=null&&ge.length||(Ne=R==null?void 0:R.related_to)!=null&&Ne.length||(Be=e.appendix)!=null&&Be.length),J=[],fe=h(U?"bookPage.sec.physical":"bookPage.sec.images");(ie.length||I.text.length||l)&&J.push({id:"fulltext",label:h("bookPage.sec.fulltext"),count:ie.length?Le:void 0}),I.groups.length&&J.push({id:"images",label:fe,count:P}),q&&J.push({id:"lineage",label:h("bookPage.sec.lineage")}),Oe.length&&J.push({id:"collections",label:h("section.containedIn"),count:Oe.length}),(We=e.location_history)!=null&&We.length&&J.push({id:"provenance",label:h("section.locationHistory")});const ze=E=>(d==null?void 0:d(E))??null,Y=ie[0],ve=Y?ze(Y.file):null,le=$?ie:ie.slice(0,Ux),Se=(E,oe,ae)=>E?t.jsx("a",{className:ae,href:E.href??"#",onClick:E.onClick?je=>{je.metaKey||je.ctrlKey||(je.preventDefault(),E.onClick())}:void 0,children:oe}):t.jsx("span",{className:ae,children:oe}),X=t.jsxs(t.Fragment,{children:[(ie.length>0||I.text.length>0||l)&&t.jsxs(et,{id:"fulltext",title:h("bookPage.sec.fulltext"),meta:ie.length>0?t.jsx(Je,{items:[Le,(Ue=a==null?void 0:a.source)!=null&&Ue.name?h("bookPage.sourceBy",{src:f(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!Y&&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"})]}),Y&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:h("bookPage.readFrom",{ch:f(Qi(Y.title)[0])||h("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:f((Y.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),Se(ve,t.jsxs(t.Fragment,{children:[h("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),ie.length>1&&t.jsx("ul",{className:"bim-d-chap",children:le.map(E=>{const[oe,ae]=Qi(E.title);return t.jsx("li",{children:Se(ze(E.file),t.jsxs(t.Fragment,{children:[oe&&t.jsx("b",{children:f(oe)}),f(ae||E.file)]}))},E.file)})}),ie.length>le.length&&t.jsx(qo,{label:h("detail.expandRest",{n:ie.length-le.length,unit:Re}),onClick:()=>_(!0)}),I.text.length>0&&t.jsxs(t.Fragment,{children:[(ie.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:h("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:I.text.map((E,oe)=>t.jsx(vr,{item:E,siblings:I.text,listedVolumeCounts:A},`${E.id||E.url||E.name}-${oe}`))})})]})]}),I.groups.length>0&&t.jsx(et,{id:"images",title:fe,meta:t.jsx(Je,{items:[I.groups.length>1?h("bookPage.groupCount",{n:I.groups.length}):"",h("bookPage.placeCount",{n:P})]}),children:t.jsx(Nc,{groups:I.groups,listedVolumeCounts:A})}),q&&t.jsx(et,{id:"lineage",title:h("bookPage.sec.lineage"),meta:(Qe=R==null?void 0:R.derived_from)!=null&&Qe.length?h("bookPage.lineageMeta"):void 0,action:T?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":h("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":C==="flow",onClick:()=>M("flow"),children:h("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":C==="graph",onClick:()=>M("graph"),children:h("bookPage.viewGraph")})]}):void 0,children:C==="graph"&&T?t.jsx(kr,{graph:T,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(E,oe)=>t.jsx(qe,{id:E,label:f(oe),onNavigate:o,renderLink:r,dense:!0})}):t.jsx(Yx,{data:e,heading:ue||ee,yearText:me,refName:V,onNavigate:o,renderLink:r})}),Oe.length>0&&t.jsx(et,{id:"collections",title:h("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:Oe.map((E,oe)=>{var G,de;const ae=typeof E=="string"?E:E.id,je=typeof E=="string"?[]:Tn(E.volume_index),ke=y.get(ae),xe=(ke==null?void 0:ke._member_count)||((G=ke==null?void 0:ke.books)==null?void 0:G.length)||((de=ke==null?void 0:ke.contained_works)==null?void 0:de.length)||0;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(qe,{id:ae,label:ke?f(ke.title):ae,onNavigate:o,renderLink:r,dense:!0}),je.length>0&&t.jsx(Gx,{volumes:je,unit:m.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${xe?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:xe>0&&h("bookPage.totalOf",{n:xe,unit:m.unit.bu})})]},`${ae}-${oe}`)})})})}),(ce=e.location_history)!=null&&ce.length?t.jsx(et,{id:"provenance",title:h("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((E,oe)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:f(E.name)}),([E.start_date,E.end_date].filter(Boolean).join("—")||E.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(Je,{items:[[E.start_date,E.end_date].filter(Boolean).join("—"),E.description?f(E.description):""]})})]},oe))})}):null,J.length===0&&t.jsx(et,{title:h("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:h("bookPage.emptyText")})})]}),Ce=b.findIndex(E=>E.id===e.id),Me=F.length<=ua,B=Me&&Ce>=0?b.slice(Math.max(0,Ce-ma),Ce+ma+1):b.filter(E=>E.id!==e.id),te=t.jsxs(t.Fragment,{children:[x&&t.jsxs("div",{id:"work",className:"bim-d-side",style:{scrollMarginTop:16},children:[t.jsx("h2",{className:"bim-d-ui bim-d-side-h",children:f(m.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(qe,{id:x.id,label:f(x.title),onNavigate:o,renderLink:r})}),t.jsx(Je,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(E=>`${E.dynasty?`〔${f(E.dynasty)}〕`:""}${f(E.name)}`),f(zt(x,m.unit.juan)),x._edition_count?h("bookPage.editionCount",{n:x._edition_count}):""]}),((tt=x.description)==null?void 0:tt.text)&&t.jsx("p",{style:{margin:"8px 0 0",fontSize:14,lineHeight:1.8,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},className:"bim-d-card-desc",children:f(x.description.text.replace(/[#*_>`[\]]/g,""))})]}),N>0&&B.length>0&&t.jsxs("div",{children:[t.jsx(Dt,{id:"siblings",timeline:!0,title:Me?h("bookPage.siblings"):m.relation.siblingVersions,meta:Me?h("bookPage.byEra"):h("bookPage.kindCount",{n:N}),cap:B.length,items:B.map(E=>E.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:f(E.edition||E.title||E.id)}):t.jsx(qe,{id:E.id,label:f(E.edition||E.title||E.id),onNavigate:o,renderLink:r,dense:!0})),metas:B.map(E=>[E.year!=null?E.year<0?h("detail.bce",{n:-E.year}):String(E.year):"",E.id===e.id?h("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:B.findIndex(E=>E.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(qe,{id:x.id,label:h("bookPage.viewAllInWork",{n:F.length}),onNavigate:o,renderLink:r,dense:!0})})]})]}),ye=e.work_id?t.jsx(Tl,{caption:m.section.belongsToWork,children:t.jsx(qe,{id:e.work_id,label:x?f(x.title):" ",onNavigate:o,renderLink:r,dense:!0})}):void 0;return t.jsx(Ln,{railTop:c,back:p,up:ye,nav:J,railLinks:u,main:X,card:be,side:te})};function Gx({volumes:e,unit:n}){const{t:o}=Q();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[o("bookPage.volumeRange",{range:ji(e,n),unit:n}),e.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-d-dot"}),o("bookPage.volumeCount",{n:e.length,unit:n})]})]})}function Yx({data:e,heading:n,yearText:o,refName:r,onNavigate:s,renderLink:a}){var w;const{t:l,convert:d}=Q(),c=e.lineage,p=(c==null?void 0:c.derived_from)||[],u=p.filter(b=>b.ref_type!=="book"),m=p.filter(b=>b.ref_type==="book"&&b.relation==="底本"),h=p.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),f=(c==null?void 0:c.related_to)||[],x=p.length>0||f.length>0,k=b=>b&&Vx.has(b)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${b}`)}):"",y=(b,j)=>t.jsx(qe,{id:b,label:d(j||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:[u.map((b,j)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:b.relation?d(b.relation):l("bookPage.lineage.ancestor")}),t.jsx("span",{className:"bim-d-lf-name",children:l("bookPage.lineage.reconstructed")}),b.evidence&&t.jsxs("span",{className:"bim-d-meta",children:[d(b.evidence),k(b.confidence)]})]})},`a-${j}`)),m.map((b,j)=>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,r(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),k(b.confidence)]})]})},`b-${j}`)),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}),o&&t.jsx("span",{className:"bim-d-lf-yr",children:d(o)})]}),h.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:h.map((b,j)=>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,r(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),k(b.confidence)]})]},j))})]}),f.length>0&&t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-out",children:[t.jsx("span",{className:"bim-d-lf-out-h bim-d-ui",children:l("bookPage.lineage.derivatives")}),t.jsx("span",{className:"bim-d-lf-chips",children:f.map((b,j)=>t.jsxs("span",{className:"bim-d-lf-chip",title:b.evidence?d(b.evidence):void 0,children:[y(b.book_id,r(b.book_id)),t.jsx("span",{className:"bim-d-meta",children:d(b.relation)})]},j))})]})]}),(w=e.appendix)==null?void 0:w.map((b,j)=>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(Ct,{text:b.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${j}`)),(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 _n=16,Kx=200,qx=16,Pc=({data:e,catalog:n,transport:o,onNavigate:r,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var Se,X,Ce,Me,B,te,ye;const{t:p,convert:u,messages:m}=Q(),[h,f]=g.useState(""),[x,k]=g.useState(!1),[y,w]=g.useState(null),[b,j]=g.useState(""),[S,v]=g.useState(!1),$=g.useMemo(()=>$l(e,n),[e,n]),[_,C]=g.useState(new Map),M=!!o&&$.rows.length>0&&$.rows.length<=Kx,T=M&&($.rows.length<=_n||S),z=T&&$.rows.every(H=>!H.id||_.has(H.id)),F=H=>{var se;return _o(H?(se=_.get(H))==null?void 0:se.l1:void 0)},N=g.useMemo(()=>{const H=h.trim(),se=H?u(H):"";return $.rows.filter(ne=>{var Ne,Be;if(b&&_o(ne.id?(Ne=_.get(ne.id))==null?void 0:Ne.l1:void 0)!==b)return!1;if(!se)return!0;const ge=ne.id&&((Be=_.get(ne.id))==null?void 0:Be.title)||ne.title;return u(ge).includes(se)||(ne.subItems||[]).some(We=>u(We).includes(se))})},[$.rows,h,b,_,u]),R=x?N:N.slice(0,_n),O=g.useMemo(()=>(T?$.rows:R).filter(H=>H.id&&!_.has(H.id)).map(H=>H.id),[T,$.rows,R,_]);g.useEffect(()=>{if(!o||O.length===0)return;let H=!1;const se=O.slice(0,qx);return Promise.all(se.map(ne=>o.getItem(ne).then(ge=>{var We,Ue;const Ne=ge??{},Be={title:Ne.title,edition:Ne.edition,authors:Ne.authors,measure:ge?zt(ge,m.unit.juan):void 0,versionCount:Ne._edition_count??((We=Ne.books)==null?void 0:We.length),l1:((Ue=Ne.classification)==null?void 0:Ue.l1)||void 0};return[ne,Be]}).catch(()=>[ne,{}]))).then(ne=>{H||C(ge=>{const Ne=new Map(ge);for(const[Be,We]of ne)Ne.set(Be,We);return Ne})}),()=>{H=!0}},[o,O,m.unit.juan]);const I=(e.contained_in||[])[0];g.useEffect(()=>{if(!I){w(null);return}if(w({id:I}),!o)return;let H=!1;return o.getItem(I).then(se=>{H||w({id:I,title:se==null?void 0:se.title})}).catch(()=>{}),()=>{H=!0}},[o,I]);const P=g.useMemo(()=>zc(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),U=P.text.length+P.groups.reduce((H,se)=>H+se.rows.length+se.mirrors.length,0),K=e.contained_works||[],L=new Set($.rows.map(H=>H.id).filter(Boolean)),Z=K.length>0&&!K.every(H=>L.has(H.id)),A=(()=>{const H=$.rows.map(se=>se.edition).filter(Boolean);return H.length>1&&new Set(H).size===1})(),V=$.rows.some(H=>H.volumes.length>0||H.expected!=null),pe=e._member_count||((Se=e.books)==null?void 0:Se.length)||K.length,ee=zt(e,m.unit.juan),ue=e.count,me=H=>typeof H=="number"&&Number.isFinite(H)?H:null,be=me(ue==null?void 0:ue.juan)??me((X=e.juan_count)==null?void 0:X.number),Oe=me(ue==null?void 0:ue.ce)??($.totalVolumes||null),ie=[{value:$.rows.length,label:p("collectionPage.stat.titles")},{value:be??0,label:m.unit.juan},{value:Oe??0,label:m.unit.volume}],Re=g.useMemo(()=>{var ne,ge;const H=[];if((ne=e.publication_info)!=null&&ne.details&&H.push({label:p("collectionPage.fact.publication"),value:u(e.publication_info.details)}),pe&&pe!==$.rows.length){const Ne=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");H.push({label:Ne,value:`${pe} ${m.unit.bu}`,title:p("collectionPage.memberNote")})}const se=[me(ue==null?void 0:ue.zhong)!=null?p("collectionPage.nZhong",{n:ue.zhong}):"",me(ue==null?void 0:ue.han)!=null?p("collectionPage.nHan",{n:ue.han}):""].filter(Boolean);return se.length&&H.push({label:p("collectionPage.fact.expected"),value:se.join(" ")}),be==null&&ee&&H.push({label:p("collectionPage.fact.measure"),value:u(ee),title:(ge=e.juan_count)!=null&&ge.description?u(e.juan_count.description):void 0}),H},[e,pe,$.rows.length,be,ee,ue,u,p,m]),Le=g.useMemo(()=>{if(!z)return[];const H=new Map;for(const ne of $.rows){const ge=F(ne.id);ge&&H.set(ge,(H.get(ge)??0)+1)}const se=En.filter(ne=>(H.get(ne.key)??0)>0);return se.length<2?[]:[{key:"",label:`${m.catalog.all} ${$.rows.length}`},...se.map(ne=>({key:ne.key,label:`${ne.label} ${H.get(ne.key)}`}))]},[z,$.rows,_,m]),q=g.useMemo(()=>{if(!z||!$.rows.some(ge=>ge.volumes.length>0))return null;const H=[],se=$.rows.filter(ge=>ge.volumes.length>0).map(ge=>({k:F(ge.id)??"",from:Math.min(...ge.volumes),to:Math.max(...ge.volumes)})).sort((ge,Ne)=>ge.from-Ne.from);for(const ge of se){const Ne=ge.to-ge.from+1,Be=H[H.length-1];Be&&Be.key===ge.k?(Be.to=Math.max(Be.to,ge.to),Be.n+=Ne):H.push({key:ge.k,from:ge.from,to:ge.to,n:Ne})}const ne=se.reduce((ge,Ne)=>Math.max(ge,Ne.to),0);return H.length>1&&H.some(ge=>ge.key)?{segs:H,last:ne}:null},[z,$.rows,_]),J=(Ce=e.description)==null?void 0:Ce.text,fe=t.jsx(An,{kind:p("collectionPage.kind"),title:u(e.title),byline:t.jsx(jr,{authors:e.authors,onNavigate:r,renderLink:s}),meta:t.jsx(Je,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(Me=e.publication_info)!=null&&Me.year?u(e.publication_info.year):""]}),description:J||(B=e.history)!=null&&B.length?t.jsxs(t.Fragment,{children:[J&&t.jsx(Ct,{text:J,style:{fontSize:15,lineHeight:1.85}}),(te=e.history)!=null&&te.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((H,se)=>t.jsx("li",{children:u(H)},se))}):null]}):void 0,clampDescription:Xo(J)||(((ye=e.history)==null?void 0:ye.length)??0)>2?6:void 0,stats:ie,facts:Re,foot:t.jsx(Pn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:q&&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:q.segs.map((H,se)=>{const ne=En.find(ge=>ge.key===H.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!ne,title:ne?p("collectionPage.dist.segTitle",{section:u(ne.label),from:H.from,to:H.to}):void 0,"aria-label":ne?p("collectionPage.dist.only",{section:u(ne.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!ne&&b===H.key,style:{flexGrow:H.n,background:i(ne?ne.token:"rule")},onClick:()=>{ne&&(j(b===H.key?"":H.key),k(!1))}},se)})}),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:q.last})})]})]})}),ze=[];$.rows.length&&ze.push({id:"titles",label:p("collectionPage.sec.titles"),count:$.rows.length}),U&&ze.push({id:"resources",label:p("collectionPage.sec.resources"),count:U}),Z&&ze.push({id:"works",label:m.section.containedWorks,count:K.length});const Y=t.jsxs(t.Fragment,{children:[$.rows.length>0&&t.jsxs(et,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(Je,{items:[`${$.rows.length} ${m.unit.items}`,$.totalVolumes?p("collectionPage.totalVolumes",{n:$.totalVolumes,unit:m.unit.volume}):"",N.length!==$.rows.length?p("collectionPage.currentN",{n:N.length,unit:m.unit.items}):""]}),action:a,children:[($.rows.length>_n||Le.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[Le.length>0&&t.jsx(vi,{items:Le,value:b,onChange:H=>{j(H),k(!1)}}),M&&$.rows.length>_n&&!z&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:S,onClick:()=>v(!0),title:p("collectionPage.loadAllTitle",{n:$.rows.length,unit:m.unit.items}),children:p(S?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),$.rows.length>_n&&t.jsx("input",{type:"search",className:"bim-d-find",value:h,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:H=>{f(H.target.value),k(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&ki(N.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[V&&t.jsx("th",{style:{width:"8.5em"},children:p("collectionPage.col.volumes")}),t.jsx("th",{children:p("collectionPage.col.title")}),t.jsx("th",{style:{textAlign:"right"},children:p("collectionPage.col.versions")})]})}),t.jsx("tbody",{children:R.map((H,se)=>{var Qe;const ne=H.id?_.get(H.id):void 0,ge=ne!=null&&ne.title&&H.title===H.id?ne.title:H.title,Ne=((ne==null?void 0:ne.authors)||[]).find(ce=>ce&&ce.name),Be=[Ne?`${Ne.dynasty?`〔${u(Ne.dynasty)}〕`:""}${u(Ne.name)}${Ne.role?` ${u(Ne.role)}`:""}`:"",ne!=null&&ne.measure?u(ne.measure):"",(Qe=H.subItems)!=null&&Qe.length?H.subItems.map(ce=>u(ce)).join("、"):"",(ne!=null&&ne.edition||H.edition)&&!A?u((ne==null?void 0:ne.edition)||H.edition||""):""].filter(Boolean),We=En.find(ce=>ce.key===F(H.id)),Ue=H.volumes.length>0?p("collectionPage.volumeRange",{range:ji(H.volumes,m.unit.volume),unit:m.unit.volume}):H.expected!=null?`${H.found??0}/${H.expected} ${m.unit.volume}`:"";return t.jsxs("tr",{children:[V&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Ue?"":" bim-d-zt-blank"}`,children:[We&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:i(We.token)}}),Ue||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[H.id?t.jsx(qe,{id:H.id,label:u(ge),onNavigate:r,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:u(ge)}),Be.length>0?t.jsx(Je,{items:Be}):H.id&&!ne&&o?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${ne!=null&&ne.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:ne!=null&&ne.versionCount?p("collectionPage.nZhong",{n:ne.versionCount}):""})]},`${H.id??H.title}-${se}`)})})]}),R.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!x&&t.jsx(Ko,{total:N.length,shown:R.length,unit:m.unit.items,onClick:()=>k(!0)})]}),U>0&&t.jsxs(et,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:U}),children:[P.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[P.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:P.text.map((H,se)=>t.jsx(vr,{item:H,siblings:P.text},`${H.id||H.url||H.name}-${se}`))})})]}),t.jsx(Nc,{groups:P.groups})]}),$.rows.length===0&&U===0&&t.jsx(et,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),ve=Z?t.jsx(Dt,{id:"works",title:m.section.containedWorks,meta:p("collectionPage.nZhong",{n:K.length}),cap:12,items:K.map(H=>t.jsx(qe,{id:H.id,label:u(H.title),onNavigate:r,renderLink:s,dense:!0}))}):null,le=y?t.jsx(Tl,{caption:p("collectionPage.parent"),children:t.jsx(qe,{id:y.id,label:u(y.title||y.id),onNavigate:r,renderLink:s,dense:!0})}):void 0;return t.jsx(Ln,{railTop:l,back:d,up:le,nav:ze,railLinks:c,main:Y,card:fe,side:ve})},Xx=16,eo=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function ha(e){if(!e)return eo.length;const n=eo.indexOf(e);return n===-1?eo.length:n}function Zx(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const Jx={秦:[-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]},Mc=({data:e,transport:n,onNavigate:o,renderLink:r,railTop:s,back:a,railLinks:l})=>{var le,Se,X,Ce,Me;const{t:d,convert:c,messages:p}=Q(),u=B=>Zx(B,d),[m,h]=g.useState("全部"),[f,x]=g.useState(!1),[k,y]=g.useState("default"),[w,b]=g.useState(new Map),j=g.useMemo(()=>(e.works||[]).map(B=>{const te=w.get(B.work_id);return{id:B.work_id,title:(te==null?void 0:te.title)??B.title??B.work_id,role:B.role||"",cls:Go(B.role),versionCount:te==null?void 0:te.versionCount,section:te==null?void 0:te.cls,l1:te==null?void 0:te.l1,measure:te==null?void 0:te.measure,hasImage:te==null?void 0:te.hasImage,loaded:!!(te!=null&&te.loaded)}}),[e.works,w]),S=g.useMemo(()=>_l((e.works||[]).map(B=>B.role),d("detail.roleAll")),[e.works,d]),v=g.useMemo(()=>{const B=m==="全部"?j:j.filter(te=>te.cls===m);return k==="versions"?[...B].sort((te,ye)=>(ye.versionCount??-1)-(te.versionCount??-1)):B},[j,m,k]),$=f?v:v.slice(0,Xx),_=g.useMemo(()=>$.filter(B=>!w.has(B.id)).map(B=>B.id),[$,w]);g.useEffect(()=>{if(!n||_.length===0)return;let B=!1;return Promise.all(_.map(te=>n.getItem(te).then(ye=>{var ge,Ne,Be,We,Ue;const H=ye??{},se=H._edition_count??(((ge=H.books)==null?void 0:ge.length)??0)+(((Ne=H.collections)==null?void 0:Ne.length)??0),ne=[(Be=H.classification)==null?void 0:Be.l1,(We=H.classification)==null?void 0:We.l2].filter(Boolean).join(" ");return[te,{id:te,title:H.title,versionCount:se,loaded:!0,cls:ne||void 0,l1:((Ue=H.classification)==null?void 0:Ue.l1)||void 0,measure:ye&&zt(ye,p.unit.juan)||void 0,hasImage:!!(H.has_image??H._has_image)}]}).catch(()=>[te,{id:te,loaded:!0}]))).then(te=>{B||b(ye=>{const H=new Map(ye);for(const[se,ne]of te)H.set(se,ne);return H})}),()=>{B=!0}},[n,_,p.unit.juan]);const C=g.useMemo(()=>{const B=new Map;for(const te of e.alt_names||[]){const ye=te.type||p.section.aliases;B.has(ye)||B.set(ye,[]),B.get(ye).push(te.name)}return[...B.entries()].sort((te,ye)=>ha(te[0])-ha(ye[0])).map(([te,ye])=>({label:te,names:ye}))},[e.alt_names,p]),M=e.birth_year??((le=e.dates)==null?void 0:le.birth)??void 0,T=e.death_year??((Se=e.dates)==null?void 0:Se.death)??void 0,z=(X=e.dates)==null?void 0:X.floruit,F=M!=null||T!=null?`${u(M)||"?"}—${u(T)||"?"}`:Array.isArray(z)&&z.length===2&&z.every(B=>Number.isFinite(B))?d("entityPage.floruit",{from:u(z[0]),to:u(z[1])}):"",N=new Set(["本名","字","號","号"]),R=C.filter(B=>N.has(B.label)),O=C.filter(B=>!N.has(B.label)),I=O.reduce((B,te)=>B+te.names.length,0),P=g.useMemo(()=>{const B=[];for(const ye of R)B.push({label:ye.label,value:ye.names.map(H=>c(H)).join("、")});const te=(e.works||[]).length;return te&&B.push({label:d("entityPage.fact.works"),value:d("entityPage.nZhong",{n:te})}),B},[e.works,R,c,d]),U=B=>{var te;return(te=C.find(ye=>B.includes(ye.label)))==null?void 0:te.names[0]},K=U(["字"]),L=U(["號","号"]),Z=[K?d("entityPage.zi",{name:c(K)}):"",L?d("entityPage.hao",{name:c(L)}):""].filter(Boolean).join(","),A=e.native_place,V=e.dynasty?Jx[e.dynasty]:void 0,pe=(()=>{if(!V||M==null||T==null||T<M)return null;const[B,te]=V,ye=Math.max(M,B),H=Math.min(T,te);if(H<=ye)return null;const se=te-B;return t.jsxs("div",{className:"bim-d-life bim-d-ui",children:[t.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":d("entityPage.lifeAria",{birth:u(M),death:u(T),years:T-M+1}),children:t.jsx("i",{style:{left:`${(ye-B)/se*100}%`,width:`${(H-ye)/se*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${u(B)} ${c(e.dynasty)}`}),t.jsx("span",{children:d("entityPage.lifeYears",{years:T-M+1})}),t.jsx("span",{children:u(te)})]})]})})(),ee=g.useMemo(()=>{if(!n||j.length===0||j.some(ye=>!ye.loaded))return null;const B=new Map;for(const ye of j){const H=_o(ye.l1);H&&B.set(H,(B.get(H)??0)+1)}const te=En.map(ye=>({...ye,n:B.get(ye.key)??0})).filter(ye=>ye.n>0);return te.length?te:null},[j,n]),ue=t.jsxs(An,{kind:p.entityPage.subtype[e.subtype]??d("entityPage.subtype.people"),title:c(e.primary_name||e.title),subtitle:Z||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(Je,{items:[e.dynasty?c(e.dynasty):"",F,A?d("entityPage.nativePlace",{place:c(A)}):""]}),pe]}),description:(Ce=e.description)!=null&&Ce.text?t.jsx(Ct,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:Xo((Me=e.description)==null?void 0:Me.text)?6:void 0,facts:P,foot:t.jsx(Pn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[I>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:d("entityPage.moreNames",{n:I})}),t.jsx("dl",{children:O.map(B=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:c(B.label)}),t.jsx("dd",{children:B.names.map(te=>c(te)).join("、")})]},B.label))})]}),ee&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:d("entityPage.dist")})}),t.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:ee.map(B=>t.jsx("i",{style:{flexGrow:B.n,background:i(B.token)}},B.key))}),t.jsx("div",{className:"bim-d-dist-key",children:ee.map(B=>t.jsxs("span",{children:[t.jsx("i",{style:{background:i(B.token)}}),c(B.label)," ",B.n]},B.key))})]})]}),me=g.useMemo(()=>j.filter(B=>B.loaded&&(B.versionCount??0)>0).sort((B,te)=>(te.versionCount??0)-(B.versionCount??0)).slice(0,3),[j]),be=!!n&&j.length>=3&&$.some(B=>!B.loaded),Oe=m==="全部"&&(be||me.length>=2),ie=e.external_ids||{},Re=[];ie.cbdb_id!=null&&Re.push({label:"CBDB",id:String(ie.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${ie.cbdb_id}`,note:ie.cbdb_match==="auto"?d("entityPage.autoMatch"):void 0});const Le=ie.wikidata_id;Le&&Re.push({label:"Wikidata",id:Le,href:`https://www.wikidata.org/wiki/${Le}`});const q=ie.viaf_id;q&&Re.push({label:"VIAF",id:q,href:`https://viaf.org/viaf/${q}`});const J=S.map(B=>({key:B.cls,label:`${B.label} ${B.count}`})),fe=[...Oe&&!be?[{id:"featured",label:d("entityPage.sec.featured"),count:me.length}]:[],...j.length?[{id:"works",label:d("entityPage.sec.allWorks"),count:j.length}]:[],...Re.length?[{id:"external",label:d("entityPage.sec.external"),count:Re.length}]:[]],ze=Oe?t.jsxs(et,{id:"featured",title:d("entityPage.sec.featured"),children:[t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:d("entityPage.featuredSub")}),t.jsxs("div",{className:"bim-d-picks","aria-busy":be||void 0,children:[be&&[0,1,2].map(B=>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:" "})]},B)),!be&&me.map(B=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(qe,{id:B.id,label:c(B.title),onNavigate:o,renderLink:r,dense:!0})}),t.jsx(Je,{items:[B.section?c(B.section):"",B.measure?c(B.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:B.versionCount}),t.jsx("span",{children:d("entityPage.versionsUnit")}),B.hasImage&&t.jsx("span",{className:"bim-d-flag",children:d("entityPage.hasImage")})]})]},B.id))]})]}):null,Y=j.length===0?t.jsx(et,{title:d("entityPage.sec.works"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:d("entityPage.empty")})}):t.jsxs(t.Fragment,{children:[ze,t.jsxs(et,{id:"works",title:d("entityPage.sec.works"),meta:t.jsx(Je,{items:[d("entityPage.total",{n:j.length}),v.length!==j.length?d("entityPage.current",{n:v.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[J.length>1&&t.jsx(vi,{items:J,value:m,onChange:B=>{h(B),x(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":k==="versions",onClick:()=>{k==="default"&&x(!0),y(B=>B==="default"?"versions":"default")},children:d(k==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!f&&ki(v.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:d("entityPage.col.work")}),t.jsx("th",{children:d("entityPage.col.section")}),t.jsx("th",{children:d("entityPage.col.role")}),t.jsx("th",{children:d("entityPage.col.versions")}),t.jsx("th",{"aria-label":d("entityPage.col.image")})]})}),t.jsx("tbody",{children:$.map(B=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(qe,{id:B.id,label:c(B.title),onNavigate:o,renderLink:r,dense:!0}),B.measure?t.jsx(Je,{items:[c(B.measure)]}):!B.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${B.section||B.loaded?"":" bim-d-zt-blank"}`,children:B.section?c(B.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${B.role?"":" bim-d-zt-blank"}`,children:B.role?c(B.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${B.loaded?"":" bim-d-zt-blank"}`,children:B.loaded?B.versionCount?d("entityPage.nZhong",{n:B.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:d("entityPage.notRecorded")}):""}),t.jsx("td",{className:B.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:B.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:d("entityPage.hasImage")})})]},B.id))})]}),$.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:d("entityPage.emptyRole")}),!f&&t.jsx(Ko,{total:v.length,shown:$.length,unit:d("entityPage.moreUnit"),onClick:()=>x(!0)})]})]}),ve=Re.length>0?t.jsx(Dt,{id:"external",title:d("entityPage.sec.external"),items:Re.map(B=>t.jsxs("a",{href:B.href,target:"_blank",rel:"noopener noreferrer",children:[B.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:Re.map(B=>B.id),foot:ie.cbdb_id!=null&&ie.cbdb_match==="auto"?d("entityPage.cbdbAuto"):void 0}):null;return t.jsx(Ln,{railTop:s,back:a,nav:fe,railLinks:l,main:Y,card:ue,side:ve})},wr="(max-width: 719px)",Qx=`${wr}, (pointer: coarse)`,Bc=`
|
|
1300
1302
|
.bim-ct {
|
|
1301
1303
|
display: grid; grid-template-columns: 248px minmax(0, 1fr); column-gap: 32px; align-items: start;
|
|
1302
1304
|
max-width: 1440px; margin: 0 auto; padding: 20px 32px 48px; box-sizing: border-box;
|
|
@@ -1404,7 +1406,7 @@ ${ne??""}`,load:te,files:Ne,activeFile:Q??null,activeJuan:(le==null?void 0:le.js
|
|
|
1404
1406
|
.bim-ct-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1405
1407
|
}
|
|
1406
1408
|
|
|
1407
|
-
@media ${
|
|
1409
|
+
@media ${wr} {
|
|
1408
1410
|
.bim-ct { display: block; padding: 12px 16px 40px; }
|
|
1409
1411
|
.bim-ct-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
|
|
1410
1412
|
.bim-ct-lrow > a { grid-template-columns: minmax(0, 1fr); }
|
|
@@ -1429,7 +1431,7 @@ ${ne??""}`,load:te,files:Ne,activeFile:Q??null,activeJuan:(le==null?void 0:le.js
|
|
|
1429
1431
|
}
|
|
1430
1432
|
|
|
1431
1433
|
/* 点击目标 ≥44px(Q5):触屏与窄屏 */
|
|
1432
|
-
@media ${
|
|
1434
|
+
@media ${Qx} {
|
|
1433
1435
|
.bim-ct-row { min-height: 44px; }
|
|
1434
1436
|
.bim-ct-tw { width: 44px; }
|
|
1435
1437
|
.bim-ct-pg { min-width: 44px; height: 44px; }
|
|
@@ -1455,7 +1457,7 @@ ${ne??""}`,load:te,files:Ne,activeFile:Q??null,activeJuan:(le==null?void 0:le.js
|
|
|
1455
1457
|
/* 窄屏分类抽屉:界栏下按钮和面板都有框 */
|
|
1456
1458
|
:root[data-layout="boxed"] .bim-ct-drawer-btn { border: ${i("fr-bd")}; background: ${i("fr-bg")}; }
|
|
1457
1459
|
:root[data-layout="boxed"] .bim-ct-drawer { border: ${i("fr-bd")}; }
|
|
1458
|
-
`,Dt="未分類",St="all",vr=20;function Mn(e){if(!e)return[];const n=[];for(const o of[e.l1,e.l2,e.l3,e.l4]){const r=(o??"").trim();if(!r)break;n.push(r)}return n}function Xx(e){const n=Mn(e);return n.length?n.join("/"):Dt}function Zx(e){const n=Mn(e);return n.length?n.map((o,r)=>n.slice(0,r+1).join("/")):[Dt]}function Jx(e,n=[]){const o=new Map;n.forEach((d,c)=>{const p=[d.cata_l1,d.cata_l2,d.cata_l3,d.cata_l4].filter(u=>!!u);p.forEach((u,m)=>{const h=p.slice(0,m+1).join("/");o.has(h)||o.set(h,c)})});const r=new Map;let s=0;for(const d of e){const c=Mn(d.classification);if(!c.length){s++;continue}let p=r;c.forEach((u,m)=>{const h=c.slice(0,m+1).join("/");let f=p.get(u);f||(f={id:h,label:u,count:0,children:new Map},p.set(u,f)),f.count++,p=f.children})}const a=d=>[...d.values()].sort((c,p)=>{const u=c.label===Dt?1:0,m=p.label===Dt?1:0;if(u!==m)return u-m;const h=o.get(c.id)??1/0,f=o.get(p.id)??1/0;return h!==f?h-f:c.label.localeCompare(p.label,"zh")}).map(c=>{const p={id:c.id,label:c.label,count:c.count};return c.children.size&&(p.children=a(c.children)),p}),l=a(r);return s>0&&l.push({id:Dt,label:Dt,count:s}),l}function nn(e,n){if(!n)return[];for(const o of e){if(o.id===n)return[o];if(o.children){const r=nn(o.children,n);if(r.length)return[o,...r]}}return[]}function kr(e){return e.reduce((n,o)=>n+o.count,0)}function Qx(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function eb(e){var d;const n={id:e.id,title:e.title||e.id},o=e.juan_count,r=typeof o=="number"?o:o==null?void 0:o.number;typeof r=="number"&&r>0?n.juan=r: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=Qx(typeof e.description=="string"?e.description:(d=e.description)==null?void 0:d.text);a&&(n.summary=a);const l=Mn(e.classification);return l.length&&(n.classification=l),n}function tb(e,n){const o=e.summary?0:1,r=n.summary?0:1;return o!==r?o-r:e.title.localeCompare(n.title,"zh")}function nb(e,n=vr){return Math.max(1,Math.ceil(e/n))}function Ac(e,n,o=2){if(n<=1)return[1];const r=new Set([1,n]);for(let l=e-o;l<=e+o;l++)l>=1&&l<=n&&r.add(l);const s=[...r].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 ib=()=>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 ob(e,n,o){const r=[];o&&r.push({id:St,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;r.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),r}function Pc({tree:e,selectedId:n,onSelect:o,allLabel:r,label:s}){const{t:a,convert:l}=J(),d=r===void 0?a("catalogPage.all"):r,c=s??a("catalogPage.classification"),p=g.useRef(null),u=n&&n!==St?n:null,m=d!==null,[h,f]=g.useState(()=>{const C=new Set;for(const M of nn(e,u))C.add(M.id);return C});g.useEffect(()=>{const C=nn(e,u);C.length&&f(M=>{if(C.every(z=>M.has(z.id)))return M;const T=new Set(M);for(const z of C)T.add(z.id);return T})},[e,u]);const x=g.useMemo(()=>ob(e,h,m),[e,h,m]),[k,y]=g.useState(null);g.useEffect(()=>{y(null)},[n]);const w=u??(m?St:null),b=g.useMemo(()=>{var T;const C=new Set(x.map(z=>z.id));if(k&&C.has(k))return k;if(w&&C.has(w))return w;const M=nn(e,u).map(z=>z.id).filter(z=>C.has(z));return M.length?M[M.length-1]:((T=x[0])==null?void 0:T.id)??null},[x,k,w,e,u]),j=g.useCallback((C,M)=>{f(T=>{const z=T.has(C),F=M??!z;if(F===z)return T;const N=new Set(T);return F?N.add(C):N.delete(C),N})},[]),S=g.useCallback(C=>{y(C),requestAnimationFrame(()=>{var T;const M=Array.from(((T=p.current)==null?void 0:T.querySelectorAll("[data-ct-id]"))??[]).find(z=>z.dataset.ctId===C);M==null||M.focus()})},[]),v=g.useCallback((C,M)=>{M&&j(C,!0),o(C)},[o,j]),$=g.useCallback(C=>{const M=C.target.closest("[data-ct-id]");if(!M)return;const T=M.dataset.ctId,z=x.findIndex(R=>R.id===T);if(z<0)return;const F=x[z];let N=null;switch(C.key){case"ArrowDown":N=x[Math.min(x.length-1,z+1)].id;break;case"ArrowUp":N=x[Math.max(0,z-1)].id;break;case"Home":N=x[0].id;break;case"End":N=x[x.length-1].id;break;case"ArrowRight":if(!F.hasChildren)break;h.has(T)?N=F.firstChildId:j(T,!0);break;case"ArrowLeft":F.hasChildren&&h.has(T)?j(T,!1):N=F.parentId;break;case"Enter":case" ":C.preventDefault(),v(T,F.hasChildren);return;default:return}C.preventDefault(),N&&N!==T&&S(N)},[x,h,j,S,v]),_=(C,M)=>C.map((T,z)=>{var I;const F=(I=T.children)!=null&&I.length?T.children:null,N=!!F&&h.has(T.id),R=T.id===u,O=M===1&&C.length>1&&z===C.length-1;return t.jsxs("li",{role:"treeitem","aria-level":M,"aria-expanded":F?N:void 0,"aria-selected":R,tabIndex:b===T.id?0:-1,"data-ct-id":T.id,className:O?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":M-1},onClick:()=>{y(T.id),v(T.id,!!F)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:F?P=>{P.stopPropagation(),y(T.id),j(T.id)}:void 0,children:F?t.jsx(ib,{}):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")})]}),N&&t.jsx("ul",{role:"group",children:_(F,M+1)})]},T.id)});return t.jsxs("ul",{ref:p,role:"tree","aria-label":l(c),className:"bim-ct-tree",onKeyDown:$,children:[m&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!u,tabIndex:b===St?0:-1,"data-ct-id":St,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(St),o(St)},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:kr(e).toLocaleString("en-US")})]})}),_(e,1)]})}const Mc=e=>`/item/${encodeURIComponent(e)}`;function rb(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function Bc(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function Wc({work:e,href:n}){var d,c;const{t:o,convert:r}=J(),s=Bc(e.juan,o),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:r(e.title)}),s&&t.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),a.length>0&&t.jsx("span",{className:"bim-ct-by",children:a.map((p,u)=>t.jsxs(g.Fragment,{children:[u>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",r(p.dynasty),"〕"]}),r(p.name)]},u))}),e.summary&&t.jsx("p",{className:"bim-ct-sum",children:r(e.summary)}),l.length>0&&t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>r(p)).join(" · ")})]})})}function Oc({work:e,href:n}){var d,c;const{t:o,convert:r}=J(),s=Bc(e.juan,o),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:[r(e.title),s&&t.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),t.jsx("span",{className:"bim-ct-by",children:a.map((p,u)=>t.jsxs(g.Fragment,{children:[u>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",r(p.dynasty),"〕"]}),r(p.name)]},u))}),t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>r(p)).join(" · ")})]})})}function Hc({page:e,pageCount:n,onPage:o,pageHref:r,label:s}){const{t:a,convert:l}=J();if(n<=1)return null;const d=p=>u=>{o&&(r&&!rb(u)||(u.preventDefault(),o(p)))},c=(p,u,m)=>{if(m.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:u});const h={className:"bim-ct-pg","aria-current":m.current?"page":void 0,"aria-label":m.aria};return r?t.jsx("a",{...h,href:r(p),onClick:d(p),children:u}):t.jsx("button",{type:"button",...h,onClick:m.current?void 0:d(p),children:u})};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:Ac(e,n).map((p,u)=>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${u}`))}),t.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[e," / ",n]}),c(e+1,a("catalogPage.nextPage"),{disabled:e>=n})]})}function Fc({works:e,workLink:n=Mc,emptyText:o,view:r="card",...s}){const{t:a,convert:l}=J();return t.jsxs("div",{className:"bim-ct-works",children:[e.length===0?t.jsx("p",{className:"bim-ct-empty",children:o===void 0?a("catalogPage.emptyWorks"):typeof o=="string"?l(o):o}):r==="list"?t.jsx("ul",{className:"bim-ct-list",children:e.map(d=>t.jsx(Oc,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(Wc,{work:d,href:n(d.id)},d.id))}),t.jsx(Hc,{...s})]})}const sb=()=>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 ab({tree:e,selectedId:n,page:o,pageCount:r,works:s,onSelect:a,onPage:l,searchSlot:d,workLink:c,pageHref:p,allLabel:u,allTitle:m,pageSize:h=vr,className:f,view:x,onViewChange:k}){const{t:y,convert:w}=J(),b=u===void 0?y("catalogPage.all"):u,j=m??y("catalogPage.allTitle"),v=`bim-ct-drawer-${g.useId().replace(/:/g,"")}`,[$,_]=g.useState(!1),[C,M]=g.useState("card"),T=x??C,z=P=>{M(P),k==null||k(P)},F=nn(e,n&&n!==St?n:null),N=F.length?F[F.length-1]:null,R=N?N.label:j,O=N?N.count:kr(e),I=g.useCallback(P=>{_(!1),a(P)},[a]);return t.jsxs("div",{className:f?`bim-ct ${f}`:"bim-ct","data-drawer":$?"open":"closed",children:[t.jsx("style",{children:Lc}),t.jsxs("aside",{className:"bim-ct-side","aria-label":y("catalogPage.sideNav"),children:[t.jsxs("button",{type:"button",className:"bim-ct-drawer-btn","aria-expanded":$,"aria-controls":v,onClick:()=>_(P=>!P),children:[t.jsx("span",{children:y("catalogPage.drawerLabel",{path:w(F.length?F.map(P=>P.label).join(" › "):b??j)})}),t.jsx(sb,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:v,children:[t.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),t.jsx(Pc,{tree:e,selectedId:n,onSelect:I,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:w(R)}),F.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:w(F.slice(0,-1).map(P=>P.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:O.toLocaleString("en-US"),size:h}),r>1&&y("catalogPage.statPage",{page:o,pages:r})]}),t.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":y("catalogPage.viewLabel"),children:[t.jsx("button",{type:"button","aria-pressed":T==="card",onClick:()=>z("card"),children:y("catalogPage.viewCard")}),t.jsx("button",{type:"button","aria-pressed":T==="list",onClick:()=>z("list"),children:y("catalogPage.viewList")})]})]}),d&&t.jsx("div",{className:"bim-ct-search",children:d}),t.jsx(Fc,{works:s,view:T,workLink:c,page:o,pageCount:r,onPage:l,pageHref:p})]})]})}const Bn="(max-width: 719px)",lb="(max-width: 1079px)",cb=`${Bn}, (pointer: coarse)`,db=[8,18,30,42,88],wr=`
|
|
1460
|
+
`,Ft="未分類",_t="all",Sr=20;function Bn(e){if(!e)return[];const n=[];for(const o of[e.l1,e.l2,e.l3,e.l4]){const r=(o??"").trim();if(!r)break;n.push(r)}return n}function eb(e){const n=Bn(e);return n.length?n.join("/"):Ft}function tb(e){const n=Bn(e);return n.length?n.map((o,r)=>n.slice(0,r+1).join("/")):[Ft]}function nb(e,n=[]){const o=new Map;n.forEach((d,c)=>{const p=[d.cata_l1,d.cata_l2,d.cata_l3,d.cata_l4].filter(u=>!!u);p.forEach((u,m)=>{const h=p.slice(0,m+1).join("/");o.has(h)||o.set(h,c)})});const r=new Map;let s=0;for(const d of e){const c=Bn(d.classification);if(!c.length){s++;continue}let p=r;c.forEach((u,m)=>{const h=c.slice(0,m+1).join("/");let f=p.get(u);f||(f={id:h,label:u,count:0,children:new Map},p.set(u,f)),f.count++,p=f.children})}const a=d=>[...d.values()].sort((c,p)=>{const u=c.label===Ft?1:0,m=p.label===Ft?1:0;if(u!==m)return u-m;const h=o.get(c.id)??1/0,f=o.get(p.id)??1/0;return h!==f?h-f:c.label.localeCompare(p.label,"zh")}).map(c=>{const p={id:c.id,label:c.label,count:c.count};return c.children.size&&(p.children=a(c.children)),p}),l=a(r);return s>0&&l.push({id:Ft,label:Ft,count:s}),l}function nn(e,n){if(!n)return[];for(const o of e){if(o.id===n)return[o];if(o.children){const r=nn(o.children,n);if(r.length)return[o,...r]}}return[]}function _r(e){return e.reduce((n,o)=>n+o.count,0)}function ib(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function ob(e){var d;const n={id:e.id,title:e.title||e.id},o=e.juan_count,r=typeof o=="number"?o:o==null?void 0:o.number;typeof r=="number"&&r>0?n.juan=r: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=ib(typeof e.description=="string"?e.description:(d=e.description)==null?void 0:d.text);a&&(n.summary=a);const l=Bn(e.classification);return l.length&&(n.classification=l),n}function rb(e,n){const o=e.summary?0:1,r=n.summary?0:1;return o!==r?o-r:e.title.localeCompare(n.title,"zh")}function sb(e,n=Sr){return Math.max(1,Math.ceil(e/n))}function Wc(e,n,o=2){if(n<=1)return[1];const r=new Set([1,n]);for(let l=e-o;l<=e+o;l++)l>=1&&l<=n&&r.add(l);const s=[...r].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 ab=()=>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 lb(e,n,o){const r=[];o&&r.push({id:_t,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;r.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),r}function Oc({tree:e,selectedId:n,onSelect:o,allLabel:r,label:s}){const{t:a,convert:l}=Q(),d=r===void 0?a("catalogPage.all"):r,c=s??a("catalogPage.classification"),p=g.useRef(null),u=n&&n!==_t?n:null,m=d!==null,[h,f]=g.useState(()=>{const C=new Set;for(const M of nn(e,u))C.add(M.id);return C});g.useEffect(()=>{const C=nn(e,u);C.length&&f(M=>{if(C.every(z=>M.has(z.id)))return M;const T=new Set(M);for(const z of C)T.add(z.id);return T})},[e,u]);const x=g.useMemo(()=>lb(e,h,m),[e,h,m]),[k,y]=g.useState(null);g.useEffect(()=>{y(null)},[n]);const w=u??(m?_t:null),b=g.useMemo(()=>{var T;const C=new Set(x.map(z=>z.id));if(k&&C.has(k))return k;if(w&&C.has(w))return w;const M=nn(e,u).map(z=>z.id).filter(z=>C.has(z));return M.length?M[M.length-1]:((T=x[0])==null?void 0:T.id)??null},[x,k,w,e,u]),j=g.useCallback((C,M)=>{f(T=>{const z=T.has(C),F=M??!z;if(F===z)return T;const N=new Set(T);return F?N.add(C):N.delete(C),N})},[]),S=g.useCallback(C=>{y(C),requestAnimationFrame(()=>{var T;const M=Array.from(((T=p.current)==null?void 0:T.querySelectorAll("[data-ct-id]"))??[]).find(z=>z.dataset.ctId===C);M==null||M.focus()})},[]),v=g.useCallback((C,M)=>{M&&j(C,!0),o(C)},[o,j]),$=g.useCallback(C=>{const M=C.target.closest("[data-ct-id]");if(!M)return;const T=M.dataset.ctId,z=x.findIndex(R=>R.id===T);if(z<0)return;const F=x[z];let N=null;switch(C.key){case"ArrowDown":N=x[Math.min(x.length-1,z+1)].id;break;case"ArrowUp":N=x[Math.max(0,z-1)].id;break;case"Home":N=x[0].id;break;case"End":N=x[x.length-1].id;break;case"ArrowRight":if(!F.hasChildren)break;h.has(T)?N=F.firstChildId:j(T,!0);break;case"ArrowLeft":F.hasChildren&&h.has(T)?j(T,!1):N=F.parentId;break;case"Enter":case" ":C.preventDefault(),v(T,F.hasChildren);return;default:return}C.preventDefault(),N&&N!==T&&S(N)},[x,h,j,S,v]),_=(C,M)=>C.map((T,z)=>{var I;const F=(I=T.children)!=null&&I.length?T.children:null,N=!!F&&h.has(T.id),R=T.id===u,O=M===1&&C.length>1&&z===C.length-1;return t.jsxs("li",{role:"treeitem","aria-level":M,"aria-expanded":F?N:void 0,"aria-selected":R,tabIndex:b===T.id?0:-1,"data-ct-id":T.id,className:O?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":M-1},onClick:()=>{y(T.id),v(T.id,!!F)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:F?P=>{P.stopPropagation(),y(T.id),j(T.id)}:void 0,children:F?t.jsx(ab,{}):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")})]}),N&&t.jsx("ul",{role:"group",children:_(F,M+1)})]},T.id)});return t.jsxs("ul",{ref:p,role:"tree","aria-label":l(c),className:"bim-ct-tree",onKeyDown:$,children:[m&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!u,tabIndex:b===_t?0:-1,"data-ct-id":_t,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(_t),o(_t)},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:_r(e).toLocaleString("en-US")})]})}),_(e,1)]})}const Hc=e=>`/item/${encodeURIComponent(e)}`;function cb(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function Fc(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function Dc({work:e,href:n}){var d,c;const{t:o,convert:r}=Q(),s=Fc(e.juan,o),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:r(e.title)}),s&&t.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),a.length>0&&t.jsx("span",{className:"bim-ct-by",children:a.map((p,u)=>t.jsxs(g.Fragment,{children:[u>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",r(p.dynasty),"〕"]}),r(p.name)]},u))}),e.summary&&t.jsx("p",{className:"bim-ct-sum",children:r(e.summary)}),l.length>0&&t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>r(p)).join(" · ")})]})})}function Uc({work:e,href:n}){var d,c;const{t:o,convert:r}=Q(),s=Fc(e.juan,o),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:[r(e.title),s&&t.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),t.jsx("span",{className:"bim-ct-by",children:a.map((p,u)=>t.jsxs(g.Fragment,{children:[u>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",r(p.dynasty),"〕"]}),r(p.name)]},u))}),t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>r(p)).join(" · ")})]})})}function Vc({page:e,pageCount:n,onPage:o,pageHref:r,label:s}){const{t:a,convert:l}=Q();if(n<=1)return null;const d=p=>u=>{o&&(r&&!cb(u)||(u.preventDefault(),o(p)))},c=(p,u,m)=>{if(m.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:u});const h={className:"bim-ct-pg","aria-current":m.current?"page":void 0,"aria-label":m.aria};return r?t.jsx("a",{...h,href:r(p),onClick:d(p),children:u}):t.jsx("button",{type:"button",...h,onClick:m.current?void 0:d(p),children:u})};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:Wc(e,n).map((p,u)=>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${u}`))}),t.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[e," / ",n]}),c(e+1,a("catalogPage.nextPage"),{disabled:e>=n})]})}function Gc({works:e,workLink:n=Hc,emptyText:o,view:r="card",...s}){const{t:a,convert:l}=Q();return t.jsxs("div",{className:"bim-ct-works",children:[e.length===0?t.jsx("p",{className:"bim-ct-empty",children:o===void 0?a("catalogPage.emptyWorks"):typeof o=="string"?l(o):o}):r==="list"?t.jsx("ul",{className:"bim-ct-list",children:e.map(d=>t.jsx(Uc,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(Dc,{work:d,href:n(d.id)},d.id))}),t.jsx(Vc,{...s})]})}const db=()=>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 pb({tree:e,selectedId:n,page:o,pageCount:r,works:s,onSelect:a,onPage:l,searchSlot:d,workLink:c,pageHref:p,allLabel:u,allTitle:m,pageSize:h=Sr,className:f,view:x,onViewChange:k}){const{t:y,convert:w}=Q(),b=u===void 0?y("catalogPage.all"):u,j=m??y("catalogPage.allTitle"),v=`bim-ct-drawer-${g.useId().replace(/:/g,"")}`,[$,_]=g.useState(!1),[C,M]=g.useState("card"),T=x??C,z=P=>{M(P),k==null||k(P)},F=nn(e,n&&n!==_t?n:null),N=F.length?F[F.length-1]:null,R=N?N.label:j,O=N?N.count:_r(e),I=g.useCallback(P=>{_(!1),a(P)},[a]);return t.jsxs("div",{className:f?`bim-ct ${f}`:"bim-ct","data-drawer":$?"open":"closed",children:[t.jsx("style",{children:Bc}),t.jsxs("aside",{className:"bim-ct-side","aria-label":y("catalogPage.sideNav"),children:[t.jsxs("button",{type:"button",className:"bim-ct-drawer-btn","aria-expanded":$,"aria-controls":v,onClick:()=>_(P=>!P),children:[t.jsx("span",{children:y("catalogPage.drawerLabel",{path:w(F.length?F.map(P=>P.label).join(" › "):b??j)})}),t.jsx(db,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:v,children:[t.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),t.jsx(Oc,{tree:e,selectedId:n,onSelect:I,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:w(R)}),F.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:w(F.slice(0,-1).map(P=>P.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:O.toLocaleString("en-US"),size:h}),r>1&&y("catalogPage.statPage",{page:o,pages:r})]}),t.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":y("catalogPage.viewLabel"),children:[t.jsx("button",{type:"button","aria-pressed":T==="card",onClick:()=>z("card"),children:y("catalogPage.viewCard")}),t.jsx("button",{type:"button","aria-pressed":T==="list",onClick:()=>z("list"),children:y("catalogPage.viewList")})]})]}),d&&t.jsx("div",{className:"bim-ct-search",children:d}),t.jsx(Gc,{works:s,view:T,workLink:c,page:o,pageCount:r,onPage:l,pageHref:p})]})]})}const Wn="(max-width: 719px)",ub="(max-width: 1079px)",mb=`${Wn}, (pointer: coarse)`,hb=[8,18,30,42,88],$r=`
|
|
1459
1461
|
.bim-rh { color: ${i("ink")}; font-family: ${i("font-ui")}; font-size: 14px; line-height: 1.6; }
|
|
1460
1462
|
.bim-rh *, .bim-rh *::before, .bim-rh *::after { box-sizing: border-box; }
|
|
1461
1463
|
.bim-rh a { color: ${i("accent")}; text-decoration: none; }
|
|
@@ -1603,7 +1605,7 @@ ${ne??""}`,load:te,files:Ne,activeFile:Q??null,activeJuan:(le==null?void 0:le.js
|
|
|
1603
1605
|
flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 8px; overflow: hidden;
|
|
1604
1606
|
color: ${i("ink")} !important; font-size: 13px;
|
|
1605
1607
|
}
|
|
1606
|
-
${
|
|
1608
|
+
${hb.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb, ${i("accent")} ${e}%, ${i("card-bg")}); }`).join(`
|
|
1607
1609
|
`)}
|
|
1608
1610
|
.bim-rh-band a[data-k="4"] { color: ${i("page-bg")} !important; }
|
|
1609
1611
|
.bim-rh-band a:hover { outline: 2px solid ${i("ink")}; outline-offset: -2px; }
|
|
@@ -1631,13 +1633,13 @@ ${db.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1631
1633
|
}
|
|
1632
1634
|
|
|
1633
1635
|
/* ── 中屏 ── */
|
|
1634
|
-
@media ${
|
|
1636
|
+
@media ${ub} {
|
|
1635
1637
|
.bim-rh-picks, .bim-rh-works, .bim-rh-groups, .bim-rh-bu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1636
1638
|
.bim-rh-authors { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
1637
1639
|
}
|
|
1638
1640
|
|
|
1639
1641
|
/* ── 手机 ── */
|
|
1640
|
-
@media ${
|
|
1642
|
+
@media ${Wn} {
|
|
1641
1643
|
.bim-rh-main { padding-top: 24px; }
|
|
1642
1644
|
.bim-rh-stats { gap: 4px 18px; }
|
|
1643
1645
|
.bim-rh-stats b { font-size: 16px; }
|
|
@@ -1674,7 +1676,7 @@ ${db.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1674
1676
|
}
|
|
1675
1677
|
|
|
1676
1678
|
/* 触屏或窄屏:点击目标放大到 44px */
|
|
1677
|
-
@media ${
|
|
1679
|
+
@media ${mb} {
|
|
1678
1680
|
.bim-rh-rows a, .bim-rh-bu-l a, .bim-rh-au li a, .bim-rh-chip, .bim-rh-secnav a, .bim-rh-expand { min-height: 44px; display: flex; align-items: center; }
|
|
1679
1681
|
.bim-rh-chip { display: inline-flex; }
|
|
1680
1682
|
}
|
|
@@ -1685,7 +1687,7 @@ ${db.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1685
1687
|
}
|
|
1686
1688
|
|
|
1687
1689
|
@media (prefers-reduced-motion: reduce) { .bim-rh * { scroll-behavior: auto !important; transition: none !important; } }
|
|
1688
|
-
`,pb=$o["zh-Hant"].period,Dc={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function At(e){return{...Dc,...e??{}}}function Sr(e){var o;const n=(o=e.authors)==null?void 0:o.find(r=>r==null?void 0:r.name);return n?n.dynasty?`${n.dynasty} ${n.name}`:n.name:""}function wi(e){return(e.authors??[]).filter(o=>o==null?void 0:o.name).map(o=>o.dynasty?`〔${o.dynasty}〕${o.name}`:o.name).join(" ")}function Uc(e,n=$o["zh-Hant"].shelfOther){var s;const o=[],r=new Map;for(const a of e){const l=((s=a.period_of)==null?void 0:s.trim())||n;let d=r.get(l);d||(d={label:l,items:[]},r.set(l,d),o.push(d)),d.items.push(a)}return o}function Vc(e){return Math.max(150,Array.from(e).length*18+44)}function Gc(e,n){if(n<=0||e<=0)return 0;const o=e/n;return o<.15?0:o<.35?1:o<.6?2:o<.85?3:4}const Yc=.04;function Ge(e){return e.toLocaleString("en-US")}function Kc({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,o)=>t.jsx("span",{children:n},o))})}function ot({id:e,title:n,sub:o,more:r,children:s}){const{convert:a}=J(),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)}),o&&t.jsx("span",{className:"bim-rh-sub",children:o}),r]}),t.jsx("div",{className:"bim-rh-bd",children:s})]})}function qc({counts:e}){const{t:n}=J();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:Ge(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:Ge(e.pieces)}),n("readHome.pieces")]})]})}function Xc({picks:e,links:n}){const{t:o,convert:r}=J(),s=At(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=wi(a),d=[a.type_label,a.edition].filter(Boolean).join(" · ");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-pk",href:s.read(a.id),children:[t.jsx("span",{className:"bim-rh-slip","aria-hidden":"true",children:t.jsx(Kc,{text:r(a.slip||a.title)})}),t.jsxs("span",{className:"bim-rh-pk-body",children:[d&&t.jsx("span",{className:"bim-rh-badge",children:r(d)}),t.jsx("h3",{children:r(a.title)}),l&&t.jsx("span",{className:"bim-rh-by",children:r(l)}),a.blurb&&t.jsx("p",{children:r(a.blurb)}),t.jsx("span",{className:"bim-rh-go","aria-hidden":"true",children:o("readHome.startReading")})]})]})},a.id)})}):null}function Zc(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function _r({topic:e,links:n,hint:o,legendCount:r,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=J(),c=At(n);if(!e.items.length)return null;const p=r===void 0?l("readHome.shelfLegendCount"):r,u=Uc(e.items,l("readHome.shelfOther")),m=h=>{const f=h.records?Ge(h.records):Zc(h.text_count,l),x=Sr(h),k=[d(h.title),h.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",h.records?l("readHome.spineRecords",{n:f}):f?l("readHome.spineOnSite",{n:f}):""].filter(Boolean).join(",");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-spine",href:c.read(h.id),"data-orig":h.orig?"":void 0,"aria-label":k,title:k,style:{height:Vc(h.title)},children:[t.jsx(Kc,{text:d(h.title)}),f&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":h.records?"":void 0,children:f})]})},h.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:o?d(o):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:u.map(h=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(h.label),children:h.items.map(m)}),t.jsx("span",{"aria-hidden":"true",children:d(h.label)})]},h.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(h=>t.jsx("span",{children:d(h)},h))]})]})}const ub=4,En=e=>e>ub+1;function Jc({topic:e,links:n}){const{t:o,convert:r}=J(),s=At(n),[a,l]=g.useState(!1);if(!e.items.length)return null;const d=`bim-rh-g-${e.key}`;return t.jsxs("div",{className:"bim-rh-grp","data-cap":En(e.items.length)?"":void 0,"data-open":a?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",id:d,children:[r(e.label),t.jsx("small",{className:"bim-rh-num",children:o("readHome.nWorks",{n:Ge(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=Zc(c.text_count,o),u=Sr(c);return t.jsx("li",{children:t.jsxs("a",{href:s.read(c.id),children:[t.jsx("span",{className:"bim-rh-t",children:r(c.title)}),p&&t.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:p}),u&&t.jsx("small",{children:r(u)})]})},c.id)})}),En(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":a,onClick:()=>l(c=>!c),children:a?o("action.collapse"):o("readHome.allNWorks",{n:e.items.length})})]})}function Qc({topics:e,links:n}){const o=e.filter(s=>s.shelf&&s.items.length),r=e.filter(s=>!s.shelf&&s.items.length);return!o.length&&!r.length?null:t.jsxs(t.Fragment,{children:[o.map(s=>t.jsx(_r,{topic:s,links:n},s.key)),r.length>0&&t.jsx("div",{className:"bim-rh-groups",children:r.map(s=>t.jsx(Jc,{topic:s,links:n},s.key))})]})}function ed({famous:e,links:n}){const{t:o,convert:r}=J(),s=At(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:r(a.title)}),a.authors&&t.jsx("span",{className:"bim-rh-by",children:r(a.authors)}),t.jsx("span",{className:"bim-rh-c bim-rh-num",children:o("readHome.nCopiesCard",{n:a.text_count})})]}),a.systems.map((l,d)=>t.jsxs("div",{className:"bim-rh-lin",role:"group","aria-label":l.label?r(l.label):void 0,children:[l.label&&t.jsx("small",{"aria-hidden":"true",children:r(l.label)}),l.items.map(c=>t.jsx("a",{className:"bim-rh-chip",href:s.read(c.id),title:r([c.title,c.edition].filter(Boolean).join(" · ")),children:r(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:o("readHome.workPageLink",{title:r(a.title)})})})]})},a.work_id??a.title))}):null}function $r({bu:e,unclassified:n,links:o,unclassifiedNote:r}){const{t:s,convert:a}=J(),l=At(o);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:Ge(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(u=>t.jsx("li",{children:t.jsxs("a",{href:l.node(u.id),children:[t.jsx("span",{children:a(u.label)}),t.jsx("small",{className:"bim-rh-num",children:Ge(u.count)}),t.jsx("span",{className:"bim-rh-bar","aria-hidden":"true",style:{"--bimrh-w":`${Math.round(u.count/c*100)}%`}})]})},u.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:Ge(n)})}),t.jsx("span",{children:r?a(r):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function td({periods:e,unknown:n,links:o}){const{t:r,convert:s,messages:a}=J(),l=a.readHome.period,d=At(o),c=e.filter(m=>m.count>0);if(!c.length)return null;const p=c.reduce((m,h)=>m+h.count,0),u=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 h=m.label?s(m.label):l[m.key]??s(m.key),f=m.count/p,x=r("readHome.periodItem",{label:h,n:Ge(m.count)});return t.jsx("li",{style:{flex:`0 0 ${(f*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(m.key),"data-k":Gc(m.count,u),"data-narrow":f<Yc?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:h}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(h)[0]}),t.jsx("small",{className:"bim-rh-num",children:Ge(m.count)})]})},m.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:r("readHome.periodUnknown",{n:Ge(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:r("readHome.hoverHint")})]})]})}function nd({authors:e,links:n}){const{t:o,convert:r}=J(),s=At(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:[r(a.name),a.dynasty&&t.jsx("span",{children:r(a.dynasty)}),t.jsx("small",{className:"bim-rh-num",children:o("readHome.nPieces",{n:Ge(a.count)})})]}),t.jsx("ul",{children:a.items.map(l=>t.jsx("li",{children:t.jsx("a",{href:s.read(l.id),children:r(l.title)})},l.id))}),s.author&&t.jsx("a",{className:"bim-rh-more",href:s.author(a.name),children:o("readHome.authorAll",{name:r(a.name),n:a.count})})]},a.name))}):null}const id={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function mb({sections:e,links:n,head:o,piecesMoreHref:r,className:s}){const{t:a}=J(),l=e,d=id,c=l.topics.filter(h=>!h.shelf),p={picks:l.picks.length>0,topics:c.some(h=>h.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(h=>h.count>0),pieces:l.pieces.authors.length>0},u=Object.keys(d).filter(h=>p[h]),m=h=>a(`readHome.nav.${h}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:wr}),t.jsxs("div",{className:"bim-rh-head",children:[o,t.jsx(qc,{counts:l.counts})]}),u.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":a("readHome.navLabel"),children:t.jsx("ul",{children:u.map(h=>t.jsx("li",{children:t.jsx("a",{href:`#${d[h]}`,children:m(h)})},h))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(ot,{id:d.picks,title:m("picks"),sub:a("readHome.picksSub"),children:t.jsx(Xc,{picks:l.picks,links:n})}),p.topics&&t.jsx(ot,{id:d.topics,title:m("topics"),sub:a("readHome.topicsSub"),children:t.jsx(Qc,{topics:c,links:n})}),p.famous&&t.jsx(ot,{id:d.famous,title:m("famous"),sub:a("readHome.famousSub"),children:t.jsx(ed,{famous:l.famous,links:n})}),p.sibu&&t.jsx(ot,{id:d.sibu,title:m("sibu"),sub:a("readHome.sibuSub"),children:t.jsx($r,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(ot,{id:d.period,title:m("period"),sub:a("readHome.periodSub"),children:t.jsx(td,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(ot,{id:d.pieces,title:m("pieces"),sub:a("readHome.piecesSub"),more:r?t.jsx("a",{className:"bim-rh-more",href:r,children:a("readHome.piecesMore")}):void 0,children:t.jsx(nd,{authors:l.pieces.authors,links:n})})]})]})}const hb="(max-width: 1079px)",gb=`${Bn}, (pointer: coarse)`,od=`
|
|
1690
|
+
`,gb=To["zh-Hant"].period,Yc={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function Lt(e){return{...Yc,...e??{}}}function Cr(e){var o;const n=(o=e.authors)==null?void 0:o.find(r=>r==null?void 0:r.name);return n?n.dynasty?`${n.dynasty} ${n.name}`:n.name:""}function _i(e){return(e.authors??[]).filter(o=>o==null?void 0:o.name).map(o=>o.dynasty?`〔${o.dynasty}〕${o.name}`:o.name).join(" ")}function Kc(e,n=To["zh-Hant"].shelfOther){var s;const o=[],r=new Map;for(const a of e){const l=((s=a.period_of)==null?void 0:s.trim())||n;let d=r.get(l);d||(d={label:l,items:[]},r.set(l,d),o.push(d)),d.items.push(a)}return o}function qc(e){return Math.max(150,Array.from(e).length*18+44)}function Xc(e,n){if(n<=0||e<=0)return 0;const o=e/n;return o<.15?0:o<.35?1:o<.6?2:o<.85?3:4}const Zc=.04;function Ve(e){return e.toLocaleString("en-US")}function Jc({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,o)=>t.jsx("span",{children:n},o))})}function rt({id:e,title:n,sub:o,more:r,children:s}){const{convert:a}=Q(),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)}),o&&t.jsx("span",{className:"bim-rh-sub",children:o}),r]}),t.jsx("div",{className:"bim-rh-bd",children:s})]})}function Qc({counts:e}){const{t:n}=Q();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:Ve(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:Ve(e.pieces)}),n("readHome.pieces")]})]})}function ed({picks:e,links:n}){const{t:o,convert:r}=Q(),s=Lt(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=_i(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(Jc,{text:r(a.slip||a.title)})}),t.jsxs("span",{className:"bim-rh-pk-body",children:[d&&t.jsx("span",{className:"bim-rh-badge",children:r(d)}),t.jsx("h3",{children:r(a.title)}),l&&t.jsx("span",{className:"bim-rh-by",children:r(l)}),a.blurb&&t.jsx("p",{children:r(a.blurb)}),t.jsx("span",{className:"bim-rh-go","aria-hidden":"true",children:o("readHome.startReading")})]})]})},a.id)})}):null}function td(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function zr({topic:e,links:n,hint:o,legendCount:r,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=Q(),c=Lt(n);if(!e.items.length)return null;const p=r===void 0?l("readHome.shelfLegendCount"):r,u=Kc(e.items,l("readHome.shelfOther")),m=h=>{const f=h.records?Ve(h.records):td(h.text_count,l),x=Cr(h),k=[d(h.title),h.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",h.records?l("readHome.spineRecords",{n:f}):f?l("readHome.spineOnSite",{n:f}):""].filter(Boolean).join(",");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-spine",href:c.read(h.id),"data-orig":h.orig?"":void 0,"aria-label":k,title:k,style:{height:qc(h.title)},children:[t.jsx(Jc,{text:d(h.title)}),f&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":h.records?"":void 0,children:f})]})},h.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:o?d(o):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:u.map(h=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(h.label),children:h.items.map(m)}),t.jsx("span",{"aria-hidden":"true",children:d(h.label)})]},h.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(h=>t.jsx("span",{children:d(h)},h))]})]})}const fb=4,In=e=>e>fb+1;function nd({topic:e,links:n}){const{t:o,convert:r}=Q(),s=Lt(n),[a,l]=g.useState(!1);if(!e.items.length)return null;const d=`bim-rh-g-${e.key}`;return t.jsxs("div",{className:"bim-rh-grp","data-cap":In(e.items.length)?"":void 0,"data-open":a?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",id:d,children:[r(e.label),t.jsx("small",{className:"bim-rh-num",children:o("readHome.nWorks",{n:Ve(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=td(c.text_count,o),u=Cr(c);return t.jsx("li",{children:t.jsxs("a",{href:s.read(c.id),children:[t.jsx("span",{className:"bim-rh-t",children:r(c.title)}),p&&t.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:p}),u&&t.jsx("small",{children:r(u)})]})},c.id)})}),In(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":a,onClick:()=>l(c=>!c),children:a?o("action.collapse"):o("readHome.allNWorks",{n:e.items.length})})]})}function id({topics:e,links:n}){const o=e.filter(s=>s.shelf&&s.items.length),r=e.filter(s=>!s.shelf&&s.items.length);return!o.length&&!r.length?null:t.jsxs(t.Fragment,{children:[o.map(s=>t.jsx(zr,{topic:s,links:n},s.key)),r.length>0&&t.jsx("div",{className:"bim-rh-groups",children:r.map(s=>t.jsx(nd,{topic:s,links:n},s.key))})]})}function od({famous:e,links:n}){const{t:o,convert:r}=Q(),s=Lt(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:r(a.title)}),a.authors&&t.jsx("span",{className:"bim-rh-by",children:r(a.authors)}),t.jsx("span",{className:"bim-rh-c bim-rh-num",children:o("readHome.nCopiesCard",{n:a.text_count})})]}),a.systems.map((l,d)=>t.jsxs("div",{className:"bim-rh-lin",role:"group","aria-label":l.label?r(l.label):void 0,children:[l.label&&t.jsx("small",{"aria-hidden":"true",children:r(l.label)}),l.items.map(c=>t.jsx("a",{className:"bim-rh-chip",href:s.read(c.id),title:r([c.title,c.edition].filter(Boolean).join(" · ")),children:r(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:o("readHome.workPageLink",{title:r(a.title)})})})]})},a.work_id??a.title))}):null}function Tr({bu:e,unclassified:n,links:o,unclassifiedNote:r}){const{t:s,convert:a}=Q(),l=Lt(o);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:Ve(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(u=>t.jsx("li",{children:t.jsxs("a",{href:l.node(u.id),children:[t.jsx("span",{children:a(u.label)}),t.jsx("small",{className:"bim-rh-num",children:Ve(u.count)}),t.jsx("span",{className:"bim-rh-bar","aria-hidden":"true",style:{"--bimrh-w":`${Math.round(u.count/c*100)}%`}})]})},u.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:Ve(n)})}),t.jsx("span",{children:r?a(r):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function rd({periods:e,unknown:n,links:o}){const{t:r,convert:s,messages:a}=Q(),l=a.readHome.period,d=Lt(o),c=e.filter(m=>m.count>0);if(!c.length)return null;const p=c.reduce((m,h)=>m+h.count,0),u=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 h=m.label?s(m.label):l[m.key]??s(m.key),f=m.count/p,x=r("readHome.periodItem",{label:h,n:Ve(m.count)});return t.jsx("li",{style:{flex:`0 0 ${(f*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(m.key),"data-k":Xc(m.count,u),"data-narrow":f<Zc?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:h}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(h)[0]}),t.jsx("small",{className:"bim-rh-num",children:Ve(m.count)})]})},m.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:r("readHome.periodUnknown",{n:Ve(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:r("readHome.hoverHint")})]})]})}function sd({authors:e,links:n}){const{t:o,convert:r}=Q(),s=Lt(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:[r(a.name),a.dynasty&&t.jsx("span",{children:r(a.dynasty)}),t.jsx("small",{className:"bim-rh-num",children:o("readHome.nPieces",{n:Ve(a.count)})})]}),t.jsx("ul",{children:a.items.map(l=>t.jsx("li",{children:t.jsx("a",{href:s.read(l.id),children:r(l.title)})},l.id))}),s.author&&t.jsx("a",{className:"bim-rh-more",href:s.author(a.name),children:o("readHome.authorAll",{name:r(a.name),n:a.count})})]},a.name))}):null}const ad={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function xb({sections:e,links:n,head:o,piecesMoreHref:r,className:s}){const{t:a}=Q(),l=e,d=ad,c=l.topics.filter(h=>!h.shelf),p={picks:l.picks.length>0,topics:c.some(h=>h.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(h=>h.count>0),pieces:l.pieces.authors.length>0},u=Object.keys(d).filter(h=>p[h]),m=h=>a(`readHome.nav.${h}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:$r}),t.jsxs("div",{className:"bim-rh-head",children:[o,t.jsx(Qc,{counts:l.counts})]}),u.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":a("readHome.navLabel"),children:t.jsx("ul",{children:u.map(h=>t.jsx("li",{children:t.jsx("a",{href:`#${d[h]}`,children:m(h)})},h))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(rt,{id:d.picks,title:m("picks"),sub:a("readHome.picksSub"),children:t.jsx(ed,{picks:l.picks,links:n})}),p.topics&&t.jsx(rt,{id:d.topics,title:m("topics"),sub:a("readHome.topicsSub"),children:t.jsx(id,{topics:c,links:n})}),p.famous&&t.jsx(rt,{id:d.famous,title:m("famous"),sub:a("readHome.famousSub"),children:t.jsx(od,{famous:l.famous,links:n})}),p.sibu&&t.jsx(rt,{id:d.sibu,title:m("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(Tr,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(rt,{id:d.period,title:m("period"),sub:a("readHome.periodSub"),children:t.jsx(rd,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(rt,{id:d.pieces,title:m("pieces"),sub:a("readHome.piecesSub"),more:r?t.jsx("a",{className:"bim-rh-more",href:r,children:a("readHome.piecesMore")}):void 0,children:t.jsx(sd,{authors:l.pieces.authors,links:n})})]})]})}const bb="(max-width: 1079px)",yb=`${Wn}, (pointer: coarse)`,ld=`
|
|
1689
1691
|
/* ── 页首:检索(宿主插槽)+类型签|最近浏览 ── */
|
|
1690
1692
|
.bim-mh-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 16px 48px; align-items: start; padding-top: 8px; }
|
|
1691
1693
|
.bim-mh-q { min-width: 0; }
|
|
@@ -1825,7 +1827,7 @@ ${db.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1825
1827
|
.bim-mh-cc0 { display: inline-block; margin-right: 8px; padding: 1px 7px; font-size: 11.5px; letter-spacing: 0.08em; background: ${i("check-fine-bg")}; color: ${i("check-fine-fg")}; }
|
|
1826
1828
|
|
|
1827
1829
|
/* ── 中屏 ── */
|
|
1828
|
-
@media ${
|
|
1830
|
+
@media ${bb} {
|
|
1829
1831
|
.bim-mh-head, .bim-mh-zhi { grid-template-columns: minmax(0, 1fr); }
|
|
1830
1832
|
.bim-mh-cg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1831
1833
|
.bim-mh-lin { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
@@ -1835,7 +1837,7 @@ ${db.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1835
1837
|
}
|
|
1836
1838
|
|
|
1837
1839
|
/* ── 手机 ── */
|
|
1838
|
-
@media ${
|
|
1840
|
+
@media ${Wn} {
|
|
1839
1841
|
.bim-mh-cg, .bim-mh-data { grid-template-columns: minmax(0, 1fr); }
|
|
1840
1842
|
.bim-mh-ge { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
|
1841
1843
|
.bim-mh-lin { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
@@ -1852,8 +1854,8 @@ ${db.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1852
1854
|
.bim-mh-tbl tr > :nth-child(2), .bim-mh-tbl tr > :nth-child(3) { display: none; }
|
|
1853
1855
|
}
|
|
1854
1856
|
|
|
1855
|
-
@media ${
|
|
1857
|
+
@media ${yb} {
|
|
1856
1858
|
.bim-mh-recent li a, .bim-mh-types a, .bim-mh-tl-list a { min-height: 44px; align-items: center; }
|
|
1857
1859
|
.bim-mh-recent-h button { min-height: 44px; }
|
|
1858
1860
|
}
|
|
1859
|
-
`,rd={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function Pt(e){return{...rd,...e??{}}}function sd(e,n){if(e.lineage)return e.lineage(n);const o=e.item(n),r=o.indexOf("#"),[s,a]=r<0?[o,""]:[o.slice(0,r),o.slice(r)];return`${s}${s.includes("?")?"&":"?"}tab=lineage${a}`}function Cr(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function ad(e){const n=e.filter(p=>Number.isFinite(p.birth_year)||Number.isFinite(p.death_year)),o=e.filter(p=>!n.includes(p));if(!n.length)return{min:0,max:0,placed:[],missing:o};const r=p=>{const u=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(u,m),Math.max(u,m)]},s=n.map(r),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,u)=>({p,from:s[u][0],to:s[u][1]})).sort((p,u)=>p.from-u.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:o}}function ai(e,n=cn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function fb(e){return{read:e.item,work:e.item,node:e.node}}function ld({counts:e,links:n}){const{t:o}=J(),r=n==null?void 0:n.type;if(!r)return null;const s=[["all",o("metaHome.typeAll"),null],["work",o("metaHome.typeLabel.work"),e.works],["book",o("metaHome.typeLabel.book"),e.books],["collection",o("metaHome.typeLabel.collection"),e.collections],["entity",o("metaHome.typeLabel.entity"),e.entities]];return t.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":o("metaHome.typeChipsLabel"),children:s.map(([a,l,d])=>t.jsx("li",{children:t.jsxs("a",{href:r(a),children:[t.jsx("b",{children:l}),d!=null&&d>0&&t.jsx("small",{children:Ge(d)})]})},a))})}function cd(e,n=5){const[o,r]=g.useState(null);g.useEffect(()=>{let a=!1;const l=Lt().slice(0,n);if(!l.length||!e){r([]);return}return Promise.all(l.map(d=>Lo(e,d))).then(d=>{a||r(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=g.useCallback(()=>{Ro(),r([])},[]);return{entries:o,clear:s}}function xb(e,n,o){const r=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return r?o(r):dd(e.type,n)}function dd(e,n){return n(`metaHome.typeLabel.${e}`)}function pd({entries:e,onClear:n,links:o}){const{t:r,convert:s}=J(),a=Pt(o);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:r("metaHome.recentTitle")}),e&&e.length>0&&n&&t.jsx("button",{type:"button",onClick:n,children:r("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":r("metaHome.recentItemLabel",{type:l.type?dd(l.type,r):"",title:s(l.title)}),children:[t.jsx("i",{className:"bim-mh-ty","aria-hidden":"true",children:l.type?r(`metaHome.typeShort.${l.type}`):""}),t.jsx("span",{children:s(l.title)}),t.jsx("small",{"aria-hidden":"true",children:xb(l,r,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:r("metaHome.recentEmpty")})]})}function ud(e,n,o,r=!1){return r&&(e==="done"||e==="in_progress")?n(`metaHome.siteStatus.${e}`):e==="done"||e==="in_progress"||e==="todo"?n(`metaHome.status.${e}`):o(e)}function md({rows:e,links:n}){const{t:o,convert:r}=J(),s=Pt(n);return e.length?t.jsx("div",{className:"bim-mh-tbl-wrap",tabIndex:0,role:"region","aria-label":o("metaHome.catalogTitle"),children:t.jsxs("table",{className:"bim-mh-tbl",children:[t.jsxs("caption",{children:[o("metaHome.catalogTitle"),t.jsx("small",{children:o("metaHome.catalogNote")})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:o("metaHome.colCatalog")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colRecords")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colMatched")}),t.jsx("th",{scope:"col",children:o("metaHome.colProgress")}),t.jsx("th",{scope:"col",children:o("metaHome.colStatus")})]})}),t.jsx("tbody",{children:e.map(a=>{const l=Cr(a.imported,a.total),d=a.work_id??a.collection_id,c=r(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:Ge(a.total)}),t.jsx("td",{className:"bim-mh-r",children:Ge(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:ud(a.status,o,r)})})]},a.id||a.name)})})]})}):null}function hd({items:e,links:n,label:o}){const{convert:r}=J();return t.jsx("ul",{className:"bim-rh-rows","aria-label":o?r(o):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:r(s.title)}),s.sub&&t.jsx("small",{children:r(s.sub)})]})},s.id))})}function gd({works:e,links:n}){const{t:o}=J(),[r,s]=g.useState(!1);if(!e.length)return null;const a=En(e.length);return t.jsxs("div",{className:"bim-rh-grp","data-cap":a?"":void 0,"data-open":r?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[o("metaHome.relatedTitle"),t.jsx("small",{children:o("metaHome.relatedNote")})]}),t.jsx(hd,{items:e.map(l=>({id:l.id,title:l.title,sub:wi(l)||void 0})),links:Pt(n)}),a&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":r,onClick:()=>s(l=>!l),children:r?o("action.collapse"):o("metaHome.allNWorks",{n:e.length})})]})}const fd="siku_qige";function bb({group:e,links:n}){const{t:o,convert:r}=J(),[s,a]=g.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":En(e.items.length)?"":void 0,"data-open":s?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[r(e.label),t.jsx("small",{className:"bim-rh-num",children:o("metaHome.nKinds",{n:e.items.length})})]}),t.jsx(hd,{items:e.items,links:n,label:e.label}),En(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":s,onClick:()=>a(l=>!l),children:s?o("action.collapse"):o("metaHome.allNKinds",{n:e.items.length})})]})}function xd({groups:e,links:n}){const{t:o,convert:r}=J(),s=Pt(n);if(!e.length)return null;const a=e.find(c=>c.key===fd),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:[r(a.label),t.jsx("small",{children:r(a.items.map(c=>d(c.title)).join("、"))})]}),t.jsx("ul",{className:"bim-mh-ge","aria-label":r(a.label),children:a.items.map(c=>t.jsx("li",{children:t.jsxs("a",{href:s.item(c.id),"aria-label":r(c.title),title:r(c.title),children:[t.jsx("span",{"aria-hidden":"true",children:r(d(c.title))}),d(c.title)!==c.title&&t.jsx("small",{"aria-hidden":"true",children:o("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(bb,{group:c,links:s},c.key))})]})}const pa=34,ua=13;function ma(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?ai(e.birth_year,n):"?"}–${e.death_year!=null?ai(e.death_year,n):"?"}`}function yb(e,n){const o=n-e,r=o>1200?300:o>400?100:50,s=[];for(let a=Math.ceil(e/r)*r;a<=n;a+=r)s.push(a);return s}function bd({people:e,links:n}){const{t:o,convert:r}=J(),s=Pt(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=ad(e),p=[],u=d.map(h=>{const f=h.left>70,x=f?Math.min(h.left,h.left+h.width-ua):h.left;let k=0;for(;p[k]!=null&&p[k]>x;)k++;return p[k]=f?h.left+h.width:h.left+Math.max(h.width,ua),{...h,lane:k,end:f}}),m=Math.max(1,l-a);return t.jsxs(t.Fragment,{children:[u.length>0&&t.jsxs("div",{className:"bim-mh-tl",children:[t.jsx("ul",{className:"bim-mh-tl-rows",style:{height:p.length*pa+10},children:u.map(h=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":h.end?"":void 0,style:{left:`${h.left}%`,top:h.lane*pa+4,width:`${Math.max(h.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(h.p.id),children:[r(h.p.name),t.jsx("small",{className:"bim-rh-num",children:ma(h.p,o)})]})]},h.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:yb(a,l).map(h=>t.jsx("span",{style:{left:`${(h-a)/m*100}%`},children:ai(h,o)},h))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":u.length?void 0:"",children:(u.length?e:c).map(h=>t.jsx("li",{children:t.jsxs("a",{href:s.item(h.id),children:[t.jsx("span",{children:r(h.name)}),t.jsx("small",{className:"bim-rh-num",children:[h.dynasty?r(h.dynasty):"",ma(h,o)].filter(Boolean).join(" ")})]})},h.id))}),c.length>0&&u.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:o("metaHome.missingLife",{names:r(c.map(h=>h.name).join("、"))})})]})}const jb=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 yd({works:e,links:n}){const{t:o,convert:r}=J(),s=Pt(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=wi(a);return t.jsx("li",{children:t.jsxs("a",{href:sd(s,a.id),children:[jb,t.jsx("b",{children:r(a.title)}),l&&t.jsx("small",{children:r(l)}),t.jsx("span",{children:o("metaHome.viewLineage")})]})},a.id)})}):null}function jd({sites:e}){const{t:n,convert:o}=J(),r=e.filter(a=>a.status!=="todo"&&a.total>0),s=e.filter(a=>!r.includes(a));return e.length?t.jsxs(t.Fragment,{children:[r.length>0&&t.jsx("ul",{className:"bim-mh-cov",children:r.map(a=>{const l=Cr(a.imported,a.total);return t.jsxs("li",{children:[a.url?t.jsx("a",{href:a.url,rel:"noopener noreferrer",target:"_blank",children:o(a.name)}):t.jsx("span",{children:o(a.name)}),t.jsx("span",{className:"bim-mh-bar","aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[`${Ge(a.imported)} / ${Ge(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:ud(a.status,n,o,!0)})]})]},a.id||a.name)})}),s.length>0&&t.jsx("p",{className:"bim-mh-todo",children:n("metaHome.plannedSites",{names:o(s.map(a=>a.name).join("、"))})})]}):null}const ha=["extant","partially_extant","lost","unknown"];function vd({stats:e,links:n,version:o,repoUrl:r,downloadHref:s}){const{t:a}=J(),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=ha.some(p=>{var u;return(((u=e.loss)==null?void 0:u[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,u])=>t.jsxs("li",{children:[t.jsx("b",{className:"bim-rh-num",children:Ge(p)}),t.jsx("span",{children:u})]},u))})]}),d&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.byLoss")}),t.jsx("ul",{className:"bim-mh-loss",children:ha.map(p=>{var h;const u=((h=e.loss)==null?void 0:h[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&&u>0?a("metaHome.lossCount",{n:Ge(u),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"),r?t.jsx("a",{href:r,children:t.jsx("code",{children:"book-index"})}):t.jsx("code",{children:"book-index"}),a("metaHome.repoNote")]}),o&&t.jsxs("p",{children:[a("metaHome.version"),t.jsx("code",{children:o})]}),s&&t.jsx("p",{children:t.jsx("a",{href:s,children:a("metaHome.download")})})]})]})}const kd={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function vb({sections:e,links:n,head:o,transport:r,catalogHref:s,collectionsHref:a,entitiesHref:l,version:d,repoUrl:c,downloadHref:p,className:u}){var v,$;const{t:m}=J(),h=e,f=Pt(n),x=fb(f),k=kd,y=cd(r),w={zhi:!!((v=h.shelf)!=null&&v.items.length)||h.catalog_progress.length>0||h.related_catalogs.length>0,sibu:h.bu.length>0||h.unclassified>0,cong:h.collection_groups.length>0,people:h.bibliographers.length>0,lineage:h.lineage.length>0,sites:h.sites.length>0,data:!0},b=Object.keys(k).filter(_=>w[_]),j=_=>m(`metaHome.nav.${_}`),S=(_,C)=>_?t.jsx("a",{className:"bim-rh-more",href:_,children:C}):void 0;return t.jsxs("div",{className:u?`bim-rh bim-mh ${u}`:"bim-rh bim-mh",children:[t.jsx("style",{children:wr+od}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[o,t.jsx(ld,{counts:h.counts,links:n})]}),r&&t.jsx(pd,{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(_=>t.jsx("li",{children:t.jsx("a",{href:`#${k[_]}`,children:j(_)})},_))})}),t.jsxs("div",{className:"bim-rh-main",children:[w.zhi&&t.jsxs(ot,{id:k.zhi,title:j("zhi"),sub:m("metaHome.zhiSub"),children:[h.shelf&&h.shelf.items.length>0&&t.jsx(_r,{topic:{key:"shelf",label:h.shelf.label,shelf:!0,items:h.shelf.items},links:x,showTitle:!1,legendCount:h.shelf.items.some(_=>_.records)?m("metaHome.shelfLegendCount"):null,legendExtra:[m("metaHome.shelfLegendClick")]}),(h.catalog_progress.length>0||h.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:($=h.shelf)!=null&&$.items.length?void 0:{marginTop:0},children:[t.jsx(md,{rows:h.catalog_progress,links:n}),t.jsx(gd,{works:h.related_catalogs,links:n})]})]}),w.sibu&&t.jsx(ot,{id:k.sibu,title:j("sibu"),sub:m("metaHome.sibuSub"),more:S(s,m("metaHome.toCatalog")),children:t.jsx($r,{bu:h.bu,unclassified:h.unclassified,links:x,unclassifiedNote:m("metaHome.unclassifiedNote")})}),w.cong&&t.jsx(ot,{id:k.cong,title:j("cong"),sub:m("metaHome.congSub"),more:S(a,m("metaHome.allNKindsMore",{n:Ge(h.counts.collections)})),children:t.jsx(xd,{groups:h.collection_groups,links:n})}),w.people&&t.jsx(ot,{id:k.people,title:j("people"),sub:m("metaHome.peopleSub"),more:S(l,m("metaHome.allNPeopleMore",{n:Ge(h.counts.entities)})),children:t.jsx(bd,{people:h.bibliographers,links:n})}),w.lineage&&t.jsx(ot,{id:k.lineage,title:j("lineage"),sub:m("metaHome.lineageSub"),children:t.jsx(yd,{works:h.lineage,links:n})}),w.sites&&t.jsx(ot,{id:k.sites,title:j("sites"),sub:m("metaHome.sitesSub"),children:t.jsx(jd,{sites:h.sites})}),t.jsx(ot,{id:k.data,title:j("data"),sub:m("metaHome.dataSub"),children:t.jsx(vd,{stats:h.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const wo=({style:e})=>{const n=g.useContext(Yt),{t:o}=J();if(!n)return null;const{locale:r,setLocale:s}=n,a=r==="zh-Hant",l=()=>s(a?"zh-Hans":"zh-Hant");return t.jsxs("button",{type:"button",onClick:l,title:o(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 ${i("border")}`,borderRadius:"4px",background:i("bg"),color:i("fg"),cursor:"pointer",userSelect:"none",...e},children:[t.jsx("span",{style:{color:a?i("primary"):void 0,fontWeight:a?700:400},children:o("common.localeShortHant")}),t.jsx("span",{style:{opacity:.3},children:"/"}),t.jsx("span",{style:{color:a?void 0:i("primary"),fontWeight:a?400:700},children:o("common.localeShortHans")})]})},So=({href:e,label:n,size:o=16,className:r,style:s})=>{const{t:a}=J(),l=n??a("common.repoSourceLink");return t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:l,"aria-label":l,className:r,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:o+8,height:o+8,borderRadius:4,color:i("desc-fg"),textDecoration:"none",transition:"color 120ms, background 120ms",...s},onMouseEnter:d=>{d.currentTarget.style.color=i("fg")},onMouseLeave:d=>{d.currentTarget.style.color=i("desc-fg")},children:t.jsx("svg",{width:o,height:o,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 Ji(e){const n=e.text_count;return typeof n=="number"&&n>0}function Qi(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function kb(e,n){if(!n)return!1;const o=n.id;return o===void 0||o===e}const wb=({id:e,transport:n,initialDetail:o,initialEntry:r,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:u,onLineageCollectionChange:m,initialPage:h=1,selectedLineageNodeId:f,onNavigate:x,onBack:k,backLabel:y,renderLink:w,enrichDetail:b,getSourceLink:j,readLink:S,railTop:v,extraTabs:$=[],showFeedbackTab:_=!0,feedbackApiUrl:C,height:M,footerExtra:T,hideHeaderControls:z=!1,className:F,style:N})=>{const R=$e(),{t:O,convert:I}=J(),[P]=g.useState(()=>{if(!kb(e,o))return null;const G={...o},ue=r??Qi(e,G);return b&&b(ue,G),{id:e,entry:ue,detail:G}}),[U,K]=g.useState((P==null?void 0:P.entry)??null),[L,Z]=g.useState((P==null?void 0:P.detail)??null),[A,V]=g.useState(!P),[ce,ne]=g.useState(!1),[de,pe]=g.useState([]),[be,Oe]=g.useState(!1),[ie,Le]=g.useState(null),[Ae,q]=g.useState(null),[Q,fe]=g.useState(null),[ze,Y]=g.useState(!1),ve=g.useRef(null),le=g.useRef(0),[Se,X]=g.useState(null),Ce=l!==void 0?l:Se,Me=g.useCallback(G=>{d?d(G):X(G)},[d]),B=g.useCallback(async G=>{if(!n.getCollectionCatalogs&&!n.getCollectionCatalog){pe([]);return}Oe(!0);try{if(n.getCollectionCatalogs)pe(await n.getCollectionCatalogs(G)||[]);else if(n.getCollectionCatalog){const ue=await n.getCollectionCatalog(G);pe(ue?[{resource_id:"",data:ue}]:[])}}catch{pe([])}finally{Oe(!1)}},[n]),ee=g.useCallback(async G=>{var ue,Te;if(!n.getTextManifest||!n.getTextIndex){Le(null),q(G);return}try{const Ee=we.pickTextVersion(await n.getTextManifest(G)),D=Ee?await n.getTextIndex(G,Ee.key):null;Le(D&&D.chapters.length>0?{chapters:D.chapters.map(re=>({n:re.n,title:re.title,file:re.file})),source:{name:((ue=D.source)==null?void 0:ue.name)??(Ee==null?void 0:Ee.source_name),license:((Te=D.source)==null?void 0:Te.license)??(Ee==null?void 0:Ee.license)??void 0}}:null)}catch{Le(null)}finally{q(G)}},[n]),ye=g.useCallback(async(G,ue)=>{const Te=++le.current,Ee=()=>Te!==le.current;Y(!0);try{if(n.getLineageGraph){const He=await n.getLineageGraph(G);if(Ee())return;He&&fe(He)}const D=ue.version_graph;if(!D||!D.enabled){Q||fe(null),ve.current=null;return}const re=ue.books??[],Pe=[];for(const He of re)try{const Fe=await n.getItem(He);Fe&&Pe.push(Fe)}catch{}if(Ee())return;ve.current={work:ue,books:Pe};const _e=u??D.default_collection??(D.core_books&&D.core_books.length>0?"core":"all"),Ye=_e==="core"&&Array.isArray(D.core_books)&&D.core_books.length>0?"core":_e??"all";fe(ei(ue,Pe,Ye))}catch{if(Ee())return;fe(null),ve.current=null}finally{Ee()||Y(!1)}},[n]),H=g.useRef({initialDetail:o,initialEntry:r});H.current={initialDetail:o,initialEntry:r},g.useEffect(()=>{let G=!1;le.current++,Y(!1);const ue=re=>{re.type==="collection"?B(e):re.type==="work"?(re.version_graph||n.getLineageGraph)&&ye(e,re):re.type==="book"&&Ji(re)&&ee(e)},Te=H.current;let Ee=null;if(P&&P.id===e)Ee=P;else if(Te.initialDetail&&Te.initialDetail.id===e){const re={...Te.initialDetail},Pe=Te.initialEntry??Qi(e,re);b&&b(Pe,re),Ee={entry:Pe,detail:re}}return Ee?(ne(!1),pe(re=>re.length?[]:re),Le(null),fe(null),ve.current=null,K(Ee.entry),Z(Ee.detail),V(!1),ue(Ee.detail),()=>{G=!0}):((async()=>{V(!0),ne(!1),K(null),Z(null),pe([]),Le(null),fe(null),ve.current=null;try{const re=await n.getItem(e);if(G)return;if(!re){ne(!0);return}const Pe=re;let _e=null;if(n.getEntry&&(_e=await n.getEntry(e),G))return;_e||(_e=Qi(e,Pe)),b&&b(_e,Pe),K(_e),Z(Pe),ue(Pe)}catch{G||ne(!0)}finally{G||V(!1)}})(),()=>{G=!0})},[e,n,P,b,B,ye,ee]),g.useEffect(()=>{const G=ve.current;!G||!u||fe(ei(G.work,G.books,u))},[u]);const se=[];if(L){if(se.push({key:"basic",label:R.detailTab.basicInfo}),L.type==="collection"){be&&de.length===0&&se.push({key:"catalog:loading",label:`${R.detailTab.catalog}…`});for(const G of de)se.push({key:`catalog:${G.resource_id}`,label:G.short_name?`${I(G.short_name)}${R.detailTab.catalogSuffix}`:R.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&se.push({key:s,label:R.detailTab.fullText}),L.type==="work"&&(Q||ze)&&se.push({key:"lineage",label:ze?`${R.detailTab.lineage}…`:R.detailTab.lineage});for(const G of $)(G.position??"before-feedback")==="before-feedback"&&G.shouldShow(L)&&se.push({key:G.key,label:G.label});_&&s==="feedback"&&se.push({key:"feedback",label:R.detailTab.feedback});for(const G of $)G.position==="after-feedback"&&G.shouldShow(L)&&se.push({key:G.key,label:G.label})}g.useEffect(()=>{if(s!=="emendated"||!L)return;a("basic");const G=setTimeout(()=>{var ue;(ue=document.getElementById("studies"))==null||ue.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(G)},[s,L,a]);const te=U&&L&&j?j({activeTab:s,activeJuan:Ce,entry:U,detail:L}):null,ge=g.useMemo(()=>{var D;if(!L)return null;const ue=(L.authors??[]).map(re=>{const Pe=Uo(re.role);return`${re.dynasty?`〔${I(re.dynasty)}〕`:""}${I(re.name)}${Pe?` ${I(Pe)}`:""}`}).join(" · ");let Te=!1;try{Te=we.extractStatus(L.id)==="draft"}catch{}if(L.type==="book"){const re=L;return{title:I(re.title),subtitle:re.edition?I(re.edition):ue||void 0,aside:[Te?R.status.draft:"",ue&&re.edition?ue:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(L.type==="collection"){const re=L;return{title:I(re.title),subtitle:I(Ct(re,R.unit.juan))||void 0,aside:[(D=re.publication_info)==null?void 0:D.year,Te?R.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:ue||void 0}}if(L.type==="entity"){const re=L,Pe=Ye=>Ye==null?"":Ye<0?O("detail.bce",{n:-Ye}):String(Ye),_e=re.birth_year!=null||re.death_year!=null?`${Pe(re.birth_year)||"?"}—${Pe(re.death_year)||"?"}`:"";return{title:I(re.primary_name||re.title),subtitle:[re.dynasty?`〔${I(re.dynasty)}〕`:"",_e].filter(Boolean).join(" ")||void 0,aside:Te?R.status.draft:void 0,secondLine:void 0}}const Ee=I(Ct(L,R.unit.juan));return{title:I(L.title),subtitle:[Ee,ue].filter(Boolean).join(" · ")||void 0,aside:[_b(R,L.subtype),Te?R.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[L,I,R,O]),Ne=L&&Ji(L)?"text":null,Be=()=>{Me(null),a("fulltext")};let We=null;if(L&&S){const G=S({detail:L,kind:Ne});G&&(We=t.jsx(po,{href:G}))}else Ne&&(We=t.jsx(po,{onClick:Be}));const Ue=G=>{if(!L)return null;const ue=G.replace(/\.[^.]+$/,"");if(S){const Te=S({detail:L,kind:Ne,juan:ue});return Te?{href:Te}:null}return{onClick:()=>{Me(ue),a("fulltext")}}},Qe=new Set($.map(G=>G.key)),me=se.filter(G=>G.key.startsWith("catalog:")&&G.key!=="catalog:loading"||G.key==="lineage"&&!!Q&&!ze||Qe.has(G.key)).map(G=>({key:G.key,label:G.label,onClick:()=>a(G.key)})),tt=()=>{var G;return L?L.type==="work"?t.jsx(Cc,{data:L,transport:n,onNavigate:x,renderLink:w,readAction:We,railTop:v,railLinks:me}):L.type==="book"?t.jsx(Ec,{data:L,transport:n,onNavigate:x,renderLink:w,readAction:We,fullText:ie,fullTextPending:Ji(L)&&!!n.getTextManifest&&Ae!==L.id,chapterLink:Ue,railTop:v,railLinks:me}):L.type==="collection"?t.jsx(Ic,{data:L,catalog:(G=de[0])==null?void 0:G.data,transport:n,onNavigate:x,renderLink:w,readAction:We,railTop:v,railLinks:me,catalogAction:de.length>0?t.jsxs("a",{href:"#catalog",onClick:ue=>{ue.preventDefault(),a(`catalog:${de[0].resource_id}`)},children:[I(R.detailTab.collectionCatalog)," →"]}):null}):t.jsx(Rc,{data:L,transport:n,onNavigate:x,renderLink:w,railTop:v,railLinks:me}):null},E=()=>{var ue,Te,Ee;if(!U||!L)return null;if(s==="basic"||s==="emendated")return tt();if(typeof s=="string"&&s.startsWith("catalog:")){const D=(ue=de.find(re=>`catalog:${re.resource_id}`===s))==null?void 0:ue.data;return t.jsx(Po,{data:D,onNavigate:x,renderLink:w})}if(s==="collated"||s==="fulltext")return t.jsx(hr,{id:e,transport:n,chapter:Ce,onLocationChange:D=>Me(D.chapter),onNavigate:x});if(s==="lineage"){if(!Q)return t.jsx("div",{style:{color:i("label-fg"),padding:"24px 0"},children:O(ze?"detail.loading":"detail.noLineageGraph")});const D=L.type==="work"?L:null;return t.jsx(yr,{graph:Q,renderLink:w,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:f,collection:u??((Te=D==null?void 0:D.version_graph)==null?void 0:Te.default_collection),onCollectionChange:m,collectionsAvailable:(Ee=D==null?void 0:D.version_graph)==null?void 0:Ee.collections,collectionCounts:(()=>{var Ye,He,Fe,zt,Wn,gt,Tt;if(!D)return;const re={},Pe=((Ye=ve.current)==null?void 0:Ye.books)??[];re.all=(((He=D.books)==null?void 0:He.length)??0)-(((zt=(Fe=D.version_graph)==null?void 0:Fe.excluded_books)==null?void 0:zt.length)??0);const _e=(Wn=D.version_graph)==null?void 0:Wn.collections;if(_e)for(const Mt of Object.keys(_e))re[Mt]=ei(D,Pe,Mt).nodes.filter(mn=>mn.kind==="book"&&!mn.bridge).length;return re.core==null&&((Tt=(gt=D.version_graph)==null?void 0:gt.core_books)!=null&&Tt.length)&&(re.core=D.version_graph.core_books.length),re})()})}if(s==="feedback"&&_)return t.jsx(wc,{resourceId:e,apiUrl:C});const G=$.find(D=>D.key===s);return G?G.render({detail:L,entry:U,transport:n,onNavigate:x}):null};if(A)return t.jsx(_n,{style:{minHeight:M,...N},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((G,ue)=>t.jsx("div",{style:{height:ue===1?40:16,width:G,opacity:.35,background:i("rule")}},ue))})});if(ce||!L||!U||!ge)return t.jsx(_n,{style:{minHeight:M,...N},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:i("label-fg"),fontSize:14},children:O("detail.notFound")})});const oe=s==="basic"||s==="emendated",ae=[{label:y??R.detailTab.backToIndex,onClick:k}];if(L.type==="book"&&L.work_id){const G=L.work_id;ae.push({label:R.indexType.work,id:G,onClick:()=>x==null?void 0:x(G)})}ae.push({label:R.indexType[L.type]});const je=s==="collated"||s==="fulltext",ke=typeof T=="string"?R.status[T.trim()]??T:T,xe=t.jsx(Bl,{left:t.jsxs(t.Fragment,{children:[ke,ke?" · ":"",t.jsx(Sb,{id:L.id,label:R.label.id,copied:R.action.copied,copyLabel:R.action.copy})]}),right:t.jsxs(t.Fragment,{children:[_&&!oe&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:R.detailTab.submitVersion}),te&&t.jsx("a",{href:te.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:i("meta-fg")},children:R.detailTab.dataLicense})]})});return oe?t.jsx("div",{className:F,children:t.jsxs(_n,{grid:!0,style:{minHeight:M,...N},children:[t.jsx(uo,{breadcrumb:t.jsx(mo,{items:ae}),actions:t.jsxs(t.Fragment,{children:[!z&&t.jsx(wo,{style:{border:"none",background:"transparent"}}),!z&&te&&t.jsx(So,{...te})]})}),tt(),xe]})}):t.jsx("div",{className:F,children:t.jsxs(_n,{wide:je,style:{minHeight:M,...N},children:[t.jsx(uo,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(Ko,{char:"籍"}),t.jsx(mo,{items:ae})]}),actions:t.jsxs(t.Fragment,{children:[!z&&t.jsx(wo,{}),_&&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:i("meta-fg")},children:R.detailTab.feedback}),!z&&te&&t.jsx(So,{...te})]})}),t.jsx(Tl,{...ge,aside:je?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:i("accent"),borderBottom:`1px solid ${i("rule")}`},children:[O("detail.workInfo")," →"]}):ge.aside}),!je&&se.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:se.map(G=>t.jsx(Nl,{label:G.label,active:G.key===s||oe&&G.key==="basic",onClick:()=>a(G.key)},G.key))}),t.jsx("div",{style:{marginTop:!je&&se.length>1?8:0},children:E()}),xe]})})};function Sb({id:e,label:n,copied:o,copyLabel:r}){const[s,a]=g.useState(!1);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[t.jsxs("span",{children:[n," ",e]}),t.jsx("button",{type:"button",onClick:()=>{var l;(l=navigator.clipboard)==null||l.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},title:s?o:r,"aria-label":s?o:r,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:i("aux-fg")},children:s?"✓":"⧉"})]})}function _b(e,n){return n?e.workSubtype[n]??n:""}const wd=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],Si="zhusha",_i="bim-theme";function Sd(e){return e==="zhusha"||e==="indigo"||e==="ink"}function $i(e){return Sd(e)?e:Si}function $b(){try{return $i(window.localStorage.getItem(_i))}catch{return Si}}function _d(e){try{window.localStorage.setItem(_i,e)}catch{}}function $d(e){const n=$i(e);return document.documentElement.setAttribute("data-theme",n),n}function Cd(){return $i(document.documentElement.getAttribute("data-theme"))}const Cb=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],zr="airy",Ci="bim-layout";function zd(e){return e==="airy"||e==="boxed"}function zi(e){return zd(e)?e:zr}function zb(){try{return zi(window.localStorage.getItem(Ci))}catch{return zr}}function Tb(e){try{window.localStorage.setItem(Ci,e)}catch{}}function Nb(e){const n=zi(e);return document.documentElement.setAttribute("data-layout",n),n}function Eb(){return zi(document.documentElement.getAttribute("data-layout"))}const Ib=`try{var t=localStorage.getItem(${JSON.stringify(_i)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Ci)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,Rb={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},Lb=({onChange:e,style:n})=>{const{t:o}=J(),[r,s]=g.useState(Si);g.useEffect(()=>{s(Cd())},[]);const a=l=>{s($d(l)),_d(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":o("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:wd.map(l=>{const d=r===l.name;return t.jsx("button",{type:"button",role:"radio","aria-checked":d,"aria-label":o(`common.theme.${l.name}`),title:o(`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:i(Rb[l.name]),boxShadow:d?`0 0 0 2px ${i("page-bg")}, 0 0 0 3.5px ${i("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=we.BidLink;exports.BookIndexError=we.BookIndexError;exports.BookIndexManager=we.BookIndexManager;exports.BookIndexStorage=we.BookIndexStorage;exports.BundleStorage=we.BundleStorage;exports.ConfigError=we.ConfigError;exports.GithubStorage=we.GithubStorage;exports.IdGenerationError=we.IdGenerationError;exports.IdGenerator=we.IdGenerator;exports.LocalStorage=we.LocalStorage;exports.MigrationError=we.MigrationError;exports.StorageError=we.StorageError;exports.VARIANT_CHARS=we.VARIANT_CHARS;exports.base36Decode=we.base36Decode;exports.base36Encode=we.base36Encode;exports.base58Decode=we.base58Decode;exports.buildId=we.buildId;exports.buildPromotionMap=we.buildPromotionMap;exports.cleanName=we.cleanName;exports.decodeId=we.decodeId;exports.decodeIdString=we.decodeIdString;exports.encodeId=we.encodeId;exports.extractIdFromUrl=we.extractIdFromUrl;exports.extractStatus=we.extractStatus;exports.extractType=we.extractType;exports.isChapterSegment=we.isChapterSegment;exports.isTextKey=we.isTextKey;exports.matchChapterAcrossVersions=we.matchChapterAcrossVersions;exports.normalizeCatalog=we.normalizeCatalog;exports.normalizeVariants=we.normalizeVariants;exports.parseId=we.parseId;exports.pickTextVersion=we.pickTextVersion;exports.shardOf=we.shardOf;exports.smartDecode=we.smartDecode;exports.textVersionLabel=we.textVersionLabel;exports.validateResource=we.validateResource;exports.Badge=si;exports.BidUrlProvider=Xd;exports.BookDetailLayout=wb;exports.BookPage=Ec;exports.Breadcrumb=mo;exports.CATALOG_ALL_ID=St;exports.CATALOG_CSS=Lc;exports.CATALOG_NARROW_QUERY=jr;exports.CATALOG_PAGE_SIZE=vr;exports.CATALOG_UNCLASSIFIED_ID=Dt;exports.CLASSIFICATIONS=mi;exports.COMMON_TRADITIONAL_CHARS=ka;exports.CardFoot=An;exports.CatalogPage=ab;exports.CatalogPager=Hc;exports.CatalogTree=Pc;exports.CheckFilter=$l;exports.Chip=El;exports.ChipWall=Hm;exports.CollectionCatalog=Po;exports.CollectionPage=Ic;exports.CreateEntityDialog=gc;exports.DEFAULT_LAYOUT=zr;exports.DEFAULT_META_HOME_LINKS=rd;exports.DEFAULT_READER_PREFS=Wo;exports.DEFAULT_READ_HOME_LINKS=Dc;exports.DEFAULT_THEME=Si;exports.DETAIL_CSS=zl;exports.DYNASTY_GROUPS=ui;exports.Dash=Ym;exports.DataTable=Dm;exports.DetailFooter=Bl;exports.DetailGrid=Rn;exports.DetailHeader=Tl;exports.EMPTY_FILTERS=pi;exports.ENTITY_TEXT_CSS=cr;exports.EmendatedBySection=Ga;exports.EmptyNote=eh;exports.EntityDetail=Oa;exports.EntityMark=pr;exports.EntityPage=Rc;exports.EntityPickerDialog=xc;exports.EntitySelector=hc;exports.EntityText=lg;exports.ExpandRow=Km;exports.ExtLink=th;exports.FEEDBACK_FAB_OFFSET_VAR=jo;exports.FILTER_SUPPORT=Ea;exports.FONT_SIZE_STEPS=wt;exports.FactList=Mm;exports.FeedbackButton=qf;exports.FeedbackDialog=vc;exports.FeedbackForm=kc;exports.FeedbackList=gr;exports.FeedbackTab=wc;exports.FilterChip=Nl;exports.FormInput=ct;exports.FormTextArea=Vt;exports.GUJI_MARKDOWN_FIELD=Fu;exports.GUJI_TABLE_NOTATION=Ja;exports.GlyphBadge=Ko;exports.GujiInteractiveReader=Gg;exports.GujiTable=Xo;exports.GujiTextViewer=ur;exports.GujiWarpCanvas=ar;exports.HomePage=bo;exports.ImagePanel=oo;exports.IndexApp=Vg;exports.IndexBrowser=no;exports.IndexDetail=Ao;exports.IndexEditor=bc;exports.IndexView=Af;exports.IntroGrid=Pm;exports.LAYOUTS=Cb;exports.LAYOUT_STORAGE_KEY=Ci;exports.LOSS_OPTIONS=Na;exports.LocaleContext=Yt;exports.LocaleProvider=wp;exports.LocaleToggle=wo;exports.META_HOME_CSS=od;exports.META_HOME_SECTION_IDS=kd;exports.MetaCatalogTable=md;exports.MetaCollectionGroups=xd;exports.MetaDataLicense=vd;exports.MetaHomeView=vb;exports.MetaLine=Je;exports.MetaLineageCards=yd;exports.MetaOnlineSites=jd;exports.MetaPeopleTimeline=bd;exports.MetaRecentPanel=pd;exports.MetaRelatedCatalogs=gd;exports.MetaTypeChips=ld;exports.ModeIndicator=$a;exports.MoreButton=Om;exports.MoreLink=Go;exports.PAGE_MAX_WIDTH=Zn;exports.PERIOD_NARROW_SHARE=Yc;exports.PageFrame=_n;exports.Quote=Xm;exports.READER_CSS=al;exports.READ_HOME_CSS=wr;exports.READ_HOME_NARROW_QUERY=Bn;exports.READ_HOME_SECTION_IDS=id;exports.READ_PERIOD_LABELS=pb;exports.RECENT_IDS_STORAGE_KEY=on;exports.ROLE_CLASS_ORDER=jl;exports.ReadButton=po;exports.ReadFamousWorks=ed;exports.ReadHomeView=mb;exports.ReadPeriodBand=td;exports.ReadPicks=Xc;exports.ReadPieces=nd;exports.ReadSection=ot;exports.ReadShelf=_r;exports.ReadSibu=$r;exports.ReadStats=qc;exports.ReadTopicGroup=Jc;exports.ReadTopics=Qc;exports.ReaderMdText=er;exports.ReaderShell=hl;exports.ReaderToc=cl;exports.RelationPanel=uc;exports.RepoSourceLink=So;exports.ResourceEditor=eo;exports.ResourceGroup=Zm;exports.ResourceLine=Jm;exports.ResourceList=Eo;exports.ResourceRow=Pl;exports.SEARCH_VIEW_STORAGE_KEY=Io;exports.SEVEN_PAVILIONS_KEY=fd;exports.SNIPPET_MARK_END=xa;exports.SNIPPET_MARK_START=fa;exports.SORTABLE_TYPES=Ta;exports.SearchInput=za;exports.SearchResults=Ma;exports.Sec=et;exports.Section=ft;exports.SectionHead=Bm;exports.SideList=Ut;exports.SmartBidInput=Qn;exports.SourceEditor=cc;exports.StripWarpRenderer=go;exports.SummaryCard=Ln;exports.THEMES=wd;exports.THEME_INIT_SCRIPT=Ib;exports.THEME_STORAGE_KEY=_i;exports.TRADITIONAL_ALLOWLIST=wa;exports.TabFilter=yi;exports.TableHead=Um;exports.TableRow=Vm;exports.TagRow=Ml;exports.TagRows=Qm;exports.TextButton=Wm;exports.TextReader=hr;exports.ThemeToggle=Lb;exports.TopStrip=uo;exports.VersionLineageGraph=Nc;exports.VersionLineageList=Tc;exports.VersionLineageView=yr;exports.VolumeChips=Fm;exports.VolumeLinks=qo;exports.WorkCard=Wc;exports.WorkCardGrid=Fc;exports.WorkCatalog=Qg;exports.WorkPage=Cc;exports.WorkRow=Oc;exports.adaptCharCord=Jg;exports.adaptEntityJson=Xl;exports.adaptGujiPages=Kg;exports.adaptPunctJson=qg;exports.applyLayout=Nb;exports.applyTheme=$d;exports.authorsLine=wi;exports.bookIndexUriToId=xo;exports.bucketResources=Fo;exports.buildCatalogTree=Jx;exports.buildCollectionTable=kl;exports.buildLineageGraph=ei;exports.buildMeiliFilter=Op;exports.buildPageUrl=No;exports.buildParagraphBlocks=Dl;exports.buildVersionRow=bl;exports.buildVersionTable=yl;exports.canParagraphize=oi;exports.catalogNodeIdOf=Xx;exports.catalogNodeIdsOf=Zx;exports.catalogPageCount=nb;exports.catalogTotal=kr;exports.classificationPath=Mn;exports.clearAllRecentIds=Ro;exports.compareCatalogCards=tb;exports.computeVersionPartition=_m;exports.countActiveFilters=hi;exports.createTextApi=nl;exports.currentLayout=Eb;exports.currentTheme=Cd;exports.defaultEntityHref=nc;exports.defaultWorkLink=Mc;exports.deriveDating=km;exports.deriveEditionType=Sl;exports.deriveEra=In;exports.deriveYear=fi;exports.deriveYearRange=Ho;exports.detailToEditor=jc;exports.detectGenre=vi;exports.displayAuthorRole=Uo;exports.editorToDetail=Lf;exports.eraRank=lo;exports.filtersFromParams=Hp;exports.filtersToParams=ti;exports.findCatalogPath=nn;exports.findTraditionalChars=$p;exports.firstAuthorText=Sr;exports.flattenTitles=ho;exports.flattenToc=ml;exports.fmtCount=Ge;exports.formatHitCount=Xn;exports.formatTemplate=dt;exports.formatVolumeRange=bi;exports.getDisplayNameFromUrl=dn;exports.getMessages=ln;exports.getStartPage=To;exports.getT=cn;exports.getTypeGroupKey=Co;exports.groupRelatedWorks=wm;exports.gujiInlineToPlain=Za;exports.hasActiveFilters=Ia;exports.hasGujiMarkdownV02=io;exports.hasGujiTableNotation=Qa;exports.hasSearchOptions=Mp;exports.iiifVolumeOf=Xg;exports.isCountedChar=lr;exports.isLayoutName=zd;exports.isThemeName=Sd;exports.lineageHref=sd;exports.loadRecentIds=Lt;exports.measureText=Ct;exports.mergeVolumeResources=zo;exports.normalizeEra=Ze;exports.normalizeLayout=zi;exports.normalizeRole=Do;exports.normalizeTheme=$i;exports.normalizeVolumeIndex=zn;exports.normalizeVolumes=_a;exports.numberToChinese=wl;exports.paginationItems=Ac;exports.parseChineseNumber=ni;exports.parseGujiInline=Xa;exports.parseGujiTable=tl;exports.parseSourceString=dc;exports.pct=Cr;exports.periodLevel=Gc;exports.pickReaderVersion=ul;exports.readStoredLayout=zb;exports.readStoredTheme=$b;exports.readerVersionOptionLabel=so;exports.remapPlainOffsets=Zl;exports.removeRecentId=Ba;exports.renderFullTextBody=ah;exports.renderProperNames=Vl;exports.renderReaderInline=Qo;exports.resolveRecentEntry=Lo;exports.resourceHref=pn;exports.resourceNote=xi;exports.resultTabFromParam=Zp;exports.resultTabToParam=Jp;exports.roleFacets=vl;exports.rowNo=Gm;exports.sameFilters=Fp;exports.saveRecentId=to;exports.segmentEntities=Jl;exports.shelfColumns=Uc;exports.sortFor=Bp;exports.sortYear=ii;exports.spineHeight=Vc;exports.splitFullTextTables=Mo;exports.splitHighlightSnippet=_o;exports.splitTableRow=el;exports.storeLayout=Tb;exports.storeTheme=_d;exports.stringifySources=pc;exports.summaryFromEntry=ec;exports.summaryFromItem=Ql;exports.timelineLayout=ad;exports.toCatalogWorkCard=eb;exports.transportSummaryLoader=tc;exports.typeSupportsFilters=Ra;exports.useBidUrl=Xe;exports.useChapterWarpData=rc;exports.useConvert=Re;exports.useEntitySummaryLoader=dr;exports.useI18n=J;exports.useReaderPrefs=pl;exports.useRecentEntries=cd;exports.useT=$e;exports.validateLineageGraph=bx;exports.volumeStats=ci;exports.withDefaultLinks=At;exports.withMetaLinks=Pt;exports.yearText=ai;
|
|
1861
|
+
`,cd={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function At(e){return{...cd,...e??{}}}function dd(e,n){if(e.lineage)return e.lineage(n);const o=e.item(n),r=o.indexOf("#"),[s,a]=r<0?[o,""]:[o.slice(0,r),o.slice(r)];return`${s}${s.includes("?")?"&":"?"}tab=lineage${a}`}function Nr(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function pd(e){const n=e.filter(p=>Number.isFinite(p.birth_year)||Number.isFinite(p.death_year)),o=e.filter(p=>!n.includes(p));if(!n.length)return{min:0,max:0,placed:[],missing:o};const r=p=>{const u=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(u,m),Math.max(u,m)]},s=n.map(r),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,u)=>({p,from:s[u][0],to:s[u][1]})).sort((p,u)=>p.from-u.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:o}}function ci(e,n=cn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function jb(e){return{read:e.item,work:e.item,node:e.node}}function ud({counts:e,links:n}){const{t:o}=Q(),r=n==null?void 0:n.type;if(!r)return null;const s=[["all",o("metaHome.typeAll"),null],["work",o("metaHome.typeLabel.work"),e.works],["book",o("metaHome.typeLabel.book"),e.books],["collection",o("metaHome.typeLabel.collection"),e.collections],["entity",o("metaHome.typeLabel.entity"),e.entities]];return t.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":o("metaHome.typeChipsLabel"),children:s.map(([a,l,d])=>t.jsx("li",{children:t.jsxs("a",{href:r(a),children:[t.jsx("b",{children:l}),d!=null&&d>0&&t.jsx("small",{children:Ve(d)})]})},a))})}function md(e,n=5){const[o,r]=g.useState(null);g.useEffect(()=>{let a=!1;const l=Rt().slice(0,n);if(!l.length||!e){r([]);return}return Promise.all(l.map(d=>Mo(e,d))).then(d=>{a||r(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=g.useCallback(()=>{Po(),r([])},[]);return{entries:o,clear:s}}function vb(e,n,o){const r=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return r?o(r):hd(e.type,n)}function hd(e,n){return n(`metaHome.typeLabel.${e}`)}function gd({entries:e,onClear:n,links:o}){const{t:r,convert:s}=Q(),a=At(o);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:r("metaHome.recentTitle")}),e&&e.length>0&&n&&t.jsx("button",{type:"button",onClick:n,children:r("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":r("metaHome.recentItemLabel",{type:l.type?hd(l.type,r):"",title:s(l.title)}),children:[t.jsx("i",{className:"bim-mh-ty","aria-hidden":"true",children:l.type?r(`metaHome.typeShort.${l.type}`):""}),t.jsx("span",{children:s(l.title)}),t.jsx("small",{"aria-hidden":"true",children:vb(l,r,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:r("metaHome.recentEmpty")})]})}function fd(e,n,o,r=!1){return r&&(e==="done"||e==="in_progress")?n(`metaHome.siteStatus.${e}`):e==="done"||e==="in_progress"||e==="todo"?n(`metaHome.status.${e}`):o(e)}function xd({rows:e,links:n}){const{t:o,convert:r}=Q(),s=At(n);return e.length?t.jsx("div",{className:"bim-mh-tbl-wrap",tabIndex:0,role:"region","aria-label":o("metaHome.catalogTitle"),children:t.jsxs("table",{className:"bim-mh-tbl",children:[t.jsxs("caption",{children:[o("metaHome.catalogTitle"),t.jsx("small",{children:o("metaHome.catalogNote")})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:o("metaHome.colCatalog")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colRecords")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colMatched")}),t.jsx("th",{scope:"col",children:o("metaHome.colProgress")}),t.jsx("th",{scope:"col",children:o("metaHome.colStatus")})]})}),t.jsx("tbody",{children:e.map(a=>{const l=Nr(a.imported,a.total),d=a.work_id??a.collection_id,c=r(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:Ve(a.total)}),t.jsx("td",{className:"bim-mh-r",children:Ve(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:fd(a.status,o,r)})})]},a.id||a.name)})})]})}):null}function bd({items:e,links:n,label:o}){const{convert:r}=Q();return t.jsx("ul",{className:"bim-rh-rows","aria-label":o?r(o):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:r(s.title)}),s.sub&&t.jsx("small",{children:r(s.sub)})]})},s.id))})}function yd({works:e,links:n}){const{t:o}=Q(),[r,s]=g.useState(!1);if(!e.length)return null;const a=In(e.length);return t.jsxs("div",{className:"bim-rh-grp","data-cap":a?"":void 0,"data-open":r?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[o("metaHome.relatedTitle"),t.jsx("small",{children:o("metaHome.relatedNote")})]}),t.jsx(bd,{items:e.map(l=>({id:l.id,title:l.title,sub:_i(l)||void 0})),links:At(n)}),a&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":r,onClick:()=>s(l=>!l),children:r?o("action.collapse"):o("metaHome.allNWorks",{n:e.length})})]})}const jd="siku_qige";function kb({group:e,links:n}){const{t:o,convert:r}=Q(),[s,a]=g.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":In(e.items.length)?"":void 0,"data-open":s?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[r(e.label),t.jsx("small",{className:"bim-rh-num",children:o("metaHome.nKinds",{n:e.items.length})})]}),t.jsx(bd,{items:e.items,links:n,label:e.label}),In(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":s,onClick:()=>a(l=>!l),children:s?o("action.collapse"):o("metaHome.allNKinds",{n:e.items.length})})]})}function vd({groups:e,links:n}){const{t:o,convert:r}=Q(),s=At(n);if(!e.length)return null;const a=e.find(c=>c.key===jd),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:[r(a.label),t.jsx("small",{children:r(a.items.map(c=>d(c.title)).join("、"))})]}),t.jsx("ul",{className:"bim-mh-ge","aria-label":r(a.label),children:a.items.map(c=>t.jsx("li",{children:t.jsxs("a",{href:s.item(c.id),"aria-label":r(c.title),title:r(c.title),children:[t.jsx("span",{"aria-hidden":"true",children:r(d(c.title))}),d(c.title)!==c.title&&t.jsx("small",{"aria-hidden":"true",children:o("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(kb,{group:c,links:s},c.key))})]})}const ga=34,fa=13;function xa(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?ci(e.birth_year,n):"?"}–${e.death_year!=null?ci(e.death_year,n):"?"}`}function wb(e,n){const o=n-e,r=o>1200?300:o>400?100:50,s=[];for(let a=Math.ceil(e/r)*r;a<=n;a+=r)s.push(a);return s}function kd({people:e,links:n}){const{t:o,convert:r}=Q(),s=At(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=pd(e),p=[],u=d.map(h=>{const f=h.left>70,x=f?Math.min(h.left,h.left+h.width-fa):h.left;let k=0;for(;p[k]!=null&&p[k]>x;)k++;return p[k]=f?h.left+h.width:h.left+Math.max(h.width,fa),{...h,lane:k,end:f}}),m=Math.max(1,l-a);return t.jsxs(t.Fragment,{children:[u.length>0&&t.jsxs("div",{className:"bim-mh-tl",children:[t.jsx("ul",{className:"bim-mh-tl-rows",style:{height:p.length*ga+10},children:u.map(h=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":h.end?"":void 0,style:{left:`${h.left}%`,top:h.lane*ga+4,width:`${Math.max(h.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(h.p.id),children:[r(h.p.name),t.jsx("small",{className:"bim-rh-num",children:xa(h.p,o)})]})]},h.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:wb(a,l).map(h=>t.jsx("span",{style:{left:`${(h-a)/m*100}%`},children:ci(h,o)},h))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":u.length?void 0:"",children:(u.length?e:c).map(h=>t.jsx("li",{children:t.jsxs("a",{href:s.item(h.id),children:[t.jsx("span",{children:r(h.name)}),t.jsx("small",{className:"bim-rh-num",children:[h.dynasty?r(h.dynasty):"",xa(h,o)].filter(Boolean).join(" ")})]})},h.id))}),c.length>0&&u.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:o("metaHome.missingLife",{names:r(c.map(h=>h.name).join("、"))})})]})}const Sb=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 wd({works:e,links:n}){const{t:o,convert:r}=Q(),s=At(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=_i(a);return t.jsx("li",{children:t.jsxs("a",{href:dd(s,a.id),children:[Sb,t.jsx("b",{children:r(a.title)}),l&&t.jsx("small",{children:r(l)}),t.jsx("span",{children:o("metaHome.viewLineage")})]})},a.id)})}):null}function Sd({sites:e}){const{t:n,convert:o}=Q(),r=e.filter(a=>a.status!=="todo"&&a.total>0),s=e.filter(a=>!r.includes(a));return e.length?t.jsxs(t.Fragment,{children:[r.length>0&&t.jsx("ul",{className:"bim-mh-cov",children:r.map(a=>{const l=Nr(a.imported,a.total);return t.jsxs("li",{children:[a.url?t.jsx("a",{href:a.url,rel:"noopener noreferrer",target:"_blank",children:o(a.name)}):t.jsx("span",{children:o(a.name)}),t.jsx("span",{className:"bim-mh-bar","aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[`${Ve(a.imported)} / ${Ve(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:fd(a.status,n,o,!0)})]})]},a.id||a.name)})}),s.length>0&&t.jsx("p",{className:"bim-mh-todo",children:n("metaHome.plannedSites",{names:o(s.map(a=>a.name).join("、"))})})]}):null}const ba=["extant","partially_extant","lost","unknown"];function _d({stats:e,links:n,version:o,repoUrl:r,downloadHref:s}){const{t:a}=Q(),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=ba.some(p=>{var u;return(((u=e.loss)==null?void 0:u[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,u])=>t.jsxs("li",{children:[t.jsx("b",{className:"bim-rh-num",children:Ve(p)}),t.jsx("span",{children:u})]},u))})]}),d&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.byLoss")}),t.jsx("ul",{className:"bim-mh-loss",children:ba.map(p=>{var h;const u=((h=e.loss)==null?void 0:h[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&&u>0?a("metaHome.lossCount",{n:Ve(u),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"),r?t.jsx("a",{href:r,children:t.jsx("code",{children:"book-index"})}):t.jsx("code",{children:"book-index"}),a("metaHome.repoNote")]}),o&&t.jsxs("p",{children:[a("metaHome.version"),t.jsx("code",{children:o})]}),s&&t.jsx("p",{children:t.jsx("a",{href:s,children:a("metaHome.download")})})]})]})}const $d={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function _b({sections:e,links:n,head:o,transport:r,catalogHref:s,collectionsHref:a,entitiesHref:l,version:d,repoUrl:c,downloadHref:p,className:u}){var v,$;const{t:m}=Q(),h=e,f=At(n),x=jb(f),k=$d,y=md(r),w={zhi:!!((v=h.shelf)!=null&&v.items.length)||h.catalog_progress.length>0||h.related_catalogs.length>0,sibu:h.bu.length>0||h.unclassified>0,cong:h.collection_groups.length>0,people:h.bibliographers.length>0,lineage:h.lineage.length>0,sites:h.sites.length>0,data:!0},b=Object.keys(k).filter(_=>w[_]),j=_=>m(`metaHome.nav.${_}`),S=(_,C)=>_?t.jsx("a",{className:"bim-rh-more",href:_,children:C}):void 0;return t.jsxs("div",{className:u?`bim-rh bim-mh ${u}`:"bim-rh bim-mh",children:[t.jsx("style",{children:$r+ld}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[o,t.jsx(ud,{counts:h.counts,links:n})]}),r&&t.jsx(gd,{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(_=>t.jsx("li",{children:t.jsx("a",{href:`#${k[_]}`,children:j(_)})},_))})}),t.jsxs("div",{className:"bim-rh-main",children:[w.zhi&&t.jsxs(rt,{id:k.zhi,title:j("zhi"),sub:m("metaHome.zhiSub"),children:[h.shelf&&h.shelf.items.length>0&&t.jsx(zr,{topic:{key:"shelf",label:h.shelf.label,shelf:!0,items:h.shelf.items},links:x,showTitle:!1,legendCount:h.shelf.items.some(_=>_.records)?m("metaHome.shelfLegendCount"):null,legendExtra:[m("metaHome.shelfLegendClick")]}),(h.catalog_progress.length>0||h.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:($=h.shelf)!=null&&$.items.length?void 0:{marginTop:0},children:[t.jsx(xd,{rows:h.catalog_progress,links:n}),t.jsx(yd,{works:h.related_catalogs,links:n})]})]}),w.sibu&&t.jsx(rt,{id:k.sibu,title:j("sibu"),sub:m("metaHome.sibuSub"),more:S(s,m("metaHome.toCatalog")),children:t.jsx(Tr,{bu:h.bu,unclassified:h.unclassified,links:x,unclassifiedNote:m("metaHome.unclassifiedNote")})}),w.cong&&t.jsx(rt,{id:k.cong,title:j("cong"),sub:m("metaHome.congSub"),more:S(a,m("metaHome.allNKindsMore",{n:Ve(h.counts.collections)})),children:t.jsx(vd,{groups:h.collection_groups,links:n})}),w.people&&t.jsx(rt,{id:k.people,title:j("people"),sub:m("metaHome.peopleSub"),more:S(l,m("metaHome.allNPeopleMore",{n:Ve(h.counts.entities)})),children:t.jsx(kd,{people:h.bibliographers,links:n})}),w.lineage&&t.jsx(rt,{id:k.lineage,title:j("lineage"),sub:m("metaHome.lineageSub"),children:t.jsx(wd,{works:h.lineage,links:n})}),w.sites&&t.jsx(rt,{id:k.sites,title:j("sites"),sub:m("metaHome.sitesSub"),children:t.jsx(Sd,{sites:h.sites})}),t.jsx(rt,{id:k.data,title:j("data"),sub:m("metaHome.dataSub"),children:t.jsx(_d,{stats:h.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const $o=({style:e})=>{const n=g.useContext(Gt),{t:o}=Q();if(!n)return null;const{locale:r,setLocale:s}=n,a=r==="zh-Hant",l=()=>s(a?"zh-Hans":"zh-Hant");return t.jsxs("button",{type:"button",onClick:l,title:o(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 ${i("border")}`,borderRadius:"4px",background:i("bg"),color:i("fg"),cursor:"pointer",userSelect:"none",...e},children:[t.jsx("span",{style:{color:a?i("primary"):void 0,fontWeight:a?700:400},children:o("common.localeShortHant")}),t.jsx("span",{style:{opacity:.3},children:"/"}),t.jsx("span",{style:{color:a?void 0:i("primary"),fontWeight:a?400:700},children:o("common.localeShortHans")})]})},Co=({href:e,label:n,size:o=16,className:r,style:s})=>{const{t:a}=Q(),l=n??a("common.repoSourceLink");return t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:l,"aria-label":l,className:r,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:o+8,height:o+8,borderRadius:4,color:i("desc-fg"),textDecoration:"none",transition:"color 120ms, background 120ms",...s},onMouseEnter:d=>{d.currentTarget.style.color=i("fg")},onMouseLeave:d=>{d.currentTarget.style.color=i("desc-fg")},children:t.jsx("svg",{width:o,height:o,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 to(e){const n=e.text_count;return typeof n=="number"&&n>0}function no(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function $b(e,n){if(!n)return!1;const o=n.id;return o===void 0||o===e}const Cb=({id:e,transport:n,initialDetail:o,initialEntry:r,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:u,onLineageCollectionChange:m,initialPage:h=1,selectedLineageNodeId:f,onNavigate:x,onBack:k,backLabel:y,renderLink:w,enrichDetail:b,getSourceLink:j,readLink:S,railTop:v,extraTabs:$=[],showFeedbackTab:_=!0,feedbackApiUrl:C,height:M,footerExtra:T,hideHeaderControls:z=!1,className:F,style:N})=>{const R=$e(),{t:O,convert:I}=Q(),[P]=g.useState(()=>{if(!$b(e,o))return null;const G={...o},de=r??no(e,G);return b&&b(de,G),{id:e,entry:de,detail:G}}),[U,K]=g.useState((P==null?void 0:P.entry)??null),[L,Z]=g.useState((P==null?void 0:P.detail)??null),[A,V]=g.useState(!P),[pe,ee]=g.useState(!1),[ue,me]=g.useState([]),[be,Oe]=g.useState(!1),[ie,Re]=g.useState(null),[Le,q]=g.useState(null),[J,fe]=g.useState(null),[ze,Y]=g.useState(!1),ve=g.useRef(null),le=g.useRef(0),[Se,X]=g.useState(null),Ce=l!==void 0?l:Se,Me=g.useCallback(G=>{d?d(G):X(G)},[d]),B=g.useCallback(async G=>{if(!n.getCollectionCatalogs&&!n.getCollectionCatalog){me([]);return}Oe(!0);try{if(n.getCollectionCatalogs)me(await n.getCollectionCatalogs(G)||[]);else if(n.getCollectionCatalog){const de=await n.getCollectionCatalog(G);me(de?[{resource_id:"",data:de}]:[])}}catch{me([])}finally{Oe(!1)}},[n]),te=g.useCallback(async G=>{var de,Te;if(!n.getTextManifest||!n.getTextIndex){Re(null),q(G);return}try{const Ee=we.pickTextVersion(await n.getTextManifest(G)),D=Ee?await n.getTextIndex(G,Ee.key):null;Re(D&&D.chapters.length>0?{chapters:D.chapters.map(re=>({n:re.n,title:re.title,file:re.file})),source:{name:((de=D.source)==null?void 0:de.name)??(Ee==null?void 0:Ee.source_name),license:((Te=D.source)==null?void 0:Te.license)??(Ee==null?void 0:Ee.license)??void 0}}:null)}catch{Re(null)}finally{q(G)}},[n]),ye=g.useCallback(async(G,de)=>{const Te=++le.current,Ee=()=>Te!==le.current;Y(!0);try{if(n.getLineageGraph){const He=await n.getLineageGraph(G);if(Ee())return;He&&fe(He)}const D=de.version_graph;if(!D||!D.enabled){J||fe(null),ve.current=null;return}const re=de.books??[],Pe=[];for(const He of re)try{const De=await n.getItem(He);De&&Pe.push(De)}catch{}if(Ee())return;ve.current={work:de,books:Pe};const _e=u??D.default_collection??(D.core_books&&D.core_books.length>0?"core":"all"),Ge=_e==="core"&&Array.isArray(D.core_books)&&D.core_books.length>0?"core":_e??"all";fe(ni(de,Pe,Ge))}catch{if(Ee())return;fe(null),ve.current=null}finally{Ee()||Y(!1)}},[n]),H=g.useRef({initialDetail:o,initialEntry:r});H.current={initialDetail:o,initialEntry:r},g.useEffect(()=>{let G=!1;le.current++,Y(!1);const de=re=>{re.type==="collection"?B(e):re.type==="work"?(re.version_graph||n.getLineageGraph)&&ye(e,re):re.type==="book"&&to(re)&&te(e)},Te=H.current;let Ee=null;if(P&&P.id===e)Ee=P;else if(Te.initialDetail&&Te.initialDetail.id===e){const re={...Te.initialDetail},Pe=Te.initialEntry??no(e,re);b&&b(Pe,re),Ee={entry:Pe,detail:re}}return Ee?(ee(!1),me(re=>re.length?[]:re),Re(null),fe(null),ve.current=null,K(Ee.entry),Z(Ee.detail),V(!1),de(Ee.detail),()=>{G=!0}):((async()=>{V(!0),ee(!1),K(null),Z(null),me([]),Re(null),fe(null),ve.current=null;try{const re=await n.getItem(e);if(G)return;if(!re){ee(!0);return}const Pe=re;let _e=null;if(n.getEntry&&(_e=await n.getEntry(e),G))return;_e||(_e=no(e,Pe)),b&&b(_e,Pe),K(_e),Z(Pe),de(Pe)}catch{G||ee(!0)}finally{G||V(!1)}})(),()=>{G=!0})},[e,n,P,b,B,ye,te]),g.useEffect(()=>{const G=ve.current;!G||!u||fe(ni(G.work,G.books,u))},[u]);const se=[];if(L){if(se.push({key:"basic",label:R.detailTab.basicInfo}),L.type==="collection"){be&&ue.length===0&&se.push({key:"catalog:loading",label:`${R.detailTab.catalog}…`});for(const G of ue)se.push({key:`catalog:${G.resource_id}`,label:G.short_name?`${I(G.short_name)}${R.detailTab.catalogSuffix}`:R.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&se.push({key:s,label:R.detailTab.fullText}),L.type==="work"&&(J||ze)&&se.push({key:"lineage",label:ze?`${R.detailTab.lineage}…`:R.detailTab.lineage});for(const G of $)(G.position??"before-feedback")==="before-feedback"&&G.shouldShow(L)&&se.push({key:G.key,label:G.label});_&&s==="feedback"&&se.push({key:"feedback",label:R.detailTab.feedback});for(const G of $)G.position==="after-feedback"&&G.shouldShow(L)&&se.push({key:G.key,label:G.label})}g.useEffect(()=>{if(s!=="emendated"||!L)return;a("basic");const G=setTimeout(()=>{var de;(de=document.getElementById("studies"))==null||de.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(G)},[s,L,a]);const ne=U&&L&&j?j({activeTab:s,activeJuan:Ce,entry:U,detail:L}):null,ge=g.useMemo(()=>{var D;if(!L)return null;const de=(L.authors??[]).map(re=>{const Pe=Yo(re.role);return`${re.dynasty?`〔${I(re.dynasty)}〕`:""}${I(re.name)}${Pe?` ${I(Pe)}`:""}`}).join(" · ");let Te=!1;try{Te=we.extractStatus(L.id)==="draft"}catch{}if(L.type==="book"){const re=L;return{title:I(re.title),subtitle:re.edition?I(re.edition):de||void 0,aside:[Te?R.status.draft:"",de&&re.edition?de:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(L.type==="collection"){const re=L;return{title:I(re.title),subtitle:I(zt(re,R.unit.juan))||void 0,aside:[(D=re.publication_info)==null?void 0:D.year,Te?R.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:de||void 0}}if(L.type==="entity"){const re=L,Pe=Ge=>Ge==null?"":Ge<0?O("detail.bce",{n:-Ge}):String(Ge),_e=re.birth_year!=null||re.death_year!=null?`${Pe(re.birth_year)||"?"}—${Pe(re.death_year)||"?"}`:"";return{title:I(re.primary_name||re.title),subtitle:[re.dynasty?`〔${I(re.dynasty)}〕`:"",_e].filter(Boolean).join(" ")||void 0,aside:Te?R.status.draft:void 0,secondLine:void 0}}const Ee=I(zt(L,R.unit.juan));return{title:I(L.title),subtitle:[Ee,de].filter(Boolean).join(" · ")||void 0,aside:[Tb(R,L.subtype),Te?R.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[L,I,R,O]),Ne=L&&to(L)?"text":null,Be=()=>{Me(null),a("fulltext")};let We=null;if(L&&S){const G=S({detail:L,kind:Ne});G&&(We=t.jsx(ho,{href:G}))}else Ne&&(We=t.jsx(ho,{onClick:Be}));const Ue=G=>{if(!L)return null;const de=G.replace(/\.[^.]+$/,"");if(S){const Te=S({detail:L,kind:Ne,juan:de});return Te?{href:Te}:null}return{onClick:()=>{Me(de),a("fulltext")}}},Qe=new Set($.map(G=>G.key)),ce=se.filter(G=>G.key.startsWith("catalog:")&&G.key!=="catalog:loading"||G.key==="lineage"&&!!J&&!ze||Qe.has(G.key)).map(G=>({key:G.key,label:G.label,onClick:()=>a(G.key)})),tt=()=>{var G;return L?L.type==="work"?t.jsx(Ec,{data:L,transport:n,onNavigate:x,renderLink:w,readAction:We,railTop:v,railLinks:ce}):L.type==="book"?t.jsx(Ac,{data:L,transport:n,onNavigate:x,renderLink:w,readAction:We,fullText:ie,fullTextPending:to(L)&&!!n.getTextManifest&&Le!==L.id,chapterLink:Ue,railTop:v,railLinks:ce}):L.type==="collection"?t.jsx(Pc,{data:L,catalog:(G=ue[0])==null?void 0:G.data,transport:n,onNavigate:x,renderLink:w,readAction:We,railTop:v,railLinks:ce,catalogAction:ue.length>0?t.jsxs("a",{href:"#catalog",onClick:de=>{de.preventDefault(),a(`catalog:${ue[0].resource_id}`)},children:[I(R.detailTab.collectionCatalog)," →"]}):null}):t.jsx(Mc,{data:L,transport:n,onNavigate:x,renderLink:w,railTop:v,railLinks:ce}):null},E=()=>{var de,Te,Ee;if(!U||!L)return null;if(s==="basic"||s==="emendated")return tt();if(typeof s=="string"&&s.startsWith("catalog:")){const D=(de=ue.find(re=>`catalog:${re.resource_id}`===s))==null?void 0:de.data;return t.jsx(Wo,{data:D,onNavigate:x,renderLink:w})}if(s==="collated"||s==="fulltext")return t.jsx(xr,{id:e,transport:n,chapter:Ce,onLocationChange:D=>Me(D.chapter),onNavigate:x});if(s==="lineage"){if(!J)return t.jsx("div",{style:{color:i("label-fg"),padding:"24px 0"},children:O(ze?"detail.loading":"detail.noLineageGraph")});const D=L.type==="work"?L:null;return t.jsx(kr,{graph:J,renderLink:w,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:f,collection:u??((Te=D==null?void 0:D.version_graph)==null?void 0:Te.default_collection),onCollectionChange:m,collectionsAvailable:(Ee=D==null?void 0:D.version_graph)==null?void 0:Ee.collections,collectionCounts:(()=>{var Ge,He,De,Tt,Pt,qt,mn;if(!D)return;const re={},Pe=((Ge=ve.current)==null?void 0:Ge.books)??[];re.all=(((He=D.books)==null?void 0:He.length)??0)-(((Tt=(De=D.version_graph)==null?void 0:De.excluded_books)==null?void 0:Tt.length)??0);const _e=(Pt=D.version_graph)==null?void 0:Pt.collections;if(_e)for(const On of Object.keys(_e))re[On]=ni(D,Pe,On).nodes.filter(ft=>ft.kind==="book"&&!ft.bridge).length;return re.core==null&&((mn=(qt=D.version_graph)==null?void 0:qt.core_books)!=null&&mn.length)&&(re.core=D.version_graph.core_books.length),re})()})}if(s==="feedback"&&_)return t.jsx(Cc,{resourceId:e,apiUrl:C});const G=$.find(D=>D.key===s);return G?G.render({detail:L,entry:U,transport:n,onNavigate:x}):null};if(A)return t.jsx($n,{style:{minHeight:M,...N},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((G,de)=>t.jsx("div",{style:{height:de===1?40:16,width:G,opacity:.35,background:i("rule")}},de))})});if(pe||!L||!U||!ge)return t.jsx($n,{style:{minHeight:M,...N},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:i("label-fg"),fontSize:14},children:O("detail.notFound")})});const oe=s==="basic"||s==="emendated",ae=[{label:y??R.detailTab.backToIndex,onClick:k}];if(L.type==="book"&&L.work_id){const G=L.work_id;ae.push({label:R.indexType.work,id:G,onClick:()=>x==null?void 0:x(G)})}ae.push({label:R.indexType[L.type]});const je=s==="collated"||s==="fulltext",ke=typeof T=="string"?R.status[T.trim()]??T:T,xe=t.jsx(Fl,{left:t.jsxs(t.Fragment,{children:[ke,ke?" · ":"",t.jsx(zb,{id:L.id,label:R.label.id,copied:R.action.copied,copyLabel:R.action.copy})]}),right:t.jsxs(t.Fragment,{children:[_&&!oe&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:R.detailTab.submitVersion}),ne&&t.jsx("a",{href:ne.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:i("meta-fg")},children:R.detailTab.dataLicense})]})});return oe?t.jsx("div",{className:F,children:t.jsxs($n,{grid:!0,style:{minHeight:M,...N},children:[t.jsx(go,{breadcrumb:t.jsx(fo,{items:ae}),actions:t.jsxs(t.Fragment,{children:[!z&&t.jsx($o,{style:{border:"none",background:"transparent"}}),!z&&ne&&t.jsx(Co,{...ne})]})}),tt(),xe]})}):t.jsx("div",{className:F,children:t.jsxs($n,{wide:je,style:{minHeight:M,...N},children:[t.jsx(go,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(Zo,{char:"籍"}),t.jsx(fo,{items:ae})]}),actions:t.jsxs(t.Fragment,{children:[!z&&t.jsx($o,{}),_&&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:i("meta-fg")},children:R.detailTab.feedback}),!z&&ne&&t.jsx(Co,{...ne})]})}),t.jsx(Rl,{...ge,aside:je?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:i("accent"),borderBottom:`1px solid ${i("rule")}`},children:[O("detail.workInfo")," →"]}):ge.aside}),!je&&se.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:se.map(G=>t.jsx(Ll,{label:G.label,active:G.key===s||oe&&G.key==="basic",onClick:()=>a(G.key)},G.key))}),t.jsx("div",{style:{marginTop:!je&&se.length>1?8:0},children:E()}),xe]})})};function zb({id:e,label:n,copied:o,copyLabel:r}){const[s,a]=g.useState(!1);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[t.jsxs("span",{children:[n," ",e]}),t.jsx("button",{type:"button",onClick:()=>{var l;(l=navigator.clipboard)==null||l.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},title:s?o:r,"aria-label":s?o:r,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:i("aux-fg")},children:s?"✓":"⧉"})]})}function Tb(e,n){return n?e.workSubtype[n]??n:""}const Cd=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],$i="zhusha",Ci="bim-theme";function zd(e){return e==="zhusha"||e==="indigo"||e==="ink"}function zi(e){return zd(e)?e:$i}function Nb(){try{return zi(window.localStorage.getItem(Ci))}catch{return $i}}function Td(e){try{window.localStorage.setItem(Ci,e)}catch{}}function Nd(e){const n=zi(e);return document.documentElement.setAttribute("data-theme",n),n}function Ed(){return zi(document.documentElement.getAttribute("data-theme"))}const Eb=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Er="airy",Ti="bim-layout";function Id(e){return e==="airy"||e==="boxed"}function Ni(e){return Id(e)?e:Er}function Ib(){try{return Ni(window.localStorage.getItem(Ti))}catch{return Er}}function Rb(e){try{window.localStorage.setItem(Ti,e)}catch{}}function Lb(e){const n=Ni(e);return document.documentElement.setAttribute("data-layout",n),n}function Ab(){return Ni(document.documentElement.getAttribute("data-layout"))}const Pb=`try{var t=localStorage.getItem(${JSON.stringify(Ci)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Ti)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,Mb={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},Bb=({onChange:e,style:n})=>{const{t:o}=Q(),[r,s]=g.useState($i);g.useEffect(()=>{s(Ed())},[]);const a=l=>{s(Nd(l)),Td(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":o("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:Cd.map(l=>{const d=r===l.name;return t.jsx("button",{type:"button",role:"radio","aria-checked":d,"aria-label":o(`common.theme.${l.name}`),title:o(`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:i(Mb[l.name]),boxShadow:d?`0 0 0 2px ${i("page-bg")}, 0 0 0 3.5px ${i("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=we.BidLink;exports.BookIndexError=we.BookIndexError;exports.BookIndexManager=we.BookIndexManager;exports.BookIndexStorage=we.BookIndexStorage;exports.BundleStorage=we.BundleStorage;exports.ConfigError=we.ConfigError;exports.GithubStorage=we.GithubStorage;exports.IdGenerationError=we.IdGenerationError;exports.IdGenerator=we.IdGenerator;exports.LocalStorage=we.LocalStorage;exports.MigrationError=we.MigrationError;exports.StorageError=we.StorageError;exports.VARIANT_CHARS=we.VARIANT_CHARS;exports.base36Decode=we.base36Decode;exports.base36Encode=we.base36Encode;exports.base58Decode=we.base58Decode;exports.buildId=we.buildId;exports.buildPromotionMap=we.buildPromotionMap;exports.cleanName=we.cleanName;exports.decodeId=we.decodeId;exports.decodeIdString=we.decodeIdString;exports.encodeId=we.encodeId;exports.extractIdFromUrl=we.extractIdFromUrl;exports.extractStatus=we.extractStatus;exports.extractType=we.extractType;exports.isChapterSegment=we.isChapterSegment;exports.isTextKey=we.isTextKey;exports.matchChapterAcrossVersions=we.matchChapterAcrossVersions;exports.normalizeCatalog=we.normalizeCatalog;exports.normalizeVariants=we.normalizeVariants;exports.parseId=we.parseId;exports.pickTextVersion=we.pickTextVersion;exports.shardOf=we.shardOf;exports.smartDecode=we.smartDecode;exports.textVersionLabel=we.textVersionLabel;exports.validateResource=we.validateResource;exports.Badge=li;exports.BidUrlProvider=ep;exports.BookDetailLayout=Cb;exports.BookPage=Ac;exports.Breadcrumb=fo;exports.CATALOG_ALL_ID=_t;exports.CATALOG_CSS=Bc;exports.CATALOG_NARROW_QUERY=wr;exports.CATALOG_PAGE_SIZE=Sr;exports.CATALOG_UNCLASSIFIED_ID=Ft;exports.CLASSIFICATIONS=gi;exports.COMMON_TRADITIONAL_CHARS=$a;exports.CardFoot=Pn;exports.CatalogPage=pb;exports.CatalogPager=Vc;exports.CatalogTree=Oc;exports.CheckFilter=Nl;exports.Chip=Al;exports.ChipWall=Vm;exports.CollectionCatalog=Wo;exports.CollectionPage=Pc;exports.CreateEntityDialog=yc;exports.DEFAULT_LAYOUT=Er;exports.DEFAULT_META_HOME_LINKS=cd;exports.DEFAULT_READER_PREFS=Fo;exports.DEFAULT_READ_HOME_LINKS=Yc;exports.DEFAULT_THEME=$i;exports.DETAIL_CSS=Il;exports.DYNASTY_GROUPS=hi;exports.Dash=Zm;exports.DataTable=Ym;exports.DetailFooter=Fl;exports.DetailGrid=Ln;exports.DetailHeader=Rl;exports.EMPTY_FILTERS=mi;exports.ENTITY_TEXT_CSS=ur;exports.EmendatedBySection=Xa;exports.EmptyNote=oh;exports.EntityDetail=Ua;exports.EntityMark=hr;exports.EntityPage=Mc;exports.EntityPickerDialog=vc;exports.EntitySelector=bc;exports.EntityText=ug;exports.ExpandRow=Jm;exports.ExtLink=rh;exports.FEEDBACK_FAB_OFFSET_VAR=wo;exports.FILTER_SUPPORT=Aa;exports.FONT_SIZE_STEPS=St;exports.FactList=Hm;exports.FeedbackButton=Qf;exports.FeedbackDialog=_c;exports.FeedbackForm=$c;exports.FeedbackList=br;exports.FeedbackTab=Cc;exports.FilterChip=Ll;exports.FormInput=dt;exports.FormTextArea=Ut;exports.GUJI_MARKDOWN_FIELD=Gu;exports.GUJI_TABLE_NOTATION=nl;exports.GlyphBadge=Zo;exports.GujiInteractiveReader=Xg;exports.GujiTable=Qo;exports.GujiTextViewer=gr;exports.GujiWarpCanvas=dr;exports.HomePage=vo;exports.ImagePanel=ao;exports.IndexApp=qg;exports.IndexBrowser=ro;exports.IndexDetail=Bo;exports.IndexEditor=kc;exports.IndexView=Wf;exports.IntroGrid=Om;exports.LAYOUTS=Eb;exports.LAYOUT_STORAGE_KEY=Ti;exports.LOSS_OPTIONS=La;exports.LocaleContext=Gt;exports.LocaleProvider=Cp;exports.LocaleToggle=$o;exports.META_HOME_CSS=ld;exports.META_HOME_SECTION_IDS=$d;exports.MetaCatalogTable=xd;exports.MetaCollectionGroups=vd;exports.MetaDataLicense=_d;exports.MetaHomeView=_b;exports.MetaLine=Je;exports.MetaLineageCards=wd;exports.MetaOnlineSites=Sd;exports.MetaPeopleTimeline=kd;exports.MetaRecentPanel=gd;exports.MetaRelatedCatalogs=yd;exports.MetaTypeChips=ud;exports.ModeIndicator=Na;exports.MoreButton=Um;exports.MoreLink=qo;exports.PAGE_MAX_WIDTH=Qn;exports.PERIOD_NARROW_SHARE=Zc;exports.PageFrame=$n;exports.Quote=eh;exports.READER_CSS=pl;exports.READ_HOME_CSS=$r;exports.READ_HOME_NARROW_QUERY=Wn;exports.READ_HOME_SECTION_IDS=ad;exports.READ_PERIOD_LABELS=gb;exports.RECENT_IDS_STORAGE_KEY=on;exports.ROLE_CLASS_ORDER=Sl;exports.ReadButton=ho;exports.ReadFamousWorks=od;exports.ReadHomeView=xb;exports.ReadPeriodBand=rd;exports.ReadPicks=ed;exports.ReadPieces=sd;exports.ReadSection=rt;exports.ReadShelf=zr;exports.ReadSibu=Tr;exports.ReadStats=Qc;exports.ReadTopicGroup=nd;exports.ReadTopics=id;exports.ReaderMdText=ir;exports.ReaderShell=bl;exports.ReaderToc=ml;exports.RelationPanel=fc;exports.RepoSourceLink=Co;exports.ResourceEditor=io;exports.ResourceGroup=th;exports.ResourceLine=nh;exports.ResourceList=Lo;exports.ResourceRow=Ol;exports.SEARCH_VIEW_STORAGE_KEY=Ao;exports.SEVEN_PAVILIONS_KEY=jd;exports.SNIPPET_MARK_END=va;exports.SNIPPET_MARK_START=ja;exports.SORTABLE_TYPES=Ra;exports.SearchInput=Ia;exports.SearchResults=Ha;exports.Sec=et;exports.Section=xt;exports.SectionHead=Fm;exports.SideList=Dt;exports.SmartBidInput=ti;exports.SourceEditor=mc;exports.StripWarpRenderer=bo;exports.SummaryCard=An;exports.THEMES=Cd;exports.THEME_INIT_SCRIPT=Pb;exports.THEME_STORAGE_KEY=Ci;exports.TRADITIONAL_ALLOWLIST=Ca;exports.TabFilter=vi;exports.TableHead=Km;exports.TableRow=qm;exports.TagRow=Hl;exports.TagRows=ih;exports.TextButton=Dm;exports.TextReader=xr;exports.ThemeToggle=Bb;exports.TopStrip=go;exports.VersionLineageGraph=Lc;exports.VersionLineageList=Rc;exports.VersionLineageView=kr;exports.VolumeChips=Gm;exports.VolumeLinks=Jo;exports.WorkCard=Dc;exports.WorkCardGrid=Gc;exports.WorkCatalog=of;exports.WorkPage=Ec;exports.WorkRow=Uc;exports.adaptCharCord=nf;exports.adaptEntityJson=ec;exports.adaptGujiPages=Jg;exports.adaptPunctJson=Qg;exports.applyLayout=Lb;exports.applyTheme=Nd;exports.authorsLine=_i;exports.bookIndexUriToId=jo;exports.bucketResources=Vo;exports.buildCatalogTree=nb;exports.buildCollectionTable=$l;exports.buildLineageGraph=ni;exports.buildMeiliFilter=Up;exports.buildPageUrl=Ro;exports.buildParagraphBlocks=Yl;exports.buildVersionRow=kl;exports.buildVersionTable=wl;exports.canParagraphize=si;exports.catalogNodeIdOf=eb;exports.catalogNodeIdsOf=tb;exports.catalogPageCount=sb;exports.catalogTotal=_r;exports.classificationPath=Bn;exports.clearAllRecentIds=Po;exports.compareCatalogCards=rb;exports.computeVersionPartition=Tm;exports.countActiveFilters=fi;exports.createTextApi=sl;exports.currentLayout=Ab;exports.currentTheme=Ed;exports.defaultEntityHref=sc;exports.defaultWorkLink=Hc;exports.deriveDating=$m;exports.deriveEditionType=zl;exports.deriveEra=Rn;exports.deriveYear=bi;exports.deriveYearRange=Uo;exports.detailToEditor=Sc;exports.detectGenre=wi;exports.displayAuthorRole=Yo;exports.editorToDetail=Bf;exports.eraRank=uo;exports.filtersFromParams=Vp;exports.filtersToParams=ii;exports.findCatalogPath=nn;exports.findTraditionalChars=Np;exports.firstAuthorText=Cr;exports.flattenTitles=xo;exports.flattenToc=xl;exports.fmtCount=Ve;exports.formatHitCount=Jn;exports.formatTemplate=pt;exports.formatVolumeRange=ji;exports.getDisplayNameFromUrl=dn;exports.getMessages=ln;exports.getStartPage=Io;exports.getT=cn;exports.getTypeGroupKey=No;exports.groupRelatedWorks=Cm;exports.gujiInlineToPlain=tl;exports.hasActiveFilters=Pa;exports.hasGujiMarkdownV02=so;exports.hasGujiTableNotation=il;exports.hasSearchOptions=Hp;exports.iiifVolumeOf=ef;exports.isCountedChar=pr;exports.isLayoutName=Id;exports.isThemeName=zd;exports.lineageHref=dd;exports.loadRecentIds=Rt;exports.measureText=zt;exports.mergeVolumeResources=Eo;exports.normalizeEra=Ze;exports.normalizeLayout=Ni;exports.normalizeRole=Go;exports.normalizeTheme=zi;exports.normalizeVolumeIndex=Tn;exports.normalizeVolumes=Ta;exports.numberToChinese=Cl;exports.paginationItems=Wc;exports.parseChineseNumber=oi;exports.parseGujiInline=el;exports.parseGujiTable=rl;exports.parseSourceString=hc;exports.pct=Nr;exports.periodLevel=Xc;exports.pickReaderVersion=fl;exports.readStoredLayout=Ib;exports.readStoredTheme=Nb;exports.readerVersionOptionLabel=co;exports.remapPlainOffsets=tc;exports.removeRecentId=Fa;exports.renderFullTextBody=ph;exports.renderProperNames=ql;exports.renderReaderInline=nr;exports.resolveRecentEntry=Mo;exports.resourceHref=pn;exports.resourceNote=yi;exports.resultTabFromParam=tu;exports.resultTabToParam=nu;exports.roleFacets=_l;exports.rowNo=Xm;exports.sameFilters=Gp;exports.saveRecentId=oo;exports.segmentEntities=nc;exports.shelfColumns=Kc;exports.sortFor=Fp;exports.sortYear=ri;exports.spineHeight=qc;exports.splitFullTextTables=Oo;exports.splitHighlightSnippet=zo;exports.splitTableRow=ol;exports.storeLayout=Rb;exports.storeTheme=Td;exports.stringifySources=gc;exports.summaryFromEntry=oc;exports.summaryFromItem=ic;exports.timelineLayout=pd;exports.toCatalogWorkCard=ob;exports.transportSummaryLoader=rc;exports.typeSupportsFilters=Ma;exports.useBidUrl=Xe;exports.useChapterWarpData=cc;exports.useConvert=Ie;exports.useEntitySummaryLoader=mr;exports.useI18n=Q;exports.useReaderPrefs=gl;exports.useRecentEntries=md;exports.useT=$e;exports.validateLineageGraph=kx;exports.volumeStats=pi;exports.withDefaultLinks=Lt;exports.withMetaLinks=At;exports.yearText=ci;
|