book-index-ui 0.40.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.cjs +24 -24
  2. package/dist/index.js +2287 -2287
  3. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var pc=Object.create;var Ao=Object.defineProperty;var uc=Object.getOwnPropertyDescriptor;var mc=Object.getOwnPropertyNames;var gc=Object.getPrototypeOf,hc=Object.prototype.hasOwnProperty;var xc=(t,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of mc(n))!hc.call(t,s)&&s!==o&&Ao(t,s,{get:()=>n[s],enumerable:!(r=uc(n,s))||r.enumerable});return t};var bn=(t,n,o)=>(o=t!=null?pc(gc(t)):{},xc(n||!t||!t.__esModule?Ao(o,"default",{value:t,enumerable:!0}):o,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const xe=require("./storage-entry-C9uAfe4i.cjs"),e=require("react/jsx-runtime"),x=require("react"),fc=require("opencc-js/t2cn"),bc=require("react-markdown"),yc=require("remark-gfm"),jc=t=>`/book-index?id=${t}`,ls=x.createContext(jc);function vc({buildUrl:t,children:n}){const o=x.useMemo(()=>t,[t]);return e.jsx(ls.Provider,{value:o,children:n})}function Ye(){return x.useContext(ls)}const as="",cs="";function Mi(t){const n=[];let o=!1,r=t;for(;r.length;){const s=o?cs:as,l=r.indexOf(s);if(l===-1){n.push({text:r,marked:o});break}l>0&&n.push({text:r.slice(0,l),marked:o}),r=r.slice(l+1),o=!o}return n}function Qe(t,n){return{title:t,tokens:n}}const Bo='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',kc=[Qe("基础(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"}}),Qe("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),Qe("提示与警告",{"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)"}}),Qe("遮罩与阴影",{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)"}}),Qe("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),Qe("资源",{"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"}}),Qe("整理本(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"}}),Qe("版本传承(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"}}),Qe("编辑器视图(主要在 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")'}}),Qe("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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}}),Qe('版式(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"}}),Qe("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"}}),Qe("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),Qe("字体(全站无衬线,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:Bo,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:Bo,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],wc=Object.assign({},...kc.map(t=>t.tokens)),ds={};for(const[t,n]of Object.entries(wc))ds[t]=`var(--bim-${t}, ${n.value})`;function i(t){const n=ds[t];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${t}`);return n}function Nt(t){return t.types&&t.types.length>0?t.types:t.type?t.type==="text+image"?["text","image"]:[t.type]:[]}function Sc(t,n){return Nt(t).includes(n)}const $c={published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"};i("quality-published"),i("quality-fine"),i("quality-rough"),i("quality-ocr");const It=x.createContext(null),ps=["曹霑"];function _c(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cc(t,n=ps){const o=[...new Set(n.filter(Boolean))].sort((l,a)=>a.length-l.length);if(!o.length)return t;const r=new RegExp(`(${o.map(_c).join("|")})`,"g"),s=new Set(o);return l=>{if(!l)return t(l);const a=l.split(r);return a.length===1?t(l):a.map((p,c)=>c%2===1&&s.has(p)?p:p&&t(p)).join("")}}let Kt=null;function zc(){if(Kt)return Kt;try{const t=fc.Converter({from:"t",to:"cn"});Kt=Cc(n=>t(xe.normalizeVariants(n)))}catch{Kt=t=>t}return Kt}const Tc={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:"圖片資源"}},Nc={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 tt(t,n,o){return{"zh-Hant":t,"zh-Hans":n}}const Ic=tt({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:"无数据"}),En=tt({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:"作品信息"}),Rc=tt({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:"附记"}}),Ec=tt({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}"}}),Lc=tt({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:"上级丛编"}),Pc=tt({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 为自动匹配,未经人工核对"}),Ac=tt({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:"参考文献"}),Bc=tt({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:"本卷条目"}),Mc=tt({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:"规模、存佚、许可与版本"}),Wi=tt({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:"按作者浏览全部 →"}),Wc=tt({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} 条"}),Hc=tt({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:"搜索"}),Oc=tt({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:"回复"}),Fc=tt({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:"有争议"}}),Dc={common:Ic,detail:En,bookPage:Rc,workPage:Ec,collectionPage:Lc,entityPage:Pc,reader:Ac,collated:Bc,metaHome:Mc,readHome:Wi,catalogPage:Wc,searchPage:Hc,feedback:Oc,lineage:Fc};function Uc(t){const n={};for(const[o,r]of Object.entries(Dc))n[o]=r[t];return n}function it(t,n){return t.replace(/\{(\w+)\}/g,(o,r)=>String(n[r]??""))}const Mo=new Map;function Ft(t){let n=Mo.get(t);return n||(n={...t==="zh-Hans"?Nc:Tc,...Uc(t)},Mo.set(t,n)),n}function Wo(t,n){let o=t;for(const r of n.split(".")){if(o==null||typeof o!="object")return;o=o[r]}return typeof o=="string"?o:void 0}function us(t){return(n,o)=>{const r=Wo(t,n)??Wo(Ft("zh-Hant"),n)??n;return o?it(r,o):r}}const Ho=new Map;function Dt(t){let n=Ho.get(t);return n||(n=us(Ft(t)),Ho.set(t,n)),n}const ms="bim-locale";function Vc(){try{const t=localStorage.getItem(ms);if(t==="zh-Hant"||t==="zh-Hans")return t}catch{}}function Gc(t){try{localStorage.setItem(ms,t)}catch{}}const Yc="zh-Hans",Kc=({locale:t,onLocaleChange:n,converter:o,children:r})=>{const[s,l]=x.useState(t??Yc),a=t??s;x.useEffect(()=>{if(t)return;const u=Vc();u&&u!==s&&l(u)},[]);const p=x.useMemo(()=>a==="zh-Hans"?o??zc():null,[a,o]),c=x.useCallback(u=>{l(u),Gc(u),n==null||n(u)},[n]),d=x.useMemo(()=>({locale:a,setLocale:c,messages:Ft(a),converter:p}),[a,c,p]);return e.jsx(It.Provider,{value:d,children:r})};function ve(){const t=x.useContext(It);return(t==null?void 0:t.messages)??Ft("zh-Hant")}const qc=2e3;function Te(){const t=x.useContext(It),n=(t==null?void 0:t.locale)??"zh-Hant",o=(t==null?void 0:t.converter)??null,r=x.useRef(new Map),s=x.useRef(n);s.current!==n&&(r.current.clear(),s.current=n);const l=x.useCallback(a=>{if(!a)return"";if(!o)return a;const p=r.current.get(a);if(p!==void 0)return p;const c=o(a);if(r.current.size>=qc){const d=r.current.keys().next().value;d!==void 0&&r.current.delete(d)}return r.current.set(a,c),c},[o]);return x.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function G(){const t=x.useContext(It),{convert:n,locale:o,isSimplified:r}=Te(),s=(t==null?void 0:t.messages)??Ft("zh-Hant"),l=x.useMemo(()=>t?us(s):Dt("zh-Hant"),[t,s]);return x.useMemo(()=>({t:l,convert:n,locale:o,isSimplified:r,messages:s}),[l,n,o,r,s])}const gs=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),Zc=new Set([...gs,...Object.keys(xe.VARIANT_CHARS)]),hs=[...ps,"切換為繁體","漢籍リポジトリ"];function Jc(t,n=hs){let o=t;for(const l of n)l&&(o=o.split(l).join(" "));const r=[],s=Array.from(o);return s.forEach((l,a)=>{Zc.has(l)&&r.push({char:l,context:s.slice(Math.max(0,a-8),a+9).join("")})}),r}function Xc(t){if(!t)return"";try{const n=new URL(t).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 Qc(){return{id:"",name:"",url:"",type:"text",details:""}}const fi=({items:t,onChange:n,onDownload:o,downloadStatuses:r,filterType:s})=>{const l=ve(),[a,p]=x.useState(null),c=[{value:"text",label:l.resourceTypeShort.text},{value:"image",label:l.resourceTypeShort.image},{value:"text+image",label:l.resourceTypeShort.textImage},{value:"physical",label:l.resourceTypeShort.physical}],d=[{value:"catalog",label:l.rootType.catalog},{value:"search",label:l.rootType.search}],u=b=>{if(!s)return!0;const j=Nt(b);return s==="text"?j.includes("text"):s==="image"?j.includes("image")||j.includes("physical"):s==="physical"?j.includes("physical"):j.includes(s)},g=t.map((b,j)=>({item:b,originalIndex:j})).filter(({item:b})=>u(b)),m=()=>{const b=Qc();s&&(b.type=s),n([...t,b]),p(t.length)},h=b=>{n(t.filter((j,S)=>S!==b)),p(null)},f=(b,j,S)=>{const k=[...t];if(k[b]={...k[b],[j]:S},j==="url"&&!k[b].id){const $=Xc(S);$&&(k[b].id=$)}n(k)},v=(b,j,S)=>{const $={...t[b].metadata||{}};S?$[j]=S:delete $[j],f(b,"metadata",Object.keys($).length>0?$:void 0)},y=(b,j)=>{const S=j.trim()?j.split(/[,,、]/).map(k=>k.trim()).filter(Boolean):void 0;f(b,"structure",S)},w=(b,j,S)=>{const $=t[b].coverage||{level:1,ranges:""};j==="level"?$.level=parseInt(S)||1:$.ranges=S,f(b,"coverage",$.ranges?$:void 0)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[g.map(({item:b,originalIndex:j})=>{var S,k,$;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>p(a===j?null:j),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:a===j?"▼":"▶"}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:ed(b.type??"text"),color:i("on-color-fg")},children:(()=>{var z,E;const _=Nt(b);return _.length===0?b.type??"text":_.length===1?((z=c.find(T=>T.value===_[0]))==null?void 0:z.label)??_[0]:_.includes("text")&&_.includes("image")?((E=c.find(T=>T.value==="text+image"))==null?void 0:E.label)??"text+image":_.join("+")})()}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:b.name||`${l.editor.resourcePlaceholder} ${j+1}`}),b.id&&e.jsx("span",{style:{fontSize:"11px",opacity:.5},children:b.id}),b.url&&e.jsx("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),o&&b.url&&td(j,r==null?void 0:r[j],o,l),e.jsx("button",{onClick:_=>{_.stopPropagation(),h(j)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:l.editor.deleteThisResource,children:"✕"})]}),a===j&&e.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:[Sc(b,"image")&&b.url&&nd(b,l),e.jsxs("div",{style:{display:"grid",gap:"8px"},children:[e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:qt,children:[e.jsx("span",{style:Zt,children:l.label.type}),e.jsx("select",{value:b.type,onChange:_=>f(j,"type",_.target.value),style:{...dt,flex:1},children:c.map(_=>e.jsx("option",{value:_.value,children:_.label},_.value))})]}),e.jsxs("label",{style:qt,children:[e.jsx("span",{style:Zt,children:l.label.rootType}),e.jsx("select",{value:b.root_type||"catalog",onChange:_=>f(j,"root_type",_.target.value),style:{...dt,flex:1},children:d.map(_=>e.jsx("option",{value:_.value,children:_.label},_.value))})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("input",{type:"text",value:b.id,onChange:_=>f(j,"id",_.target.value),placeholder:l.editor.idAutoExtract,style:{...dt,width:"140px",flexShrink:0}}),e.jsx("input",{type:"text",value:b.name,onChange:_=>f(j,"name",_.target.value),placeholder:l.editor.resourceName,style:{...dt,flex:1}})]}),e.jsx("input",{type:"text",value:b.url,onChange:_=>f(j,"url",_.target.value),placeholder:l.editor.resourceUrl,style:dt}),e.jsx("input",{type:"text",value:((S=b.structure)==null?void 0:S.join("、"))||"",onChange:_=>y(j,_.target.value),placeholder:l.editor.structurePlaceholder,style:dt}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:qt,children:[e.jsx("span",{style:Zt,children:l.label.coverageLevel}),e.jsx("input",{type:"number",min:1,value:((k=b.coverage)==null?void 0:k.level)??"",onChange:_=>w(j,"level",_.target.value),placeholder:"1",style:{...dt,width:"60px"}})]}),e.jsxs("label",{style:{...qt,flex:1},children:[e.jsx("span",{style:Zt,children:l.label.coverageRange}),e.jsx("input",{type:"text",value:(($=b.coverage)==null?void 0:$.ranges)||"",onChange:_=>w(j,"ranges",_.target.value),placeholder:l.editor.coverageRangePlaceholder,style:{...dt,flex:1}})]})]}),e.jsx("textarea",{value:b.details||"",onChange:_=>f(j,"details",_.target.value),placeholder:l.editor.detailsPlaceholder,style:{...dt,minHeight:"60px",resize:"vertical"}}),e.jsxs("div",{style:{borderTop:`1px solid ${i("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"6px"},children:l.label.metadata}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(l.metadata).map(([_,z])=>{var E;return e.jsxs("label",{style:{...qt,gap:"4px"},children:[e.jsx("span",{style:{...Zt,minWidth:"56px"},children:z}),e.jsx("input",{type:"text",value:((E=b.metadata)==null?void 0:E[_])||"",onChange:T=>v(j,_,T.target.value),placeholder:z,style:{...dt,flex:1}})]},_)})})]})]})]})]},j)}),e.jsxs("button",{onClick:m,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:[e.jsx("span",{children:"+"}),e.jsx("span",{children:l.action.addResource})]})]})};function ed(t){switch(t){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 td(t,n,o,r){const s=(n==null?void 0:n.status)==="downloading",l=(n==null?void 0:n.status)==="completed";return e.jsx("button",{onClick:a=>{a.stopPropagation(),s||o(t,"")},disabled:s,style:{background:"transparent",border:"none",color:i(l?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:l?r.download.completed:s?`${r.download.downloading} ${(n==null?void 0:n.progress)||0}%`:r.download.downloadThis,children:l?"✓":s?"⏳":"⬇"})}function nd(t,n){const o=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(t.url)||t.url.includes("iiif")||t.url.includes("image");return e.jsx("div",{style:{marginBottom:"12px"},children:o?e.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:i("overlay-bg")},children:e.jsx("img",{src:t.url,alt:t.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:r=>{r.target.style.display="none"}})}):e.jsx("div",{style:{padding:"12px",background:i("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:i("desc-fg")},children:n.editor.imageResourceLink})})}const dt={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"},qt={display:"flex",alignItems:"center",gap:"6px"},Zt={fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap"},id={"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 Ut(t){try{return id[new URL(t).hostname]}catch{return}}const Oo={text:0,image:1,physical:2};function Hi(t){return t.length===0?"physical":[...t].sort((n,o)=>(Oo[n]??99)-(Oo[o]??99)).join("+")}function Oi(t){var a;const n=p=>{const c=p.match(/^(.+?)·第(\d+)[冊册]$/);if(c)return[c[1],parseInt(c[2])];const d=p.match(/^(.+?)[·(](\d+)[)]?$/);return d?[d[1],parseInt(d[2])]:null},o=new Map;for(let p=0;p<t.length;p++){const c=t[p];if(c.volumes&&c.volumes.length>0)continue;const d=n(c.name);if(!d)continue;const[u,g]=d,m=`${u}|${Hi(Nt(c))}`;o.has(m)||o.set(m,{base:{...c,name:u,url:"",volumes:[]},volumes:[],indices:[]});const h=o.get(m);h.volumes.push({volume:g,url:c.url||void 0,status:"found"}),h.indices.push(p)}const r=[],s=new Set;for(const p of o.values())if(!(p.volumes.length<2)){p.volumes.sort((c,d)=>c.volume-d.volume),p.base.volumes=p.volumes,p.base.expected_volumes=p.volumes.length,p.base.url||(p.base.url=((a=p.volumes.find(c=>c.url))==null?void 0:a.url)??""),r.push(p.base);for(const c of p.indices)s.add(c)}const l=[...r];for(let p=0;p<t.length;p++)s.has(p)||l.push(t[p]);return l}function xs(t){if(t.url)return t.url;for(const[n,o]of Object.entries(t))if(n.endsWith("_url")&&typeof o=="string")return o}function fs(t){return!Array.isArray(t.volumes)||t.volumes.length===0?null:t.volumes.map(n=>({...n,url:n.url||xs(n)}))}function Ln(t){const n=fs(t);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:t.expected_volumes??o+r}}function Fi(t){if(!t)return;const n=t.file_page_range||t.page_range;if(!n||typeof n!="string")return;const o=n.match(/^(\d+)/);return o?parseInt(o[1],10):void 0}function Di(t,n){try{if(new URL(t).hostname.includes("wikimedia.org")){const r=t.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(t);return s.searchParams.set("page",String(n)),s.toString()}return t}catch{return t}}function Vt(t){if(!t.url)return;const n=Fi(t.metadata);return n?Di(t.url,n):t.url}const Fo={text:i("restype-text"),image:i("restype-image"),"text+image":i("restype-text-image"),physical:i("restype-physical")};function od(t){return t.includes("text")&&t.includes("image")?Fo["text+image"]:Fo[t[0]||"physical"]}const Ui=({items:t,groupByType:n=!0,resourceGroups:o,onNavigate:r,renderLink:s})=>{const l=ve(),{convert:a}=Te(),p=x.useMemo(()=>Oi(t||[]),[t]),{mirrorGroups:c,ungroupedItems:d}=x.useMemo(()=>{const y=new Map,w=[];for(const b of p){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 k=$=>$.group_role==="origin"?0:$.group_role==="mirror"?1:2;return k(j)-k(S)});return{mirrorGroups:y,ungroupedItems:w}},[p]),u={text:l.resourceType.text,image:l.resourceType.image,"text+image":l.resourceType.textImage,physical:l.resourceType.physical},g=y=>u[y]?u[y]:y.split("+").map(w=>u[w]||w).join("+");if(!p||p.length===0)return e.jsx("div",{style:{padding:"16px",color:i("desc-fg"),fontSize:"13px",textAlign:"center"},children:l.misc.noResources});if(!n)return e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:p.map((y,w)=>e.jsx(ei,{item:y},y.id||w))});const m=(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 e.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:[e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:a(j)}),S&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.5},children:a(S)}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:w.map((k,$)=>e.jsx(ei,{item:k,onNavigate:r,renderLink:s},k.id||$))})]},`group-${y}`)},h=new Map;for(const y of d){const w=Hi(Nt(y));h.has(w)||h.set(w,[]),h.get(w).push(y)}const f=["text","image","text+image","physical"],v=[...f.filter(y=>h.has(y)),...[...h.keys()].filter(y=>!f.includes(y)).sort()];return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,w])=>m(y,w)),v.map(y=>{const w=h.get(y),b=od(y.split("+"));return e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:b,whiteSpace:"nowrap",flexShrink:0},children:g(y)}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:w.map((j,S)=>e.jsx(ei,{item:j,onNavigate:r,renderLink:s},j.id||S))})]},y)})]})},rd={bw:{label:"",bg:i("colormode-bw-bg"),fg:i("colormode-bw-fg")},color:{label:"",bg:i("colormode-color-bg"),fg:i("colormode-color-fg")}},ei=({item:t})=>{const n=ve(),{convert:o}=Te(),[r,s]=x.useState(!1),l=x.useMemo(()=>(t.url?Ut(t.url):void 0)||o(t.name),[t.url,t.name,o]),a=x.useMemo(()=>!Array.isArray(t.volumes)||t.volumes.length===0?null:t.volumes.map(f=>({...f,url:f.url||xs(f)})),[t.volumes]),p=a&&a.length>0,c=p?new Set(a.filter(f=>f.status!=="missing").map(f=>f.volume)).size:0,d=p?new Set(a.filter(f=>f.status==="missing").map(f=>f.volume)).size:0,u=t.expected_volumes??(p?c+d:0),g=t.color_mode?{...rd[t.color_mode],label:n.colorMode[t.color_mode]}:null,m=t.details&&!p?o(t.details):null,h={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 e.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[e.jsxs("div",{style:h,children:[e.jsx("span",{style:{fontWeight:500},children:l}),g&&e.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:g.bg,color:g.fg},children:g.label}),m&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:m}),p&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[c,"/",u,n.unit.volume,d>0&&e.jsx("span",{style:{color:i("missing-fg"),marginLeft:"3px"},children:it(n.common.volumesMissing,{n:d})})]}),t.url&&e.jsx("a",{href:(()=>{const f=Fi(t.metadata);return f?Di(t.url,f):t.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:i("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),p&&e.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?"▲":"▼"})]}),p&&r&&e.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:a.map(f=>{const v=f.status==="missing";return f.url&&!v?e.jsx("a",{href:f.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:f.volume},f.volume):e.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:i(v?"missing-fg":"desc-fg"),textDecoration:v?"line-through":"none",opacity:v?.6:1},children:f.volume},f.volume)})})]})},bs=({indexSource:t,syncConfig:n,variant:o="index-browser",onSwitchMode:r,onToggleDraft:s,onConfigurePath:l,onSelectFolder:a})=>{const p=ve(),c=t==="local",d=(n==null?void 0:n.isDraft)??!0,u=(n==null?void 0:n.repoPath)||"",g=u?u.split(/[/\\]/).pop()||u:"",m={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:i("primary-soft"),color:i("primary")},h={onMouseOver:v=>v.currentTarget.style.opacity="0.8",onMouseOut:v=>v.currentTarget.style.opacity="1"},f=e.jsxs("div",{onClick:s,title:d?p.mode.switchToOfficial:p.mode.switchToDraft,style:{...m,background:i(d?"warning":"success"),color:i("on-color-fg")},...h,children:[e.jsx("span",{children:d?"📝":"📚"}),e.jsx("span",{children:d?"draft":"official"})]});return o==="index-browser"?c?e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[f,e.jsxs("div",{onClick:r,title:p.mode.switchToSync,style:m,...h,children:[e.jsx("span",{children:"📁"}),e.jsx("span",{children:p.mode.localMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsxs("div",{onClick:a,title:u||p.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px"},...h,children:[e.jsx("span",{children:"📂"}),g&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:g})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f,e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("div",{onClick:r,title:p.mode.switchToLocal,style:m,...h,children:[e.jsx("span",{children:"🌐"}),e.jsx("span",{children:p.mode.syncMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsx("div",{onClick:l,title:g||p.mode.configurePath,style:{...m,background:"transparent",padding:"6px",fontSize:"12px"},...h,children:e.jsx("span",{children:"⚙️"})})]})]}):e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[e.jsxs("div",{onClick:r,title:c?p.mode.switchToGithub:p.mode.switchToLocal,style:m,...h,children:[e.jsx("span",{children:c?"📁":"🌐"}),e.jsx("span",{children:c?p.mode.localMode:p.mode.githubSync}),e.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&e.jsxs("div",{onClick:a,title:u||p.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px",minWidth:u?"100px":"auto",justifyContent:"space-between"},...h,children:[e.jsx("span",{children:"📂"}),g&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:g})]}),!c&&g&&e.jsxs("div",{style:{...m,background:i("mode-active-bg"),color:i("on-color-fg"),cursor:"default"},title:u,children:[e.jsx("span",{children:"📂"}),e.jsx("span",{style:{fontSize:"11px"},children:g})]})]})},Pn="bim-search-history",Do=10,Uo=8;function on(){try{const t=localStorage.getItem(Pn);return t?JSON.parse(t):[]}catch{return[]}}function ys(t){try{const n=on().filter(o=>o!==t);n.unshift(t),n.length>Do&&(n.length=Do),localStorage.setItem(Pn,JSON.stringify(n))}catch{}}function sd(t){try{const n=on().filter(o=>o!==t);localStorage.setItem(Pn,JSON.stringify(n))}catch{}}function ld(){try{localStorage.removeItem(Pn)}catch{}}const js=({transport:t,value:n,onChange:o,onSearch:r,onEntrySelect:s,placeholder:l})=>{const a=ve(),p=l??a.search.placeholder,c={work:a.indexType.work,book:a.indexType.book,collection:a.indexType.collection,entity:a.indexType.entity},[d,u]=x.useState(!1),[g,m]=x.useState([]),[h,f]=x.useState(-1),[v,y]=x.useState(on),w=x.useRef(null),b=x.useRef(null),j=x.useRef(null),S=x.useRef(!1);x.useEffect(()=>{f(-1);const C=n.trim();if(!C){m(v.map(P=>({type:"history",text:P})));return}if(!t.searchAll){m([]);return}let O=!1;const W=setTimeout(()=>{t.searchAll(C,Uo).then(P=>{if(O)return;const Y=[...P.works,...P.books,...P.collections,...P.entities??[]];m(Y.slice(0,Uo).map(V=>({type:"entry",text:V.title||V.id,entry:V})))}).catch(()=>{O||m([])})},80);return()=>{O=!0,clearTimeout(W)}},[n,v,t]),x.useEffect(()=>{const C=O=>{j.current&&!j.current.contains(O.target)&&u(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[]),x.useEffect(()=>{const C=O=>{var W,P;if(O.key==="/"&&document.activeElement!==w.current){const Y=(W=document.activeElement)==null?void 0:W.tagName;if(Y==="INPUT"||Y==="TEXTAREA"||Y==="SELECT")return;O.preventDefault(),(P=w.current)==null||P.focus()}};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[]);const k=x.useCallback(C=>{C.trim()&&(ys(C.trim()),y(on())),r(C),u(!1)},[r]),$=x.useCallback(C=>{C.type==="history"?(o(C.text),k(C.text)):C.entry&&(s?(s(C.entry),u(!1)):(o(C.text),k(C.text)))},[o,k,s]),_=x.useCallback(C=>{if(!d||g.length===0){C.key==="Enter"&&k(n);return}switch(C.key){case"ArrowDown":C.preventDefault(),f(O=>(O+1)%g.length);break;case"ArrowUp":C.preventDefault(),f(O=>(O-1+g.length)%g.length);break;case"Enter":C.preventDefault(),h>=0&&h<g.length?$(g[h]):k(n);break;case"Escape":C.preventDefault(),u(!1);break}},[d,g,h,n,k,$]),z=x.useCallback((C,O)=>{O.stopPropagation(),sd(C),y(on()),m(W=>W.filter(P=>!(P.type==="history"&&P.text===C)))},[]),E=x.useCallback(C=>{C.stopPropagation(),ld(),y([]),m([])},[]);x.useEffect(()=>{if(h>=0&&b.current){const C=b.current.children;C[h]&&C[h].scrollIntoView({block:"nearest"})}},[h]);const T=!n.trim()&&v.length>0;return e.jsxs("div",{ref:j,style:{position:"relative",flex:1},children:[e.jsx("input",{ref:w,type:"text",placeholder:p,value:n,onChange:C=>{o(C.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"}}),d&&g.length>0&&e.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&&e.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:[e.jsx("span",{children:a.search.history}),e.jsx("button",{onClick:E,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:a.search.clearAll})]}),g.map((C,O)=>e.jsxs("div",{onClick:()=>$(C),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:i("fg"),background:O===h?i("list-active-bg"):"transparent"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:C.type==="history"?"🕐":"🔍"}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.text}),C.entry&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:[c[C.entry.type],C.entry.edition&&` · ${C.entry.edition}`,C.entry.author&&` · ${C.entry.author}`]}),C.type==="history"&&e.jsx("button",{onClick:W=>z(C.text,W),style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:a.action.remove,children:"×"})]},`${C.type}-${C.text}-${O}`))]})]})},Gt=({type:t,size:n=9})=>e.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:i(`type-${t}`),verticalAlign:"middle"}}),An={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},vs=new Set(["work","book","entity"]);function ad(t){return Ss(t)||!!t.sort}function cd(t,n){return n.sort&&vs.has(t)?n.sort:void 0}const Bn=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],Mn=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],ks=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],ws={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function Wn(t){return t.dynasty.length+t.classification.length+(t.hasImage?1:0)+(t.hasText?1:0)+(t.hasCollated?1:0)+(t.loss?1:0)}function Ss(t){return Wn(t)>0}function dd(t){const n=[];return t.dynasty.length&&n.push("dynasty"),t.classification.length&&n.push("classification"),t.hasImage&&n.push("hasImage"),t.hasText&&n.push("hasText"),t.hasCollated&&n.push("hasCollated"),t.loss&&n.push("loss"),n}function $s(t,n){const o=ws[t];return dd(n).every(r=>o.has(r))}const Jt=t=>JSON.stringify(t);function pd(t,n){if(!$s(n,t))return null;const o=[];if(t.dynasty.length){const r=Array.from(new Set(t.dynasty.flatMap(s=>{var l;return((l=Bn.find(a=>a.key===s))==null?void 0:l.values)??[]})));r.length===1?o.push(`dynasty = ${Jt(r[0])}`):r.length>1&&o.push(`dynasty IN [${r.map(Jt).join(", ")}]`)}return t.classification.length&&o.push(t.classification.length===1?`classification = ${Jt(t.classification[0])}`:`classification IN [${t.classification.map(Jt).join(", ")}]`),t.hasImage&&o.push("has_image = true"),t.hasText&&o.push("has_text = true"),t.hasCollated&&o.push("has_collated = true"),t.loss&&o.push(`loss_status = ${Jt(t.loss)}`),o.join(" AND ")}const Je={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},_s="_";function _n(t,n=new URLSearchParams){for(const o of Object.values(Je))n.delete(o);return t.dynasty.length&&n.set(Je.dynasty,t.dynasty.join(",")),t.classification.length&&n.set(Je.classification,t.classification.map(o=>o||_s).join(",")),t.hasImage&&n.set(Je.hasImage,"1"),t.hasText&&n.set(Je.hasText,"1"),t.hasCollated&&n.set(Je.hasCollated,"1"),t.loss&&n.set(Je.loss,t.loss),t.sort&&n.set(Je.sort,t.sort),n}function ud(t){const n=l=>(t.get(l)??"").split(",").map(a=>a.trim()).filter(Boolean),o=new Set(Bn.map(l=>l.key)),r=new Set(Mn.map(l=>l.value)),s=t.get(Je.loss);return{dynasty:Array.from(new Set(n(Je.dynasty).filter(l=>o.has(l)))),classification:Array.from(new Set(n(Je.classification).map(l=>l===_s?"":l).filter(l=>r.has(l)))),hasImage:t.get(Je.hasImage)==="1",hasText:t.get(Je.hasText)==="1"||t.get(Je.hasCollated)==="1",hasCollated:!1,loss:s==="extant"||s==="partially_extant"||s==="lost"?s:"",sort:["era:asc","era:desc","title:asc","title:desc"].find(l=>l===t.get(Je.sort))??""}}function md(t,n){return JSON.stringify([t.dynasty.slice().sort(),t.classification.slice().sort(),t.hasImage,t.hasText,t.hasCollated,t.loss,t.sort])===JSON.stringify([n.dynasty.slice().sort(),n.classification.slice().sort(),n.hasImage,n.hasText,n.hasCollated,n.loss,n.sort])}function Vo(t,n){return t.includes(n)?t.filter(o=>o!==n):[...t,n]}const gd=({filters:t,onChange:n})=>{const o=ve(),r=o.searchV4,{convert:s}=Te(),[l,a]=x.useState(!1),p=x.useId(),c=Wn(t),d=u=>n({...t,...u});return e.jsxs("aside",{className:"bim-sr-aside","aria-label":s(r.filterTitle),children:[e.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":l,"aria-controls":p,onClick:()=>a(u=>!u),children:[e.jsxs("span",{children:[s(r.filterButton),c>0&&e.jsx("span",{className:"bim-sr-fn",children:s(it(r.filterSelected,{n:c}))})]}),e.jsxs("span",{className:"bim-sr-fa","aria-hidden":"true",children:[s(l?r.collapse:r.expand)," ",l?"▴":"▾"]})]}),e.jsxs("div",{className:"bim-sr-filters",id:p,"data-open":l?"true":"false",...l?{}:{"data-collapsed":"true"},children:[e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:s(r.dynasty)}),e.jsx("div",{className:"bim-sr-chips",children:Bn.map(u=>e.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":t.dynasty.includes(u.key),onClick:()=>d({dynasty:Vo(t.dynasty,u.key)}),children:s(u.key)},u.key))})]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:s(r.classification)}),Mn.map(u=>e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.classification.includes(u.value),onChange:()=>d({classification:Vo(t.classification,u.value)})}),u.value?s(u.label):o.searchPage.unclassified]},u.value||"_"))]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:s(r.resources)}),e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.hasImage,onChange:u=>d({hasImage:u.target.checked})}),s(r.hasImage)]}),e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.hasText,onChange:u=>d({hasText:u.target.checked})}),s(r.hasText)]})]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{id:`${p}-loss`,children:s(r.extant)}),e.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${p}-loss`,children:ks.map(u=>e.jsx("button",{type:"button","aria-pressed":t.loss===u.value,onClick:()=>d({loss:u.value}),children:o.searchPage.loss[u.value||"all"]},u.value||"all"))})]}),c>0&&e.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...An,sort:t.sort}),children:s(r.clearAllFilters)})]})]})};function Cs({text:t,query:n}){const o=(n??"").trim();if(!o||!t)return e.jsx(e.Fragment,{children:t});const r=t.toLowerCase(),s=o.toLowerCase(),l=[];let a=0,p=0;for(;a<t.length;){const c=r.indexOf(s,a);if(c<0){l.push(t.slice(a));break}c>a&&l.push(t.slice(a,c)),l.push(e.jsx("mark",{className:"bim-sr-hl",children:t.slice(c,c+s.length)},p++)),a=c+s.length}return e.jsx(e.Fragment,{children:l})}const Go=({entries:t,query:n,onEntryLinkClick:o,typeName:r})=>{const s=ve(),l=s.searchV4,{convert:a}=Te(),p=Ye();return e.jsx("div",{className:"bim-sr-tablewrap",children:e.jsxs("table",{className:"bim-sr-table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"34%"}}),e.jsx("col",{style:{width:"8%"}}),e.jsx("col",{style:{width:"19%"}}),e.jsx("col",{style:{width:"13%"}}),e.jsx("col",{style:{width:"12%"}}),e.jsx("col",{style:{width:"14%"}})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:a(l.colTitle)}),e.jsx("th",{scope:"col",children:a(l.colType)}),e.jsx("th",{scope:"col",children:a(l.colAuthor)}),e.jsx("th",{scope:"col",children:a(l.colEra)}),e.jsx("th",{scope:"col",children:a(l.colClass)}),e.jsx("th",{scope:"col",style:{textAlign:"right"},children:a(l.colResource)})]})}),e.jsx("tbody",{children:t.map(c=>{const d=a(c.title||c.primary_name||c.id),u=c.measure_info?a(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",g=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${a(c.author)}${c.role&&c.role!=="author"?` ${a(c.role)}`:""}`:"",m=c.type==="book"?c.era??c.dynasty:c.dynasty,h=m?a(m):"",f=c.classification?a(c.classification):"",v=[];c.has_image&&v.push({label:l.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&v.push({label:l.tagText,cls:""}),c.loss_status==="lost"&&v.push({label:l.tagLost,cls:"bim-sr-tag--lost"});const y=[g,h,f].filter(Boolean).join(" · ");return e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-sr-c-title",children:[e.jsxs("div",{className:"bim-sr-tl",children:[e.jsx("a",{href:p(c.id),onClick:w=>o(c,w),children:e.jsx(Cs,{text:d,query:n?a(n):void 0})}),u&&e.jsx("span",{className:"bim-sr-measure",children:u})]}),y&&e.jsx("span",{className:"bim-sr-sub",children:y})]}),e.jsxs("td",{className:"bim-sr-c-type",children:[e.jsx(Gt,{type:c.type,size:6})," ",r(c.type)]}),e.jsx("td",{className:"bim-sr-c-who",children:g||"—"}),e.jsx("td",{className:"bim-sr-c-era",children:h||"—"}),e.jsx("td",{className:"bim-sr-c-cls",children:f||"—"}),e.jsx("td",{className:"bim-sr-c-res",children:v.map(w=>e.jsx("span",{className:`bim-sr-tag ${w.cls}`,children:a(w.label)},w.label))})]},c.id)})})]})})},hd=`
1
+ "use strict";var pc=Object.create;var Ao=Object.defineProperty;var uc=Object.getOwnPropertyDescriptor;var mc=Object.getOwnPropertyNames;var gc=Object.getPrototypeOf,hc=Object.prototype.hasOwnProperty;var xc=(t,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of mc(n))!hc.call(t,s)&&s!==o&&Ao(t,s,{get:()=>n[s],enumerable:!(r=uc(n,s))||r.enumerable});return t};var bn=(t,n,o)=>(o=t!=null?pc(gc(t)):{},xc(n||!t||!t.__esModule?Ao(o,"default",{value:t,enumerable:!0}):o,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const be=require("./storage-entry-C9uAfe4i.cjs"),e=require("react/jsx-runtime"),h=require("react"),fc=require("opencc-js/t2cn"),bc=require("react-markdown"),yc=require("remark-gfm"),jc=t=>`/book-index?id=${t}`,ls=h.createContext(jc);function vc({buildUrl:t,children:n}){const o=h.useMemo(()=>t,[t]);return e.jsx(ls.Provider,{value:o,children:n})}function Ye(){return h.useContext(ls)}const as="",cs="";function Mi(t){const n=[];let o=!1,r=t;for(;r.length;){const s=o?cs:as,l=r.indexOf(s);if(l===-1){n.push({text:r,marked:o});break}l>0&&n.push({text:r.slice(0,l),marked:o}),r=r.slice(l+1),o=!o}return n}function Qe(t,n){return{title:t,tokens:n}}const Bo='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',kc=[Qe("基础(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"}}),Qe("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),Qe("提示与警告",{"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)"}}),Qe("遮罩与阴影",{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)"}}),Qe("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),Qe("资源",{"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"}}),Qe("整理本(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"}}),Qe("版本传承(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"}}),Qe("编辑器视图(主要在 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")'}}),Qe("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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}}),Qe('版式(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"}}),Qe("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"}}),Qe("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),Qe("字体(全站无衬线,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:Bo,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:Bo,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],wc=Object.assign({},...kc.map(t=>t.tokens)),ds={};for(const[t,n]of Object.entries(wc))ds[t]=`var(--bim-${t}, ${n.value})`;function i(t){const n=ds[t];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${t}`);return n}function Nt(t){return t.types&&t.types.length>0?t.types:t.type?t.type==="text+image"?["text","image"]:[t.type]:[]}function Sc(t,n){return Nt(t).includes(n)}const $c={published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"};i("quality-published"),i("quality-fine"),i("quality-rough"),i("quality-ocr");const It=h.createContext(null),ps=["曹霑"];function _c(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cc(t,n=ps){const o=[...new Set(n.filter(Boolean))].sort((l,a)=>a.length-l.length);if(!o.length)return t;const r=new RegExp(`(${o.map(_c).join("|")})`,"g"),s=new Set(o);return l=>{if(!l)return t(l);const a=l.split(r);return a.length===1?t(l):a.map((p,c)=>c%2===1&&s.has(p)?p:p&&t(p)).join("")}}let Kt=null;function zc(){if(Kt)return Kt;try{const t=fc.Converter({from:"t",to:"cn"});Kt=Cc(n=>t(be.normalizeVariants(n)))}catch{Kt=t=>t}return Kt}const Tc={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:"圖片資源"}},Nc={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 tt(t,n,o){return{"zh-Hant":t,"zh-Hans":n}}const Ic=tt({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:"无数据"}),En=tt({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:"作品信息"}),Rc=tt({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:"附记"}}),Ec=tt({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}"}}),Lc=tt({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:"上级丛编"}),Pc=tt({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 为自动匹配,未经人工核对"}),Ac=tt({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:"参考文献"}),Bc=tt({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:"本卷条目"}),Mc=tt({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:"规模、存佚、许可与版本"}),Wi=tt({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:"按作者浏览全部 →"}),Wc=tt({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} 条"}),Hc=tt({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:"搜索"}),Oc=tt({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:"回复"}),Fc=tt({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:"有争议"}}),Dc={common:Ic,detail:En,bookPage:Rc,workPage:Ec,collectionPage:Lc,entityPage:Pc,reader:Ac,collated:Bc,metaHome:Mc,readHome:Wi,catalogPage:Wc,searchPage:Hc,feedback:Oc,lineage:Fc};function Uc(t){const n={};for(const[o,r]of Object.entries(Dc))n[o]=r[t];return n}function it(t,n){return t.replace(/\{(\w+)\}/g,(o,r)=>String(n[r]??""))}const Mo=new Map;function Ft(t){let n=Mo.get(t);return n||(n={...t==="zh-Hans"?Nc:Tc,...Uc(t)},Mo.set(t,n)),n}function Wo(t,n){let o=t;for(const r of n.split(".")){if(o==null||typeof o!="object")return;o=o[r]}return typeof o=="string"?o:void 0}function us(t){return(n,o)=>{const r=Wo(t,n)??Wo(Ft("zh-Hant"),n)??n;return o?it(r,o):r}}const Ho=new Map;function Dt(t){let n=Ho.get(t);return n||(n=us(Ft(t)),Ho.set(t,n)),n}const ms="bim-locale";function Vc(){try{const t=localStorage.getItem(ms);if(t==="zh-Hant"||t==="zh-Hans")return t}catch{}}function Gc(t){try{localStorage.setItem(ms,t)}catch{}}const Yc="zh-Hans",Kc=({locale:t,onLocaleChange:n,converter:o,children:r})=>{const[s,l]=h.useState(t??Yc),a=t??s;h.useEffect(()=>{if(t)return;const u=Vc();u&&u!==s&&l(u)},[]);const p=h.useMemo(()=>a==="zh-Hans"?o??zc():null,[a,o]),c=h.useCallback(u=>{l(u),Gc(u),n==null||n(u)},[n]),d=h.useMemo(()=>({locale:a,setLocale:c,messages:Ft(a),converter:p}),[a,c,p]);return e.jsx(It.Provider,{value:d,children:r})};function ke(){const t=h.useContext(It);return(t==null?void 0:t.messages)??Ft("zh-Hant")}const qc=2e3;function Ne(){const t=h.useContext(It),n=(t==null?void 0:t.locale)??"zh-Hant",o=(t==null?void 0:t.converter)??null,r=h.useRef(new Map),s=h.useRef(n);s.current!==n&&(r.current.clear(),s.current=n);const l=h.useCallback(a=>{if(!a)return"";if(!o)return a;const p=r.current.get(a);if(p!==void 0)return p;const c=o(a);if(r.current.size>=qc){const d=r.current.keys().next().value;d!==void 0&&r.current.delete(d)}return r.current.set(a,c),c},[o]);return h.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function Y(){const t=h.useContext(It),{convert:n,locale:o,isSimplified:r}=Ne(),s=(t==null?void 0:t.messages)??Ft("zh-Hant"),l=h.useMemo(()=>t?us(s):Dt("zh-Hant"),[t,s]);return h.useMemo(()=>({t:l,convert:n,locale:o,isSimplified:r,messages:s}),[l,n,o,r,s])}const gs=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),Zc=new Set([...gs,...Object.keys(be.VARIANT_CHARS)]),hs=[...ps,"切換為繁體","漢籍リポジトリ"];function Jc(t,n=hs){let o=t;for(const l of n)l&&(o=o.split(l).join(" "));const r=[],s=Array.from(o);return s.forEach((l,a)=>{Zc.has(l)&&r.push({char:l,context:s.slice(Math.max(0,a-8),a+9).join("")})}),r}function Xc(t){if(!t)return"";try{const n=new URL(t).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 Qc(){return{id:"",name:"",url:"",type:"text",details:""}}const fi=({items:t,onChange:n,onDownload:o,downloadStatuses:r,filterType:s})=>{const l=ke(),[a,p]=h.useState(null),c=[{value:"text",label:l.resourceTypeShort.text},{value:"image",label:l.resourceTypeShort.image},{value:"text+image",label:l.resourceTypeShort.textImage},{value:"physical",label:l.resourceTypeShort.physical}],d=[{value:"catalog",label:l.rootType.catalog},{value:"search",label:l.rootType.search}],u=y=>{if(!s)return!0;const j=Nt(y);return s==="text"?j.includes("text"):s==="image"?j.includes("image")||j.includes("physical"):s==="physical"?j.includes("physical"):j.includes(s)},g=t.map((y,j)=>({item:y,originalIndex:j})).filter(({item:y})=>u(y)),m=()=>{const y=Qc();s&&(y.type=s),n([...t,y]),p(t.length)},x=y=>{n(t.filter((j,S)=>S!==y)),p(null)},f=(y,j,S)=>{const v=[...t];if(v[y]={...v[y],[j]:S},j==="url"&&!v[y].id){const $=Xc(S);$&&(v[y].id=$)}n(v)},k=(y,j,S)=>{const $={...t[y].metadata||{}};S?$[j]=S:delete $[j],f(y,"metadata",Object.keys($).length>0?$:void 0)},b=(y,j)=>{const S=j.trim()?j.split(/[,,、]/).map(v=>v.trim()).filter(Boolean):void 0;f(y,"structure",S)},w=(y,j,S)=>{const $=t[y].coverage||{level:1,ranges:""};j==="level"?$.level=parseInt(S)||1:$.ranges=S,f(y,"coverage",$.ranges?$:void 0)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[g.map(({item:y,originalIndex:j})=>{var S,v,$;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>p(a===j?null:j),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:a===j?"▼":"▶"}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:ed(y.type??"text"),color:i("on-color-fg")},children:(()=>{var z,E;const C=Nt(y);return C.length===0?y.type??"text":C.length===1?((z=c.find(T=>T.value===C[0]))==null?void 0:z.label)??C[0]:C.includes("text")&&C.includes("image")?((E=c.find(T=>T.value==="text+image"))==null?void 0:E.label)??"text+image":C.join("+")})()}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:y.name||`${l.editor.resourcePlaceholder} ${j+1}`}),y.id&&e.jsx("span",{style:{fontSize:"11px",opacity:.5},children:y.id}),y.url&&e.jsx("a",{href:y.url,target:"_blank",rel:"noopener noreferrer",onClick:C=>C.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),o&&y.url&&td(j,r==null?void 0:r[j],o,l),e.jsx("button",{onClick:C=>{C.stopPropagation(),x(j)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:l.editor.deleteThisResource,children:"✕"})]}),a===j&&e.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:[Sc(y,"image")&&y.url&&nd(y,l),e.jsxs("div",{style:{display:"grid",gap:"8px"},children:[e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:qt,children:[e.jsx("span",{style:Zt,children:l.label.type}),e.jsx("select",{value:y.type,onChange:C=>f(j,"type",C.target.value),style:{...dt,flex:1},children:c.map(C=>e.jsx("option",{value:C.value,children:C.label},C.value))})]}),e.jsxs("label",{style:qt,children:[e.jsx("span",{style:Zt,children:l.label.rootType}),e.jsx("select",{value:y.root_type||"catalog",onChange:C=>f(j,"root_type",C.target.value),style:{...dt,flex:1},children:d.map(C=>e.jsx("option",{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("input",{type:"text",value:y.id,onChange:C=>f(j,"id",C.target.value),placeholder:l.editor.idAutoExtract,style:{...dt,width:"140px",flexShrink:0}}),e.jsx("input",{type:"text",value:y.name,onChange:C=>f(j,"name",C.target.value),placeholder:l.editor.resourceName,style:{...dt,flex:1}})]}),e.jsx("input",{type:"text",value:y.url,onChange:C=>f(j,"url",C.target.value),placeholder:l.editor.resourceUrl,style:dt}),e.jsx("input",{type:"text",value:((S=y.structure)==null?void 0:S.join("、"))||"",onChange:C=>b(j,C.target.value),placeholder:l.editor.structurePlaceholder,style:dt}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:qt,children:[e.jsx("span",{style:Zt,children:l.label.coverageLevel}),e.jsx("input",{type:"number",min:1,value:((v=y.coverage)==null?void 0:v.level)??"",onChange:C=>w(j,"level",C.target.value),placeholder:"1",style:{...dt,width:"60px"}})]}),e.jsxs("label",{style:{...qt,flex:1},children:[e.jsx("span",{style:Zt,children:l.label.coverageRange}),e.jsx("input",{type:"text",value:(($=y.coverage)==null?void 0:$.ranges)||"",onChange:C=>w(j,"ranges",C.target.value),placeholder:l.editor.coverageRangePlaceholder,style:{...dt,flex:1}})]})]}),e.jsx("textarea",{value:y.details||"",onChange:C=>f(j,"details",C.target.value),placeholder:l.editor.detailsPlaceholder,style:{...dt,minHeight:"60px",resize:"vertical"}}),e.jsxs("div",{style:{borderTop:`1px solid ${i("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"6px"},children:l.label.metadata}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(l.metadata).map(([C,z])=>{var E;return e.jsxs("label",{style:{...qt,gap:"4px"},children:[e.jsx("span",{style:{...Zt,minWidth:"56px"},children:z}),e.jsx("input",{type:"text",value:((E=y.metadata)==null?void 0:E[C])||"",onChange:T=>k(j,C,T.target.value),placeholder:z,style:{...dt,flex:1}})]},C)})})]})]})]})]},j)}),e.jsxs("button",{onClick:m,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:[e.jsx("span",{children:"+"}),e.jsx("span",{children:l.action.addResource})]})]})};function ed(t){switch(t){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 td(t,n,o,r){const s=(n==null?void 0:n.status)==="downloading",l=(n==null?void 0:n.status)==="completed";return e.jsx("button",{onClick:a=>{a.stopPropagation(),s||o(t,"")},disabled:s,style:{background:"transparent",border:"none",color:i(l?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:l?r.download.completed:s?`${r.download.downloading} ${(n==null?void 0:n.progress)||0}%`:r.download.downloadThis,children:l?"✓":s?"⏳":"⬇"})}function nd(t,n){const o=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(t.url)||t.url.includes("iiif")||t.url.includes("image");return e.jsx("div",{style:{marginBottom:"12px"},children:o?e.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:i("overlay-bg")},children:e.jsx("img",{src:t.url,alt:t.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:r=>{r.target.style.display="none"}})}):e.jsx("div",{style:{padding:"12px",background:i("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:i("desc-fg")},children:n.editor.imageResourceLink})})}const dt={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"},qt={display:"flex",alignItems:"center",gap:"6px"},Zt={fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap"},id={"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 Ut(t){try{return id[new URL(t).hostname]}catch{return}}const Oo={text:0,image:1,physical:2};function Hi(t){return t.length===0?"physical":[...t].sort((n,o)=>(Oo[n]??99)-(Oo[o]??99)).join("+")}function Oi(t){var a;const n=p=>{const c=p.match(/^(.+?)·第(\d+)[冊册]$/);if(c)return[c[1],parseInt(c[2])];const d=p.match(/^(.+?)[·(](\d+)[)]?$/);return d?[d[1],parseInt(d[2])]:null},o=new Map;for(let p=0;p<t.length;p++){const c=t[p];if(c.volumes&&c.volumes.length>0)continue;const d=n(c.name);if(!d)continue;const[u,g]=d,m=`${u}|${Hi(Nt(c))}`;o.has(m)||o.set(m,{base:{...c,name:u,url:"",volumes:[]},volumes:[],indices:[]});const x=o.get(m);x.volumes.push({volume:g,url:c.url||void 0,status:"found"}),x.indices.push(p)}const r=[],s=new Set;for(const p of o.values())if(!(p.volumes.length<2)){p.volumes.sort((c,d)=>c.volume-d.volume),p.base.volumes=p.volumes,p.base.expected_volumes=p.volumes.length,p.base.url||(p.base.url=((a=p.volumes.find(c=>c.url))==null?void 0:a.url)??""),r.push(p.base);for(const c of p.indices)s.add(c)}const l=[...r];for(let p=0;p<t.length;p++)s.has(p)||l.push(t[p]);return l}function xs(t){if(t.url)return t.url;for(const[n,o]of Object.entries(t))if(n.endsWith("_url")&&typeof o=="string")return o}function fs(t){return!Array.isArray(t.volumes)||t.volumes.length===0?null:t.volumes.map(n=>({...n,url:n.url||xs(n)}))}function Ln(t){const n=fs(t);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:t.expected_volumes??o+r}}function Fi(t){if(!t)return;const n=t.file_page_range||t.page_range;if(!n||typeof n!="string")return;const o=n.match(/^(\d+)/);return o?parseInt(o[1],10):void 0}function Di(t,n){try{if(new URL(t).hostname.includes("wikimedia.org")){const r=t.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(t);return s.searchParams.set("page",String(n)),s.toString()}return t}catch{return t}}function Vt(t){if(!t.url)return;const n=Fi(t.metadata);return n?Di(t.url,n):t.url}const Fo={text:i("restype-text"),image:i("restype-image"),"text+image":i("restype-text-image"),physical:i("restype-physical")};function od(t){return t.includes("text")&&t.includes("image")?Fo["text+image"]:Fo[t[0]||"physical"]}const Ui=({items:t,groupByType:n=!0,resourceGroups:o,onNavigate:r,renderLink:s})=>{const l=ke(),{convert:a}=Ne(),p=h.useMemo(()=>Oi(t||[]),[t]),{mirrorGroups:c,ungroupedItems:d}=h.useMemo(()=>{const b=new Map,w=[];for(const y of p){const j=y.group;j?(b.has(j)||b.set(j,[]),b.get(j).push(y)):w.push(y)}for(const y of b.values())y.sort((j,S)=>{const v=$=>$.group_role==="origin"?0:$.group_role==="mirror"?1:2;return v(j)-v(S)});return{mirrorGroups:b,ungroupedItems:w}},[p]),u={text:l.resourceType.text,image:l.resourceType.image,"text+image":l.resourceType.textImage,physical:l.resourceType.physical},g=b=>u[b]?u[b]:b.split("+").map(w=>u[w]||w).join("+");if(!p||p.length===0)return e.jsx("div",{style:{padding:"16px",color:i("desc-fg"),fontSize:"13px",textAlign:"center"},children:l.misc.noResources});if(!n)return e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:p.map((b,w)=>e.jsx(ei,{item:b},b.id||w))});const m=(b,w)=>{const y=o==null?void 0:o[b],j=(y==null?void 0:y.label)||b,S=y==null?void 0:y.description;return e.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:[e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:a(j)}),S&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.5},children:a(S)}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:w.map((v,$)=>e.jsx(ei,{item:v,onNavigate:r,renderLink:s},v.id||$))})]},`group-${b}`)},x=new Map;for(const b of d){const w=Hi(Nt(b));x.has(w)||x.set(w,[]),x.get(w).push(b)}const f=["text","image","text+image","physical"],k=[...f.filter(b=>x.has(b)),...[...x.keys()].filter(b=>!f.includes(b)).sort()];return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([b,w])=>m(b,w)),k.map(b=>{const w=x.get(b),y=od(b.split("+"));return e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:y,whiteSpace:"nowrap",flexShrink:0},children:g(b)}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:w.map((j,S)=>e.jsx(ei,{item:j,onNavigate:r,renderLink:s},j.id||S))})]},b)})]})},rd={bw:{label:"",bg:i("colormode-bw-bg"),fg:i("colormode-bw-fg")},color:{label:"",bg:i("colormode-color-bg"),fg:i("colormode-color-fg")}},ei=({item:t})=>{const n=ke(),{convert:o}=Ne(),[r,s]=h.useState(!1),l=h.useMemo(()=>(t.url?Ut(t.url):void 0)||o(t.name),[t.url,t.name,o]),a=h.useMemo(()=>!Array.isArray(t.volumes)||t.volumes.length===0?null:t.volumes.map(f=>({...f,url:f.url||xs(f)})),[t.volumes]),p=a&&a.length>0,c=p?new Set(a.filter(f=>f.status!=="missing").map(f=>f.volume)).size:0,d=p?new Set(a.filter(f=>f.status==="missing").map(f=>f.volume)).size:0,u=t.expected_volumes??(p?c+d:0),g=t.color_mode?{...rd[t.color_mode],label:n.colorMode[t.color_mode]}:null,m=t.details&&!p?o(t.details):null,x={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 e.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[e.jsxs("div",{style:x,children:[e.jsx("span",{style:{fontWeight:500},children:l}),g&&e.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:g.bg,color:g.fg},children:g.label}),m&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:m}),p&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[c,"/",u,n.unit.volume,d>0&&e.jsx("span",{style:{color:i("missing-fg"),marginLeft:"3px"},children:it(n.common.volumesMissing,{n:d})})]}),t.url&&e.jsx("a",{href:(()=>{const f=Fi(t.metadata);return f?Di(t.url,f):t.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:i("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),p&&e.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?"▲":"▼"})]}),p&&r&&e.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:a.map(f=>{const k=f.status==="missing";return f.url&&!k?e.jsx("a",{href:f.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:f.volume},f.volume):e.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:f.volume},f.volume)})})]})},bs=({indexSource:t,syncConfig:n,variant:o="index-browser",onSwitchMode:r,onToggleDraft:s,onConfigurePath:l,onSelectFolder:a})=>{const p=ke(),c=t==="local",d=(n==null?void 0:n.isDraft)??!0,u=(n==null?void 0:n.repoPath)||"",g=u?u.split(/[/\\]/).pop()||u:"",m={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:i("primary-soft"),color:i("primary")},x={onMouseOver:k=>k.currentTarget.style.opacity="0.8",onMouseOut:k=>k.currentTarget.style.opacity="1"},f=e.jsxs("div",{onClick:s,title:d?p.mode.switchToOfficial:p.mode.switchToDraft,style:{...m,background:i(d?"warning":"success"),color:i("on-color-fg")},...x,children:[e.jsx("span",{children:d?"📝":"📚"}),e.jsx("span",{children:d?"draft":"official"})]});return o==="index-browser"?c?e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[f,e.jsxs("div",{onClick:r,title:p.mode.switchToSync,style:m,...x,children:[e.jsx("span",{children:"📁"}),e.jsx("span",{children:p.mode.localMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsxs("div",{onClick:a,title:u||p.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px"},...x,children:[e.jsx("span",{children:"📂"}),g&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:g})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f,e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("div",{onClick:r,title:p.mode.switchToLocal,style:m,...x,children:[e.jsx("span",{children:"🌐"}),e.jsx("span",{children:p.mode.syncMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsx("div",{onClick:l,title:g||p.mode.configurePath,style:{...m,background:"transparent",padding:"6px",fontSize:"12px"},...x,children:e.jsx("span",{children:"⚙️"})})]})]}):e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[e.jsxs("div",{onClick:r,title:c?p.mode.switchToGithub:p.mode.switchToLocal,style:m,...x,children:[e.jsx("span",{children:c?"📁":"🌐"}),e.jsx("span",{children:c?p.mode.localMode:p.mode.githubSync}),e.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&e.jsxs("div",{onClick:a,title:u||p.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px",minWidth:u?"100px":"auto",justifyContent:"space-between"},...x,children:[e.jsx("span",{children:"📂"}),g&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:g})]}),!c&&g&&e.jsxs("div",{style:{...m,background:i("mode-active-bg"),color:i("on-color-fg"),cursor:"default"},title:u,children:[e.jsx("span",{children:"📂"}),e.jsx("span",{style:{fontSize:"11px"},children:g})]})]})},Pn="bim-search-history",Do=10,Uo=8;function on(){try{const t=localStorage.getItem(Pn);return t?JSON.parse(t):[]}catch{return[]}}function ys(t){try{const n=on().filter(o=>o!==t);n.unshift(t),n.length>Do&&(n.length=Do),localStorage.setItem(Pn,JSON.stringify(n))}catch{}}function sd(t){try{const n=on().filter(o=>o!==t);localStorage.setItem(Pn,JSON.stringify(n))}catch{}}function ld(){try{localStorage.removeItem(Pn)}catch{}}const js=({transport:t,value:n,onChange:o,onSearch:r,onEntrySelect:s,placeholder:l})=>{const a=ke(),p=l??a.search.placeholder,c={work:a.indexType.work,book:a.indexType.book,collection:a.indexType.collection,entity:a.indexType.entity},[d,u]=h.useState(!1),[g,m]=h.useState([]),[x,f]=h.useState(-1),[k,b]=h.useState(on),w=h.useRef(null),y=h.useRef(null),j=h.useRef(null),S=h.useRef(!1);h.useEffect(()=>{f(-1);const _=n.trim();if(!_){m(k.map(A=>({type:"history",text:A})));return}if(!t.searchAll){m([]);return}let O=!1;const W=setTimeout(()=>{t.searchAll(_,Uo).then(A=>{if(O)return;const G=[...A.works,...A.books,...A.collections,...A.entities??[]];m(G.slice(0,Uo).map(V=>({type:"entry",text:V.title||V.id,entry:V})))}).catch(()=>{O||m([])})},80);return()=>{O=!0,clearTimeout(W)}},[n,k,t]),h.useEffect(()=>{const _=O=>{j.current&&!j.current.contains(O.target)&&u(!1)};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[]),h.useEffect(()=>{const _=O=>{var W,A;if(O.key==="/"&&document.activeElement!==w.current){const G=(W=document.activeElement)==null?void 0:W.tagName;if(G==="INPUT"||G==="TEXTAREA"||G==="SELECT")return;O.preventDefault(),(A=w.current)==null||A.focus()}};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[]);const v=h.useCallback(_=>{_.trim()&&(ys(_.trim()),b(on())),r(_),u(!1)},[r]),$=h.useCallback(_=>{_.type==="history"?(o(_.text),v(_.text)):_.entry&&(s?(s(_.entry),u(!1)):(o(_.text),v(_.text)))},[o,v,s]),C=h.useCallback(_=>{if(!d||g.length===0){_.key==="Enter"&&v(n);return}switch(_.key){case"ArrowDown":_.preventDefault(),f(O=>(O+1)%g.length);break;case"ArrowUp":_.preventDefault(),f(O=>(O-1+g.length)%g.length);break;case"Enter":_.preventDefault(),x>=0&&x<g.length?$(g[x]):v(n);break;case"Escape":_.preventDefault(),u(!1);break}},[d,g,x,n,v,$]),z=h.useCallback((_,O)=>{O.stopPropagation(),sd(_),b(on()),m(W=>W.filter(A=>!(A.type==="history"&&A.text===_)))},[]),E=h.useCallback(_=>{_.stopPropagation(),ld(),b([]),m([])},[]);h.useEffect(()=>{if(x>=0&&y.current){const _=y.current.children;_[x]&&_[x].scrollIntoView({block:"nearest"})}},[x]);const T=!n.trim()&&k.length>0;return e.jsxs("div",{ref:j,style:{position:"relative",flex:1},children:[e.jsx("input",{ref:w,type:"text",placeholder:p,value:n,onChange:_=>{o(_.target.value),u(!0)},onCompositionStart:()=>{S.current=!0},onCompositionEnd:()=>{S.current=!1},onFocus:()=>{u(!0)},onKeyDown:C,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"}}),d&&g.length>0&&e.jsxs("div",{ref:y,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&&e.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:[e.jsx("span",{children:a.search.history}),e.jsx("button",{onClick:E,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:a.search.clearAll})]}),g.map((_,O)=>e.jsxs("div",{onClick:()=>$(_),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:i("fg"),background:O===x?i("list-active-bg"):"transparent"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:_.type==="history"?"🕐":"🔍"}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:_.text}),_.entry&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:[c[_.entry.type],_.entry.edition&&` · ${_.entry.edition}`,_.entry.author&&` · ${_.entry.author}`]}),_.type==="history"&&e.jsx("button",{onClick:W=>z(_.text,W),style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:a.action.remove,children:"×"})]},`${_.type}-${_.text}-${O}`))]})]})},Gt=({type:t,size:n=9})=>e.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:i(`type-${t}`),verticalAlign:"middle"}}),An={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},vs=new Set(["work","book","entity"]);function ad(t){return Ss(t)||!!t.sort}function cd(t,n){return n.sort&&vs.has(t)?n.sort:void 0}const Bn=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],Mn=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],ks=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],ws={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function Wn(t){return t.dynasty.length+t.classification.length+(t.hasImage?1:0)+(t.hasText?1:0)+(t.hasCollated?1:0)+(t.loss?1:0)}function Ss(t){return Wn(t)>0}function dd(t){const n=[];return t.dynasty.length&&n.push("dynasty"),t.classification.length&&n.push("classification"),t.hasImage&&n.push("hasImage"),t.hasText&&n.push("hasText"),t.hasCollated&&n.push("hasCollated"),t.loss&&n.push("loss"),n}function $s(t,n){const o=ws[t];return dd(n).every(r=>o.has(r))}const Jt=t=>JSON.stringify(t);function pd(t,n){if(!$s(n,t))return null;const o=[];if(t.dynasty.length){const r=Array.from(new Set(t.dynasty.flatMap(s=>{var l;return((l=Bn.find(a=>a.key===s))==null?void 0:l.values)??[]})));r.length===1?o.push(`dynasty = ${Jt(r[0])}`):r.length>1&&o.push(`dynasty IN [${r.map(Jt).join(", ")}]`)}return t.classification.length&&o.push(t.classification.length===1?`classification = ${Jt(t.classification[0])}`:`classification IN [${t.classification.map(Jt).join(", ")}]`),t.hasImage&&o.push("has_image = true"),t.hasText&&o.push("has_text = true"),t.hasCollated&&o.push("has_collated = true"),t.loss&&o.push(`loss_status = ${Jt(t.loss)}`),o.join(" AND ")}const Je={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},_s="_";function _n(t,n=new URLSearchParams){for(const o of Object.values(Je))n.delete(o);return t.dynasty.length&&n.set(Je.dynasty,t.dynasty.join(",")),t.classification.length&&n.set(Je.classification,t.classification.map(o=>o||_s).join(",")),t.hasImage&&n.set(Je.hasImage,"1"),t.hasText&&n.set(Je.hasText,"1"),t.hasCollated&&n.set(Je.hasCollated,"1"),t.loss&&n.set(Je.loss,t.loss),t.sort&&n.set(Je.sort,t.sort),n}function ud(t){const n=l=>(t.get(l)??"").split(",").map(a=>a.trim()).filter(Boolean),o=new Set(Bn.map(l=>l.key)),r=new Set(Mn.map(l=>l.value)),s=t.get(Je.loss);return{dynasty:Array.from(new Set(n(Je.dynasty).filter(l=>o.has(l)))),classification:Array.from(new Set(n(Je.classification).map(l=>l===_s?"":l).filter(l=>r.has(l)))),hasImage:t.get(Je.hasImage)==="1",hasText:t.get(Je.hasText)==="1"||t.get(Je.hasCollated)==="1",hasCollated:!1,loss:s==="extant"||s==="partially_extant"||s==="lost"?s:"",sort:["era:asc","era:desc","title:asc","title:desc"].find(l=>l===t.get(Je.sort))??""}}function md(t,n){return JSON.stringify([t.dynasty.slice().sort(),t.classification.slice().sort(),t.hasImage,t.hasText,t.hasCollated,t.loss,t.sort])===JSON.stringify([n.dynasty.slice().sort(),n.classification.slice().sort(),n.hasImage,n.hasText,n.hasCollated,n.loss,n.sort])}function Vo(t,n){return t.includes(n)?t.filter(o=>o!==n):[...t,n]}const gd=({filters:t,onChange:n})=>{const o=ke(),r=o.searchV4,{convert:s}=Ne(),[l,a]=h.useState(!1),p=h.useId(),c=Wn(t),d=u=>n({...t,...u});return e.jsxs("aside",{className:"bim-sr-aside","aria-label":s(r.filterTitle),children:[e.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":l,"aria-controls":p,onClick:()=>a(u=>!u),children:[e.jsxs("span",{children:[s(r.filterButton),c>0&&e.jsx("span",{className:"bim-sr-fn",children:s(it(r.filterSelected,{n:c}))})]}),e.jsxs("span",{className:"bim-sr-fa","aria-hidden":"true",children:[s(l?r.collapse:r.expand)," ",l?"▴":"▾"]})]}),e.jsxs("div",{className:"bim-sr-filters",id:p,"data-open":l?"true":"false",...l?{}:{"data-collapsed":"true"},children:[e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:s(r.dynasty)}),e.jsx("div",{className:"bim-sr-chips",children:Bn.map(u=>e.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":t.dynasty.includes(u.key),onClick:()=>d({dynasty:Vo(t.dynasty,u.key)}),children:s(u.key)},u.key))})]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:s(r.classification)}),Mn.map(u=>e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.classification.includes(u.value),onChange:()=>d({classification:Vo(t.classification,u.value)})}),u.value?s(u.label):o.searchPage.unclassified]},u.value||"_"))]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:s(r.resources)}),e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.hasImage,onChange:u=>d({hasImage:u.target.checked})}),s(r.hasImage)]}),e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.hasText,onChange:u=>d({hasText:u.target.checked})}),s(r.hasText)]})]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{id:`${p}-loss`,children:s(r.extant)}),e.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${p}-loss`,children:ks.map(u=>e.jsx("button",{type:"button","aria-pressed":t.loss===u.value,onClick:()=>d({loss:u.value}),children:o.searchPage.loss[u.value||"all"]},u.value||"all"))})]}),c>0&&e.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...An,sort:t.sort}),children:s(r.clearAllFilters)})]})]})};function Cs({text:t,query:n}){const o=(n??"").trim();if(!o||!t)return e.jsx(e.Fragment,{children:t});const r=t.toLowerCase(),s=o.toLowerCase(),l=[];let a=0,p=0;for(;a<t.length;){const c=r.indexOf(s,a);if(c<0){l.push(t.slice(a));break}c>a&&l.push(t.slice(a,c)),l.push(e.jsx("mark",{className:"bim-sr-hl",children:t.slice(c,c+s.length)},p++)),a=c+s.length}return e.jsx(e.Fragment,{children:l})}const Go=({entries:t,query:n,onEntryLinkClick:o,typeName:r})=>{const s=ke(),l=s.searchV4,{convert:a}=Ne(),p=Ye();return e.jsx("div",{className:"bim-sr-tablewrap",children:e.jsxs("table",{className:"bim-sr-table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"34%"}}),e.jsx("col",{style:{width:"8%"}}),e.jsx("col",{style:{width:"19%"}}),e.jsx("col",{style:{width:"13%"}}),e.jsx("col",{style:{width:"12%"}}),e.jsx("col",{style:{width:"14%"}})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:a(l.colTitle)}),e.jsx("th",{scope:"col",children:a(l.colType)}),e.jsx("th",{scope:"col",children:a(l.colAuthor)}),e.jsx("th",{scope:"col",children:a(l.colEra)}),e.jsx("th",{scope:"col",children:a(l.colClass)}),e.jsx("th",{scope:"col",style:{textAlign:"right"},children:a(l.colResource)})]})}),e.jsx("tbody",{children:t.map(c=>{const d=a(c.title||c.primary_name||c.id),u=c.measure_info?a(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",g=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${a(c.author)}${c.role&&c.role!=="author"?` ${a(c.role)}`:""}`:"",m=c.type==="book"?c.era??c.dynasty:c.dynasty,x=m?a(m):"",f=c.classification?a(c.classification):"",k=[];c.has_image&&k.push({label:l.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&k.push({label:l.tagText,cls:""}),c.loss_status==="lost"&&k.push({label:l.tagLost,cls:"bim-sr-tag--lost"});const b=[g,x,f].filter(Boolean).join(" · ");return e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-sr-c-title",children:[e.jsxs("div",{className:"bim-sr-tl",children:[e.jsx("a",{href:p(c.id),onClick:w=>o(c,w),children:e.jsx(Cs,{text:d,query:n?a(n):void 0})}),u&&e.jsx("span",{className:"bim-sr-measure",children:u})]}),b&&e.jsx("span",{className:"bim-sr-sub",children:b})]}),e.jsxs("td",{className:"bim-sr-c-type",children:[e.jsx(Gt,{type:c.type,size:6})," ",r(c.type)]}),e.jsx("td",{className:"bim-sr-c-who",children:g||"—"}),e.jsx("td",{className:"bim-sr-c-era",children:x||"—"}),e.jsx("td",{className:"bim-sr-c-cls",children:f||"—"}),e.jsx("td",{className:"bim-sr-c-res",children:k.map(w=>e.jsx("span",{className:`bim-sr-tag ${w.cls}`,children:a(w.label)},w.label))})]},c.id)})})]})})},hd=`
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
- `,Yo=({entries:t,query:n,onEntryLinkClick:o,typeName:r})=>{const s=ve(),l=s.searchV4,{convert:a}=Te(),p=Ye();return e.jsxs("div",{className:"bim-sc-grid",children:[e.jsx("style",{children:hd}),t.map(c=>{const d=a(c.title||c.primary_name||c.id),u=c.measure_info?a(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",m=[c.type==="entity"?c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:"":`${c.dynasty?`〔${a(c.dynasty)}〕`:""}${c.author?a(c.author):""}`,c.type==="book"&&c.edition?a(c.edition):"",u].filter(Boolean).join(" · "),h=[r(c.type),c.classification?a(c.classification):""].filter(Boolean).join(" · "),f=[];return c.has_image&&f.push({label:l.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&f.push({label:l.tagText,cls:""}),c.loss_status==="lost"&&f.push({label:l.tagLost,cls:"bim-sr-tag--lost"}),e.jsxs("a",{className:"bim-sc",href:p(c.id),onClick:v=>o(c,v),children:[e.jsx("span",{className:"bim-sc-t",children:e.jsx(Cs,{text:d,query:n?a(n):void 0})}),m&&e.jsx("span",{className:"bim-sc-m",children:m}),c.descriptionSnippet&&e.jsx("p",{className:"bim-sc-s",children:Mi(c.descriptionSnippet).map((v,y)=>v.marked?e.jsx("mark",{children:a(v.text)},y):e.jsx(x.Fragment,{children:a(v.text)},y))}),e.jsx("span",{className:"bim-sc-sp"}),e.jsxs("div",{className:"bim-sc-f",children:[e.jsx("span",{className:"bim-sc-fl",children:h}),e.jsx("span",{className:"bim-sc-tags",children:f.map(v=>e.jsx("span",{className:`bim-sr-tag ${v.cls}`,children:a(v.label)},v.label))})]})]},c.id)})]})};function xd(t,n){const o=new Set([1,n,t-1,t,t+1].filter(l=>l>=1&&l<=n)),r=Array.from(o).sort((l,a)=>l-a),s=[];return r.forEach((l,a)=>{a>0&&l-r[a-1]>1&&s.push("gap"),s.push(l)}),s}function fd(t,n,o){const r=Math.max(1,Math.ceil(n/o));return Math.min(Math.max(1,t),r)}const bd=({page:t,pageSize:n,total:o,totalLabel:r,onPage:s})=>{const l=ve().searchV4,{convert:a}=Te(),p=Math.max(1,Math.ceil(o/n));return o<=0?null:e.jsxs("nav",{className:"bim-sr-pager","aria-label":a(l.pagerLabel),children:[e.jsx("span",{className:"bim-sr-info",children:a(it(l.pageInfo,{total:r??o.toLocaleString(),size:n,page:t,pages:p}))}),p>1&&e.jsxs("ul",{children:[e.jsx("li",{children:e.jsx("button",{type:"button",disabled:t<=1,onClick:()=>s(t-1),children:a(l.prevPage)})}),xd(t,p).map((c,d)=>c==="gap"?e.jsx("li",{className:"bim-sr-gap","aria-hidden":"true",children:"…"},`g${d}`):e.jsx("li",{children:e.jsx("button",{type:"button","aria-current":c===t?"page":void 0,"aria-label":`${c}`,onClick:()=>s(c),children:c})},c)),e.jsx("li",{children:e.jsx("button",{type:"button",disabled:t>=p,onClick:()=>s(t+1),children:a(l.nextPage)})})]})]})},zs="(max-width: 719px)",yd=`${zs}, (pointer: coarse)`,jd=`
15
+ `,Yo=({entries:t,query:n,onEntryLinkClick:o,typeName:r})=>{const s=ke(),l=s.searchV4,{convert:a}=Ne(),p=Ye();return e.jsxs("div",{className:"bim-sc-grid",children:[e.jsx("style",{children:hd}),t.map(c=>{const d=a(c.title||c.primary_name||c.id),u=c.measure_info?a(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",m=[c.type==="entity"?c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:"":`${c.dynasty?`〔${a(c.dynasty)}〕`:""}${c.author?a(c.author):""}`,c.type==="book"&&c.edition?a(c.edition):"",u].filter(Boolean).join(" · "),x=[r(c.type),c.classification?a(c.classification):""].filter(Boolean).join(" · "),f=[];return c.has_image&&f.push({label:l.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&f.push({label:l.tagText,cls:""}),c.loss_status==="lost"&&f.push({label:l.tagLost,cls:"bim-sr-tag--lost"}),e.jsxs("a",{className:"bim-sc",href:p(c.id),onClick:k=>o(c,k),children:[e.jsx("span",{className:"bim-sc-t",children:e.jsx(Cs,{text:d,query:n?a(n):void 0})}),m&&e.jsx("span",{className:"bim-sc-m",children:m}),c.descriptionSnippet&&e.jsx("p",{className:"bim-sc-s",children:Mi(c.descriptionSnippet).map((k,b)=>k.marked?e.jsx("mark",{children:a(k.text)},b):e.jsx(h.Fragment,{children:a(k.text)},b))}),e.jsx("span",{className:"bim-sc-sp"}),e.jsxs("div",{className:"bim-sc-f",children:[e.jsx("span",{className:"bim-sc-fl",children:x}),e.jsx("span",{className:"bim-sc-tags",children:f.map(k=>e.jsx("span",{className:`bim-sr-tag ${k.cls}`,children:a(k.label)},k.label))})]})]},c.id)})]})};function xd(t,n){const o=new Set([1,n,t-1,t,t+1].filter(l=>l>=1&&l<=n)),r=Array.from(o).sort((l,a)=>l-a),s=[];return r.forEach((l,a)=>{a>0&&l-r[a-1]>1&&s.push("gap"),s.push(l)}),s}function fd(t,n,o){const r=Math.max(1,Math.ceil(n/o));return Math.min(Math.max(1,t),r)}const bd=({page:t,pageSize:n,total:o,totalLabel:r,onPage:s})=>{const l=ke().searchV4,{convert:a}=Ne(),p=Math.max(1,Math.ceil(o/n));return o<=0?null:e.jsxs("nav",{className:"bim-sr-pager","aria-label":a(l.pagerLabel),children:[e.jsx("span",{className:"bim-sr-info",children:a(it(l.pageInfo,{total:r??o.toLocaleString(),size:n,page:t,pages:p}))}),p>1&&e.jsxs("ul",{children:[e.jsx("li",{children:e.jsx("button",{type:"button",disabled:t<=1,onClick:()=>s(t-1),children:a(l.prevPage)})}),xd(t,p).map((c,d)=>c==="gap"?e.jsx("li",{className:"bim-sr-gap","aria-hidden":"true",children:"…"},`g${d}`):e.jsx("li",{children:e.jsx("button",{type:"button","aria-current":c===t?"page":void 0,"aria-label":`${c}`,onClick:()=>s(c),children:c})},c)),e.jsx("li",{children:e.jsx("button",{type:"button",disabled:t>=p,onClick:()=>s(t+1),children:a(l.nextPage)})})]})]})},zs="(max-width: 719px)",yd=`${zs}, (pointer: coarse)`,jd=`
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; }
@@ -117,7 +117,7 @@
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
- `,Vi="bim-search-view",ti=50,Ko=5,rn=1e3;function kn(t){return t>=rn?`${rn.toLocaleString()}+`:t.toLocaleString()}const vd={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function kd(t){return t&&vd[t.toLowerCase()]||"all"}function wd(t){return t==="all"?null:t}const qo=["work","collection","book","entity"],Sd={work:"works",collection:"collections",book:"books",entity:"entities"},$d={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function _d(){try{return window.localStorage.getItem(Vi)==="card"?"card":"table"}catch{return"table"}}function Cd(t){try{window.localStorage.setItem(Vi,t)}catch{}}const Lt=(t,n)=>(t==null?void 0:t[$d[n]])??0,ni=(t,n)=>(t==null?void 0:t[Sd[n]])??[],Ts=({transport:t,query:n,filters:o,onFiltersChange:r,onEntryLinkClick:s,typeName:l,tab:a,onTabChange:p})=>{const c=ve(),d=c.searchV4,{convert:u}=Te(),g=!!t.supportsSearchFilters,m=x.useMemo(()=>g?o:An,[g,o]),[h,f]=x.useState("table");x.useEffect(()=>{f(_d())},[]);const v=M=>{f(M),Cd(M)},[y,w]=x.useState(a??"all");x.useEffect(()=>{a!==void 0&&(w(a),j(1))},[a]);const[b,j]=x.useState(1),[S,k]=x.useState(null),[$,_]=x.useState(null),[z,E]=x.useState(!1),[T,C]=x.useState(""),O=_n(m).toString(),W=Wn(m)>0,P=_n({...m,sort:""}).toString(),Y=x.useRef({query:n,filterOnlyKey:P,sort:m.sort});x.useEffect(()=>{const M=Y.current;M.query!==n||M.filterOnlyKey!==P?(w("all"),j(1)):M.sort!==m.sort&&j(1),Y.current={query:n,filterOnlyKey:P,sort:m.sort}},[n,P,m.sort]),x.useEffect(()=>{let M=!1;return E(!0),C(""),(async()=>{try{let K;if(t.searchAll)K=await t.searchAll(n,Ko,m);else{const Re=["work","book","collection","entity"],se=await Promise.all(Re.map(ye=>t.search(n,ye,{page:1,pageSize:Ko,filters:m})));K={works:se[0].entries,books:se[1].entries,collections:se[2].entries,entities:se[3].entries,totalWorks:se[0].total,totalBooks:se[1].total,totalCollections:se[2].total,totalEntities:se[3].total}}M||k(K)}catch(K){M||(C(K instanceof Error?K.message:String(K)),k(null))}finally{M||E(!1)}})(),()=>{M=!0}},[t,n,O]);const V=y;x.useEffect(()=>{if(y==="all"){_(null);return}let M=!1;return E(!0),(async()=>{try{const K=await t.search(n,y,{page:b,pageSize:ti,filters:m});M||_({key:V,entries:K.entries,total:K.total})}catch(K){M||(C(K instanceof Error?K.message:String(K)),_(null))}finally{M||E(!1)}})(),()=>{M=!0}},[t,n,O,y,b]);const Q=$&&$.key===V?$:null;x.useEffect(()=>{if(y==="all"||!Q||z)return;const M=Math.min(Q.total,rn),K=fd(b,M,ti);Q.entries.length===0&&M>0&&K!==b&&j(K)},[y,Q,z,b]);const ge=x.useMemo(()=>qo.filter(M=>Lt(S,M)>0),[S]),A=ge.reduce((M,K)=>M+Lt(S,K),0),I=ge.some(M=>Lt(S,M)>=rn)?`${A.toLocaleString()}+`:A.toLocaleString(),Z=!z&&!T&&S!==null&&A===0,ee=x.useCallback(M=>{w(M),j(1),p==null||p(M)},[p]),ce=x.useMemo(()=>{const M=[];return m.dynasty.forEach(K=>M.push({name:K,remove:()=>r({...m,dynasty:m.dynasty.filter(Re=>Re!==K)})})),m.classification.forEach(K=>{var Re;return M.push({name:K?((Re=Mn.find(se=>se.value===K))==null?void 0:Re.label)??K:c.searchPage.unclassified,remove:()=>r({...m,classification:m.classification.filter(se=>se!==K)})})}),m.hasImage&&M.push({name:d.hasImage,remove:()=>r({...m,hasImage:!1})}),m.hasText&&M.push({name:d.hasText,remove:()=>r({...m,hasText:!1})}),m.hasCollated&&M.push({name:d.hasCollated,remove:()=>r({...m,hasCollated:!1})}),m.loss&&M.push({name:`${d.extant}:${c.searchPage.loss[m.loss]}`,remove:()=>r({...m,loss:""})}),M},[m,r,d,c]),fe={query:n,onEntryLinkClick:s,typeName:l},Ie=M=>h==="table"?e.jsx(Go,{entries:M,...fe}):e.jsx(Yo,{entries:M,...fe}),q=qo.flatMap(M=>ni(S,M));return e.jsxs("div",{className:"bim-sr-layout","data-nofilters":g?void 0:"true",children:[e.jsx("style",{children:jd}),g&&e.jsx(gd,{filters:m,onChange:r}),e.jsxs("div",{className:"bim-sr-main","aria-busy":z,children:[ge.length>0&&e.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":c.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${i("rule")}`},children:[e.jsxs(Zo,{on:y==="all",onClick:()=>ee("all"),children:[c.search.allTab," ",e.jsx("small",{children:I})]}),ge.map(M=>e.jsxs(Zo,{on:y===M,onClick:()=>ee(M),children:[l(M)," ",e.jsx("small",{children:kn(Lt(S,M))})]},M))]}),e.jsxs("div",{className:"bim-sr-tools",children:[g&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":u(d.sortLabel),children:[e.jsx("button",{type:"button","aria-pressed":!m.sort,onClick:()=>r({...m,sort:""}),children:u(d.sortRelevance)}),["era","title"].map(M=>{const K=m.sort.startsWith(`${M}:`)?m.sort.endsWith("desc")?"desc":"asc":null,Re=M==="era"?d.sortEra:d.sortTitle,se=M==="era"?K==="desc"?d.sortEraDesc:d.sortEraAsc:K==="desc"?d.sortTitleDesc:d.sortTitleAsc;return e.jsxs("button",{type:"button","aria-pressed":K!==null,title:u(se),onClick:()=>r({...m,sort:`${M}:${K==="asc"?"desc":"asc"}`}),children:[u(Re),K?e.jsxs("span",{"aria-hidden":"true",children:[" ",K==="asc"?"↑":"↓"]}):null]},M)})]}),e.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),e.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":u(d.viewLabel),children:[e.jsx("button",{type:"button","aria-pressed":h==="table",onClick:()=>v("table"),children:u(d.viewTable)}),e.jsx("button",{type:"button","aria-pressed":h==="card",onClick:()=>v("card"),children:u(d.viewCard)})]})]}),W&&e.jsxs("div",{className:"bim-sr-chips-row",children:[e.jsx("span",{className:"bim-sr-count",role:"status",children:u(it(d.filteredCount,{n:I}))}),ce.map(M=>e.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":u(it(d.removeFilter,{name:M.name})),onClick:M.remove,children:[u(M.name),e.jsx("span",{"aria-hidden":"true",children:"×"})]},M.name))]}),T&&e.jsx("div",{className:"bim-sr-empty",role:"alert",children:T}),Z&&e.jsx("div",{className:"bim-sr-empty",children:u(W?d.emptyFiltered:it(c.search.noResultsFor,{query:n}))}),!T&&!Z&&y==="all"&&S&&(h==="table"?e.jsxs(e.Fragment,{children:[e.jsx(Go,{entries:q,...fe}),e.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:u(d.limitedNote)})]}):e.jsx(e.Fragment,{children:ge.map(M=>e.jsxs("section",{style:{marginTop:22},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,marginBottom:10},children:[e.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,letterSpacing:".1em",display:"flex",alignItems:"center",gap:8},children:[e.jsx(Gt,{type:M,size:8}),l(M),e.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:i("meta-fg")},children:[kn(Lt(S,M))," ",c.unit.items]})]}),Lt(S,M)>ni(S,M).length&&e.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>ee(M),children:c.action.viewAll})]}),e.jsx(Yo,{entries:ni(S,M),...fe})]},M))})),!T&&y!=="all"&&!Q&&e.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:c.search.loading}),!T&&y!=="all"&&Q&&Q.entries.length>0&&e.jsxs(e.Fragment,{children:[Ie(Q.entries),e.jsx(bd,{page:b,pageSize:ti,total:Math.min(Q.total,rn),totalLabel:kn(Q.total),onPage:j})]}),!T&&y!=="all"&&Q&&Q.entries.length===0&&!z&&e.jsxs("div",{className:"bim-sr-empty",children:[u(W?d.emptyFiltered:it(c.search.noResultsFor,{query:n})),e.jsx("div",{children:e.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>ee("all"),children:c.search.allTab})})]})]})]})};function Zo({on:t,onClick:n,children:o}){return e.jsx("button",{type:"button","aria-pressed":t,onClick:n,style:{border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:14.5,minHeight:44,padding:"8px 12px",letterSpacing:".06em",color:i(t?"ink":"meta-fg"),fontWeight:t?700:400,boxShadow:t?`inset 0 -2px 0 ${i("accent")}`:"none"},children:o})}const Mt="bim-recent-ids",Jo="bim-recent-entries",Xo=50;function jt(){try{const t=localStorage.getItem(Mt);if(t)return JSON.parse(t);const n=localStorage.getItem(Jo);if(n){const o=JSON.parse(n).map(r=>r.id);return localStorage.setItem(Mt,JSON.stringify(o)),localStorage.removeItem(Jo),o}return[]}catch{return[]}}function bi(t){try{const n=jt().filter(o=>o!==t);n.unshift(t),n.length>Xo&&(n.length=Xo),localStorage.setItem(Mt,JSON.stringify(n))}catch{}}function Ns(t){try{const n=jt().filter(o=>o!==t);localStorage.setItem(Mt,JSON.stringify(n))}catch{}}function Gi(){try{localStorage.removeItem(Mt)}catch{}}async function Yi(t,n){var o,r,s;try{if(t.getEntry){const a=await t.getEntry(n);if(a)return a}const l=await t.getItem(n);if(l){const a=l.authors;return{id:n,title:l.title||n,type:l.type||"work",author:(o=a==null?void 0:a[0])==null?void 0:o.name,dynasty:(r=a==null?void 0:a[0])==null?void 0:r.dynasty,role:(s=a==null?void 0:a[0])==null?void 0:s.role,edition:l.edition||void 0}}}catch{}return{id:n,title:n,type:"work",notFound:!0}}const ii=5,zd=50,Td=200,Qo={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},yi=({transport:t,indexSource:n="local",syncConfig:o,onEntryClick:r,onNewEntry:s,onSwitchMode:l,onToggleDraft:a,onConfigurePath:p,onSelectFolder:c,hideModeIndicator:d,resultVariant:u="compact",renderEntry:g,initialQuery:m,onQueryChange:h,headerRight:f,reserveViewportHeight:v=!1,filtersEnabled:y=!1,filters:w=An,onFiltersChange:b,resultTab:j,onResultTabChange:S})=>{const k=ve(),$=[{type:"work",name:k.indexType.work,key:"works"},{type:"book",name:k.indexType.book,key:"books"},{type:"collection",name:k.indexType.collection,key:"collections"},{type:"entity",name:k.indexType.entity,key:"entities"}],_=["work","collection","book","entity"],[z,E]=x.useState(m??""),[T,C]=x.useState(null),[O,W]=x.useState(m??""),P=_n(w).toString(),[Y,V]=x.useState(w);x.useEffect(()=>{V(w)},[P]);const Q=J=>{V(J),b==null||b(J)},[ge,A]=x.useState(null),[I,Z]=x.useState("all"),[ee,ce]=x.useState(!1),[fe,Ie]=x.useState(null),[q,M]=x.useState(""),[K,Re]=x.useState(!(m!=null&&m.trim())),[se,ye]=x.useState(jt),[We,Be]=x.useState([]),[Ee,Ce]=x.useState(!1),[He,D]=x.useState(!1),[re,de]=x.useState(null),[ke,F]=x.useState(null),he=x.useRef(void 0),Ne=x.useRef(!1),R=x.useCallback(async(J,Pe)=>{if(!J.trim()){Re(!0),C(null),A(null);return}if(Re(!1),y){W(J);return}ce(!0),M("");try{if(t.searchAll){const N=await t.searchAll(J,Pe??ii);C(N)}else{const N=["work","book","collection","entity"],X=await Promise.all(N.map(ae=>t.search(J,ae,{page:1,pageSize:Pe??ii})));C({works:X[0].entries,books:X[1].entries,collections:X[2].entries,entities:X[3].entries,totalWorks:X[0].total,totalBooks:X[1].total,totalCollections:X[2].total,totalEntities:X[3].total})}}catch(N){M(N instanceof Error?N.message:String(N)),C(null)}finally{ce(!1)}},[t,y]);x.useEffect(()=>{let J=!1;const Pe=()=>{var pe,$e;const N=["work","book","collection","entity"],X=Promise.all(N.map(H=>t.loadEntries(H,{page:1,pageSize:1}).catch(()=>({total:0})))),ae=((pe=t.getResourceCounts)==null?void 0:pe.call(t).catch(()=>null))??Promise.resolve(null),ie=(($e=t.getSubtypeStats)==null?void 0:$e.call(t).catch(()=>null))??Promise.resolve(null);Promise.all([X,ae,ie]).then(([H,B,be])=>{J||(de({works:H[0].total,books:H[1].total,collections:H[2].total,entities:H[3].total,hasText:B==null?void 0:B.hasText,hasImage:B==null?void 0:B.hasImage}),be&&F(be))})};return t.getCounts?t.getCounts().then(N=>{var X,ae;J||(de({works:N.works,books:N.books,collections:N.collections,entities:N.entities,hasText:(X=N.resourceCounts)==null?void 0:X.hasText,hasImage:(ae=N.resourceCounts)==null?void 0:ae.hasImage}),N.subtypeStats&&F(N.subtypeStats))}).catch(()=>{J||Pe()}):Pe(),()=>{J=!0}},[t]),x.useEffect(()=>{Ne.current||!(m!=null&&m.trim())||(Ne.current=!0,R(m))},[m,R]);const ne=x.useCallback(J=>{if(E(J),!J.trim()){h==null||h(J),Re(!0),C(null),A(null),Z("all");return}he.current&&clearTimeout(he.current),he.current=setTimeout(()=>{A(null),Z("all"),h==null||h(J),R(J)},Td)},[R,h]),ue=x.useCallback(J=>{he.current&&clearTimeout(he.current),Z("all"),h==null||h(J),R(J)},[R,h]),L=x.useCallback(J=>{A(J),R(z,zd)},[z,R]);x.useEffect(()=>{if(!se.length){Be([]);return}let J=!1;return Ce(!0),Promise.all(se.slice(0,10).map(Pe=>Yi(t,Pe))).then(Pe=>{J||(Be(Pe),Ce(!1))}),()=>{J=!0}},[se,t]);const te=J=>{Ie(J.id),bi(J.id),ye(jt()),r==null||r(J)},U=(J,Pe)=>{if(r&&Id(Pe)){Pe.preventDefault(),te(J);return}bi(J.id),ye(jt())},le=J=>{Ns(J),ye(jt())},we=()=>{Gi(),ye([])},Le=J=>$.find(Pe=>Pe.type===J),Se=!K&&!T&&!q,Fe=T&&(T.works.length>0||T.books.length>0||T.collections.length>0),De=e.jsxs(e.Fragment,{children:[e.jsx(js,{transport:t,value:z,onChange:ne,onSearch:ue,onEntrySelect:te}),y&&e.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const J=z.trim();J&&ys(J),ue(z)},children:k.searchPage.submit}),s&&e.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:k.action.newEntry})]});return e.jsxs("div",{className:"bim-browser-container",style:v?{minHeight:"100svh"}:void 0,children:[e.jsx("style",{children:Rd+(y?Ed:"")}),(!y||f||!d)&&e.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[y?e.jsx("span",{}):e.jsx("h1",{style:{margin:0,fontSize:"18px",color:i("fg")},children:k.browser.title}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f,!d&&e.jsx(bs,{variant:"index-browser",indexSource:n,syncConfig:o,onSwitchMode:l,onToggleDraft:a,onConfigurePath:p,onSelectFolder:c})]})]})}),y?e.jsxs("div",{className:"bim-ib-bar","data-nofilters":t.supportsSearchFilters?void 0:"true",children:[e.jsx("span",{"aria-hidden":"true"}),e.jsx("div",{className:"bim-ib-bar-main",children:De})]}):e.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:De}),K&&e.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:re&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:ke?e.jsxs(e.Fragment,{children:[(ke.book??0)>0&&e.jsxs(e.Fragment,{children:[k.searchPage.statBook," ",e.jsx("strong",{style:{color:i("fg")},children:ke.book.toLocaleString()})," ",k.unit.bu,k.searchPage.statComma,e.jsx("strong",{style:{color:i("fg")},children:re.books.toLocaleString()})," ",k.searchPage.statBookCopies]}),ke.article?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{margin:"0 6px"},children:"·"}),k.searchPage.statArticle," ",e.jsx("strong",{style:{color:i("fg")},children:ke.article.toLocaleString()})," ",k.searchPage.statArticleUnit]}):null,ke.poem?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{margin:"0 6px"},children:"·"}),k.searchPage.statPoem," ",e.jsx("strong",{style:{color:i("fg")},children:ke.poem.toLocaleString()})," ",k.searchPage.statPoemUnit]}):null,e.jsx("span",{style:{margin:"0 6px"},children:"·"}),k.searchPage.statCollection," ",e.jsx("strong",{style:{color:i("fg")},children:re.collections.toLocaleString()})]}):e.jsxs(e.Fragment,{children:[k.indexType.work," ",e.jsx("strong",{style:{color:i("fg")},children:re.works.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),k.indexType.book," ",e.jsx("strong",{style:{color:i("fg")},children:re.books.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),k.indexType.collection," ",e.jsx("strong",{style:{color:i("fg")},children:re.collections.toLocaleString()}),re.entities>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{margin:"0 6px"},children:"·"}),k.indexType.entity," ",e.jsx("strong",{style:{color:i("fg")},children:re.entities.toLocaleString()})]})]})}),re.hasImage!=null&&re.hasText!=null&&e.jsxs("span",{children:[k.resourceType.image," ",e.jsx("strong",{style:{color:i("fg")},children:re.hasImage.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),k.resourceType.text," ",e.jsx("strong",{style:{color:i("fg")},children:re.hasText.toLocaleString()})]})]})}),y&&!K&&e.jsx(Ts,{transport:t,query:O,filters:Y,onFiltersChange:Q,onEntryLinkClick:U,typeName:J=>Le(J).name,tab:j,onTabChange:S}),!(y&&!K)&&e.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:ee||Se?e.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg"),minHeight:Nd,boxSizing:"border-box"},children:k.search.searching}):q?e.jsx("div",{style:{textAlign:"center",padding:"40px"},children:e.jsx("p",{style:{color:i("desc-fg")},children:q})}):K?e.jsx("div",{style:{flex:1},children:Ee?e.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg")},children:k.search.loading}):We.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:i("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{children:k.search.recentBrowse}),e.jsx("button",{onClick:we,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:k.search.clearRecent})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:We.slice(0,He?10:3).map(J=>J.notFound?e.jsx(Bd,{id:J.id,onRemove:le,t:k},J.id):e.jsx(er,{entry:J,selected:fe===J.id,onClick:U,getConfig:Le,onRemove:le},J.id))}),!He&&We.length>3&&e.jsx("button",{onClick:()=>D(!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:k.action.expandMore})]}):e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:k.search.searchTitle}),e.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:k.search.searchSubtitle})]})}):Fe?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[e.jsx("style",{children:Ld}),(()=>{const J=ie=>T[Qo[ie]]??0,Pe=_.map(ie=>$.find(pe=>pe.type===ie)).filter(ie=>J(ie.key)>0);if(Pe.length<2)return null;const N=Pe.reduce((ie,pe)=>ie+J(pe.key),0),X=ie=>{if(Z(ie),ie!=="all"&&ge!==ie){const pe=$.find(H=>H.type===ie),$e=(T[pe.key]??[]).length;J(pe.key)>$e&&L(ie)}},ae=ie=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:i(ie?"fg":"desc-fg"),fontWeight:ie?700:400,boxShadow:ie?`inset 0 -2px 0 ${i("primary")}`:"none"});return e.jsxs("div",{role:"group","aria-label":k.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsxs("button",{type:"button","aria-pressed":I==="all",style:ae(I==="all"),onClick:()=>X("all"),children:[k.search.allTab," ",e.jsx("span",{style:{fontSize:12,fontWeight:400},children:N.toLocaleString()})]}),Pe.map(ie=>e.jsxs("button",{type:"button","aria-pressed":I===ie.type,style:ae(I===ie.type),onClick:()=>X(ie.type),children:[ie.name," ",e.jsx("span",{style:{fontSize:12,fontWeight:400},children:J(ie.key).toLocaleString()})]},ie.type))]})})(),$.map(({type:J,name:Pe,key:N})=>{const X=T[N]??[],ae=Qo[N],ie=T[ae]??0;if(X.length===0||I!=="all"&&I!==J)return null;const $e=I==="all"&&!(ge===J)&&ie>ii;return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"6px"},children:[e.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:[e.jsx(Gt,{type:J})," ",Pe,e.jsxs("span",{style:{fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:[ie," ",k.unit.items]})]}),$e&&e.jsx("button",{className:"bim-ib-viewall",onClick:()=>L(J),style:{border:"none",background:"transparent",color:i("primary"),cursor:"pointer",fontSize:"12px"},children:k.action.viewAll})]}),e.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:X.map(H=>{if(g)return e.jsx(x.Fragment,{children:g(H)},H.id);const B=u==="card"?Ad:er;return e.jsx(B,{entry:H,selected:fe===H.id,onClick:U,getConfig:Le,query:z},H.id)})})]},J)})]}):e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:it(k.search.noResultsFor,{query:z})}),e.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:k.search.tryOther})]})})]})},Nd=240;function Id(t){return t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey}const Rd=`
120
+ `,Vi="bim-search-view",ti=50,Ko=5,rn=1e3;function kn(t){return t>=rn?`${rn.toLocaleString()}+`:t.toLocaleString()}const vd={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function kd(t){return t&&vd[t.toLowerCase()]||"all"}function wd(t){return t==="all"?null:t}const qo=["work","collection","book","entity"],Sd={work:"works",collection:"collections",book:"books",entity:"entities"},$d={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function _d(){try{return window.localStorage.getItem(Vi)==="card"?"card":"table"}catch{return"table"}}function Cd(t){try{window.localStorage.setItem(Vi,t)}catch{}}const Lt=(t,n)=>(t==null?void 0:t[$d[n]])??0,ni=(t,n)=>(t==null?void 0:t[Sd[n]])??[],Ts=({transport:t,query:n,filters:o,onFiltersChange:r,onEntryLinkClick:s,typeName:l,tab:a,onTabChange:p})=>{const c=ke(),d=c.searchV4,{convert:u}=Ne(),g=!!t.supportsSearchFilters,m=h.useMemo(()=>g?o:An,[g,o]),[x,f]=h.useState("table");h.useEffect(()=>{f(_d())},[]);const k=M=>{f(M),Cd(M)},[b,w]=h.useState(a??"all"),y=h.useRef(b);y.current=b,h.useEffect(()=>{a!==void 0&&a!==y.current&&(w(a),S(1))},[a]);const[j,S]=h.useState(1),[v,$]=h.useState(null),[C,z]=h.useState(null),[E,T]=h.useState(!1),[_,O]=h.useState(""),W=_n(m).toString(),A=Wn(m)>0,G=_n({...m,sort:""}).toString(),V=h.useRef({query:n,filterOnlyKey:G,sort:m.sort});h.useEffect(()=>{const M=V.current;M.query!==n||M.filterOnlyKey!==G?(w("all"),S(1)):M.sort!==m.sort&&S(1),V.current={query:n,filterOnlyKey:G,sort:m.sort}},[n,G,m.sort]),h.useEffect(()=>{let M=!1;return T(!0),O(""),(async()=>{try{let ue;if(t.searchAll)ue=await t.searchAll(n,Ko,m);else{const ge=["work","book","collection","entity"],de=await Promise.all(ge.map(Le=>t.search(n,Le,{page:1,pageSize:Ko,filters:m})));ue={works:de[0].entries,books:de[1].entries,collections:de[2].entries,entities:de[3].entries,totalWorks:de[0].total,totalBooks:de[1].total,totalCollections:de[2].total,totalEntities:de[3].total}}M||$(ue)}catch(ue){M||(O(ue instanceof Error?ue.message:String(ue)),$(null))}finally{M||T(!1)}})(),()=>{M=!0}},[t,n,W]);const ie=b;h.useEffect(()=>{if(b==="all"){z(null);return}let M=!1;return T(!0),(async()=>{try{const ue=await t.search(n,b,{page:j,pageSize:ti,filters:m});M||z({key:ie,entries:ue.entries,total:ue.total})}catch(ue){M||(O(ue instanceof Error?ue.message:String(ue)),z(null))}finally{M||T(!1)}})(),()=>{M=!0}},[t,n,W,b,j]);const ae=C&&C.key===ie?C:null;h.useEffect(()=>{if(b==="all"||!ae||E)return;const M=Math.min(ae.total,rn),ue=fd(j,M,ti);ae.entries.length===0&&M>0&&ue!==j&&S(ue)},[b,ae,E,j]);const P=h.useMemo(()=>qo.filter(M=>Lt(v,M)>0),[v]),I=P.reduce((M,ue)=>M+Lt(v,ue),0),q=P.some(M=>Lt(v,M)>=rn)?`${I.toLocaleString()}+`:I.toLocaleString(),Q=!E&&!_&&v!==null&&I===0,oe=h.useCallback(M=>{w(M),S(1),p==null||p(M)},[p]),je=h.useMemo(()=>{const M=[];return m.dynasty.forEach(ue=>M.push({name:ue,remove:()=>r({...m,dynasty:m.dynasty.filter(ge=>ge!==ue)})})),m.classification.forEach(ue=>{var ge;return M.push({name:ue?((ge=Mn.find(de=>de.value===ue))==null?void 0:ge.label)??ue:c.searchPage.unclassified,remove:()=>r({...m,classification:m.classification.filter(de=>de!==ue)})})}),m.hasImage&&M.push({name:d.hasImage,remove:()=>r({...m,hasImage:!1})}),m.hasText&&M.push({name:d.hasText,remove:()=>r({...m,hasText:!1})}),m.hasCollated&&M.push({name:d.hasCollated,remove:()=>r({...m,hasCollated:!1})}),m.loss&&M.push({name:`${d.extant}:${c.searchPage.loss[m.loss]}`,remove:()=>r({...m,loss:""})}),M},[m,r,d,c]),Ie={query:n,onEntryLinkClick:s,typeName:l},K=M=>x==="table"?e.jsx(Go,{entries:M,...Ie}):e.jsx(Yo,{entries:M,...Ie}),me=qo.flatMap(M=>ni(v,M));return e.jsxs("div",{className:"bim-sr-layout","data-nofilters":g?void 0:"true",children:[e.jsx("style",{children:jd}),g&&e.jsx(gd,{filters:m,onChange:r}),e.jsxs("div",{className:"bim-sr-main","aria-busy":E,children:[P.length>0&&e.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":c.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${i("rule")}`},children:[e.jsxs(Zo,{on:b==="all",onClick:()=>oe("all"),children:[c.search.allTab," ",e.jsx("small",{children:q})]}),P.map(M=>e.jsxs(Zo,{on:b===M,onClick:()=>oe(M),children:[l(M)," ",e.jsx("small",{children:kn(Lt(v,M))})]},M))]}),e.jsxs("div",{className:"bim-sr-tools",children:[g&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":u(d.sortLabel),children:[e.jsx("button",{type:"button","aria-pressed":!m.sort,onClick:()=>r({...m,sort:""}),children:u(d.sortRelevance)}),["era","title"].map(M=>{const ue=m.sort.startsWith(`${M}:`)?m.sort.endsWith("desc")?"desc":"asc":null,ge=M==="era"?d.sortEra:d.sortTitle,de=M==="era"?ue==="desc"?d.sortEraDesc:d.sortEraAsc:ue==="desc"?d.sortTitleDesc:d.sortTitleAsc;return e.jsxs("button",{type:"button","aria-pressed":ue!==null,title:u(de),onClick:()=>r({...m,sort:`${M}:${ue==="asc"?"desc":"asc"}`}),children:[u(ge),ue?e.jsxs("span",{"aria-hidden":"true",children:[" ",ue==="asc"?"↑":"↓"]}):null]},M)})]}),e.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),e.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":u(d.viewLabel),children:[e.jsx("button",{type:"button","aria-pressed":x==="table",onClick:()=>k("table"),children:u(d.viewTable)}),e.jsx("button",{type:"button","aria-pressed":x==="card",onClick:()=>k("card"),children:u(d.viewCard)})]})]}),A&&e.jsxs("div",{className:"bim-sr-chips-row",children:[e.jsx("span",{className:"bim-sr-count",role:"status",children:u(it(d.filteredCount,{n:q}))}),je.map(M=>e.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":u(it(d.removeFilter,{name:M.name})),onClick:M.remove,children:[u(M.name),e.jsx("span",{"aria-hidden":"true",children:"×"})]},M.name))]}),_&&e.jsx("div",{className:"bim-sr-empty",role:"alert",children:_}),Q&&e.jsx("div",{className:"bim-sr-empty",children:u(A?d.emptyFiltered:it(c.search.noResultsFor,{query:n}))}),!_&&!Q&&b==="all"&&v&&(x==="table"?e.jsxs(e.Fragment,{children:[e.jsx(Go,{entries:me,...Ie}),e.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:u(d.limitedNote)})]}):e.jsx(e.Fragment,{children:P.map(M=>e.jsxs("section",{style:{marginTop:22},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,marginBottom:10},children:[e.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,letterSpacing:".1em",display:"flex",alignItems:"center",gap:8},children:[e.jsx(Gt,{type:M,size:8}),l(M),e.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:i("meta-fg")},children:[kn(Lt(v,M))," ",c.unit.items]})]}),Lt(v,M)>ni(v,M).length&&e.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>oe(M),children:c.action.viewAll})]}),e.jsx(Yo,{entries:ni(v,M),...Ie})]},M))})),!_&&b!=="all"&&!ae&&e.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:c.search.loading}),!_&&b!=="all"&&ae&&ae.entries.length>0&&e.jsxs(e.Fragment,{children:[K(ae.entries),e.jsx(bd,{page:j,pageSize:ti,total:Math.min(ae.total,rn),totalLabel:kn(ae.total),onPage:S})]}),!_&&b!=="all"&&ae&&ae.entries.length===0&&!E&&e.jsxs("div",{className:"bim-sr-empty",children:[u(A?d.emptyFiltered:it(c.search.noResultsFor,{query:n})),e.jsx("div",{children:e.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>oe("all"),children:c.search.allTab})})]})]})]})};function Zo({on:t,onClick:n,children:o}){return e.jsx("button",{type:"button","aria-pressed":t,onClick:n,style:{border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:14.5,minHeight:44,padding:"8px 12px",letterSpacing:".06em",color:i(t?"ink":"meta-fg"),fontWeight:t?700:400,boxShadow:t?`inset 0 -2px 0 ${i("accent")}`:"none"},children:o})}const Mt="bim-recent-ids",Jo="bim-recent-entries",Xo=50;function jt(){try{const t=localStorage.getItem(Mt);if(t)return JSON.parse(t);const n=localStorage.getItem(Jo);if(n){const o=JSON.parse(n).map(r=>r.id);return localStorage.setItem(Mt,JSON.stringify(o)),localStorage.removeItem(Jo),o}return[]}catch{return[]}}function bi(t){try{const n=jt().filter(o=>o!==t);n.unshift(t),n.length>Xo&&(n.length=Xo),localStorage.setItem(Mt,JSON.stringify(n))}catch{}}function Ns(t){try{const n=jt().filter(o=>o!==t);localStorage.setItem(Mt,JSON.stringify(n))}catch{}}function Gi(){try{localStorage.removeItem(Mt)}catch{}}async function Yi(t,n){var o,r,s;try{if(t.getEntry){const a=await t.getEntry(n);if(a)return a}const l=await t.getItem(n);if(l){const a=l.authors;return{id:n,title:l.title||n,type:l.type||"work",author:(o=a==null?void 0:a[0])==null?void 0:o.name,dynasty:(r=a==null?void 0:a[0])==null?void 0:r.dynasty,role:(s=a==null?void 0:a[0])==null?void 0:s.role,edition:l.edition||void 0}}}catch{}return{id:n,title:n,type:"work",notFound:!0}}const ii=5,zd=50,Td=200,Qo={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},yi=({transport:t,indexSource:n="local",syncConfig:o,onEntryClick:r,onNewEntry:s,onSwitchMode:l,onToggleDraft:a,onConfigurePath:p,onSelectFolder:c,hideModeIndicator:d,resultVariant:u="compact",renderEntry:g,initialQuery:m,onQueryChange:x,headerRight:f,reserveViewportHeight:k=!1,filtersEnabled:b=!1,filters:w=An,onFiltersChange:y,resultTab:j,onResultTabChange:S})=>{const v=ke(),$=[{type:"work",name:v.indexType.work,key:"works"},{type:"book",name:v.indexType.book,key:"books"},{type:"collection",name:v.indexType.collection,key:"collections"},{type:"entity",name:v.indexType.entity,key:"entities"}],C=["work","collection","book","entity"],[z,E]=h.useState(m??""),[T,_]=h.useState(null),[O,W]=h.useState(m??""),A=_n(w).toString(),[G,V]=h.useState(w);h.useEffect(()=>{V(w)},[A]);const ie=Z=>{V(Z),y==null||y(Z)},[ae,P]=h.useState(null),[I,q]=h.useState("all"),[Q,oe]=h.useState(!1),[je,Ie]=h.useState(null),[K,me]=h.useState(""),[M,ue]=h.useState(!(m!=null&&m.trim())),[ge,de]=h.useState(jt),[Le,Me]=h.useState([]),[Ee,ze]=h.useState(!1),[He,D]=h.useState(!1),[re,ce]=h.useState(null),[we,F]=h.useState(null),fe=h.useRef(void 0),Re=h.useRef(!1),R=h.useCallback(async(Z,Ae)=>{if(!Z.trim()){ue(!0),_(null),P(null);return}if(ue(!1),b){W(Z);return}oe(!0),me("");try{if(t.searchAll){const N=await t.searchAll(Z,Ae??ii);_(N)}else{const N=["work","book","collection","entity"],J=await Promise.all(N.map(le=>t.search(Z,le,{page:1,pageSize:Ae??ii})));_({works:J[0].entries,books:J[1].entries,collections:J[2].entries,entities:J[3].entries,totalWorks:J[0].total,totalBooks:J[1].total,totalCollections:J[2].total,totalEntities:J[3].total})}}catch(N){me(N instanceof Error?N.message:String(N)),_(null)}finally{oe(!1)}},[t,b]);h.useEffect(()=>{let Z=!1;const Ae=()=>{var pe,_e;const N=["work","book","collection","entity"],J=Promise.all(N.map(H=>t.loadEntries(H,{page:1,pageSize:1}).catch(()=>({total:0})))),le=((pe=t.getResourceCounts)==null?void 0:pe.call(t).catch(()=>null))??Promise.resolve(null),te=((_e=t.getSubtypeStats)==null?void 0:_e.call(t).catch(()=>null))??Promise.resolve(null);Promise.all([J,le,te]).then(([H,B,ye])=>{Z||(ce({works:H[0].total,books:H[1].total,collections:H[2].total,entities:H[3].total,hasText:B==null?void 0:B.hasText,hasImage:B==null?void 0:B.hasImage}),ye&&F(ye))})};return t.getCounts?t.getCounts().then(N=>{var J,le;Z||(ce({works:N.works,books:N.books,collections:N.collections,entities:N.entities,hasText:(J=N.resourceCounts)==null?void 0:J.hasText,hasImage:(le=N.resourceCounts)==null?void 0:le.hasImage}),N.subtypeStats&&F(N.subtypeStats))}).catch(()=>{Z||Ae()}):Ae(),()=>{Z=!0}},[t]),h.useEffect(()=>{Re.current||!(m!=null&&m.trim())||(Re.current=!0,R(m))},[m,R]);const ee=h.useCallback(Z=>{if(E(Z),!Z.trim()){x==null||x(Z),ue(!0),_(null),P(null),q("all");return}fe.current&&clearTimeout(fe.current),fe.current=setTimeout(()=>{P(null),q("all"),x==null||x(Z),R(Z)},Td)},[R,x]),he=h.useCallback(Z=>{fe.current&&clearTimeout(fe.current),q("all"),x==null||x(Z),R(Z)},[R,x]),L=h.useCallback(Z=>{P(Z),R(z,zd)},[z,R]);h.useEffect(()=>{if(!ge.length){Me([]);return}let Z=!1;return ze(!0),Promise.all(ge.slice(0,10).map(Ae=>Yi(t,Ae))).then(Ae=>{Z||(Me(Ae),ze(!1))}),()=>{Z=!0}},[ge,t]);const X=Z=>{Ie(Z.id),bi(Z.id),de(jt()),r==null||r(Z)},U=(Z,Ae)=>{if(r&&Id(Ae)){Ae.preventDefault(),X(Z);return}bi(Z.id),de(jt())},se=Z=>{Ns(Z),de(jt())},Se=()=>{Gi(),de([])},Pe=Z=>$.find(Ae=>Ae.type===Z),$e=!M&&!T&&!K,Fe=T&&(T.works.length>0||T.books.length>0||T.collections.length>0),De=e.jsxs(e.Fragment,{children:[e.jsx(js,{transport:t,value:z,onChange:ee,onSearch:he,onEntrySelect:X}),b&&e.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const Z=z.trim();Z&&ys(Z),he(z)},children:v.searchPage.submit}),s&&e.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:v.action.newEntry})]});return e.jsxs("div",{className:"bim-browser-container",style:k?{minHeight:"100svh"}:void 0,children:[e.jsx("style",{children:Rd+(b?Ed:"")}),(!b||f||!d)&&e.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[b?e.jsx("span",{}):e.jsx("h1",{style:{margin:0,fontSize:"18px",color:i("fg")},children:v.browser.title}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f,!d&&e.jsx(bs,{variant:"index-browser",indexSource:n,syncConfig:o,onSwitchMode:l,onToggleDraft:a,onConfigurePath:p,onSelectFolder:c})]})]})}),b?e.jsxs("div",{className:"bim-ib-bar","data-nofilters":t.supportsSearchFilters?void 0:"true",children:[e.jsx("span",{"aria-hidden":"true"}),e.jsx("div",{className:"bim-ib-bar-main",children:De})]}):e.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:De}),M&&e.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:re&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:we?e.jsxs(e.Fragment,{children:[(we.book??0)>0&&e.jsxs(e.Fragment,{children:[v.searchPage.statBook," ",e.jsx("strong",{style:{color:i("fg")},children:we.book.toLocaleString()})," ",v.unit.bu,v.searchPage.statComma,e.jsx("strong",{style:{color:i("fg")},children:re.books.toLocaleString()})," ",v.searchPage.statBookCopies]}),we.article?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{margin:"0 6px"},children:"·"}),v.searchPage.statArticle," ",e.jsx("strong",{style:{color:i("fg")},children:we.article.toLocaleString()})," ",v.searchPage.statArticleUnit]}):null,we.poem?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{margin:"0 6px"},children:"·"}),v.searchPage.statPoem," ",e.jsx("strong",{style:{color:i("fg")},children:we.poem.toLocaleString()})," ",v.searchPage.statPoemUnit]}):null,e.jsx("span",{style:{margin:"0 6px"},children:"·"}),v.searchPage.statCollection," ",e.jsx("strong",{style:{color:i("fg")},children:re.collections.toLocaleString()})]}):e.jsxs(e.Fragment,{children:[v.indexType.work," ",e.jsx("strong",{style:{color:i("fg")},children:re.works.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),v.indexType.book," ",e.jsx("strong",{style:{color:i("fg")},children:re.books.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),v.indexType.collection," ",e.jsx("strong",{style:{color:i("fg")},children:re.collections.toLocaleString()}),re.entities>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{margin:"0 6px"},children:"·"}),v.indexType.entity," ",e.jsx("strong",{style:{color:i("fg")},children:re.entities.toLocaleString()})]})]})}),re.hasImage!=null&&re.hasText!=null&&e.jsxs("span",{children:[v.resourceType.image," ",e.jsx("strong",{style:{color:i("fg")},children:re.hasImage.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),v.resourceType.text," ",e.jsx("strong",{style:{color:i("fg")},children:re.hasText.toLocaleString()})]})]})}),b&&!M&&e.jsx(Ts,{transport:t,query:O,filters:G,onFiltersChange:ie,onEntryLinkClick:U,typeName:Z=>Pe(Z).name,tab:j,onTabChange:S}),!(b&&!M)&&e.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:Q||$e?e.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg"),minHeight:Nd,boxSizing:"border-box"},children:v.search.searching}):K?e.jsx("div",{style:{textAlign:"center",padding:"40px"},children:e.jsx("p",{style:{color:i("desc-fg")},children:K})}):M?e.jsx("div",{style:{flex:1},children:Ee?e.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg")},children:v.search.loading}):Le.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:i("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{children:v.search.recentBrowse}),e.jsx("button",{onClick:Se,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:v.search.clearRecent})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:Le.slice(0,He?10:3).map(Z=>Z.notFound?e.jsx(Bd,{id:Z.id,onRemove:se,t:v},Z.id):e.jsx(er,{entry:Z,selected:je===Z.id,onClick:U,getConfig:Pe,onRemove:se},Z.id))}),!He&&Le.length>3&&e.jsx("button",{onClick:()=>D(!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:v.action.expandMore})]}):e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:v.search.searchTitle}),e.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:v.search.searchSubtitle})]})}):Fe?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[e.jsx("style",{children:Ld}),(()=>{const Z=te=>T[Qo[te]]??0,Ae=C.map(te=>$.find(pe=>pe.type===te)).filter(te=>Z(te.key)>0);if(Ae.length<2)return null;const N=Ae.reduce((te,pe)=>te+Z(pe.key),0),J=te=>{if(q(te),te!=="all"&&ae!==te){const pe=$.find(H=>H.type===te),_e=(T[pe.key]??[]).length;Z(pe.key)>_e&&L(te)}},le=te=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:i(te?"fg":"desc-fg"),fontWeight:te?700:400,boxShadow:te?`inset 0 -2px 0 ${i("primary")}`:"none"});return e.jsxs("div",{role:"group","aria-label":v.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsxs("button",{type:"button","aria-pressed":I==="all",style:le(I==="all"),onClick:()=>J("all"),children:[v.search.allTab," ",e.jsx("span",{style:{fontSize:12,fontWeight:400},children:N.toLocaleString()})]}),Ae.map(te=>e.jsxs("button",{type:"button","aria-pressed":I===te.type,style:le(I===te.type),onClick:()=>J(te.type),children:[te.name," ",e.jsx("span",{style:{fontSize:12,fontWeight:400},children:Z(te.key).toLocaleString()})]},te.type))]})})(),$.map(({type:Z,name:Ae,key:N})=>{const J=T[N]??[],le=Qo[N],te=T[le]??0;if(J.length===0||I!=="all"&&I!==Z)return null;const _e=I==="all"&&!(ae===Z)&&te>ii;return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"6px"},children:[e.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:[e.jsx(Gt,{type:Z})," ",Ae,e.jsxs("span",{style:{fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:[te," ",v.unit.items]})]}),_e&&e.jsx("button",{className:"bim-ib-viewall",onClick:()=>L(Z),style:{border:"none",background:"transparent",color:i("primary"),cursor:"pointer",fontSize:"12px"},children:v.action.viewAll})]}),e.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:J.map(H=>{if(g)return e.jsx(h.Fragment,{children:g(H)},H.id);const B=u==="card"?Ad:er;return e.jsx(B,{entry:H,selected:je===H.id,onClick:U,getConfig:Pe,query:z},H.id)})})]},Z)})]}):e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:it(v.search.noResultsFor,{query:z})}),e.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:v.search.tryOther})]})})]})},Nd=240;function Id(t){return t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey}const Rd=`
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
  `,Ed=`
@@ -142,13 +142,13 @@
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
- }`,Is={color:"inherit",textDecoration:"none"},Pd=({snippet:t})=>{const{convert:n}=Te();return e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.6},children:Mi(t).map((o,r)=>o.marked?e.jsx("mark",{style:{background:i("highlight-bg"),color:i("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(o.text)},r):e.jsx(x.Fragment,{children:n(o.text)},r))})},Ad=({entry:t,selected:n,onClick:o,getConfig:r,query:s})=>{const l=ve(),{convert:a}=Te(),p=a(t.title||t.primary_name||t.id),c=t.measure_info?a(t.measure_info):t.juan_count!=null&&t.juan_count>0?`${t.juan_count}${l.unit.juan}`:"",d=[...t.additional_titles||[],...t.attached_texts||[]],u=s&&d.length?d.find(h=>{const f=typeof h=="string"?h:h==null?void 0:h.book_title;return f==null?void 0:f.toLowerCase().includes(s.toLowerCase())}):void 0,g=i("cover-accent"),m=Ye();return e.jsxs("a",{href:m(t.id),onClick:h=>o(t,h),className:"bim-result-card",style:{...Is,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:[e.jsxs("div",{"aria-hidden":"true",style:{position:"relative",width:"92px",minHeight:"126px",flexShrink:0,borderRadius:"4px",border:`1px solid color-mix(in srgb, ${g} 50%, ${i("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${g} 14%, ${i("bg")}), color-mix(in srgb, ${g} 7%, ${i("bg")}))`,display:"flex",alignItems:"center",justifyContent:"center",padding:"0.6rem 0.3rem"},children:[e.jsx("span",{style:{position:"absolute",left:"6px",top:0,bottom:0,borderLeft:`1px dashed color-mix(in srgb, ${g} 45%, transparent)`}}),e.jsx("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",height:"108px",flexShrink:0,overflow:"hidden",fontSize:"1.05rem",fontWeight:700,lineHeight:1.25,color:g},children:Array.from(p).map((h,f)=>e.jsx("span",{children:h},f))})]}),e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"6px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:"17px",fontWeight:600,color:i("fg")},children:p}),c&&e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:c})]}),(t.dynasty||t.author)&&e.jsxs("div",{style:{fontSize:"13px",color:i("desc-fg")},children:[t.dynasty&&e.jsxs("span",{children:["〔",a(t.dynasty),"〕"]}),t.author&&e.jsx("span",{children:a(t.author)}),t.role&&t.role!=="author"&&e.jsxs("span",{children:[" ",a(t.role)]})]}),(t.era||t.edition)&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[t.era&&e.jsxs("span",{children:["〔",a(t.era),"〕"]}),t.edition&&e.jsx("span",{children:a(t.edition)})]}),u&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[l.search.alias,":",a(typeof u=="string"?u:u.book_title||"")]}),t.descriptionSnippet&&e.jsx(Pd,{snippet:t.descriptionSnippet}),e.jsxs("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"auto",paddingTop:"4px"},children:[e.jsxs("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:[e.jsx(Gt,{type:t.type,size:8})," ",r(t.type).name]}),t.has_text&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:l.misc.textResource}),t.has_image&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:l.misc.imageResource})]})]})]})},er=({entry:t,selected:n,onClick:o,getConfig:r,query:s,onRemove:l})=>{const a=ve(),{convert:p}=Te(),c=[...t.additional_titles||[],...t.attached_texts||[]],d=s&&c.length?c.find(g=>{const m=typeof g=="string"?g:g==null?void 0:g.book_title;return m==null?void 0:m.toLowerCase().includes(s.toLowerCase())}):void 0,u=Ye();return e.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:[e.jsxs("a",{href:u(t.id),onClick:g=>o(t,g),className:"bim-result-card",style:{...Is,flex:1,minWidth:0,display:"flex",alignItems:"flex-start",gap:"10px",padding:l?"10px 0 10px 12px":"10px 12px",borderRadius:"6px",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",marginTop:"2px"},children:[e.jsx(Gt,{type:t.type,size:12}),e.jsx("span",{style:{fontSize:"9px",color:i("desc-fg"),lineHeight:1},children:r(t.type).name})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg")},children:p(t.title||t.primary_name||t.id)}),e.jsxs("span",{style:{display:"flex",gap:"2px",fontSize:"12px",opacity:.7},children:[t.has_text&&e.jsx("span",{children:a.misc.textResource}),t.has_image&&e.jsx("span",{children:a.misc.imageResource})]}),(t.era||t.edition)&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[t.era&&e.jsxs(e.Fragment,{children:["〔",p(t.era),"〕"]}),t.edition&&p(t.edition)]}),t.measure_info?e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:p(t.measure_info)}):t.juan_count!=null&&t.juan_count>0?e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[t.juan_count,a.unit.juan]}):null]}),(t.dynasty||t.author)&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px"},children:[t.dynasty&&e.jsxs("span",{children:["〔",p(t.dynasty),"〕"]}),t.author&&e.jsx("span",{children:p(t.author)}),t.role&&t.role!=="author"&&e.jsxs("span",{children:[" ",p(t.role)]}),t.type==="entity"&&(t.birth_year!=null||t.death_year!=null)&&e.jsxs("span",{style:{marginLeft:t.dynasty?"4px":0},children:[t.birth_year??"?","—",t.death_year??"?"]})]}),d&&e.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:[a.search.alias,":",p(d)]})]}),!l&&e.jsx("span",{"aria-hidden":"true",style:{opacity:.4,marginTop:"2px"},children:"→"})]}),l&&e.jsx("button",{type:"button",onClick:()=>l(t.id),title:a.search.removeFromRecent,"aria-label":a.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:"×"})]})},Bd=({id:t,onRemove:n,t:o})=>e.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:[e.jsx("span",{style:{fontSize:"16px"},children:"❓"}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:"13px",color:i("fg"),fontFamily:"monospace"},children:t}),e.jsx("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:o.search.itemNotFound})]}),e.jsx("button",{onClick:()=>n(t),title:o.search.removeFromRecent,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"2px 4px",lineHeight:1},children:"×"})]});function Md(t){var n;return!t.dynasty&&!t.birth_year&&!t.death_year&&(!t.alt_names||t.alt_names.length===0)&&!((n=t.description)!=null&&n.text)}function Wd({data:t}){const{convert:n}=Te(),{dynasty:o,birth_year:r,death_year:s}=t,l=[];return o&&l.push(`〔${n(o)}〕`),r!==void 0&&s!==void 0?l.push(`${r}—${s}`):r!==void 0?l.push(`${r}—?`):s!==void 0&&l.push(`?—${s}`),l.length===0?null:e.jsx("span",{style:{fontSize:"14px",color:i("desc-fg"),marginLeft:"8px",fontWeight:"normal"},children:l.join(" ")})}function Hd({alt_names:t}){const{convert:n}=Te(),o=new Map;for(const l of t){const a=l.type||"別名";o.has(a)||o.set(a,[]),o.get(a).push(l.name)}const r=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...o.keys()].sort((l,a)=>{const p=r.indexOf(l),c=r.indexOf(a);return p===-1&&c===-1?0:p===-1?1:c===-1?-1:p-c});return e.jsx("div",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(l=>{const a=o.get(l);return e.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[e.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px",minWidth:"36px",paddingTop:"2px"},children:n(l)}),e.jsx("span",{children:a.map((p,c)=>e.jsxs("span",{children:[c>0&&e.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),n(p)]},c))})]},l)})})}function Od({data:t}){const n=ve(),o=t.external_ids;if(!o)return null;const r=[];return o.cbdb_id&&r.push(e.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:e.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:r})}function Fd({works:t,transport:n,onNavigate:o,renderLink:r}){const s=ve(),{convert:l}=Te(),a=Ye(),[p,c]=x.useState(new Map);x.useEffect(()=>{if(!n)return;let m=!1;const h=t.map(v=>v.work_id);return(async()=>{const v=new Map;if(n.getEntriesByIds)try{const j=await n.getEntriesByIds(h);let S=!0;for(let k=0;k<h.length;k++){const $=j[k];$!=null&&$.title?v.set(h[k],$.title):$!=null&&$.primary_name?v.set(h[k],$.primary_name):S=!1}if(S)return v}catch{}const y=[...h],w=8,b=new Array(w).fill(0).map(async()=>{for(;y.length;){const j=y.shift();if(!j)break;if(!v.has(j))try{if(n.getEntry){const $=await n.getEntry(j);if($!=null&&$.title){v.set(j,$.title);continue}}const S=await n.getItem(j),k=S&&(S.title||S.primary_name)||j;v.set(j,k)}catch{v.set(j,j)}}});return await Promise.all(b),v})().then(v=>{m||c(v)}),()=>{m=!0}},[t,n]);const d=new Map;for(const m of t){const h=m.role||"";d.has(h)||d.set(h,[]),d.get(h).push(m)}const u=["撰","編","注","輯","集","校","評","譯","述","作",""],g=[...d.keys()].sort((m,h)=>{const f=u.indexOf(m),v=u.indexOf(h);return f===-1&&v===-1?m.localeCompare(h):f===-1?1:v===-1?-1:f-v});return e.jsxs("div",{style:{marginTop:"12px"},children:[e.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," ",e.jsxs("span",{style:{color:i("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",t.length,")"]})]}),g.map(m=>{const h=d.get(m);return e.jsxs("div",{style:{marginBottom:"8px"},children:[m&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"2px"},children:[l(m)," ",e.jsxs("span",{style:{color:i("desc-fg")},children:["(",h.length,")"]})]}),e.jsx("ul",{style:{margin:0,paddingLeft:m?"16px":"0",listStyle:m?"disc":"none",fontSize:"14px",lineHeight:1.8},children:h.map((f,v)=>{const y=l(p.get(f.work_id)||f.work_id);return r?e.jsx("li",{children:r(f.work_id,y)},v):o?e.jsx("li",{children:e.jsx("a",{href:a(f.work_id),onClick:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),o(f.work_id))},style:{color:i("link-fg"),textDecoration:"underline",cursor:"pointer"},children:y})},v):e.jsx("li",{children:y},v)})})]},m)})]})}const Rs=({data:t,transport:n,onNavigate:o,renderLink:r,headerExtra:s,hideHeader:l})=>{var g;const a=ve(),{convert:p}=Te();let c=!1;try{c=xe.extractStatus(t.id)==="draft"}catch{}const d=Md(t),u=t.subtype&&t.subtype in a.common.entitySubtype?a.common.entitySubtype[t.subtype]:p(t.subtype);return e.jsxs("div",{children:[!l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"4px"},children:[e.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:600,margin:0,lineHeight:1.3,color:i("fg")},children:[p(t.primary_name),e.jsx(Wd,{data:t})]}),s]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:i("desc-fg"),marginBottom:"8px"},children:[e.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:a.indexType.entity}),u&&t.subtype!=="people"&&e.jsx("span",{children:u}),c&&e.jsx("span",{style:{padding:"1px 6px",background:i("warn-bg"),border:`1px solid ${i("warn-border")}`,borderRadius:"2px",color:i("warn-fg")},children:a.status.draft}),e.jsx("span",{style:{fontFamily:"monospace",opacity:.6},children:t.id})]})]}),d&&e.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:a.common.entityPlaceholderNote}),t.alt_names&&t.alt_names.length>0&&e.jsx(Hd,{alt_names:t.alt_names}),e.jsx(Od,{data:t}),((g=t.description)==null?void 0:g.text)&&e.jsx("p",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:p(t.description.text)}),t.works&&t.works.length>0&&e.jsx(Fd,{works:t.works,transport:n,onNavigate:o,renderLink:r})]})},Dd=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function Ud(t){const n=t.search(Dd);return n<0?[t,""]:[t.slice(0,n),t.slice(n)]}const Es={p:({children:t})=>e.jsx("p",{style:{margin:"0 0 0.5em"},children:t}),ul:({children:t})=>e.jsx("ul",{style:{margin:"0 0 0.5em",paddingLeft:"1.4em"},children:t}),ol:({children:t})=>e.jsx("ol",{style:{margin:"0 0 0.5em",paddingLeft:"1.6em"},children:t}),li:({children:t})=>e.jsx("li",{style:{marginBottom:"2px"},children:t}),a:({href:t,children:n})=>{let o=t,r="",s=n;if(t&&typeof n=="string"&&(n===t||n===Vd(t))){const[l,a]=Ud(n);a&&(o=encodeURI(l),s=l,r=a)}return e.jsxs(e.Fragment,{children:[e.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:t})=>e.jsx("code",{style:{background:i("bg-subtle"),padding:"1px 4px",borderRadius:3,fontSize:"0.92em"},children:t})};function Vd(t){try{return decodeURI(t)}catch{return t}}const Gd={...Es,strong:({children:t})=>e.jsx(e.Fragment,{children:t})},ft=({text:t,plainStrong:n,style:o,className:r})=>{const{convert:s}=Te(),l=n?Gd:Es;return e.jsx("div",{className:r,style:o,children:e.jsx(bc,{remarkPlugins:[yc],components:l,children:s(t)})})},Yd=["〇","一","二","三","四","五","六","七","八","九"],tr=["","十","百","千"];function Ls(t){if(t<=0)return"";if(t>=1e4)return String(t);const n=String(t),o=n.length;let r="",s=!1;for(let l=0;l<o;l++){const a=parseInt(n[l]),p=o-1-l;a===0?s=!0:(s&&r&&(r+="〇"),s=!1,a===1&&p===1&&l===0?r+=tr[p]:r+=Yd[a]+tr[p])}return r}function Ps(t){return{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:t,border:`1px solid color-mix(in srgb, ${t} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${t} 3%, transparent)`}}const Kd={book:i("type-book"),work:i("type-work"),collection:i("type-collection"),entity:i("type-entity")};function qd({type:t}){const n=ve();return e.jsx("span",{style:Ps(Kd[t]),children:n.indexType[t]})}function Zd({isDraft:t}){const n=ve(),o=i(t?"status-draft":"status-official");return e.jsx("span",{style:Ps(o),children:t?n.status.draft:n.status.official})}function Jd({id:t}){const n=ve(),[o,r]=x.useState(!1),s=()=>{navigator.clipboard.writeText(t).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})};return e.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:[e.jsx("span",{children:n.label.id}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:i("fg")},children:t}),e.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:l=>l.currentTarget.style.opacity="1",onMouseLeave:l=>l.currentTarget.style.opacity=o?"1":"0.5",children:o?"✓":"⧉"})]})}function rt({children:t,extra:n}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"20px",marginBottom:"8px"},children:[e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:i("desc-fg"),letterSpacing:"1px"},children:t}),e.jsx("span",{style:{flex:1}}),n]})}function pt({label:t,children:n}){return e.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[e.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:t}),e.jsx("span",{style:{color:i("fg")},children:n})]})}function As({authors:t,type:n,onNavigate:o,renderLink:r}){const{convert:s}=Te();return e.jsx("span",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.6},children:t.map((l,a)=>{const p=s(l.name),c=l.entity_id?e.jsx(ct,{id:l.entity_id,label:p,onNavigate:o,renderLink:r}):e.jsx("span",{style:{fontWeight:500},children:p});return e.jsxs("span",{children:[a>0&&e.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),l.dynasty&&e.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:["〔",s(l.dynasty),"〕"]}),c,l.role&&e.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px",marginLeft:"2px"},children:[" ",s(l.role)]})]},a)})})}function ct({id:t,label:n,onNavigate:o,renderLink:r}){const s=Ye();return r?e.jsx(e.Fragment,{children:r(t,n)}):o?e.jsx("a",{href:s(t),onClick:l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),o(t))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`,paddingBottom:"1px"},onMouseEnter:l=>l.currentTarget.style.borderBottomStyle="solid",onMouseLeave:l=>l.currentTarget.style.borderBottomStyle="dashed",children:n||t}):e.jsx("span",{children:n||t})}function Xd({id:t,title:n,edition:o,type:r,isDraft:s,authors:l,volumeText:a,meta:p,headerExtra:c,onNavigate:d,renderLink:u}){return e.jsxs("div",{style:{marginBottom:"4px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[e.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&&e.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:o}),a&&e.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:a})]}),c&&e.jsx("div",{style:{flexShrink:0,paddingTop:"2px"},children:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"4px"},children:[e.jsx(qd,{type:r}),e.jsx(Zd,{isDraft:s}),e.jsx(Jd,{id:t})]}),((l==null?void 0:l.length)||p.length>0)&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"12px",marginTop:"6px"},children:[l&&l.length>0&&e.jsx(As,{authors:l,type:r,onNavigate:d,renderLink:u}),p]})]})}function Bs({items:t,label:n,showMeta:o,onNavigate:r,renderLink:s}){const l=ve(),{convert:a}=Te();if(!t.length)return null;const[p,c]=x.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:n}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.map((d,u)=>{const g=p===u;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...g?{boxShadow:i("shadow-card")}:{}},children:[e.jsxs("div",{onClick:()=>c(g?null:u),style:{padding:"8px 12px",background:i("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[e.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.15s",transform:g?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:a(d.source)}),!g&&o&&d.title_info&&e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a(d.title_info)}),d.source_bid&&e.jsx("span",{onClick:m=>m.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:e.jsx(ct,{id:d.source_bid,label:l.action.view,onNavigate:r,renderLink:s})})]}),g&&e.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${i("widget-border")}`},children:[o&&(d.title_info||d.author_info||d.edition)&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[d.title_info&&e.jsx(pt,{label:l.label.titleInfo,children:a(d.title_info)}),d.author_info&&e.jsx(pt,{label:l.label.authorInfo,children:a(d.author_info)}),d.edition&&e.jsx(pt,{label:l.label.edition,children:a(d.edition)})]}),d.summary&&e.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:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.summary}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:a(d.summary)})]}),d.comment&&e.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.comment}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:a(d.comment)})]}),d.additional_comment&&e.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.additionalComment}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:a(d.additional_comment)})]})]})]},u)})})]})}function Qd({items:t,onNavigate:n,renderLink:o}){const r=ve();return e.jsx(Bs,{items:t,label:r.section.indexed,showMeta:!0,onNavigate:n,renderLink:o})}function Ms({items:t,onNavigate:n,renderLink:o}){const r=ve();return e.jsx(Bs,{items:t,label:r.section.emendated,onNavigate:n,renderLink:o})}function Ws({label:t,items:n}){const{convert:o}=Te();return n.length?e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:t}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:n.map((r,s)=>{const l=typeof r=="string"?r:r.book_title;return e.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(l)},s)})})]}):null}function ep({items:t}){const n=ve();return e.jsx(Ws,{label:n.section.aliases,items:t})}function tp({items:t}){const n=ve();return e.jsx(Ws,{label:n.section.attachedTexts,items:t})}function np({items:t}){const n=ve(),{convert:o}=Te();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:n.section.appendix}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:t.map((r,s)=>e.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&&e.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:[r.n_juan,n.unit.juan]})]},s))})]}):null}function ip({items:t}){const n=ve(),{convert:o}=Te();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:n.section.locationHistory}),e.jsxs("div",{style:{position:"relative",paddingLeft:"18px"},children:[e.jsx("div",{style:{position:"absolute",left:"4px",top:"6px",bottom:"6px",width:"1px",background:i("widget-border")}}),t.map((r,s)=>e.jsxs("div",{style:{position:"relative",marginBottom:"10px"},children:[e.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")}`}}),e.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:i("fg")},children:o(r.name)}),r.description&&e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),marginLeft:"8px"},children:o(r.description)})]},s))]})]}):null}function op({items:t}){const n=ve(),{convert:o}=Te();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:n.section.historyOverview}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:t.map((r,s)=>e.jsxs("div",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[e.jsx("span",{style:{position:"absolute",left:0,top:0,color:i("desc-fg")},children:"·"}),o(r)]},s))})]}):null}function nr({title:t,ids:n,transport:o,onNavigate:r,renderLink:s}){const{convert:l}=Te(),[a,p]=x.useState([]);return x.useEffect(()=>{if(!n.length){p([]);return}if(!o){p(n.map(d=>({id:d})));return}let c=!1;return Promise.all(n.map(d=>o.getItem(d).then(u=>({id:d,title:u?u.title:void 0,edition:u?u.edition:void 0,type:u?u.type:void 0})).catch(()=>({id:d})))).then(d=>{c||p(d)}),()=>{c=!0}},[n,o]),n.length?e.jsxs(e.Fragment,{children:[e.jsxs(rt,{children:[t,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",n.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:(a.length?a:n.map(c=>({id:c}))).map(c=>{const d=c.edition?`${l(c.title)||c.id}(${l(c.edition)})`:l(c.title)||void 0;return e.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:e.jsx(ct,{id:c.id,label:d,onNavigate:r,renderLink:s})},c.id)})})]}):null}function oi({book:t,onNavigate:n,renderLink:o}){const r=ve(),{convert:s}=Te(),[l,a]=x.useState(!1),p=t.resources&&t.resources.length>0,c=t.edition?s(t.edition):s(t.title)||void 0;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:i("input-bg")},children:[e.jsxs("div",{style:{padding:"6px 12px",borderBottom:p&&!l?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:e.jsx(ct,{id:t.id,label:c,onNavigate:n,renderLink:o})}),p&&e.jsx("span",{onClick:()=>a(d=>!d),style:{cursor:"pointer",fontSize:"10px",color:i("desc-fg"),userSelect:"none",transition:"transform 0.15s",transform:l?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:l?r.action.expand:r.action.collapse,children:"▼"})]}),p&&!l&&e.jsx("div",{style:{padding:"10px 14px"},children:e.jsx(Ui,{items:t.resources,resourceGroups:t.resource_groups,groupByType:!0,onNavigate:n,renderLink:o})})]})}function rp({ids:t,workData:n,transport:o,onNavigate:r,renderLink:s,footer:l}){const a=ve(),{convert:p}=Te(),[c,d]=x.useState([]);if(x.useEffect(()=>{if(!t.length){d([]);return}if(!o){d(t.map(v=>({id:v})));return}let f=!1;return Promise.all(t.map(v=>o.getItem(v).then(y=>({id:v,title:y?y.title:void 0,edition:y?y.edition:void 0,resources:y?y.resources:void 0,resource_groups:y?y.resource_groups:void 0})).catch(()=>({id:v})))).then(v=>{f||d(v)}),()=>{f=!0}},[t,o]),!t.length)return null;const u=c.length?c:t.map(f=>({id:f})),g=new Map(u.map(f=>[f.id,f])),m=n==null?void 0:n.version_graph,h=sp(t,m,a.common.otherVersions);return e.jsxs(e.Fragment,{children:[e.jsxs(rt,{children:[a.section.relatedVersions,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",t.length,")"]})]}),l,h.useGrouping?e.jsxs(e.Fragment,{children:[h.coreIds.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:h.coreIds.map(f=>{const v=g.get(f);return v?e.jsx(oi,{book:v,onNavigate:r,renderLink:s},f):null})}),h.groupedIds.map(f=>e.jsxs("details",{style:{marginTop:12,border:`1px solid ${i("widget-border")}`,borderRadius:6,background:i("bg-subtle")},children:[e.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:i("fg"),userSelect:"none"},children:[p(f.label),e.jsxs("span",{style:{marginLeft:6,fontSize:12,color:i("desc-fg"),fontWeight:400},children:["(",f.ids.length,")"]}),f.description&&e.jsx("span",{style:{marginLeft:8,fontSize:12,color:i("desc-fg"),fontWeight:400},children:p(f.description)})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"0 12px 12px"},children:f.ids.map(v=>{const y=g.get(v);return y?e.jsx(oi,{book:y,onNavigate:r,renderLink:s},v):null})})]},f.id))]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:u.map(f=>e.jsx(oi,{book:f,onNavigate:r,renderLink:s},f.id))})]})}function sp(t,n,o){var w,b;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:t,groupedIds:[]};const r=(w=n.collections)==null?void 0:w[n.default_collection],s=(r==null?void 0:r.groups)??[],l=(r==null?void 0:r.book_ids)??[],a=s.length>0||l.length>0,p=!a&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!a&&p.length===0)return{useGrouping:!1,coreIds:t,groupedIds:[]};const c=new Set(s),d=new Set([...l,...p]),u=j=>{if(d.has(j))return!0;const S=n.node_groups[j];return S!=null&&c.has(S)},g=[],m=new Map,h=[];for(const j of t)if(!((b=n.excluded_books)!=null&&b.includes(j)))if(u(j))g.push(j);else{const S=n.node_groups[j];S?(m.has(S)||m.set(S,[]),m.get(S).push(j)):h.push(j)}if(h.length+[...m.values()].reduce((j,S)=>j+S.length,0)<3)return{useGrouping:!1,coreIds:t,groupedIds:[]};const v=new Map((n.groups??[]).map(j=>[j.id,j])),y=[...m.entries()].map(([j,S])=>{const k=v.get(j);return{id:j,label:(k==null?void 0:k.label)??j,description:k==null?void 0:k.description,ids:S}});return h.length>0&&y.push({id:"__other__",label:o,description:void 0,ids:h}),{useGrouping:!0,coreIds:g,groupedIds:y}}function lp({workData:t,onNavigate:n,renderLink:o}){var a,p,c,d;const r=ve(),{convert:s}=Te(),l=!!((a=t.description)!=null&&a.text)||!!t.parent_work;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:i("input-bg"),marginTop:"4px"},children:[e.jsxs("div",{style:{padding:"6px 14px",borderBottom:l?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`},children:[e.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:e.jsx(ct,{id:t.id,label:s(t.title),onNavigate:n,renderLink:o})}),t.measure_info?e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:s(t.measure_info)}):((p=t.juan_count)==null?void 0:p.number)!=null&&t.juan_count.number>0?e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[Ls(t.juan_count.number),r.unit.juan]}):null,t.authors&&t.authors.length>0&&e.jsx("span",{style:{fontSize:"13px"},children:e.jsx(As,{authors:t.authors,type:"work",onNavigate:n,renderLink:o})})]}),l&&e.jsxs("div",{style:{padding:"8px 14px"},children:[((c=t.description)==null?void 0:c.text)&&e.jsx(ft,{text:t.description.text,style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,textAlign:"justify"}}),t.parent_work&&e.jsx("div",{style:{marginTop:(d=t.description)!=null&&d.text?"8px":0,fontSize:"13px"},children:e.jsx(pt,{label:r.label.parentWork,children:e.jsx(ct,{id:t.parent_work.id,label:s(t.parent_work.title),onNavigate:n,renderLink:o})})})]})]})}function ap({items:t,onNavigate:n,renderLink:o}){const r=ve(),{convert:s}=Te();return t.length?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"6px"},children:t.map(l=>e.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:[e.jsx("span",{style:{fontSize:"11px",color:i("type-collection")},children:r.indexType.collection}),e.jsx(ct,{id:l.id,label:s(l.title)||l.id,onNavigate:n,renderLink:o}),l.volume_index!=null&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"2px"},children:it(r.catalog.volume,{n:l.volume_index})})]},l.id))}):null}const Ki=({data:t,id:n,transport:o,onNavigate:r,renderLink:s,headerExtra:l,relatedBooksFooter:a,className:p,style:c})=>{var O,W,P,Y,V,Q,ge,A;const d=ve(),{convert:u}=Te(),[g,m]=x.useState(null),[h,f]=x.useState(!1),[v,y]=x.useState(null),[w,b]=x.useState(null),[j,S]=x.useState([]),k=t||g;if(x.useEffect(()=>{if(t||!n||!o)return;let I=!1;return f(!0),y(null),o.getItem(n).then(Z=>{I||(Z?m(Z):y(d.misc.notFoundEntry))}).catch(Z=>{I||y(Z instanceof Error?Z.message:d.misc.loadFailed)}).finally(()=>{I||f(!1)}),()=>{I=!0}},[t,n,o]),x.useEffect(()=>{if(!k||!o){b(null),S([]);return}let I=!1;const Z=k.type==="book"||k.type==="collection"?k.work_id:void 0;if(Z?o.getItem(Z).then(ee=>{!I&&ee&&ee.type==="work"&&b(ee)}).catch(()=>{}):b(null),k.type==="book"){const ee=k;ee.contained_in&&ee.contained_in.length>0?Promise.all(ee.contained_in.map(ce=>{const fe=typeof ce=="string"?ce:ce.id,Ie=typeof ce=="string"?void 0:ce.volume_index;return o.getItem(fe).then(q=>({id:fe,title:q&&q.title||fe,volume_index:Ie})).catch(()=>({id:fe,title:fe,volume_index:Ie}))})).then(ce=>{I||S(ce)}):S([])}else S([]);return()=>{I=!0}},[k,o]),h)return e.jsx("div",{className:p,style:{...c,padding:"24px"},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((I,Z)=>e.jsx("div",{style:{height:Z===1?"32px":"16px",width:`${I}px`,background:i("widget-border"),borderRadius:"4px",opacity:.4}},Z))})});if(v)return e.jsx("div",{className:p,style:{...c,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:v});if(!k)return null;if(k.type==="entity")return e.jsx("div",{className:p,style:c,children:e.jsx(Rs,{data:k,transport:o,onNavigate:r,renderLink:s,headerExtra:l})});const $=k.type==="book"?k:null,_=k.type==="collection"?k:null,z=k.type==="work"?k:null;let E=!1;try{E=xe.extractStatus(k.id)==="draft"}catch{}let T="";k.measure_info?T=u(k.measure_info):(O=k.juan_count)!=null&&O.number?T=Ls(k.juan_count.number)+d.unit.juan:(W=k.juan_count)!=null&&W.description&&(T=u(k.juan_count.description));const C=[];return(P=k.publication_info)!=null&&P.year&&C.push(e.jsx(pt,{label:d.label.year,children:k.publication_info.year},"year")),(Y=k.current_location)!=null&&Y.name&&C.push(e.jsx(pt,{label:d.label.currentLocation,children:u(k.current_location.name)},"loc")),(V=k.page_count)!=null&&V.description&&C.push(e.jsx(pt,{label:d.label.pageCount,children:k.page_count.description},"page")),$!=null&&$.edition&&C.push(e.jsx(pt,{label:d.label.edition,children:u($.edition)},"ver")),z!=null&&z.parent_work&&C.push(e.jsx(pt,{label:d.label.parentWork,children:e.jsx(ct,{id:z.parent_work.id,label:u(z.parent_work.title),onNavigate:r,renderLink:s})},"pw")),z!=null&&z.parent_works&&z.parent_works.length>0&&!z.parent_work&&C.push(e.jsx(pt,{label:d.label.parentWork,children:z.parent_works.map((I,Z)=>e.jsxs("span",{children:[Z>0&&"、",e.jsx(ct,{id:I,onNavigate:r,renderLink:s})]},I))},"pws")),e.jsxs("div",{className:p,style:c,children:[e.jsx(Xd,{id:k.id,title:u(k.title),edition:k.edition?u(k.edition):void 0,type:k.type,isDraft:E,authors:k.authors,volumeText:T,meta:C,headerExtra:l,onNavigate:r,renderLink:s}),((Q=k.description)==null?void 0:Q.text)&&e.jsx(ft,{text:k.description.text,style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),k.appendix&&k.appendix.length>0&&e.jsx("div",{style:{marginTop:8,marginBottom:4},children:k.appendix.map((I,Z)=>e.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:i("bg-subtle"),borderRadius:4,border:`1px solid ${i("widget-border")}`},children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:i("muted")},children:u(I.title)}),e.jsx(ft,{text:I.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:i("fg")}})]},Z))}),j.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:d.section.containedIn}),e.jsx(ap,{items:j,onNavigate:r,renderLink:s})]}),w&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:d.section.belongsToWork}),e.jsx(lp,{workData:w,onNavigate:r,renderLink:s})]}),k.additional_works&&k.additional_works.length>0&&e.jsx(np,{items:k.additional_works}),k.additional_titles&&k.additional_titles.length>0&&e.jsx(ep,{items:k.additional_titles}),k.attached_texts&&k.attached_texts.length>0&&e.jsx(tp,{items:k.attached_texts}),k.indexed_by&&k.indexed_by.length>0&&e.jsx(Qd,{items:k.indexed_by,onNavigate:r,renderLink:s}),k.emendated_by&&k.emendated_by.length>0&&e.jsx(Ms,{items:k.emendated_by,onNavigate:r,renderLink:s}),k.resources&&k.resources.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:d.section.resources}),e.jsx(Ui,{items:k.resources,resourceGroups:k.resource_groups,groupByType:!0,onNavigate:r,renderLink:s})]}),($==null?void 0:$.location_history)&&$.location_history.length>0&&e.jsx(ip,{items:$.location_history}),(_==null?void 0:_.history)&&_.history.length>0&&e.jsx(op,{items:_.history}),($==null?void 0:$.related_books)&&$.related_books.length>0&&e.jsx(nr,{title:d.section.relatedVersions,ids:$.related_books,transport:o,onNavigate:r,renderLink:s}),(_==null?void 0:_.books)&&_.books.length>0&&e.jsx(nr,{title:d.section.containedBooks,ids:_.books,transport:o,onNavigate:r,renderLink:s}),(_==null?void 0:_.contained_works)&&_.contained_works.length>0&&e.jsxs("div",{children:[e.jsxs(rt,{children:[d.section.containedWorks,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",_.contained_works.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:_.contained_works.map(I=>e.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:e.jsx(ct,{id:I.id,label:u(I.title),onNavigate:r,renderLink:s})},I.id))})]}),(((ge=z==null?void 0:z.books)==null?void 0:ge.length)||0)+(((A=z==null?void 0:z.collections)==null?void 0:A.length)||0)>0&&e.jsx(rp,{ids:[...(z==null?void 0:z.books)||[],...(z==null?void 0:z.collections)||[]],workData:z??void 0,transport:o,onNavigate:r,renderLink:s,footer:a}),(z==null?void 0:z.related_works)&&z.related_works.length>0&&(()=>{const I=[],Z=z.related_works.filter(M=>M.relation==="part_of"),ee=z.related_works.filter(M=>M.relation==="has_part"),ce=z.related_works.filter(M=>M.relation==="has_adaptation"),fe=z.related_works.filter(M=>M.relation==="text_carried_by"),Ie=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),q=z.related_works.filter(M=>!M.relation||!Ie.has(M.relation));return Z.length>0&&I.push({label:d.section.belongsToWork,items:Z}),ee.length>0&&I.push({label:d.section.containedWorks,items:ee}),ce.length>0&&I.push({label:d.section.adaptations,items:ce}),fe.length>0&&I.push({label:d.section.derivativeWorks,items:fe}),q.length>0&&I.push({label:d.section.relatedWorks,items:q}),I.map(M=>e.jsxs("div",{children:[e.jsxs(rt,{children:[M.label,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",M.items.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:M.items.map(K=>e.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:e.jsx(ct,{id:K.id,label:u(K.title),onNavigate:r,renderLink:s})},K.id))})]},M.label))})()]})};function cp({data:t}){const n=ve(),{convert:o}=Te(),{stats:r}=t,s=r.processed_volumes??r.total_found_volumes,l=s!=null&&t.total_volumes>0?Math.round(s/t.total_volumes*100):null;return e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:o(t.title)}),t.resource_name&&e.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"6px"},children:o(t.resource_name)}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:i("desc-fg")},children:[e.jsxs("span",{children:[n.catalog.totalVolumes," ",e.jsx("strong",{style:{color:i("fg")},children:t.total_volumes})," ",n.unit.volume]}),l!=null&&e.jsxs("span",{children:[n.catalog.processed," ",e.jsx("strong",{style:{color:i("fg")},children:s})," ",n.unit.volume," (",l,"%)"]}),e.jsxs("span",{children:[n.catalog.contains," ",e.jsx("strong",{style:{color:i("fg")},children:r.total_books})," ",n.unit.bu]}),r.matched_works!=null&&r.matched_works>0&&e.jsxs("span",{children:[n.catalog.matched," ",e.jsx("strong",{style:{color:i("fg")},children:r.matched_works})," ",n.unit.bu]}),r.unmatched_works!=null&&r.unmatched_works>0&&e.jsxs("span",{children:[n.catalog.unmatched," ",e.jsx("strong",{style:{color:i("missing-fg")},children:r.unmatched_works})," ",n.unit.bu]})]}),t.source&&e.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:i("desc-fg")},children:[n.catalog.source," ",t.source]})]})}function dp({sections:t,activeSection:n,onSelect:o}){const r=ve();return e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[e.jsx("button",{onClick:()=>o(null),style:ir(n===null),children:r.catalog.all}),t.map(s=>e.jsxs("button",{onClick:()=>o(s.name),style:ir(n===s.name),children:[s.name,s.volume_range&&e.jsxs("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"4px"},children:[s.volume_range[0],"–",s.volume_range[1]]})]},s.name))]})}function ir(t){return{padding:"4px 12px",border:t?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:t?`color-mix(in srgb, ${i("primary")} 8%, transparent)`:"transparent",color:i(t?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:t?600:400}}function pp({id:t,label:n,onNavigate:o,renderLink:r}){const s=Ye();return r?e.jsx(e.Fragment,{children:r(t,n)}):o?e.jsx("a",{href:s(t),onClick:l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),o(t))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`,paddingBottom:"1px",fontSize:"12px"},onMouseEnter:l=>l.currentTarget.style.borderBottomStyle="solid",onMouseLeave:l=>l.currentTarget.style.borderBottomStyle="dashed",children:n||t}):e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:n||t})}function up(t,n){if(t.length===0)return"";if(t.length===1)return`${t[0]}`;const o=t[0],r=t[t.length-1];return r-o+1===t.length?`${o}–${r}`:t.length<=3?t.join(", "):`${o}–${r} (${t.length}${n})`}function or({book:t,onNavigate:n,renderLink:o,showVolumes:r}){const s=ve(),{convert:l}=Te(),a=t.book_id||t.work_id,p=r&&t.volumes.length>0?up(t.volumes,s.unit.volume):null,c=t.missing_volumes&&t.missing_volumes.length>0;return e.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&&e.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:i("desc-fg"),textAlign:"right"},children:p}),e.jsxs("span",{style:{flex:1,fontWeight:500,color:i("fg")},children:[l(t.title),t.sub_items&&t.sub_items.length>0&&e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400,marginLeft:"6px"},children:["(",t.sub_items.map(d=>l(d)).join("、"),")"]}),t.edition&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),fontWeight:400,marginLeft:"8px"},children:l(t.edition)})]}),t.expected_volumes!=null&&e.jsxs("span",{style:{fontSize:"11px",color:i(c?"missing-fg":"desc-fg"),flexShrink:0},children:[t.found_volumes??0,"/",t.expected_volumes,s.unit.volume]}),a&&e.jsx(pp,{id:a,label:t.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:o}),!a&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const qi=({data:t,collectionId:n,transport:o,onNavigate:r,renderLink:s,className:l,style:a})=>{const p=ve(),[c,d]=x.useState(null),[u,g]=x.useState(!1),[m,h]=x.useState(null),[f,v]=x.useState(null),[y,w]=x.useState(""),b=t||c;x.useEffect(()=>{if(t||!n||!(o!=null&&o.getCollectionCatalog))return;let _=!1;return g(!0),h(null),o.getCollectionCatalog(n).then(z=>{_||(z?d(z):h(p.catalog.notFound))}).catch(z=>{_||h(z instanceof Error?z.message:p.catalog.loadFailed)}).finally(()=>{_||g(!1)}),()=>{_=!0}},[t,n,o,p]);const j=(b==null?void 0:b.sections)&&b.sections.length>0,S=x.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const _=b.books.map(E=>E.volumes[0]).filter(E=>E!=null);return new Set(_).size<_.length},[b]),k=x.useMemo(()=>{if(!b)return[];let _=b.books;if(f&&(_=_.filter(z=>z.section===f)),y.trim()){const z=y.trim().toLowerCase();_=_.filter(E=>E.title.toLowerCase().includes(z)||E.sub_items&&E.sub_items.some(T=>T.toLowerCase().includes(z))||E.edition&&E.edition.toLowerCase().includes(z))}return _},[b,f,y]),$=x.useMemo(()=>{if(!S)return null;const _=[],z=new Map;for(const T of k){if(!T.volumes||T.volumes.length===0)continue;const C=T.volumes[0];z.has(C)||z.set(C,[]),z.get(C).push(T)}const E=[...z.keys()].sort((T,C)=>T-C);for(const T of E)_.push({volume:T,books:z.get(T)});return _},[k,S]);return u?e.jsx("div",{className:l,style:{...a,padding:"24px"},children:e.jsx("div",{style:{color:i("desc-fg"),fontSize:"13px"},children:p.catalog.loading})}):m?e.jsx("div",{className:l,style:{...a,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:m}):b?e.jsxs("div",{className:l,style:a,children:[e.jsx(cp,{data:b}),j&&e.jsx(dp,{sections:b.sections,activeSection:f,onSelect:v}),e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("input",{type:"text",placeholder:p.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"}}),e.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:i("desc-fg")},children:[k.length," ",p.unit.bu]})]}),e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[$?$.map((_,z)=>e.jsxs("div",{children:[e.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:it(p.catalog.volume,{n:_.volume})}),_.books.map((E,T)=>e.jsx(or,{book:E,onNavigate:r,renderLink:s,showVolumes:E.volumes.length>1},`${_.volume}-${T}`))]},`${_.volume}-${z}`)):k.map((_,z)=>e.jsx(or,{book:_,onNavigate:r,renderLink:s,showVolumes:!0},z)),k.length===0&&e.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:p.catalog.noMatch})]})]}):null},mp="guji_markdown";function ji(t){const n=t==null?void 0:t.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 gp=/^□\{guess=([^\s{}]+)\}/;function hp(t,n){const o=t[n+1];return o!==void 0&&!/[A-Za-z/!?>\s]/.test(o)}function Hs(t,n){let o=0;for(let r=n;r<t.length;r++){const s=t[r];if(s===`
145
+ }`,Is={color:"inherit",textDecoration:"none"},Pd=({snippet:t})=>{const{convert:n}=Ne();return e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.6},children:Mi(t).map((o,r)=>o.marked?e.jsx("mark",{style:{background:i("highlight-bg"),color:i("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(o.text)},r):e.jsx(h.Fragment,{children:n(o.text)},r))})},Ad=({entry:t,selected:n,onClick:o,getConfig:r,query:s})=>{const l=ke(),{convert:a}=Ne(),p=a(t.title||t.primary_name||t.id),c=t.measure_info?a(t.measure_info):t.juan_count!=null&&t.juan_count>0?`${t.juan_count}${l.unit.juan}`:"",d=[...t.additional_titles||[],...t.attached_texts||[]],u=s&&d.length?d.find(x=>{const f=typeof x=="string"?x:x==null?void 0:x.book_title;return f==null?void 0:f.toLowerCase().includes(s.toLowerCase())}):void 0,g=i("cover-accent"),m=Ye();return e.jsxs("a",{href:m(t.id),onClick:x=>o(t,x),className:"bim-result-card",style:{...Is,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:[e.jsxs("div",{"aria-hidden":"true",style:{position:"relative",width:"92px",minHeight:"126px",flexShrink:0,borderRadius:"4px",border:`1px solid color-mix(in srgb, ${g} 50%, ${i("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${g} 14%, ${i("bg")}), color-mix(in srgb, ${g} 7%, ${i("bg")}))`,display:"flex",alignItems:"center",justifyContent:"center",padding:"0.6rem 0.3rem"},children:[e.jsx("span",{style:{position:"absolute",left:"6px",top:0,bottom:0,borderLeft:`1px dashed color-mix(in srgb, ${g} 45%, transparent)`}}),e.jsx("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",height:"108px",flexShrink:0,overflow:"hidden",fontSize:"1.05rem",fontWeight:700,lineHeight:1.25,color:g},children:Array.from(p).map((x,f)=>e.jsx("span",{children:x},f))})]}),e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"6px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:"17px",fontWeight:600,color:i("fg")},children:p}),c&&e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:c})]}),(t.dynasty||t.author)&&e.jsxs("div",{style:{fontSize:"13px",color:i("desc-fg")},children:[t.dynasty&&e.jsxs("span",{children:["〔",a(t.dynasty),"〕"]}),t.author&&e.jsx("span",{children:a(t.author)}),t.role&&t.role!=="author"&&e.jsxs("span",{children:[" ",a(t.role)]})]}),(t.era||t.edition)&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[t.era&&e.jsxs("span",{children:["〔",a(t.era),"〕"]}),t.edition&&e.jsx("span",{children:a(t.edition)})]}),u&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[l.search.alias,":",a(typeof u=="string"?u:u.book_title||"")]}),t.descriptionSnippet&&e.jsx(Pd,{snippet:t.descriptionSnippet}),e.jsxs("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"auto",paddingTop:"4px"},children:[e.jsxs("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:[e.jsx(Gt,{type:t.type,size:8})," ",r(t.type).name]}),t.has_text&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:l.misc.textResource}),t.has_image&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:l.misc.imageResource})]})]})]})},er=({entry:t,selected:n,onClick:o,getConfig:r,query:s,onRemove:l})=>{const a=ke(),{convert:p}=Ne(),c=[...t.additional_titles||[],...t.attached_texts||[]],d=s&&c.length?c.find(g=>{const m=typeof g=="string"?g:g==null?void 0:g.book_title;return m==null?void 0:m.toLowerCase().includes(s.toLowerCase())}):void 0,u=Ye();return e.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:[e.jsxs("a",{href:u(t.id),onClick:g=>o(t,g),className:"bim-result-card",style:{...Is,flex:1,minWidth:0,display:"flex",alignItems:"flex-start",gap:"10px",padding:l?"10px 0 10px 12px":"10px 12px",borderRadius:"6px",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",marginTop:"2px"},children:[e.jsx(Gt,{type:t.type,size:12}),e.jsx("span",{style:{fontSize:"9px",color:i("desc-fg"),lineHeight:1},children:r(t.type).name})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg")},children:p(t.title||t.primary_name||t.id)}),e.jsxs("span",{style:{display:"flex",gap:"2px",fontSize:"12px",opacity:.7},children:[t.has_text&&e.jsx("span",{children:a.misc.textResource}),t.has_image&&e.jsx("span",{children:a.misc.imageResource})]}),(t.era||t.edition)&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[t.era&&e.jsxs(e.Fragment,{children:["〔",p(t.era),"〕"]}),t.edition&&p(t.edition)]}),t.measure_info?e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:p(t.measure_info)}):t.juan_count!=null&&t.juan_count>0?e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[t.juan_count,a.unit.juan]}):null]}),(t.dynasty||t.author)&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px"},children:[t.dynasty&&e.jsxs("span",{children:["〔",p(t.dynasty),"〕"]}),t.author&&e.jsx("span",{children:p(t.author)}),t.role&&t.role!=="author"&&e.jsxs("span",{children:[" ",p(t.role)]}),t.type==="entity"&&(t.birth_year!=null||t.death_year!=null)&&e.jsxs("span",{style:{marginLeft:t.dynasty?"4px":0},children:[t.birth_year??"?","—",t.death_year??"?"]})]}),d&&e.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:[a.search.alias,":",p(d)]})]}),!l&&e.jsx("span",{"aria-hidden":"true",style:{opacity:.4,marginTop:"2px"},children:"→"})]}),l&&e.jsx("button",{type:"button",onClick:()=>l(t.id),title:a.search.removeFromRecent,"aria-label":a.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:"×"})]})},Bd=({id:t,onRemove:n,t:o})=>e.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:[e.jsx("span",{style:{fontSize:"16px"},children:"❓"}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:"13px",color:i("fg"),fontFamily:"monospace"},children:t}),e.jsx("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:o.search.itemNotFound})]}),e.jsx("button",{onClick:()=>n(t),title:o.search.removeFromRecent,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"2px 4px",lineHeight:1},children:"×"})]});function Md(t){var n;return!t.dynasty&&!t.birth_year&&!t.death_year&&(!t.alt_names||t.alt_names.length===0)&&!((n=t.description)!=null&&n.text)}function Wd({data:t}){const{convert:n}=Ne(),{dynasty:o,birth_year:r,death_year:s}=t,l=[];return o&&l.push(`〔${n(o)}〕`),r!==void 0&&s!==void 0?l.push(`${r}—${s}`):r!==void 0?l.push(`${r}—?`):s!==void 0&&l.push(`?—${s}`),l.length===0?null:e.jsx("span",{style:{fontSize:"14px",color:i("desc-fg"),marginLeft:"8px",fontWeight:"normal"},children:l.join(" ")})}function Hd({alt_names:t}){const{convert:n}=Ne(),o=new Map;for(const l of t){const a=l.type||"別名";o.has(a)||o.set(a,[]),o.get(a).push(l.name)}const r=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...o.keys()].sort((l,a)=>{const p=r.indexOf(l),c=r.indexOf(a);return p===-1&&c===-1?0:p===-1?1:c===-1?-1:p-c});return e.jsx("div",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(l=>{const a=o.get(l);return e.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[e.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px",minWidth:"36px",paddingTop:"2px"},children:n(l)}),e.jsx("span",{children:a.map((p,c)=>e.jsxs("span",{children:[c>0&&e.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),n(p)]},c))})]},l)})})}function Od({data:t}){const n=ke(),o=t.external_ids;if(!o)return null;const r=[];return o.cbdb_id&&r.push(e.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:e.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:r})}function Fd({works:t,transport:n,onNavigate:o,renderLink:r}){const s=ke(),{convert:l}=Ne(),a=Ye(),[p,c]=h.useState(new Map);h.useEffect(()=>{if(!n)return;let m=!1;const x=t.map(k=>k.work_id);return(async()=>{const k=new Map;if(n.getEntriesByIds)try{const j=await n.getEntriesByIds(x);let S=!0;for(let v=0;v<x.length;v++){const $=j[v];$!=null&&$.title?k.set(x[v],$.title):$!=null&&$.primary_name?k.set(x[v],$.primary_name):S=!1}if(S)return k}catch{}const b=[...x],w=8,y=new Array(w).fill(0).map(async()=>{for(;b.length;){const j=b.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(y),k})().then(k=>{m||c(k)}),()=>{m=!0}},[t,n]);const d=new Map;for(const m of t){const x=m.role||"";d.has(x)||d.set(x,[]),d.get(x).push(m)}const u=["撰","編","注","輯","集","校","評","譯","述","作",""],g=[...d.keys()].sort((m,x)=>{const f=u.indexOf(m),k=u.indexOf(x);return f===-1&&k===-1?m.localeCompare(x):f===-1?1:k===-1?-1:f-k});return e.jsxs("div",{style:{marginTop:"12px"},children:[e.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," ",e.jsxs("span",{style:{color:i("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",t.length,")"]})]}),g.map(m=>{const x=d.get(m);return e.jsxs("div",{style:{marginBottom:"8px"},children:[m&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"2px"},children:[l(m)," ",e.jsxs("span",{style:{color:i("desc-fg")},children:["(",x.length,")"]})]}),e.jsx("ul",{style:{margin:0,paddingLeft:m?"16px":"0",listStyle:m?"disc":"none",fontSize:"14px",lineHeight:1.8},children:x.map((f,k)=>{const b=l(p.get(f.work_id)||f.work_id);return r?e.jsx("li",{children:r(f.work_id,b)},k):o?e.jsx("li",{children:e.jsx("a",{href:a(f.work_id),onClick:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),o(f.work_id))},style:{color:i("link-fg"),textDecoration:"underline",cursor:"pointer"},children:b})},k):e.jsx("li",{children:b},k)})})]},m)})]})}const Rs=({data:t,transport:n,onNavigate:o,renderLink:r,headerExtra:s,hideHeader:l})=>{var g;const a=ke(),{convert:p}=Ne();let c=!1;try{c=be.extractStatus(t.id)==="draft"}catch{}const d=Md(t),u=t.subtype&&t.subtype in a.common.entitySubtype?a.common.entitySubtype[t.subtype]:p(t.subtype);return e.jsxs("div",{children:[!l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"4px"},children:[e.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:600,margin:0,lineHeight:1.3,color:i("fg")},children:[p(t.primary_name),e.jsx(Wd,{data:t})]}),s]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:i("desc-fg"),marginBottom:"8px"},children:[e.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:a.indexType.entity}),u&&t.subtype!=="people"&&e.jsx("span",{children:u}),c&&e.jsx("span",{style:{padding:"1px 6px",background:i("warn-bg"),border:`1px solid ${i("warn-border")}`,borderRadius:"2px",color:i("warn-fg")},children:a.status.draft}),e.jsx("span",{style:{fontFamily:"monospace",opacity:.6},children:t.id})]})]}),d&&e.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:a.common.entityPlaceholderNote}),t.alt_names&&t.alt_names.length>0&&e.jsx(Hd,{alt_names:t.alt_names}),e.jsx(Od,{data:t}),((g=t.description)==null?void 0:g.text)&&e.jsx("p",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:p(t.description.text)}),t.works&&t.works.length>0&&e.jsx(Fd,{works:t.works,transport:n,onNavigate:o,renderLink:r})]})},Dd=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function Ud(t){const n=t.search(Dd);return n<0?[t,""]:[t.slice(0,n),t.slice(n)]}const Es={p:({children:t})=>e.jsx("p",{style:{margin:"0 0 0.5em"},children:t}),ul:({children:t})=>e.jsx("ul",{style:{margin:"0 0 0.5em",paddingLeft:"1.4em"},children:t}),ol:({children:t})=>e.jsx("ol",{style:{margin:"0 0 0.5em",paddingLeft:"1.6em"},children:t}),li:({children:t})=>e.jsx("li",{style:{marginBottom:"2px"},children:t}),a:({href:t,children:n})=>{let o=t,r="",s=n;if(t&&typeof n=="string"&&(n===t||n===Vd(t))){const[l,a]=Ud(n);a&&(o=encodeURI(l),s=l,r=a)}return e.jsxs(e.Fragment,{children:[e.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:t})=>e.jsx("code",{style:{background:i("bg-subtle"),padding:"1px 4px",borderRadius:3,fontSize:"0.92em"},children:t})};function Vd(t){try{return decodeURI(t)}catch{return t}}const Gd={...Es,strong:({children:t})=>e.jsx(e.Fragment,{children:t})},ft=({text:t,plainStrong:n,style:o,className:r})=>{const{convert:s}=Ne(),l=n?Gd:Es;return e.jsx("div",{className:r,style:o,children:e.jsx(bc,{remarkPlugins:[yc],components:l,children:s(t)})})},Yd=["〇","一","二","三","四","五","六","七","八","九"],tr=["","十","百","千"];function Ls(t){if(t<=0)return"";if(t>=1e4)return String(t);const n=String(t),o=n.length;let r="",s=!1;for(let l=0;l<o;l++){const a=parseInt(n[l]),p=o-1-l;a===0?s=!0:(s&&r&&(r+="〇"),s=!1,a===1&&p===1&&l===0?r+=tr[p]:r+=Yd[a]+tr[p])}return r}function Ps(t){return{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:t,border:`1px solid color-mix(in srgb, ${t} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${t} 3%, transparent)`}}const Kd={book:i("type-book"),work:i("type-work"),collection:i("type-collection"),entity:i("type-entity")};function qd({type:t}){const n=ke();return e.jsx("span",{style:Ps(Kd[t]),children:n.indexType[t]})}function Zd({isDraft:t}){const n=ke(),o=i(t?"status-draft":"status-official");return e.jsx("span",{style:Ps(o),children:t?n.status.draft:n.status.official})}function Jd({id:t}){const n=ke(),[o,r]=h.useState(!1),s=()=>{navigator.clipboard.writeText(t).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})};return e.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:[e.jsx("span",{children:n.label.id}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:i("fg")},children:t}),e.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:l=>l.currentTarget.style.opacity="1",onMouseLeave:l=>l.currentTarget.style.opacity=o?"1":"0.5",children:o?"✓":"⧉"})]})}function rt({children:t,extra:n}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"20px",marginBottom:"8px"},children:[e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:i("desc-fg"),letterSpacing:"1px"},children:t}),e.jsx("span",{style:{flex:1}}),n]})}function pt({label:t,children:n}){return e.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[e.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:t}),e.jsx("span",{style:{color:i("fg")},children:n})]})}function As({authors:t,type:n,onNavigate:o,renderLink:r}){const{convert:s}=Ne();return e.jsx("span",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.6},children:t.map((l,a)=>{const p=s(l.name),c=l.entity_id?e.jsx(ct,{id:l.entity_id,label:p,onNavigate:o,renderLink:r}):e.jsx("span",{style:{fontWeight:500},children:p});return e.jsxs("span",{children:[a>0&&e.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),l.dynasty&&e.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:["〔",s(l.dynasty),"〕"]}),c,l.role&&e.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px",marginLeft:"2px"},children:[" ",s(l.role)]})]},a)})})}function ct({id:t,label:n,onNavigate:o,renderLink:r}){const s=Ye();return r?e.jsx(e.Fragment,{children:r(t,n)}):o?e.jsx("a",{href:s(t),onClick:l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),o(t))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`,paddingBottom:"1px"},onMouseEnter:l=>l.currentTarget.style.borderBottomStyle="solid",onMouseLeave:l=>l.currentTarget.style.borderBottomStyle="dashed",children:n||t}):e.jsx("span",{children:n||t})}function Xd({id:t,title:n,edition:o,type:r,isDraft:s,authors:l,volumeText:a,meta:p,headerExtra:c,onNavigate:d,renderLink:u}){return e.jsxs("div",{style:{marginBottom:"4px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[e.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&&e.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:o}),a&&e.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:a})]}),c&&e.jsx("div",{style:{flexShrink:0,paddingTop:"2px"},children:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"4px"},children:[e.jsx(qd,{type:r}),e.jsx(Zd,{isDraft:s}),e.jsx(Jd,{id:t})]}),((l==null?void 0:l.length)||p.length>0)&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"12px",marginTop:"6px"},children:[l&&l.length>0&&e.jsx(As,{authors:l,type:r,onNavigate:d,renderLink:u}),p]})]})}function Bs({items:t,label:n,showMeta:o,onNavigate:r,renderLink:s}){const l=ke(),{convert:a}=Ne();if(!t.length)return null;const[p,c]=h.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:n}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.map((d,u)=>{const g=p===u;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...g?{boxShadow:i("shadow-card")}:{}},children:[e.jsxs("div",{onClick:()=>c(g?null:u),style:{padding:"8px 12px",background:i("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[e.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.15s",transform:g?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:a(d.source)}),!g&&o&&d.title_info&&e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a(d.title_info)}),d.source_bid&&e.jsx("span",{onClick:m=>m.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:e.jsx(ct,{id:d.source_bid,label:l.action.view,onNavigate:r,renderLink:s})})]}),g&&e.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${i("widget-border")}`},children:[o&&(d.title_info||d.author_info||d.edition)&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[d.title_info&&e.jsx(pt,{label:l.label.titleInfo,children:a(d.title_info)}),d.author_info&&e.jsx(pt,{label:l.label.authorInfo,children:a(d.author_info)}),d.edition&&e.jsx(pt,{label:l.label.edition,children:a(d.edition)})]}),d.summary&&e.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:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.summary}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:a(d.summary)})]}),d.comment&&e.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.comment}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:a(d.comment)})]}),d.additional_comment&&e.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.additionalComment}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:a(d.additional_comment)})]})]})]},u)})})]})}function Qd({items:t,onNavigate:n,renderLink:o}){const r=ke();return e.jsx(Bs,{items:t,label:r.section.indexed,showMeta:!0,onNavigate:n,renderLink:o})}function Ms({items:t,onNavigate:n,renderLink:o}){const r=ke();return e.jsx(Bs,{items:t,label:r.section.emendated,onNavigate:n,renderLink:o})}function Ws({label:t,items:n}){const{convert:o}=Ne();return n.length?e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:t}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:n.map((r,s)=>{const l=typeof r=="string"?r:r.book_title;return e.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(l)},s)})})]}):null}function ep({items:t}){const n=ke();return e.jsx(Ws,{label:n.section.aliases,items:t})}function tp({items:t}){const n=ke();return e.jsx(Ws,{label:n.section.attachedTexts,items:t})}function np({items:t}){const n=ke(),{convert:o}=Ne();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:n.section.appendix}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:t.map((r,s)=>e.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&&e.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:[r.n_juan,n.unit.juan]})]},s))})]}):null}function ip({items:t}){const n=ke(),{convert:o}=Ne();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:n.section.locationHistory}),e.jsxs("div",{style:{position:"relative",paddingLeft:"18px"},children:[e.jsx("div",{style:{position:"absolute",left:"4px",top:"6px",bottom:"6px",width:"1px",background:i("widget-border")}}),t.map((r,s)=>e.jsxs("div",{style:{position:"relative",marginBottom:"10px"},children:[e.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")}`}}),e.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:i("fg")},children:o(r.name)}),r.description&&e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),marginLeft:"8px"},children:o(r.description)})]},s))]})]}):null}function op({items:t}){const n=ke(),{convert:o}=Ne();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:n.section.historyOverview}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:t.map((r,s)=>e.jsxs("div",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[e.jsx("span",{style:{position:"absolute",left:0,top:0,color:i("desc-fg")},children:"·"}),o(r)]},s))})]}):null}function nr({title:t,ids:n,transport:o,onNavigate:r,renderLink:s}){const{convert:l}=Ne(),[a,p]=h.useState([]);return h.useEffect(()=>{if(!n.length){p([]);return}if(!o){p(n.map(d=>({id:d})));return}let c=!1;return Promise.all(n.map(d=>o.getItem(d).then(u=>({id:d,title:u?u.title:void 0,edition:u?u.edition:void 0,type:u?u.type:void 0})).catch(()=>({id:d})))).then(d=>{c||p(d)}),()=>{c=!0}},[n,o]),n.length?e.jsxs(e.Fragment,{children:[e.jsxs(rt,{children:[t,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",n.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:(a.length?a:n.map(c=>({id:c}))).map(c=>{const d=c.edition?`${l(c.title)||c.id}(${l(c.edition)})`:l(c.title)||void 0;return e.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:e.jsx(ct,{id:c.id,label:d,onNavigate:r,renderLink:s})},c.id)})})]}):null}function oi({book:t,onNavigate:n,renderLink:o}){const r=ke(),{convert:s}=Ne(),[l,a]=h.useState(!1),p=t.resources&&t.resources.length>0,c=t.edition?s(t.edition):s(t.title)||void 0;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:i("input-bg")},children:[e.jsxs("div",{style:{padding:"6px 12px",borderBottom:p&&!l?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:e.jsx(ct,{id:t.id,label:c,onNavigate:n,renderLink:o})}),p&&e.jsx("span",{onClick:()=>a(d=>!d),style:{cursor:"pointer",fontSize:"10px",color:i("desc-fg"),userSelect:"none",transition:"transform 0.15s",transform:l?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:l?r.action.expand:r.action.collapse,children:"▼"})]}),p&&!l&&e.jsx("div",{style:{padding:"10px 14px"},children:e.jsx(Ui,{items:t.resources,resourceGroups:t.resource_groups,groupByType:!0,onNavigate:n,renderLink:o})})]})}function rp({ids:t,workData:n,transport:o,onNavigate:r,renderLink:s,footer:l}){const a=ke(),{convert:p}=Ne(),[c,d]=h.useState([]);if(h.useEffect(()=>{if(!t.length){d([]);return}if(!o){d(t.map(k=>({id:k})));return}let f=!1;return Promise.all(t.map(k=>o.getItem(k).then(b=>({id:k,title:b?b.title:void 0,edition:b?b.edition:void 0,resources:b?b.resources:void 0,resource_groups:b?b.resource_groups:void 0})).catch(()=>({id:k})))).then(k=>{f||d(k)}),()=>{f=!0}},[t,o]),!t.length)return null;const u=c.length?c:t.map(f=>({id:f})),g=new Map(u.map(f=>[f.id,f])),m=n==null?void 0:n.version_graph,x=sp(t,m,a.common.otherVersions);return e.jsxs(e.Fragment,{children:[e.jsxs(rt,{children:[a.section.relatedVersions,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",t.length,")"]})]}),l,x.useGrouping?e.jsxs(e.Fragment,{children:[x.coreIds.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:x.coreIds.map(f=>{const k=g.get(f);return k?e.jsx(oi,{book:k,onNavigate:r,renderLink:s},f):null})}),x.groupedIds.map(f=>e.jsxs("details",{style:{marginTop:12,border:`1px solid ${i("widget-border")}`,borderRadius:6,background:i("bg-subtle")},children:[e.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:i("fg"),userSelect:"none"},children:[p(f.label),e.jsxs("span",{style:{marginLeft:6,fontSize:12,color:i("desc-fg"),fontWeight:400},children:["(",f.ids.length,")"]}),f.description&&e.jsx("span",{style:{marginLeft:8,fontSize:12,color:i("desc-fg"),fontWeight:400},children:p(f.description)})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"0 12px 12px"},children:f.ids.map(k=>{const b=g.get(k);return b?e.jsx(oi,{book:b,onNavigate:r,renderLink:s},k):null})})]},f.id))]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:u.map(f=>e.jsx(oi,{book:f,onNavigate:r,renderLink:s},f.id))})]})}function sp(t,n,o){var w,y;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:t,groupedIds:[]};const r=(w=n.collections)==null?void 0:w[n.default_collection],s=(r==null?void 0:r.groups)??[],l=(r==null?void 0:r.book_ids)??[],a=s.length>0||l.length>0,p=!a&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!a&&p.length===0)return{useGrouping:!1,coreIds:t,groupedIds:[]};const c=new Set(s),d=new Set([...l,...p]),u=j=>{if(d.has(j))return!0;const S=n.node_groups[j];return S!=null&&c.has(S)},g=[],m=new Map,x=[];for(const j of t)if(!((y=n.excluded_books)!=null&&y.includes(j)))if(u(j))g.push(j);else{const S=n.node_groups[j];S?(m.has(S)||m.set(S,[]),m.get(S).push(j)):x.push(j)}if(x.length+[...m.values()].reduce((j,S)=>j+S.length,0)<3)return{useGrouping:!1,coreIds:t,groupedIds:[]};const k=new Map((n.groups??[]).map(j=>[j.id,j])),b=[...m.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 x.length>0&&b.push({id:"__other__",label:o,description:void 0,ids:x}),{useGrouping:!0,coreIds:g,groupedIds:b}}function lp({workData:t,onNavigate:n,renderLink:o}){var a,p,c,d;const r=ke(),{convert:s}=Ne(),l=!!((a=t.description)!=null&&a.text)||!!t.parent_work;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:i("input-bg"),marginTop:"4px"},children:[e.jsxs("div",{style:{padding:"6px 14px",borderBottom:l?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`},children:[e.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:e.jsx(ct,{id:t.id,label:s(t.title),onNavigate:n,renderLink:o})}),t.measure_info?e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:s(t.measure_info)}):((p=t.juan_count)==null?void 0:p.number)!=null&&t.juan_count.number>0?e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[Ls(t.juan_count.number),r.unit.juan]}):null,t.authors&&t.authors.length>0&&e.jsx("span",{style:{fontSize:"13px"},children:e.jsx(As,{authors:t.authors,type:"work",onNavigate:n,renderLink:o})})]}),l&&e.jsxs("div",{style:{padding:"8px 14px"},children:[((c=t.description)==null?void 0:c.text)&&e.jsx(ft,{text:t.description.text,style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,textAlign:"justify"}}),t.parent_work&&e.jsx("div",{style:{marginTop:(d=t.description)!=null&&d.text?"8px":0,fontSize:"13px"},children:e.jsx(pt,{label:r.label.parentWork,children:e.jsx(ct,{id:t.parent_work.id,label:s(t.parent_work.title),onNavigate:n,renderLink:o})})})]})]})}function ap({items:t,onNavigate:n,renderLink:o}){const r=ke(),{convert:s}=Ne();return t.length?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"6px"},children:t.map(l=>e.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:[e.jsx("span",{style:{fontSize:"11px",color:i("type-collection")},children:r.indexType.collection}),e.jsx(ct,{id:l.id,label:s(l.title)||l.id,onNavigate:n,renderLink:o}),l.volume_index!=null&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"2px"},children:it(r.catalog.volume,{n:l.volume_index})})]},l.id))}):null}const Ki=({data:t,id:n,transport:o,onNavigate:r,renderLink:s,headerExtra:l,relatedBooksFooter:a,className:p,style:c})=>{var O,W,A,G,V,ie,ae,P;const d=ke(),{convert:u}=Ne(),[g,m]=h.useState(null),[x,f]=h.useState(!1),[k,b]=h.useState(null),[w,y]=h.useState(null),[j,S]=h.useState([]),v=t||g;if(h.useEffect(()=>{if(t||!n||!o)return;let I=!1;return f(!0),b(null),o.getItem(n).then(q=>{I||(q?m(q):b(d.misc.notFoundEntry))}).catch(q=>{I||b(q instanceof Error?q.message:d.misc.loadFailed)}).finally(()=>{I||f(!1)}),()=>{I=!0}},[t,n,o]),h.useEffect(()=>{if(!v||!o){y(null),S([]);return}let I=!1;const q=v.type==="book"||v.type==="collection"?v.work_id:void 0;if(q?o.getItem(q).then(Q=>{!I&&Q&&Q.type==="work"&&y(Q)}).catch(()=>{}):y(null),v.type==="book"){const Q=v;Q.contained_in&&Q.contained_in.length>0?Promise.all(Q.contained_in.map(oe=>{const je=typeof oe=="string"?oe:oe.id,Ie=typeof oe=="string"?void 0:oe.volume_index;return o.getItem(je).then(K=>({id:je,title:K&&K.title||je,volume_index:Ie})).catch(()=>({id:je,title:je,volume_index:Ie}))})).then(oe=>{I||S(oe)}):S([])}else S([]);return()=>{I=!0}},[v,o]),x)return e.jsx("div",{className:p,style:{...c,padding:"24px"},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((I,q)=>e.jsx("div",{style:{height:q===1?"32px":"16px",width:`${I}px`,background:i("widget-border"),borderRadius:"4px",opacity:.4}},q))})});if(k)return e.jsx("div",{className:p,style:{...c,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:k});if(!v)return null;if(v.type==="entity")return e.jsx("div",{className:p,style:c,children:e.jsx(Rs,{data:v,transport:o,onNavigate:r,renderLink:s,headerExtra:l})});const $=v.type==="book"?v:null,C=v.type==="collection"?v:null,z=v.type==="work"?v:null;let E=!1;try{E=be.extractStatus(v.id)==="draft"}catch{}let T="";v.measure_info?T=u(v.measure_info):(O=v.juan_count)!=null&&O.number?T=Ls(v.juan_count.number)+d.unit.juan:(W=v.juan_count)!=null&&W.description&&(T=u(v.juan_count.description));const _=[];return(A=v.publication_info)!=null&&A.year&&_.push(e.jsx(pt,{label:d.label.year,children:v.publication_info.year},"year")),(G=v.current_location)!=null&&G.name&&_.push(e.jsx(pt,{label:d.label.currentLocation,children:u(v.current_location.name)},"loc")),(V=v.page_count)!=null&&V.description&&_.push(e.jsx(pt,{label:d.label.pageCount,children:v.page_count.description},"page")),$!=null&&$.edition&&_.push(e.jsx(pt,{label:d.label.edition,children:u($.edition)},"ver")),z!=null&&z.parent_work&&_.push(e.jsx(pt,{label:d.label.parentWork,children:e.jsx(ct,{id:z.parent_work.id,label:u(z.parent_work.title),onNavigate:r,renderLink:s})},"pw")),z!=null&&z.parent_works&&z.parent_works.length>0&&!z.parent_work&&_.push(e.jsx(pt,{label:d.label.parentWork,children:z.parent_works.map((I,q)=>e.jsxs("span",{children:[q>0&&"、",e.jsx(ct,{id:I,onNavigate:r,renderLink:s})]},I))},"pws")),e.jsxs("div",{className:p,style:c,children:[e.jsx(Xd,{id:v.id,title:u(v.title),edition:v.edition?u(v.edition):void 0,type:v.type,isDraft:E,authors:v.authors,volumeText:T,meta:_,headerExtra:l,onNavigate:r,renderLink:s}),((ie=v.description)==null?void 0:ie.text)&&e.jsx(ft,{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&&e.jsx("div",{style:{marginTop:8,marginBottom:4},children:v.appendix.map((I,q)=>e.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:i("bg-subtle"),borderRadius:4,border:`1px solid ${i("widget-border")}`},children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:i("muted")},children:u(I.title)}),e.jsx(ft,{text:I.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:i("fg")}})]},q))}),j.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:d.section.containedIn}),e.jsx(ap,{items:j,onNavigate:r,renderLink:s})]}),w&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:d.section.belongsToWork}),e.jsx(lp,{workData:w,onNavigate:r,renderLink:s})]}),v.additional_works&&v.additional_works.length>0&&e.jsx(np,{items:v.additional_works}),v.additional_titles&&v.additional_titles.length>0&&e.jsx(ep,{items:v.additional_titles}),v.attached_texts&&v.attached_texts.length>0&&e.jsx(tp,{items:v.attached_texts}),v.indexed_by&&v.indexed_by.length>0&&e.jsx(Qd,{items:v.indexed_by,onNavigate:r,renderLink:s}),v.emendated_by&&v.emendated_by.length>0&&e.jsx(Ms,{items:v.emendated_by,onNavigate:r,renderLink:s}),v.resources&&v.resources.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:d.section.resources}),e.jsx(Ui,{items:v.resources,resourceGroups:v.resource_groups,groupByType:!0,onNavigate:r,renderLink:s})]}),($==null?void 0:$.location_history)&&$.location_history.length>0&&e.jsx(ip,{items:$.location_history}),(C==null?void 0:C.history)&&C.history.length>0&&e.jsx(op,{items:C.history}),($==null?void 0:$.related_books)&&$.related_books.length>0&&e.jsx(nr,{title:d.section.relatedVersions,ids:$.related_books,transport:o,onNavigate:r,renderLink:s}),(C==null?void 0:C.books)&&C.books.length>0&&e.jsx(nr,{title:d.section.containedBooks,ids:C.books,transport:o,onNavigate:r,renderLink:s}),(C==null?void 0:C.contained_works)&&C.contained_works.length>0&&e.jsxs("div",{children:[e.jsxs(rt,{children:[d.section.containedWorks,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",C.contained_works.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:C.contained_works.map(I=>e.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:e.jsx(ct,{id:I.id,label:u(I.title),onNavigate:r,renderLink:s})},I.id))})]}),(((ae=z==null?void 0:z.books)==null?void 0:ae.length)||0)+(((P=z==null?void 0:z.collections)==null?void 0:P.length)||0)>0&&e.jsx(rp,{ids:[...(z==null?void 0:z.books)||[],...(z==null?void 0:z.collections)||[]],workData:z??void 0,transport:o,onNavigate:r,renderLink:s,footer:a}),(z==null?void 0:z.related_works)&&z.related_works.length>0&&(()=>{const I=[],q=z.related_works.filter(me=>me.relation==="part_of"),Q=z.related_works.filter(me=>me.relation==="has_part"),oe=z.related_works.filter(me=>me.relation==="has_adaptation"),je=z.related_works.filter(me=>me.relation==="text_carried_by"),Ie=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),K=z.related_works.filter(me=>!me.relation||!Ie.has(me.relation));return q.length>0&&I.push({label:d.section.belongsToWork,items:q}),Q.length>0&&I.push({label:d.section.containedWorks,items:Q}),oe.length>0&&I.push({label:d.section.adaptations,items:oe}),je.length>0&&I.push({label:d.section.derivativeWorks,items:je}),K.length>0&&I.push({label:d.section.relatedWorks,items:K}),I.map(me=>e.jsxs("div",{children:[e.jsxs(rt,{children:[me.label,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",me.items.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:me.items.map(M=>e.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:e.jsx(ct,{id:M.id,label:u(M.title),onNavigate:r,renderLink:s})},M.id))})]},me.label))})()]})};function cp({data:t}){const n=ke(),{convert:o}=Ne(),{stats:r}=t,s=r.processed_volumes??r.total_found_volumes,l=s!=null&&t.total_volumes>0?Math.round(s/t.total_volumes*100):null;return e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:o(t.title)}),t.resource_name&&e.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"6px"},children:o(t.resource_name)}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:i("desc-fg")},children:[e.jsxs("span",{children:[n.catalog.totalVolumes," ",e.jsx("strong",{style:{color:i("fg")},children:t.total_volumes})," ",n.unit.volume]}),l!=null&&e.jsxs("span",{children:[n.catalog.processed," ",e.jsx("strong",{style:{color:i("fg")},children:s})," ",n.unit.volume," (",l,"%)"]}),e.jsxs("span",{children:[n.catalog.contains," ",e.jsx("strong",{style:{color:i("fg")},children:r.total_books})," ",n.unit.bu]}),r.matched_works!=null&&r.matched_works>0&&e.jsxs("span",{children:[n.catalog.matched," ",e.jsx("strong",{style:{color:i("fg")},children:r.matched_works})," ",n.unit.bu]}),r.unmatched_works!=null&&r.unmatched_works>0&&e.jsxs("span",{children:[n.catalog.unmatched," ",e.jsx("strong",{style:{color:i("missing-fg")},children:r.unmatched_works})," ",n.unit.bu]})]}),t.source&&e.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:i("desc-fg")},children:[n.catalog.source," ",t.source]})]})}function dp({sections:t,activeSection:n,onSelect:o}){const r=ke();return e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[e.jsx("button",{onClick:()=>o(null),style:ir(n===null),children:r.catalog.all}),t.map(s=>e.jsxs("button",{onClick:()=>o(s.name),style:ir(n===s.name),children:[s.name,s.volume_range&&e.jsxs("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"4px"},children:[s.volume_range[0],"–",s.volume_range[1]]})]},s.name))]})}function ir(t){return{padding:"4px 12px",border:t?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:t?`color-mix(in srgb, ${i("primary")} 8%, transparent)`:"transparent",color:i(t?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:t?600:400}}function pp({id:t,label:n,onNavigate:o,renderLink:r}){const s=Ye();return r?e.jsx(e.Fragment,{children:r(t,n)}):o?e.jsx("a",{href:s(t),onClick:l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),o(t))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`,paddingBottom:"1px",fontSize:"12px"},onMouseEnter:l=>l.currentTarget.style.borderBottomStyle="solid",onMouseLeave:l=>l.currentTarget.style.borderBottomStyle="dashed",children:n||t}):e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:n||t})}function up(t,n){if(t.length===0)return"";if(t.length===1)return`${t[0]}`;const o=t[0],r=t[t.length-1];return r-o+1===t.length?`${o}–${r}`:t.length<=3?t.join(", "):`${o}–${r} (${t.length}${n})`}function or({book:t,onNavigate:n,renderLink:o,showVolumes:r}){const s=ke(),{convert:l}=Ne(),a=t.book_id||t.work_id,p=r&&t.volumes.length>0?up(t.volumes,s.unit.volume):null,c=t.missing_volumes&&t.missing_volumes.length>0;return e.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&&e.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:i("desc-fg"),textAlign:"right"},children:p}),e.jsxs("span",{style:{flex:1,fontWeight:500,color:i("fg")},children:[l(t.title),t.sub_items&&t.sub_items.length>0&&e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400,marginLeft:"6px"},children:["(",t.sub_items.map(d=>l(d)).join("、"),")"]}),t.edition&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),fontWeight:400,marginLeft:"8px"},children:l(t.edition)})]}),t.expected_volumes!=null&&e.jsxs("span",{style:{fontSize:"11px",color:i(c?"missing-fg":"desc-fg"),flexShrink:0},children:[t.found_volumes??0,"/",t.expected_volumes,s.unit.volume]}),a&&e.jsx(pp,{id:a,label:t.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:o}),!a&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const qi=({data:t,collectionId:n,transport:o,onNavigate:r,renderLink:s,className:l,style:a})=>{const p=ke(),[c,d]=h.useState(null),[u,g]=h.useState(!1),[m,x]=h.useState(null),[f,k]=h.useState(null),[b,w]=h.useState(""),y=t||c;h.useEffect(()=>{if(t||!n||!(o!=null&&o.getCollectionCatalog))return;let C=!1;return g(!0),x(null),o.getCollectionCatalog(n).then(z=>{C||(z?d(z):x(p.catalog.notFound))}).catch(z=>{C||x(z instanceof Error?z.message:p.catalog.loadFailed)}).finally(()=>{C||g(!1)}),()=>{C=!0}},[t,n,o,p]);const j=(y==null?void 0:y.sections)&&y.sections.length>0,S=h.useMemo(()=>{if(!y)return!1;if(y.volume_index&&Object.keys(y.volume_index).length>0)return!0;const C=y.books.map(E=>E.volumes[0]).filter(E=>E!=null);return new Set(C).size<C.length},[y]),v=h.useMemo(()=>{if(!y)return[];let C=y.books;if(f&&(C=C.filter(z=>z.section===f)),b.trim()){const z=b.trim().toLowerCase();C=C.filter(E=>E.title.toLowerCase().includes(z)||E.sub_items&&E.sub_items.some(T=>T.toLowerCase().includes(z))||E.edition&&E.edition.toLowerCase().includes(z))}return C},[y,f,b]),$=h.useMemo(()=>{if(!S)return null;const C=[],z=new Map;for(const T of v){if(!T.volumes||T.volumes.length===0)continue;const _=T.volumes[0];z.has(_)||z.set(_,[]),z.get(_).push(T)}const E=[...z.keys()].sort((T,_)=>T-_);for(const T of E)C.push({volume:T,books:z.get(T)});return C},[v,S]);return u?e.jsx("div",{className:l,style:{...a,padding:"24px"},children:e.jsx("div",{style:{color:i("desc-fg"),fontSize:"13px"},children:p.catalog.loading})}):m?e.jsx("div",{className:l,style:{...a,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:m}):y?e.jsxs("div",{className:l,style:a,children:[e.jsx(cp,{data:y}),j&&e.jsx(dp,{sections:y.sections,activeSection:f,onSelect:k}),e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("input",{type:"text",placeholder:p.search.searchBookName,value:b,onChange:C=>w(C.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"}}),e.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:i("desc-fg")},children:[v.length," ",p.unit.bu]})]}),e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[$?$.map((C,z)=>e.jsxs("div",{children:[e.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:it(p.catalog.volume,{n:C.volume})}),C.books.map((E,T)=>e.jsx(or,{book:E,onNavigate:r,renderLink:s,showVolumes:E.volumes.length>1},`${C.volume}-${T}`))]},`${C.volume}-${z}`)):v.map((C,z)=>e.jsx(or,{book:C,onNavigate:r,renderLink:s,showVolumes:!0},z)),v.length===0&&e.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:p.catalog.noMatch})]})]}):null},mp="guji_markdown";function ji(t){const n=t==null?void 0:t.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 gp=/^□\{guess=([^\s{}]+)\}/;function hp(t,n){const o=t[n+1];return o!==void 0&&!/[A-Za-z/!?>\s]/.test(o)}function Hs(t,n){let o=0;for(let r=n;r<t.length;r++){const s=t[r];if(s===`
146
146
  `)return-1;if(s==="\\"){r++;continue}if(s==="[")o++;else if(s==="]"&&(o--,o===0))return r}return-1}function xp(t){return t.replace(/\\([\\[\]<>|{}])/g,"$1")}function fp(t,n){const o=t[n];if(o==="["&&t[n+1]==="["){const r=t.indexOf("]]",n+2);return r>=0&&t.slice(n+2,r).indexOf(`
147
147
  `)<0?{node:{type:"qw",label:t.slice(n+2,r)},end:r+2}:null}if(o===":"&&t.startsWith(":zi[",n)){const r=Hs(t,n+3);return r>n+4?{node:{type:"zi",label:xp(t.slice(n+4,r))},end:r+1}:null}if(o==="□"&&t[n+1]==="{"){const r=gp.exec(t.slice(n,n+64));if(r)return{node:{type:"qz",guess:r[1]},end:n+r[0].length}}return null}function Os(t,n,o,r){const s=[];let l="";const a=()=>{if(!l)return;const p=r?l.replace(/\\?\|/g,""):l;p&&s.push({type:"text",text:p}),l=""};for(;n<t.length;){const p=t[n];if(o!==null){if(p===o)return a(),{nodes:s,end:n};if(p===`
148
- `)return null}const c=fp(t,n);if(c){a(),s.push(c.node),n=c.end;continue}let d=null;if(p==="⟨"?d="⟩":p==="<"&&hp(t,n)&&(d=">"),d){const u=Os(t,n+1,d,!0);if(u){a(),s.push({type:"jz",children:u.nodes}),n=u.end+1;continue}}l+=p,n++}return o!==null?null:(a(),{nodes:s,end:n})}function Fs(t){return Os(t,0,null,!1).nodes}function bp(t){return/[<⟨□]|\[\[|:zi\[/.test(t)}function Ds(t){return t.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${Ds(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const Us="guji-table-v1";function Vs(t){return!!t&&t.table_notation===Us}const yp=/^:::table(?:\{[^}]*\})?[ \t]*$/,jp=/^:::[ \t]*$/;function Gs(t){const n=[];let o="";for(let r=0;r<t.length;r++){const s=t[r];if(s===":"&&t.startsWith(":zi[",r)){const a=Hs(t,r+3);if(a>r+4){o+=t.slice(r,a+1),r=a;continue}}let l=null;if(s==="⟨")l="⟩";else if(s==="<"){const a=t[r+1];a!==void 0&&!/[A-Za-z/!?>\s]/.test(a)&&(l=">")}if(l){const a=t.indexOf(l,r+1);if(a>0){o+=t.slice(r,a+1),r=a;continue}}s==="|"?(n.push(o),o=""):o+=s}return n.push(o),n.map(r=>r.trim())}const vp=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function kp(t){if(t==="^")return{cont:!0};const n=vp.exec(t),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,l=o==="_";return{cont:!1,cell:{text:l?"":o,empty:l,colspan:r,rowspan:s}}}function Ys(t,n=1){const o=[],r=[],s=[];let l=[];t.forEach((p,c)=>{const d=c+n+1;let u=p.trim();if(!u)return;let g=!1;u.startsWith("!")&&(g=!0,u=u.slice(1));const m=Gs(u).map(kp),h=l.map(w=>w>0),f=l.map(w=>w>0?w-1:0),v=[];let y=0;for(const w of m){if(w.cont){h[y]||o.push(`第 ${d} 行第 ${y+1} 列:续格 ^ 上方没有跨行格`),y+=1;continue}const{cell:b}=w;for(let j=y;j<y+b.colspan;j++)if(h[j]){o.push(`第 ${d} 行第 ${j+1} 列:此处被上方跨行格占住,应写 ^`);break}if(b.rowspan>1)for(let j=y;j<y+b.colspan;j++)f[j]=b.rowspan-1;v.push(b),y+=b.colspan}for(let w=y;w<h.length;w++)h[w]&&o.push(`第 ${d} 行第 ${w+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let w=0;w<f.length;w++)f[w]===void 0&&(f[w]=0);l=f,r.push({header:g,cells:v}),s.push({width:y,line:d})});const a=s.reduce((p,c)=>Math.max(p,c.width),0);for(const p of s)p.width!==a&&o.push(`第 ${p.line} 行:占 ${p.width} 列,与总列数 ${a} 不符`);return l.some(p=>p>0)&&o.push("表尾:有跨行格超出了表的最后一行"),r.length===0&&o.push("空表"),{rows:r,columns:a,warnings:o}}function Zi(t){const n=t.split(`
148
+ `)return null}const c=fp(t,n);if(c){a(),s.push(c.node),n=c.end;continue}let d=null;if(p==="⟨"?d="⟩":p==="<"&&hp(t,n)&&(d=">"),d){const u=Os(t,n+1,d,!0);if(u){a(),s.push({type:"jz",children:u.nodes}),n=u.end+1;continue}}l+=p,n++}return o!==null?null:(a(),{nodes:s,end:n})}function Fs(t){return Os(t,0,null,!1).nodes}function bp(t){return/[<⟨□]|\[\[|:zi\[/.test(t)}function Ds(t){return t.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${Ds(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const Us="guji-table-v1";function Vs(t){return!!t&&t.table_notation===Us}const yp=/^:::table(?:\{[^}]*\})?[ \t]*$/,jp=/^:::[ \t]*$/;function Gs(t){const n=[];let o="";for(let r=0;r<t.length;r++){const s=t[r];if(s===":"&&t.startsWith(":zi[",r)){const a=Hs(t,r+3);if(a>r+4){o+=t.slice(r,a+1),r=a;continue}}let l=null;if(s==="⟨")l="⟩";else if(s==="<"){const a=t[r+1];a!==void 0&&!/[A-Za-z/!?>\s]/.test(a)&&(l=">")}if(l){const a=t.indexOf(l,r+1);if(a>0){o+=t.slice(r,a+1),r=a;continue}}s==="|"?(n.push(o),o=""):o+=s}return n.push(o),n.map(r=>r.trim())}const vp=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function kp(t){if(t==="^")return{cont:!0};const n=vp.exec(t),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,l=o==="_";return{cont:!1,cell:{text:l?"":o,empty:l,colspan:r,rowspan:s}}}function Ys(t,n=1){const o=[],r=[],s=[];let l=[];t.forEach((p,c)=>{const d=c+n+1;let u=p.trim();if(!u)return;let g=!1;u.startsWith("!")&&(g=!0,u=u.slice(1));const m=Gs(u).map(kp),x=l.map(w=>w>0),f=l.map(w=>w>0?w-1:0),k=[];let b=0;for(const w of m){if(w.cont){x[b]||o.push(`第 ${d} 行第 ${b+1} 列:续格 ^ 上方没有跨行格`),b+=1;continue}const{cell:y}=w;for(let j=b;j<b+y.colspan;j++)if(x[j]){o.push(`第 ${d} 行第 ${j+1} 列:此处被上方跨行格占住,应写 ^`);break}if(y.rowspan>1)for(let j=b;j<b+y.colspan;j++)f[j]=y.rowspan-1;k.push(y),b+=y.colspan}for(let w=b;w<x.length;w++)x[w]&&o.push(`第 ${d} 行第 ${w+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let w=0;w<f.length;w++)f[w]===void 0&&(f[w]=0);l=f,r.push({header:g,cells:k}),s.push({width:b,line:d})});const a=s.reduce((p,c)=>Math.max(p,c.width),0);for(const p of s)p.width!==a&&o.push(`第 ${p.line} 行:占 ${p.width} 列,与总列数 ${a} 不符`);return l.some(p=>p>0)&&o.push("表尾:有跨行格超出了表的最后一行"),r.length===0&&o.push("空表"),{rows:r,columns:a,warnings:o}}function Zi(t){const n=t.split(`
149
149
  `),o=[];let r=[];const s=()=>{if(r.length===0)return;const a=r.join(`
150
150
  `);r=[],o.push({type:"text",text:a})};let l=0;for(;l<n.length;){if(yp.test(n[l].trim())){let a=l+1;for(;a<n.length&&!jp.test(n[a].trim());)a++;if(a<n.length){s();const p=n.slice(l+1,a);o.push({type:"table",table:Ys(p,l+1),source:n.slice(l,a+1).join(`
151
- `)}),l=a+1;continue}}r.push(n[l]),l++}return s(),o.map((a,p)=>{var d,u;if(a.type!=="text")return a;let c=a.text;return((d=o[p-1])==null?void 0:d.type)==="table"&&(c=c.replace(/^\n+/,"")),((u=o[p+1])==null?void 0:u.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(a=>a.type!=="text"||a.text!=="")}const ri=t=>t?t.catch(()=>null):Promise.resolve(null);function Ks(t){const n=new Map;function o(r){var l;let s=n.get(r);return s||(s=ri((l=t.getTextManifest)==null?void 0:l.call(t,r)).then(a=>{const p=a&&Array.isArray(a.versions)&&a.versions.length>0?a:null;return p||n.delete(r),p}),n.set(r,s)),s}return{getManifest(r){return xe.isSafeSegment(r)?o(r):Promise.resolve(null)},async getIndex(r,s){return!xe.isSafeSegment(r)||!xe.isSafeSegment(s)||!t.getTextIndex?null:ri(t.getTextIndex(r,s))},async getChapter(r,s,l,a){return!xe.isSafeSegment(r)||!xe.isSafeSegment(s)||!xe.isSafeSegment(l)||!t.getChapter?null:ri(t.getChapter(r,s,l,a))}}}const Rt=()=>{const{t}=G(),[n,o]=x.useState(1);return x.useEffect(()=>{const r=setInterval(()=>o(s=>s>=3?1:s+1),500);return()=>clearInterval(r)},[]),e.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:i("desc-fg"),fontSize:"14px"},children:t("common.loading")+".".repeat(n)})},si=String.raw`https?:\/\/[^\s()()<>"]+`,wp=new RegExp(String.raw`\[([^\]\n]+)\]\((${si})\)`+String.raw`|(《[^》\n]+》)\s?[((](${si})[))]`+`|(${si})`,"g");function Sp(t){try{return new URL(t).hostname.replace(/^www\./,"")}catch{return t}}function $p(t){const n=[];let o=0;for(const r of t.matchAll(wp)){const s=r.index??0;s>o&&n.push({text:t.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:Sp(r[5]),url:r[5]}),o=s+r[0].length}return o<t.length&&n.push({text:t.slice(o)}),n}function qs({text:t,convert:n,className:o="bim-rd-link"}){return e.jsx(e.Fragment,{children:$p(t).map((r,s)=>r.url?e.jsx("a",{className:o,href:r.url,target:"_blank",rel:"noopener noreferrer",children:n(r.text)},s):e.jsx(x.Fragment,{children:n(r.text)},s))})}const Zs="(min-width: 1100px)",Js="(max-width: 719px)",Xs="(max-width: 859px)",_p=`${Js}, (pointer: coarse)`,yt=i("reader-top"),Cp="48px",Qs=`
151
+ `)}),l=a+1;continue}}r.push(n[l]),l++}return s(),o.map((a,p)=>{var d,u;if(a.type!=="text")return a;let c=a.text;return((d=o[p-1])==null?void 0:d.type)==="table"&&(c=c.replace(/^\n+/,"")),((u=o[p+1])==null?void 0:u.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(a=>a.type!=="text"||a.text!=="")}const ri=t=>t?t.catch(()=>null):Promise.resolve(null);function Ks(t){const n=new Map;function o(r){var l;let s=n.get(r);return s||(s=ri((l=t.getTextManifest)==null?void 0:l.call(t,r)).then(a=>{const p=a&&Array.isArray(a.versions)&&a.versions.length>0?a:null;return p||n.delete(r),p}),n.set(r,s)),s}return{getManifest(r){return be.isSafeSegment(r)?o(r):Promise.resolve(null)},async getIndex(r,s){return!be.isSafeSegment(r)||!be.isSafeSegment(s)||!t.getTextIndex?null:ri(t.getTextIndex(r,s))},async getChapter(r,s,l,a){return!be.isSafeSegment(r)||!be.isSafeSegment(s)||!be.isSafeSegment(l)||!t.getChapter?null:ri(t.getChapter(r,s,l,a))}}}const Rt=()=>{const{t}=Y(),[n,o]=h.useState(1);return h.useEffect(()=>{const r=setInterval(()=>o(s=>s>=3?1:s+1),500);return()=>clearInterval(r)},[]),e.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:i("desc-fg"),fontSize:"14px"},children:t("common.loading")+".".repeat(n)})},si=String.raw`https?:\/\/[^\s()()<>"]+`,wp=new RegExp(String.raw`\[([^\]\n]+)\]\((${si})\)`+String.raw`|(《[^》\n]+》)\s?[((](${si})[))]`+`|(${si})`,"g");function Sp(t){try{return new URL(t).hostname.replace(/^www\./,"")}catch{return t}}function $p(t){const n=[];let o=0;for(const r of t.matchAll(wp)){const s=r.index??0;s>o&&n.push({text:t.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:Sp(r[5]),url:r[5]}),o=s+r[0].length}return o<t.length&&n.push({text:t.slice(o)}),n}function qs({text:t,convert:n,className:o="bim-rd-link"}){return e.jsx(e.Fragment,{children:$p(t).map((r,s)=>r.url?e.jsx("a",{className:o,href:r.url,target:"_blank",rel:"noopener noreferrer",children:n(r.text)},s):e.jsx(h.Fragment,{children:n(r.text)},s))})}const Zs="(min-width: 1100px)",Js="(max-width: 719px)",Xs="(max-width: 859px)",_p=`${Js}, (pointer: coarse)`,yt=i("reader-top"),Cp="48px",Qs=`
152
152
  .bim-rd {
153
153
  position: relative;
154
154
  background: ${i("page-bg")};
@@ -515,8 +515,8 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
515
515
  :root[data-theme="ink"] .bim-rd-t[aria-pressed="true"], :root[data-theme="ink"] .bim-rd-t[aria-current="true"] {
516
516
  text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px;
517
517
  }
518
- `;function Ji(t,n){var o;return n?t.key===n?!0:!!((o=t.children)!=null&&o.some(r=>Ji(r,n))):!1}const zp=()=>e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:e.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Tp({item:t,activeKey:n,onSelect:o,tabKey:r}){const s=Ji(t,n),[l,a]=x.useState(s||!!t.defaultExpanded);return x.useEffect(()=>{s&&a(!0)},[s]),x.useEffect(()=>{t.defaultExpanded&&a(!0)},[t.defaultExpanded]),e.jsxs("li",{children:[e.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":l,"data-rd-toc-key":t.key,tabIndex:r===t.key?0:-1,onClick:()=>a(p=>!p),children:[e.jsx(zp,{}),e.jsx("span",{children:t.label}),t.hint!=null&&e.jsx("span",{className:"bim-rd-hint",children:t.hint})]}),l&&e.jsx(el,{items:t.children,activeKey:n,onSelect:o,tabKey:r})]})}function el({items:t,activeKey:n,onSelect:o,tabKey:r}){return e.jsx("ul",{children:t.map(s=>s.children&&s.children.length>0?e.jsx(Tp,{item:s,activeKey:n,onSelect:o,tabKey:r},s.key):e.jsx("li",{children:e.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:[e.jsx("span",{children:s.label}),s.hint!=null&&e.jsx("span",{className:"bim-rd-hint",children:s.hint})]})},s.key))})}function rr(t,n){var o;for(const r of t)if(r.key===n||Ji(r,n))return r.key;return((o=t[0])==null?void 0:o.key)??null}function tl({items:t,activeKey:n,onSelect:o,label:r}){const{t:s}=G(),l=r??s("reader.toc"),a=x.useRef(null),[p,c]=x.useState(null);x.useEffect(()=>{c(null)},[n]);const d=x.useMemo(()=>p||(n??rr(t,n)),[p,n,t]);x.useEffect(()=>{const g=a.current;if(!g)return;const m=Array.from(g.querySelectorAll("[data-rd-toc-key]"));if(m.length===0)return;const h=m.find(f=>f.dataset.rdTocKey===d)??m.find(f=>f.dataset.rdTocKey===rr(t,n))??m.find(f=>!f.disabled)??m[0];for(const f of m)f.tabIndex=f===h?0:-1}),x.useEffect(()=>{const g=a.current,m=g==null?void 0:g.closest(".bim-rd-toc");if(!g||!m||!n)return;const h=Array.from(g.querySelectorAll("[data-rd-toc-key]")).find(v=>v.dataset.rdTocKey===n);if(!h)return;const f=h.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop;(f<m.scrollTop+80||f>m.scrollTop+m.clientHeight-40)&&(m.scrollTop=Math.max(0,f-m.clientHeight/3))},[n]);const u=x.useCallback(g=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(g.key))return;const h=a.current;if(!h)return;const f=Array.from(h.querySelectorAll("[data-rd-toc-key]")).filter(b=>!b.disabled),v=f.indexOf(document.activeElement);let y=v;if(g.key==="ArrowDown"?y=Math.min(f.length-1,v+1):g.key==="ArrowUp"?y=Math.max(0,v-1):g.key==="Home"?y=0:g.key==="End"&&(y=f.length-1),y<0||y===v)return;g.preventDefault();const w=f[y];for(const b of f)b.tabIndex=-1;w.tabIndex=0,w.focus(),c(w.dataset.rdTocKey??null)},[]);return e.jsx("div",{ref:a,role:"navigation","aria-label":l,onKeyDown:u,children:e.jsx(el,{items:t,activeKey:n,onSelect:o,tabKey:d})})}function Np({page:t}){var n;return!((n=t.boxes)!=null&&n.length)||!t.width||!t.height||t.boxFormat&&t.boxFormat!=="bim-charbox-v0"?null:e.jsx("svg",{viewBox:`0 0 ${t.width} ${t.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:t.boxes.map((o,r)=>e.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 vi({pages:t,loading:n,page:o,onPageChange:r,renderOverlay:s}){const{t:l}=G(),[a,p]=x.useState(0),c=o??a,d=h=>{r?r(h):p(h)};if(x.useEffect(()=>{o===void 0&&p(0)},[t,o]),n)return e.jsx("div",{className:"bim-rd-img-box",children:e.jsx("div",{className:"bim-rd-img-empty",children:l("reader.imagesLoading")})});if(!t||t.length===0)return e.jsx("div",{className:"bim-rd-img-box",children:e.jsxs("div",{className:"bim-rd-img-empty",children:[e.jsx("div",{className:"bim-rd-img-frame","aria-hidden":"true"}),e.jsx("b",{children:l("reader.noImages")}),e.jsx("span",{children:l("reader.noImagesHint")})]})});const u=Math.max(0,Math.min(t.length-1,c)),g=t[u],m=g.label??`${u+1}`;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-rd-img-box",children:e.jsxs("figure",{className:"bim-rd-img-fig",children:[e.jsx("img",{src:g.url,alt:g.alt??l("reader.imageAlt",{label:m}),width:g.width,height:g.height,loading:"lazy",decoding:"async"}),e.jsx(Np,{page:g}),s==null?void 0:s(g,u)]})}),t.length>1&&e.jsxs("div",{className:"bim-rd-img-pager",children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.prevImage"),disabled:u===0,onClick:()=>d(u-1),children:"‹"}),e.jsx("span",{"aria-live":"polite",children:g.label??`${u+1} / ${t.length}`}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.nextImage"),disabled:u===t.length-1,onClick:()=>d(u+1),children:"›"})]})]})}const Xi={fontSize:null,readingMode:"line",properNames:!1,writingMode:"horizontal",workLinks:!0},gt=[15,16,17,18,20,22,24],ki=18,nl="bim-reader-prefs",Ip="bim-reading-mode";function Rp(){const t={...Xi};try{const n=localStorage.getItem(nl),o=n?JSON.parse(n):{};typeof o.fontSize=="number"&&gt.includes(o.fontSize)&&(t.fontSize=o.fontSize),(o.readingMode??localStorage.getItem(Ip))==="paragraph"&&(t.readingMode="paragraph"),o.properNames===!0&&(t.properNames=!0),o.writingMode==="vertical"&&(t.writingMode="vertical"),o.workLinks===!1&&(t.workLinks=!1)}catch{}return t}function Ep(t){try{localStorage.setItem(nl,JSON.stringify(t))}catch{}}function yn(t,n){const o=t??ki,r=gt;let s=r.indexOf(o);return s<0&&(s=r.indexOf(ki)),r[Math.max(0,Math.min(r.length-1,s+n))]}function il(){const[t,n]=x.useState(Xi);x.useEffect(()=>{n(Rp())},[]);const o=x.useCallback(r=>{n(s=>{const l={...s,...r};return Ep(l),l})},[]);return[t,o]}function wi(t){if(t.optionLabel)return t.optionLabel;const n=t.label||t.key;return!t.sourceName||n.includes(t.sourceName)?n:`${n} · ${t.sourceName}`}function ol(t,n){if(!(!t||t.length===0))return(n!=null?t.find(o=>o.key===n):void 0)??t.find(o=>o.primary)??t[0]}function rl(t){const n=[],o=r=>{for(const s of r)s.children&&s.children.length>0?o(s.children):n.push(s)};return o(t),n}const sr=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:e.jsx("path",{d:"M4 6h16M4 12h10M4 18h16"})}),Lp=()=>e.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:e.jsx("path",{d:"M15 5l-7 7 7 7"})}),Pp=()=>e.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:e.jsx("path",{d:"M9 5l7 7-7 7"})}),lr=()=>e.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:[e.jsx("rect",{x:"4",y:"3",width:"16",height:"18",rx:"1.5"}),e.jsx("path",{d:"M9 3v18M13 7v10M16.5 7v10"})]});function ar(t,n){if(!n)return;const o=Array.from(n.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(a=>a.tabIndex>=0);if(o.length===0)return;const r=o[0],s=o[o.length-1],l=document.activeElement;t.shiftKey&&(l===r||!n.contains(l))?(t.preventDefault(),s.focus()):!t.shiftKey&&(l===s||!n.contains(l))&&(t.preventDefault(),r.focus())}function cr(t,n){const[o,r]=x.useState(n);return x.useEffect(()=>{var a;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(t);r(s.matches);const l=()=>r(s.matches);return(a=s.addEventListener)==null||a.call(s,"change",l),()=>{var p;return(p=s.removeEventListener)==null?void 0:p.call(s,"change",l)}},[t]),o}function Ap(){const t=x.useContext(It),{t:n}=G();if(!t)return null;const o=t.locale==="zh-Hant";return e.jsxs("button",{type:"button",className:"bim-rd-t",title:n(o?"common.toHans":"common.toHant"),"aria-label":n(o?"common.toHans":"common.toHant"),onClick:()=>t.setLocale(o?"zh-Hans":"zh-Hant"),children:[e.jsx("span",{className:o?"bim-rd-on":"bim-rd-off",children:n("common.localeShortHant")}),e.jsx("span",{className:"bim-rd-off",children:"|"}),e.jsx("span",{className:o?"bim-rd-off":"bim-rd-on",children:n("common.localeShortHans")})]})}function Bp(t,n){if(!t)return;let o;for(const r of Array.from(t.querySelectorAll('[id^="rd-e-"]')))if(r.getBoundingClientRect().top<=n+8)o=r.id;else break;return o}function Mp(t){var l;if(typeof window>"u"||!t)return;const n=(l=window.getSelection)==null?void 0:l.call(window);if(!n||n.isCollapsed||n.rangeCount===0)return;const o=t.querySelector(".bim-rd-col"),r=a=>{const p=(a==null?void 0:a.nodeType)===1?a:a==null?void 0:a.parentElement;return!!a&&!!(o!=null&&o.contains(a))&&!(p!=null&&p.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 sl({title:t,subtitle:n,toc:o,activeKey:r,onSelect:s,tocHeader:l,tocCaption:a,images:p,imagesLoading:c,renderImageOverlay:d,imagePanel:u="auto",prefs:g,onPrefsChange:m,paragraphToggle:h,properNameToggle:f=!0,allowVertical:v,byline:y,current:w,workLinkToggle:b,rail:j,onReportError:S,revisedAt:k,backHref:$,backLabel:_,bottomBar:z=!0,pager:E=!0,pagerUnit:T,versions:C,currentVersionKey:O,onVersionChange:W,versionSource:P=!0,keepChapterOnVersionChange:Y=!1,children:V,className:Q,style:ge}){const{t:A,convert:I}=G(),Z=_??A("reader.back"),ee=I(T??A("reader.unitJuan")),ce=x.useId().replace(/:/g,""),fe=`bim-rd-toc-${ce}`,Ie=`bim-rd-text-${ce}`,q=x.useRef(null),M=x.useRef(null),K=x.useRef(null),Re=x.useRef(null),se=cr(Zs,!0),ye=cr(Xs,!1),We=z&&ye,[Be,Ee]=x.useState(null),Ce=x.useRef(null),He=x.useRef(null),D=(B,be)=>{He.current=be,Ee(_e=>_e===B?null:B)},re=x.useCallback(()=>{var B;Ee(null),(B=He.current)==null||B.focus()},[]);x.useEffect(()=>{We||Ee(null)},[We]),x.useEffect(()=>{var B,be;Be&&((be=(B=Ce.current)==null?void 0:B.querySelector("button:not([disabled])"))==null||be.focus())},[Be]);const[de,ke]=x.useState("auto"),F=de==="auto"?se:de==="open",he=!se,Ne=!!p&&p.length>0,[R,ne]=x.useState(u);x.useEffect(()=>{ne(u)},[u]);const ue=R==="auto"?Ne||!!c:R==="open",L=x.useCallback(B=>{var be;ke("auto"),B&&((be=Re.current)==null||be.focus())},[]),te=()=>ke(F?"closed":"open");x.useEffect(()=>{if(!he||de!=="open")return;const B=K.current,be=B==null?void 0:B.querySelector('input, [data-rd-toc-key][tabindex="0"]');be==null||be.focus()},[he,de]);const U=x.useCallback(B=>{s(B),he&&L(!1);const be=M.current,_e=q.current;if(be&&_e&&typeof window<"u"){const je=be.getBoundingClientRect().top-_e.getBoundingClientRect().bottom;je<0&&window.scrollBy({top:je})}},[s,he,L]),le=x.useMemo(()=>rl(o),[o]),[we,Le]=x.useState(null),Se=ol(C,O!==void 0?O:we),Fe=(Se==null?void 0:Se.key)??null,De=x.useMemo(()=>le.map(B=>B.key).join(`
519
- `),[le]),J=x.useRef(null),Pe=B=>{B!==Fe&&(Y||(J.current={key:B,sig:De,done:!1}),O===void 0&&Le(B),W==null||W(B))};x.useEffect(()=>{const B=J.current;if(!B||B.key!==Fe)return;const be=le.find(je=>!je.disabled);if(!be)return;const _e=De!==B.sig;!_e&&B.done||(_e?J.current=null:B.done=!0,be.key!==r&&U(be.key))},[Fe,De,le,r,U]);const N=le.find(B=>B.key===r),X=()=>{var B;S==null||S({chapterKey:r,chapterLabel:typeof(N==null?void 0:N.label)=="string"?N.label:void 0,anchor:Bp(M.current,((B=q.current)==null?void 0:B.getBoundingClientRect().bottom)??0),selectedText:Mp(M.current)})},ae=le.findIndex(B=>B.key===r),ie=ae>0?le.slice(0,ae).reverse().find(B=>!B.disabled):void 0,pe=ae>=0?le.slice(ae+1).find(B=>!B.disabled):void 0,$e=g.fontSize??ki,H={...ge,...g.fontSize?{"--bimrd-fs":`${g.fontSize}px`}:null};return e.jsxs("div",{className:["bim-rd",g.writingMode==="vertical"&&v?"bim-rd-vertical":"",Q].filter(Boolean).join(" "),"data-toc":de,"data-img":ue?"open":"closed","data-bb":We?"":void 0,style:H,children:[e.jsx("style",{children:Qs}),e.jsx("a",{className:"bim-rd-skip",href:`#${Ie}`,onClick:B=>{var be,_e,je;B.preventDefault(),(be=M.current)==null||be.focus(),(je=(_e=M.current)==null?void 0:_e.scrollIntoView)==null||je.call(_e,{block:"start"})},children:A("reader.skipToText")}),e.jsxs("div",{className:"bim-rd-bar",ref:q,children:[$&&e.jsxs("a",{className:"bim-rd-back",href:$,"aria-label":A("reader.backAria",{label:Z}),children:[e.jsx("span",{"aria-hidden":"true",children:"‹"}),e.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:Z})]}),(t||n||y||w)&&e.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[t&&e.jsx("b",{children:t}),y&&e.jsx("span",{className:"bim-rd-by",children:y}),w&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),e.jsx("span",{className:"bim-rd-cur",children:w})]}),n&&e.jsx("span",{children:n})]}),e.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":A("reader.settings"),children:[C&&C.length>1&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"bim-rd-ver",title:Se?I(wi(Se)):void 0,children:[e.jsx("span",{className:"bim-rd-tlabel",children:A("reader.version")}),e.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:A("reader.versionShort")}),e.jsx("select",{"aria-label":A("reader.version"),value:Fe??"",onChange:B=>Pe(B.target.value),children:C.map(B=>e.jsx("option",{value:B.key,children:I(wi(B))},B.key))})]}),e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),E&&(ie||pe)&&e.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":A("reader.pagerGroup",{unit:ee}),children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.prevUnit",{unit:ee}),title:ie?typeof ie.label=="string"&&ie.label?A("reader.prevUnitTitle",{unit:ee,label:ie.label}):A("reader.prevUnit",{unit:ee}):A("reader.firstUnit",{unit:ee}),disabled:!ie,onClick:()=>ie&&U(ie.key),children:e.jsx(Lp,{})}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.nextUnit",{unit:ee}),title:pe?typeof pe.label=="string"&&pe.label?A("reader.nextUnitTitle",{unit:ee,label:pe.label}):A("reader.nextUnit",{unit:ee}):A("reader.lastUnit",{unit:ee}),disabled:!pe,onClick:()=>pe&&U(pe.key),children:e.jsx(Pp,{})})]}),E&&(ie||pe)&&e.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),e.jsxs("button",{ref:Re,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":F,"aria-controls":fe,onClick:te,children:[e.jsx(sr,{}),e.jsx("span",{className:"bim-rd-tlabel",children:A("reader.toc")})]}),e.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":ue,onClick:()=>ne(ue?"closed":"open"),children:[e.jsx(lr,{}),A("reader.images")]}),e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),e.jsx(Ap,{}),e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),e.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":A("reader.fontSmaller"),disabled:$e<=gt[0],onClick:()=>m({fontSize:yn(g.fontSize,-1)}),children:"A−"}),e.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":A("reader.fontLarger"),disabled:$e>=gt[gt.length-1],onClick:()=>m({fontSize:yn(g.fontSize,1)}),children:"A+"}),(h||f||v)&&e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),h&&e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":g.readingMode==="paragraph",title:A("reader.paragraphTitle"),onClick:()=>m({readingMode:g.readingMode==="paragraph"?"line":"paragraph"}),children:A("reader.paragraph")}),b&&e.jsxs("label",{className:"bim-rd-t bim-rd-chk",children:[e.jsx("input",{type:"checkbox",checked:g.workLinks,onChange:B=>m({workLinks:B.target.checked})}),e.jsx("span",{children:A("reader.workLinks")})]}),f&&e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":g.properNames,title:A("reader.properNameTitle"),onClick:()=>m({properNames:!g.properNames}),children:A("reader.properName")}),v&&e.jsx("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":g.writingMode==="vertical",onClick:()=>m({writingMode:g.writingMode==="vertical"?"horizontal":"vertical"}),children:A("reader.vertical")})]})]}),e.jsxs("div",{className:"bim-rd-body",children:[e.jsxs("div",{className:"bim-rd-toc",id:fe,ref:K,role:he&&F?"dialog":void 0,"aria-modal":he&&F?!0:void 0,"aria-label":he&&F?A("reader.toc"):void 0,onKeyDown:B=>{if(!(!he||!F)){if(B.key==="Escape"){B.stopPropagation(),L(!0);return}B.key==="Tab"&&ar(B,K.current)}},children:[e.jsxs("div",{className:"bim-rd-toc-top",children:[e.jsxs("div",{className:"bim-rd-toc-head",children:[e.jsx("span",{children:a??A("reader.toc")}),he&&e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.closeToc"),onClick:()=>L(!0),children:"✕"})]}),l]}),e.jsx(tl,{items:o,activeKey:r,onSelect:U})]}),e.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>L(!0)}),e.jsx("aside",{className:"bim-rd-img","aria-label":A("reader.images"),children:ue&&e.jsx(vi,{pages:p??null,loading:c,renderOverlay:d})}),e.jsxs("div",{className:"bim-rd-text",id:Ie,ref:M,tabIndex:-1,"data-rail":j||S?"true":void 0,children:[e.jsxs("div",{className:"bim-rd-col",children:[V,P&&Se&&(Se.sourceName||Se.license)&&e.jsxs("p",{className:"bim-rd-src","data-version":Se.key,children:[Se.sourceName&&e.jsxs(e.Fragment,{children:[A("reader.sourceLabel")," ",Se.sourceUrl?e.jsx("a",{className:"bim-rd-link",href:Se.sourceUrl,target:"_blank",rel:"noreferrer",children:I(Se.sourceName)}):I(Se.sourceName)]}),Se.sourceName&&Se.license&&e.jsx("span",{className:"bim-rd-dot"}),Se.license&&e.jsx(e.Fragment,{children:A("reader.licenseOf",{license:Se.license})})]}),k&&e.jsx("p",{className:"bim-rd-src bim-rd-rev",children:A("reader.revisedAt",{date:k})}),S&&e.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:e.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:B=>B.preventDefault(),onClick:X,children:A("reader.reportError")})}),E&&(ie||pe)&&e.jsxs("nav",{className:"bim-rd-pager","aria-label":A("reader.pagerNav"),children:[ie?e.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>U(ie.key),children:[e.jsxs("span",{className:"bim-rd-pgcap",children:[e.jsx("span",{"aria-hidden":"true",children:"← "}),A("reader.prevUnit",{unit:ee})]}),e.jsx("span",{className:"bim-rd-pglabel",children:ie.label})]}):e.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",A("reader.firstUnit",{unit:ee})]}),pe?e.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>U(pe.key),children:[e.jsxs("span",{className:"bim-rd-pgcap",children:[A("reader.nextUnit",{unit:ee}),e.jsx("span",{"aria-hidden":"true",children:" →"})]}),e.jsx("span",{className:"bim-rd-pglabel",children:pe.label})]}):e.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)&&e.jsxs("aside",{className:"bim-rd-rail","aria-label":A("reader.rail"),children:[j,S&&e.jsx("div",{className:"bim-rd-rail-acts",children:e.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:B=>B.preventDefault(),onClick:X,children:A("reader.reportError")})})]})]})]}),We&&e.jsxs("nav",{className:"bim-rd-bb","aria-label":A("reader.bottomBar"),children:[e.jsxs("button",{type:"button","aria-expanded":F,"aria-controls":fe,onClick:()=>{Ee(null),te()},children:[e.jsx(sr,{}),e.jsx("span",{children:A("reader.tocShort")})]}),e.jsxs("button",{type:"button","aria-expanded":Be==="img","aria-haspopup":"dialog",onClick:B=>D("img",B.currentTarget),children:[e.jsx(lr,{}),e.jsx("span",{children:A("reader.images")})]}),e.jsxs("button",{type:"button","aria-expanded":Be==="fs","aria-haspopup":"dialog",onClick:B=>D("fs",B.currentTarget),children:[e.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"A"}),e.jsx("span",{children:A("reader.fontSize")})]}),S&&e.jsxs("button",{type:"button",onMouseDown:B=>B.preventDefault(),onClick:()=>{Ee(null),X()},children:[e.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),e.jsx("span",{children:A("reader.reportError")})]})]}),We&&Be&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:re}),e.jsxs("div",{className:"bim-rd-sheet",ref:Ce,role:"dialog","aria-modal":"true","aria-label":A(Be==="img"?"reader.images":"reader.fontSize"),onKeyDown:B=>{if(B.key==="Escape"){B.stopPropagation(),re();return}B.key==="Tab"&&ar(B,Ce.current)},children:[e.jsxs("div",{className:"bim-rd-sheet-head",children:[e.jsx("span",{children:A(Be==="img"?"reader.images":"reader.fontSize")}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.close"),onClick:re,children:"✕"})]}),Be==="img"?e.jsx("div",{className:"bim-rd-sheet-img",children:e.jsx(vi,{pages:p??null,loading:c,renderOverlay:d})}):e.jsxs("div",{className:"bim-rd-sheet-fs",children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.fontSmaller"),disabled:$e<=gt[0],onClick:()=>m({fontSize:yn(g.fontSize,-1)}),children:"A−"}),e.jsxs("output",{"aria-live":"polite",children:[$e,"px"]}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.fontLarger"),disabled:$e>=gt[gt.length-1],onClick:()=>m({fontSize:yn(g.fontSize,1)}),children:"A+"})]})]})]})]})}const ll=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],Wp={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function Ke(t){return Wp[t]??t}const Wt=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],Ht={熹平: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},al={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function Hn(t){const n=t.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 Hp(t){return t>=1950?"":t>=1912?"民國":t>=1645?"清":t>=1368?"明":t>=1279?"元":t>=960?"宋":t>=907?"五代":t>=618?"唐":t>=581?"隋":t>=420?"南北朝":t>=265?"晉":t>=220?"三國":t>=-202?"漢":""}const Op=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,dr={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function Qi(t){const n=t.trim().replace(/[代朝]$/,"");for(const s of Object.keys(dr))if(n.startsWith(s))return dr[s];const o=Ke(n);if($t[o]!=null)return o;const r=xt(n);if(r&&n.length<=r.length+1)return Ke(r)}function St(t,n){if(n){const o=al[`${n}|${t}`];if(o!=null)return o}return Ht[t]}const Fp=1911;function Dp(t){const n=Ht[t];if(n==null)return;const o=ut[t];let r;for(const[s,l]of Object.entries(Ht))ut[s]===o&&l>n&&(r==null||l<r)&&(r=l);return r!=null?r-1:void 0}const Up={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function Cn(t){if(!t)return;if(/^\d+$/.test(t))return parseInt(t,10);let n=0,o=0,r=!1;for(const l of t){const a=Up[l];if(a===void 0)return;r=!0,l==="十"?o=(o||1)*10:l==="廿"||l==="卅"?(n+=a,o=0):o>=10?(n+=o+a,o=0):o=o*10+a}const s=n+o;return r&&s>0?s:void 0}function xt(t){for(const n of ll)if(t.startsWith(n))return n}const ut={};{const t=(n,o)=>{for(const r of o)ut[r]=n};t("東漢",["熹平","建安"]),t("三國",["黃初","正始"]),t("五代",["廣政"]),t("西晉",["太康"]),t("東晉",["永和"]),t("隋",["開皇"]),t("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),t("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),t("金",["大定","明昌"]),t("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),t("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),t("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),t("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function _t(t,n){const o=n==="北宋"||n==="南宋"?"宋":n;for(const r of Object.keys(Ht))if(t.includes(r)&&!(o&&ut[r]&&ut[r]!==o&&al[`${o}|${r}`]==null))return r}function dn(t){var a,p,c;const n={era:"",reign:"",source:"none"},o=t.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=(a=t.lineage)==null?void 0:a.year_text;if(r){const d=xt(r)??"";return{era:Ke(d),reign:_t(r,d)??"",source:"lineage"}}const s=(p=t.publication_info)==null?void 0:p.year;if(s){const d=Hn(s);if(d)return{era:Hp(d.from),reign:"",source:"publication"};const u=xt(s)??Qi(s)??((c=Wt.find(h=>h.pattern.test(s)))==null?void 0:c.era)??"",g=_t(s,u)??"",m=u||(g?ut[g]??"":"");if(m||g)return{era:Ke(m),reign:g,source:"publication"}}const l=t.edition||t.title||"";if(l){const d=xt(l);if(d)return{era:Ke(d),reign:_t(l,d)??"",source:"edition"};const u=Wt.find(g=>g.pattern.test(l));if(u)return{era:Ke(u.era),reign:_t(l,u.era)??u.reign??"",source:"edition"}}return n}function On(t){var r,s,l,a,p,c,d,u,g;if(((r=t.dating)==null?void 0:r.year)!=null)return t.dating.year;if(typeof((s=t.lineage)==null?void 0:s.year)=="number")return t.lineage.year;const n=(l=t.publication_info)==null?void 0:l.year;if(n){const m=Hn(n);if(m)return m.from}const o=[(a=t.lineage)==null?void 0:a.year_text,(p=t.publication_info)==null?void 0:p.year,t.edition,t.edition?void 0:t.title].filter(Boolean);for(const m of o){const h=((c=t.publication_info)==null?void 0:c.year)||((d=t.lineage)==null?void 0:d.year_text);if(h&&m!==h&&(xt(h)||Qi(h)))break;const f=m.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??m.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(f){const j=parseInt(f[1],10);if(j>=100&&j<=2100)return j}const v=m.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(v){const j=xt(m);if(!j||Ke(j)==="民國"){const k=Cn(v[1]);if(k!=null&&k>=1&&k<=120)return Fp+k}}const y=xt(m)??((u=Wt.find(j=>j.pattern.test(m)))==null?void 0:u.era),w=y?Ke(y):void 0,b=_t(m,w)??(xt(m)||(g=Wt.find(j=>j.pattern.test(m)))==null?void 0:g.reign);if(b){const j=St(b,w);if(j==null)continue;const S=m.indexOf(b),k=S>=0?m.slice(S+b.length):"",$=k.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??k.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),_=$?Cn($[1]):void 0;return j+(_?_-1:0)}}}function eo(t){var a,p,c,d,u,g;const n=(a=t.dating)==null?void 0:a.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const o=(p=t.lineage)==null?void 0:p.year_range;if(o&&o.length===2)return{from:o[0],to:o[1]};const r=(c=t.lineage)==null?void 0:c.year_text;if(r){const m=r.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(m){const h=Si[Ke(m[1])],f=$t[Ke(m[2])];if(h!=null&&f!=null)return{from:Math.min(h,f)-20,to:Math.max(h,f)+40}}}const s=(d=t.publication_info)==null?void 0:d.year;if(s){const m=Hn(s);if((m==null?void 0:m.to)!=null)return{from:m.from,to:m.to};const h=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(h){const f=Si[Ke(h[1])],v=$t[Ke(h[2])];if(f!=null&&v!=null)return{from:Math.min(f,v)-20,to:Math.max(f,v)+40}}}const l=[(u=t.publication_info)==null?void 0:u.year,t.edition,t.title].filter(Boolean);for(const m of l){if(!/[間间]/.test(m))continue;const h=xt(m)??Qi(m)??((g=Wt.find(y=>y.pattern.test(m)))==null?void 0:g.era),f=h?Ke(h):void 0,v=[];for(const y of Object.keys(Ht))m.includes(y)&&(f&&ut[y]&&ut[y]!==f||St(y,f)!=null&&v.push(y));if(v.length===0){const y=m.match(/([一-鿿])([一-鿿])[間间]/);if(y&&f){for(const w of[y[1],y[2]])for(const b of Object.keys(Ht))if(ut[b]===f&&!(b[0]!==w&&b[b.length-1]!==w)&&St(b,f)!=null){v.push(b);break}}}if(v.length>0){const y=v.map(S=>St(S,f)).filter(S=>S!=null),w=Math.min(...y),b=v.reduce((S,k)=>St(S,f)>=St(k,f)?S:k),j=Dp(b)??li(f??"")??Math.max(...y);return{from:w,to:j>w?j:li(f??ut[b]??"")??w}}if(f&&$t[f]!=null)return{from:$t[f],to:li(f)??$t[f]}}}const $t={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},Vp=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],Gp=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,pr=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function ur(t,n){for(const o of ll){const r=t.indexOf(o);if(r<0)continue;if(o.length===1){const c=t[r+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!_t(t.slice(r),Ke(o)))continue}const s=Ke(o);if(s===n)continue;const l=t.slice(r),a=_t(l,s)??"";let p;if(a){const c=St(a,s);if(c!=null){const u=l.slice(l.indexOf(a)+a.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),g=u?Cn(u[1]):void 0;p=c+(g?g-1:0)}}return{era:s,reign:a,year:p}}for(const o of Wt)if(o.pattern.test(t))return{era:Ke(o.era),reign:o.reign??""}}function Yp(t){var w,b,j,S,k;const n=dn(t),o=((w=t.publication_info)==null?void 0:w.year)??"",r=o?Hn(o):void 0;if(!n.era&&!n.reign&&!r)return;const s=t.edition||t.title||"",l=/[間间]/.test(s),a=((b=t.lineage)==null?void 0:b.year_text)??"",p=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(a),c=n.source==="publication"&&Op.test(o),d=n.source==="publication"&&/[間间]/.test(o),u=a.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let g;l||p||c||d?g=void 0:u?g=parseInt(u[2],10):g=On(t);const m=g==null?eo(t):void 0;let h;n.source==="publication"&&(c||pr.test(o))?h="uncertain":n.source==="lineage"||n.source==="publication"?h="attested":pr.test(s)||!n.reign&&g==null?h="uncertain":h="inferred";const f=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((j=t.lineage)==null?void 0:j.year_text)??((S=t.lineage)==null?void 0:S.year)??""}」`:`出版著錄「${((k=t.publication_info)==null?void 0:k.year)??""}」`,v={era:n.era,reign:n.reign,year:g,yearRange:m,certainty:h,source:n.source==="edition"?"edition":"catalog",basis:f};if(u){const $=a.match(/[、,,]\s*([宋元明清])/);$&&$[1]!==v.era&&(v.laterRepair={era:$[1]})}if(!v.laterRepair&&Gp.test(s)){const $=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);$&&$[1]!==n.era&&(v.laterRepair={era:$[1]})}const y=Vp.find($=>$.re.test(s));if(y){const $=s.search(y.re),_=s.slice($),z=ur(_,n.era)??ur(s,n.era);z&&(v.basedOn={era:z.era,reign:z.reign,year:z.year,relation:y.relation})}return v}const Si={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function li(t){return Si[t]}function zn(t){const n=On(t);if(n!=null)return n;const o=eo(t);if(o)return o.from;const r=dn(t).era;return r?$t[r]:void 0}const mr=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function $i(t){const n=mr.indexOf(t);return n===-1?mr.length:n}function Kp(t){const n={belongsTo:[],collected:[],contains:[],derivative:[],studies:[],related:[]};for(const s of t){const l=s.relation;l==="part_of"?n.belongsTo.push(s):l==="collected_in"?n.collected.push(s):l==="has_part"||l==="contains_text_of"?n.contains.push(s):l==="text_carried_by"||l==="studied_by"||l==="derived_from"||l==="followed_by"||l==="has_adaptation"?n.derivative.push(s):l==="studies"||l==="preceded_by"?n.studies.push(s):n.related.push(s)}const o=[],r=(s,l)=>{n[s].length&&o.push({key:s,labelKey:l,items:n[s]})};return r("belongsTo","belongsToWork"),r("collected","collectedIn"),r("contains","containedWorks"),r("derivative","derivativeWorks"),r("studies","studies"),r("related","relatedWorks"),o}function to(t,n){const o=Oi(t||[]),r=new Map,s=[];for(const d of o)d.group?(r.has(d.group)||r.set(d.group,[]),r.get(d.group).push(d)):s.push(d);for(const d of r.values())d.sort((u,g)=>{const m=h=>h.group_role==="origin"?0:h.group_role==="mirror"?1:2;return m(u)-m(g)});const l={text:[],image:[],textImage:[],physical:[]};for(const d of s){const u=Nt(d),g=u.includes("text"),m=u.includes("image");g&&m?l.textImage.push(d):g?l.text.push(d):m?l.image.push(d):l.physical.push(d)}const p=["text","image","textImage","physical"].filter(d=>l[d].length>0).map(d=>({key:d,items:l[d]})),c=[...r.entries()].map(([d,u])=>{var g,m;return{key:d,label:((g=n==null?void 0:n[d])==null?void 0:g.label)||d,description:(m=n==null?void 0:n[d])==null?void 0:m.description,items:u}});return{buckets:p,mirrors:c,total:o.length}}function Fn(t,n=Dt("zh-Hant")){const o=[],r=t.metadata||{};r.edition&&o.push(String(r.edition)),t.source_label&&o.push(t.source_label),t.details&&o.push(t.details);const s=Ln(t);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 cl(t,n){if(Fn(t)||n.filter(r=>r.name===t.name).length<2)return"";try{const r=new URL(t.url),s=r.searchParams.get("res")||r.searchParams.get("id");if(s)return s;const l=r.pathname.split("/").filter(Boolean).pop();if(l)return decodeURIComponent(l)}catch{}return""}function dl(t,n){var l,a;const o=t.resources||[],r=[],s=[];for(const p of o){const c=Nt(p);c.includes("image")&&r.push(p),c.includes("physical")&&s.push(p)}return{id:t.id,name:t.edition||t.title||t.id,era:dn(t),year:On(t),sortYear:zn(t),images:r,holders:s,locationName:(l=t.current_location)==null?void 0:l.name,important:qp(t.id,n),group:(a=n==null?void 0:n.node_groups)==null?void 0:a[t.id],hasImage:r.length>0}}function qp(t,n){var p,c;if(!n)return!1;const o=n.default_collection;if(!o)return!1;const r=(p=n.collections)==null?void 0:p[o];if(((r==null?void 0:r.book_ids)??(o==="core"?n.core_books??[]:[])).includes(t))return!0;const l=(r==null?void 0:r.groups)??[],a=(c=n.node_groups)==null?void 0:c[t];return!!a&&l.includes(a)}function pl(t,n,o={}){const r=new Set((n==null?void 0:n.excluded_books)??[]),s=t.filter(c=>!r.has(c.id)).map(c=>dl(c,n));let l=s;o.era&&(l=l.filter(c=>c.era.era===o.era)),o.scanOnly&&(l=l.filter(c=>c.hasImage)),o.sort==="year"?l=l.map((c,d)=>({r:c,i:d})).sort((c,d)=>{const u=c.r.sortYear,g=d.r.sortYear;return u!=null&&g!=null?u-g||c.i-d.i:u!=null?-1:g!=null?1:c.i-d.i}).map(c=>c.r):l=l.map((c,d)=>({r:c,i:d})).sort((c,d)=>{const u=g=>(g.important?0:1)*2+(g.hasImage?0:1);return u(c.r)-u(d.r)||c.i-d.i}).map(c=>c.r);const p=[...new Set(s.map(c=>c.era.era).filter(Boolean))].sort((c,d)=>$i(c)-$i(d));return{rows:l,allRows:s,eras:p,hasInferredEra:s.some(c=>c.era.source==="edition")}}function Zp(t,n){var y,w;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:t,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)??[],l=r.length>0||s.length>0,a=!l&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!l&&a.length===0)return{useGrouping:!1,coreIds:t,groupedIds:[]};const p=new Set(r),c=new Set([...s,...a]),d=b=>{if(c.has(b))return!0;const j=n.node_groups[b];return j!=null&&p.has(j)},u=[],g=new Map,m=[];for(const b of t)if(!((w=n.excluded_books)!=null&&w.includes(b)))if(d(b))u.push(b);else{const j=n.node_groups[b];j?(g.has(j)||g.set(j,[]),g.get(j).push(b)):m.push(b)}if(m.length+[...g.values()].reduce((b,j)=>b+j.length,0)<3)return{useGrouping:!1,coreIds:t,groupedIds:[]};const f=new Map((n.groups??[]).map(b=>[b.id,b])),v=[...g.entries()].map(([b,j])=>{const S=f.get(b);return{id:b,label:(S==null?void 0:S.label)??b,description:S==null?void 0:S.description,ids:j}});return m.length>0&&v.push({id:"__other__",label:"其他版本",description:void 0,ids:m}),{useGrouping:!0,coreIds:u,groupedIds:v}}const ul=["撰","編","注","校","譯","繪","其他"],Jp=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function no(t){if(!t||!t.trim())return"撰";const n=t.replace(/[\s-]/g,"");if(!n||n==="author")return"撰";for(const{cls:o,re:r}of Jp)if(r.test(n))return o;return"其他"}function io(t){if(!t)return"";const n=t.trim();return!n||!/[一-鿿]/.test(n)?"":n}function ml(t,n="全部"){const o=new Map;for(const s of t){const l=no(s);o.set(l,(o.get(l)??0)+1)}const r=[{cls:"全部",label:n,count:t.length}];for(const s of ul){const l=o.get(s);l&&r.push({cls:s,label:s,count:l})}return r.length>2?r:[]}function gl(t,n,o){if(n&&n.books&&n.books.length>0){const s=n.books.map(a=>({id:a.work_id||a.book_id||void 0,title:a.title,section:a.section,volumes:a.volumes||[],subItems:a.sub_items,edition:a.edition,found:a.found_volumes,expected:a.expected_volumes})),l=[...new Set(s.map(a=>a.section).filter(Boolean))];return{rows:s,source:"catalog",sections:l,totalVolumes:n.total_volumes}}return t.contained_works&&t.contained_works.length>0?{rows:t.contained_works.map(l=>({id:l.id,title:l.title,volumes:sn(l.volume_index)})),source:"works",sections:[]}:{rows:(t.books||[]).map(s=>{var l,a;return{id:s,title:((l=o==null?void 0:o.get(s))==null?void 0:l.title)||s,edition:(a=o==null?void 0:o.get(s))==null?void 0:a.edition,volumes:[]}}),source:"books",sections:[]}}function sn(t){if(t==null)return[];if(typeof t=="number")return[t];if(Array.isArray(t))return t.filter(n=>typeof n=="number");if(typeof t=="string"){const n=t.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,l)=>o+l)}return t.split(/[,、]/).map(o=>parseInt(o.trim())).filter(o=>!isNaN(o))}return[]}function Dn(t,n="冊"){if(t.length===0)return"";if(t.length===1)return`${t[0]}`;const o=[...t].sort((l,a)=>l-a),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 Xp=["〇","一","二","三","四","五","六","七","八","九"],gr=["","十","百","千"];function hl(t){if(t<=0)return"";if(t>=1e4)return String(t);const n=String(t),o=n.length;let r="",s=!1;for(let l=0;l<o;l++){const a=parseInt(n[l]),p=o-1-l;a===0?s=!0:(s&&r&&(r+="〇"),s=!1,a===1&&p===1&&l===0?r+=gr[p]:r+=Xp[a]+gr[p])}return r}function Qp(t){return t==null?"":typeof t=="string"?t:t.title??""}function bt(t,n="卷"){var r,s;const o=t;return o.measure_info?o.measure_info:(r=o.juan_count)!=null&&r.number?hl(o.juan_count.number)+n:(s=o.juan_count)!=null&&s.description?o.juan_count.description:""}function xl(t){var r;if(t.edition_type)return t.edition_type;if((r=t.lineage)!=null&&r.category)return t.lineage.category;const n=t.edition||t.title||"",o=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,l]of o)if(s.test(n))return l;return""}const eu=216,hr="clamp(280px, 23vw, 360px)",tu=1440,_i="(max-width: 719px)",nu=`${_i}, (pointer: coarse)`,iu=`
518
+ `;function Ji(t,n){var o;return n?t.key===n?!0:!!((o=t.children)!=null&&o.some(r=>Ji(r,n))):!1}const zp=()=>e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:e.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Tp({item:t,activeKey:n,onSelect:o,tabKey:r}){const s=Ji(t,n),[l,a]=h.useState(s||!!t.defaultExpanded);return h.useEffect(()=>{s&&a(!0)},[s]),h.useEffect(()=>{t.defaultExpanded&&a(!0)},[t.defaultExpanded]),e.jsxs("li",{children:[e.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":l,"data-rd-toc-key":t.key,tabIndex:r===t.key?0:-1,onClick:()=>a(p=>!p),children:[e.jsx(zp,{}),e.jsx("span",{children:t.label}),t.hint!=null&&e.jsx("span",{className:"bim-rd-hint",children:t.hint})]}),l&&e.jsx(el,{items:t.children,activeKey:n,onSelect:o,tabKey:r})]})}function el({items:t,activeKey:n,onSelect:o,tabKey:r}){return e.jsx("ul",{children:t.map(s=>s.children&&s.children.length>0?e.jsx(Tp,{item:s,activeKey:n,onSelect:o,tabKey:r},s.key):e.jsx("li",{children:e.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:[e.jsx("span",{children:s.label}),s.hint!=null&&e.jsx("span",{className:"bim-rd-hint",children:s.hint})]})},s.key))})}function rr(t,n){var o;for(const r of t)if(r.key===n||Ji(r,n))return r.key;return((o=t[0])==null?void 0:o.key)??null}function tl({items:t,activeKey:n,onSelect:o,label:r}){const{t:s}=Y(),l=r??s("reader.toc"),a=h.useRef(null),[p,c]=h.useState(null);h.useEffect(()=>{c(null)},[n]);const d=h.useMemo(()=>p||(n??rr(t,n)),[p,n,t]);h.useEffect(()=>{const g=a.current;if(!g)return;const m=Array.from(g.querySelectorAll("[data-rd-toc-key]"));if(m.length===0)return;const x=m.find(f=>f.dataset.rdTocKey===d)??m.find(f=>f.dataset.rdTocKey===rr(t,n))??m.find(f=>!f.disabled)??m[0];for(const f of m)f.tabIndex=f===x?0:-1}),h.useEffect(()=>{const g=a.current,m=g==null?void 0:g.closest(".bim-rd-toc");if(!g||!m||!n)return;const x=Array.from(g.querySelectorAll("[data-rd-toc-key]")).find(k=>k.dataset.rdTocKey===n);if(!x)return;const f=x.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop;(f<m.scrollTop+80||f>m.scrollTop+m.clientHeight-40)&&(m.scrollTop=Math.max(0,f-m.clientHeight/3))},[n]);const u=h.useCallback(g=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(g.key))return;const x=a.current;if(!x)return;const f=Array.from(x.querySelectorAll("[data-rd-toc-key]")).filter(y=>!y.disabled),k=f.indexOf(document.activeElement);let b=k;if(g.key==="ArrowDown"?b=Math.min(f.length-1,k+1):g.key==="ArrowUp"?b=Math.max(0,k-1):g.key==="Home"?b=0:g.key==="End"&&(b=f.length-1),b<0||b===k)return;g.preventDefault();const w=f[b];for(const y of f)y.tabIndex=-1;w.tabIndex=0,w.focus(),c(w.dataset.rdTocKey??null)},[]);return e.jsx("div",{ref:a,role:"navigation","aria-label":l,onKeyDown:u,children:e.jsx(el,{items:t,activeKey:n,onSelect:o,tabKey:d})})}function Np({page:t}){var n;return!((n=t.boxes)!=null&&n.length)||!t.width||!t.height||t.boxFormat&&t.boxFormat!=="bim-charbox-v0"?null:e.jsx("svg",{viewBox:`0 0 ${t.width} ${t.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:t.boxes.map((o,r)=>e.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 vi({pages:t,loading:n,page:o,onPageChange:r,renderOverlay:s}){const{t:l}=Y(),[a,p]=h.useState(0),c=o??a,d=x=>{r?r(x):p(x)};if(h.useEffect(()=>{o===void 0&&p(0)},[t,o]),n)return e.jsx("div",{className:"bim-rd-img-box",children:e.jsx("div",{className:"bim-rd-img-empty",children:l("reader.imagesLoading")})});if(!t||t.length===0)return e.jsx("div",{className:"bim-rd-img-box",children:e.jsxs("div",{className:"bim-rd-img-empty",children:[e.jsx("div",{className:"bim-rd-img-frame","aria-hidden":"true"}),e.jsx("b",{children:l("reader.noImages")}),e.jsx("span",{children:l("reader.noImagesHint")})]})});const u=Math.max(0,Math.min(t.length-1,c)),g=t[u],m=g.label??`${u+1}`;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-rd-img-box",children:e.jsxs("figure",{className:"bim-rd-img-fig",children:[e.jsx("img",{src:g.url,alt:g.alt??l("reader.imageAlt",{label:m}),width:g.width,height:g.height,loading:"lazy",decoding:"async"}),e.jsx(Np,{page:g}),s==null?void 0:s(g,u)]})}),t.length>1&&e.jsxs("div",{className:"bim-rd-img-pager",children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.prevImage"),disabled:u===0,onClick:()=>d(u-1),children:"‹"}),e.jsx("span",{"aria-live":"polite",children:g.label??`${u+1} / ${t.length}`}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.nextImage"),disabled:u===t.length-1,onClick:()=>d(u+1),children:"›"})]})]})}const Xi={fontSize:null,readingMode:"line",properNames:!1,writingMode:"horizontal",workLinks:!0},gt=[15,16,17,18,20,22,24],ki=18,nl="bim-reader-prefs",Ip="bim-reading-mode";function Rp(){const t={...Xi};try{const n=localStorage.getItem(nl),o=n?JSON.parse(n):{};typeof o.fontSize=="number"&&gt.includes(o.fontSize)&&(t.fontSize=o.fontSize),(o.readingMode??localStorage.getItem(Ip))==="paragraph"&&(t.readingMode="paragraph"),o.properNames===!0&&(t.properNames=!0),o.writingMode==="vertical"&&(t.writingMode="vertical"),o.workLinks===!1&&(t.workLinks=!1)}catch{}return t}function Ep(t){try{localStorage.setItem(nl,JSON.stringify(t))}catch{}}function yn(t,n){const o=t??ki,r=gt;let s=r.indexOf(o);return s<0&&(s=r.indexOf(ki)),r[Math.max(0,Math.min(r.length-1,s+n))]}function il(){const[t,n]=h.useState(Xi);h.useEffect(()=>{n(Rp())},[]);const o=h.useCallback(r=>{n(s=>{const l={...s,...r};return Ep(l),l})},[]);return[t,o]}function wi(t){if(t.optionLabel)return t.optionLabel;const n=t.label||t.key;return!t.sourceName||n.includes(t.sourceName)?n:`${n} · ${t.sourceName}`}function ol(t,n){if(!(!t||t.length===0))return(n!=null?t.find(o=>o.key===n):void 0)??t.find(o=>o.primary)??t[0]}function rl(t){const n=[],o=r=>{for(const s of r)s.children&&s.children.length>0?o(s.children):n.push(s)};return o(t),n}const sr=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:e.jsx("path",{d:"M4 6h16M4 12h10M4 18h16"})}),Lp=()=>e.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:e.jsx("path",{d:"M15 5l-7 7 7 7"})}),Pp=()=>e.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:e.jsx("path",{d:"M9 5l7 7-7 7"})}),lr=()=>e.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:[e.jsx("rect",{x:"4",y:"3",width:"16",height:"18",rx:"1.5"}),e.jsx("path",{d:"M9 3v18M13 7v10M16.5 7v10"})]});function ar(t,n){if(!n)return;const o=Array.from(n.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(a=>a.tabIndex>=0);if(o.length===0)return;const r=o[0],s=o[o.length-1],l=document.activeElement;t.shiftKey&&(l===r||!n.contains(l))?(t.preventDefault(),s.focus()):!t.shiftKey&&(l===s||!n.contains(l))&&(t.preventDefault(),r.focus())}function cr(t,n){const[o,r]=h.useState(n);return h.useEffect(()=>{var a;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(t);r(s.matches);const l=()=>r(s.matches);return(a=s.addEventListener)==null||a.call(s,"change",l),()=>{var p;return(p=s.removeEventListener)==null?void 0:p.call(s,"change",l)}},[t]),o}function Ap(){const t=h.useContext(It),{t:n}=Y();if(!t)return null;const o=t.locale==="zh-Hant";return e.jsxs("button",{type:"button",className:"bim-rd-t",title:n(o?"common.toHans":"common.toHant"),"aria-label":n(o?"common.toHans":"common.toHant"),onClick:()=>t.setLocale(o?"zh-Hans":"zh-Hant"),children:[e.jsx("span",{className:o?"bim-rd-on":"bim-rd-off",children:n("common.localeShortHant")}),e.jsx("span",{className:"bim-rd-off",children:"|"}),e.jsx("span",{className:o?"bim-rd-off":"bim-rd-on",children:n("common.localeShortHans")})]})}function Bp(t,n){if(!t)return;let o;for(const r of Array.from(t.querySelectorAll('[id^="rd-e-"]')))if(r.getBoundingClientRect().top<=n+8)o=r.id;else break;return o}function Mp(t){var l;if(typeof window>"u"||!t)return;const n=(l=window.getSelection)==null?void 0:l.call(window);if(!n||n.isCollapsed||n.rangeCount===0)return;const o=t.querySelector(".bim-rd-col"),r=a=>{const p=(a==null?void 0:a.nodeType)===1?a:a==null?void 0:a.parentElement;return!!a&&!!(o!=null&&o.contains(a))&&!(p!=null&&p.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 sl({title:t,subtitle:n,toc:o,activeKey:r,onSelect:s,tocHeader:l,tocCaption:a,images:p,imagesLoading:c,renderImageOverlay:d,imagePanel:u="auto",prefs:g,onPrefsChange:m,paragraphToggle:x,properNameToggle:f=!0,allowVertical:k,byline:b,current:w,workLinkToggle:y,rail:j,onReportError:S,revisedAt:v,backHref:$,backLabel:C,bottomBar:z=!0,pager:E=!0,pagerUnit:T,versions:_,currentVersionKey:O,onVersionChange:W,versionSource:A=!0,keepChapterOnVersionChange:G=!1,children:V,className:ie,style:ae}){const{t:P,convert:I}=Y(),q=C??P("reader.back"),Q=I(T??P("reader.unitJuan")),oe=h.useId().replace(/:/g,""),je=`bim-rd-toc-${oe}`,Ie=`bim-rd-text-${oe}`,K=h.useRef(null),me=h.useRef(null),M=h.useRef(null),ue=h.useRef(null),ge=cr(Zs,!0),de=cr(Xs,!1),Le=z&&de,[Me,Ee]=h.useState(null),ze=h.useRef(null),He=h.useRef(null),D=(B,ye)=>{He.current=ye,Ee(Ce=>Ce===B?null:B)},re=h.useCallback(()=>{var B;Ee(null),(B=He.current)==null||B.focus()},[]);h.useEffect(()=>{Le||Ee(null)},[Le]),h.useEffect(()=>{var B,ye;Me&&((ye=(B=ze.current)==null?void 0:B.querySelector("button:not([disabled])"))==null||ye.focus())},[Me]);const[ce,we]=h.useState("auto"),F=ce==="auto"?ge:ce==="open",fe=!ge,Re=!!p&&p.length>0,[R,ee]=h.useState(u);h.useEffect(()=>{ee(u)},[u]);const he=R==="auto"?Re||!!c:R==="open",L=h.useCallback(B=>{var ye;we("auto"),B&&((ye=ue.current)==null||ye.focus())},[]),X=()=>we(F?"closed":"open");h.useEffect(()=>{if(!fe||ce!=="open")return;const B=M.current,ye=B==null?void 0:B.querySelector('input, [data-rd-toc-key][tabindex="0"]');ye==null||ye.focus()},[fe,ce]);const U=h.useCallback(B=>{s(B),fe&&L(!1);const ye=me.current,Ce=K.current;if(ye&&Ce&&typeof window<"u"){const ve=ye.getBoundingClientRect().top-Ce.getBoundingClientRect().bottom;ve<0&&window.scrollBy({top:ve})}},[s,fe,L]),se=h.useMemo(()=>rl(o),[o]),[Se,Pe]=h.useState(null),$e=ol(_,O!==void 0?O:Se),Fe=($e==null?void 0:$e.key)??null,De=h.useMemo(()=>se.map(B=>B.key).join(`
519
+ `),[se]),Z=h.useRef(null),Ae=B=>{B!==Fe&&(G||(Z.current={key:B,sig:De,done:!1}),O===void 0&&Pe(B),W==null||W(B))};h.useEffect(()=>{const B=Z.current;if(!B||B.key!==Fe)return;const ye=se.find(ve=>!ve.disabled);if(!ye)return;const Ce=De!==B.sig;!Ce&&B.done||(Ce?Z.current=null:B.done=!0,ye.key!==r&&U(ye.key))},[Fe,De,se,r,U]);const N=se.find(B=>B.key===r),J=()=>{var B;S==null||S({chapterKey:r,chapterLabel:typeof(N==null?void 0:N.label)=="string"?N.label:void 0,anchor:Bp(me.current,((B=K.current)==null?void 0:B.getBoundingClientRect().bottom)??0),selectedText:Mp(me.current)})},le=se.findIndex(B=>B.key===r),te=le>0?se.slice(0,le).reverse().find(B=>!B.disabled):void 0,pe=le>=0?se.slice(le+1).find(B=>!B.disabled):void 0,_e=g.fontSize??ki,H={...ae,...g.fontSize?{"--bimrd-fs":`${g.fontSize}px`}:null};return e.jsxs("div",{className:["bim-rd",g.writingMode==="vertical"&&k?"bim-rd-vertical":"",ie].filter(Boolean).join(" "),"data-toc":ce,"data-img":he?"open":"closed","data-bb":Le?"":void 0,style:H,children:[e.jsx("style",{children:Qs}),e.jsx("a",{className:"bim-rd-skip",href:`#${Ie}`,onClick:B=>{var ye,Ce,ve;B.preventDefault(),(ye=me.current)==null||ye.focus(),(ve=(Ce=me.current)==null?void 0:Ce.scrollIntoView)==null||ve.call(Ce,{block:"start"})},children:P("reader.skipToText")}),e.jsxs("div",{className:"bim-rd-bar",ref:K,children:[$&&e.jsxs("a",{className:"bim-rd-back",href:$,"aria-label":P("reader.backAria",{label:q}),children:[e.jsx("span",{"aria-hidden":"true",children:"‹"}),e.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:q})]}),(t||n||b||w)&&e.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[t&&e.jsx("b",{children:t}),b&&e.jsx("span",{className:"bim-rd-by",children:b}),w&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),e.jsx("span",{className:"bim-rd-cur",children:w})]}),n&&e.jsx("span",{children:n})]}),e.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":P("reader.settings"),children:[_&&_.length>1&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"bim-rd-ver",title:$e?I(wi($e)):void 0,children:[e.jsx("span",{className:"bim-rd-tlabel",children:P("reader.version")}),e.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:P("reader.versionShort")}),e.jsx("select",{"aria-label":P("reader.version"),value:Fe??"",onChange:B=>Ae(B.target.value),children:_.map(B=>e.jsx("option",{value:B.key,children:I(wi(B))},B.key))})]}),e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),E&&(te||pe)&&e.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":P("reader.pagerGroup",{unit:Q}),children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":P("reader.prevUnit",{unit:Q}),title:te?typeof te.label=="string"&&te.label?P("reader.prevUnitTitle",{unit:Q,label:te.label}):P("reader.prevUnit",{unit:Q}):P("reader.firstUnit",{unit:Q}),disabled:!te,onClick:()=>te&&U(te.key),children:e.jsx(Lp,{})}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":P("reader.nextUnit",{unit:Q}),title:pe?typeof pe.label=="string"&&pe.label?P("reader.nextUnitTitle",{unit:Q,label:pe.label}):P("reader.nextUnit",{unit:Q}):P("reader.lastUnit",{unit:Q}),disabled:!pe,onClick:()=>pe&&U(pe.key),children:e.jsx(Pp,{})})]}),E&&(te||pe)&&e.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),e.jsxs("button",{ref:ue,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":F,"aria-controls":je,onClick:X,children:[e.jsx(sr,{}),e.jsx("span",{className:"bim-rd-tlabel",children:P("reader.toc")})]}),e.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":he,onClick:()=>ee(he?"closed":"open"),children:[e.jsx(lr,{}),P("reader.images")]}),e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),e.jsx(Ap,{}),e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),e.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":P("reader.fontSmaller"),disabled:_e<=gt[0],onClick:()=>m({fontSize:yn(g.fontSize,-1)}),children:"A−"}),e.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":P("reader.fontLarger"),disabled:_e>=gt[gt.length-1],onClick:()=>m({fontSize:yn(g.fontSize,1)}),children:"A+"}),(x||f||k)&&e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),x&&e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":g.readingMode==="paragraph",title:P("reader.paragraphTitle"),onClick:()=>m({readingMode:g.readingMode==="paragraph"?"line":"paragraph"}),children:P("reader.paragraph")}),y&&e.jsxs("label",{className:"bim-rd-t bim-rd-chk",children:[e.jsx("input",{type:"checkbox",checked:g.workLinks,onChange:B=>m({workLinks:B.target.checked})}),e.jsx("span",{children:P("reader.workLinks")})]}),f&&e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":g.properNames,title:P("reader.properNameTitle"),onClick:()=>m({properNames:!g.properNames}),children:P("reader.properName")}),k&&e.jsx("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":g.writingMode==="vertical",onClick:()=>m({writingMode:g.writingMode==="vertical"?"horizontal":"vertical"}),children:P("reader.vertical")})]})]}),e.jsxs("div",{className:"bim-rd-body",children:[e.jsxs("div",{className:"bim-rd-toc",id:je,ref:M,role:fe&&F?"dialog":void 0,"aria-modal":fe&&F?!0:void 0,"aria-label":fe&&F?P("reader.toc"):void 0,onKeyDown:B=>{if(!(!fe||!F)){if(B.key==="Escape"){B.stopPropagation(),L(!0);return}B.key==="Tab"&&ar(B,M.current)}},children:[e.jsxs("div",{className:"bim-rd-toc-top",children:[e.jsxs("div",{className:"bim-rd-toc-head",children:[e.jsx("span",{children:a??P("reader.toc")}),fe&&e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":P("reader.closeToc"),onClick:()=>L(!0),children:"✕"})]}),l]}),e.jsx(tl,{items:o,activeKey:r,onSelect:U})]}),e.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>L(!0)}),e.jsx("aside",{className:"bim-rd-img","aria-label":P("reader.images"),children:he&&e.jsx(vi,{pages:p??null,loading:c,renderOverlay:d})}),e.jsxs("div",{className:"bim-rd-text",id:Ie,ref:me,tabIndex:-1,"data-rail":j||S?"true":void 0,children:[e.jsxs("div",{className:"bim-rd-col",children:[V,A&&$e&&($e.sourceName||$e.license)&&e.jsxs("p",{className:"bim-rd-src","data-version":$e.key,children:[$e.sourceName&&e.jsxs(e.Fragment,{children:[P("reader.sourceLabel")," ",$e.sourceUrl?e.jsx("a",{className:"bim-rd-link",href:$e.sourceUrl,target:"_blank",rel:"noreferrer",children:I($e.sourceName)}):I($e.sourceName)]}),$e.sourceName&&$e.license&&e.jsx("span",{className:"bim-rd-dot"}),$e.license&&e.jsx(e.Fragment,{children:P("reader.licenseOf",{license:$e.license})})]}),v&&e.jsx("p",{className:"bim-rd-src bim-rd-rev",children:P("reader.revisedAt",{date:v})}),S&&e.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:e.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:B=>B.preventDefault(),onClick:J,children:P("reader.reportError")})}),E&&(te||pe)&&e.jsxs("nav",{className:"bim-rd-pager","aria-label":P("reader.pagerNav"),children:[te?e.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>U(te.key),children:[e.jsxs("span",{className:"bim-rd-pgcap",children:[e.jsx("span",{"aria-hidden":"true",children:"← "}),P("reader.prevUnit",{unit:Q})]}),e.jsx("span",{className:"bim-rd-pglabel",children:te.label})]}):e.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",P("reader.firstUnit",{unit:Q})]}),pe?e.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>U(pe.key),children:[e.jsxs("span",{className:"bim-rd-pgcap",children:[P("reader.nextUnit",{unit:Q}),e.jsx("span",{"aria-hidden":"true",children:" →"})]}),e.jsx("span",{className:"bim-rd-pglabel",children:pe.label})]}):e.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[P("reader.lastUnit",{unit:Q})," →"]})]})]}),(j||S)&&e.jsxs("aside",{className:"bim-rd-rail","aria-label":P("reader.rail"),children:[j,S&&e.jsx("div",{className:"bim-rd-rail-acts",children:e.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:B=>B.preventDefault(),onClick:J,children:P("reader.reportError")})})]})]})]}),Le&&e.jsxs("nav",{className:"bim-rd-bb","aria-label":P("reader.bottomBar"),children:[e.jsxs("button",{type:"button","aria-expanded":F,"aria-controls":je,onClick:()=>{Ee(null),X()},children:[e.jsx(sr,{}),e.jsx("span",{children:P("reader.tocShort")})]}),e.jsxs("button",{type:"button","aria-expanded":Me==="img","aria-haspopup":"dialog",onClick:B=>D("img",B.currentTarget),children:[e.jsx(lr,{}),e.jsx("span",{children:P("reader.images")})]}),e.jsxs("button",{type:"button","aria-expanded":Me==="fs","aria-haspopup":"dialog",onClick:B=>D("fs",B.currentTarget),children:[e.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"A"}),e.jsx("span",{children:P("reader.fontSize")})]}),S&&e.jsxs("button",{type:"button",onMouseDown:B=>B.preventDefault(),onClick:()=>{Ee(null),J()},children:[e.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),e.jsx("span",{children:P("reader.reportError")})]})]}),Le&&Me&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:re}),e.jsxs("div",{className:"bim-rd-sheet",ref:ze,role:"dialog","aria-modal":"true","aria-label":P(Me==="img"?"reader.images":"reader.fontSize"),onKeyDown:B=>{if(B.key==="Escape"){B.stopPropagation(),re();return}B.key==="Tab"&&ar(B,ze.current)},children:[e.jsxs("div",{className:"bim-rd-sheet-head",children:[e.jsx("span",{children:P(Me==="img"?"reader.images":"reader.fontSize")}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":P("reader.close"),onClick:re,children:"✕"})]}),Me==="img"?e.jsx("div",{className:"bim-rd-sheet-img",children:e.jsx(vi,{pages:p??null,loading:c,renderOverlay:d})}):e.jsxs("div",{className:"bim-rd-sheet-fs",children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":P("reader.fontSmaller"),disabled:_e<=gt[0],onClick:()=>m({fontSize:yn(g.fontSize,-1)}),children:"A−"}),e.jsxs("output",{"aria-live":"polite",children:[_e,"px"]}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":P("reader.fontLarger"),disabled:_e>=gt[gt.length-1],onClick:()=>m({fontSize:yn(g.fontSize,1)}),children:"A+"})]})]})]})]})}const ll=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],Wp={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function Ke(t){return Wp[t]??t}const Wt=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],Ht={熹平: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},al={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function Hn(t){const n=t.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 Hp(t){return t>=1950?"":t>=1912?"民國":t>=1645?"清":t>=1368?"明":t>=1279?"元":t>=960?"宋":t>=907?"五代":t>=618?"唐":t>=581?"隋":t>=420?"南北朝":t>=265?"晉":t>=220?"三國":t>=-202?"漢":""}const Op=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,dr={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function Qi(t){const n=t.trim().replace(/[代朝]$/,"");for(const s of Object.keys(dr))if(n.startsWith(s))return dr[s];const o=Ke(n);if($t[o]!=null)return o;const r=xt(n);if(r&&n.length<=r.length+1)return Ke(r)}function St(t,n){if(n){const o=al[`${n}|${t}`];if(o!=null)return o}return Ht[t]}const Fp=1911;function Dp(t){const n=Ht[t];if(n==null)return;const o=ut[t];let r;for(const[s,l]of Object.entries(Ht))ut[s]===o&&l>n&&(r==null||l<r)&&(r=l);return r!=null?r-1:void 0}const Up={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function Cn(t){if(!t)return;if(/^\d+$/.test(t))return parseInt(t,10);let n=0,o=0,r=!1;for(const l of t){const a=Up[l];if(a===void 0)return;r=!0,l==="十"?o=(o||1)*10:l==="廿"||l==="卅"?(n+=a,o=0):o>=10?(n+=o+a,o=0):o=o*10+a}const s=n+o;return r&&s>0?s:void 0}function xt(t){for(const n of ll)if(t.startsWith(n))return n}const ut={};{const t=(n,o)=>{for(const r of o)ut[r]=n};t("東漢",["熹平","建安"]),t("三國",["黃初","正始"]),t("五代",["廣政"]),t("西晉",["太康"]),t("東晉",["永和"]),t("隋",["開皇"]),t("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),t("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),t("金",["大定","明昌"]),t("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),t("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),t("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),t("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function _t(t,n){const o=n==="北宋"||n==="南宋"?"宋":n;for(const r of Object.keys(Ht))if(t.includes(r)&&!(o&&ut[r]&&ut[r]!==o&&al[`${o}|${r}`]==null))return r}function dn(t){var a,p,c;const n={era:"",reign:"",source:"none"},o=t.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=(a=t.lineage)==null?void 0:a.year_text;if(r){const d=xt(r)??"";return{era:Ke(d),reign:_t(r,d)??"",source:"lineage"}}const s=(p=t.publication_info)==null?void 0:p.year;if(s){const d=Hn(s);if(d)return{era:Hp(d.from),reign:"",source:"publication"};const u=xt(s)??Qi(s)??((c=Wt.find(x=>x.pattern.test(s)))==null?void 0:c.era)??"",g=_t(s,u)??"",m=u||(g?ut[g]??"":"");if(m||g)return{era:Ke(m),reign:g,source:"publication"}}const l=t.edition||t.title||"";if(l){const d=xt(l);if(d)return{era:Ke(d),reign:_t(l,d)??"",source:"edition"};const u=Wt.find(g=>g.pattern.test(l));if(u)return{era:Ke(u.era),reign:_t(l,u.era)??u.reign??"",source:"edition"}}return n}function On(t){var r,s,l,a,p,c,d,u,g;if(((r=t.dating)==null?void 0:r.year)!=null)return t.dating.year;if(typeof((s=t.lineage)==null?void 0:s.year)=="number")return t.lineage.year;const n=(l=t.publication_info)==null?void 0:l.year;if(n){const m=Hn(n);if(m)return m.from}const o=[(a=t.lineage)==null?void 0:a.year_text,(p=t.publication_info)==null?void 0:p.year,t.edition,t.edition?void 0:t.title].filter(Boolean);for(const m of o){const x=((c=t.publication_info)==null?void 0:c.year)||((d=t.lineage)==null?void 0:d.year_text);if(x&&m!==x&&(xt(x)||Qi(x)))break;const f=m.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??m.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(f){const j=parseInt(f[1],10);if(j>=100&&j<=2100)return j}const k=m.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(k){const j=xt(m);if(!j||Ke(j)==="民國"){const v=Cn(k[1]);if(v!=null&&v>=1&&v<=120)return Fp+v}}const b=xt(m)??((u=Wt.find(j=>j.pattern.test(m)))==null?void 0:u.era),w=b?Ke(b):void 0,y=_t(m,w)??(xt(m)||(g=Wt.find(j=>j.pattern.test(m)))==null?void 0:g.reign);if(y){const j=St(y,w);if(j==null)continue;const S=m.indexOf(y),v=S>=0?m.slice(S+y.length):"",$=v.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??v.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),C=$?Cn($[1]):void 0;return j+(C?C-1:0)}}}function eo(t){var a,p,c,d,u,g;const n=(a=t.dating)==null?void 0:a.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const o=(p=t.lineage)==null?void 0:p.year_range;if(o&&o.length===2)return{from:o[0],to:o[1]};const r=(c=t.lineage)==null?void 0:c.year_text;if(r){const m=r.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(m){const x=Si[Ke(m[1])],f=$t[Ke(m[2])];if(x!=null&&f!=null)return{from:Math.min(x,f)-20,to:Math.max(x,f)+40}}}const s=(d=t.publication_info)==null?void 0:d.year;if(s){const m=Hn(s);if((m==null?void 0:m.to)!=null)return{from:m.from,to:m.to};const x=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(x){const f=Si[Ke(x[1])],k=$t[Ke(x[2])];if(f!=null&&k!=null)return{from:Math.min(f,k)-20,to:Math.max(f,k)+40}}}const l=[(u=t.publication_info)==null?void 0:u.year,t.edition,t.title].filter(Boolean);for(const m of l){if(!/[間间]/.test(m))continue;const x=xt(m)??Qi(m)??((g=Wt.find(b=>b.pattern.test(m)))==null?void 0:g.era),f=x?Ke(x):void 0,k=[];for(const b of Object.keys(Ht))m.includes(b)&&(f&&ut[b]&&ut[b]!==f||St(b,f)!=null&&k.push(b));if(k.length===0){const b=m.match(/([一-鿿])([一-鿿])[間间]/);if(b&&f){for(const w of[b[1],b[2]])for(const y of Object.keys(Ht))if(ut[y]===f&&!(y[0]!==w&&y[y.length-1]!==w)&&St(y,f)!=null){k.push(y);break}}}if(k.length>0){const b=k.map(S=>St(S,f)).filter(S=>S!=null),w=Math.min(...b),y=k.reduce((S,v)=>St(S,f)>=St(v,f)?S:v),j=Dp(y)??li(f??"")??Math.max(...b);return{from:w,to:j>w?j:li(f??ut[y]??"")??w}}if(f&&$t[f]!=null)return{from:$t[f],to:li(f)??$t[f]}}}const $t={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},Vp=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],Gp=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,pr=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function ur(t,n){for(const o of ll){const r=t.indexOf(o);if(r<0)continue;if(o.length===1){const c=t[r+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!_t(t.slice(r),Ke(o)))continue}const s=Ke(o);if(s===n)continue;const l=t.slice(r),a=_t(l,s)??"";let p;if(a){const c=St(a,s);if(c!=null){const u=l.slice(l.indexOf(a)+a.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),g=u?Cn(u[1]):void 0;p=c+(g?g-1:0)}}return{era:s,reign:a,year:p}}for(const o of Wt)if(o.pattern.test(t))return{era:Ke(o.era),reign:o.reign??""}}function Yp(t){var w,y,j,S,v;const n=dn(t),o=((w=t.publication_info)==null?void 0:w.year)??"",r=o?Hn(o):void 0;if(!n.era&&!n.reign&&!r)return;const s=t.edition||t.title||"",l=/[間间]/.test(s),a=((y=t.lineage)==null?void 0:y.year_text)??"",p=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(a),c=n.source==="publication"&&Op.test(o),d=n.source==="publication"&&/[間间]/.test(o),u=a.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let g;l||p||c||d?g=void 0:u?g=parseInt(u[2],10):g=On(t);const m=g==null?eo(t):void 0;let x;n.source==="publication"&&(c||pr.test(o))?x="uncertain":n.source==="lineage"||n.source==="publication"?x="attested":pr.test(s)||!n.reign&&g==null?x="uncertain":x="inferred";const f=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((j=t.lineage)==null?void 0:j.year_text)??((S=t.lineage)==null?void 0:S.year)??""}」`:`出版著錄「${((v=t.publication_info)==null?void 0:v.year)??""}」`,k={era:n.era,reign:n.reign,year:g,yearRange:m,certainty:x,source:n.source==="edition"?"edition":"catalog",basis:f};if(u){const $=a.match(/[、,,]\s*([宋元明清])/);$&&$[1]!==k.era&&(k.laterRepair={era:$[1]})}if(!k.laterRepair&&Gp.test(s)){const $=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);$&&$[1]!==n.era&&(k.laterRepair={era:$[1]})}const b=Vp.find($=>$.re.test(s));if(b){const $=s.search(b.re),C=s.slice($),z=ur(C,n.era)??ur(s,n.era);z&&(k.basedOn={era:z.era,reign:z.reign,year:z.year,relation:b.relation})}return k}const Si={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function li(t){return Si[t]}function zn(t){const n=On(t);if(n!=null)return n;const o=eo(t);if(o)return o.from;const r=dn(t).era;return r?$t[r]:void 0}const mr=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function $i(t){const n=mr.indexOf(t);return n===-1?mr.length:n}function Kp(t){const n={belongsTo:[],collected:[],contains:[],derivative:[],studies:[],related:[]};for(const s of t){const l=s.relation;l==="part_of"?n.belongsTo.push(s):l==="collected_in"?n.collected.push(s):l==="has_part"||l==="contains_text_of"?n.contains.push(s):l==="text_carried_by"||l==="studied_by"||l==="derived_from"||l==="followed_by"||l==="has_adaptation"?n.derivative.push(s):l==="studies"||l==="preceded_by"?n.studies.push(s):n.related.push(s)}const o=[],r=(s,l)=>{n[s].length&&o.push({key:s,labelKey:l,items:n[s]})};return r("belongsTo","belongsToWork"),r("collected","collectedIn"),r("contains","containedWorks"),r("derivative","derivativeWorks"),r("studies","studies"),r("related","relatedWorks"),o}function to(t,n){const o=Oi(t||[]),r=new Map,s=[];for(const d of o)d.group?(r.has(d.group)||r.set(d.group,[]),r.get(d.group).push(d)):s.push(d);for(const d of r.values())d.sort((u,g)=>{const m=x=>x.group_role==="origin"?0:x.group_role==="mirror"?1:2;return m(u)-m(g)});const l={text:[],image:[],textImage:[],physical:[]};for(const d of s){const u=Nt(d),g=u.includes("text"),m=u.includes("image");g&&m?l.textImage.push(d):g?l.text.push(d):m?l.image.push(d):l.physical.push(d)}const p=["text","image","textImage","physical"].filter(d=>l[d].length>0).map(d=>({key:d,items:l[d]})),c=[...r.entries()].map(([d,u])=>{var g,m;return{key:d,label:((g=n==null?void 0:n[d])==null?void 0:g.label)||d,description:(m=n==null?void 0:n[d])==null?void 0:m.description,items:u}});return{buckets:p,mirrors:c,total:o.length}}function Fn(t,n=Dt("zh-Hant")){const o=[],r=t.metadata||{};r.edition&&o.push(String(r.edition)),t.source_label&&o.push(t.source_label),t.details&&o.push(t.details);const s=Ln(t);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 cl(t,n){if(Fn(t)||n.filter(r=>r.name===t.name).length<2)return"";try{const r=new URL(t.url),s=r.searchParams.get("res")||r.searchParams.get("id");if(s)return s;const l=r.pathname.split("/").filter(Boolean).pop();if(l)return decodeURIComponent(l)}catch{}return""}function dl(t,n){var l,a;const o=t.resources||[],r=[],s=[];for(const p of o){const c=Nt(p);c.includes("image")&&r.push(p),c.includes("physical")&&s.push(p)}return{id:t.id,name:t.edition||t.title||t.id,era:dn(t),year:On(t),sortYear:zn(t),images:r,holders:s,locationName:(l=t.current_location)==null?void 0:l.name,important:qp(t.id,n),group:(a=n==null?void 0:n.node_groups)==null?void 0:a[t.id],hasImage:r.length>0}}function qp(t,n){var p,c;if(!n)return!1;const o=n.default_collection;if(!o)return!1;const r=(p=n.collections)==null?void 0:p[o];if(((r==null?void 0:r.book_ids)??(o==="core"?n.core_books??[]:[])).includes(t))return!0;const l=(r==null?void 0:r.groups)??[],a=(c=n.node_groups)==null?void 0:c[t];return!!a&&l.includes(a)}function pl(t,n,o={}){const r=new Set((n==null?void 0:n.excluded_books)??[]),s=t.filter(c=>!r.has(c.id)).map(c=>dl(c,n));let l=s;o.era&&(l=l.filter(c=>c.era.era===o.era)),o.scanOnly&&(l=l.filter(c=>c.hasImage)),o.sort==="year"?l=l.map((c,d)=>({r:c,i:d})).sort((c,d)=>{const u=c.r.sortYear,g=d.r.sortYear;return u!=null&&g!=null?u-g||c.i-d.i:u!=null?-1:g!=null?1:c.i-d.i}).map(c=>c.r):l=l.map((c,d)=>({r:c,i:d})).sort((c,d)=>{const u=g=>(g.important?0:1)*2+(g.hasImage?0:1);return u(c.r)-u(d.r)||c.i-d.i}).map(c=>c.r);const p=[...new Set(s.map(c=>c.era.era).filter(Boolean))].sort((c,d)=>$i(c)-$i(d));return{rows:l,allRows:s,eras:p,hasInferredEra:s.some(c=>c.era.source==="edition")}}function Zp(t,n){var b,w;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:t,groupedIds:[]};const o=(b=n.collections)==null?void 0:b[n.default_collection],r=(o==null?void 0:o.groups)??[],s=(o==null?void 0:o.book_ids)??[],l=r.length>0||s.length>0,a=!l&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!l&&a.length===0)return{useGrouping:!1,coreIds:t,groupedIds:[]};const p=new Set(r),c=new Set([...s,...a]),d=y=>{if(c.has(y))return!0;const j=n.node_groups[y];return j!=null&&p.has(j)},u=[],g=new Map,m=[];for(const y of t)if(!((w=n.excluded_books)!=null&&w.includes(y)))if(d(y))u.push(y);else{const j=n.node_groups[y];j?(g.has(j)||g.set(j,[]),g.get(j).push(y)):m.push(y)}if(m.length+[...g.values()].reduce((y,j)=>y+j.length,0)<3)return{useGrouping:!1,coreIds:t,groupedIds:[]};const f=new Map((n.groups??[]).map(y=>[y.id,y])),k=[...g.entries()].map(([y,j])=>{const S=f.get(y);return{id:y,label:(S==null?void 0:S.label)??y,description:S==null?void 0:S.description,ids:j}});return m.length>0&&k.push({id:"__other__",label:"其他版本",description:void 0,ids:m}),{useGrouping:!0,coreIds:u,groupedIds:k}}const ul=["撰","編","注","校","譯","繪","其他"],Jp=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function no(t){if(!t||!t.trim())return"撰";const n=t.replace(/[\s-]/g,"");if(!n||n==="author")return"撰";for(const{cls:o,re:r}of Jp)if(r.test(n))return o;return"其他"}function io(t){if(!t)return"";const n=t.trim();return!n||!/[一-鿿]/.test(n)?"":n}function ml(t,n="全部"){const o=new Map;for(const s of t){const l=no(s);o.set(l,(o.get(l)??0)+1)}const r=[{cls:"全部",label:n,count:t.length}];for(const s of ul){const l=o.get(s);l&&r.push({cls:s,label:s,count:l})}return r.length>2?r:[]}function gl(t,n,o){if(n&&n.books&&n.books.length>0){const s=n.books.map(a=>({id:a.work_id||a.book_id||void 0,title:a.title,section:a.section,volumes:a.volumes||[],subItems:a.sub_items,edition:a.edition,found:a.found_volumes,expected:a.expected_volumes})),l=[...new Set(s.map(a=>a.section).filter(Boolean))];return{rows:s,source:"catalog",sections:l,totalVolumes:n.total_volumes}}return t.contained_works&&t.contained_works.length>0?{rows:t.contained_works.map(l=>({id:l.id,title:l.title,volumes:sn(l.volume_index)})),source:"works",sections:[]}:{rows:(t.books||[]).map(s=>{var l,a;return{id:s,title:((l=o==null?void 0:o.get(s))==null?void 0:l.title)||s,edition:(a=o==null?void 0:o.get(s))==null?void 0:a.edition,volumes:[]}}),source:"books",sections:[]}}function sn(t){if(t==null)return[];if(typeof t=="number")return[t];if(Array.isArray(t))return t.filter(n=>typeof n=="number");if(typeof t=="string"){const n=t.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,l)=>o+l)}return t.split(/[,、]/).map(o=>parseInt(o.trim())).filter(o=>!isNaN(o))}return[]}function Dn(t,n="冊"){if(t.length===0)return"";if(t.length===1)return`${t[0]}`;const o=[...t].sort((l,a)=>l-a),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 Xp=["〇","一","二","三","四","五","六","七","八","九"],gr=["","十","百","千"];function hl(t){if(t<=0)return"";if(t>=1e4)return String(t);const n=String(t),o=n.length;let r="",s=!1;for(let l=0;l<o;l++){const a=parseInt(n[l]),p=o-1-l;a===0?s=!0:(s&&r&&(r+="〇"),s=!1,a===1&&p===1&&l===0?r+=gr[p]:r+=Xp[a]+gr[p])}return r}function Qp(t){return t==null?"":typeof t=="string"?t:t.title??""}function bt(t,n="卷"){var r,s;const o=t;return o.measure_info?o.measure_info:(r=o.juan_count)!=null&&r.number?hl(o.juan_count.number)+n:(s=o.juan_count)!=null&&s.description?o.juan_count.description:""}function xl(t){var r;if(t.edition_type)return t.edition_type;if((r=t.lineage)!=null&&r.category)return t.lineage.category;const n=t.edition||t.title||"",o=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,l]of o)if(s.test(n))return l;return""}const eu=216,hr="clamp(280px, 23vw, 360px)",tu=1440,_i="(max-width: 719px)",nu=`${_i}, (pointer: coarse)`,iu=`
520
520
  .bim-d-main.bim-d-main-grid { max-width: ${tu}px; padding: 16px 32px 0; }
521
521
  .bim-d-grid {
522
522
  display: grid;
@@ -996,7 +996,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
996
996
  :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 {
997
997
  text-decoration-color: currentColor; text-decoration-thickness: 2px;
998
998
  }
999
- `;function pn({railTop:t,back:n,up:o,nav:r,railLinks:s,main:l,card:a,side:p}){const{t:c,convert:d}=G(),u=(r||[]).filter(Boolean);return e.jsxs("div",{className:"bim-d-grid",children:[e.jsxs("aside",{className:"bim-d-g-rail bim-d-ui",children:[t,n&&e.jsx("div",{style:{marginTop:t?12:0},children:n}),o,u.length>1&&e.jsxs("nav",{className:"bim-d-rail-navwrap","aria-label":c("detail.pageNav"),style:{marginTop:20},children:[e.jsx("p",{className:"bim-d-rail-cap",style:{marginTop:0},children:c("detail.thisPage")}),e.jsx("ul",{className:"bim-d-rail-nav",children:u.map(g=>e.jsx("li",{children:e.jsxs("a",{href:`#${g.id}`,children:[e.jsx("span",{children:d(g.label)}),g.count!=null&&e.jsx("span",{className:"bim-d-meta",children:g.count})]})},g.id))})]}),s&&s.length>0&&e.jsxs("nav",{className:"bim-d-rail-links","aria-label":c("detail.more"),children:[e.jsx("p",{className:"bim-d-rail-cap",children:c("detail.more")}),e.jsx("ul",{className:"bim-d-rail-nav",children:s.map(g=>e.jsx("li",{children:e.jsxs("a",{href:g.href??"#",onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),g.onClick())},children:[e.jsx("span",{children:d(g.label)}),e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:"→"})]})},g.key))})]})]}),e.jsx("div",{className:"bim-d-g-main",children:l}),e.jsx("div",{className:"bim-d-g-card",children:a}),e.jsx("div",{className:"bim-d-g-side",children:p})]})}function fl({caption:t,children:n}){const{convert:o}=G();return e.jsxs("div",{className:"bim-d-up bim-d-ui",children:[e.jsx("span",{className:"bim-d-up-cap",children:o(t)}),n]})}function Ze({id:t,title:n,meta:o,action:r,children:s}){const{convert:l}=G();return e.jsxs("section",{id:t,className:"bim-d-sec",children:[e.jsxs("div",{className:"bim-d-sec-head bim-d-ui",children:[e.jsx("h2",{children:l(n)}),o!=null&&o!==""&&e.jsx("span",{className:"bim-d-meta",children:o}),r&&e.jsx("span",{className:"bim-d-sec-act",children:r})]}),e.jsx("div",{className:"bim-d-sec-body",children:s})]})}function qe({items:t,className:n,style:o}){const r=t.filter(s=>s!=null&&s!==""&&s!==!1);return r.length?e.jsx("span",{className:`bim-d-meta${n?` ${n}`:""}`,style:o,children:r.map((s,l)=>e.jsxs(x.Fragment,{children:[l>0&&e.jsx("span",{className:"bim-d-dot"}),e.jsx("span",{children:s})]},l))}):null}function Un({items:t,value:n,onChange:o}){const{convert:r}=G();return e.jsx(e.Fragment,{children:t.map(s=>e.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 bl({label:t,checked:n,onChange:o}){const{convert:r}=G();return e.jsxs("label",{className:"bim-d-check",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:s=>o(s.target.checked)}),r(t)]})}const yl=6,Vn=t=>t>yl+1;function oo({total:t,shown:n,unit:o,onClick:r}){const{t:s,convert:l}=G(),a=t-n,p=Vn(t)?t-Math.min(n,yl):a;return p<=0?null:e.jsxs("button",{type:"button",className:`bim-d-more bim-d-ui${a>0?"":" bim-d-more-ncap"}`,onClick:r,children:[a>0&&e.jsx("span",{className:"bim-d-more-w",children:s("detail.expandRest",{n:a,unit:l(o)})}),e.jsx("span",{className:"bim-d-more-n",children:s("detail.expandRest",{n:p,unit:l(o)})})]})}function ro({label:t,onClick:n}){const{convert:o}=G();return e.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:o(t)})}function un({kind:t,title:n,subtitle:o,byline:r,meta:s,description:l,clampDescription:a,facts:p,stats:c,readAction:d,secondaryAction:u,children:g,foot:m}){const{t:h,convert:f}=G(),v=(p||[]).filter(S=>S.value!=null&&S.value!==""),y=(c||[]).filter(S=>S.value!=null&&S.value!==""&&S.value!==0),[w,b]=x.useState(!1),j=!!a&&!w;return e.jsxs("div",{className:"bim-d-card",children:[t&&e.jsx("div",{className:"bim-d-card-kind bim-d-ui",children:f(t)}),e.jsx("h1",{className:typeof n=="string"&&[...n].length>7?"bim-d-card-long":void 0,children:n}),o&&e.jsx("div",{className:"bim-d-card-sub",children:o}),r&&e.jsx("p",{className:"bim-d-card-byline",style:{marginBottom:0},children:r}),s&&e.jsx("div",{className:"bim-d-card-cls bim-d-ui",children:s}),l&&e.jsx("div",{className:j?"bim-d-card-desc bim-d-clamp":"bim-d-card-desc",style:j?{"--detail-clamp":a}:void 0,children:l}),l&&!!a&&e.jsx("button",{type:"button",className:"bim-d-card-toggle bim-d-ui","aria-expanded":w,onClick:()=>b(S=>!S),children:h(w?"action.collapse":"action.expand")}),y.length>0&&e.jsx("div",{className:"bim-d-stats bim-d-ui",children:y.map((S,k)=>e.jsxs("div",{children:[e.jsx("b",{children:S.value}),e.jsx("span",{children:f(S.label)})]},k))}),v.length>0&&e.jsx("dl",{className:"bim-d-ui",children:v.map((S,k)=>e.jsxs(x.Fragment,{children:[e.jsx("dt",{children:f(S.label)}),e.jsx("dd",{title:S.title,children:S.value})]},k))}),g,d,u,m&&e.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:m})]})}function so(t){return!!t&&[...t.replace(/\s+/g,"")].length>110}function Ci({href:t,onClick:n,label:o}){const{t:r,convert:s}=G(),l=o??r("detail.read");return t?e.jsx("a",{className:"bim-d-btn",href:t,onClick:n?a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),n())}:void 0,children:s(l)}):e.jsx("button",{type:"button",className:"bim-d-btn",onClick:n,children:s(l)})}function zt({id:t,title:n,meta:o,items:r,metas:s,currentIndex:l,cap:a=8,moreLabel:p,foot:c,sub:d,timeline:u}){const{t:g,convert:m}=G(),[h,f]=x.useState(!1);if(!r.length)return null;const v=h?r:r.slice(0,a),y=r.length-v.length;return e.jsxs("div",{id:t,className:u?"bim-d-side bim-d-side-tl":"bim-d-side",style:{scrollMarginTop:16},children:[e.jsxs("h2",{className:"bim-d-ui bim-d-side-h",children:[m(n),o!=null&&o!==""&&e.jsx("span",{className:"bim-d-meta",children:o})]}),d&&e.jsx("p",{className:"bim-d-side-sub bim-d-ui",children:d}),e.jsx("ul",{children:v.map((w,b)=>e.jsxs("li",{className:b===l?"bim-d-side-cur":void 0,"aria-current":b===l?"page":void 0,children:[w,s!=null&&s[b]?e.jsx("span",{className:"bim-d-meta",style:{marginLeft:"auto"},children:s[b]}):null]},b))}),y>0&&e.jsx(ro,{label:p?p(y):g("detail.showMore",{n:y}),onClick:()=>f(!0)}),c&&e.jsx("p",{className:"bim-d-side-note bim-d-ui",children:c})]})}const ou=new Set(["reviewed","disputed","unreviewed","draft"]);function mn({revision:t,revisedAt:n,review:o,todo:r}){const{t:s,convert:l}=G(),a=o&&ou.has(o.status)?s(`detail.review.${o.status}`):void 0,p=o&&o.status!=="unreviewed"&&a?[a,o.by,o.date].filter(Boolean).join(" "):"",c=[t!=null&&t!==""?`${s("detail.dataVersion")} ${t}`:"",n??"",l(p)].filter(Boolean),d=(r||[]).filter(u=>u&&u.what);return!c.length&&!d.length?null:e.jsxs(e.Fragment,{children:[c.length>0&&e.jsx(qe,{items:c,style:{fontSize:12}}),d.length>0&&e.jsxs("details",{children:[e.jsx("summary",{children:s("detail.todoCount",{n:d.length})}),e.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:18,lineHeight:1.7},children:d.map((u,g)=>e.jsxs("li",{children:[l(u.what),(u.by||u.date)&&e.jsxs("span",{style:{marginLeft:6},children:["(",[u.by&&l(u.by),u.date].filter(Boolean).join(" · "),")"]})]},g))})]})]})}const wn=1e3,xr=208,ru=1440,su="(max-width: 719px)",jl=`
999
+ `;function pn({railTop:t,back:n,up:o,nav:r,railLinks:s,main:l,card:a,side:p}){const{t:c,convert:d}=Y(),u=(r||[]).filter(Boolean);return e.jsxs("div",{className:"bim-d-grid",children:[e.jsxs("aside",{className:"bim-d-g-rail bim-d-ui",children:[t,n&&e.jsx("div",{style:{marginTop:t?12:0},children:n}),o,u.length>1&&e.jsxs("nav",{className:"bim-d-rail-navwrap","aria-label":c("detail.pageNav"),style:{marginTop:20},children:[e.jsx("p",{className:"bim-d-rail-cap",style:{marginTop:0},children:c("detail.thisPage")}),e.jsx("ul",{className:"bim-d-rail-nav",children:u.map(g=>e.jsx("li",{children:e.jsxs("a",{href:`#${g.id}`,children:[e.jsx("span",{children:d(g.label)}),g.count!=null&&e.jsx("span",{className:"bim-d-meta",children:g.count})]})},g.id))})]}),s&&s.length>0&&e.jsxs("nav",{className:"bim-d-rail-links","aria-label":c("detail.more"),children:[e.jsx("p",{className:"bim-d-rail-cap",children:c("detail.more")}),e.jsx("ul",{className:"bim-d-rail-nav",children:s.map(g=>e.jsx("li",{children:e.jsxs("a",{href:g.href??"#",onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),g.onClick())},children:[e.jsx("span",{children:d(g.label)}),e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:"→"})]})},g.key))})]})]}),e.jsx("div",{className:"bim-d-g-main",children:l}),e.jsx("div",{className:"bim-d-g-card",children:a}),e.jsx("div",{className:"bim-d-g-side",children:p})]})}function fl({caption:t,children:n}){const{convert:o}=Y();return e.jsxs("div",{className:"bim-d-up bim-d-ui",children:[e.jsx("span",{className:"bim-d-up-cap",children:o(t)}),n]})}function Ze({id:t,title:n,meta:o,action:r,children:s}){const{convert:l}=Y();return e.jsxs("section",{id:t,className:"bim-d-sec",children:[e.jsxs("div",{className:"bim-d-sec-head bim-d-ui",children:[e.jsx("h2",{children:l(n)}),o!=null&&o!==""&&e.jsx("span",{className:"bim-d-meta",children:o}),r&&e.jsx("span",{className:"bim-d-sec-act",children:r})]}),e.jsx("div",{className:"bim-d-sec-body",children:s})]})}function qe({items:t,className:n,style:o}){const r=t.filter(s=>s!=null&&s!==""&&s!==!1);return r.length?e.jsx("span",{className:`bim-d-meta${n?` ${n}`:""}`,style:o,children:r.map((s,l)=>e.jsxs(h.Fragment,{children:[l>0&&e.jsx("span",{className:"bim-d-dot"}),e.jsx("span",{children:s})]},l))}):null}function Un({items:t,value:n,onChange:o}){const{convert:r}=Y();return e.jsx(e.Fragment,{children:t.map(s=>e.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 bl({label:t,checked:n,onChange:o}){const{convert:r}=Y();return e.jsxs("label",{className:"bim-d-check",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:s=>o(s.target.checked)}),r(t)]})}const yl=6,Vn=t=>t>yl+1;function oo({total:t,shown:n,unit:o,onClick:r}){const{t:s,convert:l}=Y(),a=t-n,p=Vn(t)?t-Math.min(n,yl):a;return p<=0?null:e.jsxs("button",{type:"button",className:`bim-d-more bim-d-ui${a>0?"":" bim-d-more-ncap"}`,onClick:r,children:[a>0&&e.jsx("span",{className:"bim-d-more-w",children:s("detail.expandRest",{n:a,unit:l(o)})}),e.jsx("span",{className:"bim-d-more-n",children:s("detail.expandRest",{n:p,unit:l(o)})})]})}function ro({label:t,onClick:n}){const{convert:o}=Y();return e.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:o(t)})}function un({kind:t,title:n,subtitle:o,byline:r,meta:s,description:l,clampDescription:a,facts:p,stats:c,readAction:d,secondaryAction:u,children:g,foot:m}){const{t:x,convert:f}=Y(),k=(p||[]).filter(S=>S.value!=null&&S.value!==""),b=(c||[]).filter(S=>S.value!=null&&S.value!==""&&S.value!==0),[w,y]=h.useState(!1),j=!!a&&!w;return e.jsxs("div",{className:"bim-d-card",children:[t&&e.jsx("div",{className:"bim-d-card-kind bim-d-ui",children:f(t)}),e.jsx("h1",{className:typeof n=="string"&&[...n].length>7?"bim-d-card-long":void 0,children:n}),o&&e.jsx("div",{className:"bim-d-card-sub",children:o}),r&&e.jsx("p",{className:"bim-d-card-byline",style:{marginBottom:0},children:r}),s&&e.jsx("div",{className:"bim-d-card-cls bim-d-ui",children:s}),l&&e.jsx("div",{className:j?"bim-d-card-desc bim-d-clamp":"bim-d-card-desc",style:j?{"--detail-clamp":a}:void 0,children:l}),l&&!!a&&e.jsx("button",{type:"button",className:"bim-d-card-toggle bim-d-ui","aria-expanded":w,onClick:()=>y(S=>!S),children:x(w?"action.collapse":"action.expand")}),b.length>0&&e.jsx("div",{className:"bim-d-stats bim-d-ui",children:b.map((S,v)=>e.jsxs("div",{children:[e.jsx("b",{children:S.value}),e.jsx("span",{children:f(S.label)})]},v))}),k.length>0&&e.jsx("dl",{className:"bim-d-ui",children:k.map((S,v)=>e.jsxs(h.Fragment,{children:[e.jsx("dt",{children:f(S.label)}),e.jsx("dd",{title:S.title,children:S.value})]},v))}),g,d,u,m&&e.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:m})]})}function so(t){return!!t&&[...t.replace(/\s+/g,"")].length>110}function Ci({href:t,onClick:n,label:o}){const{t:r,convert:s}=Y(),l=o??r("detail.read");return t?e.jsx("a",{className:"bim-d-btn",href:t,onClick:n?a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),n())}:void 0,children:s(l)}):e.jsx("button",{type:"button",className:"bim-d-btn",onClick:n,children:s(l)})}function zt({id:t,title:n,meta:o,items:r,metas:s,currentIndex:l,cap:a=8,moreLabel:p,foot:c,sub:d,timeline:u}){const{t:g,convert:m}=Y(),[x,f]=h.useState(!1);if(!r.length)return null;const k=x?r:r.slice(0,a),b=r.length-k.length;return e.jsxs("div",{id:t,className:u?"bim-d-side bim-d-side-tl":"bim-d-side",style:{scrollMarginTop:16},children:[e.jsxs("h2",{className:"bim-d-ui bim-d-side-h",children:[m(n),o!=null&&o!==""&&e.jsx("span",{className:"bim-d-meta",children:o})]}),d&&e.jsx("p",{className:"bim-d-side-sub bim-d-ui",children:d}),e.jsx("ul",{children:k.map((w,y)=>e.jsxs("li",{className:y===l?"bim-d-side-cur":void 0,"aria-current":y===l?"page":void 0,children:[w,s!=null&&s[y]?e.jsx("span",{className:"bim-d-meta",style:{marginLeft:"auto"},children:s[y]}):null]},y))}),b>0&&e.jsx(ro,{label:p?p(b):g("detail.showMore",{n:b}),onClick:()=>f(!0)}),c&&e.jsx("p",{className:"bim-d-side-note bim-d-ui",children:c})]})}const ou=new Set(["reviewed","disputed","unreviewed","draft"]);function mn({revision:t,revisedAt:n,review:o,todo:r}){const{t:s,convert:l}=Y(),a=o&&ou.has(o.status)?s(`detail.review.${o.status}`):void 0,p=o&&o.status!=="unreviewed"&&a?[a,o.by,o.date].filter(Boolean).join(" "):"",c=[t!=null&&t!==""?`${s("detail.dataVersion")} ${t}`:"",n??"",l(p)].filter(Boolean),d=(r||[]).filter(u=>u&&u.what);return!c.length&&!d.length?null:e.jsxs(e.Fragment,{children:[c.length>0&&e.jsx(qe,{items:c,style:{fontSize:12}}),d.length>0&&e.jsxs("details",{children:[e.jsx("summary",{children:s("detail.todoCount",{n:d.length})}),e.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:18,lineHeight:1.7},children:d.map((u,g)=>e.jsxs("li",{children:[l(u.what),(u.by||u.date)&&e.jsxs("span",{style:{marginLeft:6},children:["(",[u.by&&l(u.by),u.date].filter(Boolean).join(" · "),")"]})]},g))})]})]})}const wn=1e3,xr=208,ru=1440,su="(max-width: 719px)",jl=`
1000
1000
  .bim-d-page {
1001
1001
  background: ${i("page-bg")};
1002
1002
  color: ${i("ink")};
@@ -1091,22 +1091,22 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
1091
1091
  padding-right: 0; padding-bottom: 12px;
1092
1092
  }
1093
1093
  }
1094
- ${iu}`;function nn({children:t,style:n,wide:o,grid:r}){return e.jsxs("div",{className:"bim-d-page",style:n,children:[e.jsx("style",{children:jl}),e.jsx("div",{className:r?"bim-d-main bim-d-main-grid":o?"bim-d-main bim-d-main-wide":"bim-d-main",children:t})]})}function zi({breadcrumb:t,actions:n}){return e.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:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:t}),n&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:16},children:n})]})}function lo({char:t,tone:n="accent"}){return e.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:t})}function Ti({items:t}){const n=Ye();return e.jsx(e.Fragment,{children:t.map((o,r)=>{const s=r===t.length-1,l=r>0&&e.jsx("span",{style:{color:i("hint-fg")},children:"/"},`s${r}`),a=o.id?n(o.id):o.href,p=s||!o.onClick&&!a?e.jsx("span",{style:{color:i("ink")},children:o.label},r):e.jsx("a",{href:a??"#",onClick:o.onClick?c=>{c.metaKey||c.ctrlKey||(c.preventDefault(),o.onClick())}:void 0,style:{color:i("meta-fg")},children:o.label},r);return e.jsxs(x.Fragment,{children:[l,p]},r)})})}function vl({title:t,subtitle:n,aside:o,secondLine:r}){return e.jsxs("header",{style:{borderBottom:`2px solid ${i("rule-strong")}`,paddingBottom:18},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"flex-end",justifyContent:"space-between",gap:"10px 24px"},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"6px 14px",minWidth:0},children:[e.jsx("h1",{className:"bim-d-h1",style:{margin:0,fontSize:42,fontWeight:700,letterSpacing:".06em",lineHeight:1.1,wordBreak:"break-word"},children:t}),n&&e.jsx("span",{style:{fontSize:15,color:i("meta-fg"),letterSpacing:".06em"},children:n})]}),o&&e.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:i("label-fg"),letterSpacing:".06em"},children:o})]}),r&&e.jsx("div",{style:{marginTop:12,fontSize:13.5,color:i("quiet-fg")},children:r})]})}function lu({children:t,facts:n}){return!t&&n?e.jsx("div",{style:{padding:"20px 0 26px",borderBottom:`1px solid ${i("rule")}`,marginBottom:40},children:n}):e.jsxs("div",{className:"bim-d-intro",children:[e.jsx("div",{style:{minWidth:0},children:t}),n]})}function au({items:t,horizontal:n}){const{convert:o}=Te();return t.length?e.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:t.map((r,s)=>e.jsxs("div",{title:r.title,style:n?{display:"flex",flexDirection:"column",gap:3}:{display:"flex",justifyContent:"space-between",gap:10},children:[e.jsx("span",{className:"bim-d-ui",style:{color:i("label-fg"),letterSpacing:".08em",flex:"none"},children:o(r.label)}),e.jsx("span",{style:{color:i("body-fg"),textAlign:n?"left":"right",minWidth:0},children:r.value})]},s))}):null}function cu({glyph:t,tone:n,title:o,count:r,actions:s,id:l}){const{convert:a}=Te();return e.jsxs("div",{id:l,style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",justifyContent:"space-between",gap:"10px 16px",marginBottom:14,scrollMarginTop:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(lo,{char:t,tone:n}),e.jsx("h2",{style:{margin:0,fontSize:19,fontWeight:600,letterSpacing:".1em"},children:a(o)}),r!=null&&e.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:i("label-fg")},children:r})]}),s&&e.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:14,fontSize:12},children:s})]})}function kl({label:t,active:n,onClick:o,dashed:r}){const{convert:s}=Te();return e.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(t)})}function du({label:t,onClick:n}){const{convert:o}=Te();return e.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(t)})}function pu({label:t,onClick:n,inline:o}){const{convert:r}=Te();return e.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(t)})}function wl({children:t,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?e.jsx("a",{href:n??"#",title:r,onClick:o?l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),o())}:void 0,style:s,children:t}):e.jsx("span",{title:r,style:s,children:t})}function uu({children:t}){return e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:t})}function mu({volumes:t,unit:n,max:o=60}){const{t:r}=G(),s=n??r("unit.volume"),[l,a]=x.useState(!1);if(!t.length)return null;const p=l?t:t.slice(0,o);return e.jsxs("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,fontSize:11.5},children:[p.map(c=>e.jsx("span",{style:{minWidth:30,textAlign:"center",padding:"2px 5px",border:`1px solid ${i("rule")}`,color:i("meta-fg")},children:c},c)),!l&&t.length>o&&e.jsxs("button",{type:"button",onClick:()=>a(!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:["+",t.length-o]}),e.jsx("span",{style:{padding:"2px 6px",color:i("hint-fg")},children:s})]})}function gu({children:t}){return e.jsx("div",{style:{borderTop:`1px solid ${i("rule-strong")}`},children:t})}function hu({spec:t}){const{convert:n}=Te();return e.jsxs("div",{className:"bim-d-thead bim-d-ui",style:{display:"grid",gridTemplateColumns:`${t.leadWidth}px 1fr ${t.metaWidth}px`,gap:12,padding:"7px 4px",borderBottom:`1px solid ${i("rule-strong")}`,fontSize:11,color:i("label-fg"),letterSpacing:".1em"},children:[e.jsx("span",{}),e.jsx("span",{children:n(t.mainLabel)}),e.jsx("span",{style:{display:"grid",gridTemplateColumns:t.columns.map(o=>o.width).join(" "),gap:12},children:t.columns.map(o=>e.jsx("span",{children:n(o.label)},o.label))})]})}function xu({no:t,main:n,meta:o,spec:r}){return e.jsxs("div",{className:"bim-d-row",style:{gridTemplateColumns:`${r.leadWidth}px 1fr ${r.metaWidth}px`,gap:12},children:[e.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:i("hint-fg"),textAlign:"right"},children:t}),e.jsx("span",{style:{minWidth:0},children:n}),e.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 fu(t){return String(t+1).padStart(2,"0")}function bu(){return e.jsx("span",{style:{color:i("hint-fg")},children:"—"})}function yu({open:t,onToggle:n,main:o,action:r,children:s}){return e.jsxs("div",{style:{borderBottom:`1px solid ${i("rule")}`},children:[e.jsxs("div",{className:"bim-d-expand-head",style:{display:"grid",gridTemplateColumns:"26px 1fr auto",gap:12,alignItems:"baseline",padding:"9px 4px"},children:[e.jsx("button",{type:"button",onClick:n,"aria-expanded":t,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(t?"accent":"rule-dashed")}`,background:t?i("accent"):"transparent",color:i(t?"page-bg":"accent")},children:t?"-":"+"}),e.jsx("span",{style:{fontSize:14,minWidth:0},children:o}),r]}),t&&s&&e.jsx("div",{style:{padding:"2px 4px 14px 38px",borderLeft:`2px solid ${i("rule-accent-soft")}`,marginLeft:12},children:s})]})}function Sl(t){const n=[];for(let o=0;o<t.length;o++){const r=t[o];let s;if(r==="⟨")s="⟩";else if(r==="<"){const p=t[o+1];if(p===void 0||/[A-Za-z/!?>\s]/.test(p))continue;s=">"}else continue;const l=t.indexOf(s,o+1);if(l<0)continue;const a=t.slice(o+1,l);a.includes(`
1095
- `)||(n.push({start:o,end:l+1,inner:a}),o=l)}return n}function $l(t,n){if(t.length<=n)return t;let o=n;for(const r of Sl(t)){if(r.start>=o)break;if(r.end>o){o=r.start>0?r.start:r.end;break}}return t.slice(0,o)}const _l={fontSize:".78em",color:i("meta-fg"),lineHeight:1.55},ju={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 Cl(t,n,o,r){return t.map((s,l)=>{switch(s.type){case"text":return e.jsx(x.Fragment,{children:n(s.text)},l);case"jz":return e.jsx("span",{className:"bim-jiazhu",style:o===0?_l:void 0,children:Cl(s.children,n,o+1,r)},l);case"qw":return e.jsx("span",{className:"bim-qw guji-qw",title:s.label?r("detail.lacunaWith",{label:s.label}):r("detail.lacuna"),children:"□"},l);case"qz":return e.jsx("span",{className:"bim-qz guji-qz","data-guji-guess":s.guess,children:"□"},l);case"zi":return e.jsx("span",{className:"bim-zi guji-zi",title:r("detail.composedChar",{label:s.label}),style:ju,children:s.label},l)}})}function ot(t,n=r=>r,o){if(!t)return"";if(o!=null&&o.gujiMarkdown)return bp(t)?Cl(Fs(t),n,0,o.t??Dt("zh-Hant")):n(t);if(t.indexOf("⟨")<0&&t.indexOf("<")<0)return n(t);const r=[];let s=0,l=0;for(const a of Sl(t))a.start>s&&r.push(e.jsx(x.Fragment,{children:n(t.slice(s,a.start))},l++)),r.push(e.jsx("span",{className:"bim-jiazhu",style:_l,children:n(a.inner)},l++)),s=a.end;return s<t.length&&r.push(e.jsx(x.Fragment,{children:n(t.slice(s))},l++)),r}function vu({label:t,children:n}){return e.jsxs("div",{style:{marginBottom:10},children:[t&&e.jsx("div",{className:"bim-d-ui",style:{fontSize:11,fontWeight:600,letterSpacing:".1em",color:i("label-fg"),marginBottom:4},children:t}),e.jsx("div",{style:{fontSize:13.5,lineHeight:2,color:i("quiet-fg"),textAlign:"justify"},children:n})]})}function ku({title:t,tag:n,children:o}){const{convert:r}=Te();return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,paddingBottom:7,borderBottom:`1px solid ${i("rule-strong")}`,marginBottom:2},children:[e.jsx("span",{style:{fontSize:14.5,letterSpacing:".08em"},children:r(t)}),n&&e.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:i("accent"),letterSpacing:".06em"},children:r(n)})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:o})]})}function zl({name:t,note:n,href:o,extra:r}){const s=e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontSize:14,minWidth:0},children:t}),e.jsx("span",{className:"bim-d-ui",style:{fontSize:11,color:i("hint-fg"),flex:"none"},children:o?"↗":""}),n&&e.jsx("span",{className:"bim-d-ui",style:{gridColumn:"1 / -1",fontSize:11.5,color:i("label-fg")},children:n})]}),l={display:"grid",gridTemplateColumns:"1fr auto",gap:"4px 12px",padding:"9px 4px",borderBottom:`1px solid ${i("rule")}`,color:i("body-fg"),alignItems:"baseline"};return e.jsxs(e.Fragment,{children:[o?e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:l,children:s}):e.jsx("div",{style:l,children:s}),r]})}function wu({item:t,siblings:n,showVolumes:o=!0,fallbackNote:r}){const{t:s,convert:l}=G(),[a,p]=x.useState(!1),c=Ln(t),d=o&&!!c&&c.expected>0,u=(t.url?Ut(t.url):void 0)||l(t.name),g=n?cl(t,n):"",m=g?`${u}(${g})`:u;return e.jsx(zl,{name:m,note:Fn(t,s)||r,href:Vt(t),extra:d?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>p(h=>!h),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:a?s("detail.collapseVolumes"):s("detail.expandVolumes",{n:c.expected})}),a&&e.jsx(ao,{item:t})]}):void 0})}function ao({item:t}){return e.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,padding:"6px 0 10px",fontSize:11},children:(t.volumes||[]).map((n,o)=>{const r=n.status==="missing";return n.url&&!r?e.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):e.jsx("span",{style:{padding:"1px 5px",color:i(r?"missing-fg":"hint-fg"),textDecoration:r?"line-through":void 0},children:n.volume},o)})})}function Tl({label:t,items:n}){const{convert:o}=Te();return n.length?e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},children:[e.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:i("label-fg"),letterSpacing:".08em"},children:t}),n.map((r,s)=>e.jsx(wl,{children:o(r)},s))]}):null}function Su({rows:t}){const n=t.filter(o=>o.items.length>0);return n.length?e.jsx("div",{style:{marginTop:16,display:"flex",flexDirection:"column",gap:8},children:n.map(o=>e.jsx(Tl,{label:o.label,items:o.items},o.label))}):null}function Ni(t){return(t||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Nl({left:t,right:n}){return e.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:[e.jsx("span",{children:t}),n&&e.jsx("span",{style:{display:"flex",gap:16},children:n})]})}function $u({children:t,action:n}){return e.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:[e.jsx("span",{children:t}),n]})}function Ge({id:t,label:n,onNavigate:o,renderLink:r,style:s,dense:l}){const a=Ye();return r?e.jsx(e.Fragment,{children:r(t,typeof n=="string"?n:void 0,{dense:l})}):e.jsx("a",{href:a(t),onClick:o?p=>{p.metaKey||p.ctrlKey||(p.preventDefault(),o(t))}:void 0,style:s,children:n??t})}function _u({href:t,children:n}){return e.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:[n," ",e.jsx("span",{className:"bim-d-ui",style:{fontSize:11},children:"↗"})]})}const Cu={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},zu={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},Tu=`1px solid ${i("table-border")}`,Il={border:Tu,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},Nu={...Il,background:i("table-head-bg"),fontWeight:600};function co({table:t,opts:n}){return e.jsx("div",{className:"bim-guji-table-wrap",style:Cu,children:e.jsx("table",{className:"bim-guji-table",style:zu,children:e.jsx("tbody",{children:t.rows.map((o,r)=>e.jsx("tr",{children:o.cells.map((s,l)=>{const a=o.header?"th":"td";return e.jsx(a,{colSpan:s.colspan>1?s.colspan:void 0,rowSpan:s.rowspan>1?s.rowspan:void 0,style:o.header?Nu:Il,children:s.empty?null:ot(s.text,void 0,n)},l)})},r))})})})}function Iu(t,n){return t.indexOf("**")<0?ot(t,void 0,n):t.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((r,s)=>s%2===1?e.jsx("strong",{children:ot(r.trim().slice(2,-2),void 0,n)},s):e.jsx(x.Fragment,{children:ot(r,void 0,n)},s))}function Ru(t,n,o=!1){const r=o?{gujiMarkdown:!0}:void 0;return n?Zi(t).map((s,l)=>s.type==="table"?e.jsx(co,{table:s.table,opts:r},l):e.jsx(x.Fragment,{children:Iu(s.text,r)},l)):ot(t,void 0,r)}const Eu=/^(#{1,6})\s+(.*)$/,Lu=/^\*\*([^*\n]+)\*\*\s*$/;function po(t){const n=t.match(Eu);if(n)return{level:n[1].length,text:n[2].trim()};const o=t.trim().match(Lu);return o?{level:3,text:o[1].trim()}:null}const uo=/^<!--.*-->$/;function Rl(t){return t.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function El(t){return t.split(`
1094
+ ${iu}`;function nn({children:t,style:n,wide:o,grid:r}){return e.jsxs("div",{className:"bim-d-page",style:n,children:[e.jsx("style",{children:jl}),e.jsx("div",{className:r?"bim-d-main bim-d-main-grid":o?"bim-d-main bim-d-main-wide":"bim-d-main",children:t})]})}function zi({breadcrumb:t,actions:n}){return e.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:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:t}),n&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:16},children:n})]})}function lo({char:t,tone:n="accent"}){return e.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:t})}function Ti({items:t}){const n=Ye();return e.jsx(e.Fragment,{children:t.map((o,r)=>{const s=r===t.length-1,l=r>0&&e.jsx("span",{style:{color:i("hint-fg")},children:"/"},`s${r}`),a=o.id?n(o.id):o.href,p=s||!o.onClick&&!a?e.jsx("span",{style:{color:i("ink")},children:o.label},r):e.jsx("a",{href:a??"#",onClick:o.onClick?c=>{c.metaKey||c.ctrlKey||(c.preventDefault(),o.onClick())}:void 0,style:{color:i("meta-fg")},children:o.label},r);return e.jsxs(h.Fragment,{children:[l,p]},r)})})}function vl({title:t,subtitle:n,aside:o,secondLine:r}){return e.jsxs("header",{style:{borderBottom:`2px solid ${i("rule-strong")}`,paddingBottom:18},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"flex-end",justifyContent:"space-between",gap:"10px 24px"},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"6px 14px",minWidth:0},children:[e.jsx("h1",{className:"bim-d-h1",style:{margin:0,fontSize:42,fontWeight:700,letterSpacing:".06em",lineHeight:1.1,wordBreak:"break-word"},children:t}),n&&e.jsx("span",{style:{fontSize:15,color:i("meta-fg"),letterSpacing:".06em"},children:n})]}),o&&e.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:i("label-fg"),letterSpacing:".06em"},children:o})]}),r&&e.jsx("div",{style:{marginTop:12,fontSize:13.5,color:i("quiet-fg")},children:r})]})}function lu({children:t,facts:n}){return!t&&n?e.jsx("div",{style:{padding:"20px 0 26px",borderBottom:`1px solid ${i("rule")}`,marginBottom:40},children:n}):e.jsxs("div",{className:"bim-d-intro",children:[e.jsx("div",{style:{minWidth:0},children:t}),n]})}function au({items:t,horizontal:n}){const{convert:o}=Ne();return t.length?e.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:t.map((r,s)=>e.jsxs("div",{title:r.title,style:n?{display:"flex",flexDirection:"column",gap:3}:{display:"flex",justifyContent:"space-between",gap:10},children:[e.jsx("span",{className:"bim-d-ui",style:{color:i("label-fg"),letterSpacing:".08em",flex:"none"},children:o(r.label)}),e.jsx("span",{style:{color:i("body-fg"),textAlign:n?"left":"right",minWidth:0},children:r.value})]},s))}):null}function cu({glyph:t,tone:n,title:o,count:r,actions:s,id:l}){const{convert:a}=Ne();return e.jsxs("div",{id:l,style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",justifyContent:"space-between",gap:"10px 16px",marginBottom:14,scrollMarginTop:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(lo,{char:t,tone:n}),e.jsx("h2",{style:{margin:0,fontSize:19,fontWeight:600,letterSpacing:".1em"},children:a(o)}),r!=null&&e.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:i("label-fg")},children:r})]}),s&&e.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:14,fontSize:12},children:s})]})}function kl({label:t,active:n,onClick:o,dashed:r}){const{convert:s}=Ne();return e.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(t)})}function du({label:t,onClick:n}){const{convert:o}=Ne();return e.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(t)})}function pu({label:t,onClick:n,inline:o}){const{convert:r}=Ne();return e.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(t)})}function wl({children:t,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?e.jsx("a",{href:n??"#",title:r,onClick:o?l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),o())}:void 0,style:s,children:t}):e.jsx("span",{title:r,style:s,children:t})}function uu({children:t}){return e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:t})}function mu({volumes:t,unit:n,max:o=60}){const{t:r}=Y(),s=n??r("unit.volume"),[l,a]=h.useState(!1);if(!t.length)return null;const p=l?t:t.slice(0,o);return e.jsxs("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,fontSize:11.5},children:[p.map(c=>e.jsx("span",{style:{minWidth:30,textAlign:"center",padding:"2px 5px",border:`1px solid ${i("rule")}`,color:i("meta-fg")},children:c},c)),!l&&t.length>o&&e.jsxs("button",{type:"button",onClick:()=>a(!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:["+",t.length-o]}),e.jsx("span",{style:{padding:"2px 6px",color:i("hint-fg")},children:s})]})}function gu({children:t}){return e.jsx("div",{style:{borderTop:`1px solid ${i("rule-strong")}`},children:t})}function hu({spec:t}){const{convert:n}=Ne();return e.jsxs("div",{className:"bim-d-thead bim-d-ui",style:{display:"grid",gridTemplateColumns:`${t.leadWidth}px 1fr ${t.metaWidth}px`,gap:12,padding:"7px 4px",borderBottom:`1px solid ${i("rule-strong")}`,fontSize:11,color:i("label-fg"),letterSpacing:".1em"},children:[e.jsx("span",{}),e.jsx("span",{children:n(t.mainLabel)}),e.jsx("span",{style:{display:"grid",gridTemplateColumns:t.columns.map(o=>o.width).join(" "),gap:12},children:t.columns.map(o=>e.jsx("span",{children:n(o.label)},o.label))})]})}function xu({no:t,main:n,meta:o,spec:r}){return e.jsxs("div",{className:"bim-d-row",style:{gridTemplateColumns:`${r.leadWidth}px 1fr ${r.metaWidth}px`,gap:12},children:[e.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:i("hint-fg"),textAlign:"right"},children:t}),e.jsx("span",{style:{minWidth:0},children:n}),e.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 fu(t){return String(t+1).padStart(2,"0")}function bu(){return e.jsx("span",{style:{color:i("hint-fg")},children:"—"})}function yu({open:t,onToggle:n,main:o,action:r,children:s}){return e.jsxs("div",{style:{borderBottom:`1px solid ${i("rule")}`},children:[e.jsxs("div",{className:"bim-d-expand-head",style:{display:"grid",gridTemplateColumns:"26px 1fr auto",gap:12,alignItems:"baseline",padding:"9px 4px"},children:[e.jsx("button",{type:"button",onClick:n,"aria-expanded":t,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(t?"accent":"rule-dashed")}`,background:t?i("accent"):"transparent",color:i(t?"page-bg":"accent")},children:t?"-":"+"}),e.jsx("span",{style:{fontSize:14,minWidth:0},children:o}),r]}),t&&s&&e.jsx("div",{style:{padding:"2px 4px 14px 38px",borderLeft:`2px solid ${i("rule-accent-soft")}`,marginLeft:12},children:s})]})}function Sl(t){const n=[];for(let o=0;o<t.length;o++){const r=t[o];let s;if(r==="⟨")s="⟩";else if(r==="<"){const p=t[o+1];if(p===void 0||/[A-Za-z/!?>\s]/.test(p))continue;s=">"}else continue;const l=t.indexOf(s,o+1);if(l<0)continue;const a=t.slice(o+1,l);a.includes(`
1095
+ `)||(n.push({start:o,end:l+1,inner:a}),o=l)}return n}function $l(t,n){if(t.length<=n)return t;let o=n;for(const r of Sl(t)){if(r.start>=o)break;if(r.end>o){o=r.start>0?r.start:r.end;break}}return t.slice(0,o)}const _l={fontSize:".78em",color:i("meta-fg"),lineHeight:1.55},ju={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 Cl(t,n,o,r){return t.map((s,l)=>{switch(s.type){case"text":return e.jsx(h.Fragment,{children:n(s.text)},l);case"jz":return e.jsx("span",{className:"bim-jiazhu",style:o===0?_l:void 0,children:Cl(s.children,n,o+1,r)},l);case"qw":return e.jsx("span",{className:"bim-qw guji-qw",title:s.label?r("detail.lacunaWith",{label:s.label}):r("detail.lacuna"),children:"□"},l);case"qz":return e.jsx("span",{className:"bim-qz guji-qz","data-guji-guess":s.guess,children:"□"},l);case"zi":return e.jsx("span",{className:"bim-zi guji-zi",title:r("detail.composedChar",{label:s.label}),style:ju,children:s.label},l)}})}function ot(t,n=r=>r,o){if(!t)return"";if(o!=null&&o.gujiMarkdown)return bp(t)?Cl(Fs(t),n,0,o.t??Dt("zh-Hant")):n(t);if(t.indexOf("⟨")<0&&t.indexOf("<")<0)return n(t);const r=[];let s=0,l=0;for(const a of Sl(t))a.start>s&&r.push(e.jsx(h.Fragment,{children:n(t.slice(s,a.start))},l++)),r.push(e.jsx("span",{className:"bim-jiazhu",style:_l,children:n(a.inner)},l++)),s=a.end;return s<t.length&&r.push(e.jsx(h.Fragment,{children:n(t.slice(s))},l++)),r}function vu({label:t,children:n}){return e.jsxs("div",{style:{marginBottom:10},children:[t&&e.jsx("div",{className:"bim-d-ui",style:{fontSize:11,fontWeight:600,letterSpacing:".1em",color:i("label-fg"),marginBottom:4},children:t}),e.jsx("div",{style:{fontSize:13.5,lineHeight:2,color:i("quiet-fg"),textAlign:"justify"},children:n})]})}function ku({title:t,tag:n,children:o}){const{convert:r}=Ne();return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,paddingBottom:7,borderBottom:`1px solid ${i("rule-strong")}`,marginBottom:2},children:[e.jsx("span",{style:{fontSize:14.5,letterSpacing:".08em"},children:r(t)}),n&&e.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:i("accent"),letterSpacing:".06em"},children:r(n)})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:o})]})}function zl({name:t,note:n,href:o,extra:r}){const s=e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontSize:14,minWidth:0},children:t}),e.jsx("span",{className:"bim-d-ui",style:{fontSize:11,color:i("hint-fg"),flex:"none"},children:o?"↗":""}),n&&e.jsx("span",{className:"bim-d-ui",style:{gridColumn:"1 / -1",fontSize:11.5,color:i("label-fg")},children:n})]}),l={display:"grid",gridTemplateColumns:"1fr auto",gap:"4px 12px",padding:"9px 4px",borderBottom:`1px solid ${i("rule")}`,color:i("body-fg"),alignItems:"baseline"};return e.jsxs(e.Fragment,{children:[o?e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:l,children:s}):e.jsx("div",{style:l,children:s}),r]})}function wu({item:t,siblings:n,showVolumes:o=!0,fallbackNote:r}){const{t:s,convert:l}=Y(),[a,p]=h.useState(!1),c=Ln(t),d=o&&!!c&&c.expected>0,u=(t.url?Ut(t.url):void 0)||l(t.name),g=n?cl(t,n):"",m=g?`${u}(${g})`:u;return e.jsx(zl,{name:m,note:Fn(t,s)||r,href:Vt(t),extra:d?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>p(x=>!x),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:a?s("detail.collapseVolumes"):s("detail.expandVolumes",{n:c.expected})}),a&&e.jsx(ao,{item:t})]}):void 0})}function ao({item:t}){return e.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,padding:"6px 0 10px",fontSize:11},children:(t.volumes||[]).map((n,o)=>{const r=n.status==="missing";return n.url&&!r?e.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):e.jsx("span",{style:{padding:"1px 5px",color:i(r?"missing-fg":"hint-fg"),textDecoration:r?"line-through":void 0},children:n.volume},o)})})}function Tl({label:t,items:n}){const{convert:o}=Ne();return n.length?e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},children:[e.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:i("label-fg"),letterSpacing:".08em"},children:t}),n.map((r,s)=>e.jsx(wl,{children:o(r)},s))]}):null}function Su({rows:t}){const n=t.filter(o=>o.items.length>0);return n.length?e.jsx("div",{style:{marginTop:16,display:"flex",flexDirection:"column",gap:8},children:n.map(o=>e.jsx(Tl,{label:o.label,items:o.items},o.label))}):null}function Ni(t){return(t||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Nl({left:t,right:n}){return e.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:[e.jsx("span",{children:t}),n&&e.jsx("span",{style:{display:"flex",gap:16},children:n})]})}function $u({children:t,action:n}){return e.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:[e.jsx("span",{children:t}),n]})}function Ge({id:t,label:n,onNavigate:o,renderLink:r,style:s,dense:l}){const a=Ye();return r?e.jsx(e.Fragment,{children:r(t,typeof n=="string"?n:void 0,{dense:l})}):e.jsx("a",{href:a(t),onClick:o?p=>{p.metaKey||p.ctrlKey||(p.preventDefault(),o(t))}:void 0,style:s,children:n??t})}function _u({href:t,children:n}){return e.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:[n," ",e.jsx("span",{className:"bim-d-ui",style:{fontSize:11},children:"↗"})]})}const Cu={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},zu={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},Tu=`1px solid ${i("table-border")}`,Il={border:Tu,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},Nu={...Il,background:i("table-head-bg"),fontWeight:600};function co({table:t,opts:n}){return e.jsx("div",{className:"bim-guji-table-wrap",style:Cu,children:e.jsx("table",{className:"bim-guji-table",style:zu,children:e.jsx("tbody",{children:t.rows.map((o,r)=>e.jsx("tr",{children:o.cells.map((s,l)=>{const a=o.header?"th":"td";return e.jsx(a,{colSpan:s.colspan>1?s.colspan:void 0,rowSpan:s.rowspan>1?s.rowspan:void 0,style:o.header?Nu:Il,children:s.empty?null:ot(s.text,void 0,n)},l)})},r))})})})}function Iu(t,n){return t.indexOf("**")<0?ot(t,void 0,n):t.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((r,s)=>s%2===1?e.jsx("strong",{children:ot(r.trim().slice(2,-2),void 0,n)},s):e.jsx(h.Fragment,{children:ot(r,void 0,n)},s))}function Ru(t,n,o=!1){const r=o?{gujiMarkdown:!0}:void 0;return n?Zi(t).map((s,l)=>s.type==="table"?e.jsx(co,{table:s.table,opts:r},l):e.jsx(h.Fragment,{children:Iu(s.text,r)},l)):ot(t,void 0,r)}const Eu=/^(#{1,6})\s+(.*)$/,Lu=/^\*\*([^*\n]+)\*\*\s*$/;function po(t){const n=t.match(Eu);if(n)return{level:n[1].length,text:n[2].trim()};const o=t.trim().match(Lu);return o?{level:3,text:o[1].trim()}:null}const uo=/^<!--.*-->$/;function Rl(t){return t.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function El(t){return t.split(`
1096
1096
  `).map(n=>n.trim()).filter(n=>n&&!uo.test(n))}const Pu=60;function Ll(t){let n=0,o=0;for(const r of t.split(`
1097
1097
  `)){const s=r.trim();if(!s||uo.test(s)||po(s))continue;const l=s.replace(/<[^<>\n]*>|\u27e8[^\u27e9\n]*\u27e9/g,"").replace(/\s/g,"").length;n+=l,l>Pu&&(o+=l)}return n>0&&o*2>=n}function Au(t){return t.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function Gn(t){if(t=Au(t),Ll(t))return"unknown";const n=Rl(t);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const o=n.map(s=>El(s).length).filter(s=>s>0);if(o.length===0)return"unknown";const r=o.reduce((s,l)=>s+l,0)/o.length;return r<=4?"record":r>=8?"catalog":"unknown"}function Bu(t){const n=t.split(`
1098
1098
  `),o=[];let r=null,s=[];const l=()=>{o.push({heading:r,body:s.join(`
1099
1099
  `)}),s=[]};for(const a of n){const p=po(a);if(p){l(),r={kind:"heading",level:p.level,text:p.text};continue}s.push(a)}return l(),o}function fr(t){const n=[];for(const o of t.split(`
1100
- `)){const r=po(o);if(r){n.push({kind:"heading",level:r.level,text:r.text});continue}const s=o.trim();!s||uo.test(s)||n.push({kind:"body",text:o})}return n}function Pl(t){if(!t)return[];const n=Gn(t);if(n==="unknown")return fr(t);const o=[];for(const{heading:r,body:s}of Bu(t)){r&&o.push(r);const l=Rl(s);if(l.length!==0){if(Ll(s)){o.push(...fr(s));continue}if(n==="record"){const a=l.join(" ");a&&o.push({kind:"body",text:a})}else for(const a of l){const p=El(a);p.length&&o.push({kind:"body",text:p.join(" ")})}}}return o}const Al=t=>t;function Bl(t,n=Al){if(t.indexOf("《")<0)return n(t);const o=[],r=/《([^《》\n]+)》/g;let s=0,l=0,a;for(;a=r.exec(t);)a.index>s&&o.push(e.jsx(x.Fragment,{children:n(t.slice(s,a.index))},l++)),o.push(e.jsxs("span",{className:"bim-rd-pn",children:[e.jsx("span",{className:"bim-rd-sr",children:"《"}),n(a[1]),e.jsx("span",{className:"bim-rd-sr",children:"》"})]},l++)),s=a.index+a[0].length;return s===0?n(t):(s<t.length&&o.push(e.jsx(x.Fragment,{children:n(t.slice(s))},l++)),o)}function mo(t,n={}){const o=n.renderText??Al,r=n.properNames?l=>Bl(l,o):o,s=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return ot(t,r,s)}function br(t,n,o){return t.indexOf("**")<0?n(t):t.split(/(\*\*[^*]+\*\*)/g).map((s,l)=>s.startsWith("**")&&s.endsWith("**")&&s.length>4?e.jsx("strong",{children:n(s.slice(2,-2))},`${o}-${l}`):e.jsx(x.Fragment,{children:n(s)},`${o}-${l}`))}const ai=/^(#{1,6})\s+(.*)$/,Mu=/^\s*<!--.*-->\s*$/;function Ml(t){return t.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
1101
- `)?"":n)}function Wu(t){return t<=1?2:t===2?3:4}function Hu(){let t=1;return n=>{const o=Wu(n),r=Math.min(o,t+1);return t=r,{Tag:`h${r}`,className:`bim-rd-hl${o}`}}}function Tn(t){return t?Gn(Ml(t))!=="unknown":!1}function Ou(t){return/^\u3000{2}/.test(t)}const yr=t=>Ou(t)?"bim-rd-noindent":void 0;function jr({text:t,mode:n,inline:o,dropTitle:r}){const s=Ml(t),l=(d,u,g)=>!!r&&g<=1&&d<=2&&u.trim()===r.trim(),a=Hu();if(n==="paragraph"&&Gn(s)!=="unknown"){const d=Pl(s);return e.jsx(e.Fragment,{children:d.map((u,g)=>{if(u.kind==="heading"){if(l(u.level??1,u.text,g))return null;const{Tag:m,className:h}=a(u.level??1);return e.jsx(m,{className:h,children:o(u.text)},g)}return e.jsx("p",{className:yr(u.text),children:br(u.text,o,g)},g)})})}const p=s.split(`
1102
- `);let c=0;return e.jsx(e.Fragment,{children:p.map((d,u)=>{const g=d.match(ai);if(g){const h=c++;if(l(g[1].length,g[2],h))return null;const{Tag:f,className:v}=a(g[1].length);return e.jsx(f,{className:v,children:o(g[2])},u)}if(!d.trim())return u>=2&&!!p[u-1].trim()&&!!p[u-2].trim()&&!ai.test(p[u-1])&&!ai.test(p[u-2])?e.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},u):null;if(Mu.test(d))return null;if(c++,/^\*\*[^*]+\*\*\s*$/.test(d.trim())){const{Tag:h,className:f}=a(3);return e.jsx(h,{className:f,children:o(d.trim().slice(2,-2))},u)}return e.jsx("p",{className:yr(d),children:br(d,o,u)},u)})})}function Fu(t){const{convert:n}=Te();return x.useMemo(()=>t?n(t):"",[t,n])}function go({text:t,mode:n,tables:o=!1,gujiMarkdown:r=!1,properNames:s=!1,renderText:l,dropTitle:a}){const p=Fu(t),{t:c,convert:d}=G(),u=h=>mo(h,{renderText:l,properNames:s,gujiMarkdown:r,t:c}),g=r?{gujiMarkdown:!0,t:c}:void 0,m=a?d(a):void 0;return!o||p.indexOf(":::")<0?e.jsx(jr,{text:p,mode:n,inline:u,dropTitle:m}):e.jsx(e.Fragment,{children:Zi(p).map((h,f)=>h.type==="table"?e.jsx(co,{table:h.table,opts:g},f):e.jsx(jr,{text:h.text,mode:n,inline:u,dropTitle:f===0?m:void 0},f))})}function Du(t,n){const[o,r]=x.useState(null),[s,l]=x.useState(!1),a=x.useRef(0);return x.useEffect(()=>{const p=++a.current;if(!t||!n){r(null),l(!1);return}let c;try{c=t(n)}catch{r(null),l(!1);return}if(!c||typeof c.then!="function"){r(c??null),l(!1);return}l(!0),c.then(d=>{p===a.current&&r(d??null)}).catch(()=>{p===a.current&&r(null)}).finally(()=>{p===a.current&&l(!1)})},[t,n]),{images:o,loading:s}}const vr={A:"fine",B:"rough",C:"rough",D:"ocr"};function Uu(t){return typeof t!="string"?null:t in $c?t:t in vr?vr[t]:null}const Vu={書:"书",類:"类",結語:"结语",結语:"结语",考證:"考证",詩:"诗"},Gu={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释"},Wl="\0";function Yu(t,n,o){const[r,s=""]=t.split(Wl);return e.jsxs(e.Fragment,{children:[r,e.jsx(qs,{text:n,convert:o}),s]})}function st(t){return typeof t!="string"?"":Vu[t]??Gu[t]??t}const Ku=["〇","一","二","三","四","五","六","七","八","九"],kr=["","十","百","千"],qu=["","萬","億"];function ho(t){if(t===0)return"〇";if(t<0)return`負${ho(-t)}`;const n=[];let o=t,r=0;for(;o>0;){const s=o%1e4;s>0?n.unshift(Zu(s,r>0)+qu[r]):n.length>0&&n.unshift("〇"),o=Math.floor(o/1e4),r++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Zu(t,n){const o=[];let r=t;for(;r>0;)o.unshift(r%10),r=Math.floor(r/10);let s="";for(let l=0;l<o.length;l++){const a=o[l],p=o.length-1-l;a===0?s&&!s.endsWith("〇")&&(s+="〇"):a===1&&p===1&&l===0&&!n?s+=kr[p]:s+=Ku[a]+kr[p]}return s.replace(/〇$/,"")}let ln=null,jn=null;const Nn=new Set;function Ju(){return ln?Promise.resolve():jn||(jn=import("opencc-js/t2cn").then(t=>{const n=t.Converter({from:"t",to:"cn"});ln=o=>n(xe.normalizeVariants(o)),Nn.forEach(o=>o())}).catch(()=>{ln=t=>t,Nn.forEach(t=>t())}),jn)}const Xu=t=>t;function Et(){const[,t]=x.useState(0);return x.useEffect(()=>{if(ln)return;const n=()=>t(o=>o+1);return Nn.add(n),Ju(),()=>{Nn.delete(n)}},[]),ln??Xu}function Ot(t,n){return n(t).toLowerCase()}const Qu=i("highlight-bg");function gn(t,n,o){if(!n)return t;const r=Ot(n,o);if(!r)return t;const s=Ot(t,o);if(s.length!==t.length)return t;const l=[];let a=0,p=0;for(;a<t.length;){const c=s.indexOf(r,a);if(c===-1){l.push(t.slice(a));break}c>a&&l.push(t.slice(a,c)),l.push(e.jsx("mark",{style:{background:Qu,padding:0,color:"inherit"},children:t.slice(c,c+r.length)},p++)),a=c+r.length}return e.jsx(e.Fragment,{children:l})}function xo(t,n,o,r){if(!n)return!0;const s=Ot(n,r);return(o?[t.title,t.header_line,t.content,t.comment]:[t.title,t.book_title,t.author,t.author_info,t.summary,t.content,t.comment,t.additional_comment]).some(a=>typeof a=="string"&&Ot(a,r).includes(s))}function em(t,n,o){return n?Ot(t,o).includes(Ot(n,o)):!0}const fo={类:i("section-lei"),书:i("section-shu"),序:i("section-xu"),结语:i("section-jieyu"),注释:i("section-zhushi")},tm={考证:i("section-kaozhen")};function bo(t,n,o){return t.collated.sectionType[n]??o(n)}function Hl(t){var r;const n=t.files.length,o=((r=t.children)==null?void 0:r.reduce((s,l)=>s+Hl(l),0))||0;return n+o}function nm(t,n){const o=[],r=a=>{var p;o.push(...a.files),(p=a.children)==null||p.forEach(r)};if(r(t),o.length===0)return;const s=o.map(a=>n[a]);if(s.every(a=>a===void 0))return;if(s.some(a=>a==="loading"))return"loading";let l=0;for(const a of s)typeof a=="number"&&(l+=a);return l}const im={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function yo({enabled:t,expanded:n,onClick:o,style:r,children:s}){return t?e.jsx("button",{type:"button","aria-expanded":n,onClick:o,style:{...im,...r},children:s}):e.jsx("span",{style:r,children:s})}function om({type:t}){const{convert:n,messages:o}=G(),r=st(t),s=fo[r]||i("desc-fg");return e.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:bo(o,r,n)})}function rm({section:t,onNavigate:n,highlightQuery:o="",no:r,showUnlinked:s=!1,domId:l}){const{t:a,convert:p}=G(),c=Ye(),d=Et(),u=j=>j?ot(p(j),S=>o?gn(S,o,d):S,{t:a}):"",[g,m]=x.useState(!1),h=!!t.summary,f=!!t.comment,v=!!t.additional_comment,y=!!(t.content&&t.content.length>60),w=h||f||v||y;x.useEffect(()=>{o&&m(!0)},[o]);const b=!g&&y?$l(t.content.replace(/\n/g," "),80)+"…":null;return e.jsxs("div",{className:"bim-rd-row",id:l,style:{borderBottom:`1px solid ${i("rule")}`,overflow:"hidden"},children:[e.jsxs("div",{onClick:()=>w&&m(!g),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:w?"pointer":"default",userSelect:"none"},children:[r!=null&&e.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:i("label-fg")},children:r}),e.jsxs(yo,{enabled:w,expanded:g,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[w&&e.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),transition:"transform 0.15s",transform:g?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsxs("span",{style:{display:"block",flex:1,minWidth:0},children:[e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg")},children:[t.book_title?e.jsxs(e.Fragment,{children:["《",u(t.book_title),"》"]}):u(t.title),t.n_juan!=null&&e.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:a("collated.nJuan",{n:p(ho(t.n_juan))})}),(t.author_info||t.author)&&e.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:u(t.author_info||t.author)})]}),!g&&b&&e.jsx("span",{style:{display:"block",fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:u(b)})]})]}),t.edition&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u(t.edition)}),t.tag&&e.jsx("span",{style:{fontSize:"11px",color:i("section-tag-fg")},children:t.tag==="triangle"?"△":t.tag}),t.work_id&&n&&e.jsx("a",{href:c(t.work_id),onClick:j=>{j.metaKey||j.ctrlKey||(j.preventDefault(),j.stopPropagation(),n(t.work_id))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:a("collated.viewWork"),"aria-label":a("collated.viewWorkOf",{title:p(t.book_title||t.title)}),children:a("collated.workArrow")}),s&&!t.work_id&&e.jsx("span",{style:{fontSize:"11px",color:i("label-fg"),flexShrink:0},children:a("collated.unlinked")})]}),g&&w&&e.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${i("widget-border")}`,background:i("bg")},children:[t.author_info&&e.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"8px"},children:u(t.author_info)}),t.summary&&e.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:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a("collated.summary")}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:u(t.summary)})]}),t.comment&&e.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a("collated.comment")}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(t.comment)})]}),t.additional_comment&&e.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a("collated.additionalComment")}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(t.additional_comment)})]}),y&&!h&&!f&&!v&&e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(t.content)})]})]})}function sm({section:t,highlightQuery:n=""}){const{t:o,convert:r}=G(),s=Et(),l=d=>d?ot(r(d),u=>n?gn(u,n,s):u,{t:o}):"",[a,p]=x.useState(!1),c=!!t.content;return e.jsxs("div",{style:{padding:"12px 0 6px"},children:[e.jsxs(yo,{enabled:c,expanded:a,onClick:()=>p(!a),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[e.jsx(om,{type:t.type}),e.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:l(t.title)}),c&&e.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),transition:"transform 0.15s",transform:a?"rotate(90deg)":"none",display:"inline-block"},children:"▶"})]}),a&&c&&e.jsx("div",{style:{marginTop:"8px",padding:"10px 14px",borderLeft:`3px solid color-mix(in srgb, ${fo[st(t.type)]||i("desc-fg")} 25%, transparent)`,borderRadius:"0 4px 4px 0",background:i("bg")},children:e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:l(t.content)})})]})}const lm=100;function jo(t){return st(t.type)!=="page_header"?!1:(t.content||"").length>=lm}function am({section:t,highlightQuery:n=""}){const{t:o,convert:r,messages:s}=G(),l=Et();if(st(t.type)==="page_header"&&!jo(t)||!t.content&&!t.title)return null;const a=r((t.content||t.title||"").replace(/\n{2,}/g,`
1103
- `)),p=ot(a,g=>n?gn(g,n,l):g,{t:o}),c=st(t.type),d=fo[c]||i("desc-fg"),u=c==="序"||c==="结语"||c==="注释";return e.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 ${d}40`:void 0,background:u?i("bg"):void 0,borderRadius:u?"0 4px 4px 0":void 0,position:"relative"},children:[u&&e.jsx("span",{style:{display:"inline-block",fontSize:"10px",fontWeight:500,color:d,marginRight:"8px",padding:"1px 5px",border:`1px solid ${d}40`,borderRadius:"2px",background:`${d}08`,verticalAlign:"middle"},children:bo(s,c,r)}),p]})}function cm(t,n,o){const[r,s]=x.useState({});return x.useEffect(()=>{var d;if(!n||t.length===0)return;let l=!1;const a=t.filter(u=>{var g;return!((g=o==null?void 0:o.current)!=null&&g.has(u))}),p={};for(const u of t)(d=o==null?void 0:o.current)!=null&&d.has(u)&&(p[u]=o.current.get(u));if(Object.keys(p).length>0&&s(p),a.length===0)return;const c=async u=>{var g;try{if(n.getEntry){const y=await n.getEntry(u);if(y)return{title:y.title,author:y.author}}const m=await n.getItem(u);if(!m)return null;const h=m.title||u,f=m.authors,v=(g=f==null?void 0:f[0])==null?void 0:g.name;return{title:h,author:v}}catch{return null}};return Promise.all(a.map(async u=>{var m;const g=await c(u);return(m=o==null?void 0:o.current)==null||m.set(u,g),[u,g]})).then(u=>{l||s(g=>{const m={...g};for(const[h,f]of u)m[h]=f;return m})}),()=>{l=!0}},[t.join(","),n]),r}function dm({section:t,onNavigate:n,transport:o,workLabelCache:r,highlightQuery:s=""}){const{t:l,convert:a,messages:p}=G(),c=Ye(),d=Et(),u=S=>S?ot(a(S),k=>s?gn(k,s,d):k,{t:l}):"",[g,m]=x.useState(!1);x.useEffect(()=>{s&&m(!0)},[s]);const h=st(t.type),f=tm[h]||i("desc-fg"),v=!!t.content,y=t.work_ids||[],w=y.length>1,b=cm(w?y:[],o,r),j=v&&!g&&t.content.length>80?$l(t.content,80)+"……":null;return e.jsxs("div",{style:{borderBottom:`1px solid ${i("widget-border")}`,padding:"10px 0"},children:[e.jsxs("div",{onClick:()=>v&&m(!g),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:v?"pointer":"default",userSelect:"none"},children:[e.jsxs(yo,{enabled:v,expanded:g,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[v&&e.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:g?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsxs("span",{style:{display:"block",flex:1},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg"),lineHeight:1.6},children:t.header_line?u(t.header_line):u(t.title)}),!g&&j&&e.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:i("desc-fg"),lineHeight:1.7},children:u(j)})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[y.length===1&&n&&e.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:l("collated.viewWork"),children:l("collated.arrowWork")}),w&&e.jsx("span",{style:{fontSize:"11px",color:i("link-fg"),flexShrink:0},children:l("collated.nWorks",{n:y.length})}),e.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:f,border:`1px solid ${f}40`,borderRadius:"2px",background:`${f}08`},children:bo(p,h,a)})]})]}),w&&n&&e.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:y.map(S=>{const k=b[S],$=k?`${a(k.title)}${k.author?`(${a(k.author)})`:""}`:S.slice(0,8)+"…";return e.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)})}),g&&v&&e.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${f}40`,borderRadius:"0 4px 4px 0",background:i("bg")},children:[e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(t.content)}),t.comment&&e.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(t.comment)})]})]})}function pm({juan:t,searchQuery:n,onNavigate:o,transport:r,workLabelCache:s}){const{t:l}=G(),a=Et(),p=n.trim(),c=x.useMemo(()=>p?t.sections.filter(d=>xo(d,p,!0,a)):t.sections,[t.sections,p,a]);return e.jsxs("div",{children:[e.jsx("div",{children:c.map((d,u)=>e.jsx(dm,{section:d,onNavigate:o,transport:r,workLabelCache:s,highlightQuery:p},u))}),c.length===0&&e.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:l("collated.noMatch")})]})}function um(){let t=!1;return n=>n==="类"?(t=!0,"h2"):t?"h3":"h2"}function mm({sections:t,onNavigate:n,inline:o,workLinks:r=!0}){const s=Ye(),{t:l,convert:a}=G(),p=um();return e.jsx(e.Fragment,{children:t.map((c,d)=>{const u=st(c.type);if(u==="page_header"&&!jo(c))return null;if(u==="类")return e.jsxs(x.Fragment,{children:[x.createElement(p("类"),null,o(a(c.title))),c.content&&e.jsx("p",{children:o(a(c.content))})]},d);if(u==="书"||u==="诗"||u==="考证"||u==="注释"){const g=c.book_title?`《${c.book_title}》${c.n_juan!=null?l("collated.nJuan",{n:ho(c.n_juan)}):""}`:c.title,m=o(a(g));return e.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${d}`,children:[x.createElement(p("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&r?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:s(c.work_id),onClick:h=>{h.metaKey||h.ctrlKey||(h.preventDefault(),n(c.work_id))},title:l("collated.viewWork"),children:m}),e.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:h=>{h.metaKey||h.ctrlKey||(h.preventDefault(),n(c.work_id))},"aria-label":l("collated.viewWorkOf",{title:a(g)}),children:l("collated.workArrow")})]}):m),c.author_info&&e.jsx("p",{className:"bim-rd-sub",children:o(a(c.author_info))}),c.content&&c.content.split(/\n+/).map((h,f)=>e.jsx("p",{children:o(a(h))},f)),c.summary&&e.jsxs("p",{children:[e.jsx("span",{className:"bim-rd-lbl",children:l("collated.summary")}),o(a(c.summary))]}),c.comment&&e.jsxs("p",{children:[e.jsx("span",{className:"bim-rd-lbl",children:l("collated.comment")}),o(a(c.comment))]}),c.additional_comment&&e.jsxs("p",{children:[e.jsx("span",{className:"bim-rd-lbl",children:l("collated.additionalComment")}),o(a(c.additional_comment))]})]},d)}return c.content?e.jsx("p",{children:o(a(c.content))},d):null})})}function Ol(t){return t.some(n=>{const o=st(n.type);return o==="书"||o==="诗"||o==="考证"||o==="注释"||o==="类"||(o==="序"||o==="结语")&&!!n.content||o==="page_header"&&jo(n)})}function gm({juan:t,rawText:n,positionLabel:o,groupLabel:r,index:s,searchQuery:l,onNavigate:a,transport:p,workLabelCache:c,prefs:d,view:u,onViewChange:g}){var Z;const{t:m,convert:h,messages:f}=G(),v=Et(),[y,w]=x.useState("text"),b=u??y,j=ee=>{w(ee),g==null||g(ee)},S=l.trim(),k=(s==null?void 0:s.type)==="kaozhen",$=x.useCallback(ee=>S?gn(ee,S,v):ee,[S,v]),_=ee=>mo(ee,{renderText:$,properNames:d.properNames,t:m}),z=x.useMemo(()=>S?t.sections.filter(ee=>xo(ee,S,k,v)):t.sections,[t.sections,S,k,v]),E=(ee,ce)=>ce.filter(fe=>st(fe.type)===ee).length,T=E("书",t.sections),C=E("诗",t.sections),O=E("考证",t.sections);let W="";k?W=S?m("collated.countTiaoOf",{m:E("考证",z),n:O}):m("collated.countTiao",{n:O}):C>0?W=S?m("collated.countPoemsOf",{m:E("诗",z),n:C}):m("collated.countPoems",{n:C}):T>0&&(W=S?m("collated.countBooksOf",{m:E("书",z),n:T}):m("collated.countBooks",{n:T}));const P=s!=null&&s.text_quality?Uu(s.text_quality.grade):null,Y=[];W&&Y.push(W),k&&(s!=null&&s.target_source)&&Y.push(e.jsx(e.Fragment,{children:m("collated.kaozhenTarget",{target:h(s.target_source)})})),P&&Y.push(e.jsx("span",{title:f.collated.qualityCriteria[P],children:(Z=s==null?void 0:s.text_quality)!=null&&Z.source_note?e.jsxs(e.Fragment,{children:[Yu(m("collated.baseText",{note:Wl}),s.text_quality.source_note,h),e.jsx("span",{className:"bim-rd-grade",children:f.collated.qualityLabel[P]})]}):e.jsxs(e.Fragment,{children:[m("collated.textQuality"),e.jsx("span",{className:"bim-rd-grade",children:f.collated.qualityLabel[P]})]})})),t.source_url&&Y.push(e.jsx("a",{className:"bim-rd-link",href:t.source_url,target:"_blank",rel:"noopener noreferrer",children:m("collated.originalSource")}));const V=!k&&Ol(t.sections),Q=!!n&&(!V||d.readingMode==="paragraph"&&Tn(n)),ge=!k&&(V||!!n),A=k||!ge?"entries":b;let I=0;return e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[(o||r)&&e.jsxs("p",{className:"bim-rd-kicker",children:[o,o&&r&&e.jsx("span",{className:"bim-rd-dot"}),r&&h(r)]}),e.jsx("h1",{className:"bim-rd-h1",children:h(t.title)}),Y.length>0&&e.jsx("p",{className:"bim-rd-meta",children:Y.map((ee,ce)=>e.jsxs(x.Fragment,{children:[ce>0&&e.jsx("span",{className:"bim-rd-dot"}),ee]},ce))}),ge&&t.sections.length>0&&e.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":m("collated.viewsGroup"),children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":A==="text",onClick:()=>j("text"),children:m("collated.viewText")}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":A==="entries",onClick:()=>j("entries"),children:m("collated.viewEntries")})]})]}),A==="text"&&e.jsx("article",{className:"bim-rd-prose",children:Q?e.jsx(go,{text:n,mode:d.readingMode,properNames:d.properNames,renderText:$,dropTitle:t.title}):e.jsx(mm,{sections:t.sections,onNavigate:a,inline:_,workLinks:d.workLinks})}),A==="entries"&&e.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:k?e.jsx(pm,{juan:t,searchQuery:l,onNavigate:a,transport:p,workLabelCache:c}):e.jsxs(e.Fragment,{children:[z.some(ee=>["书","诗","考证"].includes(st(ee.type)))&&e.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[e.jsx("span",{style:{width:28},children:m("collated.rowHeadNo")}),e.jsx("span",{style:{flex:1},children:m("collated.rowHeadTitle")}),e.jsx("span",{children:m("collated.rowHeadWork")})]}),z.map((ee,ce)=>{const fe=st(ee.type);return fe==="书"||fe==="诗"||fe==="考证"?(I+=1,e.jsx(rm,{domId:`rd-e-${t.sections.indexOf(ee)}`,section:ee,onNavigate:d.workLinks?a:void 0,highlightQuery:S,no:I,showUnlinked:d.workLinks&&!!a},ce)):fe==="类"?e.jsx(sm,{section:ee,highlightQuery:S},ce):e.jsx(am,{section:ee,highlightQuery:S},ce)}),z.length===0&&e.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:m("collated.noMatch")})]})})]})}function hm(t){const{resetKey:n,load:o,files:r,activeFile:s,activeJuan:l,activeRawText:a,query:p,isKaozhen:c}=t,d=Et(),u=x.useRef(new Map),[g,m]=x.useState({}),[h,f]=x.useState({}),v=x.useCallback((w,b)=>{const j=b==null?void 0:b.title;j&&f(S=>S[w]===j?S:{...S,[w]:j})},[]);x.useEffect(()=>{s&&l&&(u.current.set(s,{juan:l,rawText:a}),v(s,l))},[s,l,a,v]),x.useEffect(()=>{u.current.clear(),m({}),f({})},[n]);const y=x.useCallback((w,b)=>{let j=0;if(w.juan)for(const S of w.juan.sections)xo(S,b,c,d)&&j++;return j===0&&w.rawText&&em(w.rawText,b,d)&&(j=1),j},[c,d]);return x.useEffect(()=>{const w=p.trim();if(!w){m({});return}if(!o||r.length===0)return;let b=!1;const j={},S=[];for(const E of r){const T=u.current.get(E);T?j[E]=y(T,w):(j[E]="loading",S.push(E))}m(j);const k=8;let $=0;const _=async()=>{for(;$<S.length;){if(b)return;const E=$++,T=S[E];try{const C=await o(T),O=C.juan;if(u.current.set(T,C),v(T,O),b)return;m(W=>({...W,[T]:y(C,w)}))}catch{if(b)return;m(C=>({...C,[T]:0}))}}},z=Array.from({length:Math.min(k,S.length)},()=>_());return Promise.all(z),()=>{b=!0}},[p,n,o,r.join(","),y,d,v]),{matchStates:g,titles:h}}function xm({juan:t,view:n,onView:o,textHasEntries:r}){const{t:s,convert:l}=G(),a=t.sections.map((u,g)=>({s:u,i:g,t:st(u.type)})).filter(u=>u.t==="书"||u.t==="诗");if(a.length===0)return null;const p=a.filter(u=>!!u.s.work_id).length,c=a.every(u=>u.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),d=u=>{const g=()=>{var m,h;return(h=(m=document.getElementById(`rd-e-${u}`))==null?void 0:m.scrollIntoView)==null?void 0:h.call(m,{block:"start",behavior:"smooth"})};n==="text"&&!r&&o("entries"),n==="text"&&!r?setTimeout(g,0):g()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bim-rd-rail-card",children:[e.jsx("div",{className:"bim-rd-rail-cap",children:s("collated.railCap")}),e.jsxs("div",{className:"bim-rd-rail-n",children:[e.jsx("b",{children:a.length}),e.jsx("span",{children:c}),e.jsx("span",{className:"bim-rd-rail-linked",children:s("collated.linkedN",{n:p})})]}),e.jsx("div",{className:"bim-rd-rail-bar",role:"img","aria-label":s("collated.linkedOf",{n:p,total:a.length}),children:e.jsx("span",{style:{width:`${Math.round(p/a.length*100)}%`}})})]}),e.jsxs("nav",{"aria-label":s("collated.railEntriesNav"),children:[e.jsx("div",{className:"bim-rd-rail-cap",style:{margin:"20px 0 6px 12px"},children:s("collated.viewEntries")}),e.jsx("ul",{className:"bim-rd-rail-list",children:a.map(({s:u,i:g})=>e.jsx("li",{children:e.jsxs("a",{href:`#rd-e-${g}`,onClick:m=>{m.preventDefault(),d(g)},children:[e.jsx("span",{className:`bim-rd-rail-dot${u.work_id?" on":""}`,"aria-hidden":"true"}),e.jsx("span",{children:l(u.book_title||u.title)})]})},g))})]})]})}const wr={padding:24,color:i("desc-fg"),fontSize:14};function Sr({title:t,label:n,className:o,style:r}){const s=(l,a=14,p=14)=>({width:l,height:a,marginTop:p,borderRadius:3,background:i("rule")});return e.jsxs("div",{className:o,style:{...r,padding:"20px 24px",maxWidth:760,margin:"0 auto"},"aria-busy":"true",children:[t&&e.jsx("div",{style:{fontSize:15,color:i("ink"),fontFamily:i("font-ui")},children:t}),e.jsx("div",{style:s("42%",24,28)}),e.jsx("div",{style:s("30%",12,10)}),["96%","100%","92%","98%","64%"].map((l,a)=>e.jsx("div",{style:s(l,16,a===0?30:14)},a)),e.jsx("p",{role:"status",style:{marginTop:24,color:i("desc-fg"),fontSize:14,fontFamily:i("font-ui")},children:n})]})}const $r=/^https?:\/\//i;function fm(t){if(!t||typeof t!="object")return null;const n=l=>typeof l=="string"&&l.trim()?l.trim():void 0,o=n(t.url),r=n(t.license_url),s={name:n(t.name),url:o&&$r.test(o)?o:void 0,license:n(t.license),license_url:r&&$r.test(r)?r:void 0,note:n(t.note)};return s.name||s.license||s.note?s:null}function bm(t,n){return{work_id:n.work_id??t,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 ym(t,n){return(n==null?void 0:n.type)==="kaozhen"?"章":n!=null&&n.juan_metadata&&Object.values(n.juan_metadata).some(o=>o.vol_label)?"冊":(t==null?void 0:t.kind)==="collated"?"卷":"章"}function Fl(t,n,o,r=!1){const s=o(`${n}${t.n}`);if(!t.title)return s;const l=o(t.title);return r&&!/^[卷冊册章篇回第]/.test(t.title)?`${s} ${l}`:l}function jm(t,n,o,r,s){var d;const l=new Map(t.chapters.map(u=>[u.file,u])),a=u=>u==="loading"?"…":typeof u=="number"&&u>0?u:void 0,p=(u,g)=>{const m=l.get(u);return{key:u,label:g??(m?Fl(m,o,r,s):u),hint:a(n[u]),disabled:n[u]===0}},c=(d=t.juan_groups)==null?void 0:d.filter(u=>{var g;return u.files.some(m=>l.has(m))||((g=u.children)==null?void 0:g.length)});if(c&&c.length>0){const u=(g,m)=>{var f;if(g.files.length===1&&!((f=g.children)!=null&&f.length))return p(g.files[0],r(g.label));const h=nm(g,n);return{key:`group:${m}`,label:r(g.label),hint:h==="loading"?"…":typeof h=="number"&&h>0?`${h}`:Hl(g),defaultExpanded:typeof h=="number"&&h>0,children:[...g.files.filter(v=>l.has(v)).map(v=>p(v)),...(g.children??[]).map((v,y)=>u(v,`${m}.${y}`))]}};return c.map((g,m)=>u(g,`${m}`))}return t.chapters.map(u=>p(u.file))}const vo=({id:t,transport:n,versionKey:o,chapter:r,onLocationChange:s,onNavigate:l,title:a,subtitle:p,resolveImages:c,renderImageOverlay:d,imagePanel:u,allowVertical:g,onReportError:m,revisedAt:h,backHref:f,backLabel:v,className:y,style:w})=>{var Ve,Ae,lt;const{t:b,convert:j}=G(),S=x.useMemo(()=>Ks(n),[n]),[k,$]=il(),_=Ye(),z=x.useRef(s);z.current=s;const[E,T]=x.useState(null),[C,O]=x.useState("loading");x.useEffect(()=>{let oe=!1;return T(null),O("loading"),S.getManifest(t).then(Me=>{oe||(Me?(T(Me),O("ready")):O("missing"))}).catch(()=>{oe||O("missing")}),()=>{oe=!0}},[S,t]);const W=o!==void 0,P=r!==void 0,[Y,V]=x.useState(null),[Q,ge]=x.useState(null);x.useEffect(()=>{V(null),ge(null)},[t]);const A=xe.pickTextVersion(E,W?o:Y),I=((Ve=E==null?void 0:E.versions.find(oe=>oe.key==="default"))==null?void 0:Ve.key)??((Ae=E==null?void 0:E.versions[0])==null?void 0:Ae.key)??"default",Z=(A==null?void 0:A.key)??null,ee=P?r:Q,ce=x.useCallback((oe,Me,Xe)=>{var wt;(wt=z.current)==null||wt.call(z,{key:oe,chapter:Me,isDefault:oe===I},Xe)},[I]);x.useEffect(()=>{!E||!W||o==null||E.versions.some(oe=>oe.key===o)||ce(I,null,"auto")},[E,W,o,I,ce]);const fe=x.useRef(new Map);x.useEffect(()=>{fe.current.clear()},[S,t]);const Ie=x.useCallback(async oe=>{const Me=`${t}
1104
- ${oe}`;if(fe.current.has(Me))return fe.current.get(Me)??null;const Xe=await S.getIndex(t,oe).catch(()=>null);return Xe&&fe.current.set(Me,Xe),Xe},[S,t]),[q,M]=x.useState(null),[K,Re]=x.useState("loading");x.useEffect(()=>{if(!Z)return;let oe=!1;return M(null),Re("loading"),Ie(Z).then(Me=>{oe||(Me&&Me.chapters.length>0?(M(Me),Re("ready")):Re("failed"))}),()=>{oe=!0}},[Z,Ie]),x.useEffect(()=>{if(!q||!Z||ee!=null&&q.chapters.some(Xe=>Xe.file===ee))return;const Me=q.chapters[0].file;P||ge(Me),ce(Z,Me,"auto")},[q,Z,ee,P,ce]);const se=q?ee!=null&&q.chapters.some(oe=>oe.file===ee)?ee:q.chapters[0].file:ee,ye=x.useMemo(()=>q&&se?q.chapters.find(oe=>oe.file===se)??null:null,[q,se]),We=x.useRef(0),Be=x.useCallback(async oe=>{if(!E||oe===Z||!E.versions.some(fn=>fn.key===oe))return;const Me=++We.current,Xe=await Ie(oe);if(Me!==We.current)return;const wt=ye??(se?{file:se}:null),Yt=xe.matchChapterAcrossVersions(wt,Xe);W||V(oe),P||ge(Yt),ce(oe,Yt,"version")},[E,Z,Ie,ye,se,W,P,ce]),Ee=x.useCallback(oe=>{Z&&(P||ge(oe),ce(Z,oe,"chapter"))},[Z,P,ce]),[Ce,He]=x.useState(null),D=Z&&ye?`${t}
1105
- ${Z}
1106
- ${ye.file}`:null,[re,de]=x.useState(null),ke=D!==null&&re!==D,F=x.useRef(0);x.useEffect(()=>{if(!Z||!ye)return;const oe=++F.current,Me=`${t}
1107
- ${Z}
1108
- ${ye.file}`;He(null),S.getChapter(t,Z,ye.file,{json:!!ye.has_json}).then(Xe=>{oe===F.current&&He(Xe)}).catch(()=>{oe===F.current&&He(null)}).finally(()=>{oe===F.current&&de(Me)})},[S,t,Z,ye]);const he=(A==null?void 0:A.kind)==="collated",[Ne,R]=x.useState("");x.useEffect(()=>{R("")},[t,Z]);const ne=x.useMemo(()=>Z&&he?async oe=>{const Me=await S.getChapter(t,Z,oe,{json:!0});return{juan:(Me==null?void 0:Me.json)??null,rawText:(Me==null?void 0:Me.md)??null}}:null,[S,t,Z,he]),ue=(q==null?void 0:q.type)==="kaozhen",L=x.useMemo(()=>(q==null?void 0:q.chapters.map(oe=>oe.file))??[],[q]),{matchStates:te}=hm({resetKey:`${t}
1109
- ${Z??""}`,load:ne,files:L,activeFile:se??null,activeJuan:(Ce==null?void 0:Ce.json)??null,activeRawText:(Ce==null?void 0:Ce.md)??null,query:Ne,isKaozhen:ue}),U=x.useRef(new Map);x.useEffect(()=>{U.current.clear()},[t]);const le=Du(c,se??null),{entryTitle:we,authors:Le}=wm(t,n,a===void 0),[Se,Fe]=x.useState("text");if(x.useEffect(()=>{Fe("text")},[se,Z]),C==="loading")return e.jsx(Sr,{className:y,style:w,title:a??we,label:b("reader.loading")});if(C==="missing"||!E||!A)return e.jsx("div",{className:y,style:{...w,...wr},children:b("reader.noText")});if(K==="failed")return e.jsx("div",{className:y,style:{...w,...wr},children:b("reader.tocFailed")});if(!q)return e.jsx(Sr,{className:y,style:w,title:a??we,label:b("reader.tocLoading")});const De=ym(A,q),J=jm(q,te,De,j,he),Pe=E.versions.map(oe=>({key:oe.key,label:xe.textVersionLabel(oe),optionLabel:j(xe.textVersionLabel(oe)),sourceName:oe.source_name?j(oe.source_name):void 0,license:oe.license??void 0,sourceUrl:oe.source_url??void 0,primary:oe.key===I})),N=fm((lt=q.source)==null?void 0:lt.upstream),X=(typeof a=="string"?j(a):a)??(q.title?j(q.title):we?j(we):void 0),ae=X?e.jsx("a",{href:_(t),title:b("reader.viewEntry"),onClick:l?oe=>{oe.metaKey||oe.ctrlKey||(oe.preventDefault(),l(t))}:void 0,children:X}):void 0,ie=Le.length>0?j(Le.slice(0,2).map(oe=>`${oe.dynasty?`〔${oe.dynasty}〕`:""}${oe.name}${` ${oe.role||b("reader.defaultRole")}`}`).join("、")):void 0,pe=ye?Fl(ye,De,j,he):void 0,$e=he&&!!(Ce!=null&&Ce.json),H=(Ce==null?void 0:Ce.json)??null,B=(Ce==null?void 0:Ce.md)??null,be=$e&&!ue&&Ol(H.sections),_e=be&&!(B&&k.readingMode==="paragraph"&&Tn(B)),je=$e&&be?e.jsx(xm,{juan:H,view:Se,onView:Fe,textHasEntries:_e}):void 0,me=Vs(q)||ji(q),Oe=B?B.replace(/^##\s+[^\n]+\n+/,""):null,ze=(typeof p=="string"?j(p):p)??(A.source_name?j(A.source_name):j(xe.textVersionLabel(A)));return e.jsxs(sl,{className:y,style:w,title:ae,subtitle:ze,byline:ie,current:pe,pagerUnit:De,rail:je,revisedAt:h,backHref:f,backLabel:v,onReportError:m?oe=>m({...oe,bookTitle:typeof X=="string"?X:void 0,entryId:t}):void 0,workLinkToggle:$e&&!ue&&!!l&&!!(H!=null&&H.sections.some(oe=>oe.work_id)),toc:J,tocCaption:b("reader.tocCaption",{n:q.chapters.length,unit:j(De)}),tocHeader:he&&q.chapters.length>1?e.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:ue?b("reader.searchChaptersPlaceholder"):b("reader.searchUnitPlaceholder",{unit:j(De)}),"aria-label":ue?b("reader.searchChapters"):b("reader.searchUnit",{unit:j(De)}),value:Ne,onChange:oe=>R(oe.target.value)}):void 0,activeKey:se??null,onSelect:Ee,images:le.images,imagesLoading:le.loading,renderImageOverlay:d,imagePanel:u,prefs:k,onPrefsChange:$,versions:Pe.length>1?Pe:void 0,currentVersionKey:Pe.length>1?A.key:void 0,onVersionChange:Be,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:Tn(B),allowVertical:g,children:[ke&&e.jsx(Rt,{}),!ke&&$e&&H&&e.jsx(gm,{juan:H,rawText:B,positionLabel:vm(ye,q,De,j),groupLabel:km(q,se??null),index:bm(t,q),searchQuery:Ne,onNavigate:l,transport:n,workLabelCache:U,prefs:k,view:Se,onViewChange:Fe},`${Z}/${se}`),!ke&&!$e&&Oe!=null&&ye&&e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[e.jsx("h1",{className:"bim-rd-h1",children:ye.title?j(ye.title):pe}),(A.source_name||A.license)&&e.jsxs("p",{className:"bim-rd-meta",children:[A.source_name&&e.jsxs(e.Fragment,{children:[b("reader.textSource")," ",A.source_url?e.jsx("a",{className:"bim-rd-link",href:A.source_url,target:"_blank",rel:"noreferrer",children:j(A.source_name)}):j(A.source_name)]}),A.source_name&&A.license&&e.jsx("span",{className:"bim-rd-dot"}),A.license]}),N&&e.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[b("reader.upstream")," ",N.url?e.jsx("a",{className:"bim-rd-link",href:N.url,target:"_blank",rel:"noreferrer",children:j(N.name??N.url)}):j(N.name??""),N.license&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot"}),N.license_url?e.jsx("a",{className:"bim-rd-link",href:N.license_url,target:"_blank",rel:"noreferrer",children:N.license}):N.license]}),N.note&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot"}),e.jsx(qs,{text:N.note,convert:j})]})]})]}),e.jsx("article",{className:"bim-rd-prose",children:e.jsx(go,{text:Oe,mode:k.readingMode,tables:me,gujiMarkdown:ji(q),properNames:k.properNames})})]}),!ke&&!$e&&Oe==null&&ye&&e.jsx("div",{className:"bim-rd-state",children:b("reader.chapterFailed")}),q.references&&q.references.length>0&&e.jsxs("section",{className:"bim-rd-refs",children:[e.jsx("h2",{children:b("reader.references")}),e.jsx("ol",{children:q.references.map((oe,Me)=>e.jsxs("li",{children:[oe.url?e.jsx("a",{className:"bim-rd-link",href:oe.url,target:"_blank",rel:"noopener noreferrer",children:j(oe.title)}):e.jsx("span",{children:j(oe.title)}),oe.author&&e.jsxs("span",{children:[",",j(oe.author)]}),oe.note&&e.jsxs("span",{children:["。",j(oe.note)]})]},Me))})]})]})};function vm(t,n,o,r){var l,a;if(!t)return;const s=(a=(l=n.juan_metadata)==null?void 0:l[t.file])==null?void 0:a.vol_label;return r(s?`${s}冊`:`${o}${t.n}`)}function km(t,n){if(!n)return;const o=r=>{var s;for(const l of r??[]){const a=o(l.children);if(a)return a;if((s=l.files)!=null&&s.includes(n))return l.label}};return o(t.juan_groups)}function wm(t,n,o){const[r,s]=x.useState({entryTitle:void 0,authors:[]});return x.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let l=!1;return Promise.resolve(n.getItem(t)).then(a=>{if(l||!a)return;const p=(a.authors??[]).filter(c=>c&&c.name);s({entryTitle:o&&typeof a.title=="string"?a.title:void 0,authors:p})}).catch(()=>{}),()=>{l=!0}},[t,n,o]),r}const Dl={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")}},Sm=Dl.other,Ul={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")}},$m=Ul.pending;function _m(t){try{const n=new Date(t),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 t}}function Cm(t,n){if(!t)return!1;try{const o=new URL(t,n);if(o.protocol!=="http:"&&o.protocol!=="https:")return!1;const r=new URL(n);return o.hostname===r.hostname}catch{return!1}}const ko=({items:t,loading:n})=>{const o=Ye(),{t:r,convert:s}=G();return n?e.jsx(Rt,{}):t.length===0?e.jsx("div",{style:zm,children:r("feedback.empty")}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:t.map(l=>{const a=Dl[l.type]||Sm,p=Ul[l.status]||$m,c=typeof window<"u"&&Cm(l.pageUrl,window.location.href);return e.jsxs("div",{style:Tm,children:[e.jsxs("div",{style:Nm,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{..._r,background:a.color},children:r(`feedback.listType.${a.key}`)}),e.jsx("span",{style:{..._r,background:p.color},children:r(`feedback.status.${p.key}`)})]}),e.jsx("span",{style:Im,children:_m(l.createdAt)})]}),(l.resourceId||l.pageUrl)&&e.jsxs("div",{style:Rm,children:[l.resourceId&&e.jsx("a",{href:o(l.resourceId),style:ci,children:l.resourceId}),l.pageUrl&&!l.resourceId&&(c?e.jsx("a",{href:l.pageUrl,style:ci,children:l.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):e.jsx("span",{style:ci,children:l.pageUrl}))]}),e.jsx("div",{style:Em,children:s(l.content)}),l.reply&&e.jsxs("div",{style:Lm,children:[e.jsx("div",{style:Pm,children:r("feedback.reply")}),e.jsx("div",{children:s(l.reply)})]})]},l.id)})})},zm={textAlign:"center",padding:"40px 0",color:i("desc-fg"),fontSize:"14px"},Tm={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"16px"},Nm={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},_r={fontSize:"12px",color:i("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},Im={fontSize:"12px",color:i("desc-fg")},Rm={fontSize:"12px",marginBottom:"6px"},ci={color:i("primary"),textDecoration:"none",borderBottom:`1px dashed ${i("primary")}`},Em={fontSize:"14px",lineHeight:"1.6",color:i("fg"),whiteSpace:"pre-wrap"},Lm={marginTop:"12px",padding:"10px 12px",background:i("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:i("fg")},Pm={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:i("primary")},Ii=({transport:t,onNavigate:n,recommendedIds:o,activeTab:r,onTabChange:s,feedbackApiUrl:l})=>{const a=ve(),[p,c]=x.useState(null),[d,u]=x.useState([]),[g,m]=x.useState("recommend"),[h,f]=x.useState([]),[v,y]=x.useState(!1),w=r??g,b=Y=>{m(Y),s==null||s(Y)},[j,S]=x.useState(!0),[k,$]=x.useState(null),[_,z]=x.useState(null),[E,T]=x.useState(null);x.useEffect(()=>{let Y=!1;if(t.getCounts)return t.getCounts().then(V=>{Y||c({works:V.works,books:V.books,collections:V.collections})}).catch(()=>{}),()=>{Y=!0}},[t]),x.useEffect(()=>{let Y=!1;return(async()=>{if(o)return o;if(t.getRecommended)try{const Q=await t.getRecommended();if(Q!=null&&Q.groups)return Q.groups.flatMap(ge=>ge.items.map(A=>({...A,group:ge.name})))}catch{}return[]})().then(async Q=>{if(Y)return;const ge=Q.filter(I=>I.id);if(ge.length===0){S(!1);return}const A=await Promise.all(ge.map(async I=>{if(I.type)return{id:I.id,title:I.title,type:I.type,author:I.author,dynasty:I.dynasty,role:I.role,edition:I.edition,has_text:I.has_text,has_image:I.has_image,has_collated:I.has_collated,subtype:I.subtype,primary_name:I.primary_name,group:I.group,fallbackDescription:I.description};try{let Z=null;if(t.getEntry)Z=await t.getEntry(I.id);else{const ee=await t.getItem(I.id);ee&&(Z={id:I.id,title:ee.title||I.id,type:ee.type||"work"})}if(Z)return{...Z,group:I.group,fallbackDescription:I.description}}catch{}return{id:I.id,title:I.title,type:xe.extractType(I.id),group:I.group,fallbackDescription:I.description}}));Y||(u(A.filter(I=>I!==null)),S(!1))}),()=>{Y=!0}},[t,o]);const C=x.useRef(!1),O=x.useRef(!1),W=x.useRef(!1);x.useEffect(()=>{if(w!=="catalog"||C.current)return;const Y=t.getCatalogProgress??t.getResourceProgress;if(!Y)return;C.current=!0;let V=!1;return Y.call(t).then(Q=>{V||$(Q)}).catch(()=>{C.current=!1}),()=>{V=!0}},[t,w]),x.useEffect(()=>{if(w!=="collection"||O.current||!t.getCollectionProgress)return;O.current=!0;let Y=!1;return t.getCollectionProgress().then(V=>{Y||z(V)}).catch(()=>{O.current=!1}),()=>{Y=!0}},[t,w]),x.useEffect(()=>{if(w!=="site"||W.current||!t.getSiteProgress)return;W.current=!0;let Y=!1;return t.getSiteProgress().then(V=>{Y||T(V)}).catch(()=>{W.current=!1}),()=>{Y=!0}},[t,w]),x.useEffect(()=>{if(!l||w!=="feedback")return;let Y=!1;return y(!0),fetch(l).then(V=>V.json()).then(V=>{!Y&&V.success&&f(V.items||[])}).catch(()=>{}).finally(()=>{Y||y(!1)}),()=>{Y=!0}},[l,w]);const P=Y=>e.jsx(Gt,{type:Y,size:12});return e.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:i("fg")},children:e.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[e.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"16px"},children:[e.jsx(Xt,{label:a.home.recommendTab,active:w==="recommend",onClick:()=>b("recommend")}),e.jsx(Xt,{label:a.home.catalogTab,active:w==="catalog",onClick:()=>b("catalog")}),e.jsx(Xt,{label:a.home.collectionTab,active:w==="collection",onClick:()=>b("collection")}),e.jsx(Xt,{label:a.home.siteTab,active:w==="site",onClick:()=>b("site")}),l&&e.jsx(Xt,{label:a.home.feedbackTab,active:w==="feedback",onClick:()=>b("feedback")})]}),w==="recommend"&&e.jsx(Am,{recommended:d,loading:j,onNavigate:n,getIcon:P,t:a}),w==="catalog"&&e.jsx(Cr,{progress:k,t:a,onNavigate:n}),w==="collection"&&e.jsx(Cr,{progress:_,t:a,onNavigate:n}),w==="site"&&e.jsx(Mm,{progress:E,t:a,totalWorks:(p==null?void 0:p.works)??0}),w==="feedback"&&l&&e.jsx(ko,{items:h,loading:v})]})})},Xt=({label:t,active:n,onClick:o})=>e.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:t}),Am=({recommended:t,loading:n,onNavigate:o,getIcon:r,t:s})=>{const l=Ye();if(n)return e.jsx(Rt,{});if(t.length===0)return null;const a=new Map;for(const p of t){const c=p.group||s.home.recommendedBrowse;a.has(c)||a.set(c,[]),a.get(c).push(p)}return e.jsx(e.Fragment,{children:Array.from(a.entries()).map(([p,c])=>e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:p}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"8px"},children:c.map(d=>{const u=d.dynasty||d.author?`${d.dynasty?`〔${d.dynasty}〕`:""}${d.author||""}`:d.fallbackDescription;return e.jsxs("a",{href:l(d.id),onClick:g=>{g.metaKey||g.ctrlKey||(g.preventDefault(),o==null||o(d.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:[e.jsx("span",{style:{fontSize:"20px"},children:r(d.type)}),e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[d.title,d.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:i("desc-fg"),marginLeft:"4px"},children:d.edition})]}),u&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u})]})]},d.id)})})]},p))})},Cr=({progress:t,t:n,onNavigate:o})=>{if(!t)return e.jsx(Rt,{});const r=[...t.resources].sort((p,c)=>p.priority-c.priority),s=["in_progress","done","todo"],l={in_progress:n.home.statusInProgress,done:n.home.statusDone,todo:n.home.statusTodo},a={in_progress:i("progress-active"),done:i("progress-done"),todo:i("progress-todo")};return e.jsx("div",{children:s.map(p=>{const c=r.filter(d=>d.status===p);return c.length===0?null:e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:a[p]}}),l[p]," (",c.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c.map(d=>e.jsx(Bm,{item:d,t:n,statusColor:a[p],onNavigate:o},d.id))})]},p)})})},Bm=({item:t,t:n,statusColor:o,onNavigate:r})=>{const s=Ye(),l=t.total>0?Math.round(t.imported/t.total*100):0,a=t.type==="catalog"?n.home.typeCatalog:n.home.typeCollection;return e.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(()=>{const p=t.edition?`${t.name}·${t.edition}`:t.name,c=t.collection_id||t.work_id;return c&&r?e.jsx("a",{href:s(c),onClick:d=>{d.metaKey||d.ctrlKey||(d.preventDefault(),r(c))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`},onMouseEnter:d=>d.currentTarget.style.borderBottomStyle="solid",onMouseLeave:d=>d.currentTarget.style.borderBottomStyle="dashed",children:p}):t.url?e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:p}):p})()}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"4px",background:i("widget-border"),color:i("desc-fg"),whiteSpace:"nowrap"},children:t.collection_id?n.indexType.collection:t.work_id?n.indexType.work:a})]}),e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:t.total>0?it(n.home.progressFormat,{imported:String(t.imported),total:String(t.total)}):n.home.totalPending})]}),t.total>0&&e.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:e.jsx("div",{style:{height:"100%",width:`${l}%`,borderRadius:"2px",background:o,transition:"width 0.3s ease"}})}),t.description&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:t.description})]})},Mm=({progress:t,t:n,totalWorks:o})=>{if(!t)return e.jsx(Rt,{});const r=[...t.resources].sort((c,d)=>c.priority-d.priority),s=r.filter(c=>c.imported>0),l=r.filter(c=>c.imported===0),a=s.reduce((c,d)=>Math.max(c,d.imported),0),p=o>0?Math.round(a/o*100):0;return e.jsxs("div",{children:[o>0&&e.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,": ",e.jsx("strong",{children:a.toLocaleString()})," / ",o.toLocaleString()," ",n.indexType.work," (",p,"%)"]}),s.length>0&&e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-done")}}),n.home.statusInProgress," (",s.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(c=>e.jsx(zr,{item:c,t:n,totalWorks:o},c.id))})]}),l.length>0&&e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-todo")}}),n.home.statusTodo," (",l.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:l.map(c=>e.jsx(zr,{item:c,t:n,totalWorks:o},c.id))})]})]})},zr=({item:t,t:n,totalWorks:o})=>{const r=o>0?Math.round(t.imported/o*100):0;return e.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:e.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:t.url?e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:t.name}):t.name})}),e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:t.imported>0?`${t.imported.toLocaleString()} ${n.indexType.work} (${r}%)`:n.home.statusTodo})]}),t.imported>0&&o>0&&e.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:e.jsx("div",{style:{height:"100%",width:`${r}%`,borderRadius:"2px",background:i("progress-done"),transition:"width 0.3s ease"}})}),t.description&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:t.description})]})},Tr="(max-width: 768px)";function Wm(){const[t,n]=x.useState(()=>typeof window>"u"?!1:window.matchMedia(Tr).matches);return x.useEffect(()=>{const o=window.matchMedia(Tr),r=s=>n(s.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[]),t}const Hm=({transport:t,hideModeIndicator:n=!0,onEntryClick:o,recommendedIds:r,headerRight:s})=>{var O;const l=ve(),{convert:a}=Te(),p=Wm(),[c,d]=x.useState(null),[u,g]=x.useState(null),[m,h]=x.useState(!1),[f,v]=x.useState("detail"),[y,w]=x.useState([]),[b,j]=x.useState(!1),S=x.useCallback(async W=>{if(!t.getCollectionCatalogs&&!t.getCollectionCatalog){w([]);return}j(!0);try{if(t.getCollectionCatalogs){const P=await t.getCollectionCatalogs(W);w(P||[])}else if(t.getCollectionCatalog){const P=await t.getCollectionCatalog(W);w(P?[{resource_id:"",data:P}]:[])}}catch{w([])}finally{j(!1)}},[t]),k=x.useCallback(async W=>{if(o){o(W);return}d(W),g(null),w([]),v("detail"),h(!0);try{const P=await t.getItem(W.id);P&&(g(P),P.type==="collection"&&S(W.id))}catch(P){console.error("加载详情失败:",P)}finally{h(!1)}},[t,o,S]),$=x.useCallback(async W=>{g(null),w([]),v("detail"),h(!0);try{const P=await t.getItem(W);P&&(g(P),d({id:W,title:P.title||W,type:P.type||"book"}),P.type==="collection"&&S(W))}catch(P){console.error("导航失败:",P)}finally{h(!1)}},[t,S]),_=typeof(u==null?void 0:u.text_count)=="number"&&u.text_count>0,z=(u==null?void 0:u.type)==="collection"&&(y.length>0||b)||(u==null?void 0:u.type)==="work"&&_,E=p&&(m||u),T=x.useCallback(()=>{d(null),g(null),w([]),v("detail")},[]),C=e.jsx(e.Fragment,{children:m?e.jsx(Rt,{}):u?e.jsxs(e.Fragment,{children:[(z||s)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${i("widget-border")}`,padding:p?"0 12px":"0 48px",background:i("input-bg"),flexShrink:0,overflowX:p?"auto":void 0},children:[z&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>v("detail"),style:vn(f==="detail"),children:l.detailTab.basicInfo}),u.type==="collection"&&b&&y.length===0&&e.jsxs("button",{onClick:()=>{},style:vn(!1),children:[l.detailTab.catalog,e.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),u.type==="collection"&&y.map(W=>e.jsx("button",{onClick:()=>v(`catalog:${W.resource_id}`),style:vn(f===`catalog:${W.resource_id}`),children:W.short_name?`${a(W.short_name)}${l.detailTab.catalogSuffix}`:l.detailTab.collectionCatalog},W.resource_id)),u.type==="work"&&_&&e.jsx("button",{onClick:()=>v("collated"),style:vn(f==="collated"),children:l.detailTab.collatedEdition})]}),s&&e.jsx("div",{style:{marginLeft:"auto",flexShrink:0,padding:"4px 0"},children:s})]}),e.jsx("div",{style:{padding:p?"16px 12px":"32px 48px",maxWidth:"900px",flex:1,overflow:"auto"},children:f==="detail"?e.jsx(Ki,{data:u,transport:t,onNavigate:$}):f.startsWith("catalog:")?e.jsx(qi,{data:(O=y.find(W=>`catalog:${W.resource_id}`===f))==null?void 0:O.data,onNavigate:$}):f==="collated"?e.jsx(vo,{id:u.id,transport:t,onNavigate:$}):null})]}):e.jsx(Ii,{transport:t,onNavigate:$,recommendedIds:r})});return p?e.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:E?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${i("widget-border")}`,background:i("input-bg"),flexShrink:0},children:e.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:["← ",l.detailTab.basicInfo]})}),e.jsx("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:C})]}):e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[e.jsx(yi,{transport:t,onEntryClick:k,hideModeIndicator:n}),!u&&e.jsx(Ii,{transport:t,onNavigate:$,recommendedIds:r})]})}):e.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:[e.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:`1px solid ${i("widget-border")}`,display:"flex",flexDirection:"column",background:i("input-bg"),overflow:"hidden"},children:e.jsx("div",{style:{flex:1,overflow:"auto"},children:e.jsx(yi,{transport:t,onEntryClick:k,hideModeIndicator:n})})}),e.jsx("div",{style:{flex:1,overflow:"auto",background:i("bg"),display:"flex",flexDirection:"column"},children:C})]})};function vn(t){return{padding:"10px 16px",border:"none",borderBottom:t?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(t?"primary":"desc-fg"),cursor:"pointer",fontSize:"13px",fontWeight:t?600:400}}const Om=({data:t,onNavigate:n,className:o,style:r})=>{var u;const{t:s,convert:l}=G(),[a,p]=x.useState(((u=t.divisions[0])==null?void 0:u.name)??null),[c,d]=x.useState(null);return e.jsxs("div",{className:o,style:r,children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:l(t.title)}),t.stats&&e.jsxs("div",{style:{fontSize:"13px",color:i("desc-fg"),display:"flex",gap:"16px"},children:[t.total_volumes!=null&&e.jsxs("span",{children:[s("catalog.totalVolumes")," ",e.jsx("strong",{children:t.total_volumes})," ",s("unit.juan")]}),t.stats.zhulu!=null&&e.jsxs("span",{children:[s("catalogPage.zhulu")," ",e.jsx("strong",{children:t.stats.zhulu})," ",s("unit.bu")]}),t.stats.cunmu!=null&&e.jsxs("span",{children:[s("catalogPage.cunmu")," ",e.jsx("strong",{children:t.stats.cunmu})," ",s("unit.bu")]}),t.stats.categories!=null&&e.jsx("span",{children:s("catalogPage.categoriesN",{n:t.stats.categories})})]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.divisions.map(g=>e.jsx(Fm,{division:g,expanded:a===g.name,onToggle:()=>p(a===g.name?null:g.name),expandedCat:c,onCatToggle:m=>d(c===m?null:m),onNavigate:n},g.name))})]})},Fm=({division:t,expanded:n,onToggle:o,expandedCat:r,onCatToggle:s,onNavigate:l})=>{const{t:a,convert:p}=G(),c=t.categories.reduce((d,u)=>{const g=u.stats||{zhulu:0,cunmu:0};return d+(g.zhulu||0)+(g.cunmu||0)},0);return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[e.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:[e.jsx("span",{children:p(t.name)}),e.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg")},children:[a("catalogPage.divisionStat",{cats:t.categories.length,books:c}),e.jsx("span",{style:{marginLeft:"8px"},children:n?"▲":"▼"})]})]}),n&&e.jsx("div",{style:{padding:"4px 0"},children:t.categories.map(d=>{const u=`${t.name}/${d.name}`;return e.jsx(Dm,{category:d,expanded:r===u,onToggle:()=>s(u),onNavigate:l},d.name)})})]})},Dm=({category:t,expanded:n,onToggle:o,onNavigate:r})=>{var d,u,g,m;const{t:s,convert:l}=G(),a=((d=t.books)==null?void 0:d.zhulu)||[],p=((u=t.books)==null?void 0:u.cunmu)||[],c=(((g=t.stats)==null?void 0:g.zhulu)||a.length)+(((m=t.stats)==null?void 0:m.cunmu)||p.length);return e.jsxs("div",{children:[e.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:[e.jsxs("span",{style:{fontWeight:500},children:[l(t.name),t.volumes&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:l(t.volumes)})})]}),e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[s("catalogPage.booksN",{n:c})," ",n?"▲":"▼"]})]}),n&&(a.length>0||p.length>0)&&e.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[a.length>0&&e.jsx(Nr,{label:s("catalogPage.zhulu"),books:a,onNavigate:r}),p.length>0&&e.jsx(Nr,{label:s("catalogPage.cunmu"),books:p,onNavigate:r})]})]})},Nr=({label:t,books:n,onNavigate:o})=>{const{t:r,convert:s}=G(),l=Ye(),[a,p]=x.useState(n.length<=20),c=a?n:n.slice(0,10);return e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:[t," (",n.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((d,u)=>e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[e.jsx("span",{style:{fontWeight:500,color:i("fg")},children:d.work_id&&o?e.jsx("a",{href:l(d.work_id),onClick:g=>{g.metaKey||g.ctrlKey||(g.preventDefault(),o(d.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`},children:s(d.title)}):s(d.title)}),d.volumes&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(d.volumes)}),d.author&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(d.author).slice(0,20)})]},u))}),!a&&e.jsx("button",{onClick:()=>p(!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})})]})},at=({title:t,onSave:n,onAskAI:o,extraButtons:r,children:s})=>{const l=ve();return e.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",paddingBottom:"8px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:i("fg")},children:t}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[r,o&&e.jsx("button",{onClick:o,style:Vm,children:"AI"}),n&&e.jsx("button",{onClick:n,style:Um,children:l.action.save})]})]}),s]})},Um={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Vm={padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},nt=({label:t,value:n,onChange:o,placeholder:r,disabled:s})=>e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:{display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:t}),e.jsx("input",{type:"text",value:n,onChange:l=>o(l.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"}})]}),Tt=({value:t,onChange:n,placeholder:o})=>{const r=x.useRef(null);return x.useEffect(()=>{r.current&&(r.current.style.height="auto",r.current.style.height=`${r.current.scrollHeight}px`)},[t]),e.jsx("textarea",{ref:r,value:t||"",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"}})},In=({children:t,color:n,style:o})=>e.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:t});function Gm(t){const n=t.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const Sn=({value:t,onChange:n,label:o})=>{const[r,s]=x.useState(!1),l=x.useRef(null),a=Gm(t||"");return x.useEffect(()=>{r&&l.current&&l.current.focus()},[r]),!r&&a?e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:Ir,children:o}),e.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:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:i("fg")},children:a.name}),e.jsx(In,{children:a.id})]})]}):e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:Ir,children:o}),e.jsx("input",{ref:l,type:"text",value:t||"",onChange:p=>n(p.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"}})]})},Ir={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500};function Ym(t){switch(t){case"url":return i("source-url");case"bookID":return i("source-bookid");default:return i("desc-fg")}}function Km(t){switch(t){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const Vl=({items:t,onChange:n,onOpenEntityPicker:o})=>{const r=ve(),[s,l]=x.useState(null),a=()=>{n([...t,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),l(t.length)},p=g=>{n(t.filter((m,h)=>h!==g)),s===g&&l(null)},c=(g,m,h)=>{const f=[...t];f[g]={...f[g],[m]:h},n(f)},d=(g,m)=>{const h=[...t];h[g]={...h[g],type:m,id:"",name:""},n(h),m==="bookID"&&o&&o(f=>{const v=[...t];v[g]={...v[g],id:f.id,name:f.title,type:"bookID"},n(v)})},u=g=>{o&&o(m=>{const h=[...t];h[g]={...h[g],id:m.id,name:m.title,type:"bookID"},n(h)})};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((g,m)=>e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>l(s===m?null:m),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===m?"▼":"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:i("fg")},children:g.name||`${r.editor.sourcePlaceholder} ${m+1}`}),g.type&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:Ym(g.type),color:i("on-color-fg"),borderRadius:"3px",fontWeight:500},children:Km(g.type)}),e.jsx("button",{onClick:h=>{h.stopPropagation(),p(m)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:r.editor.deleteThisSource,children:"✕"})]}),s===m&&e.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!g.type&&e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.editor.selectSourceType}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsxs("button",{onClick:()=>d(m,"bookID"),style:{...Rr,borderColor:i("source-bookid"),color:i("source-bookid")},children:[e.jsx("span",{style:{fontSize:"18px"},children:"📚"}),e.jsx("span",{children:"Book ID"}),e.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.fromExistingBook})]}),e.jsxs("button",{onClick:()=>d(m,"url"),style:{...Rr,borderColor:i("source-url"),color:i("source-url")},children:[e.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),e.jsx("span",{children:"URL"}),e.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.enterUrl})]})]})]}),g.type==="bookID"&&e.jsx(e.Fragment,{children:e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("label",{style:mt,children:r.action.selectBookOrWork}),e.jsx("button",{onClick:()=>{const h=[...t];h[m]={...h[m],type:"",id:"",name:""},n(h)},style:Er,children:r.action.changeType})]}),g.id&&g.name?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:i("bg"),border:`1px solid ${i("source-bookid")}`,borderRadius:"6px"},children:[e.jsx("span",{style:{color:i("source-bookid"),fontSize:"16px"},children:"✓"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:g.name}),e.jsx("code",{style:{fontSize:"11px",background:i("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:g.id})]}),e.jsx("button",{onClick:()=>u(m),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})]}):e.jsxs("button",{onClick:()=>u(m),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:[e.jsx("span",{children:"🔍"}),e.jsx("span",{children:r.action.clickToSelectBookOrWork})]})]})}),g.type==="url"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("label",{style:mt,children:r.label.sourceName}),e.jsx("button",{onClick:()=>{const h=[...t];h[m]={...h[m],type:"",id:"",name:""},n(h)},style:Er,children:r.action.changeType})]}),e.jsx("input",{type:"text",value:g.name,onChange:h=>c(m,"name",h.target.value),placeholder:r.editor.sourceNamePlaceholder,style:Pt})]}),e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.label.urlAddress}),e.jsx("input",{type:"text",value:g.id,onChange:h=>c(m,"id",h.target.value),placeholder:"https://...",style:Pt})]})]}),g.type&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{borderTop:`1px dashed ${i("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:e.jsx("label",{style:{...mt,opacity:.7},children:r.label.optionalInfo})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.label.detailsOptional}),e.jsx("input",{type:"text",value:g.details,onChange:h=>c(m,"details",h.target.value),placeholder:r.editor.detailsPlaceholder,style:Pt})]}),e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.label.positionOptional}),e.jsx("input",{type:"text",value:g.position,onChange:h=>c(m,"position",h.target.value),placeholder:"如: 卷三, p.52",style:Pt})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.label.dataVersionOptional}),e.jsx("input",{type:"text",value:g.version,onChange:h=>c(m,"version",h.target.value),placeholder:"如: v1.0, 2024-01",style:Pt})]}),e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.label.processorVersionOptional}),e.jsx("input",{type:"text",value:g.processor_version,onChange:h=>c(m,"processor_version",h.target.value),placeholder:"如: v0.1",style:Pt})]})]})]})]})})]},m)),e.jsxs("button",{onClick:a,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:[e.jsx("span",{children:"+"}),e.jsx("span",{children:r.action.addSource})]})]})},mt={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},Pt={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"},Rr={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"},Er={background:"transparent",border:"none",color:i("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function Gl(t){if(!t||!t.trim())return[];try{const n=JSON.parse(t);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 Yl(t){return!t||t.length===0?"":JSON.stringify(t)}const Kl=({entityType:t,entityId:n,entityTitle:o,parentWork:r,parentCollection:s,belongsToWork:l,belongsToCollection:a,childWorks:p,childCollections:c,containedBooks:d,siblingBooks:u,onLinkEntity:g,onUnlinkEntity:m,onViewEntity:h,onCreateAndLink:f,onSaveRelations:v})=>{const y=ve();return e.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[e.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:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:"🔗"}),e.jsx("span",{children:y.section.relations})]}),v&&e.jsx("button",{onClick:v,style:qm,children:y.action.save})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[t==="book"&&e.jsxs(e.Fragment,{children:[e.jsx(Qt,{direction:"up",title:y.relation.belongsToWork,entity:l,onView:h,onUnlink:()=>m("workId"),onLink:()=>g("workId","work"),onCreate:()=>f("workId","work",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),e.jsx(Qt,{direction:"up",title:y.relation.containedInCollection,entity:a,onView:h,onUnlink:()=>m("collectionId"),onLink:()=>g("collectionId","collection"),onCreate:()=>f("collectionId","collection",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),l&&u&&u.length>0&&e.jsx(At,{direction:"horizontal",title:`${y.relation.siblingVersions} (${u.length})`,entities:u,onView:h,onAdd:()=>f("siblingBook","book",{workId:l.id}),addLabel:y.relation.addVersionForWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),t==="work"&&e.jsxs(e.Fragment,{children:[e.jsx(Qt,{direction:"up",title:y.relation.parentWork,entity:r,onView:h,onUnlink:()=>m("parentWorkId"),onLink:()=>g("parentWorkId","work"),onCreate:()=>f("parentWorkId","work"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),p&&p.length>0&&e.jsx(At,{direction:"down",title:`${y.relation.childWorks} (${p.length})`,entities:p,onView:h,onAdd:()=>f("childWork","work",{parentWorkId:n}),addLabel:y.action.addSubWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),c&&c.length>0&&e.jsx(At,{direction:"down",title:`${y.relation.collectionImpl} (${c.length})`,entities:c,onView:h,onAdd:()=>f("childCollection","collection",{workId:n}),addLabel:y.action.addCollectionImpl,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),e.jsx(At,{direction:"down",title:`${y.relation.allVersions} (${(d==null?void 0:d.length)??0})`,entities:d||[],onView:h,onAdd:()=>f("childBook","book",{workId:n}),addLabel:y.action.addVersion,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),t==="collection"&&e.jsxs(e.Fragment,{children:[e.jsx(Qt,{direction:"up",title:y.relation.correspondingWork,entity:l,onView:h,onUnlink:()=>m("workId"),onLink:()=>g("workId","work"),onCreate:()=>f("workId","work",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),e.jsx(Qt,{direction:"up",title:y.relation.parentCollection,entity:s,onView:h,onUnlink:()=>m("parentCollectionId"),onLink:()=>g("parentCollectionId","collection"),onCreate:()=>f("parentCollectionId","collection"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),e.jsx(At,{direction:"down",title:`${y.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:h,onAdd:()=>f("childCollection","collection",{parentCollectionId:n}),addLabel:y.action.addSubCollection,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),e.jsx(At,{direction:"down",title:`${y.relation.containedBooks} (${(d==null?void 0:d.length)??0})`,entities:d||[],onView:h,onAdd:()=>f("childBook","book",{collectionId:n}),addLabel:y.action.addBook,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]})]})]})},Qt=({direction:t,title:n,entity:o,onView:r,onUnlink:s,onLink:l,onCreate:a,linkLabel:p,createLabel:c,notLinkedLabel:d,viewLabel:u,unlinkLabel:g})=>{const m=i(t==="up"?"relation-up":t==="down"?"relation-down":"relation-flat"),h=t==="up"?"⬆️":t==="down"?"⬇️":"↔️";return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("input-bg")},children:[e.jsxs("div",{style:{fontSize:"12px",color:m,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:h}),e.jsx("span",{children:n})]}),o?e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:i("bg"),borderRadius:"4px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:ql(o.type)}),e.jsx("span",{style:{fontWeight:500},children:o.title}),e.jsx("span",{style:{fontSize:"11px",opacity:.6},children:o.id})]}),e.jsxs("div",{style:{display:"flex",gap:"4px"},children:[e.jsx(Lr,{onClick:()=>r(o),title:u,children:"👁️"}),e.jsx(Lr,{onClick:s,title:g,danger:!0,children:"✕"})]})]}):e.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:d}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsx(Ri,{onClick:l,children:p}),e.jsx(Ri,{onClick:a,primary:!0,children:c})]})]})},At=({direction:t,title:n,entities:o,onView:r,onAdd:s,addLabel:l,noneLabel:a,expandMoreLabel:p})=>{const[c,d]=x.useState(!1),u=i(t==="up"?"relation-up":t==="down"?"relation-down":"relation-flat"),g=t==="up"?"⬆️":t==="down"?"⬇️":"↔️",m=c?o:o.slice(0,5);return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("input-bg")},children:[e.jsxs("div",{style:{fontSize:"12px",color:u,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:g}),e.jsx("span",{children:n})]}),o.length>0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[m.map(h=>e.jsxs("div",{onClick:()=>r(h),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:i("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[e.jsx("span",{children:ql(h.type)}),e.jsx("span",{children:h.title})]},h.id)),o.length>5&&!c&&e.jsxs("div",{onClick:()=>d(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:i("link-fg"),cursor:"pointer"},children:[p," (",o.length-5,")"]})]}):e.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:a}),e.jsx("div",{style:{marginTop:"8px"},children:e.jsxs(Ri,{onClick:s,primary:!0,children:["+ ",l]})})]})},Lr=({onClick:t,title:n,danger:o,children:r})=>e.jsx("button",{onClick:s=>{s.stopPropagation(),t()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:o?i("danger"):"inherit",opacity:.7},children:r}),Ri=({onClick:t,primary:n,children:o})=>e.jsx("button",{onClick:t,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 ql(t){switch(t){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const qm={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},Zl=({isOpen:t,entityType:n,title:o,onSelect:r,onCancel:s,onCreate:l,searchResults:a,onSearch:p,isLoading:c,excludeId:d})=>{const[u,g]=x.useState(""),m=d?a.filter(y=>y.id!==d):a;x.useEffect(()=>{t&&(g(""),p(""))},[t]);const h=y=>{g(y),p(y)};if(!t)return null;const f=n==="work"?"作品":n==="book"?"书籍":"丛编",v=n==="work"?"📜":n==="book"?"📖":"📚";return e.jsx("div",{style:Zm,children:e.jsxs("div",{style:Jm,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:o}),e.jsx("button",{onClick:s,style:Xm,children:"✕"})]}),e.jsx("div",{style:{padding:"12px 16px"},children:e.jsx("input",{type:"text",value:u,onChange:y=>h(y.target.value),placeholder:`搜索${f}名称或 ID...`,autoFocus:!0,style:Qm})}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?e.jsx("div",{style:di,children:"搜索中..."}):m.length>0?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:m.map(y=>e.jsxs("div",{onClick:()=>r(y),style:eg,children:[e.jsx("span",{style:{fontSize:"16px"},children:v}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontWeight:500},children:[y.title,y.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:y.edition})]}),e.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[y.id,y.author&&` · ${y.author}`,y.dynasty&&` · ${y.dynasty}`]})]})]},y.id))}):u?e.jsxs("div",{style:di,children:["未找到匹配的",f]}):e.jsxs("div",{style:di,children:["输入关键词搜索",f]})}),e.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),e.jsxs("button",{onClick:l,style:tg,children:["创建新",f,"并关联"]})]})]})})},Zm={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Jm={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")},Xm={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},Qm={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"},eg={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:i("primary-soft")},di={padding:"20px",textAlign:"center",color:i("desc-fg")},tg={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Pr={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},ng={work:"📜",book:"📖",collection:"📚",entity:"👤"},Jl=({isOpen:t,entityType:n,relationField:o,inheritData:r,onConfirm:s,onCancel:l})=>{const[a,p]=x.useState(""),c=x.useRef(null);x.useEffect(()=>{t&&(p((r==null?void 0:r.title)||""),setTimeout(()=>{var m,h;(m=c.current)==null||m.focus(),(h=c.current)==null||h.select()},100))},[t,r==null?void 0:r.title]);const d=m=>{m.key==="Enter"&&a.trim()?u():m.key==="Escape"&&l()},u=()=>{a.trim()&&s(a.trim(),{...r,title:a.trim()})};if(!t)return null;const g=()=>{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`创建新${Pr[n]}`}};return e.jsx("div",{style:ig,onClick:m=>{m.target===m.currentTarget&&l()},children:e.jsxs("div",{style:og,onClick:m=>m.stopPropagation(),children:[e.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:ng[n]}),e.jsx("span",{children:g()})]}),e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:i("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",e.jsx("span",{style:{color:i("danger"),marginLeft:"4px"},children:"*"})]}),e.jsx("input",{ref:c,type:"text",value:a,onChange:m=>p(m.target.value),onKeyDown:d,placeholder:`请输入${Pr[n]}名称...`,style:rg})]}),((r==null?void 0:r.author)||(r==null?void 0:r.dynasty))&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),background:i("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[e.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(r==null?void 0:r.author)&&e.jsxs("div",{children:["作者: ",r.author]}),(r==null?void 0:r.dynasty)&&e.jsxs("div",{children:["朝代/年份: ",r.dynasty]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[e.jsx("button",{onClick:l,style:sg,children:"取消"}),e.jsx("button",{onClick:u,disabled:!a.trim(),style:{...lg,opacity:a.trim()?1:.6,cursor:a.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},ig={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},og={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")},rg={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"},sg={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},lg={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg")};function ag(t){switch(t){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Xl(t){switch(t){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function cg(t){switch(t){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 Ql=({isOpen:t,title:n,filterType:o="all",recentEntities:r=[],excludeId:s,showCreateButton:l=!1,createButtonText:a,onSelect:p,onCancel:c,onCreate:d,onSearch:u})=>{const[g,m]=x.useState(""),[h,f]=x.useState([]),[v,y]=x.useState(!1),[w,b]=x.useState("recent");x.useEffect(()=>{t&&(m(""),f([]),b(r.length>0?"recent":"search"))},[t,r.length]),x.useEffect(()=>{if(!g.trim()){f([]);return}const z=setTimeout(async()=>{y(!0);try{f(await u(g,o))}catch{f([])}finally{y(!1)}},300);return()=>clearTimeout(z)},[g,o,u]);const j=x.useCallback(z=>{m(z.target.value),z.target.value.trim()&&b("search")},[]),S=x.useCallback(z=>s?z.filter(E=>E.id!==s):z,[s]);if(!t)return null;const k=n||(o==="all"?"选择实体":`选择${Xl(o)}`),$=S(r),_=S(h);return e.jsx("div",{style:pg,children:e.jsxs("div",{style:ug,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:k}),e.jsx("button",{onClick:c,style:mg,children:"✕"})]}),e.jsx("div",{style:{padding:"16px 20px 12px"},children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{type:"text",value:g,onChange:j,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:gg}),e.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),v&&e.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),$.length>0&&e.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsxs(Ar,{active:w==="recent",onClick:()=>b("recent"),children:["最近使用 (",$.length,")"]}),e.jsxs(Ar,{active:w==="search",onClick:()=>b("search"),children:["搜索结果 ",_.length>0&&`(${_.length})`]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:w==="recent"&&$.length>0?e.jsx(Br,{entities:$,onSelect:p}):g.trim()?v?e.jsx(pi,{message:"搜索中..."}):_.length>0?e.jsx(Br,{entities:_,onSelect:p}):e.jsx(pi,{message:"未找到匹配的结果"}):e.jsx(pi,{message:"输入关键词开始搜索"})}),l&&d&&e.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),e.jsx("button",{onClick:d,style:hg,children:a||"创建新实体"})]})]})})},Ar=({active:t,onClick:n,children:o})=>e.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:t?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(t?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:t?600:400,marginBottom:"-1px"},children:o}),Br=({entities:t,onSelect:n})=>e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:t.map(o=>e.jsx(dg,{entity:o,onClick:()=>n(o)},o.id))}),dg=({entity:t,onClick:n})=>{const[o,r]=x.useState(!1);return e.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:[e.jsx("span",{style:{fontSize:"18px"},children:ag(t.type)}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{fontWeight:500,fontSize:"13px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[t.title,t.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:i("desc-fg"),marginLeft:"4px"},children:t.edition})]}),e.jsxs("div",{style:{fontSize:"11px",opacity:.7,display:"flex",alignItems:"center",gap:"6px",marginTop:"2px"},children:[e.jsx("code",{style:{fontSize:"10px",background:i("primary-soft"),padding:"1px 4px",borderRadius:"2px"},children:t.id}),t.author&&e.jsx("span",{children:t.author}),t.dynasty&&e.jsx("span",{children:t.dynasty})]})]}),e.jsx("span",{style:{fontSize:"10px",padding:"3px 8px",background:cg(t.type),color:i("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:Xl(t.type)})]})},pi=({message:t})=>e.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:t}),pg={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},ug={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")},mg={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},gg={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"},hg={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},xg={work:i("editor-type-work"),collection:i("editor-type-collection"),book:i("editor-type-book"),entity:i("editor-type-entity")},fg={work:"📜",collection:"📚",book:"📖",entity:"👤"},ea=({data:t,onChange:n,onSave:o,transport:r,onNavigate:s,showDelete:l,onDelete:a,onAskAI:p,renderSectionActions:c,onDownloadResource:d,downloadStatuses:u,relations:g,onRelationsChange:m})=>{var ke;const h=ve(),[f,v]=x.useState(!1),[y,w]=x.useState("work"),[b,j]=x.useState(""),[S,k]=x.useState(""),[$,_]=x.useState([]),[z,E]=x.useState(!1),[T,C]=x.useState(!1),[O,W]=x.useState("work"),[P,Y]=x.useState(""),[V,Q]=x.useState(),[ge,A]=x.useState(!1),[I,Z]=x.useState(null),[ee,ce]=x.useState([]);x.useRef(null);const fe=t.type,Ie=fe==="work",q=fe==="collection",M=fe==="book",K=x.useCallback((F,he)=>{n({...t,[F]:he})},[t,n]),Re=x.useCallback((F,he)=>{j(F),w(he),k(h.editor.selectToLink+h.indexType[he]),_([]),v(!0)},[h]),se=x.useCallback(F=>{r!=null&&r.unlinkEntity&&r.unlinkEntity(t.id,F)},[r,t.id]),ye=x.useCallback(F=>{s==null||s(F.id,F.type)},[s]),We=x.useCallback((F,he,Ne)=>{const R={...Ne,author:(Ne==null?void 0:Ne.author)||t.author,dynasty:Ne==null?void 0:Ne.dynasty};W(he),Y(F),Q(R),C(!0)},[t.author]),Be=x.useCallback((F,he)=>{r!=null&&r.createAndLink&&r.createAndLink(t.id,P,{type:O,title:F,inheritData:he}),C(!1)},[r,t.id,P,O]),Ee=x.useCallback(F=>{if(!F.trim()){_([]);return}E(!0),r!=null&&r.searchEntities&&r.searchEntities(F,y).then(he=>{_(he),E(!1)}).catch(()=>{_([]),E(!1)})},[r,y]),Ce=x.useCallback(F=>{r!=null&&r.linkEntity&&r.linkEntity(t.id,b,F.id),v(!1)},[r,t.id,b]),He=x.useCallback(()=>{o()},[o]),D=x.useCallback(F=>{Z(()=>F),A(!0),r!=null&&r.getRecentEntities&&r.getRecentEntities().then(ce).catch(()=>{})},[r]),re=x.useCallback((F,he)=>r!=null&&r.searchEntities?r.searchEntities(F,he==="all"?void 0:he):Promise.resolve([]),[r]),de=x.useCallback(F=>{r!=null&&r.addRecentEntity&&r.addRecentEntity(F),ce(he=>[F,...he.filter(Ne=>Ne.id!==F.id)].slice(0,10)),I==null||I(F),A(!1),Z(null)},[r,I]);return e.jsxs("div",{style:{padding:"16px",maxWidth:"900px",margin:"0 auto"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:`1px solid ${i("widget-border")}`,paddingBottom:"16px"},children:e.jsxs("h1",{style:{fontSize:"20px",fontWeight:600,margin:0,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:fg[fe]}),e.jsx("span",{children:t.title||h.editor.untitled}),e.jsx(In,{children:t.id}),e.jsx(In,{color:xg[fe],children:h.indexType[fe]})]})}),e.jsx(at,{title:h.section.basicInfo,onSave:o,onAskAI:p?()=>p("基本信息"):void 0,extraButtons:c==null?void 0:c("基本信息"),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[e.jsx(Sn,{label:Ie?h.editor.workTitle:q?h.editor.collectionTitle:h.editor.bookTitle,value:t.title,onChange:F=>K("title",F)}),M&&e.jsx(Sn,{label:h.editor.belongsToWork,value:t.workName||"",onChange:F=>K("workName",F)}),e.jsx(nt,{label:h.editor.authorLabel,value:t.author||"",onChange:F=>K("author",F)}),e.jsx(nt,{label:h.editor.publicationYearLabel,value:t.publicationYear||"",onChange:F=>K("publicationYear",F)}),(M||q)&&e.jsx(Sn,{label:h.editor.containedIn,value:t.collection||"",onChange:F=>K("collection",F)}),(M||q)&&e.jsx(nt,{label:h.editor.holderLabel,value:t.holder||"",onChange:F=>K("holder",F)}),(M||q)&&e.jsx(nt,{label:M?h.editor.pageLabel:h.editor.volumeLabel,value:t.pages||"",onChange:F=>K("pages",F)}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(nt,{label:h.editor.firstImageLabel,value:t.firstImage||"",onChange:F=>K("firstImage",F)})})]})}),e.jsx(at,{title:h.section.description,onSave:o,onAskAI:p?()=>p("介绍"):void 0,children:e.jsx(Tt,{value:t.description||"",onChange:F=>K("description",F),placeholder:h.editor.descriptionPlaceholder})}),(((ke=t.additional_works)==null?void 0:ke.length)||0)>0&&e.jsx(at,{title:h.section.additionalWorks,onSave:o,children:e.jsx(bg,{items:t.additional_works||[],onChange:F=>K("additional_works",F)})}),e.jsx(at,{title:h.section.indexedBy,onSave:o,onAskAI:p?()=>p("收录于"):void 0,children:e.jsx(yg,{items:t.indexed_by||[],onChange:F=>K("indexed_by",F)})}),e.jsx(at,{title:h.section.emendatedBy,onSave:o,onAskAI:p?()=>p("考证"):void 0,children:e.jsx(jg,{items:t.emendated_by||[],onChange:F=>K("emendated_by",F)})}),e.jsx(at,{title:h.section.textResources,onSave:o,onAskAI:p?()=>p("资源"):void 0,children:e.jsx(fi,{items:t.resources||[],onChange:F=>K("resources",F),onDownload:d,downloadStatuses:u,filterType:"text"})}),e.jsx(at,{title:h.section.imageResources,onSave:o,children:e.jsx(fi,{items:t.resources||[],onChange:F=>K("resources",F),onDownload:d,downloadStatuses:u,filterType:"image"})}),e.jsx(at,{title:h.section.sources,onSave:o,onAskAI:p?()=>p("资料来源"):void 0,children:e.jsx(Vl,{items:Gl(t.sources||""),onChange:F=>K("sources",Yl(F)),onOpenEntityPicker:D})}),(M||q)&&e.jsx(at,{title:h.section.provenance,onSave:o,onAskAI:p?()=>p("收藏历史"):void 0,children:e.jsx(Tt,{value:t.provenance||"",onChange:F=>K("provenance",F),placeholder:h.editor.provenancePlaceholder})}),M&&e.jsx(at,{title:h.section.otherEditions,onSave:o,onAskAI:p?()=>p("其他版本"):void 0,children:e.jsx(Tt,{value:t.otherEditions||"",onChange:F=>K("otherEditions",F),placeholder:h.editor.otherEditionsPlaceholder})}),e.jsx(Kl,{entityType:fe,entityId:t.id,entityTitle:t.title,parentWork:g==null?void 0:g.parentWork,parentCollection:g==null?void 0:g.parentCollection,belongsToWork:g==null?void 0:g.belongsToWork,belongsToCollection:g==null?void 0:g.belongsToCollection,childWorks:g==null?void 0:g.childWorks,childCollections:g==null?void 0:g.childCollections,containedBooks:g==null?void 0:g.containedBooks,siblingBooks:g==null?void 0:g.siblingBooks,onLinkEntity:Re,onUnlinkEntity:se,onViewEntity:ye,onCreateAndLink:We,onSaveRelations:He}),l&&a&&e.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${i("danger-soft-border")}`,background:i("danger-soft-bg"),borderRadius:"4px"},children:[e.jsx("div",{style:{color:i("danger"),fontWeight:600,marginBottom:"8px"},children:h.section.dangerZone}),e.jsx("p",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"12px"},children:h.editor.dangerZoneDesc}),e.jsx("button",{onClick:a,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("danger")}`,borderRadius:"4px",background:"transparent",color:i("danger"),cursor:"pointer"},children:h.editor.deleteEntity})]}),e.jsx(Zl,{isOpen:f,entityType:y,title:S,onSelect:Ce,onCancel:()=>v(!1),onCreate:()=>{v(!1),We(b,y)},searchResults:$,onSearch:Ee,isLoading:z,excludeId:t.id}),e.jsx(Jl,{isOpen:T,entityType:O,relationField:P,inheritData:V,onConfirm:Be,onCancel:()=>C(!1)}),e.jsx(Ql,{isOpen:ge,title:h.action.selectBookOrWork,filterType:"all",recentEntities:ee,excludeId:t.id,onSelect:de,onCancel:()=>{A(!1),Z(null)},onSearch:re})]})};function bg({items:t,onChange:n}){const o=ve(),r=(a,p,c)=>{const d=t.map((u,g)=>g===a?{...u,[p]:c}:u);n(d)},s=a=>n(t.filter((p,c)=>c!==a)),l=()=>n([...t,{book_title:""}]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((a,p)=>e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx(nt,{label:o.editor.bookNameLabel,value:a.book_title,onChange:c=>r(p,"book_title",c)}),e.jsx("div",{style:{width:"100px"},children:e.jsx(nt,{label:o.label.juanCount,value:a.n_juan!=null?String(a.n_juan):"",onChange:c=>r(p,"n_juan",c&&parseInt(c,10)||void 0)})}),e.jsx("button",{onClick:()=>s(p),style:{padding:"4px 8px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("muted"),marginTop:"18px"},children:"✕"})]},p)),e.jsx("button",{onClick:l,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 ta({items:t,onChange:n,showMeta:o,addLabel:r}){const s=ve(),[l,a]=x.useState(null),p=(u,g,m)=>{const h=t.map((f,v)=>v===u?{...f,[g]:m||void 0}:f);n(h)},c=u=>{n(t.filter((g,m)=>m!==u)),l===u&&a(null)},d=()=>{n([...t,{source:""}]),a(t.length)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((u,g)=>{const m=l===g;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:m?`color-mix(in srgb, ${i("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>a(m?null:g),children:[e.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.2s",transform:m?"rotate(90deg)":"none"},children:"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:u.source||s.editor.unnamedSource}),u.source_bid&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u.source_bid}),e.jsx("button",{onClick:h=>{h.stopPropagation(),c(g)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${i("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:i("muted")},children:"✕"})]}),!m&&o&&(u.title_info||u.author_info)&&e.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]}),m&&e.jsxs("div",{style:{padding:"8px 12px 12px",display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsx(nt,{label:s.label.sourceName,value:u.source,onChange:h=>p(g,"source",h)}),e.jsx(nt,{label:s.label.sourceBid,value:u.source_bid||"",onChange:h=>p(g,"source_bid",h)})]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsx(nt,{label:s.label.titleInfo,value:u.title_info||"",onChange:h=>p(g,"title_info",h)}),e.jsx(nt,{label:s.label.authorInfo,value:u.author_info||"",onChange:h=>p(g,"author_info",h)})]}),e.jsx(nt,{label:s.label.edition,value:u.edition||"",onChange:h=>p(g,"edition",h)})]}),e.jsx(Tt,{value:u.summary||"",onChange:h=>p(g,"summary",h),placeholder:s.editor.summaryPlaceholder}),e.jsx(Tt,{value:u.comment||"",onChange:h=>p(g,"comment",h),placeholder:s.editor.commentPlaceholder}),e.jsx(Tt,{value:u.additional_comment||"",onChange:h=>p(g,"additional_comment",h),placeholder:s.editor.additionalCommentPlaceholder})]})]},g)}),e.jsx("button",{onClick:d,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 yg({items:t,onChange:n}){const o=ve();return e.jsx(ta,{items:t,onChange:n,showMeta:!0,addLabel:o.action.addIndexedBy})}function jg({items:t,onChange:n}){const o=ve();return e.jsx(ta,{items:t,onChange:n,addLabel:o.action.addEmendatedBy})}function na(t){var p,c,d,u,g,m,h;const n=((c=(p=t.authors)==null?void 0:p[0])==null?void 0:c.name)||"",o=((d=t.publication_info)==null?void 0:d.year)||"",r=((u=t.current_location)==null?void 0:u.name)||"",s=(g=t.page_count)!=null&&g.number?String(t.page_count.number):((m=t.page_count)==null?void 0:m.description)||"",l=typeof t.description=="object"&&t.description!==null&&t.description.text||"",a={id:t.id,title:t.title,type:t.type,author:n,publicationYear:o,holder:r,pages:s,description:l,resources:t.resources,additional_works:t.additional_works,indexed_by:t.indexed_by,emendated_by:t.emendated_by};if(t.type==="work"){const f=t;if(Array.isArray(f.related_works)){const v=f.related_works.find(y=>y.relation==="part_of");v&&(a.parentWorkId=v.id,a.parentWorkName=v.title)}}if(t.type==="book"){const f=t;a.workId=f.work_id,Array.isArray(f.contained_in)&&f.contained_in.length>0&&(a.collectionId=(h=f.contained_in[0])==null?void 0:h.id)}return a}function vg(t){const n={id:t.id,title:t.title,type:t.type,description:t.description?{text:t.description}:void 0,authors:t.author?[{name:t.author}]:void 0,publication_info:t.publicationYear?{year:t.publicationYear}:void 0,current_location:t.holder?{name:t.holder}:void 0,page_count:t.pages?{number:parseInt(t.pages)||0,description:t.pages}:void 0,resources:t.resources,additional_works:t.additional_works,indexed_by:t.indexed_by,emendated_by:t.emendated_by};return t.type==="work"&&t.parentWorkId&&(n.related_works=[{id:t.parentWorkId,title:t.parentWorkName||"",relation:"part_of"}]),t.type==="book"&&(n.work_id=t.workId,t.collectionId&&(n.contained_in=[{id:t.collectionId}])),n}const kg=t=>{const{data:n,id:o,transport:r,mode:s="view",onModeChange:l,onChange:a,onSave:p,onDelete:c,onNavigate:d,renderLink:u,onAskAI:g,renderSectionActions:m,onDownloadResource:h,downloadStatuses:f,relations:v,onRelationsChange:y,headerExtra:w,className:b,style:j}=t,S=ve(),[k,$]=x.useState(s),_=l?s:k;x.useEffect(()=>{s!==k&&$(s)},[s]);const z=x.useCallback(()=>{const Y=_==="view"?"edit":"view";l?l(Y):$(Y)},[_,l]),[E,T]=x.useState(null);x.useEffect(()=>{o&&r&&r.getItem(o).then(Y=>{Y&&T(Y)})},[o,r]);const C=n||E,O=x.useMemo(()=>C?na(C):null,[C]),W=l||!n?e.jsx("button",{onClick:z,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,P=e.jsxs(e.Fragment,{children:[W,w]});return!C&&!O?e.jsx(Rt,{}):_==="view"?e.jsx(Ki,{data:C,transport:r,onNavigate:d?Y=>d(Y):void 0,renderLink:u,headerExtra:P,className:b,style:j}):O?e.jsxs("div",{className:b,style:j,children:[P&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:P}),e.jsx(ea,{data:O,onChange:a||(()=>{}),onSave:p||(()=>{}),transport:r,onNavigate:d,showDelete:!!c,onDelete:c,onAskAI:g,renderSectionActions:m,onDownloadResource:h,downloadStatuses:f,relations:v,onRelationsChange:y})]}):e.jsx("div",{style:{padding:"24px",textAlign:"center",color:i("muted")},children:S.common.noData})},wg=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],ia=({isOpen:t,onClose:n,onSubmit:o,feedbackListUrl:r})=>{const{t:s}=G(),[l,a]=x.useState(null),[p,c]=x.useState(""),[d,u]=x.useState(""),[g,m]=x.useState("idle"),[h,f]=x.useState(""),v=x.useRef(null);x.useEffect(()=>{t&&(a(null),c(""),u(""),m("idle"),f(""))},[t]),x.useEffect(()=>{l&&setTimeout(()=>{var b;return(b=v.current)==null?void 0:b.focus()},100)},[l]),x.useEffect(()=>{if(g==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[g,n]),x.useEffect(()=>{if(!t)return;const b=j=>{j.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[t,n]);const y=async()=>{if(!(!l||!p.trim())){m("submitting"),f("");try{await o({type:l,content:p.trim(),...d.trim()?{contact:d.trim()}:{}}),m("success")}catch(b){m("error"),f(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!t)return null;const w=l&&p.trim()&&g!=="submitting";return e.jsx("div",{style:Sg,onClick:b=>{b.target===b.currentTarget&&n()},children:e.jsxs("div",{style:$g,onClick:b=>b.stopPropagation(),children:[e.jsxs("div",{style:_g,children:[e.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),e.jsx("button",{onClick:n,style:Cg,"aria-label":s("feedback.close"),children:"✕"})]}),g==="success"?e.jsxs("div",{style:Rg,children:[e.jsx("span",{style:{fontSize:"32px"},children:"✓"}),e.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:s("feedback.thanks")}),r&&e.jsx("a",{href:r,style:{fontSize:"13px",color:i("primary"),marginTop:"8px"},children:s("feedback.viewList")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"16px"},children:wg.map(b=>e.jsxs("button",{onClick:()=>a(b.value),style:{...zg,...l===b.value?Tg:{}},children:[e.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),e.jsx("textarea",{ref:v,value:p,onChange:b=>c(b.target.value),placeholder:s(l?`feedback.placeholder.${l}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!l||g==="submitting",style:{...Ng,opacity:l?1:.6}}),e.jsx("input",{type:"text",value:d,onChange:b=>u(b.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!l||g==="submitting","aria-label":s("feedback.contactLabel"),style:Lg}),e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[p.length," / 2000"]}),g==="error"&&e.jsx("div",{style:Eg,children:h}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{onClick:y,disabled:!w,style:{...Ig,opacity:w?1:.6,cursor:w?"pointer":"not-allowed"},children:s(g==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},Sg={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},$g={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:i("shadow-dialog")},_g={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},Cg={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:i("desc-fg"),padding:"4px 8px",borderRadius:"4px"},zg={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"},Tg={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},Ng={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"},Ig={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},Rg={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:i("success")},Eg={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginBottom:"12px"},Lg={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"},Ei="--bim-feedback-fab-offset",Li=48,Pg=16,Ag=({onSubmit:t,position:n={bottom:24,right:24},feedbackListUrl:o,hidden:r=!1,zIndex:s})=>{const{t:l}=G(),[a,p]=x.useState(!1),c=n.bottom??24;return x.useEffect(()=>{if(r||typeof document>"u")return;const d=document.documentElement;return d.style.setProperty(Ei,`calc(${c+Li+Pg}px + env(safe-area-inset-bottom, 0px))`),()=>{d.style.removeProperty(Ei)}},[r,c]),e.jsxs(e.Fragment,{children:[!r&&e.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>p(!0),style:{...Bg,zIndex:s??i("feedback-fab-z"),bottom:`calc(${c}px + env(safe-area-inset-bottom, 0px))`,right:n.right},"aria-label":l("feedback.title"),title:l("feedback.title"),children:e.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:e.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"})})}),e.jsx(ia,{isOpen:a,onClose:()=>p(!1),onSubmit:t,feedbackListUrl:o})]})},Bg={position:"fixed",width:`${Li}px`,height:`${Li}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"},Mg=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],oa=({onSubmit:t})=>{const{t:n}=G(),[o,r]=x.useState("bug"),[s,l]=x.useState(""),[a,p]=x.useState(""),[c,d]=x.useState("idle"),[u,g]=x.useState(""),m=x.useRef(null);x.useEffect(()=>{o&&setTimeout(()=>{var v;return(v=m.current)==null?void 0:v.focus()},100)},[o]);const h=async()=>{if(!(!o||!s.trim())){d("submitting"),g("");try{await t({type:o,content:s.trim(),...a.trim()?{contact:a.trim()}:{}}),d("success"),l(""),p(""),r("bug")}catch(v){d("error"),g(v instanceof Error?v.message:n("feedback.submitFailedRetry"))}}},f=o&&s.trim()&&c!=="submitting";return c==="success"?e.jsx("div",{style:Mr,children:e.jsxs("div",{style:Dg,children:[e.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),e.jsx("button",{onClick:()=>d("idle"),style:Ug,children:n("feedback.continueSubmit")})]})}):e.jsxs("div",{style:Mr,children:[e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:Mg.map(v=>e.jsxs("button",{onClick:()=>r(v.value),style:{...Wg,...o===v.value?Hg:{}},children:[e.jsx("span",{children:v.icon})," ",n(`feedback.submitType.${v.value}`)]},v.value))}),e.jsx("textarea",{ref:m,value:s,onChange:v=>l(v.target.value),placeholder:n(o?`feedback.placeholder.${o}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...Og}}),e.jsx("input",{type:"text",value:a,onChange:v=>p(v.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:Gg}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[s.length," / 2000"]}),e.jsx("button",{onClick:h,disabled:!f,style:{...Fg,opacity:f?1:.6,cursor:f?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&e.jsx("div",{style:Vg,children:u})]})},Mr={padding:"16px",border:`1px solid ${i("widget-border")}`,borderRadius:"8px",background:i("input-bg")},Wg={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"},Hg={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},Og={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"},Fg={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},Dg={display:"flex",alignItems:"center",gap:"12px",color:i("success"),fontSize:"14px"},Ug={background:"none",border:"none",color:i("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},Vg={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginTop:"8px"},Gg={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 Wr(t){return typeof t=="function"?t():t??"/api/feedback"}const ra=({resourceId:t,apiUrl:n})=>{const{t:o}=G(),[r,s]=x.useState([]),[l,a]=x.useState(!0),p=x.useCallback(async()=>{const d=Wr(n);a(!0);try{const g=await(await fetch(`${d}?resourceId=${encodeURIComponent(t)}`)).json();g.success&&s(g.items)}catch{}finally{a(!1)}},[t,n]);x.useEffect(()=>{p()},[p]);const c=async d=>{const u=Wr(n),g=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...d,pageUrl:typeof window<"u"?window.location.href:"",resourceId:t})});if(!g.ok){const m=await g.json().catch(()=>null);throw new Error((m==null?void 0:m.error)||o("feedback.submitFailed"))}setTimeout(()=>p(),500)};return e.jsxs("div",{children:[e.jsx(ko,{items:r,loading:l}),e.jsx("div",{style:{marginTop:"24px"},children:e.jsx(oa,{onSubmit:c})})]})},Yg=En["zh-Hant"].relation,Kg=En["zh-Hant"].lossStatus,qg=En["zh-Hant"].resourceKind,Yn=Dt("zh-Hant"),wo=(t,n)=>Object.prototype.hasOwnProperty.call(t,n);function Hr(t,n=Yn){return t?wo(Yg,t)?n(`detail.relation.${t}`):t:n("detail.relation.related")}function Zg(t,n=Yn){return wo(Kg,t)?n(`detail.lossStatus.${t}`):t}function Jg(t,n=Yn){return wo(qg,t)?n(`detail.resourceKind.${t}`):""}function So({authors:t,onNavigate:n,renderLink:o}){const{convert:r}=G(),s=(t||[]).filter(l=>l&&l.name);return s.length?e.jsx(e.Fragment,{children:s.map((l,a)=>{const p=io(l.role);return e.jsxs(x.Fragment,{children:[a>0&&" ",l.dynasty&&e.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",r(l.dynasty),"〕"]}),l.entity_id?e.jsx(Ge,{id:l.entity_id,label:r(l.name),onNavigate:n,renderLink:o,dense:!0}):r(l.name),p&&e.jsx("span",{style:{marginLeft:4},children:r(p)})]},a)})}):null}function sa(t,n,o=Yn){var c,d;const r=to(t,n),s=r.mirrors.map(u=>({key:u.key,label:u.label,description:u.description,rows:u.items.filter(g=>g.group_role!=="mirror"),mirrors:u.items.filter(g=>g.group_role==="mirror")})),l=r.buckets.filter(u=>u.key==="image"||u.key==="textImage").flatMap(u=>u.items);l.length&&s.push({key:"_images",label:s.length?o("detail.otherImages"):void 0,rows:l,mirrors:[]});const a=((c=r.buckets.find(u=>u.key==="physical"))==null?void 0:c.items)??[];return a.length&&s.push({key:"_physical",label:o("detail.resourceKind.physical"),rows:a,mirrors:[]}),{text:((d=r.buckets.find(u=>u.key==="text"))==null?void 0:d.items)??[],groups:s}}function la(t,n){const o=(t.url?Ut(t.url):void 0)||t.name,r=cl(t,n);return r?`${o}(${r})`:o}function $o({item:t,siblings:n,listedVolumeCounts:o}){const{t:r,convert:s}=G(),[l,a]=x.useState(!1),p=Ln(t),c=!!p&&p.expected>0&&!(o!=null&&o.has(p.expected)),d=s(la(t,n)),u=Vt(t),g=Fn(t,r)||t.details;return e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var h,f;const m=(h=t.metadata)!=null&&h.fragment||t.color_mode?e.jsxs("span",{className:"bim-d-tags bim-d-ui",style:{display:"inline-flex",margin:"0 0 0 8px",verticalAlign:"middle"},children:[((f=t.metadata)==null?void 0:f.fragment)&&e.jsx("span",{className:"bim-d-tag",children:r("detail.fragmentTag")}),t.color_mode&&e.jsx("span",{className:"bim-d-tag",children:t.color_mode==="color"?r("colorMode.color"):r("colorMode.bw")})]}):null;return u?e.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:[d," ",e.jsx("span",{"aria-hidden":"true",children:"↗"}),m]}):e.jsxs("span",{className:"bim-d-zt-name",children:[d,m]})})(),g&&e.jsx("span",{className:"bim-d-meta",children:s(g)}),c&&l&&e.jsx("div",{style:{padding:"0 12px 10px"},children:e.jsx(ao,{item:t})})]}),e.jsx("td",{className:c?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:c&&e.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":l,onClick:()=>a(m=>!m),children:l?r("detail.collapseVolumes"):r("detail.expandVolumes",{n:p.expected})})})]})}function aa({groups:t,listedVolumeCounts:n}){const{t:o,convert:r}=G();return e.jsx(e.Fragment,{children:t.map(s=>e.jsxs("div",{className:"bim-d-rg",children:[s.label&&e.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:r(s.label)}),s.description&&e.jsx("p",{className:"bim-d-rg-d",children:r(s.description)}),s.rows.length>0&&e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:s.rows.map((l,a)=>e.jsx($o,{item:l,siblings:s.rows,listedVolumeCounts:n},`${l.id||l.url||l.name}-${a}`))})}),s.mirrors.length>0&&e.jsxs("div",{className:"bim-d-rg-mir bim-d-ui",children:[s.rows.length>0&&e.jsx("span",{className:"bim-d-meta",style:{marginRight:10},children:o("detail.mirror")}),s.mirrors.map((l,a)=>{const p=Vt(l),c=r(la(l,s.mirrors));return p?e.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",title:l.details?r(l.details):void 0,children:[c," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]},a):e.jsx("span",{style:{marginRight:14},children:c},a)})]})]},s.key))})}const an=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function Pi(t){var o;if(!t)return;const n=t.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(o=an.find(r=>n.startsWith(r.key[0])))==null?void 0:o.key}const Or=12,Xg=60,ca=({data:t,transport:n,onNavigate:o,renderLink:r,readAction:s,railTop:l,back:a,railLinks:p})=>{var Ee,Ce,He;const{t:c,convert:d,messages:u}=G(),g=x.useMemo(()=>[...t.books||[],...t.collections||[]],[t.books,t.collections]),[m,h]=x.useState(new Map),[f,v]=x.useState(!1),[y,w]=x.useState(""),[b,j]=x.useState(!1),S=g.length<=Xg,k=S||f||!!y||b,$=x.useMemo(()=>k?g:g.slice(0,Or),[g,k]);x.useEffect(()=>{if(!n||$.length===0)return;const D=$.filter(de=>!m.has(de));if(D.length===0)return;let re=!1;return Promise.all(D.map(de=>n.getItem(de).then(ke=>{const F=ke??{};return[de,{id:de,title:F.title,edition:F.edition,resources:F.resources,publication_info:F.publication_info,current_location:F.current_location,lineage:F.lineage,measure_info:F.measure_info}]}).catch(()=>[de,{id:de}]))).then(de=>{re||h(ke=>{const F=new Map(ke);for(const[he,Ne]of de)F.set(he,Ne);return F})}),()=>{re=!0}},[n,$,m]);const _=x.useMemo(()=>g.map(D=>m.get(D)??{id:D}),[g,m]),z=g.length>0&&g.every(D=>m.has(D)),E=!!n&&$.some(D=>!m.has(D)),T=S||k,C=x.useMemo(()=>pl(_,t.version_graph,{era:y,scanOnly:b,sort:T?"year":"default"}),[_,t.version_graph,y,b,T]),O=f?C.rows:C.rows.slice(0,Or),W=C.allRows.filter(D=>D.hasImage).length,P=t.related_works||[],Y=P.filter(D=>D.relation==="collected_in"),V=x.useMemo(()=>{const D=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],re=de=>{const ke=D.indexOf(de??"");return ke<0?D.length:ke};return P.filter(de=>de.relation!=="collected_in").map((de,ke)=>({r:de,i:ke})).sort((de,ke)=>re(de.r.relation)-re(ke.r.relation)||de.i-ke.i).map(de=>de.r)},[P]),Q=x.useMemo(()=>{const D=to(t.resources,t.resource_groups);return[...D.mirrors.flatMap(re=>re.items.map(de=>({r:de,kind:d(re.label)}))),...D.buckets.flatMap(re=>re.items.map(de=>({r:de,kind:d(Jg(re.key,c))})))]},[t.resources,t.resource_groups,d,c]),ge=t.indexed_by||[],A=t.emendated_by||[],I=x.useMemo(()=>{var ne,ue,L;const D=[],re=(ue=(ne=t.authors)==null?void 0:ne[0])==null?void 0:ue.dynasty;re&&D.push({label:c("workPage.fact.written"),value:d(re)});const de=bt(t,u.unit.juan);if(de){const te=(L=t.juan_count)==null?void 0:L.description;D.push({label:c("workPage.fact.measure"),value:e.jsxs(e.Fragment,{children:[d(de),te&&te!==de?e.jsxs("span",{className:"bim-d-meta",children:["(",d(te),")"]}):null]})})}t.loss_status&&D.push({label:c("workPage.fact.loss"),value:d(Zg(t.loss_status,c))});const ke=C.allRows.filter(te=>te.sortYear!=null),F=ke.length>0?ke.reduce((te,U)=>te.sortYear<=U.sortYear?te:U):null;F!=null&&F.era.era?D.push({label:c("workPage.fact.earliest"),value:d([F.era.era,F.era.reign].filter(Boolean).join(" ")),title:F.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):E&&D.push({label:c("workPage.fact.earliest"),value:e.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),A.length&&D.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:A.length})});const he=Fr(t.additional_titles);he.length&&D.push({label:c("workPage.fact.alias"),value:he.map(d).join("、")});const Ne=Fr(t.attached_texts);Ne.length&&D.push({label:c("workPage.fact.attached"),value:Ne.map(d).join("、")});const R=(t.additional_works||[]).map(te=>d(te.book_title)+(te.n_juan!=null?` ${te.n_juan}${u.unit.juan}`:""));return R.length&&D.push({label:c("workPage.fact.appendix"),value:R.join("、")}),D},[t,d,c,u,E,C.allRows,A.length]),ee=[{value:t._edition_count??g.length,label:c("workPage.stat.editions")},{value:z?W:0,label:c("workPage.stat.hasImage")},{value:ge.length,label:c("workPage.stat.catalogs")}],ce=t.classification,fe=ce?[ce.l1,ce.l2,ce.l3,ce.l4].filter(Boolean).map(D=>d(D)):[],Ie=t.subtype?u.workSubtype[t.subtype]??d(t.subtype):"",q=e.jsx(un,{title:d(t.title),byline:e.jsx(So,{authors:t.authors,onNavigate:o,renderLink:r}),meta:e.jsx(qe,{items:[...fe,ce!=null&&ce.source?c("workPage.classifiedBy",{source:d(ce.source.split("/")[0])}):"",Ie]}),description:(Ee=t.description)!=null&&Ee.text?e.jsxs(e.Fragment,{children:[e.jsx(ft,{text:t.description.text,style:{fontSize:15,lineHeight:1.85}}),(Ce=t.description.sources)!=null&&Ce.length?e.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:t.description.sources.map(D=>d(Qp(D))).filter(Boolean).join(" · ")}):null]}):void 0,stats:ee,facts:I,readAction:s,foot:e.jsx(mn,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo}),children:(He=t.appendix)==null?void 0:He.map((D,re)=>e.jsxs("details",{style:{marginTop:12},children:[e.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:d(D.title)}),e.jsx(ft,{text:D.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},re))}),M=C.eras.length>=2?[{key:"",label:c("catalog.all")},...C.eras.map(D=>({key:D,label:`${D} ${C.allRows.filter(re=>re.era.era===D).length}`}))]:[],K=[];g.length&&K.push({id:"versions",label:c("workPage.sec.versions"),count:g.length}),ge.length&&K.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:ge.length}),Y.length&&K.push({id:"collected",label:c("workPage.sec.collected"),count:Y.length}),V.length&&K.push({id:"related",label:c("workPage.sec.related"),count:V.length}),Q.length&&K.push({id:"resources",label:c("workPage.sec.resources"),count:Q.length});const Re=g.length===0&&ge.length===0,se=e.jsxs(e.Fragment,{children:[g.length>0&&e.jsxs(Ze,{id:"versions",title:c("workPage.sec.versions"),meta:e.jsx(qe,{items:[c("workPage.versionsTotal",{n:g.length}),z&&W?c("workPage.versionsWithImage",{n:W}):"",C.rows.length!==C.allRows.length?c("workPage.versionsCurrent",{n:C.rows.length}):""]}),children:[e.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":E&&M.length===0&&g.length>1?"":void 0,children:[M.length>0&&e.jsx(Un,{items:M,value:y,onChange:D=>{w(D),v(!1)}}),e.jsx("span",{className:"bim-d-spacer"}),e.jsx(bl,{label:c("workPage.scanOnly"),checked:b,onChange:D=>{j(D),v(!1)}}),e.jsx("span",{className:"bim-d-meta",children:c(T?"workPage.sortByYear":"workPage.sortByCatalog")})]}),e.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!f&&Vn(C.rows.length)?"":void 0,children:[e.jsx("thead",{className:"bim-d-ui",children:e.jsxs("tr",{children:[e.jsx("th",{children:c("workPage.col.edition")}),e.jsx("th",{children:c("workPage.col.era")}),e.jsx("th",{children:c("workPage.col.holder")}),e.jsx("th",{children:e.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:c("workPage.col.image")})})]})}),e.jsx("tbody",{children:O.map(D=>{var re;return e.jsx(Qg,{row:D,measure:(re=m.get(D.id))==null?void 0:re.measure_info,loaded:m.has(D.id),onNavigate:o,renderLink:r},`${D.id}:${m.has(D.id)?"r":"p"}`)})})]}),O.length===0&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c(y||b?"workPage.noVersionsFiltered":"workPage.noVersions")}),!f&&e.jsx(oo,{total:C.rows.length,shown:O.length,unit:c("workPage.moreUnit"),onClick:()=>v(!0)}),C.hasInferredEra&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),ge.length>0&&e.jsx(eh,{items:ge,transport:n,onNavigate:o,renderLink:r}),Re&&e.jsx(Ze,{title:c("workPage.sec.versions"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),ye=(D,re)=>e.jsx(Ge,{id:D,label:d(re),onNavigate:o,renderLink:r,dense:!0}),We=x.useMemo(()=>{const D=new Map;for(const re of V){const de=Hr(re.relation,c);D.set(de,(D.get(de)??0)+1)}return D.size>1?[...D.entries()].sort((re,de)=>de[1]-re[1]).slice(0,4).map(([re,de])=>`${d(re)} ${de}`).join(" · "):void 0},[V,d,c]),Be=e.jsxs(e.Fragment,{children:[e.jsx(zt,{id:"collected",title:c("workPage.sec.collected"),items:Y.map(D=>ye(D.id,D.title))}),e.jsx(zt,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:V.length}),sub:We,items:V.map(D=>e.jsxs(e.Fragment,{children:[ye(D.id,D.title),e.jsx("span",{className:"bim-d-meta",title:D.note?d(D.note):void 0,children:d(Hr(D.relation,c))})]}))}),e.jsx(zt,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:Q.map(({r:D,kind:re})=>{const de=d((D.url?Ut(D.url):void 0)||D.name),ke=Vt(D);return e.jsxs(e.Fragment,{children:[ke?e.jsxs("a",{href:ke,target:"_blank",rel:"noopener noreferrer",children:[de," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]}):e.jsx("span",{children:de}),re&&e.jsx("span",{className:"bim-d-meta bim-d-kind",children:re})]})})})]});return e.jsx(pn,{railTop:l,back:a,nav:K,railLinks:p,main:se,card:q,side:Be})};function Fr(t){return(t||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Dr(t,n){return n((t.url?Ut(t.url):void 0)||t.name)}function Qg({row:t,measure:n,loaded:o,onNavigate:r,renderLink:s}){const{t:l,convert:a}=G(),p=[t.era.era,t.era.reign].filter(Boolean).join(" "),c=t.era.source==="edition",d=t.holders[0],u=d?Dr(d,a):t.locationName?a(t.locationName):"",g=t.images[0],m=g?Vt(g):void 0,h=t.images.map(f=>Dr(f,a)).join("、");return e.jsxs("tr",{"data-loading":o?void 0:"",children:[e.jsxs("td",{className:"bim-d-zt-main",children:[e.jsx(Ge,{id:t.id,label:a(t.name),onNavigate:r,renderLink:s,dense:!0}),n?e.jsx("span",{className:"bim-d-meta",children:a(n)}):e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "})]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${p?"":" bim-d-zt-blank"}`,title:c?l("workPage.inferredFromEdition"):void 0,children:p?a(p):o?e.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),e.jsxs("td",{className:`bim-d-zt-sub${u?"":" bim-d-zt-blank"}`,children:[u||(o?e.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),t.holders.length>1&&e.jsxs("span",{className:"bim-d-meta",children:[" +",t.holders.length-1]})]}),e.jsx("td",{className:t.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:t.hasImage&&(m?e.jsx("a",{className:"bim-d-flag",href:m,target:"_blank",rel:"noopener noreferrer",title:h,children:l("workPage.hasImage")}):e.jsx("span",{className:"bim-d-flag",title:h,children:l("workPage.hasImage")}))})]})}function eh({items:t,transport:n,onNavigate:o,renderLink:r}){const{t:s,convert:l}=G(),[a,p]=x.useState(0),c=Math.min(a,t.length-1),d=t[c],[u,g]=x.useState(new Map);return x.useEffect(()=>{if(!n)return;const m=[...new Set(t.map(f=>f.source_bid).filter(f=>!!f))];if(m.length===0)return;let h=!1;return Promise.all(m.map(f=>n.getItem(f).then(v=>{var y,w;return[f,((w=(y=v==null?void 0:v.authors)==null?void 0:y[0])==null?void 0:w.dynasty)??""]}).catch(()=>[f,""]))).then(f=>{h||g(new Map(f.filter(([,v])=>v)))}),()=>{h=!0}},[n,t]),e.jsx(Ze,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:e.jsx(qe,{items:[s("workPage.catalog.meta",{n:t.length}),s("workPage.sortByCatalog")]}),children:e.jsxs("div",{className:"bim-d-lu",children:[e.jsx("ul",{className:"bim-d-tl2 bim-d-ui",role:"tablist","aria-label":s("workPage.catalog.tablist"),children:t.map((m,h)=>e.jsx("li",{role:"presentation",children:e.jsxs("button",{type:"button",role:"tab","aria-selected":h===c,"aria-label":l(m.source),onClick:()=>p(h),children:[e.jsx("span",{className:"bim-d-tl2-dyn",children:u.get(m.source_bid??"")?l(u.get(m.source_bid??"")):" "}),e.jsx("i",{className:"bim-d-tl2-dot","aria-hidden":"true"}),e.jsx("span",{className:"bim-d-tl2-name","aria-hidden":"true",children:[...l(m.source)].slice(0,9).map((f,v)=>e.jsx("span",{children:f},v))})]})},h))}),e.jsxs("div",{className:"bim-d-lu-body",role:"tabpanel",children:[d.title_info&&e.jsx("div",{className:"bim-d-lu-title",children:l(d.title_info)}),e.jsx(qe,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[d.source_bid?e.jsx(Ge,{id:d.source_bid,label:l(d.source),onNavigate:o,renderLink:r,dense:!0}):l(d.source),d.section?l(d.section):"",d.author_info?`${s("label.authorInfo")} ${l(d.author_info)}`:"",d.edition?`${s("label.edition")} ${l(d.edition)}`:"",d.page??""]}),d.summary&&e.jsx("p",{className:"bim-d-quote",children:ot(l(d.summary),void 0,{t:s})}),d.comment&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.comment")}),e.jsx("p",{className:"bim-d-quote",children:ot(l(d.comment),void 0,{t:s})})]}),d.additional_comment&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.additionalComment")}),e.jsx("p",{className:"bim-d-quote",children:ot(l(d.additional_comment),void 0,{t:s})})]}),!d.summary&&!d.comment&&!d.additional_comment&&!d.title_info&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{marginTop:12},children:s("workPage.catalog.titleOnly")}),t.length>1&&e.jsxs("div",{className:"bim-d-lu-pager bim-d-ui",children:[c>0?e.jsx("button",{type:"button","aria-label":s("workPage.catalog.prev",{name:l(t[c-1].source)}),onClick:()=>p(c-1),children:e.jsxs("span",{"aria-hidden":"true",children:["← ",l(t[c-1].source)]})}):e.jsx("span",{"aria-hidden":"true"}),e.jsxs("span",{className:"bim-d-meta",children:[c+1," / ",t.length]}),c<t.length-1?e.jsx("button",{type:"button","aria-label":s("workPage.catalog.next",{name:l(t[c+1].source)}),onClick:()=>p(c+1),children:e.jsxs("span",{"aria-hidden":"true",children:[l(t[c+1].source)," →"]})}):e.jsx("span",{"aria-hidden":"true"})]})]})]})})}function th(t){var n;return{id:t.id,kind:"hypothetical",label:t.label,year:t.year??((n=t.year_range)==null?void 0:n[0]),year_range:t.year_range,year_uncertain:t.year_uncertain,group:t.group,note:t.note,description:t.description}}function nh(t,n){if(!t.lineage)return null;const o=t.lineage;return{id:t.id,kind:"book",label:t.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[t.id],note:o.note}}function Ur(t,n,o){return{id:`derive:${n.ref}->${t}:${o}`,source:n.ref,target:t,kind:"derive",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function ih(t,n,o){const[r,s]=[t,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 oh(t,n){var d;if(n==="all")return null;const o=(d=t.collections)==null?void 0:d[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,l=r||s||!!(o!=null&&o.hypothetical_ids);if(!l&&n==="core"&&Array.isArray(t.core_books)&&t.core_books.length>0)return{books:new Set(t.core_books),hypos:t.core_hypotheticals?new Set(t.core_hypotheticals):null};if(!o||!l)return null;const a=r?new Set(o.groups):null,p=new Set(o.book_ids??[]);if(a&&t.node_groups)for(const[u,g]of Object.entries(t.node_groups))a.has(g)&&p.add(u);let c=null;if(o.hypothetical_ids&&(c=new Set(o.hypothetical_ids)),a){c||(c=new Set);for(const u of t.hypothetical_nodes??[])u.group&&a.has(u.group)&&c.add(u.id)}return{books:p,hypos:c}}function $n(t,n,o){const r=t.version_graph,s={nodes:[],edges:[],groups:[],layout:"LR",excluded:[]};if(!r||!r.enabled)return s;const l=new Set(r.excluded_books??[]),a=r.node_groups??{},p=oh(r,o??r.default_collection??"all"),c=p!==null,d=(p==null?void 0:p.books)??null,u=(p==null?void 0:p.hypos)??null,g=new Set,m=new Set;if(c){const S=new Map(n.map(T=>[T.id,T])),k=new Map((r.hypothetical_nodes??[]).map(T=>[T.id,T])),$=T=>{const C=S.get(T);if(C&&C.lineage)return(C.lineage.derived_from??[]).map(W=>W.ref);const O=k.get(T);return O?(O.derived_from??[]).map(W=>W.ref):[]},_=T=>k.has(T)?!u||u.has(T):!d||d.has(T),z=new Set,E=T=>{if(!z.has(T)){z.add(T);for(const C of $(T))l.has(C)||(_(C)||(k.has(C)?m.add(C):S.has(C)&&g.add(C)),E(C))}};for(const T of n)d&&d.has(T.id)&&!l.has(T.id)&&E(T.id);for(const T of r.hypothetical_nodes??[])u&&u.has(T.id)&&E(T.id)}const h=n.filter(S=>!l.has(S.id)).filter(S=>!d||d.has(S.id)||g.has(S.id)).map(S=>{const k=nh(S,a);return k&&g.has(S.id)&&(k.bridge=!0),k}).filter(S=>S!==null),f=(r.hypothetical_nodes??[]).filter(S=>!u||u.has(S.id)||m.has(S.id)).map(S=>{const k=th(S);return m.has(S.id)&&(k.bridge=!0),k}),v=[...h,...f],y=new Set(v.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)l.has(S.id)||!S.lineage||d&&!d.has(S.id)&&!g.has(S.id)||((S.lineage.derived_from??[]).forEach((k,$)=>{j(Ur(S.id,k,$))}),(S.lineage.related_to??[]).forEach((k,$)=>{j(ih(S.id,k,$))}));for(const S of r.hypothetical_nodes??[])u&&!u.has(S.id)&&!m.has(S.id)||(S.derived_from??[]).forEach((k,$)=>{j(Ur(S.id,k,$))});return{nodes:v,edges:b,groups:r.groups??[],title:r.title,description:r.description,layout:r.layout??"LR",excluded:Array.from(l)}}function da(t,n,o){const r=(t??(n!=null?String(n):"")).trim();return r?!o||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(r)?r:`约 ${r}`:""}function rh(t,n){const o=[],r=t.version_graph;if(!r)return o;const s=new Set(n.map(c=>c.id)),l=new Set((r.hypothetical_nodes??[]).map(c=>c.id)),a=new Set([...s,...l]),p=(c,d)=>{a.has(d.ref)||o.push(`${c}: derived_from.ref "${d.ref}" 未在 books 或 hypothetical_nodes 中找到`),d.ref_type==="book"&&!s.has(d.ref)&&o.push(`${c}: derived_from.ref "${d.ref}" 标记为 book 但不在 books 列表中`),d.ref_type==="hypothetical"&&!l.has(d.ref)&&o.push(`${c}: derived_from.ref "${d.ref}" 标记为 hypothetical 但不在 hypothetical_nodes 中`)};for(const c of n){if(!c.lineage)continue;const d=`Book ${c.id} (${c.title})`;(c.lineage.derived_from??[]).forEach(u=>p(d,u)),(c.lineage.related_to??[]).forEach(u=>{s.has(u.book_id)||o.push(`${d}: related_to.book_id "${u.book_id}" 不在 books 列表中`)})}for(const c of r.hypothetical_nodes??[]){const d=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(u=>p(d,u))}return o}const pa=({graph:t,renderLink:n,className:o,style:r})=>{const{t:s,convert:l}=G();if(!t.nodes.length)return e.jsx("div",{style:{...yh,...r},className:o,children:s("lineage.emptyGraph")});const a=new Map,p=new Map;for(const h of t.edges)if(h.kind==="derive"){const f=a.get(h.target)??[];f.push(h),a.set(h.target,f)}else for(const f of[h.source,h.target]){const v=p.get(f)??[];v.push(h),p.set(f,v)}const c=new Map(t.nodes.map(h=>[h.id,h])),d=new Map,u=[];for(const h of t.nodes)if(h.group){const f=d.get(h.group)??[];f.push(h),d.set(h.group,f)}else u.push(h);const g=(h,f)=>(h.year??9999)-(f.year??9999);d.forEach(h=>h.sort(g)),u.sort(g);const m=t.groups.filter(h=>d.has(h.id));return e.jsxs("div",{className:o,style:{...lh,...r},children:[t.title&&e.jsx("div",{style:ah,children:l(t.title)}),t.description&&e.jsx("div",{style:ch,children:l(t.description)}),m.map(h=>e.jsx(Vr,{label:h.label,color:h.color,nodes:d.get(h.id),incomingMap:a,siblingMap:p,nodeMap:c,renderLink:n},h.id)),u.length>0&&e.jsx(Vr,{label:s("lineage.otherGroup"),nodes:u,incomingMap:a,siblingMap:p,nodeMap:c,renderLink:n})]})},Vr=({label:t,color:n,nodes:o,incomingMap:r,siblingMap:s,nodeMap:l,renderLink:a})=>{const{convert:p}=G();return e.jsxs("div",{style:dh,children:[e.jsx("div",{style:{...ph,borderLeftColor:n??i("widget-border")},children:p(t)}),o.map(c=>e.jsx(sh,{node:c,incoming:r.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:l,renderLink:a},c.id))]})},sh=({node:t,incoming:n,siblings:o,nodeMap:r,renderLink:s})=>{const l=t.kind==="hypothetical",a=t.bridge,{t:p,convert:c}=G();return e.jsxs("div",{style:{...uh,borderStyle:l||a?"dashed":"solid",opacity:a?.55:t.status==="lost"?.7:1,background:a?i("bg-subtle"):void 0},title:a?p("lineage.bridgeTitle"):void 0,children:[e.jsxs("div",{style:mh,children:[e.jsx("span",{style:gh,children:l||!s?c(t.label):s(t.id,c(t.label))}),(t.year_text||t.year!=null)&&e.jsx("span",{style:hh,children:da(c(t.year_text),t.year,t.year_uncertain)})]}),e.jsxs("div",{style:xh,children:[t.category&&e.jsx(en,{children:c(t.category)}),t.status==="lost"&&e.jsx(en,{tone:"warn",children:p("lineage.lost")}),t.status==="fragment"&&e.jsx(en,{tone:"warn",children:p("lineage.fragment")}),l&&e.jsx(en,{tone:"info",children:p("lineage.hypothetical")}),a&&e.jsx(en,{tone:"info",children:p("lineage.bridge")})]}),t.extant_juan&&e.jsx("div",{style:fh,children:p("lineage.extant",{juan:c(t.extant_juan)})}),t.note&&e.jsx("div",{style:bh,children:c(t.note)}),n.length>0&&e.jsxs("div",{style:Yr,children:[e.jsx("div",{style:Kr,children:p("lineage.sources")}),n.map(d=>{const u=r.get(d.source);return e.jsxs("div",{style:qr(d.confidence),children:[e.jsx("span",{style:Zr,children:c(d.relation)}),e.jsx("span",{children:(u==null?void 0:u.kind)==="book"&&s?s(u.id,c(u.label)):c((u==null?void 0:u.label)??d.source)}),d.confidence!=="consensus"&&d.confidence!=="certain"&&e.jsx(Gr,{level:d.confidence}),d.evidence&&e.jsxs("span",{style:Jr,children:["· ",c(d.evidence)]})]},d.id)})]}),o.length>0&&e.jsxs("div",{style:Yr,children:[e.jsx("div",{style:Kr,children:p("lineage.related")}),o.map(d=>{const u=d.source===t.id?d.target:d.source,g=r.get(u);return e.jsxs("div",{style:qr(d.confidence),children:[e.jsx("span",{style:Zr,children:c(d.relation)}),e.jsx("span",{children:(g==null?void 0:g.kind)==="book"&&s?s(g.id,c(g.label)):c((g==null?void 0:g.label)??u)}),e.jsx(Gr,{level:d.confidence}),d.evidence&&e.jsxs("span",{style:Jr,children:["· ",c(d.evidence)]})]},d.id)})]})]})},en=({children:t,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 e.jsx("span",{style:{display:"inline-block",padding:"1px 8px",fontSize:"11px",borderRadius:"10px",background:r.bg,color:r.fg,marginRight:"4px"},children:t})},Gr=({level:t})=>{const{t:n}=G(),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")}}[t];return r?e.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},lh={fontSize:"14px",color:i("fg")},ah={fontSize:"16px",fontWeight:600,marginBottom:"8px"},ch={fontSize:"13px",color:i("muted"),marginBottom:"16px",lineHeight:1.6},dh={marginBottom:"16px"},ph={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:i("fg")},uh={border:`1px solid ${i("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:i("bg")},mh={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},gh={fontSize:"15px",fontWeight:600},hh={fontSize:"12px",color:i("muted")},xh={marginBottom:"6px"},fh={fontSize:"12px",color:i("muted"),margin:"2px 0"},bh={fontSize:"12px",color:i("muted"),fontStyle:"italic",margin:"4px 0"},Yr={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${i("widget-border")}`},Kr={fontSize:"11px",color:i("muted"),marginBottom:"2px"},qr=t=>({fontSize:"12px",margin:"2px 0",opacity:t==="probable"||t==="disputed"?.85:1}),Zr={display:"inline-block",padding:"0 6px",fontSize:"11px",background:i("tag-bg"),color:i("fg"),borderRadius:"3px",marginRight:"6px"},Jr={fontSize:"11px",color:i("muted")},yh={padding:"20px",textAlign:"center",color:i("muted"),fontSize:"13px"},ua=({selectedNodeId:t,...n})=>{const{t:o}=G(),[r,s]=x.useState("loading"),[l,a]=x.useState(null);return x.useEffect(()=>{let p=!1;return jh().then(c=>{p||(c?(a(c),s("ready")):s("missing"))}),()=>{p=!0}},[]),r==="loading"?e.jsx("div",{style:Qr,children:o("lineage.graphLoading")}):r==="missing"||!l?e.jsxs("div",{style:Qr,children:[e.jsx("div",{children:Xr(o("lineage.graphMissing"),{xyflow:e.jsx("code",{children:"@xyflow/react"}),dagre:e.jsx("code",{children:"@dagrejs/dagre"})})}),e.jsx("div",{style:{fontSize:"12px",marginTop:"4px"},children:Xr(o("lineage.graphMissingHint"),{list:e.jsx("code",{children:"VersionLineageList"})})})]}):e.jsx(vh,{modules:l,selectedNodeId:t,...n})};function Xr(t,n){return t.split(/(\{\w+\})/).map((o,r)=>{const s=/^\{(\w+)\}$/.exec(o);return e.jsx(x.Fragment,{children:s&&s[1]in n?n[s[1]]:o},r)})}async function jh(){try{const[t,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:t.ReactFlow,Background:t.Background,Controls:t.Controls,Handle:t.Handle,Position:t.Position,BaseEdge:t.BaseEdge,EdgeLabelRenderer:t.EdgeLabelRenderer,getSmoothStepPath:t.getSmoothStepPath,dagre:n,cssLoaded:o}}catch{return null}}const vh=({graph:t,renderLink:n,height:o=600,className:r,style:s,selectedNodeId:l,modules:a})=>{const{ReactFlow:p,Background:c,Controls:d,Handle:u,Position:g,BaseEdge:m,EdgeLabelRenderer:h,getSmoothStepPath:f,dagre:v}=a,y=x.useMemo(()=>({lineage:$=>{var V,Q,ge,A;const _=((V=$.data)==null?void 0:V.stepPosition)??.85,[z,E,T]=f({sourceX:$.sourceX,sourceY:$.sourceY,sourcePosition:$.sourcePosition,targetX:$.targetX,targetY:$.targetY,targetPosition:$.targetPosition,stepPosition:_,borderRadius:5}),C=!!((Q=$.data)!=null&&Q.isSibling),O=C?E:$.targetX-18,W=C?T:$.targetY-12,P=(ge=$.data)==null?void 0:ge.labelStyle,Y=(A=$.data)==null?void 0:A.labelBgStyle;return e.jsxs(e.Fragment,{children:[e.jsx(m,{id:$.id,path:z,style:$.style,markerStart:$.markerStart,markerEnd:$.markerEnd}),$.label&&e.jsx(h,{children:e.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${O}px,${W}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:i("bg"),border:`0.5px solid ${i("widget-border")}`,...Y,...P},children:$.label})})]})}}),[m,h,f]),w=x.useMemo(()=>({version:$=>{const{t:_}=G(),z=$.data,E=z.kind==="hypothetical",T=z.status==="lost",C=z.isSelected,O=z.bridge,W=z.borderColor??i("muted"),P=O||E?"dashed":"solid",Y=O?.5:T?.6:1;return e.jsxs("div",{style:{background:i(O?"bg-subtle":"bg"),border:`2px ${P} ${C?i("primary"):W}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:Y,boxShadow:C?i("shadow-node-selected"):E||O?"none":i("shadow-node")},title:O?_("lineage.bridgeTitle"):void 0,children:[e.jsx(u,{type:"target",position:g.Left,style:{visibility:"hidden"}}),e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:E||!z.renderLink?z.label:z.renderLink(z.bookId,z.label)}),z.description&&e.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.25,marginTop:1},children:z.description}),z.yearText&&e.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.2},children:da(z.yearText,void 0,z.uncertain)}),T&&e.jsx("div",{style:{fontSize:9,color:i("lost-fg"),marginTop:1},children:_("lineage.lost")}),e.jsx(u,{type:"source",position:g.Right,style:{visibility:"hidden"}})]})}}),[u,g]),{convert:b}=G(),{rfNodes:j,rfEdges:S}=x.useMemo(()=>kh(t,v,n,l,b),[t,v,n,l,b]);return e.jsx("div",{style:{width:"100%",height:o,...s},className:r,children:e.jsxs(p,{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:[e.jsx(c,{gap:16}),e.jsx(d,{showInteractive:!1})]})})};function kh(t,n,o,r,s=l=>l??""){const p=t.layout==="LR"||!t.layout,c=new n.graphlib.Graph;c.setGraph({rankdir:p?"LR":"TB",ranksep:160,nodesep:40,edgesep:16,marginx:20,marginy:20}),c.setDefaultEdgeLabel(()=>({}));const d=new Map(t.groups.map(w=>[w.id,w.color??i("muted")]));for(const w of t.nodes)c.setNode(w.id,{width:160,height:90});const u=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const w of t.edges)w.kind==="derive"&&(u.has(w.relation)||c.setEdge(w.source,w.target));n.layout(c);const g=t.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??Sh(w)),uncertain:w.year_uncertain,category:w.category,status:w.status,borderColor:w.group?d.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}}),m=.78,h=.06,f=new Map;for(const w of t.edges)w.kind==="derive"&&(f.has(w.source)||f.set(w.source,[]),f.get(w.source).push(w));const v=new Map;for(const[w,b]of f){if(b.length<=1)continue;const j=[...b].sort((k,$)=>{var E,T;const _=((E=c.node(k.target))==null?void 0:E.y)??0,z=((T=c.node($.target))==null?void 0:T.y)??0;return _-z}),S=j.length;j.forEach((k,$)=>{const _=($-(S-1)/2)*h;v.set(k.id,m+_)})}const y=t.edges.map(w=>wh(w,v.get(w.id),s));return{rfNodes:g,rfEdges:y}}function wh(t,n,o=r=>r??""){const r=t.confidence==="probable"||t.confidence==="disputed",s=t.kind==="sibling",l=$h(t.confidence),a={type:"arrowclosed",color:l,width:14,height:14};return{id:t.id,source:t.source,target:t.target,type:"lineage",label:o(t.relation),data:{labelStyle:{color:i("fg")},isSibling:s,stepPosition:n},style:{stroke:l,strokeWidth:s?1:1.5,strokeDasharray:s?"4 3":r?"6 4":void 0,opacity:r?.75:1},animated:!1,markerEnd:a,markerStart:s?a:void 0,zIndex:1e3}}function Sh(t){if(t.year_range)return`~${t.year_range[0]}–${t.year_range[1]}`;if(typeof t.year=="number")return String(t.year)}function $h(t){switch(t){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 Qr={padding:"40px 20px",textAlign:"center",color:i("muted"),fontSize:"13px",border:`1px dashed ${i("widget-border")}`,borderRadius:8,background:i("bg")},_o=({graph:t,defaultMode:n="list",renderLink:o,graphHeight:r=600,selectedNodeId:s,onModeChange:l,collection:a,onCollectionChange:p,collectionsAvailable:c,collectionCounts:d,className:u,style:g})=>{var S;const{t:m,convert:h}=G(),[f,v]=x.useState(n),y=k=>{v(k),l==null||l(k)},w=(()=>{if(!c)return[];const k=Object.entries(c);return k.length===0||c.all?k:[...k,["all",{label:m("lineage.collectionAll"),description:m("lineage.collectionAllDesc")}]]})(),b=!!(p&&w.length>0);if(!t.nodes.length)return e.jsx("div",{style:{padding:24,color:i("muted"),textAlign:"center"},children:m("lineage.empty")});const j=a?(S=c==null?void 0:c[a])==null?void 0:S.description:void 0;return e.jsxs("div",{className:u,style:g,children:[e.jsxs("div",{style:_h,children:[e.jsx("button",{onClick:()=>y("list"),style:ui(f==="list"),children:m("lineage.modeList")}),e.jsx("button",{onClick:()=>y("graph"),style:ui(f==="graph"),children:m("lineage.modeGraph")}),b&&e.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:12,color:i("muted"),marginRight:4},children:m("lineage.collectionLabel")}),w.map(([k,$])=>{const _=d==null?void 0:d[k];return e.jsxs("button",{onClick:()=>p==null?void 0:p(k),style:ui(a===k),title:$.description?h($.description):void 0,children:[h($.label),_!=null?` ${_}`:""]},k)})]})]}),b&&j&&e.jsx("div",{style:{fontSize:12,color:i("muted"),marginBottom:8,padding:"4px 8px",background:i("bg-subtle"),borderRadius:4},children:h(j)}),f==="list"?e.jsx(pa,{graph:t,renderLink:o}):e.jsx(ua,{graph:t,renderLink:o,height:r,selectedNodeId:s})]})},_h={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},ui=t=>({padding:"4px 12px",fontSize:12,border:`1px solid ${i("widget-border")}`,borderRadius:4,background:t?i("primary"):"transparent",color:i(t?"primary-fg":"fg"),cursor:"pointer"}),es=40,ts=2,Ch=9,zh=new Set(["certain","consensus","probable","disputed"]);function mi(t){if(!t)return["",""];const n=t.split(/[  ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",t]}const ma=({data:t,transport:n,onNavigate:o,renderLink:r,readAction:s,fullText:l,fullTextPending:a,chapterLink:p,railTop:c,back:d,railLinks:u})=>{var L,te,U,le,we,Le,Se,Fe,De,J,Pe;const g=ve(),{t:m,convert:h}=G(),[f,v]=x.useState(null),[y,w]=x.useState(new Map),[b,j]=x.useState([]),[S,k]=x.useState(new Map),[$,_]=x.useState(!1),[z,E]=x.useState("flow"),[T,C]=x.useState(null);x.useEffect(()=>{if(!n||!t.work_id){v(null);return}let N=!1;return n.getItem(t.work_id).then(X=>{!N&&X&&X.type==="work"&&v(X)}).catch(()=>{}),()=>{N=!0}},[n,t.work_id]),x.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!t.work_id){C(null);return}let N=!1;return n.getLineageGraph(t.work_id).then(X=>{N||C(X&&X.nodes.length>1?X:null)}).catch(()=>{N||C(null)}),()=>{N=!0}},[n,t.work_id]),x.useEffect(()=>{const N=t.contained_in||[];if(!n||N.length===0){w(new Map);return}let X=!1;return Promise.all(N.map(ae=>{const ie=typeof ae=="string"?ae:ae.id;return n.getItem(ie).then(pe=>[ie,pe]).catch(()=>[ie,null])})).then(ae=>{if(X)return;const ie=new Map;for(const[pe,$e]of ae)$e&&ie.set(pe,$e);w(ie)}),()=>{X=!0}},[n,t.contained_in]);const O=x.useMemo(()=>{const N=new Set([...(f==null?void 0:f.books)||[],...t.related_books||[]]);return N.add(t.id),[...N]},[f==null?void 0:f.books,t.related_books,t.id]),W=O.length-1;x.useEffect(()=>{if(!n||W<=0){j([]);return}const N=O.length<=es,X=N?O:O.slice(0,8);let ae=!1;return Promise.all(X.map(ie=>ie===t.id?Promise.resolve({id:ie,title:t.title,edition:t.edition,year:zn(t)}):n.getItem(ie).then(pe=>{const $e=pe??{};return{id:ie,title:$e.title,edition:$e.edition,year:pe?zn($e):void 0}}).catch(()=>({id:ie})))).then(ie=>{if(ae)return;const pe=ie.filter($e=>$e.id===t.id||$e.title||$e.edition);N&&pe.sort(($e,H)=>($e.year??1/0)-(H.year??1/0)),j(pe)}),()=>{ae=!0}},[n,O,W,t]);const P=t.lineage,Y=x.useMemo(()=>[...((P==null?void 0:P.derived_from)||[]).filter(N=>N.ref_type==="book").map(N=>N.ref),...((P==null?void 0:P.related_to)||[]).map(N=>N.book_id)].filter(Boolean),[P]);x.useEffect(()=>{if(!n||Y.length===0){k(new Map);return}let N=!1;return Promise.all(Y.map(X=>n.getItem(X).then(ae=>[X,{id:X,title:ae==null?void 0:ae.title,edition:ae==null?void 0:ae.edition}]).catch(()=>[X,{id:X}]))).then(X=>{N||k(new Map(X))}),()=>{N=!0}},[n,Y]);const V=x.useMemo(()=>sa(t.resources,t.resource_groups,m),[t.resources,t.resource_groups,m]),Q=V.groups.reduce((N,X)=>N+X.rows.length+X.mirrors.length,0),ge=V.groups.length>0&&V.groups.every(N=>N.key==="_physical"),A=dn(t),I=xl(t),Z=bt(t,g.unit.juan),ee=new Set((t.contained_in||[]).map(N=>typeof N=="string"?0:sn(N.volume_index).length).filter(N=>N>0)),ce=N=>{var ie;const X=(ie=t.base_edition)==null?void 0:ie.find(pe=>pe.book_id===N&&pe.name);if(X!=null&&X.name)return X.name;const ae=S.get(N);return(ae==null?void 0:ae.edition)||(ae==null?void 0:ae.title)||""},fe=x.useMemo(()=>{var be,_e,je,me,Oe;const N=[];I&&N.push({label:m("bookPage.fact.editionType"),value:h(I),title:t.edition_type||(be=t.lineage)!=null&&be.category?void 0:m("bookPage.inferredFromEdition")}),(_e=t.publication_info)!=null&&_e.details?N.push({label:m("bookPage.fact.publication"),value:h(t.publication_info.details)}):(A.era||A.reign)&&N.push({label:m("bookPage.fact.era"),value:h([A.era,A.reign].filter(Boolean).join(" ")),title:A.source==="edition"?m("bookPage.inferredFromEdition"):void 0}),Z&&N.push({label:m("bookPage.fact.measure"),value:h(Z)});const X=(t.contained_in||[]).flatMap(ze=>typeof ze=="string"?[]:sn(ze.volume_index));X.length&&N.push({label:m("bookPage.fact.volumes"),value:m("bookPage.volumesValue",{range:Dn(X,g.unit.volume),unit:g.unit.volume,n:X.length})});const ae=(((je=t.lineage)==null?void 0:je.derived_from)||[]).find(ze=>ze.relation==="底本"&&ze.ref_type==="book");ae&&ce(ae.ref)&&N.push({label:m("bookPage.fact.baseEdition"),value:e.jsx(Ge,{id:ae.ref,label:h(ce(ae.ref)),onNavigate:o,renderLink:r,dense:!0})});const ie=(t.base_edition||[]).filter(ze=>ze&&ze.name);for(const ze of["底本","配補","參校"]){if(ze==="底本"&&ae&&ce(ae.ref))continue;const Ve=ie.filter(Ae=>Ae.role===ze);Ve.length&&N.push({label:h(ze),value:Ve.map((Ae,lt)=>e.jsxs(x.Fragment,{children:[lt>0&&"、",Ae.book_id?e.jsx(Ge,{id:Ae.book_id,label:h(Ae.name),onNavigate:o,renderLink:r,dense:!0}):h(Ae.name)]},lt))})}const pe=(t.provenance||[]).filter(ze=>ze&&ze.institution),$e=(t.resources||[]).filter(ze=>(ze.types||(ze.type?[ze.type]:[])).includes("physical"));if(pe.length){N.push({label:m("bookPage.fact.holdings"),value:pe.slice(0,2).map(Ae=>h(Ae.institution)).join("、")+(pe.length>2?m("bookPage.andMorePlaces",{n:pe.length}):"")});const ze=pe.filter(Ae=>Ae.call_number).slice(0,2).map(Ae=>`${h(Ae.institution)} ${Ae.call_number}`);ze.length&&N.push({label:m("bookPage.fact.callNumber"),value:ze.join(";")+(pe.filter(Ae=>Ae.call_number).length>2?"…":"")});const Ve=pe.flatMap(Ae=>Ae.seals||[]).filter(Boolean);Ve.length&&N.push({label:m("bookPage.fact.seals"),value:h(Ve.join("、"))})}else $e.length?N.push({label:m("bookPage.fact.holdings"),value:$e.slice(0,2).map(ze=>h(ze.name)).join("、")+($e.length>2?m("bookPage.andMorePlaces",{n:$e.length}):"")}):(me=t.current_location)!=null&&me.name&&N.push({label:m("bookPage.fact.holdings"),value:h(t.current_location.name)});const H=t.physical_description;if(H){const ze=[[m("bookPage.fact.leafStyle"),H.leaf_style],[m("bookPage.fact.binding"),H.binding],[m("bookPage.fact.dimensions"),H.dimensions],[m("bookPage.fact.condition"),H.condition]];for(const[Ve,Ae]of ze)Ae&&Ae.trim()&&N.push({label:Ve,value:h(Ae)})}(Oe=t.page_count)!=null&&Oe.description&&N.push({label:g.label.pageCount,value:h(t.page_count.description)});const B=[...Ni(t.additional_titles),...Ni(t.attached_texts)];return B.length&&N.push({label:m("bookPage.fact.aliases"),value:B.map(h).join("、")}),N},[t,h,g,m,A,I,Z,S,o,r]),Ie=h(t.title),q=t.edition?h(t.edition):void 0,M=((L=t.lineage)==null?void 0:L.year_text)||"",K=e.jsx(un,{kind:m("bookPage.kind"),title:Ie,subtitle:q,byline:e.jsx(So,{authors:t.authors??(f==null?void 0:f.authors),onNavigate:o,renderLink:r}),meta:(()=>{const N=[I?h(I):"",A.era?h([A.era,A.reign].filter(Boolean).join("")):"",Z?h(Z):""].filter(Boolean);return N.length?e.jsx("span",{className:"bim-d-tags",children:N.map((X,ae)=>e.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(ae,2)}`,children:X},ae))}):null})(),description:(te=t.description)!=null&&te.text?e.jsx(ft,{text:t.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:so((U=t.description)==null?void 0:U.text)?6:void 0,facts:fe,readAction:s,secondaryAction:s&&Q>0&&!ge?e.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:m("bookPage.viewImages")}):void 0,foot:e.jsx(mn,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo})}),Re=t.contained_in||[],se=(l==null?void 0:l.chapters)||[],ye=h(se[0]&&mi(se[0].title)[0].slice(-1)||"")||m("bookPage.chapterUnit"),We=m("bookPage.chapterCount",{n:se.length,unit:ye}),Be=!!((le=P==null?void 0:P.derived_from)!=null&&le.length||(we=P==null?void 0:P.related_to)!=null&&we.length||(Le=t.appendix)!=null&&Le.length),Ee=[],Ce=m(ge?"bookPage.sec.physical":"bookPage.sec.images");(se.length||V.text.length||a)&&Ee.push({id:"fulltext",label:m("bookPage.sec.fulltext"),count:se.length?We:void 0}),V.groups.length&&Ee.push({id:"images",label:Ce,count:Q}),Be&&Ee.push({id:"lineage",label:m("bookPage.sec.lineage")}),Re.length&&Ee.push({id:"collections",label:m("section.containedIn"),count:Re.length}),(Se=t.location_history)!=null&&Se.length&&Ee.push({id:"provenance",label:m("section.locationHistory")});const He=N=>(p==null?void 0:p(N))??null,D=se[0],re=D?He(D.file):null,de=$?se:se.slice(0,Ch),ke=(N,X,ae)=>N?e.jsx("a",{className:ae,href:N.href??"#",onClick:N.onClick?ie=>{ie.metaKey||ie.ctrlKey||(ie.preventDefault(),N.onClick())}:void 0,children:X}):e.jsx("span",{className:ae,children:X}),F=e.jsxs(e.Fragment,{children:[(se.length>0||V.text.length>0||a)&&e.jsxs(Ze,{id:"fulltext",title:m("bookPage.sec.fulltext"),meta:se.length>0?e.jsx(qe,{items:[We,(Fe=l==null?void 0:l.source)!=null&&Fe.name?m("bookPage.sourceBy",{src:h(`${l.source.name}${l.source.license?` ${l.source.license}`:""}`)}):""]}):void 0,children:[a&&!D&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bim-d-ft","aria-busy":"true",children:[e.jsx("span",{className:"bim-d-ft-h",children:" "}),e.jsx("span",{className:"bim-d-meta",children:" "})]}),e.jsx("div",{className:"bim-d-chap-pending","aria-hidden":"true"})]}),D&&e.jsxs("div",{className:"bim-d-ft",children:[e.jsx("h3",{className:"bim-d-ft-h",children:m("bookPage.readFrom",{ch:h(mi(D.title)[0])||m("bookPage.firstChapter")})}),e.jsx("span",{className:"bim-d-meta",children:h((D.title||"").replace(/^第.+?[回章卷篇節节][  ]*/,""))}),ke(re,e.jsxs(e.Fragment,{children:[m("bookPage.enterReader")," ",e.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),se.length>1&&e.jsx("ul",{className:"bim-d-chap",children:de.map(N=>{const[X,ae]=mi(N.title);return e.jsx("li",{children:ke(He(N.file),e.jsxs(e.Fragment,{children:[X&&e.jsx("b",{children:h(X)}),h(ae||N.file)]}))},N.file)})}),se.length>de.length&&e.jsx(ro,{label:m("detail.expandRest",{n:se.length-de.length,unit:ye}),onClick:()=>_(!0)}),V.text.length>0&&e.jsxs(e.Fragment,{children:[(se.length>0||a)&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:m("bookPage.externalText")}),e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:V.text.map((N,X)=>e.jsx($o,{item:N,siblings:V.text,listedVolumeCounts:ee},`${N.id||N.url||N.name}-${X}`))})})]})]}),V.groups.length>0&&e.jsx(Ze,{id:"images",title:Ce,meta:e.jsx(qe,{items:[V.groups.length>1?m("bookPage.groupCount",{n:V.groups.length}):"",m("bookPage.placeCount",{n:Q})]}),children:e.jsx(aa,{groups:V.groups,listedVolumeCounts:ee})}),Be&&e.jsx(Ze,{id:"lineage",title:m("bookPage.sec.lineage"),meta:(De=P==null?void 0:P.derived_from)!=null&&De.length?m("bookPage.lineageMeta"):void 0,action:T?e.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":m("bookPage.lineageView"),children:[e.jsx("button",{type:"button","aria-pressed":z==="flow",onClick:()=>E("flow"),children:m("bookPage.viewCards")}),e.jsx("button",{type:"button","aria-pressed":z==="graph",onClick:()=>E("graph"),children:m("bookPage.viewGraph")})]}):void 0,children:z==="graph"&&T?e.jsx(_o,{graph:T,defaultMode:"graph",selectedNodeId:t.id,graphHeight:480,renderLink:(N,X)=>e.jsx(Ge,{id:N,label:h(X),onNavigate:o,renderLink:r,dense:!0})}):e.jsx(Nh,{data:t,heading:q||Ie,yearText:M,refName:ce,onNavigate:o,renderLink:r})}),Re.length>0&&e.jsx(Ze,{id:"collections",title:m("section.containedIn"),children:e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:Re.map((N,X)=>{var H,B;const ae=typeof N=="string"?N:N.id,ie=typeof N=="string"?[]:sn(N.volume_index),pe=y.get(ae),$e=(pe==null?void 0:pe._member_count)||((H=pe==null?void 0:pe.books)==null?void 0:H.length)||((B=pe==null?void 0:pe.contained_works)==null?void 0:B.length)||0;return e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-d-zt-main",children:[e.jsx(Ge,{id:ae,label:pe?h(pe.title):ae,onNavigate:o,renderLink:r,dense:!0}),ie.length>0&&e.jsx(Th,{volumes:ie,unit:g.unit.volume})]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${$e?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:$e>0&&m("bookPage.totalOf",{n:$e,unit:g.unit.bu})})]},`${ae}-${X}`)})})})}),(J=t.location_history)!=null&&J.length?e.jsx(Ze,{id:"provenance",title:m("section.locationHistory"),children:e.jsx("ul",{className:"bim-d-tl",children:t.location_history.map((N,X)=>e.jsxs("li",{children:[e.jsx("span",{className:"bim-d-tl-t",children:h(N.name)}),([N.start_date,N.end_date].filter(Boolean).join("—")||N.description)&&e.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:e.jsx(qe,{items:[[N.start_date,N.end_date].filter(Boolean).join("—"),N.description?h(N.description):""]})})]},X))})}):null,Ee.length===0&&e.jsx(Ze,{title:m("bookPage.sec.empty"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:m("bookPage.emptyText")})})]}),he=b.findIndex(N=>N.id===t.id),Ne=O.length<=es,R=Ne&&he>=0?b.slice(Math.max(0,he-ts),he+ts+1):b.filter(N=>N.id!==t.id),ne=e.jsxs(e.Fragment,{children:[f&&e.jsxs("div",{id:"work",className:"bim-d-side",style:{scrollMarginTop:16},children:[e.jsx("h2",{className:"bim-d-ui bim-d-side-h",children:h(g.section.belongsToWork)}),e.jsx("div",{style:{fontSize:17,fontWeight:500},children:e.jsx(Ge,{id:f.id,label:h(f.title),onNavigate:o,renderLink:r})}),e.jsx(qe,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(f.authors||[]).slice(0,2).map(N=>`${N.dynasty?`〔${h(N.dynasty)}〕`:""}${h(N.name)}`),h(bt(f,g.unit.juan)),f._edition_count?m("bookPage.editionCount",{n:f._edition_count}):""]}),((Pe=f.description)==null?void 0:Pe.text)&&e.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:h(f.description.text.replace(/[#*_>`[\]]/g,""))})]}),W>0&&R.length>0&&e.jsxs("div",{children:[e.jsx(zt,{id:"siblings",timeline:!0,title:Ne?m("bookPage.siblings"):g.relation.siblingVersions,meta:Ne?m("bookPage.byEra"):m("bookPage.kindCount",{n:W}),cap:R.length,items:R.map(N=>N.id===t.id?e.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:h(N.edition||N.title||N.id)}):e.jsx(Ge,{id:N.id,label:h(N.edition||N.title||N.id),onNavigate:o,renderLink:r,dense:!0})),metas:R.map(N=>[N.year!=null?N.year<0?m("detail.bce",{n:-N.year}):String(N.year):"",N.id===t.id?m("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:R.findIndex(N=>N.id===t.id)}),f&&e.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:e.jsx(Ge,{id:f.id,label:m("bookPage.viewAllInWork",{n:O.length}),onNavigate:o,renderLink:r,dense:!0})})]})]}),ue=t.work_id?e.jsx(fl,{caption:g.section.belongsToWork,children:e.jsx(Ge,{id:t.work_id,label:f?h(f.title):" ",onNavigate:o,renderLink:r,dense:!0})}):void 0;return e.jsx(pn,{railTop:c,back:d,up:ue,nav:Ee,railLinks:u,main:F,card:K,side:ne})};function Th({volumes:t,unit:n}){const{t:o}=G();return e.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[o("bookPage.volumeRange",{range:Dn(t,n),unit:n}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-d-dot"}),o("bookPage.volumeCount",{n:t.length,unit:n})]})]})}function Nh({data:t,heading:n,yearText:o,refName:r,onNavigate:s,renderLink:l}){var w;const{t:a,convert:p}=G(),c=t.lineage,d=(c==null?void 0:c.derived_from)||[],u=d.filter(b=>b.ref_type!=="book"),g=d.filter(b=>b.ref_type==="book"&&b.relation==="底本"),m=d.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),h=(c==null?void 0:c.related_to)||[],f=d.length>0||h.length>0,v=b=>b&&zh.has(b)?a("bookPage.confidenceNote",{c:a(`bookPage.confidence.${b}`)}):"",y=(b,j)=>e.jsx(Ge,{id:b,label:p(j||b),onNavigate:s,renderLink:l,dense:!0});return e.jsxs("div",{className:"bim-d-lf",children:[f&&e.jsxs("ol",{className:"bim-d-lf-list",children:[u.map((b,j)=>e.jsx("li",{className:"bim-d-lf-node",children:e.jsxs("div",{className:"bim-d-lf-dash",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:b.relation?p(b.relation):a("bookPage.lineage.ancestor")}),e.jsx("span",{className:"bim-d-lf-name",children:a("bookPage.lineage.reconstructed")}),b.evidence&&e.jsxs("span",{className:"bim-d-meta",children:[p(b.evidence),v(b.confidence)]})]})},`a-${j}`)),g.map((b,j)=>e.jsx("li",{className:"bim-d-lf-node",children:e.jsxs("div",{className:"bim-d-lf-card",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:p(b.relation)}),e.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,r(b.ref))}),b.evidence&&e.jsxs("p",{className:"bim-d-lf-ev",children:[p(b.evidence),v(b.confidence)]})]})},`b-${j}`)),e.jsxs("li",{className:"bim-d-lf-node bim-d-lf-cur",children:[e.jsxs("div",{className:"bim-d-lf-here",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:a("bookPage.lineage.thisEdition")}),e.jsx("span",{className:"bim-d-lf-name",children:n}),o&&e.jsx("span",{className:"bim-d-lf-yr",children:p(o)})]}),m.length>0&&e.jsx("div",{className:"bim-d-lf-side",children:m.map((b,j)=>e.jsxs("div",{className:"bim-d-lf-dash",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:p(b.relation)}),e.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,r(b.ref))}),b.evidence&&e.jsxs("p",{className:"bim-d-lf-ev",children:[p(b.evidence),v(b.confidence)]})]},j))})]}),h.length>0&&e.jsxs("li",{className:"bim-d-lf-node bim-d-lf-out",children:[e.jsx("span",{className:"bim-d-lf-out-h bim-d-ui",children:a("bookPage.lineage.derivatives")}),e.jsx("span",{className:"bim-d-lf-chips",children:h.map((b,j)=>e.jsxs("span",{className:"bim-d-lf-chip",title:b.evidence?p(b.evidence):void 0,children:[y(b.book_id,r(b.book_id)),e.jsx("span",{className:"bim-d-meta",children:p(b.relation)})]},j))})]})]}),(w=t.appendix)==null?void 0:w.map((b,j)=>e.jsxs("details",{className:"bim-d-lf-app",children:[e.jsxs("summary",{className:"bim-d-ui",children:[e.jsx("span",{className:"bim-d-meta",children:a("bookPage.lineage.appendix")})," ",p(b.title)]}),e.jsx(ft,{text:b.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${j}`)),(c==null?void 0:c.note)&&e.jsx("p",{className:"bim-d-meta",style:{margin:"12px 0 0",maxWidth:"46em"},children:p(c.note)})]})}const tn=16,Ih=200,Rh=16,ga=({data:t,catalog:n,transport:o,onNavigate:r,renderLink:s,catalogAction:l,railTop:a,back:p,railLinks:c})=>{var ke,F,he,Ne,R,ne,ue;const{t:d,convert:u,messages:g}=G(),[m,h]=x.useState(""),[f,v]=x.useState(!1),[y,w]=x.useState(null),[b,j]=x.useState(""),[S,k]=x.useState(!1),$=x.useMemo(()=>gl(t,n),[t,n]),[_,z]=x.useState(new Map),E=!!o&&$.rows.length>0&&$.rows.length<=Ih,T=E&&($.rows.length<=tn||S),C=T&&$.rows.every(L=>!L.id||_.has(L.id)),O=L=>{var te;return Pi(L?(te=_.get(L))==null?void 0:te.l1:void 0)},W=x.useMemo(()=>{const L=m.trim(),te=L?u(L):"";return $.rows.filter(U=>{var we,Le;if(b&&Pi(U.id?(we=_.get(U.id))==null?void 0:we.l1:void 0)!==b)return!1;if(!te)return!0;const le=U.id&&((Le=_.get(U.id))==null?void 0:Le.title)||U.title;return u(le).includes(te)||(U.subItems||[]).some(Se=>u(Se).includes(te))})},[$.rows,m,b,_,u]),P=f?W:W.slice(0,tn),Y=x.useMemo(()=>(T?$.rows:P).filter(L=>L.id&&!_.has(L.id)).map(L=>L.id),[T,$.rows,P,_]);x.useEffect(()=>{if(!o||Y.length===0)return;let L=!1;const te=Y.slice(0,Rh);return Promise.all(te.map(U=>o.getItem(U).then(le=>{var Se,Fe;const we=le??{},Le={title:we.title,edition:we.edition,authors:we.authors,measure:le?bt(le,g.unit.juan):void 0,versionCount:we._edition_count??((Se=we.books)==null?void 0:Se.length),l1:((Fe=we.classification)==null?void 0:Fe.l1)||void 0};return[U,Le]}).catch(()=>[U,{}]))).then(U=>{L||z(le=>{const we=new Map(le);for(const[Le,Se]of U)we.set(Le,Se);return we})}),()=>{L=!0}},[o,Y,g.unit.juan]);const V=(t.contained_in||[])[0];x.useEffect(()=>{if(!V){w(null);return}if(w({id:V}),!o)return;let L=!1;return o.getItem(V).then(te=>{L||w({id:V,title:te==null?void 0:te.title})}).catch(()=>{}),()=>{L=!0}},[o,V]);const Q=x.useMemo(()=>sa(t.resources,t.resource_groups,d),[t.resources,t.resource_groups,d]),ge=Q.text.length+Q.groups.reduce((L,te)=>L+te.rows.length+te.mirrors.length,0),A=t.contained_works||[],I=new Set($.rows.map(L=>L.id).filter(Boolean)),Z=A.length>0&&!A.every(L=>I.has(L.id)),ee=(()=>{const L=$.rows.map(te=>te.edition).filter(Boolean);return L.length>1&&new Set(L).size===1})(),ce=$.rows.some(L=>L.volumes.length>0||L.expected!=null),fe=t._member_count||((ke=t.books)==null?void 0:ke.length)||A.length,Ie=bt(t,g.unit.juan),q=t.count,M=L=>typeof L=="number"&&Number.isFinite(L)?L:null,K=M(q==null?void 0:q.juan)??M((F=t.juan_count)==null?void 0:F.number),Re=M(q==null?void 0:q.ce)??($.totalVolumes||null),se=[{value:$.rows.length,label:d("collectionPage.stat.titles")},{value:K??0,label:g.unit.juan},{value:Re??0,label:g.unit.volume}],ye=x.useMemo(()=>{var U,le;const L=[];if((U=t.publication_info)!=null&&U.details&&L.push({label:d("collectionPage.fact.publication"),value:u(t.publication_info.details)}),fe&&fe!==$.rows.length){const we=t._member_type==="Book"?d("collectionPage.member.Book"):t._member_type==="Work"?d("collectionPage.member.Work"):d("collectionPage.member.other");L.push({label:we,value:`${fe} ${g.unit.bu}`,title:d("collectionPage.memberNote")})}const te=[M(q==null?void 0:q.zhong)!=null?d("collectionPage.nZhong",{n:q.zhong}):"",M(q==null?void 0:q.han)!=null?d("collectionPage.nHan",{n:q.han}):""].filter(Boolean);return te.length&&L.push({label:d("collectionPage.fact.expected"),value:te.join(" ")}),K==null&&Ie&&L.push({label:d("collectionPage.fact.measure"),value:u(Ie),title:(le=t.juan_count)!=null&&le.description?u(t.juan_count.description):void 0}),L},[t,fe,$.rows.length,K,Ie,q,u,d,g]),We=x.useMemo(()=>{if(!C)return[];const L=new Map;for(const U of $.rows){const le=O(U.id);le&&L.set(le,(L.get(le)??0)+1)}const te=an.filter(U=>(L.get(U.key)??0)>0);return te.length<2?[]:[{key:"",label:`${g.catalog.all} ${$.rows.length}`},...te.map(U=>({key:U.key,label:`${U.label} ${L.get(U.key)}`}))]},[C,$.rows,_,g]),Be=x.useMemo(()=>{if(!C||!$.rows.some(le=>le.volumes.length>0))return null;const L=[],te=$.rows.filter(le=>le.volumes.length>0).map(le=>({k:O(le.id)??"",from:Math.min(...le.volumes),to:Math.max(...le.volumes)})).sort((le,we)=>le.from-we.from);for(const le of te){const we=le.to-le.from+1,Le=L[L.length-1];Le&&Le.key===le.k?(Le.to=Math.max(Le.to,le.to),Le.n+=we):L.push({key:le.k,from:le.from,to:le.to,n:we})}const U=te.reduce((le,we)=>Math.max(le,we.to),0);return L.length>1&&L.some(le=>le.key)?{segs:L,last:U}:null},[C,$.rows,_]),Ee=(he=t.description)==null?void 0:he.text,Ce=e.jsx(un,{kind:d("collectionPage.kind"),title:u(t.title),byline:e.jsx(So,{authors:t.authors,onNavigate:r,renderLink:s}),meta:e.jsx(qe,{items:[t.subtype==="work_collection"?d("collectionPage.workCollection"):"",(Ne=t.publication_info)!=null&&Ne.year?u(t.publication_info.year):""]}),description:Ee||(R=t.history)!=null&&R.length?e.jsxs(e.Fragment,{children:[Ee&&e.jsx(ft,{text:Ee,style:{fontSize:15,lineHeight:1.85}}),(ne=t.history)!=null&&ne.length?e.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:t.history.map((L,te)=>e.jsx("li",{children:u(L)},te))}):null]}):void 0,clampDescription:so(Ee)||(((ue=t.history)==null?void 0:ue.length)??0)>2?6:void 0,stats:se,facts:ye,foot:e.jsx(mn,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo}),children:Be&&e.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[e.jsx("div",{className:"bim-d-dist-head",children:e.jsx("span",{children:d("collectionPage.dist.head")})}),e.jsx("div",{className:"bim-d-dist-bar",role:"group","aria-label":d("collectionPage.dist.head"),children:Be.segs.map((L,te)=>{const U=an.find(le=>le.key===L.key);return e.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!U,title:U?d("collectionPage.dist.segTitle",{section:u(U.label),from:L.from,to:L.to}):void 0,"aria-label":U?d("collectionPage.dist.only",{section:u(U.label)}):d("collectionPage.dist.unclassified"),"aria-pressed":!!U&&b===L.key,style:{flexGrow:L.n,background:i(U?U.token:"rule")},onClick:()=>{U&&(j(b===L.key?"":L.key),v(!1))}},te)})}),e.jsxs("div",{className:"bim-d-life-lab",children:[e.jsx("span",{children:d("catalog.volume",{n:1})}),e.jsx("span",{children:d("collectionPage.dist.hint")}),e.jsx("span",{children:d("catalog.volume",{n:Be.last})})]})]})}),He=[];$.rows.length&&He.push({id:"titles",label:d("collectionPage.sec.titles"),count:$.rows.length}),ge&&He.push({id:"resources",label:d("collectionPage.sec.resources"),count:ge}),Z&&He.push({id:"works",label:g.section.containedWorks,count:A.length});const D=e.jsxs(e.Fragment,{children:[$.rows.length>0&&e.jsxs(Ze,{id:"titles",title:d("collectionPage.sec.titles"),meta:e.jsx(qe,{items:[`${$.rows.length} ${g.unit.items}`,$.totalVolumes?d("collectionPage.totalVolumes",{n:$.totalVolumes,unit:g.unit.volume}):"",W.length!==$.rows.length?d("collectionPage.currentN",{n:W.length,unit:g.unit.items}):""]}),action:l,children:[($.rows.length>tn||We.length>0)&&e.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[We.length>0&&e.jsx(Un,{items:We,value:b,onChange:L=>{j(L),v(!1)}}),E&&$.rows.length>tn&&!C&&e.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:S,onClick:()=>k(!0),title:d("collectionPage.loadAllTitle",{n:$.rows.length,unit:g.unit.items}),children:d(S?"collectionPage.grouping":"collectionPage.groupBySection")}),e.jsx("span",{className:"bim-d-spacer"}),$.rows.length>tn&&e.jsx("input",{type:"search",className:"bim-d-find",value:m,placeholder:d("collectionPage.find"),"aria-label":d("collectionPage.find"),onChange:L=>{h(L.target.value),v(!1)}})]}),e.jsxs("table",{className:"bim-d-zt","data-ncap":!f&&Vn(W.length)?"":void 0,children:[e.jsx("thead",{className:"bim-d-ui",children:e.jsxs("tr",{children:[ce&&e.jsx("th",{style:{width:"8.5em"},children:d("collectionPage.col.volumes")}),e.jsx("th",{children:d("collectionPage.col.title")}),e.jsx("th",{style:{textAlign:"right"},children:d("collectionPage.col.versions")})]})}),e.jsx("tbody",{children:P.map((L,te)=>{var De;const U=L.id?_.get(L.id):void 0,le=U!=null&&U.title&&L.title===L.id?U.title:L.title,we=((U==null?void 0:U.authors)||[]).find(J=>J&&J.name),Le=[we?`${we.dynasty?`〔${u(we.dynasty)}〕`:""}${u(we.name)}${we.role?` ${u(we.role)}`:""}`:"",U!=null&&U.measure?u(U.measure):"",(De=L.subItems)!=null&&De.length?L.subItems.map(J=>u(J)).join("、"):"",(U!=null&&U.edition||L.edition)&&!ee?u((U==null?void 0:U.edition)||L.edition||""):""].filter(Boolean),Se=an.find(J=>J.key===O(L.id)),Fe=L.volumes.length>0?d("collectionPage.volumeRange",{range:Dn(L.volumes,g.unit.volume),unit:g.unit.volume}):L.expected!=null?`${L.found??0}/${L.expected} ${g.unit.volume}`:"";return e.jsxs("tr",{children:[ce&&e.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Fe?"":" bim-d-zt-blank"}`,children:[Se&&e.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:i(Se.token)}}),Fe||e.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),e.jsxs("td",{className:"bim-d-zt-main",children:[L.id?e.jsx(Ge,{id:L.id,label:u(le),onNavigate:r,renderLink:s,dense:!0}):e.jsx("span",{className:"bim-d-zt-name",children:u(le)}),Le.length>0?e.jsx(qe,{items:Le}):L.id&&!U&&o?e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${U!=null&&U.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:U!=null&&U.versionCount?d("collectionPage.nZhong",{n:U.versionCount}):""})]},`${L.id??L.title}-${te}`)})})]}),P.length===0&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:d("catalog.noMatch")}),!f&&e.jsx(oo,{total:W.length,shown:P.length,unit:g.unit.items,onClick:()=>v(!0)})]}),ge>0&&e.jsxs(Ze,{id:"resources",title:d("collectionPage.sec.resources"),meta:d("collectionPage.resourcesCount",{n:ge}),children:[Q.text.length>0&&e.jsxs("div",{className:"bim-d-rg",children:[Q.groups.length>0&&e.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:d("collectionPage.text")}),e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:Q.text.map((L,te)=>e.jsx($o,{item:L,siblings:Q.text},`${L.id||L.url||L.name}-${te}`))})})]}),e.jsx(aa,{groups:Q.groups})]}),$.rows.length===0&&ge===0&&e.jsx(Ze,{title:d("collectionPage.sec.titles"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:d("collectionPage.empty")})})]}),re=Z?e.jsx(zt,{id:"works",title:g.section.containedWorks,meta:d("collectionPage.nZhong",{n:A.length}),cap:12,items:A.map(L=>e.jsx(Ge,{id:L.id,label:u(L.title),onNavigate:r,renderLink:s,dense:!0}))}):null,de=y?e.jsx(fl,{caption:d("collectionPage.parent"),children:e.jsx(Ge,{id:y.id,label:u(y.title||y.id),onNavigate:r,renderLink:s,dense:!0})}):void 0;return e.jsx(pn,{railTop:a,back:p,up:de,nav:He,railLinks:c,main:D,card:Ce,side:re})},Eh=16,gi=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function ns(t){if(!t)return gi.length;const n=gi.indexOf(t);return n===-1?gi.length:n}function Lh(t,n){return t==null?"":t<0?n("entityPage.bce",{n:-t}):String(t)}const Ph={秦:[-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]},ha=({data:t,transport:n,onNavigate:o,renderLink:r,railTop:s,back:l,railLinks:a})=>{var de,ke,F,he,Ne;const{t:p,convert:c,messages:d}=G(),u=R=>Lh(R,p),[g,m]=x.useState("全部"),[h,f]=x.useState(!1),[v,y]=x.useState("default"),[w,b]=x.useState(new Map),j=x.useMemo(()=>(t.works||[]).map(R=>{const ne=w.get(R.work_id);return{id:R.work_id,title:(ne==null?void 0:ne.title)??R.title??R.work_id,role:R.role||"",cls:no(R.role),versionCount:ne==null?void 0:ne.versionCount,section:ne==null?void 0:ne.cls,l1:ne==null?void 0:ne.l1,measure:ne==null?void 0:ne.measure,hasImage:ne==null?void 0:ne.hasImage,loaded:!!(ne!=null&&ne.loaded)}}),[t.works,w]),S=x.useMemo(()=>ml((t.works||[]).map(R=>R.role),p("detail.roleAll")),[t.works,p]),k=x.useMemo(()=>{const R=g==="全部"?j:j.filter(ne=>ne.cls===g);return v==="versions"?[...R].sort((ne,ue)=>(ue.versionCount??-1)-(ne.versionCount??-1)):R},[j,g,v]),$=h?k:k.slice(0,Eh),_=x.useMemo(()=>$.filter(R=>!w.has(R.id)).map(R=>R.id),[$,w]);x.useEffect(()=>{if(!n||_.length===0)return;let R=!1;return Promise.all(_.map(ne=>n.getItem(ne).then(ue=>{var le,we,Le,Se,Fe;const L=ue??{},te=L._edition_count??(((le=L.books)==null?void 0:le.length)??0)+(((we=L.collections)==null?void 0:we.length)??0),U=[(Le=L.classification)==null?void 0:Le.l1,(Se=L.classification)==null?void 0:Se.l2].filter(Boolean).join(" ");return[ne,{id:ne,title:L.title,versionCount:te,loaded:!0,cls:U||void 0,l1:((Fe=L.classification)==null?void 0:Fe.l1)||void 0,measure:ue&&bt(ue,d.unit.juan)||void 0,hasImage:!!(L.has_image??L._has_image)}]}).catch(()=>[ne,{id:ne,loaded:!0}]))).then(ne=>{R||b(ue=>{const L=new Map(ue);for(const[te,U]of ne)L.set(te,U);return L})}),()=>{R=!0}},[n,_,d.unit.juan]);const z=x.useMemo(()=>{const R=new Map;for(const ne of t.alt_names||[]){const ue=ne.type||d.section.aliases;R.has(ue)||R.set(ue,[]),R.get(ue).push(ne.name)}return[...R.entries()].sort((ne,ue)=>ns(ne[0])-ns(ue[0])).map(([ne,ue])=>({label:ne,names:ue}))},[t.alt_names,d]),E=t.birth_year??((de=t.dates)==null?void 0:de.birth)??void 0,T=t.death_year??((ke=t.dates)==null?void 0:ke.death)??void 0,C=(F=t.dates)==null?void 0:F.floruit,O=E!=null||T!=null?`${u(E)||"?"}—${u(T)||"?"}`:Array.isArray(C)&&C.length===2&&C.every(R=>Number.isFinite(R))?p("entityPage.floruit",{from:u(C[0]),to:u(C[1])}):"",W=new Set(["本名","字","號","号"]),P=z.filter(R=>W.has(R.label)),Y=z.filter(R=>!W.has(R.label)),V=Y.reduce((R,ne)=>R+ne.names.length,0),Q=x.useMemo(()=>{const R=[];for(const ue of P)R.push({label:ue.label,value:ue.names.map(L=>c(L)).join("、")});const ne=(t.works||[]).length;return ne&&R.push({label:p("entityPage.fact.works"),value:p("entityPage.nZhong",{n:ne})}),R},[t.works,P,c,p]),ge=R=>{var ne;return(ne=z.find(ue=>R.includes(ue.label)))==null?void 0:ne.names[0]},A=ge(["字"]),I=ge(["號","号"]),Z=[A?p("entityPage.zi",{name:c(A)}):"",I?p("entityPage.hao",{name:c(I)}):""].filter(Boolean).join(","),ee=t.native_place,ce=t.dynasty?Ph[t.dynasty]:void 0,fe=(()=>{if(!ce||E==null||T==null||T<E)return null;const[R,ne]=ce,ue=Math.max(E,R),L=Math.min(T,ne);if(L<=ue)return null;const te=ne-R;return e.jsxs("div",{className:"bim-d-life bim-d-ui",children:[e.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":p("entityPage.lifeAria",{birth:u(E),death:u(T),years:T-E+1}),children:e.jsx("i",{style:{left:`${(ue-R)/te*100}%`,width:`${(L-ue)/te*100}%`}})}),e.jsxs("div",{className:"bim-d-life-lab",children:[e.jsx("span",{children:`${u(R)} ${c(t.dynasty)}`}),e.jsx("span",{children:p("entityPage.lifeYears",{years:T-E+1})}),e.jsx("span",{children:u(ne)})]})]})})(),Ie=x.useMemo(()=>{if(!n||j.length===0||j.some(ue=>!ue.loaded))return null;const R=new Map;for(const ue of j){const L=Pi(ue.l1);L&&R.set(L,(R.get(L)??0)+1)}const ne=an.map(ue=>({...ue,n:R.get(ue.key)??0})).filter(ue=>ue.n>0);return ne.length?ne:null},[j,n]),q=e.jsxs(un,{kind:d.entityPage.subtype[t.subtype]??p("entityPage.subtype.people"),title:c(t.primary_name||t.title),subtitle:Z||void 0,meta:e.jsxs(e.Fragment,{children:[e.jsx(qe,{items:[t.dynasty?c(t.dynasty):"",O,ee?p("entityPage.nativePlace",{place:c(ee)}):""]}),fe]}),description:(he=t.description)!=null&&he.text?e.jsx(ft,{text:t.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:so((Ne=t.description)==null?void 0:Ne.text)?6:void 0,facts:Q,foot:e.jsx(mn,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo}),children:[V>0&&e.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[e.jsx("summary",{children:p("entityPage.moreNames",{n:V})}),e.jsx("dl",{children:Y.map(R=>e.jsxs(x.Fragment,{children:[e.jsx("dt",{children:c(R.label)}),e.jsx("dd",{children:R.names.map(ne=>c(ne)).join("、")})]},R.label))})]}),Ie&&e.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[e.jsx("div",{className:"bim-d-dist-head",children:e.jsx("span",{children:p("entityPage.dist")})}),e.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:Ie.map(R=>e.jsx("i",{style:{flexGrow:R.n,background:i(R.token)}},R.key))}),e.jsx("div",{className:"bim-d-dist-key",children:Ie.map(R=>e.jsxs("span",{children:[e.jsx("i",{style:{background:i(R.token)}}),c(R.label)," ",R.n]},R.key))})]})]}),M=x.useMemo(()=>j.filter(R=>R.loaded&&(R.versionCount??0)>0).sort((R,ne)=>(ne.versionCount??0)-(R.versionCount??0)).slice(0,3),[j]),K=!!n&&j.length>=3&&$.some(R=>!R.loaded),Re=g==="全部"&&(K||M.length>=2),se=t.external_ids||{},ye=[];se.cbdb_id!=null&&ye.push({label:"CBDB",id:String(se.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${se.cbdb_id}`,note:se.cbdb_match==="auto"?p("entityPage.autoMatch"):void 0});const We=se.wikidata_id;We&&ye.push({label:"Wikidata",id:We,href:`https://www.wikidata.org/wiki/${We}`});const Be=se.viaf_id;Be&&ye.push({label:"VIAF",id:Be,href:`https://viaf.org/viaf/${Be}`});const Ee=S.map(R=>({key:R.cls,label:`${R.label} ${R.count}`})),Ce=[...Re&&!K?[{id:"featured",label:p("entityPage.sec.featured"),count:M.length}]:[],...j.length?[{id:"works",label:p("entityPage.sec.allWorks"),count:j.length}]:[],...ye.length?[{id:"external",label:p("entityPage.sec.external"),count:ye.length}]:[]],He=Re?e.jsxs(Ze,{id:"featured",title:p("entityPage.sec.featured"),children:[e.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:p("entityPage.featuredSub")}),e.jsxs("div",{className:"bim-d-picks","aria-busy":K||void 0,children:[K&&[0,1,2].map(R=>e.jsxs("div",{className:"bim-d-pick","aria-hidden":"true",children:[e.jsx("span",{className:"bim-d-pick-t",children:" "}),e.jsx("span",{className:"bim-d-meta",children:" "}),e.jsx("div",{className:"bim-d-pick-n",children:" "})]},R)),!K&&M.map(R=>e.jsxs("div",{className:"bim-d-pick",children:[e.jsx("span",{className:"bim-d-pick-t",children:e.jsx(Ge,{id:R.id,label:c(R.title),onNavigate:o,renderLink:r,dense:!0})}),e.jsx(qe,{items:[R.section?c(R.section):"",R.measure?c(R.measure):""]}),e.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[e.jsx("span",{className:"bim-d-pick-num",children:R.versionCount}),e.jsx("span",{children:p("entityPage.versionsUnit")}),R.hasImage&&e.jsx("span",{className:"bim-d-flag",children:p("entityPage.hasImage")})]})]},R.id))]})]}):null,D=j.length===0?e.jsx(Ze,{title:p("entityPage.sec.works"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("entityPage.empty")})}):e.jsxs(e.Fragment,{children:[He,e.jsxs(Ze,{id:"works",title:p("entityPage.sec.works"),meta:e.jsx(qe,{items:[p("entityPage.total",{n:j.length}),k.length!==j.length?p("entityPage.current",{n:k.length}):""]}),children:[e.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[Ee.length>1&&e.jsx(Un,{items:Ee,value:g,onChange:R=>{m(R),f(!1)}}),e.jsx("span",{className:"bim-d-spacer"}),e.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":v==="versions",onClick:()=>{v==="default"&&f(!0),y(R=>R==="default"?"versions":"default")},children:p(v==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),e.jsxs("table",{className:"bim-d-zt","data-ncap":!h&&Vn(k.length)?"":void 0,children:[e.jsx("thead",{className:"bim-d-ui",children:e.jsxs("tr",{children:[e.jsx("th",{children:p("entityPage.col.work")}),e.jsx("th",{children:p("entityPage.col.section")}),e.jsx("th",{children:p("entityPage.col.role")}),e.jsx("th",{children:p("entityPage.col.versions")}),e.jsx("th",{"aria-label":p("entityPage.col.image")})]})}),e.jsx("tbody",{children:$.map(R=>e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-d-zt-main",children:[e.jsx(Ge,{id:R.id,label:c(R.title),onNavigate:o,renderLink:r,dense:!0}),R.measure?e.jsx(qe,{items:[c(R.measure)]}):!R.loaded&&n?e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${R.section||R.loaded?"":" bim-d-zt-blank"}`,children:R.section?c(R.section):null}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${R.role?"":" bim-d-zt-blank"}`,children:R.role?c(R.role):e.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${R.loaded?"":" bim-d-zt-blank"}`,children:R.loaded?R.versionCount?p("entityPage.nZhong",{n:R.versionCount}):e.jsx("span",{className:"bim-d-zt-empty",children:p("entityPage.notRecorded")}):""}),e.jsx("td",{className:R.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:R.hasImage&&e.jsx("span",{className:"bim-d-flag bim-d-ui",children:p("entityPage.hasImage")})})]},R.id))})]}),$.length===0&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("entityPage.emptyRole")}),!h&&e.jsx(oo,{total:k.length,shown:$.length,unit:p("entityPage.moreUnit"),onClick:()=>f(!0)})]})]}),re=ye.length>0?e.jsx(zt,{id:"external",title:p("entityPage.sec.external"),items:ye.map(R=>e.jsxs("a",{href:R.href,target:"_blank",rel:"noopener noreferrer",children:[R.label," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:ye.map(R=>R.id),foot:se.cbdb_id!=null&&se.cbdb_match==="auto"?p("entityPage.cbdbAuto"):void 0}):null;return e.jsx(pn,{railTop:s,back:l,nav:Ce,railLinks:a,main:D,card:q,side:re})},Co="(max-width: 719px)",Ah=`${Co}, (pointer: coarse)`,xa=`
1100
+ `)){const r=po(o);if(r){n.push({kind:"heading",level:r.level,text:r.text});continue}const s=o.trim();!s||uo.test(s)||n.push({kind:"body",text:o})}return n}function Pl(t){if(!t)return[];const n=Gn(t);if(n==="unknown")return fr(t);const o=[];for(const{heading:r,body:s}of Bu(t)){r&&o.push(r);const l=Rl(s);if(l.length!==0){if(Ll(s)){o.push(...fr(s));continue}if(n==="record"){const a=l.join(" ");a&&o.push({kind:"body",text:a})}else for(const a of l){const p=El(a);p.length&&o.push({kind:"body",text:p.join(" ")})}}}return o}const Al=t=>t;function Bl(t,n=Al){if(t.indexOf("《")<0)return n(t);const o=[],r=/《([^《》\n]+)》/g;let s=0,l=0,a;for(;a=r.exec(t);)a.index>s&&o.push(e.jsx(h.Fragment,{children:n(t.slice(s,a.index))},l++)),o.push(e.jsxs("span",{className:"bim-rd-pn",children:[e.jsx("span",{className:"bim-rd-sr",children:"《"}),n(a[1]),e.jsx("span",{className:"bim-rd-sr",children:"》"})]},l++)),s=a.index+a[0].length;return s===0?n(t):(s<t.length&&o.push(e.jsx(h.Fragment,{children:n(t.slice(s))},l++)),o)}function mo(t,n={}){const o=n.renderText??Al,r=n.properNames?l=>Bl(l,o):o,s=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return ot(t,r,s)}function br(t,n,o){return t.indexOf("**")<0?n(t):t.split(/(\*\*[^*]+\*\*)/g).map((s,l)=>s.startsWith("**")&&s.endsWith("**")&&s.length>4?e.jsx("strong",{children:n(s.slice(2,-2))},`${o}-${l}`):e.jsx(h.Fragment,{children:n(s)},`${o}-${l}`))}const ai=/^(#{1,6})\s+(.*)$/,Mu=/^\s*<!--.*-->\s*$/;function Ml(t){return t.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
1101
+ `)?"":n)}function Wu(t){return t<=1?2:t===2?3:4}function Hu(){let t=1;return n=>{const o=Wu(n),r=Math.min(o,t+1);return t=r,{Tag:`h${r}`,className:`bim-rd-hl${o}`}}}function Tn(t){return t?Gn(Ml(t))!=="unknown":!1}function Ou(t){return/^\u3000{2}/.test(t)}const yr=t=>Ou(t)?"bim-rd-noindent":void 0;function jr({text:t,mode:n,inline:o,dropTitle:r}){const s=Ml(t),l=(d,u,g)=>!!r&&g<=1&&d<=2&&u.trim()===r.trim(),a=Hu();if(n==="paragraph"&&Gn(s)!=="unknown"){const d=Pl(s);return e.jsx(e.Fragment,{children:d.map((u,g)=>{if(u.kind==="heading"){if(l(u.level??1,u.text,g))return null;const{Tag:m,className:x}=a(u.level??1);return e.jsx(m,{className:x,children:o(u.text)},g)}return e.jsx("p",{className:yr(u.text),children:br(u.text,o,g)},g)})})}const p=s.split(`
1102
+ `);let c=0;return e.jsx(e.Fragment,{children:p.map((d,u)=>{const g=d.match(ai);if(g){const x=c++;if(l(g[1].length,g[2],x))return null;const{Tag:f,className:k}=a(g[1].length);return e.jsx(f,{className:k,children:o(g[2])},u)}if(!d.trim())return u>=2&&!!p[u-1].trim()&&!!p[u-2].trim()&&!ai.test(p[u-1])&&!ai.test(p[u-2])?e.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},u):null;if(Mu.test(d))return null;if(c++,/^\*\*[^*]+\*\*\s*$/.test(d.trim())){const{Tag:x,className:f}=a(3);return e.jsx(x,{className:f,children:o(d.trim().slice(2,-2))},u)}return e.jsx("p",{className:yr(d),children:br(d,o,u)},u)})})}function Fu(t){const{convert:n}=Ne();return h.useMemo(()=>t?n(t):"",[t,n])}function go({text:t,mode:n,tables:o=!1,gujiMarkdown:r=!1,properNames:s=!1,renderText:l,dropTitle:a}){const p=Fu(t),{t:c,convert:d}=Y(),u=x=>mo(x,{renderText:l,properNames:s,gujiMarkdown:r,t:c}),g=r?{gujiMarkdown:!0,t:c}:void 0,m=a?d(a):void 0;return!o||p.indexOf(":::")<0?e.jsx(jr,{text:p,mode:n,inline:u,dropTitle:m}):e.jsx(e.Fragment,{children:Zi(p).map((x,f)=>x.type==="table"?e.jsx(co,{table:x.table,opts:g},f):e.jsx(jr,{text:x.text,mode:n,inline:u,dropTitle:f===0?m:void 0},f))})}function Du(t,n){const[o,r]=h.useState(null),[s,l]=h.useState(!1),a=h.useRef(0);return h.useEffect(()=>{const p=++a.current;if(!t||!n){r(null),l(!1);return}let c;try{c=t(n)}catch{r(null),l(!1);return}if(!c||typeof c.then!="function"){r(c??null),l(!1);return}l(!0),c.then(d=>{p===a.current&&r(d??null)}).catch(()=>{p===a.current&&r(null)}).finally(()=>{p===a.current&&l(!1)})},[t,n]),{images:o,loading:s}}const vr={A:"fine",B:"rough",C:"rough",D:"ocr"};function Uu(t){return typeof t!="string"?null:t in $c?t:t in vr?vr[t]:null}const Vu={書:"书",類:"类",結語:"结语",結语:"结语",考證:"考证",詩:"诗"},Gu={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释"},Wl="\0";function Yu(t,n,o){const[r,s=""]=t.split(Wl);return e.jsxs(e.Fragment,{children:[r,e.jsx(qs,{text:n,convert:o}),s]})}function st(t){return typeof t!="string"?"":Vu[t]??Gu[t]??t}const Ku=["〇","一","二","三","四","五","六","七","八","九"],kr=["","十","百","千"],qu=["","萬","億"];function ho(t){if(t===0)return"〇";if(t<0)return`負${ho(-t)}`;const n=[];let o=t,r=0;for(;o>0;){const s=o%1e4;s>0?n.unshift(Zu(s,r>0)+qu[r]):n.length>0&&n.unshift("〇"),o=Math.floor(o/1e4),r++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Zu(t,n){const o=[];let r=t;for(;r>0;)o.unshift(r%10),r=Math.floor(r/10);let s="";for(let l=0;l<o.length;l++){const a=o[l],p=o.length-1-l;a===0?s&&!s.endsWith("〇")&&(s+="〇"):a===1&&p===1&&l===0&&!n?s+=kr[p]:s+=Ku[a]+kr[p]}return s.replace(/〇$/,"")}let ln=null,jn=null;const Nn=new Set;function Ju(){return ln?Promise.resolve():jn||(jn=import("opencc-js/t2cn").then(t=>{const n=t.Converter({from:"t",to:"cn"});ln=o=>n(be.normalizeVariants(o)),Nn.forEach(o=>o())}).catch(()=>{ln=t=>t,Nn.forEach(t=>t())}),jn)}const Xu=t=>t;function Et(){const[,t]=h.useState(0);return h.useEffect(()=>{if(ln)return;const n=()=>t(o=>o+1);return Nn.add(n),Ju(),()=>{Nn.delete(n)}},[]),ln??Xu}function Ot(t,n){return n(t).toLowerCase()}const Qu=i("highlight-bg");function gn(t,n,o){if(!n)return t;const r=Ot(n,o);if(!r)return t;const s=Ot(t,o);if(s.length!==t.length)return t;const l=[];let a=0,p=0;for(;a<t.length;){const c=s.indexOf(r,a);if(c===-1){l.push(t.slice(a));break}c>a&&l.push(t.slice(a,c)),l.push(e.jsx("mark",{style:{background:Qu,padding:0,color:"inherit"},children:t.slice(c,c+r.length)},p++)),a=c+r.length}return e.jsx(e.Fragment,{children:l})}function xo(t,n,o,r){if(!n)return!0;const s=Ot(n,r);return(o?[t.title,t.header_line,t.content,t.comment]:[t.title,t.book_title,t.author,t.author_info,t.summary,t.content,t.comment,t.additional_comment]).some(a=>typeof a=="string"&&Ot(a,r).includes(s))}function em(t,n,o){return n?Ot(t,o).includes(Ot(n,o)):!0}const fo={类:i("section-lei"),书:i("section-shu"),序:i("section-xu"),结语:i("section-jieyu"),注释:i("section-zhushi")},tm={考证:i("section-kaozhen")};function bo(t,n,o){return t.collated.sectionType[n]??o(n)}function Hl(t){var r;const n=t.files.length,o=((r=t.children)==null?void 0:r.reduce((s,l)=>s+Hl(l),0))||0;return n+o}function nm(t,n){const o=[],r=a=>{var p;o.push(...a.files),(p=a.children)==null||p.forEach(r)};if(r(t),o.length===0)return;const s=o.map(a=>n[a]);if(s.every(a=>a===void 0))return;if(s.some(a=>a==="loading"))return"loading";let l=0;for(const a of s)typeof a=="number"&&(l+=a);return l}const im={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function yo({enabled:t,expanded:n,onClick:o,style:r,children:s}){return t?e.jsx("button",{type:"button","aria-expanded":n,onClick:o,style:{...im,...r},children:s}):e.jsx("span",{style:r,children:s})}function om({type:t}){const{convert:n,messages:o}=Y(),r=st(t),s=fo[r]||i("desc-fg");return e.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:bo(o,r,n)})}function rm({section:t,onNavigate:n,highlightQuery:o="",no:r,showUnlinked:s=!1,domId:l}){const{t:a,convert:p}=Y(),c=Ye(),d=Et(),u=j=>j?ot(p(j),S=>o?gn(S,o,d):S,{t:a}):"",[g,m]=h.useState(!1),x=!!t.summary,f=!!t.comment,k=!!t.additional_comment,b=!!(t.content&&t.content.length>60),w=x||f||k||b;h.useEffect(()=>{o&&m(!0)},[o]);const y=!g&&b?$l(t.content.replace(/\n/g," "),80)+"…":null;return e.jsxs("div",{className:"bim-rd-row",id:l,style:{borderBottom:`1px solid ${i("rule")}`,overflow:"hidden"},children:[e.jsxs("div",{onClick:()=>w&&m(!g),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:w?"pointer":"default",userSelect:"none"},children:[r!=null&&e.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:i("label-fg")},children:r}),e.jsxs(yo,{enabled:w,expanded:g,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[w&&e.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),transition:"transform 0.15s",transform:g?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsxs("span",{style:{display:"block",flex:1,minWidth:0},children:[e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg")},children:[t.book_title?e.jsxs(e.Fragment,{children:["《",u(t.book_title),"》"]}):u(t.title),t.n_juan!=null&&e.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:a("collated.nJuan",{n:p(ho(t.n_juan))})}),(t.author_info||t.author)&&e.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:u(t.author_info||t.author)})]}),!g&&y&&e.jsx("span",{style:{display:"block",fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:u(y)})]})]}),t.edition&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u(t.edition)}),t.tag&&e.jsx("span",{style:{fontSize:"11px",color:i("section-tag-fg")},children:t.tag==="triangle"?"△":t.tag}),t.work_id&&n&&e.jsx("a",{href:c(t.work_id),onClick:j=>{j.metaKey||j.ctrlKey||(j.preventDefault(),j.stopPropagation(),n(t.work_id))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:a("collated.viewWork"),"aria-label":a("collated.viewWorkOf",{title:p(t.book_title||t.title)}),children:a("collated.workArrow")}),s&&!t.work_id&&e.jsx("span",{style:{fontSize:"11px",color:i("label-fg"),flexShrink:0},children:a("collated.unlinked")})]}),g&&w&&e.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${i("widget-border")}`,background:i("bg")},children:[t.author_info&&e.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"8px"},children:u(t.author_info)}),t.summary&&e.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:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a("collated.summary")}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:u(t.summary)})]}),t.comment&&e.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a("collated.comment")}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(t.comment)})]}),t.additional_comment&&e.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a("collated.additionalComment")}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(t.additional_comment)})]}),b&&!x&&!f&&!k&&e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(t.content)})]})]})}function sm({section:t,highlightQuery:n=""}){const{t:o,convert:r}=Y(),s=Et(),l=d=>d?ot(r(d),u=>n?gn(u,n,s):u,{t:o}):"",[a,p]=h.useState(!1),c=!!t.content;return e.jsxs("div",{style:{padding:"12px 0 6px"},children:[e.jsxs(yo,{enabled:c,expanded:a,onClick:()=>p(!a),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[e.jsx(om,{type:t.type}),e.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:l(t.title)}),c&&e.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),transition:"transform 0.15s",transform:a?"rotate(90deg)":"none",display:"inline-block"},children:"▶"})]}),a&&c&&e.jsx("div",{style:{marginTop:"8px",padding:"10px 14px",borderLeft:`3px solid color-mix(in srgb, ${fo[st(t.type)]||i("desc-fg")} 25%, transparent)`,borderRadius:"0 4px 4px 0",background:i("bg")},children:e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:l(t.content)})})]})}const lm=100;function jo(t){return st(t.type)!=="page_header"?!1:(t.content||"").length>=lm}function am({section:t,highlightQuery:n=""}){const{t:o,convert:r,messages:s}=Y(),l=Et();if(st(t.type)==="page_header"&&!jo(t)||!t.content&&!t.title)return null;const a=r((t.content||t.title||"").replace(/\n{2,}/g,`
1103
+ `)),p=ot(a,g=>n?gn(g,n,l):g,{t:o}),c=st(t.type),d=fo[c]||i("desc-fg"),u=c==="序"||c==="结语"||c==="注释";return e.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 ${d}40`:void 0,background:u?i("bg"):void 0,borderRadius:u?"0 4px 4px 0":void 0,position:"relative"},children:[u&&e.jsx("span",{style:{display:"inline-block",fontSize:"10px",fontWeight:500,color:d,marginRight:"8px",padding:"1px 5px",border:`1px solid ${d}40`,borderRadius:"2px",background:`${d}08`,verticalAlign:"middle"},children:bo(s,c,r)}),p]})}function cm(t,n,o){const[r,s]=h.useState({});return h.useEffect(()=>{var d;if(!n||t.length===0)return;let l=!1;const a=t.filter(u=>{var g;return!((g=o==null?void 0:o.current)!=null&&g.has(u))}),p={};for(const u of t)(d=o==null?void 0:o.current)!=null&&d.has(u)&&(p[u]=o.current.get(u));if(Object.keys(p).length>0&&s(p),a.length===0)return;const c=async u=>{var g;try{if(n.getEntry){const b=await n.getEntry(u);if(b)return{title:b.title,author:b.author}}const m=await n.getItem(u);if(!m)return null;const x=m.title||u,f=m.authors,k=(g=f==null?void 0:f[0])==null?void 0:g.name;return{title:x,author:k}}catch{return null}};return Promise.all(a.map(async u=>{var m;const g=await c(u);return(m=o==null?void 0:o.current)==null||m.set(u,g),[u,g]})).then(u=>{l||s(g=>{const m={...g};for(const[x,f]of u)m[x]=f;return m})}),()=>{l=!0}},[t.join(","),n]),r}function dm({section:t,onNavigate:n,transport:o,workLabelCache:r,highlightQuery:s=""}){const{t:l,convert:a,messages:p}=Y(),c=Ye(),d=Et(),u=S=>S?ot(a(S),v=>s?gn(v,s,d):v,{t:l}):"",[g,m]=h.useState(!1);h.useEffect(()=>{s&&m(!0)},[s]);const x=st(t.type),f=tm[x]||i("desc-fg"),k=!!t.content,b=t.work_ids||[],w=b.length>1,y=cm(w?b:[],o,r),j=k&&!g&&t.content.length>80?$l(t.content,80)+"……":null;return e.jsxs("div",{style:{borderBottom:`1px solid ${i("widget-border")}`,padding:"10px 0"},children:[e.jsxs("div",{onClick:()=>k&&m(!g),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:k?"pointer":"default",userSelect:"none"},children:[e.jsxs(yo,{enabled:k,expanded:g,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[k&&e.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:g?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsxs("span",{style:{display:"block",flex:1},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg"),lineHeight:1.6},children:t.header_line?u(t.header_line):u(t.title)}),!g&&j&&e.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:i("desc-fg"),lineHeight:1.7},children:u(j)})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[b.length===1&&n&&e.jsx("a",{href:c(b[0]),onClick:S=>{S.metaKey||S.ctrlKey||(S.preventDefault(),S.stopPropagation(),n(b[0]))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:l("collated.viewWork"),children:l("collated.arrowWork")}),w&&e.jsx("span",{style:{fontSize:"11px",color:i("link-fg"),flexShrink:0},children:l("collated.nWorks",{n:b.length})}),e.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:f,border:`1px solid ${f}40`,borderRadius:"2px",background:`${f}08`},children:bo(p,x,a)})]})]}),w&&n&&e.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:b.map(S=>{const v=y[S],$=v?`${a(v.title)}${v.author?`(${a(v.author)})`:""}`:S.slice(0,8)+"…";return e.jsxs("a",{href:c(S),onClick:C=>{C.metaKey||C.ctrlKey||(C.preventDefault(),C.stopPropagation(),n(S))},style:{fontSize:"12px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:S,children:["→",$]},S)})}),g&&k&&e.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${f}40`,borderRadius:"0 4px 4px 0",background:i("bg")},children:[e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(t.content)}),t.comment&&e.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(t.comment)})]})]})}function pm({juan:t,searchQuery:n,onNavigate:o,transport:r,workLabelCache:s}){const{t:l}=Y(),a=Et(),p=n.trim(),c=h.useMemo(()=>p?t.sections.filter(d=>xo(d,p,!0,a)):t.sections,[t.sections,p,a]);return e.jsxs("div",{children:[e.jsx("div",{children:c.map((d,u)=>e.jsx(dm,{section:d,onNavigate:o,transport:r,workLabelCache:s,highlightQuery:p},u))}),c.length===0&&e.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:l("collated.noMatch")})]})}function um(){let t=!1;return n=>n==="类"?(t=!0,"h2"):t?"h3":"h2"}function mm({sections:t,onNavigate:n,inline:o,workLinks:r=!0}){const s=Ye(),{t:l,convert:a}=Y(),p=um();return e.jsx(e.Fragment,{children:t.map((c,d)=>{const u=st(c.type);if(u==="page_header"&&!jo(c))return null;if(u==="类")return e.jsxs(h.Fragment,{children:[h.createElement(p("类"),null,o(a(c.title))),c.content&&e.jsx("p",{children:o(a(c.content))})]},d);if(u==="书"||u==="诗"||u==="考证"||u==="注释"){const g=c.book_title?`《${c.book_title}》${c.n_juan!=null?l("collated.nJuan",{n:ho(c.n_juan)}):""}`:c.title,m=o(a(g));return e.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${d}`,children:[h.createElement(p("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&r?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:s(c.work_id),onClick:x=>{x.metaKey||x.ctrlKey||(x.preventDefault(),n(c.work_id))},title:l("collated.viewWork"),children:m}),e.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:x=>{x.metaKey||x.ctrlKey||(x.preventDefault(),n(c.work_id))},"aria-label":l("collated.viewWorkOf",{title:a(g)}),children:l("collated.workArrow")})]}):m),c.author_info&&e.jsx("p",{className:"bim-rd-sub",children:o(a(c.author_info))}),c.content&&c.content.split(/\n+/).map((x,f)=>e.jsx("p",{children:o(a(x))},f)),c.summary&&e.jsxs("p",{children:[e.jsx("span",{className:"bim-rd-lbl",children:l("collated.summary")}),o(a(c.summary))]}),c.comment&&e.jsxs("p",{children:[e.jsx("span",{className:"bim-rd-lbl",children:l("collated.comment")}),o(a(c.comment))]}),c.additional_comment&&e.jsxs("p",{children:[e.jsx("span",{className:"bim-rd-lbl",children:l("collated.additionalComment")}),o(a(c.additional_comment))]})]},d)}return c.content?e.jsx("p",{children:o(a(c.content))},d):null})})}function Ol(t){return t.some(n=>{const o=st(n.type);return o==="书"||o==="诗"||o==="考证"||o==="注释"||o==="类"||(o==="序"||o==="结语")&&!!n.content||o==="page_header"&&jo(n)})}function gm({juan:t,rawText:n,positionLabel:o,groupLabel:r,index:s,searchQuery:l,onNavigate:a,transport:p,workLabelCache:c,prefs:d,view:u,onViewChange:g}){var q;const{t:m,convert:x,messages:f}=Y(),k=Et(),[b,w]=h.useState("text"),y=u??b,j=Q=>{w(Q),g==null||g(Q)},S=l.trim(),v=(s==null?void 0:s.type)==="kaozhen",$=h.useCallback(Q=>S?gn(Q,S,k):Q,[S,k]),C=Q=>mo(Q,{renderText:$,properNames:d.properNames,t:m}),z=h.useMemo(()=>S?t.sections.filter(Q=>xo(Q,S,v,k)):t.sections,[t.sections,S,v,k]),E=(Q,oe)=>oe.filter(je=>st(je.type)===Q).length,T=E("书",t.sections),_=E("诗",t.sections),O=E("考证",t.sections);let W="";v?W=S?m("collated.countTiaoOf",{m:E("考证",z),n:O}):m("collated.countTiao",{n:O}):_>0?W=S?m("collated.countPoemsOf",{m:E("诗",z),n:_}):m("collated.countPoems",{n:_}):T>0&&(W=S?m("collated.countBooksOf",{m:E("书",z),n:T}):m("collated.countBooks",{n:T}));const A=s!=null&&s.text_quality?Uu(s.text_quality.grade):null,G=[];W&&G.push(W),v&&(s!=null&&s.target_source)&&G.push(e.jsx(e.Fragment,{children:m("collated.kaozhenTarget",{target:x(s.target_source)})})),A&&G.push(e.jsx("span",{title:f.collated.qualityCriteria[A],children:(q=s==null?void 0:s.text_quality)!=null&&q.source_note?e.jsxs(e.Fragment,{children:[Yu(m("collated.baseText",{note:Wl}),s.text_quality.source_note,x),e.jsx("span",{className:"bim-rd-grade",children:f.collated.qualityLabel[A]})]}):e.jsxs(e.Fragment,{children:[m("collated.textQuality"),e.jsx("span",{className:"bim-rd-grade",children:f.collated.qualityLabel[A]})]})})),t.source_url&&G.push(e.jsx("a",{className:"bim-rd-link",href:t.source_url,target:"_blank",rel:"noopener noreferrer",children:m("collated.originalSource")}));const V=!v&&Ol(t.sections),ie=!!n&&(!V||d.readingMode==="paragraph"&&Tn(n)),ae=!v&&(V||!!n),P=v||!ae?"entries":y;let I=0;return e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[(o||r)&&e.jsxs("p",{className:"bim-rd-kicker",children:[o,o&&r&&e.jsx("span",{className:"bim-rd-dot"}),r&&x(r)]}),e.jsx("h1",{className:"bim-rd-h1",children:x(t.title)}),G.length>0&&e.jsx("p",{className:"bim-rd-meta",children:G.map((Q,oe)=>e.jsxs(h.Fragment,{children:[oe>0&&e.jsx("span",{className:"bim-rd-dot"}),Q]},oe))}),ae&&t.sections.length>0&&e.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":m("collated.viewsGroup"),children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":P==="text",onClick:()=>j("text"),children:m("collated.viewText")}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":P==="entries",onClick:()=>j("entries"),children:m("collated.viewEntries")})]})]}),P==="text"&&e.jsx("article",{className:"bim-rd-prose",children:ie?e.jsx(go,{text:n,mode:d.readingMode,properNames:d.properNames,renderText:$,dropTitle:t.title}):e.jsx(mm,{sections:t.sections,onNavigate:a,inline:C,workLinks:d.workLinks})}),P==="entries"&&e.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:v?e.jsx(pm,{juan:t,searchQuery:l,onNavigate:a,transport:p,workLabelCache:c}):e.jsxs(e.Fragment,{children:[z.some(Q=>["书","诗","考证"].includes(st(Q.type)))&&e.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[e.jsx("span",{style:{width:28},children:m("collated.rowHeadNo")}),e.jsx("span",{style:{flex:1},children:m("collated.rowHeadTitle")}),e.jsx("span",{children:m("collated.rowHeadWork")})]}),z.map((Q,oe)=>{const je=st(Q.type);return je==="书"||je==="诗"||je==="考证"?(I+=1,e.jsx(rm,{domId:`rd-e-${t.sections.indexOf(Q)}`,section:Q,onNavigate:d.workLinks?a:void 0,highlightQuery:S,no:I,showUnlinked:d.workLinks&&!!a},oe)):je==="类"?e.jsx(sm,{section:Q,highlightQuery:S},oe):e.jsx(am,{section:Q,highlightQuery:S},oe)}),z.length===0&&e.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:m("collated.noMatch")})]})})]})}function hm(t){const{resetKey:n,load:o,files:r,activeFile:s,activeJuan:l,activeRawText:a,query:p,isKaozhen:c}=t,d=Et(),u=h.useRef(new Map),[g,m]=h.useState({}),[x,f]=h.useState({}),k=h.useCallback((w,y)=>{const j=y==null?void 0:y.title;j&&f(S=>S[w]===j?S:{...S,[w]:j})},[]);h.useEffect(()=>{s&&l&&(u.current.set(s,{juan:l,rawText:a}),k(s,l))},[s,l,a,k]),h.useEffect(()=>{u.current.clear(),m({}),f({})},[n]);const b=h.useCallback((w,y)=>{let j=0;if(w.juan)for(const S of w.juan.sections)xo(S,y,c,d)&&j++;return j===0&&w.rawText&&em(w.rawText,y,d)&&(j=1),j},[c,d]);return h.useEffect(()=>{const w=p.trim();if(!w){m({});return}if(!o||r.length===0)return;let y=!1;const j={},S=[];for(const E of r){const T=u.current.get(E);T?j[E]=b(T,w):(j[E]="loading",S.push(E))}m(j);const v=8;let $=0;const C=async()=>{for(;$<S.length;){if(y)return;const E=$++,T=S[E];try{const _=await o(T),O=_.juan;if(u.current.set(T,_),k(T,O),y)return;m(W=>({...W,[T]:b(_,w)}))}catch{if(y)return;m(_=>({..._,[T]:0}))}}},z=Array.from({length:Math.min(v,S.length)},()=>C());return Promise.all(z),()=>{y=!0}},[p,n,o,r.join(","),b,d,k]),{matchStates:g,titles:x}}function xm({juan:t,view:n,onView:o,textHasEntries:r}){const{t:s,convert:l}=Y(),a=t.sections.map((u,g)=>({s:u,i:g,t:st(u.type)})).filter(u=>u.t==="书"||u.t==="诗");if(a.length===0)return null;const p=a.filter(u=>!!u.s.work_id).length,c=a.every(u=>u.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),d=u=>{const g=()=>{var m,x;return(x=(m=document.getElementById(`rd-e-${u}`))==null?void 0:m.scrollIntoView)==null?void 0:x.call(m,{block:"start",behavior:"smooth"})};n==="text"&&!r&&o("entries"),n==="text"&&!r?setTimeout(g,0):g()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bim-rd-rail-card",children:[e.jsx("div",{className:"bim-rd-rail-cap",children:s("collated.railCap")}),e.jsxs("div",{className:"bim-rd-rail-n",children:[e.jsx("b",{children:a.length}),e.jsx("span",{children:c}),e.jsx("span",{className:"bim-rd-rail-linked",children:s("collated.linkedN",{n:p})})]}),e.jsx("div",{className:"bim-rd-rail-bar",role:"img","aria-label":s("collated.linkedOf",{n:p,total:a.length}),children:e.jsx("span",{style:{width:`${Math.round(p/a.length*100)}%`}})})]}),e.jsxs("nav",{"aria-label":s("collated.railEntriesNav"),children:[e.jsx("div",{className:"bim-rd-rail-cap",style:{margin:"20px 0 6px 12px"},children:s("collated.viewEntries")}),e.jsx("ul",{className:"bim-rd-rail-list",children:a.map(({s:u,i:g})=>e.jsx("li",{children:e.jsxs("a",{href:`#rd-e-${g}`,onClick:m=>{m.preventDefault(),d(g)},children:[e.jsx("span",{className:`bim-rd-rail-dot${u.work_id?" on":""}`,"aria-hidden":"true"}),e.jsx("span",{children:l(u.book_title||u.title)})]})},g))})]})]})}const wr={padding:24,color:i("desc-fg"),fontSize:14};function Sr({title:t,label:n,className:o,style:r}){const s=(l,a=14,p=14)=>({width:l,height:a,marginTop:p,borderRadius:3,background:i("rule")});return e.jsxs("div",{className:o,style:{...r,padding:"20px 24px",maxWidth:760,margin:"0 auto"},"aria-busy":"true",children:[t&&e.jsx("div",{style:{fontSize:15,color:i("ink"),fontFamily:i("font-ui")},children:t}),e.jsx("div",{style:s("42%",24,28)}),e.jsx("div",{style:s("30%",12,10)}),["96%","100%","92%","98%","64%"].map((l,a)=>e.jsx("div",{style:s(l,16,a===0?30:14)},a)),e.jsx("p",{role:"status",style:{marginTop:24,color:i("desc-fg"),fontSize:14,fontFamily:i("font-ui")},children:n})]})}const $r=/^https?:\/\//i;function fm(t){if(!t||typeof t!="object")return null;const n=l=>typeof l=="string"&&l.trim()?l.trim():void 0,o=n(t.url),r=n(t.license_url),s={name:n(t.name),url:o&&$r.test(o)?o:void 0,license:n(t.license),license_url:r&&$r.test(r)?r:void 0,note:n(t.note)};return s.name||s.license||s.note?s:null}function bm(t,n){return{work_id:n.work_id??t,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 ym(t,n){return(n==null?void 0:n.type)==="kaozhen"?"章":n!=null&&n.juan_metadata&&Object.values(n.juan_metadata).some(o=>o.vol_label)?"冊":(t==null?void 0:t.kind)==="collated"?"卷":"章"}function Fl(t,n,o,r=!1){const s=o(`${n}${t.n}`);if(!t.title)return s;const l=o(t.title);return r&&!/^[卷冊册章篇回第]/.test(t.title)?`${s} ${l}`:l}function jm(t,n,o,r,s){var d;const l=new Map(t.chapters.map(u=>[u.file,u])),a=u=>u==="loading"?"…":typeof u=="number"&&u>0?u:void 0,p=(u,g)=>{const m=l.get(u);return{key:u,label:g??(m?Fl(m,o,r,s):u),hint:a(n[u]),disabled:n[u]===0}},c=(d=t.juan_groups)==null?void 0:d.filter(u=>{var g;return u.files.some(m=>l.has(m))||((g=u.children)==null?void 0:g.length)});if(c&&c.length>0){const u=(g,m)=>{var f;if(g.files.length===1&&!((f=g.children)!=null&&f.length))return p(g.files[0],r(g.label));const x=nm(g,n);return{key:`group:${m}`,label:r(g.label),hint:x==="loading"?"…":typeof x=="number"&&x>0?`${x}`:Hl(g),defaultExpanded:typeof x=="number"&&x>0,children:[...g.files.filter(k=>l.has(k)).map(k=>p(k)),...(g.children??[]).map((k,b)=>u(k,`${m}.${b}`))]}};return c.map((g,m)=>u(g,`${m}`))}return t.chapters.map(u=>p(u.file))}const vo=({id:t,transport:n,versionKey:o,chapter:r,onLocationChange:s,onNavigate:l,title:a,subtitle:p,resolveImages:c,renderImageOverlay:d,imagePanel:u,allowVertical:g,onReportError:m,revisedAt:x,backHref:f,backLabel:k,className:b,style:w})=>{var Ve,Be,lt;const{t:y,convert:j}=Y(),S=h.useMemo(()=>Ks(n),[n]),[v,$]=il(),C=Ye(),z=h.useRef(s);z.current=s;const[E,T]=h.useState(null),[_,O]=h.useState("loading");h.useEffect(()=>{let ne=!1;return T(null),O("loading"),S.getManifest(t).then(We=>{ne||(We?(T(We),O("ready")):O("missing"))}).catch(()=>{ne||O("missing")}),()=>{ne=!0}},[S,t]);const W=o!==void 0,A=r!==void 0,[G,V]=h.useState(null),[ie,ae]=h.useState(null);h.useEffect(()=>{V(null),ae(null)},[t]);const P=be.pickTextVersion(E,W?o:G),I=((Ve=E==null?void 0:E.versions.find(ne=>ne.key==="default"))==null?void 0:Ve.key)??((Be=E==null?void 0:E.versions[0])==null?void 0:Be.key)??"default",q=(P==null?void 0:P.key)??null,Q=A?r:ie,oe=h.useCallback((ne,We,Xe)=>{var wt;(wt=z.current)==null||wt.call(z,{key:ne,chapter:We,isDefault:ne===I},Xe)},[I]);h.useEffect(()=>{!E||!W||o==null||E.versions.some(ne=>ne.key===o)||oe(I,null,"auto")},[E,W,o,I,oe]);const je=h.useRef(new Map);h.useEffect(()=>{je.current.clear()},[S,t]);const Ie=h.useCallback(async ne=>{const We=`${t}
1104
+ ${ne}`;if(je.current.has(We))return je.current.get(We)??null;const Xe=await S.getIndex(t,ne).catch(()=>null);return Xe&&je.current.set(We,Xe),Xe},[S,t]),[K,me]=h.useState(null),[M,ue]=h.useState("loading");h.useEffect(()=>{if(!q)return;let ne=!1;return me(null),ue("loading"),Ie(q).then(We=>{ne||(We&&We.chapters.length>0?(me(We),ue("ready")):ue("failed"))}),()=>{ne=!0}},[q,Ie]),h.useEffect(()=>{if(!K||!q||Q!=null&&K.chapters.some(Xe=>Xe.file===Q))return;const We=K.chapters[0].file;A||ae(We),oe(q,We,"auto")},[K,q,Q,A,oe]);const ge=K?Q!=null&&K.chapters.some(ne=>ne.file===Q)?Q:K.chapters[0].file:Q,de=h.useMemo(()=>K&&ge?K.chapters.find(ne=>ne.file===ge)??null:null,[K,ge]),Le=h.useRef(0),Me=h.useCallback(async ne=>{if(!E||ne===q||!E.versions.some(fn=>fn.key===ne))return;const We=++Le.current,Xe=await Ie(ne);if(We!==Le.current)return;const wt=de??(ge?{file:ge}:null),Yt=be.matchChapterAcrossVersions(wt,Xe);W||V(ne),A||ae(Yt),oe(ne,Yt,"version")},[E,q,Ie,de,ge,W,A,oe]),Ee=h.useCallback(ne=>{q&&(A||ae(ne),oe(q,ne,"chapter"))},[q,A,oe]),[ze,He]=h.useState(null),D=q&&de?`${t}
1105
+ ${q}
1106
+ ${de.file}`:null,[re,ce]=h.useState(null),we=D!==null&&re!==D,F=h.useRef(0);h.useEffect(()=>{if(!q||!de)return;const ne=++F.current,We=`${t}
1107
+ ${q}
1108
+ ${de.file}`;He(null),S.getChapter(t,q,de.file,{json:!!de.has_json}).then(Xe=>{ne===F.current&&He(Xe)}).catch(()=>{ne===F.current&&He(null)}).finally(()=>{ne===F.current&&ce(We)})},[S,t,q,de]);const fe=(P==null?void 0:P.kind)==="collated",[Re,R]=h.useState("");h.useEffect(()=>{R("")},[t,q]);const ee=h.useMemo(()=>q&&fe?async ne=>{const We=await S.getChapter(t,q,ne,{json:!0});return{juan:(We==null?void 0:We.json)??null,rawText:(We==null?void 0:We.md)??null}}:null,[S,t,q,fe]),he=(K==null?void 0:K.type)==="kaozhen",L=h.useMemo(()=>(K==null?void 0:K.chapters.map(ne=>ne.file))??[],[K]),{matchStates:X}=hm({resetKey:`${t}
1109
+ ${q??""}`,load:ee,files:L,activeFile:ge??null,activeJuan:(ze==null?void 0:ze.json)??null,activeRawText:(ze==null?void 0:ze.md)??null,query:Re,isKaozhen:he}),U=h.useRef(new Map);h.useEffect(()=>{U.current.clear()},[t]);const se=Du(c,ge??null),{entryTitle:Se,authors:Pe}=wm(t,n,a===void 0),[$e,Fe]=h.useState("text");if(h.useEffect(()=>{Fe("text")},[ge,q]),_==="loading")return e.jsx(Sr,{className:b,style:w,title:a??Se,label:y("reader.loading")});if(_==="missing"||!E||!P)return e.jsx("div",{className:b,style:{...w,...wr},children:y("reader.noText")});if(M==="failed")return e.jsx("div",{className:b,style:{...w,...wr},children:y("reader.tocFailed")});if(!K)return e.jsx(Sr,{className:b,style:w,title:a??Se,label:y("reader.tocLoading")});const De=ym(P,K),Z=jm(K,X,De,j,fe),Ae=E.versions.map(ne=>({key:ne.key,label:be.textVersionLabel(ne),optionLabel:j(be.textVersionLabel(ne)),sourceName:ne.source_name?j(ne.source_name):void 0,license:ne.license??void 0,sourceUrl:ne.source_url??void 0,primary:ne.key===I})),N=fm((lt=K.source)==null?void 0:lt.upstream),J=(typeof a=="string"?j(a):a)??(K.title?j(K.title):Se?j(Se):void 0),le=J?e.jsx("a",{href:C(t),title:y("reader.viewEntry"),onClick:l?ne=>{ne.metaKey||ne.ctrlKey||(ne.preventDefault(),l(t))}:void 0,children:J}):void 0,te=Pe.length>0?j(Pe.slice(0,2).map(ne=>`${ne.dynasty?`〔${ne.dynasty}〕`:""}${ne.name}${` ${ne.role||y("reader.defaultRole")}`}`).join("、")):void 0,pe=de?Fl(de,De,j,fe):void 0,_e=fe&&!!(ze!=null&&ze.json),H=(ze==null?void 0:ze.json)??null,B=(ze==null?void 0:ze.md)??null,ye=_e&&!he&&Ol(H.sections),Ce=ye&&!(B&&v.readingMode==="paragraph"&&Tn(B)),ve=_e&&ye?e.jsx(xm,{juan:H,view:$e,onView:Fe,textHasEntries:Ce}):void 0,xe=Vs(K)||ji(K),Oe=B?B.replace(/^##\s+[^\n]+\n+/,""):null,Te=(typeof p=="string"?j(p):p)??(P.source_name?j(P.source_name):j(be.textVersionLabel(P)));return e.jsxs(sl,{className:b,style:w,title:le,subtitle:Te,byline:te,current:pe,pagerUnit:De,rail:ve,revisedAt:x,backHref:f,backLabel:k,onReportError:m?ne=>m({...ne,bookTitle:typeof J=="string"?J:void 0,entryId:t}):void 0,workLinkToggle:_e&&!he&&!!l&&!!(H!=null&&H.sections.some(ne=>ne.work_id)),toc:Z,tocCaption:y("reader.tocCaption",{n:K.chapters.length,unit:j(De)}),tocHeader:fe&&K.chapters.length>1?e.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:he?y("reader.searchChaptersPlaceholder"):y("reader.searchUnitPlaceholder",{unit:j(De)}),"aria-label":he?y("reader.searchChapters"):y("reader.searchUnit",{unit:j(De)}),value:Re,onChange:ne=>R(ne.target.value)}):void 0,activeKey:ge??null,onSelect:Ee,images:se.images,imagesLoading:se.loading,renderImageOverlay:d,imagePanel:u,prefs:v,onPrefsChange:$,versions:Ae.length>1?Ae:void 0,currentVersionKey:Ae.length>1?P.key:void 0,onVersionChange:Me,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:Tn(B),allowVertical:g,children:[we&&e.jsx(Rt,{}),!we&&_e&&H&&e.jsx(gm,{juan:H,rawText:B,positionLabel:vm(de,K,De,j),groupLabel:km(K,ge??null),index:bm(t,K),searchQuery:Re,onNavigate:l,transport:n,workLabelCache:U,prefs:v,view:$e,onViewChange:Fe},`${q}/${ge}`),!we&&!_e&&Oe!=null&&de&&e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[e.jsx("h1",{className:"bim-rd-h1",children:de.title?j(de.title):pe}),(P.source_name||P.license)&&e.jsxs("p",{className:"bim-rd-meta",children:[P.source_name&&e.jsxs(e.Fragment,{children:[y("reader.textSource")," ",P.source_url?e.jsx("a",{className:"bim-rd-link",href:P.source_url,target:"_blank",rel:"noreferrer",children:j(P.source_name)}):j(P.source_name)]}),P.source_name&&P.license&&e.jsx("span",{className:"bim-rd-dot"}),P.license]}),N&&e.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[y("reader.upstream")," ",N.url?e.jsx("a",{className:"bim-rd-link",href:N.url,target:"_blank",rel:"noreferrer",children:j(N.name??N.url)}):j(N.name??""),N.license&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot"}),N.license_url?e.jsx("a",{className:"bim-rd-link",href:N.license_url,target:"_blank",rel:"noreferrer",children:N.license}):N.license]}),N.note&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot"}),e.jsx(qs,{text:N.note,convert:j})]})]})]}),e.jsx("article",{className:"bim-rd-prose",children:e.jsx(go,{text:Oe,mode:v.readingMode,tables:xe,gujiMarkdown:ji(K),properNames:v.properNames})})]}),!we&&!_e&&Oe==null&&de&&e.jsx("div",{className:"bim-rd-state",children:y("reader.chapterFailed")}),K.references&&K.references.length>0&&e.jsxs("section",{className:"bim-rd-refs",children:[e.jsx("h2",{children:y("reader.references")}),e.jsx("ol",{children:K.references.map((ne,We)=>e.jsxs("li",{children:[ne.url?e.jsx("a",{className:"bim-rd-link",href:ne.url,target:"_blank",rel:"noopener noreferrer",children:j(ne.title)}):e.jsx("span",{children:j(ne.title)}),ne.author&&e.jsxs("span",{children:[",",j(ne.author)]}),ne.note&&e.jsxs("span",{children:["。",j(ne.note)]})]},We))})]})]})};function vm(t,n,o,r){var l,a;if(!t)return;const s=(a=(l=n.juan_metadata)==null?void 0:l[t.file])==null?void 0:a.vol_label;return r(s?`${s}冊`:`${o}${t.n}`)}function km(t,n){if(!n)return;const o=r=>{var s;for(const l of r??[]){const a=o(l.children);if(a)return a;if((s=l.files)!=null&&s.includes(n))return l.label}};return o(t.juan_groups)}function wm(t,n,o){const[r,s]=h.useState({entryTitle:void 0,authors:[]});return h.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let l=!1;return Promise.resolve(n.getItem(t)).then(a=>{if(l||!a)return;const p=(a.authors??[]).filter(c=>c&&c.name);s({entryTitle:o&&typeof a.title=="string"?a.title:void 0,authors:p})}).catch(()=>{}),()=>{l=!0}},[t,n,o]),r}const Dl={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")}},Sm=Dl.other,Ul={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")}},$m=Ul.pending;function _m(t){try{const n=new Date(t),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 t}}function Cm(t,n){if(!t)return!1;try{const o=new URL(t,n);if(o.protocol!=="http:"&&o.protocol!=="https:")return!1;const r=new URL(n);return o.hostname===r.hostname}catch{return!1}}const ko=({items:t,loading:n})=>{const o=Ye(),{t:r,convert:s}=Y();return n?e.jsx(Rt,{}):t.length===0?e.jsx("div",{style:zm,children:r("feedback.empty")}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:t.map(l=>{const a=Dl[l.type]||Sm,p=Ul[l.status]||$m,c=typeof window<"u"&&Cm(l.pageUrl,window.location.href);return e.jsxs("div",{style:Tm,children:[e.jsxs("div",{style:Nm,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{..._r,background:a.color},children:r(`feedback.listType.${a.key}`)}),e.jsx("span",{style:{..._r,background:p.color},children:r(`feedback.status.${p.key}`)})]}),e.jsx("span",{style:Im,children:_m(l.createdAt)})]}),(l.resourceId||l.pageUrl)&&e.jsxs("div",{style:Rm,children:[l.resourceId&&e.jsx("a",{href:o(l.resourceId),style:ci,children:l.resourceId}),l.pageUrl&&!l.resourceId&&(c?e.jsx("a",{href:l.pageUrl,style:ci,children:l.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):e.jsx("span",{style:ci,children:l.pageUrl}))]}),e.jsx("div",{style:Em,children:s(l.content)}),l.reply&&e.jsxs("div",{style:Lm,children:[e.jsx("div",{style:Pm,children:r("feedback.reply")}),e.jsx("div",{children:s(l.reply)})]})]},l.id)})})},zm={textAlign:"center",padding:"40px 0",color:i("desc-fg"),fontSize:"14px"},Tm={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"16px"},Nm={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},_r={fontSize:"12px",color:i("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},Im={fontSize:"12px",color:i("desc-fg")},Rm={fontSize:"12px",marginBottom:"6px"},ci={color:i("primary"),textDecoration:"none",borderBottom:`1px dashed ${i("primary")}`},Em={fontSize:"14px",lineHeight:"1.6",color:i("fg"),whiteSpace:"pre-wrap"},Lm={marginTop:"12px",padding:"10px 12px",background:i("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:i("fg")},Pm={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:i("primary")},Ii=({transport:t,onNavigate:n,recommendedIds:o,activeTab:r,onTabChange:s,feedbackApiUrl:l})=>{const a=ke(),[p,c]=h.useState(null),[d,u]=h.useState([]),[g,m]=h.useState("recommend"),[x,f]=h.useState([]),[k,b]=h.useState(!1),w=r??g,y=G=>{m(G),s==null||s(G)},[j,S]=h.useState(!0),[v,$]=h.useState(null),[C,z]=h.useState(null),[E,T]=h.useState(null);h.useEffect(()=>{let G=!1;if(t.getCounts)return t.getCounts().then(V=>{G||c({works:V.works,books:V.books,collections:V.collections})}).catch(()=>{}),()=>{G=!0}},[t]),h.useEffect(()=>{let G=!1;return(async()=>{if(o)return o;if(t.getRecommended)try{const ie=await t.getRecommended();if(ie!=null&&ie.groups)return ie.groups.flatMap(ae=>ae.items.map(P=>({...P,group:ae.name})))}catch{}return[]})().then(async ie=>{if(G)return;const ae=ie.filter(I=>I.id);if(ae.length===0){S(!1);return}const P=await Promise.all(ae.map(async I=>{if(I.type)return{id:I.id,title:I.title,type:I.type,author:I.author,dynasty:I.dynasty,role:I.role,edition:I.edition,has_text:I.has_text,has_image:I.has_image,has_collated:I.has_collated,subtype:I.subtype,primary_name:I.primary_name,group:I.group,fallbackDescription:I.description};try{let q=null;if(t.getEntry)q=await t.getEntry(I.id);else{const Q=await t.getItem(I.id);Q&&(q={id:I.id,title:Q.title||I.id,type:Q.type||"work"})}if(q)return{...q,group:I.group,fallbackDescription:I.description}}catch{}return{id:I.id,title:I.title,type:be.extractType(I.id),group:I.group,fallbackDescription:I.description}}));G||(u(P.filter(I=>I!==null)),S(!1))}),()=>{G=!0}},[t,o]);const _=h.useRef(!1),O=h.useRef(!1),W=h.useRef(!1);h.useEffect(()=>{if(w!=="catalog"||_.current)return;const G=t.getCatalogProgress??t.getResourceProgress;if(!G)return;_.current=!0;let V=!1;return G.call(t).then(ie=>{V||$(ie)}).catch(()=>{_.current=!1}),()=>{V=!0}},[t,w]),h.useEffect(()=>{if(w!=="collection"||O.current||!t.getCollectionProgress)return;O.current=!0;let G=!1;return t.getCollectionProgress().then(V=>{G||z(V)}).catch(()=>{O.current=!1}),()=>{G=!0}},[t,w]),h.useEffect(()=>{if(w!=="site"||W.current||!t.getSiteProgress)return;W.current=!0;let G=!1;return t.getSiteProgress().then(V=>{G||T(V)}).catch(()=>{W.current=!1}),()=>{G=!0}},[t,w]),h.useEffect(()=>{if(!l||w!=="feedback")return;let G=!1;return b(!0),fetch(l).then(V=>V.json()).then(V=>{!G&&V.success&&f(V.items||[])}).catch(()=>{}).finally(()=>{G||b(!1)}),()=>{G=!0}},[l,w]);const A=G=>e.jsx(Gt,{type:G,size:12});return e.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:i("fg")},children:e.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[e.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"16px"},children:[e.jsx(Xt,{label:a.home.recommendTab,active:w==="recommend",onClick:()=>y("recommend")}),e.jsx(Xt,{label:a.home.catalogTab,active:w==="catalog",onClick:()=>y("catalog")}),e.jsx(Xt,{label:a.home.collectionTab,active:w==="collection",onClick:()=>y("collection")}),e.jsx(Xt,{label:a.home.siteTab,active:w==="site",onClick:()=>y("site")}),l&&e.jsx(Xt,{label:a.home.feedbackTab,active:w==="feedback",onClick:()=>y("feedback")})]}),w==="recommend"&&e.jsx(Am,{recommended:d,loading:j,onNavigate:n,getIcon:A,t:a}),w==="catalog"&&e.jsx(Cr,{progress:v,t:a,onNavigate:n}),w==="collection"&&e.jsx(Cr,{progress:C,t:a,onNavigate:n}),w==="site"&&e.jsx(Mm,{progress:E,t:a,totalWorks:(p==null?void 0:p.works)??0}),w==="feedback"&&l&&e.jsx(ko,{items:x,loading:k})]})})},Xt=({label:t,active:n,onClick:o})=>e.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:t}),Am=({recommended:t,loading:n,onNavigate:o,getIcon:r,t:s})=>{const l=Ye();if(n)return e.jsx(Rt,{});if(t.length===0)return null;const a=new Map;for(const p of t){const c=p.group||s.home.recommendedBrowse;a.has(c)||a.set(c,[]),a.get(c).push(p)}return e.jsx(e.Fragment,{children:Array.from(a.entries()).map(([p,c])=>e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:p}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"8px"},children:c.map(d=>{const u=d.dynasty||d.author?`${d.dynasty?`〔${d.dynasty}〕`:""}${d.author||""}`:d.fallbackDescription;return e.jsxs("a",{href:l(d.id),onClick:g=>{g.metaKey||g.ctrlKey||(g.preventDefault(),o==null||o(d.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:[e.jsx("span",{style:{fontSize:"20px"},children:r(d.type)}),e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[d.title,d.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:i("desc-fg"),marginLeft:"4px"},children:d.edition})]}),u&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u})]})]},d.id)})})]},p))})},Cr=({progress:t,t:n,onNavigate:o})=>{if(!t)return e.jsx(Rt,{});const r=[...t.resources].sort((p,c)=>p.priority-c.priority),s=["in_progress","done","todo"],l={in_progress:n.home.statusInProgress,done:n.home.statusDone,todo:n.home.statusTodo},a={in_progress:i("progress-active"),done:i("progress-done"),todo:i("progress-todo")};return e.jsx("div",{children:s.map(p=>{const c=r.filter(d=>d.status===p);return c.length===0?null:e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:a[p]}}),l[p]," (",c.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c.map(d=>e.jsx(Bm,{item:d,t:n,statusColor:a[p],onNavigate:o},d.id))})]},p)})})},Bm=({item:t,t:n,statusColor:o,onNavigate:r})=>{const s=Ye(),l=t.total>0?Math.round(t.imported/t.total*100):0,a=t.type==="catalog"?n.home.typeCatalog:n.home.typeCollection;return e.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(()=>{const p=t.edition?`${t.name}·${t.edition}`:t.name,c=t.collection_id||t.work_id;return c&&r?e.jsx("a",{href:s(c),onClick:d=>{d.metaKey||d.ctrlKey||(d.preventDefault(),r(c))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`},onMouseEnter:d=>d.currentTarget.style.borderBottomStyle="solid",onMouseLeave:d=>d.currentTarget.style.borderBottomStyle="dashed",children:p}):t.url?e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:p}):p})()}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"4px",background:i("widget-border"),color:i("desc-fg"),whiteSpace:"nowrap"},children:t.collection_id?n.indexType.collection:t.work_id?n.indexType.work:a})]}),e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:t.total>0?it(n.home.progressFormat,{imported:String(t.imported),total:String(t.total)}):n.home.totalPending})]}),t.total>0&&e.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:e.jsx("div",{style:{height:"100%",width:`${l}%`,borderRadius:"2px",background:o,transition:"width 0.3s ease"}})}),t.description&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:t.description})]})},Mm=({progress:t,t:n,totalWorks:o})=>{if(!t)return e.jsx(Rt,{});const r=[...t.resources].sort((c,d)=>c.priority-d.priority),s=r.filter(c=>c.imported>0),l=r.filter(c=>c.imported===0),a=s.reduce((c,d)=>Math.max(c,d.imported),0),p=o>0?Math.round(a/o*100):0;return e.jsxs("div",{children:[o>0&&e.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,": ",e.jsx("strong",{children:a.toLocaleString()})," / ",o.toLocaleString()," ",n.indexType.work," (",p,"%)"]}),s.length>0&&e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-done")}}),n.home.statusInProgress," (",s.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(c=>e.jsx(zr,{item:c,t:n,totalWorks:o},c.id))})]}),l.length>0&&e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-todo")}}),n.home.statusTodo," (",l.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:l.map(c=>e.jsx(zr,{item:c,t:n,totalWorks:o},c.id))})]})]})},zr=({item:t,t:n,totalWorks:o})=>{const r=o>0?Math.round(t.imported/o*100):0;return e.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:e.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:t.url?e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:t.name}):t.name})}),e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:t.imported>0?`${t.imported.toLocaleString()} ${n.indexType.work} (${r}%)`:n.home.statusTodo})]}),t.imported>0&&o>0&&e.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:e.jsx("div",{style:{height:"100%",width:`${r}%`,borderRadius:"2px",background:i("progress-done"),transition:"width 0.3s ease"}})}),t.description&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:t.description})]})},Tr="(max-width: 768px)";function Wm(){const[t,n]=h.useState(()=>typeof window>"u"?!1:window.matchMedia(Tr).matches);return h.useEffect(()=>{const o=window.matchMedia(Tr),r=s=>n(s.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[]),t}const Hm=({transport:t,hideModeIndicator:n=!0,onEntryClick:o,recommendedIds:r,headerRight:s})=>{var O;const l=ke(),{convert:a}=Ne(),p=Wm(),[c,d]=h.useState(null),[u,g]=h.useState(null),[m,x]=h.useState(!1),[f,k]=h.useState("detail"),[b,w]=h.useState([]),[y,j]=h.useState(!1),S=h.useCallback(async W=>{if(!t.getCollectionCatalogs&&!t.getCollectionCatalog){w([]);return}j(!0);try{if(t.getCollectionCatalogs){const A=await t.getCollectionCatalogs(W);w(A||[])}else if(t.getCollectionCatalog){const A=await t.getCollectionCatalog(W);w(A?[{resource_id:"",data:A}]:[])}}catch{w([])}finally{j(!1)}},[t]),v=h.useCallback(async W=>{if(o){o(W);return}d(W),g(null),w([]),k("detail"),x(!0);try{const A=await t.getItem(W.id);A&&(g(A),A.type==="collection"&&S(W.id))}catch(A){console.error("加载详情失败:",A)}finally{x(!1)}},[t,o,S]),$=h.useCallback(async W=>{g(null),w([]),k("detail"),x(!0);try{const A=await t.getItem(W);A&&(g(A),d({id:W,title:A.title||W,type:A.type||"book"}),A.type==="collection"&&S(W))}catch(A){console.error("导航失败:",A)}finally{x(!1)}},[t,S]),C=typeof(u==null?void 0:u.text_count)=="number"&&u.text_count>0,z=(u==null?void 0:u.type)==="collection"&&(b.length>0||y)||(u==null?void 0:u.type)==="work"&&C,E=p&&(m||u),T=h.useCallback(()=>{d(null),g(null),w([]),k("detail")},[]),_=e.jsx(e.Fragment,{children:m?e.jsx(Rt,{}):u?e.jsxs(e.Fragment,{children:[(z||s)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${i("widget-border")}`,padding:p?"0 12px":"0 48px",background:i("input-bg"),flexShrink:0,overflowX:p?"auto":void 0},children:[z&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>k("detail"),style:vn(f==="detail"),children:l.detailTab.basicInfo}),u.type==="collection"&&y&&b.length===0&&e.jsxs("button",{onClick:()=>{},style:vn(!1),children:[l.detailTab.catalog,e.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),u.type==="collection"&&b.map(W=>e.jsx("button",{onClick:()=>k(`catalog:${W.resource_id}`),style:vn(f===`catalog:${W.resource_id}`),children:W.short_name?`${a(W.short_name)}${l.detailTab.catalogSuffix}`:l.detailTab.collectionCatalog},W.resource_id)),u.type==="work"&&C&&e.jsx("button",{onClick:()=>k("collated"),style:vn(f==="collated"),children:l.detailTab.collatedEdition})]}),s&&e.jsx("div",{style:{marginLeft:"auto",flexShrink:0,padding:"4px 0"},children:s})]}),e.jsx("div",{style:{padding:p?"16px 12px":"32px 48px",maxWidth:"900px",flex:1,overflow:"auto"},children:f==="detail"?e.jsx(Ki,{data:u,transport:t,onNavigate:$}):f.startsWith("catalog:")?e.jsx(qi,{data:(O=b.find(W=>`catalog:${W.resource_id}`===f))==null?void 0:O.data,onNavigate:$}):f==="collated"?e.jsx(vo,{id:u.id,transport:t,onNavigate:$}):null})]}):e.jsx(Ii,{transport:t,onNavigate:$,recommendedIds:r})});return p?e.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:E?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${i("widget-border")}`,background:i("input-bg"),flexShrink:0},children:e.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:["← ",l.detailTab.basicInfo]})}),e.jsx("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:_})]}):e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[e.jsx(yi,{transport:t,onEntryClick:v,hideModeIndicator:n}),!u&&e.jsx(Ii,{transport:t,onNavigate:$,recommendedIds:r})]})}):e.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:[e.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:`1px solid ${i("widget-border")}`,display:"flex",flexDirection:"column",background:i("input-bg"),overflow:"hidden"},children:e.jsx("div",{style:{flex:1,overflow:"auto"},children:e.jsx(yi,{transport:t,onEntryClick:v,hideModeIndicator:n})})}),e.jsx("div",{style:{flex:1,overflow:"auto",background:i("bg"),display:"flex",flexDirection:"column"},children:_})]})};function vn(t){return{padding:"10px 16px",border:"none",borderBottom:t?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(t?"primary":"desc-fg"),cursor:"pointer",fontSize:"13px",fontWeight:t?600:400}}const Om=({data:t,onNavigate:n,className:o,style:r})=>{var u;const{t:s,convert:l}=Y(),[a,p]=h.useState(((u=t.divisions[0])==null?void 0:u.name)??null),[c,d]=h.useState(null);return e.jsxs("div",{className:o,style:r,children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:l(t.title)}),t.stats&&e.jsxs("div",{style:{fontSize:"13px",color:i("desc-fg"),display:"flex",gap:"16px"},children:[t.total_volumes!=null&&e.jsxs("span",{children:[s("catalog.totalVolumes")," ",e.jsx("strong",{children:t.total_volumes})," ",s("unit.juan")]}),t.stats.zhulu!=null&&e.jsxs("span",{children:[s("catalogPage.zhulu")," ",e.jsx("strong",{children:t.stats.zhulu})," ",s("unit.bu")]}),t.stats.cunmu!=null&&e.jsxs("span",{children:[s("catalogPage.cunmu")," ",e.jsx("strong",{children:t.stats.cunmu})," ",s("unit.bu")]}),t.stats.categories!=null&&e.jsx("span",{children:s("catalogPage.categoriesN",{n:t.stats.categories})})]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.divisions.map(g=>e.jsx(Fm,{division:g,expanded:a===g.name,onToggle:()=>p(a===g.name?null:g.name),expandedCat:c,onCatToggle:m=>d(c===m?null:m),onNavigate:n},g.name))})]})},Fm=({division:t,expanded:n,onToggle:o,expandedCat:r,onCatToggle:s,onNavigate:l})=>{const{t:a,convert:p}=Y(),c=t.categories.reduce((d,u)=>{const g=u.stats||{zhulu:0,cunmu:0};return d+(g.zhulu||0)+(g.cunmu||0)},0);return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[e.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:[e.jsx("span",{children:p(t.name)}),e.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg")},children:[a("catalogPage.divisionStat",{cats:t.categories.length,books:c}),e.jsx("span",{style:{marginLeft:"8px"},children:n?"▲":"▼"})]})]}),n&&e.jsx("div",{style:{padding:"4px 0"},children:t.categories.map(d=>{const u=`${t.name}/${d.name}`;return e.jsx(Dm,{category:d,expanded:r===u,onToggle:()=>s(u),onNavigate:l},d.name)})})]})},Dm=({category:t,expanded:n,onToggle:o,onNavigate:r})=>{var d,u,g,m;const{t:s,convert:l}=Y(),a=((d=t.books)==null?void 0:d.zhulu)||[],p=((u=t.books)==null?void 0:u.cunmu)||[],c=(((g=t.stats)==null?void 0:g.zhulu)||a.length)+(((m=t.stats)==null?void 0:m.cunmu)||p.length);return e.jsxs("div",{children:[e.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:[e.jsxs("span",{style:{fontWeight:500},children:[l(t.name),t.volumes&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:l(t.volumes)})})]}),e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[s("catalogPage.booksN",{n:c})," ",n?"▲":"▼"]})]}),n&&(a.length>0||p.length>0)&&e.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[a.length>0&&e.jsx(Nr,{label:s("catalogPage.zhulu"),books:a,onNavigate:r}),p.length>0&&e.jsx(Nr,{label:s("catalogPage.cunmu"),books:p,onNavigate:r})]})]})},Nr=({label:t,books:n,onNavigate:o})=>{const{t:r,convert:s}=Y(),l=Ye(),[a,p]=h.useState(n.length<=20),c=a?n:n.slice(0,10);return e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:[t," (",n.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((d,u)=>e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[e.jsx("span",{style:{fontWeight:500,color:i("fg")},children:d.work_id&&o?e.jsx("a",{href:l(d.work_id),onClick:g=>{g.metaKey||g.ctrlKey||(g.preventDefault(),o(d.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`},children:s(d.title)}):s(d.title)}),d.volumes&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(d.volumes)}),d.author&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(d.author).slice(0,20)})]},u))}),!a&&e.jsx("button",{onClick:()=>p(!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})})]})},at=({title:t,onSave:n,onAskAI:o,extraButtons:r,children:s})=>{const l=ke();return e.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",paddingBottom:"8px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:i("fg")},children:t}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[r,o&&e.jsx("button",{onClick:o,style:Vm,children:"AI"}),n&&e.jsx("button",{onClick:n,style:Um,children:l.action.save})]})]}),s]})},Um={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Vm={padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},nt=({label:t,value:n,onChange:o,placeholder:r,disabled:s})=>e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:{display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:t}),e.jsx("input",{type:"text",value:n,onChange:l=>o(l.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"}})]}),Tt=({value:t,onChange:n,placeholder:o})=>{const r=h.useRef(null);return h.useEffect(()=>{r.current&&(r.current.style.height="auto",r.current.style.height=`${r.current.scrollHeight}px`)},[t]),e.jsx("textarea",{ref:r,value:t||"",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"}})},In=({children:t,color:n,style:o})=>e.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:t});function Gm(t){const n=t.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const Sn=({value:t,onChange:n,label:o})=>{const[r,s]=h.useState(!1),l=h.useRef(null),a=Gm(t||"");return h.useEffect(()=>{r&&l.current&&l.current.focus()},[r]),!r&&a?e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:Ir,children:o}),e.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:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:i("fg")},children:a.name}),e.jsx(In,{children:a.id})]})]}):e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:Ir,children:o}),e.jsx("input",{ref:l,type:"text",value:t||"",onChange:p=>n(p.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"}})]})},Ir={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500};function Ym(t){switch(t){case"url":return i("source-url");case"bookID":return i("source-bookid");default:return i("desc-fg")}}function Km(t){switch(t){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const Vl=({items:t,onChange:n,onOpenEntityPicker:o})=>{const r=ke(),[s,l]=h.useState(null),a=()=>{n([...t,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),l(t.length)},p=g=>{n(t.filter((m,x)=>x!==g)),s===g&&l(null)},c=(g,m,x)=>{const f=[...t];f[g]={...f[g],[m]:x},n(f)},d=(g,m)=>{const x=[...t];x[g]={...x[g],type:m,id:"",name:""},n(x),m==="bookID"&&o&&o(f=>{const k=[...t];k[g]={...k[g],id:f.id,name:f.title,type:"bookID"},n(k)})},u=g=>{o&&o(m=>{const x=[...t];x[g]={...x[g],id:m.id,name:m.title,type:"bookID"},n(x)})};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((g,m)=>e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>l(s===m?null:m),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===m?"▼":"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:i("fg")},children:g.name||`${r.editor.sourcePlaceholder} ${m+1}`}),g.type&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:Ym(g.type),color:i("on-color-fg"),borderRadius:"3px",fontWeight:500},children:Km(g.type)}),e.jsx("button",{onClick:x=>{x.stopPropagation(),p(m)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:r.editor.deleteThisSource,children:"✕"})]}),s===m&&e.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!g.type&&e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.editor.selectSourceType}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsxs("button",{onClick:()=>d(m,"bookID"),style:{...Rr,borderColor:i("source-bookid"),color:i("source-bookid")},children:[e.jsx("span",{style:{fontSize:"18px"},children:"📚"}),e.jsx("span",{children:"Book ID"}),e.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.fromExistingBook})]}),e.jsxs("button",{onClick:()=>d(m,"url"),style:{...Rr,borderColor:i("source-url"),color:i("source-url")},children:[e.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),e.jsx("span",{children:"URL"}),e.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.enterUrl})]})]})]}),g.type==="bookID"&&e.jsx(e.Fragment,{children:e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("label",{style:mt,children:r.action.selectBookOrWork}),e.jsx("button",{onClick:()=>{const x=[...t];x[m]={...x[m],type:"",id:"",name:""},n(x)},style:Er,children:r.action.changeType})]}),g.id&&g.name?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:i("bg"),border:`1px solid ${i("source-bookid")}`,borderRadius:"6px"},children:[e.jsx("span",{style:{color:i("source-bookid"),fontSize:"16px"},children:"✓"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:g.name}),e.jsx("code",{style:{fontSize:"11px",background:i("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:g.id})]}),e.jsx("button",{onClick:()=>u(m),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})]}):e.jsxs("button",{onClick:()=>u(m),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:[e.jsx("span",{children:"🔍"}),e.jsx("span",{children:r.action.clickToSelectBookOrWork})]})]})}),g.type==="url"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("label",{style:mt,children:r.label.sourceName}),e.jsx("button",{onClick:()=>{const x=[...t];x[m]={...x[m],type:"",id:"",name:""},n(x)},style:Er,children:r.action.changeType})]}),e.jsx("input",{type:"text",value:g.name,onChange:x=>c(m,"name",x.target.value),placeholder:r.editor.sourceNamePlaceholder,style:Pt})]}),e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.label.urlAddress}),e.jsx("input",{type:"text",value:g.id,onChange:x=>c(m,"id",x.target.value),placeholder:"https://...",style:Pt})]})]}),g.type&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{borderTop:`1px dashed ${i("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:e.jsx("label",{style:{...mt,opacity:.7},children:r.label.optionalInfo})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.label.detailsOptional}),e.jsx("input",{type:"text",value:g.details,onChange:x=>c(m,"details",x.target.value),placeholder:r.editor.detailsPlaceholder,style:Pt})]}),e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.label.positionOptional}),e.jsx("input",{type:"text",value:g.position,onChange:x=>c(m,"position",x.target.value),placeholder:"如: 卷三, p.52",style:Pt})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.label.dataVersionOptional}),e.jsx("input",{type:"text",value:g.version,onChange:x=>c(m,"version",x.target.value),placeholder:"如: v1.0, 2024-01",style:Pt})]}),e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.label.processorVersionOptional}),e.jsx("input",{type:"text",value:g.processor_version,onChange:x=>c(m,"processor_version",x.target.value),placeholder:"如: v0.1",style:Pt})]})]})]})]})})]},m)),e.jsxs("button",{onClick:a,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:[e.jsx("span",{children:"+"}),e.jsx("span",{children:r.action.addSource})]})]})},mt={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},Pt={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"},Rr={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"},Er={background:"transparent",border:"none",color:i("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function Gl(t){if(!t||!t.trim())return[];try{const n=JSON.parse(t);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 Yl(t){return!t||t.length===0?"":JSON.stringify(t)}const Kl=({entityType:t,entityId:n,entityTitle:o,parentWork:r,parentCollection:s,belongsToWork:l,belongsToCollection:a,childWorks:p,childCollections:c,containedBooks:d,siblingBooks:u,onLinkEntity:g,onUnlinkEntity:m,onViewEntity:x,onCreateAndLink:f,onSaveRelations:k})=>{const b=ke();return e.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[e.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:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:"🔗"}),e.jsx("span",{children:b.section.relations})]}),k&&e.jsx("button",{onClick:k,style:qm,children:b.action.save})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[t==="book"&&e.jsxs(e.Fragment,{children:[e.jsx(Qt,{direction:"up",title:b.relation.belongsToWork,entity:l,onView:x,onUnlink:()=>m("workId"),onLink:()=>g("workId","work"),onCreate:()=>f("workId","work",{title:o}),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),e.jsx(Qt,{direction:"up",title:b.relation.containedInCollection,entity:a,onView:x,onUnlink:()=>m("collectionId"),onLink:()=>g("collectionId","collection"),onCreate:()=>f("collectionId","collection",{title:o}),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),l&&u&&u.length>0&&e.jsx(At,{direction:"horizontal",title:`${b.relation.siblingVersions} (${u.length})`,entities:u,onView:x,onAdd:()=>f("siblingBook","book",{workId:l.id}),addLabel:b.relation.addVersionForWork,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore})]}),t==="work"&&e.jsxs(e.Fragment,{children:[e.jsx(Qt,{direction:"up",title:b.relation.parentWork,entity:r,onView:x,onUnlink:()=>m("parentWorkId"),onLink:()=>g("parentWorkId","work"),onCreate:()=>f("parentWorkId","work"),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),p&&p.length>0&&e.jsx(At,{direction:"down",title:`${b.relation.childWorks} (${p.length})`,entities:p,onView:x,onAdd:()=>f("childWork","work",{parentWorkId:n}),addLabel:b.action.addSubWork,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore}),c&&c.length>0&&e.jsx(At,{direction:"down",title:`${b.relation.collectionImpl} (${c.length})`,entities:c,onView:x,onAdd:()=>f("childCollection","collection",{workId:n}),addLabel:b.action.addCollectionImpl,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore}),e.jsx(At,{direction:"down",title:`${b.relation.allVersions} (${(d==null?void 0:d.length)??0})`,entities:d||[],onView:x,onAdd:()=>f("childBook","book",{workId:n}),addLabel:b.action.addVersion,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore})]}),t==="collection"&&e.jsxs(e.Fragment,{children:[e.jsx(Qt,{direction:"up",title:b.relation.correspondingWork,entity:l,onView:x,onUnlink:()=>m("workId"),onLink:()=>g("workId","work"),onCreate:()=>f("workId","work",{title:o}),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),e.jsx(Qt,{direction:"up",title:b.relation.parentCollection,entity:s,onView:x,onUnlink:()=>m("parentCollectionId"),onLink:()=>g("parentCollectionId","collection"),onCreate:()=>f("parentCollectionId","collection"),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),e.jsx(At,{direction:"down",title:`${b.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:x,onAdd:()=>f("childCollection","collection",{parentCollectionId:n}),addLabel:b.action.addSubCollection,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore}),e.jsx(At,{direction:"down",title:`${b.relation.containedBooks} (${(d==null?void 0:d.length)??0})`,entities:d||[],onView:x,onAdd:()=>f("childBook","book",{collectionId:n}),addLabel:b.action.addBook,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore})]})]})]})},Qt=({direction:t,title:n,entity:o,onView:r,onUnlink:s,onLink:l,onCreate:a,linkLabel:p,createLabel:c,notLinkedLabel:d,viewLabel:u,unlinkLabel:g})=>{const m=i(t==="up"?"relation-up":t==="down"?"relation-down":"relation-flat"),x=t==="up"?"⬆️":t==="down"?"⬇️":"↔️";return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("input-bg")},children:[e.jsxs("div",{style:{fontSize:"12px",color:m,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:x}),e.jsx("span",{children:n})]}),o?e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:i("bg"),borderRadius:"4px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:ql(o.type)}),e.jsx("span",{style:{fontWeight:500},children:o.title}),e.jsx("span",{style:{fontSize:"11px",opacity:.6},children:o.id})]}),e.jsxs("div",{style:{display:"flex",gap:"4px"},children:[e.jsx(Lr,{onClick:()=>r(o),title:u,children:"👁️"}),e.jsx(Lr,{onClick:s,title:g,danger:!0,children:"✕"})]})]}):e.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:d}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsx(Ri,{onClick:l,children:p}),e.jsx(Ri,{onClick:a,primary:!0,children:c})]})]})},At=({direction:t,title:n,entities:o,onView:r,onAdd:s,addLabel:l,noneLabel:a,expandMoreLabel:p})=>{const[c,d]=h.useState(!1),u=i(t==="up"?"relation-up":t==="down"?"relation-down":"relation-flat"),g=t==="up"?"⬆️":t==="down"?"⬇️":"↔️",m=c?o:o.slice(0,5);return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("input-bg")},children:[e.jsxs("div",{style:{fontSize:"12px",color:u,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:g}),e.jsx("span",{children:n})]}),o.length>0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[m.map(x=>e.jsxs("div",{onClick:()=>r(x),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:i("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[e.jsx("span",{children:ql(x.type)}),e.jsx("span",{children:x.title})]},x.id)),o.length>5&&!c&&e.jsxs("div",{onClick:()=>d(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:i("link-fg"),cursor:"pointer"},children:[p," (",o.length-5,")"]})]}):e.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:a}),e.jsx("div",{style:{marginTop:"8px"},children:e.jsxs(Ri,{onClick:s,primary:!0,children:["+ ",l]})})]})},Lr=({onClick:t,title:n,danger:o,children:r})=>e.jsx("button",{onClick:s=>{s.stopPropagation(),t()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:o?i("danger"):"inherit",opacity:.7},children:r}),Ri=({onClick:t,primary:n,children:o})=>e.jsx("button",{onClick:t,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 ql(t){switch(t){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const qm={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},Zl=({isOpen:t,entityType:n,title:o,onSelect:r,onCancel:s,onCreate:l,searchResults:a,onSearch:p,isLoading:c,excludeId:d})=>{const[u,g]=h.useState(""),m=d?a.filter(b=>b.id!==d):a;h.useEffect(()=>{t&&(g(""),p(""))},[t]);const x=b=>{g(b),p(b)};if(!t)return null;const f=n==="work"?"作品":n==="book"?"书籍":"丛编",k=n==="work"?"📜":n==="book"?"📖":"📚";return e.jsx("div",{style:Zm,children:e.jsxs("div",{style:Jm,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:o}),e.jsx("button",{onClick:s,style:Xm,children:"✕"})]}),e.jsx("div",{style:{padding:"12px 16px"},children:e.jsx("input",{type:"text",value:u,onChange:b=>x(b.target.value),placeholder:`搜索${f}名称或 ID...`,autoFocus:!0,style:Qm})}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?e.jsx("div",{style:di,children:"搜索中..."}):m.length>0?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:m.map(b=>e.jsxs("div",{onClick:()=>r(b),style:eg,children:[e.jsx("span",{style:{fontSize:"16px"},children:k}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontWeight:500},children:[b.title,b.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:b.edition})]}),e.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[b.id,b.author&&` · ${b.author}`,b.dynasty&&` · ${b.dynasty}`]})]})]},b.id))}):u?e.jsxs("div",{style:di,children:["未找到匹配的",f]}):e.jsxs("div",{style:di,children:["输入关键词搜索",f]})}),e.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),e.jsxs("button",{onClick:l,style:tg,children:["创建新",f,"并关联"]})]})]})})},Zm={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Jm={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")},Xm={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},Qm={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"},eg={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:i("primary-soft")},di={padding:"20px",textAlign:"center",color:i("desc-fg")},tg={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Pr={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},ng={work:"📜",book:"📖",collection:"📚",entity:"👤"},Jl=({isOpen:t,entityType:n,relationField:o,inheritData:r,onConfirm:s,onCancel:l})=>{const[a,p]=h.useState(""),c=h.useRef(null);h.useEffect(()=>{t&&(p((r==null?void 0:r.title)||""),setTimeout(()=>{var m,x;(m=c.current)==null||m.focus(),(x=c.current)==null||x.select()},100))},[t,r==null?void 0:r.title]);const d=m=>{m.key==="Enter"&&a.trim()?u():m.key==="Escape"&&l()},u=()=>{a.trim()&&s(a.trim(),{...r,title:a.trim()})};if(!t)return null;const g=()=>{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`创建新${Pr[n]}`}};return e.jsx("div",{style:ig,onClick:m=>{m.target===m.currentTarget&&l()},children:e.jsxs("div",{style:og,onClick:m=>m.stopPropagation(),children:[e.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:ng[n]}),e.jsx("span",{children:g()})]}),e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:i("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",e.jsx("span",{style:{color:i("danger"),marginLeft:"4px"},children:"*"})]}),e.jsx("input",{ref:c,type:"text",value:a,onChange:m=>p(m.target.value),onKeyDown:d,placeholder:`请输入${Pr[n]}名称...`,style:rg})]}),((r==null?void 0:r.author)||(r==null?void 0:r.dynasty))&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),background:i("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[e.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(r==null?void 0:r.author)&&e.jsxs("div",{children:["作者: ",r.author]}),(r==null?void 0:r.dynasty)&&e.jsxs("div",{children:["朝代/年份: ",r.dynasty]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[e.jsx("button",{onClick:l,style:sg,children:"取消"}),e.jsx("button",{onClick:u,disabled:!a.trim(),style:{...lg,opacity:a.trim()?1:.6,cursor:a.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},ig={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},og={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")},rg={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"},sg={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},lg={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg")};function ag(t){switch(t){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Xl(t){switch(t){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function cg(t){switch(t){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 Ql=({isOpen:t,title:n,filterType:o="all",recentEntities:r=[],excludeId:s,showCreateButton:l=!1,createButtonText:a,onSelect:p,onCancel:c,onCreate:d,onSearch:u})=>{const[g,m]=h.useState(""),[x,f]=h.useState([]),[k,b]=h.useState(!1),[w,y]=h.useState("recent");h.useEffect(()=>{t&&(m(""),f([]),y(r.length>0?"recent":"search"))},[t,r.length]),h.useEffect(()=>{if(!g.trim()){f([]);return}const z=setTimeout(async()=>{b(!0);try{f(await u(g,o))}catch{f([])}finally{b(!1)}},300);return()=>clearTimeout(z)},[g,o,u]);const j=h.useCallback(z=>{m(z.target.value),z.target.value.trim()&&y("search")},[]),S=h.useCallback(z=>s?z.filter(E=>E.id!==s):z,[s]);if(!t)return null;const v=n||(o==="all"?"选择实体":`选择${Xl(o)}`),$=S(r),C=S(x);return e.jsx("div",{style:pg,children:e.jsxs("div",{style:ug,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:v}),e.jsx("button",{onClick:c,style:mg,children:"✕"})]}),e.jsx("div",{style:{padding:"16px 20px 12px"},children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{type:"text",value:g,onChange:j,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:gg}),e.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),k&&e.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),$.length>0&&e.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsxs(Ar,{active:w==="recent",onClick:()=>y("recent"),children:["最近使用 (",$.length,")"]}),e.jsxs(Ar,{active:w==="search",onClick:()=>y("search"),children:["搜索结果 ",C.length>0&&`(${C.length})`]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:w==="recent"&&$.length>0?e.jsx(Br,{entities:$,onSelect:p}):g.trim()?k?e.jsx(pi,{message:"搜索中..."}):C.length>0?e.jsx(Br,{entities:C,onSelect:p}):e.jsx(pi,{message:"未找到匹配的结果"}):e.jsx(pi,{message:"输入关键词开始搜索"})}),l&&d&&e.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),e.jsx("button",{onClick:d,style:hg,children:a||"创建新实体"})]})]})})},Ar=({active:t,onClick:n,children:o})=>e.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:t?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(t?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:t?600:400,marginBottom:"-1px"},children:o}),Br=({entities:t,onSelect:n})=>e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:t.map(o=>e.jsx(dg,{entity:o,onClick:()=>n(o)},o.id))}),dg=({entity:t,onClick:n})=>{const[o,r]=h.useState(!1);return e.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:[e.jsx("span",{style:{fontSize:"18px"},children:ag(t.type)}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{fontWeight:500,fontSize:"13px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[t.title,t.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:i("desc-fg"),marginLeft:"4px"},children:t.edition})]}),e.jsxs("div",{style:{fontSize:"11px",opacity:.7,display:"flex",alignItems:"center",gap:"6px",marginTop:"2px"},children:[e.jsx("code",{style:{fontSize:"10px",background:i("primary-soft"),padding:"1px 4px",borderRadius:"2px"},children:t.id}),t.author&&e.jsx("span",{children:t.author}),t.dynasty&&e.jsx("span",{children:t.dynasty})]})]}),e.jsx("span",{style:{fontSize:"10px",padding:"3px 8px",background:cg(t.type),color:i("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:Xl(t.type)})]})},pi=({message:t})=>e.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:t}),pg={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},ug={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")},mg={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},gg={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"},hg={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},xg={work:i("editor-type-work"),collection:i("editor-type-collection"),book:i("editor-type-book"),entity:i("editor-type-entity")},fg={work:"📜",collection:"📚",book:"📖",entity:"👤"},ea=({data:t,onChange:n,onSave:o,transport:r,onNavigate:s,showDelete:l,onDelete:a,onAskAI:p,renderSectionActions:c,onDownloadResource:d,downloadStatuses:u,relations:g,onRelationsChange:m})=>{var we;const x=ke(),[f,k]=h.useState(!1),[b,w]=h.useState("work"),[y,j]=h.useState(""),[S,v]=h.useState(""),[$,C]=h.useState([]),[z,E]=h.useState(!1),[T,_]=h.useState(!1),[O,W]=h.useState("work"),[A,G]=h.useState(""),[V,ie]=h.useState(),[ae,P]=h.useState(!1),[I,q]=h.useState(null),[Q,oe]=h.useState([]);h.useRef(null);const je=t.type,Ie=je==="work",K=je==="collection",me=je==="book",M=h.useCallback((F,fe)=>{n({...t,[F]:fe})},[t,n]),ue=h.useCallback((F,fe)=>{j(F),w(fe),v(x.editor.selectToLink+x.indexType[fe]),C([]),k(!0)},[x]),ge=h.useCallback(F=>{r!=null&&r.unlinkEntity&&r.unlinkEntity(t.id,F)},[r,t.id]),de=h.useCallback(F=>{s==null||s(F.id,F.type)},[s]),Le=h.useCallback((F,fe,Re)=>{const R={...Re,author:(Re==null?void 0:Re.author)||t.author,dynasty:Re==null?void 0:Re.dynasty};W(fe),G(F),ie(R),_(!0)},[t.author]),Me=h.useCallback((F,fe)=>{r!=null&&r.createAndLink&&r.createAndLink(t.id,A,{type:O,title:F,inheritData:fe}),_(!1)},[r,t.id,A,O]),Ee=h.useCallback(F=>{if(!F.trim()){C([]);return}E(!0),r!=null&&r.searchEntities&&r.searchEntities(F,b).then(fe=>{C(fe),E(!1)}).catch(()=>{C([]),E(!1)})},[r,b]),ze=h.useCallback(F=>{r!=null&&r.linkEntity&&r.linkEntity(t.id,y,F.id),k(!1)},[r,t.id,y]),He=h.useCallback(()=>{o()},[o]),D=h.useCallback(F=>{q(()=>F),P(!0),r!=null&&r.getRecentEntities&&r.getRecentEntities().then(oe).catch(()=>{})},[r]),re=h.useCallback((F,fe)=>r!=null&&r.searchEntities?r.searchEntities(F,fe==="all"?void 0:fe):Promise.resolve([]),[r]),ce=h.useCallback(F=>{r!=null&&r.addRecentEntity&&r.addRecentEntity(F),oe(fe=>[F,...fe.filter(Re=>Re.id!==F.id)].slice(0,10)),I==null||I(F),P(!1),q(null)},[r,I]);return e.jsxs("div",{style:{padding:"16px",maxWidth:"900px",margin:"0 auto"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:`1px solid ${i("widget-border")}`,paddingBottom:"16px"},children:e.jsxs("h1",{style:{fontSize:"20px",fontWeight:600,margin:0,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:fg[je]}),e.jsx("span",{children:t.title||x.editor.untitled}),e.jsx(In,{children:t.id}),e.jsx(In,{color:xg[je],children:x.indexType[je]})]})}),e.jsx(at,{title:x.section.basicInfo,onSave:o,onAskAI:p?()=>p("基本信息"):void 0,extraButtons:c==null?void 0:c("基本信息"),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[e.jsx(Sn,{label:Ie?x.editor.workTitle:K?x.editor.collectionTitle:x.editor.bookTitle,value:t.title,onChange:F=>M("title",F)}),me&&e.jsx(Sn,{label:x.editor.belongsToWork,value:t.workName||"",onChange:F=>M("workName",F)}),e.jsx(nt,{label:x.editor.authorLabel,value:t.author||"",onChange:F=>M("author",F)}),e.jsx(nt,{label:x.editor.publicationYearLabel,value:t.publicationYear||"",onChange:F=>M("publicationYear",F)}),(me||K)&&e.jsx(Sn,{label:x.editor.containedIn,value:t.collection||"",onChange:F=>M("collection",F)}),(me||K)&&e.jsx(nt,{label:x.editor.holderLabel,value:t.holder||"",onChange:F=>M("holder",F)}),(me||K)&&e.jsx(nt,{label:me?x.editor.pageLabel:x.editor.volumeLabel,value:t.pages||"",onChange:F=>M("pages",F)}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(nt,{label:x.editor.firstImageLabel,value:t.firstImage||"",onChange:F=>M("firstImage",F)})})]})}),e.jsx(at,{title:x.section.description,onSave:o,onAskAI:p?()=>p("介绍"):void 0,children:e.jsx(Tt,{value:t.description||"",onChange:F=>M("description",F),placeholder:x.editor.descriptionPlaceholder})}),(((we=t.additional_works)==null?void 0:we.length)||0)>0&&e.jsx(at,{title:x.section.additionalWorks,onSave:o,children:e.jsx(bg,{items:t.additional_works||[],onChange:F=>M("additional_works",F)})}),e.jsx(at,{title:x.section.indexedBy,onSave:o,onAskAI:p?()=>p("收录于"):void 0,children:e.jsx(yg,{items:t.indexed_by||[],onChange:F=>M("indexed_by",F)})}),e.jsx(at,{title:x.section.emendatedBy,onSave:o,onAskAI:p?()=>p("考证"):void 0,children:e.jsx(jg,{items:t.emendated_by||[],onChange:F=>M("emendated_by",F)})}),e.jsx(at,{title:x.section.textResources,onSave:o,onAskAI:p?()=>p("资源"):void 0,children:e.jsx(fi,{items:t.resources||[],onChange:F=>M("resources",F),onDownload:d,downloadStatuses:u,filterType:"text"})}),e.jsx(at,{title:x.section.imageResources,onSave:o,children:e.jsx(fi,{items:t.resources||[],onChange:F=>M("resources",F),onDownload:d,downloadStatuses:u,filterType:"image"})}),e.jsx(at,{title:x.section.sources,onSave:o,onAskAI:p?()=>p("资料来源"):void 0,children:e.jsx(Vl,{items:Gl(t.sources||""),onChange:F=>M("sources",Yl(F)),onOpenEntityPicker:D})}),(me||K)&&e.jsx(at,{title:x.section.provenance,onSave:o,onAskAI:p?()=>p("收藏历史"):void 0,children:e.jsx(Tt,{value:t.provenance||"",onChange:F=>M("provenance",F),placeholder:x.editor.provenancePlaceholder})}),me&&e.jsx(at,{title:x.section.otherEditions,onSave:o,onAskAI:p?()=>p("其他版本"):void 0,children:e.jsx(Tt,{value:t.otherEditions||"",onChange:F=>M("otherEditions",F),placeholder:x.editor.otherEditionsPlaceholder})}),e.jsx(Kl,{entityType:je,entityId:t.id,entityTitle:t.title,parentWork:g==null?void 0:g.parentWork,parentCollection:g==null?void 0:g.parentCollection,belongsToWork:g==null?void 0:g.belongsToWork,belongsToCollection:g==null?void 0:g.belongsToCollection,childWorks:g==null?void 0:g.childWorks,childCollections:g==null?void 0:g.childCollections,containedBooks:g==null?void 0:g.containedBooks,siblingBooks:g==null?void 0:g.siblingBooks,onLinkEntity:ue,onUnlinkEntity:ge,onViewEntity:de,onCreateAndLink:Le,onSaveRelations:He}),l&&a&&e.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${i("danger-soft-border")}`,background:i("danger-soft-bg"),borderRadius:"4px"},children:[e.jsx("div",{style:{color:i("danger"),fontWeight:600,marginBottom:"8px"},children:x.section.dangerZone}),e.jsx("p",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"12px"},children:x.editor.dangerZoneDesc}),e.jsx("button",{onClick:a,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("danger")}`,borderRadius:"4px",background:"transparent",color:i("danger"),cursor:"pointer"},children:x.editor.deleteEntity})]}),e.jsx(Zl,{isOpen:f,entityType:b,title:S,onSelect:ze,onCancel:()=>k(!1),onCreate:()=>{k(!1),Le(y,b)},searchResults:$,onSearch:Ee,isLoading:z,excludeId:t.id}),e.jsx(Jl,{isOpen:T,entityType:O,relationField:A,inheritData:V,onConfirm:Me,onCancel:()=>_(!1)}),e.jsx(Ql,{isOpen:ae,title:x.action.selectBookOrWork,filterType:"all",recentEntities:Q,excludeId:t.id,onSelect:ce,onCancel:()=>{P(!1),q(null)},onSearch:re})]})};function bg({items:t,onChange:n}){const o=ke(),r=(a,p,c)=>{const d=t.map((u,g)=>g===a?{...u,[p]:c}:u);n(d)},s=a=>n(t.filter((p,c)=>c!==a)),l=()=>n([...t,{book_title:""}]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((a,p)=>e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx(nt,{label:o.editor.bookNameLabel,value:a.book_title,onChange:c=>r(p,"book_title",c)}),e.jsx("div",{style:{width:"100px"},children:e.jsx(nt,{label:o.label.juanCount,value:a.n_juan!=null?String(a.n_juan):"",onChange:c=>r(p,"n_juan",c&&parseInt(c,10)||void 0)})}),e.jsx("button",{onClick:()=>s(p),style:{padding:"4px 8px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("muted"),marginTop:"18px"},children:"✕"})]},p)),e.jsx("button",{onClick:l,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 ta({items:t,onChange:n,showMeta:o,addLabel:r}){const s=ke(),[l,a]=h.useState(null),p=(u,g,m)=>{const x=t.map((f,k)=>k===u?{...f,[g]:m||void 0}:f);n(x)},c=u=>{n(t.filter((g,m)=>m!==u)),l===u&&a(null)},d=()=>{n([...t,{source:""}]),a(t.length)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((u,g)=>{const m=l===g;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:m?`color-mix(in srgb, ${i("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>a(m?null:g),children:[e.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.2s",transform:m?"rotate(90deg)":"none"},children:"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:u.source||s.editor.unnamedSource}),u.source_bid&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u.source_bid}),e.jsx("button",{onClick:x=>{x.stopPropagation(),c(g)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${i("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:i("muted")},children:"✕"})]}),!m&&o&&(u.title_info||u.author_info)&&e.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]}),m&&e.jsxs("div",{style:{padding:"8px 12px 12px",display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsx(nt,{label:s.label.sourceName,value:u.source,onChange:x=>p(g,"source",x)}),e.jsx(nt,{label:s.label.sourceBid,value:u.source_bid||"",onChange:x=>p(g,"source_bid",x)})]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsx(nt,{label:s.label.titleInfo,value:u.title_info||"",onChange:x=>p(g,"title_info",x)}),e.jsx(nt,{label:s.label.authorInfo,value:u.author_info||"",onChange:x=>p(g,"author_info",x)})]}),e.jsx(nt,{label:s.label.edition,value:u.edition||"",onChange:x=>p(g,"edition",x)})]}),e.jsx(Tt,{value:u.summary||"",onChange:x=>p(g,"summary",x),placeholder:s.editor.summaryPlaceholder}),e.jsx(Tt,{value:u.comment||"",onChange:x=>p(g,"comment",x),placeholder:s.editor.commentPlaceholder}),e.jsx(Tt,{value:u.additional_comment||"",onChange:x=>p(g,"additional_comment",x),placeholder:s.editor.additionalCommentPlaceholder})]})]},g)}),e.jsx("button",{onClick:d,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 yg({items:t,onChange:n}){const o=ke();return e.jsx(ta,{items:t,onChange:n,showMeta:!0,addLabel:o.action.addIndexedBy})}function jg({items:t,onChange:n}){const o=ke();return e.jsx(ta,{items:t,onChange:n,addLabel:o.action.addEmendatedBy})}function na(t){var p,c,d,u,g,m,x;const n=((c=(p=t.authors)==null?void 0:p[0])==null?void 0:c.name)||"",o=((d=t.publication_info)==null?void 0:d.year)||"",r=((u=t.current_location)==null?void 0:u.name)||"",s=(g=t.page_count)!=null&&g.number?String(t.page_count.number):((m=t.page_count)==null?void 0:m.description)||"",l=typeof t.description=="object"&&t.description!==null&&t.description.text||"",a={id:t.id,title:t.title,type:t.type,author:n,publicationYear:o,holder:r,pages:s,description:l,resources:t.resources,additional_works:t.additional_works,indexed_by:t.indexed_by,emendated_by:t.emendated_by};if(t.type==="work"){const f=t;if(Array.isArray(f.related_works)){const k=f.related_works.find(b=>b.relation==="part_of");k&&(a.parentWorkId=k.id,a.parentWorkName=k.title)}}if(t.type==="book"){const f=t;a.workId=f.work_id,Array.isArray(f.contained_in)&&f.contained_in.length>0&&(a.collectionId=(x=f.contained_in[0])==null?void 0:x.id)}return a}function vg(t){const n={id:t.id,title:t.title,type:t.type,description:t.description?{text:t.description}:void 0,authors:t.author?[{name:t.author}]:void 0,publication_info:t.publicationYear?{year:t.publicationYear}:void 0,current_location:t.holder?{name:t.holder}:void 0,page_count:t.pages?{number:parseInt(t.pages)||0,description:t.pages}:void 0,resources:t.resources,additional_works:t.additional_works,indexed_by:t.indexed_by,emendated_by:t.emendated_by};return t.type==="work"&&t.parentWorkId&&(n.related_works=[{id:t.parentWorkId,title:t.parentWorkName||"",relation:"part_of"}]),t.type==="book"&&(n.work_id=t.workId,t.collectionId&&(n.contained_in=[{id:t.collectionId}])),n}const kg=t=>{const{data:n,id:o,transport:r,mode:s="view",onModeChange:l,onChange:a,onSave:p,onDelete:c,onNavigate:d,renderLink:u,onAskAI:g,renderSectionActions:m,onDownloadResource:x,downloadStatuses:f,relations:k,onRelationsChange:b,headerExtra:w,className:y,style:j}=t,S=ke(),[v,$]=h.useState(s),C=l?s:v;h.useEffect(()=>{s!==v&&$(s)},[s]);const z=h.useCallback(()=>{const G=C==="view"?"edit":"view";l?l(G):$(G)},[C,l]),[E,T]=h.useState(null);h.useEffect(()=>{o&&r&&r.getItem(o).then(G=>{G&&T(G)})},[o,r]);const _=n||E,O=h.useMemo(()=>_?na(_):null,[_]),W=l||!n?e.jsx("button",{onClick:z,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:C==="edit"?i("accent-bg"):"transparent",color:i(C==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:C==="view"?S.common.switchToEdit:S.common.switchToView,children:C==="view"?S.common.modeEdit:S.common.modeView}):null,A=e.jsxs(e.Fragment,{children:[W,w]});return!_&&!O?e.jsx(Rt,{}):C==="view"?e.jsx(Ki,{data:_,transport:r,onNavigate:d?G=>d(G):void 0,renderLink:u,headerExtra:A,className:y,style:j}):O?e.jsxs("div",{className:y,style:j,children:[A&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:A}),e.jsx(ea,{data:O,onChange:a||(()=>{}),onSave:p||(()=>{}),transport:r,onNavigate:d,showDelete:!!c,onDelete:c,onAskAI:g,renderSectionActions:m,onDownloadResource:x,downloadStatuses:f,relations:k,onRelationsChange:b})]}):e.jsx("div",{style:{padding:"24px",textAlign:"center",color:i("muted")},children:S.common.noData})},wg=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],ia=({isOpen:t,onClose:n,onSubmit:o,feedbackListUrl:r})=>{const{t:s}=Y(),[l,a]=h.useState(null),[p,c]=h.useState(""),[d,u]=h.useState(""),[g,m]=h.useState("idle"),[x,f]=h.useState(""),k=h.useRef(null);h.useEffect(()=>{t&&(a(null),c(""),u(""),m("idle"),f(""))},[t]),h.useEffect(()=>{l&&setTimeout(()=>{var y;return(y=k.current)==null?void 0:y.focus()},100)},[l]),h.useEffect(()=>{if(g==="success"){const y=setTimeout(n,2e3);return()=>clearTimeout(y)}},[g,n]),h.useEffect(()=>{if(!t)return;const y=j=>{j.key==="Escape"&&n()};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[t,n]);const b=async()=>{if(!(!l||!p.trim())){m("submitting"),f("");try{await o({type:l,content:p.trim(),...d.trim()?{contact:d.trim()}:{}}),m("success")}catch(y){m("error"),f(y instanceof Error?y.message:s("feedback.submitFailedRetry"))}}};if(!t)return null;const w=l&&p.trim()&&g!=="submitting";return e.jsx("div",{style:Sg,onClick:y=>{y.target===y.currentTarget&&n()},children:e.jsxs("div",{style:$g,onClick:y=>y.stopPropagation(),children:[e.jsxs("div",{style:_g,children:[e.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),e.jsx("button",{onClick:n,style:Cg,"aria-label":s("feedback.close"),children:"✕"})]}),g==="success"?e.jsxs("div",{style:Rg,children:[e.jsx("span",{style:{fontSize:"32px"},children:"✓"}),e.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:s("feedback.thanks")}),r&&e.jsx("a",{href:r,style:{fontSize:"13px",color:i("primary"),marginTop:"8px"},children:s("feedback.viewList")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"16px"},children:wg.map(y=>e.jsxs("button",{onClick:()=>a(y.value),style:{...zg,...l===y.value?Tg:{}},children:[e.jsx("span",{children:y.icon})," ",s(`feedback.submitType.${y.value}`)]},y.value))}),e.jsx("textarea",{ref:k,value:p,onChange:y=>c(y.target.value),placeholder:s(l?`feedback.placeholder.${l}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!l||g==="submitting",style:{...Ng,opacity:l?1:.6}}),e.jsx("input",{type:"text",value:d,onChange:y=>u(y.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!l||g==="submitting","aria-label":s("feedback.contactLabel"),style:Lg}),e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[p.length," / 2000"]}),g==="error"&&e.jsx("div",{style:Eg,children:x}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{onClick:b,disabled:!w,style:{...Ig,opacity:w?1:.6,cursor:w?"pointer":"not-allowed"},children:s(g==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},Sg={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},$g={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:i("shadow-dialog")},_g={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},Cg={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:i("desc-fg"),padding:"4px 8px",borderRadius:"4px"},zg={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"},Tg={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},Ng={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"},Ig={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},Rg={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:i("success")},Eg={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginBottom:"12px"},Lg={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"},Ei="--bim-feedback-fab-offset",Li=48,Pg=16,Ag=({onSubmit:t,position:n={bottom:24,right:24},feedbackListUrl:o,hidden:r=!1,zIndex:s})=>{const{t:l}=Y(),[a,p]=h.useState(!1),c=n.bottom??24;return h.useEffect(()=>{if(r||typeof document>"u")return;const d=document.documentElement;return d.style.setProperty(Ei,`calc(${c+Li+Pg}px + env(safe-area-inset-bottom, 0px))`),()=>{d.style.removeProperty(Ei)}},[r,c]),e.jsxs(e.Fragment,{children:[!r&&e.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>p(!0),style:{...Bg,zIndex:s??i("feedback-fab-z"),bottom:`calc(${c}px + env(safe-area-inset-bottom, 0px))`,right:n.right},"aria-label":l("feedback.title"),title:l("feedback.title"),children:e.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:e.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"})})}),e.jsx(ia,{isOpen:a,onClose:()=>p(!1),onSubmit:t,feedbackListUrl:o})]})},Bg={position:"fixed",width:`${Li}px`,height:`${Li}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"},Mg=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],oa=({onSubmit:t})=>{const{t:n}=Y(),[o,r]=h.useState("bug"),[s,l]=h.useState(""),[a,p]=h.useState(""),[c,d]=h.useState("idle"),[u,g]=h.useState(""),m=h.useRef(null);h.useEffect(()=>{o&&setTimeout(()=>{var k;return(k=m.current)==null?void 0:k.focus()},100)},[o]);const x=async()=>{if(!(!o||!s.trim())){d("submitting"),g("");try{await t({type:o,content:s.trim(),...a.trim()?{contact:a.trim()}:{}}),d("success"),l(""),p(""),r("bug")}catch(k){d("error"),g(k instanceof Error?k.message:n("feedback.submitFailedRetry"))}}},f=o&&s.trim()&&c!=="submitting";return c==="success"?e.jsx("div",{style:Mr,children:e.jsxs("div",{style:Dg,children:[e.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),e.jsx("button",{onClick:()=>d("idle"),style:Ug,children:n("feedback.continueSubmit")})]})}):e.jsxs("div",{style:Mr,children:[e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:Mg.map(k=>e.jsxs("button",{onClick:()=>r(k.value),style:{...Wg,...o===k.value?Hg:{}},children:[e.jsx("span",{children:k.icon})," ",n(`feedback.submitType.${k.value}`)]},k.value))}),e.jsx("textarea",{ref:m,value:s,onChange:k=>l(k.target.value),placeholder:n(o?`feedback.placeholder.${o}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...Og}}),e.jsx("input",{type:"text",value:a,onChange:k=>p(k.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:Gg}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[s.length," / 2000"]}),e.jsx("button",{onClick:x,disabled:!f,style:{...Fg,opacity:f?1:.6,cursor:f?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&e.jsx("div",{style:Vg,children:u})]})},Mr={padding:"16px",border:`1px solid ${i("widget-border")}`,borderRadius:"8px",background:i("input-bg")},Wg={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"},Hg={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},Og={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"},Fg={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},Dg={display:"flex",alignItems:"center",gap:"12px",color:i("success"),fontSize:"14px"},Ug={background:"none",border:"none",color:i("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},Vg={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginTop:"8px"},Gg={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 Wr(t){return typeof t=="function"?t():t??"/api/feedback"}const ra=({resourceId:t,apiUrl:n})=>{const{t:o}=Y(),[r,s]=h.useState([]),[l,a]=h.useState(!0),p=h.useCallback(async()=>{const d=Wr(n);a(!0);try{const g=await(await fetch(`${d}?resourceId=${encodeURIComponent(t)}`)).json();g.success&&s(g.items)}catch{}finally{a(!1)}},[t,n]);h.useEffect(()=>{p()},[p]);const c=async d=>{const u=Wr(n),g=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...d,pageUrl:typeof window<"u"?window.location.href:"",resourceId:t})});if(!g.ok){const m=await g.json().catch(()=>null);throw new Error((m==null?void 0:m.error)||o("feedback.submitFailed"))}setTimeout(()=>p(),500)};return e.jsxs("div",{children:[e.jsx(ko,{items:r,loading:l}),e.jsx("div",{style:{marginTop:"24px"},children:e.jsx(oa,{onSubmit:c})})]})},Yg=En["zh-Hant"].relation,Kg=En["zh-Hant"].lossStatus,qg=En["zh-Hant"].resourceKind,Yn=Dt("zh-Hant"),wo=(t,n)=>Object.prototype.hasOwnProperty.call(t,n);function Hr(t,n=Yn){return t?wo(Yg,t)?n(`detail.relation.${t}`):t:n("detail.relation.related")}function Zg(t,n=Yn){return wo(Kg,t)?n(`detail.lossStatus.${t}`):t}function Jg(t,n=Yn){return wo(qg,t)?n(`detail.resourceKind.${t}`):""}function So({authors:t,onNavigate:n,renderLink:o}){const{convert:r}=Y(),s=(t||[]).filter(l=>l&&l.name);return s.length?e.jsx(e.Fragment,{children:s.map((l,a)=>{const p=io(l.role);return e.jsxs(h.Fragment,{children:[a>0&&" ",l.dynasty&&e.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",r(l.dynasty),"〕"]}),l.entity_id?e.jsx(Ge,{id:l.entity_id,label:r(l.name),onNavigate:n,renderLink:o,dense:!0}):r(l.name),p&&e.jsx("span",{style:{marginLeft:4},children:r(p)})]},a)})}):null}function sa(t,n,o=Yn){var c,d;const r=to(t,n),s=r.mirrors.map(u=>({key:u.key,label:u.label,description:u.description,rows:u.items.filter(g=>g.group_role!=="mirror"),mirrors:u.items.filter(g=>g.group_role==="mirror")})),l=r.buckets.filter(u=>u.key==="image"||u.key==="textImage").flatMap(u=>u.items);l.length&&s.push({key:"_images",label:s.length?o("detail.otherImages"):void 0,rows:l,mirrors:[]});const a=((c=r.buckets.find(u=>u.key==="physical"))==null?void 0:c.items)??[];return a.length&&s.push({key:"_physical",label:o("detail.resourceKind.physical"),rows:a,mirrors:[]}),{text:((d=r.buckets.find(u=>u.key==="text"))==null?void 0:d.items)??[],groups:s}}function la(t,n){const o=(t.url?Ut(t.url):void 0)||t.name,r=cl(t,n);return r?`${o}(${r})`:o}function $o({item:t,siblings:n,listedVolumeCounts:o}){const{t:r,convert:s}=Y(),[l,a]=h.useState(!1),p=Ln(t),c=!!p&&p.expected>0&&!(o!=null&&o.has(p.expected)),d=s(la(t,n)),u=Vt(t),g=Fn(t,r)||t.details;return e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var x,f;const m=(x=t.metadata)!=null&&x.fragment||t.color_mode?e.jsxs("span",{className:"bim-d-tags bim-d-ui",style:{display:"inline-flex",margin:"0 0 0 8px",verticalAlign:"middle"},children:[((f=t.metadata)==null?void 0:f.fragment)&&e.jsx("span",{className:"bim-d-tag",children:r("detail.fragmentTag")}),t.color_mode&&e.jsx("span",{className:"bim-d-tag",children:t.color_mode==="color"?r("colorMode.color"):r("colorMode.bw")})]}):null;return u?e.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:[d," ",e.jsx("span",{"aria-hidden":"true",children:"↗"}),m]}):e.jsxs("span",{className:"bim-d-zt-name",children:[d,m]})})(),g&&e.jsx("span",{className:"bim-d-meta",children:s(g)}),c&&l&&e.jsx("div",{style:{padding:"0 12px 10px"},children:e.jsx(ao,{item:t})})]}),e.jsx("td",{className:c?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:c&&e.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":l,onClick:()=>a(m=>!m),children:l?r("detail.collapseVolumes"):r("detail.expandVolumes",{n:p.expected})})})]})}function aa({groups:t,listedVolumeCounts:n}){const{t:o,convert:r}=Y();return e.jsx(e.Fragment,{children:t.map(s=>e.jsxs("div",{className:"bim-d-rg",children:[s.label&&e.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:r(s.label)}),s.description&&e.jsx("p",{className:"bim-d-rg-d",children:r(s.description)}),s.rows.length>0&&e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:s.rows.map((l,a)=>e.jsx($o,{item:l,siblings:s.rows,listedVolumeCounts:n},`${l.id||l.url||l.name}-${a}`))})}),s.mirrors.length>0&&e.jsxs("div",{className:"bim-d-rg-mir bim-d-ui",children:[s.rows.length>0&&e.jsx("span",{className:"bim-d-meta",style:{marginRight:10},children:o("detail.mirror")}),s.mirrors.map((l,a)=>{const p=Vt(l),c=r(la(l,s.mirrors));return p?e.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",title:l.details?r(l.details):void 0,children:[c," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]},a):e.jsx("span",{style:{marginRight:14},children:c},a)})]})]},s.key))})}const an=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function Pi(t){var o;if(!t)return;const n=t.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(o=an.find(r=>n.startsWith(r.key[0])))==null?void 0:o.key}const Or=12,Xg=60,ca=({data:t,transport:n,onNavigate:o,renderLink:r,readAction:s,railTop:l,back:a,railLinks:p})=>{var Ee,ze,He;const{t:c,convert:d,messages:u}=Y(),g=h.useMemo(()=>[...t.books||[],...t.collections||[]],[t.books,t.collections]),[m,x]=h.useState(new Map),[f,k]=h.useState(!1),[b,w]=h.useState(""),[y,j]=h.useState(!1),S=g.length<=Xg,v=S||f||!!b||y,$=h.useMemo(()=>v?g:g.slice(0,Or),[g,v]);h.useEffect(()=>{if(!n||$.length===0)return;const D=$.filter(ce=>!m.has(ce));if(D.length===0)return;let re=!1;return Promise.all(D.map(ce=>n.getItem(ce).then(we=>{const F=we??{};return[ce,{id:ce,title:F.title,edition:F.edition,resources:F.resources,publication_info:F.publication_info,current_location:F.current_location,lineage:F.lineage,measure_info:F.measure_info}]}).catch(()=>[ce,{id:ce}]))).then(ce=>{re||x(we=>{const F=new Map(we);for(const[fe,Re]of ce)F.set(fe,Re);return F})}),()=>{re=!0}},[n,$,m]);const C=h.useMemo(()=>g.map(D=>m.get(D)??{id:D}),[g,m]),z=g.length>0&&g.every(D=>m.has(D)),E=!!n&&$.some(D=>!m.has(D)),T=S||v,_=h.useMemo(()=>pl(C,t.version_graph,{era:b,scanOnly:y,sort:T?"year":"default"}),[C,t.version_graph,b,y,T]),O=f?_.rows:_.rows.slice(0,Or),W=_.allRows.filter(D=>D.hasImage).length,A=t.related_works||[],G=A.filter(D=>D.relation==="collected_in"),V=h.useMemo(()=>{const D=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],re=ce=>{const we=D.indexOf(ce??"");return we<0?D.length:we};return A.filter(ce=>ce.relation!=="collected_in").map((ce,we)=>({r:ce,i:we})).sort((ce,we)=>re(ce.r.relation)-re(we.r.relation)||ce.i-we.i).map(ce=>ce.r)},[A]),ie=h.useMemo(()=>{const D=to(t.resources,t.resource_groups);return[...D.mirrors.flatMap(re=>re.items.map(ce=>({r:ce,kind:d(re.label)}))),...D.buckets.flatMap(re=>re.items.map(ce=>({r:ce,kind:d(Jg(re.key,c))})))]},[t.resources,t.resource_groups,d,c]),ae=t.indexed_by||[],P=t.emendated_by||[],I=h.useMemo(()=>{var ee,he,L;const D=[],re=(he=(ee=t.authors)==null?void 0:ee[0])==null?void 0:he.dynasty;re&&D.push({label:c("workPage.fact.written"),value:d(re)});const ce=bt(t,u.unit.juan);if(ce){const X=(L=t.juan_count)==null?void 0:L.description;D.push({label:c("workPage.fact.measure"),value:e.jsxs(e.Fragment,{children:[d(ce),X&&X!==ce?e.jsxs("span",{className:"bim-d-meta",children:["(",d(X),")"]}):null]})})}t.loss_status&&D.push({label:c("workPage.fact.loss"),value:d(Zg(t.loss_status,c))});const we=_.allRows.filter(X=>X.sortYear!=null),F=we.length>0?we.reduce((X,U)=>X.sortYear<=U.sortYear?X:U):null;F!=null&&F.era.era?D.push({label:c("workPage.fact.earliest"),value:d([F.era.era,F.era.reign].filter(Boolean).join(" ")),title:F.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):E&&D.push({label:c("workPage.fact.earliest"),value:e.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),P.length&&D.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:P.length})});const fe=Fr(t.additional_titles);fe.length&&D.push({label:c("workPage.fact.alias"),value:fe.map(d).join("、")});const Re=Fr(t.attached_texts);Re.length&&D.push({label:c("workPage.fact.attached"),value:Re.map(d).join("、")});const R=(t.additional_works||[]).map(X=>d(X.book_title)+(X.n_juan!=null?` ${X.n_juan}${u.unit.juan}`:""));return R.length&&D.push({label:c("workPage.fact.appendix"),value:R.join("、")}),D},[t,d,c,u,E,_.allRows,P.length]),Q=[{value:t._edition_count??g.length,label:c("workPage.stat.editions")},{value:z?W:0,label:c("workPage.stat.hasImage")},{value:ae.length,label:c("workPage.stat.catalogs")}],oe=t.classification,je=oe?[oe.l1,oe.l2,oe.l3,oe.l4].filter(Boolean).map(D=>d(D)):[],Ie=t.subtype?u.workSubtype[t.subtype]??d(t.subtype):"",K=e.jsx(un,{title:d(t.title),byline:e.jsx(So,{authors:t.authors,onNavigate:o,renderLink:r}),meta:e.jsx(qe,{items:[...je,oe!=null&&oe.source?c("workPage.classifiedBy",{source:d(oe.source.split("/")[0])}):"",Ie]}),description:(Ee=t.description)!=null&&Ee.text?e.jsxs(e.Fragment,{children:[e.jsx(ft,{text:t.description.text,style:{fontSize:15,lineHeight:1.85}}),(ze=t.description.sources)!=null&&ze.length?e.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:t.description.sources.map(D=>d(Qp(D))).filter(Boolean).join(" · ")}):null]}):void 0,stats:Q,facts:I,readAction:s,foot:e.jsx(mn,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo}),children:(He=t.appendix)==null?void 0:He.map((D,re)=>e.jsxs("details",{style:{marginTop:12},children:[e.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:d(D.title)}),e.jsx(ft,{text:D.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},re))}),me=_.eras.length>=2?[{key:"",label:c("catalog.all")},..._.eras.map(D=>({key:D,label:`${D} ${_.allRows.filter(re=>re.era.era===D).length}`}))]:[],M=[];g.length&&M.push({id:"versions",label:c("workPage.sec.versions"),count:g.length}),ae.length&&M.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:ae.length}),G.length&&M.push({id:"collected",label:c("workPage.sec.collected"),count:G.length}),V.length&&M.push({id:"related",label:c("workPage.sec.related"),count:V.length}),ie.length&&M.push({id:"resources",label:c("workPage.sec.resources"),count:ie.length});const ue=g.length===0&&ae.length===0,ge=e.jsxs(e.Fragment,{children:[g.length>0&&e.jsxs(Ze,{id:"versions",title:c("workPage.sec.versions"),meta:e.jsx(qe,{items:[c("workPage.versionsTotal",{n:g.length}),z&&W?c("workPage.versionsWithImage",{n:W}):"",_.rows.length!==_.allRows.length?c("workPage.versionsCurrent",{n:_.rows.length}):""]}),children:[e.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":E&&me.length===0&&g.length>1?"":void 0,children:[me.length>0&&e.jsx(Un,{items:me,value:b,onChange:D=>{w(D),k(!1)}}),e.jsx("span",{className:"bim-d-spacer"}),e.jsx(bl,{label:c("workPage.scanOnly"),checked:y,onChange:D=>{j(D),k(!1)}}),e.jsx("span",{className:"bim-d-meta",children:c(T?"workPage.sortByYear":"workPage.sortByCatalog")})]}),e.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!f&&Vn(_.rows.length)?"":void 0,children:[e.jsx("thead",{className:"bim-d-ui",children:e.jsxs("tr",{children:[e.jsx("th",{children:c("workPage.col.edition")}),e.jsx("th",{children:c("workPage.col.era")}),e.jsx("th",{children:c("workPage.col.holder")}),e.jsx("th",{children:e.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:c("workPage.col.image")})})]})}),e.jsx("tbody",{children:O.map(D=>{var re;return e.jsx(Qg,{row:D,measure:(re=m.get(D.id))==null?void 0:re.measure_info,loaded:m.has(D.id),onNavigate:o,renderLink:r},`${D.id}:${m.has(D.id)?"r":"p"}`)})})]}),O.length===0&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c(b||y?"workPage.noVersionsFiltered":"workPage.noVersions")}),!f&&e.jsx(oo,{total:_.rows.length,shown:O.length,unit:c("workPage.moreUnit"),onClick:()=>k(!0)}),_.hasInferredEra&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),ae.length>0&&e.jsx(eh,{items:ae,transport:n,onNavigate:o,renderLink:r}),ue&&e.jsx(Ze,{title:c("workPage.sec.versions"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),de=(D,re)=>e.jsx(Ge,{id:D,label:d(re),onNavigate:o,renderLink:r,dense:!0}),Le=h.useMemo(()=>{const D=new Map;for(const re of V){const ce=Hr(re.relation,c);D.set(ce,(D.get(ce)??0)+1)}return D.size>1?[...D.entries()].sort((re,ce)=>ce[1]-re[1]).slice(0,4).map(([re,ce])=>`${d(re)} ${ce}`).join(" · "):void 0},[V,d,c]),Me=e.jsxs(e.Fragment,{children:[e.jsx(zt,{id:"collected",title:c("workPage.sec.collected"),items:G.map(D=>de(D.id,D.title))}),e.jsx(zt,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:V.length}),sub:Le,items:V.map(D=>e.jsxs(e.Fragment,{children:[de(D.id,D.title),e.jsx("span",{className:"bim-d-meta",title:D.note?d(D.note):void 0,children:d(Hr(D.relation,c))})]}))}),e.jsx(zt,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:ie.map(({r:D,kind:re})=>{const ce=d((D.url?Ut(D.url):void 0)||D.name),we=Vt(D);return e.jsxs(e.Fragment,{children:[we?e.jsxs("a",{href:we,target:"_blank",rel:"noopener noreferrer",children:[ce," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]}):e.jsx("span",{children:ce}),re&&e.jsx("span",{className:"bim-d-meta bim-d-kind",children:re})]})})})]});return e.jsx(pn,{railTop:l,back:a,nav:M,railLinks:p,main:ge,card:K,side:Me})};function Fr(t){return(t||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Dr(t,n){return n((t.url?Ut(t.url):void 0)||t.name)}function Qg({row:t,measure:n,loaded:o,onNavigate:r,renderLink:s}){const{t:l,convert:a}=Y(),p=[t.era.era,t.era.reign].filter(Boolean).join(" "),c=t.era.source==="edition",d=t.holders[0],u=d?Dr(d,a):t.locationName?a(t.locationName):"",g=t.images[0],m=g?Vt(g):void 0,x=t.images.map(f=>Dr(f,a)).join("、");return e.jsxs("tr",{"data-loading":o?void 0:"",children:[e.jsxs("td",{className:"bim-d-zt-main",children:[e.jsx(Ge,{id:t.id,label:a(t.name),onNavigate:r,renderLink:s,dense:!0}),n?e.jsx("span",{className:"bim-d-meta",children:a(n)}):e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "})]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${p?"":" bim-d-zt-blank"}`,title:c?l("workPage.inferredFromEdition"):void 0,children:p?a(p):o?e.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),e.jsxs("td",{className:`bim-d-zt-sub${u?"":" bim-d-zt-blank"}`,children:[u||(o?e.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),t.holders.length>1&&e.jsxs("span",{className:"bim-d-meta",children:[" +",t.holders.length-1]})]}),e.jsx("td",{className:t.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:t.hasImage&&(m?e.jsx("a",{className:"bim-d-flag",href:m,target:"_blank",rel:"noopener noreferrer",title:x,children:l("workPage.hasImage")}):e.jsx("span",{className:"bim-d-flag",title:x,children:l("workPage.hasImage")}))})]})}function eh({items:t,transport:n,onNavigate:o,renderLink:r}){const{t:s,convert:l}=Y(),[a,p]=h.useState(0),c=Math.min(a,t.length-1),d=t[c],[u,g]=h.useState(new Map);return h.useEffect(()=>{if(!n)return;const m=[...new Set(t.map(f=>f.source_bid).filter(f=>!!f))];if(m.length===0)return;let x=!1;return Promise.all(m.map(f=>n.getItem(f).then(k=>{var b,w;return[f,((w=(b=k==null?void 0:k.authors)==null?void 0:b[0])==null?void 0:w.dynasty)??""]}).catch(()=>[f,""]))).then(f=>{x||g(new Map(f.filter(([,k])=>k)))}),()=>{x=!0}},[n,t]),e.jsx(Ze,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:e.jsx(qe,{items:[s("workPage.catalog.meta",{n:t.length}),s("workPage.sortByCatalog")]}),children:e.jsxs("div",{className:"bim-d-lu",children:[e.jsx("ul",{className:"bim-d-tl2 bim-d-ui",role:"tablist","aria-label":s("workPage.catalog.tablist"),children:t.map((m,x)=>e.jsx("li",{role:"presentation",children:e.jsxs("button",{type:"button",role:"tab","aria-selected":x===c,"aria-label":l(m.source),onClick:()=>p(x),children:[e.jsx("span",{className:"bim-d-tl2-dyn",children:u.get(m.source_bid??"")?l(u.get(m.source_bid??"")):" "}),e.jsx("i",{className:"bim-d-tl2-dot","aria-hidden":"true"}),e.jsx("span",{className:"bim-d-tl2-name","aria-hidden":"true",children:[...l(m.source)].slice(0,9).map((f,k)=>e.jsx("span",{children:f},k))})]})},x))}),e.jsxs("div",{className:"bim-d-lu-body",role:"tabpanel",children:[d.title_info&&e.jsx("div",{className:"bim-d-lu-title",children:l(d.title_info)}),e.jsx(qe,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[d.source_bid?e.jsx(Ge,{id:d.source_bid,label:l(d.source),onNavigate:o,renderLink:r,dense:!0}):l(d.source),d.section?l(d.section):"",d.author_info?`${s("label.authorInfo")} ${l(d.author_info)}`:"",d.edition?`${s("label.edition")} ${l(d.edition)}`:"",d.page??""]}),d.summary&&e.jsx("p",{className:"bim-d-quote",children:ot(l(d.summary),void 0,{t:s})}),d.comment&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.comment")}),e.jsx("p",{className:"bim-d-quote",children:ot(l(d.comment),void 0,{t:s})})]}),d.additional_comment&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.additionalComment")}),e.jsx("p",{className:"bim-d-quote",children:ot(l(d.additional_comment),void 0,{t:s})})]}),!d.summary&&!d.comment&&!d.additional_comment&&!d.title_info&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{marginTop:12},children:s("workPage.catalog.titleOnly")}),t.length>1&&e.jsxs("div",{className:"bim-d-lu-pager bim-d-ui",children:[c>0?e.jsx("button",{type:"button","aria-label":s("workPage.catalog.prev",{name:l(t[c-1].source)}),onClick:()=>p(c-1),children:e.jsxs("span",{"aria-hidden":"true",children:["← ",l(t[c-1].source)]})}):e.jsx("span",{"aria-hidden":"true"}),e.jsxs("span",{className:"bim-d-meta",children:[c+1," / ",t.length]}),c<t.length-1?e.jsx("button",{type:"button","aria-label":s("workPage.catalog.next",{name:l(t[c+1].source)}),onClick:()=>p(c+1),children:e.jsxs("span",{"aria-hidden":"true",children:[l(t[c+1].source)," →"]})}):e.jsx("span",{"aria-hidden":"true"})]})]})]})})}function th(t){var n;return{id:t.id,kind:"hypothetical",label:t.label,year:t.year??((n=t.year_range)==null?void 0:n[0]),year_range:t.year_range,year_uncertain:t.year_uncertain,group:t.group,note:t.note,description:t.description}}function nh(t,n){if(!t.lineage)return null;const o=t.lineage;return{id:t.id,kind:"book",label:t.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[t.id],note:o.note}}function Ur(t,n,o){return{id:`derive:${n.ref}->${t}:${o}`,source:n.ref,target:t,kind:"derive",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function ih(t,n,o){const[r,s]=[t,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 oh(t,n){var d;if(n==="all")return null;const o=(d=t.collections)==null?void 0:d[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,l=r||s||!!(o!=null&&o.hypothetical_ids);if(!l&&n==="core"&&Array.isArray(t.core_books)&&t.core_books.length>0)return{books:new Set(t.core_books),hypos:t.core_hypotheticals?new Set(t.core_hypotheticals):null};if(!o||!l)return null;const a=r?new Set(o.groups):null,p=new Set(o.book_ids??[]);if(a&&t.node_groups)for(const[u,g]of Object.entries(t.node_groups))a.has(g)&&p.add(u);let c=null;if(o.hypothetical_ids&&(c=new Set(o.hypothetical_ids)),a){c||(c=new Set);for(const u of t.hypothetical_nodes??[])u.group&&a.has(u.group)&&c.add(u.id)}return{books:p,hypos:c}}function $n(t,n,o){const r=t.version_graph,s={nodes:[],edges:[],groups:[],layout:"LR",excluded:[]};if(!r||!r.enabled)return s;const l=new Set(r.excluded_books??[]),a=r.node_groups??{},p=oh(r,o??r.default_collection??"all"),c=p!==null,d=(p==null?void 0:p.books)??null,u=(p==null?void 0:p.hypos)??null,g=new Set,m=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 _=S.get(T);if(_&&_.lineage)return(_.lineage.derived_from??[]).map(W=>W.ref);const O=v.get(T);return O?(O.derived_from??[]).map(W=>W.ref):[]},C=T=>v.has(T)?!u||u.has(T):!d||d.has(T),z=new Set,E=T=>{if(!z.has(T)){z.add(T);for(const _ of $(T))l.has(_)||(C(_)||(v.has(_)?m.add(_):S.has(_)&&g.add(_)),E(_))}};for(const T of n)d&&d.has(T.id)&&!l.has(T.id)&&E(T.id);for(const T of r.hypothetical_nodes??[])u&&u.has(T.id)&&E(T.id)}const x=n.filter(S=>!l.has(S.id)).filter(S=>!d||d.has(S.id)||g.has(S.id)).map(S=>{const v=nh(S,a);return v&&g.has(S.id)&&(v.bridge=!0),v}).filter(S=>S!==null),f=(r.hypothetical_nodes??[]).filter(S=>!u||u.has(S.id)||m.has(S.id)).map(S=>{const v=th(S);return m.has(S.id)&&(v.bridge=!0),v}),k=[...x,...f],b=new Set(k.map(S=>S.id)),w=new Set,y=[],j=S=>{w.has(S.id)||!b.has(S.source)||!b.has(S.target)||(w.add(S.id),y.push(S))};for(const S of n)l.has(S.id)||!S.lineage||d&&!d.has(S.id)&&!g.has(S.id)||((S.lineage.derived_from??[]).forEach((v,$)=>{j(Ur(S.id,v,$))}),(S.lineage.related_to??[]).forEach((v,$)=>{j(ih(S.id,v,$))}));for(const S of r.hypothetical_nodes??[])u&&!u.has(S.id)&&!m.has(S.id)||(S.derived_from??[]).forEach((v,$)=>{j(Ur(S.id,v,$))});return{nodes:k,edges:y,groups:r.groups??[],title:r.title,description:r.description,layout:r.layout??"LR",excluded:Array.from(l)}}function da(t,n,o){const r=(t??(n!=null?String(n):"")).trim();return r?!o||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(r)?r:`约 ${r}`:""}function rh(t,n){const o=[],r=t.version_graph;if(!r)return o;const s=new Set(n.map(c=>c.id)),l=new Set((r.hypothetical_nodes??[]).map(c=>c.id)),a=new Set([...s,...l]),p=(c,d)=>{a.has(d.ref)||o.push(`${c}: derived_from.ref "${d.ref}" 未在 books 或 hypothetical_nodes 中找到`),d.ref_type==="book"&&!s.has(d.ref)&&o.push(`${c}: derived_from.ref "${d.ref}" 标记为 book 但不在 books 列表中`),d.ref_type==="hypothetical"&&!l.has(d.ref)&&o.push(`${c}: derived_from.ref "${d.ref}" 标记为 hypothetical 但不在 hypothetical_nodes 中`)};for(const c of n){if(!c.lineage)continue;const d=`Book ${c.id} (${c.title})`;(c.lineage.derived_from??[]).forEach(u=>p(d,u)),(c.lineage.related_to??[]).forEach(u=>{s.has(u.book_id)||o.push(`${d}: related_to.book_id "${u.book_id}" 不在 books 列表中`)})}for(const c of r.hypothetical_nodes??[]){const d=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(u=>p(d,u))}return o}const pa=({graph:t,renderLink:n,className:o,style:r})=>{const{t:s,convert:l}=Y();if(!t.nodes.length)return e.jsx("div",{style:{...yh,...r},className:o,children:s("lineage.emptyGraph")});const a=new Map,p=new Map;for(const x of t.edges)if(x.kind==="derive"){const f=a.get(x.target)??[];f.push(x),a.set(x.target,f)}else for(const f of[x.source,x.target]){const k=p.get(f)??[];k.push(x),p.set(f,k)}const c=new Map(t.nodes.map(x=>[x.id,x])),d=new Map,u=[];for(const x of t.nodes)if(x.group){const f=d.get(x.group)??[];f.push(x),d.set(x.group,f)}else u.push(x);const g=(x,f)=>(x.year??9999)-(f.year??9999);d.forEach(x=>x.sort(g)),u.sort(g);const m=t.groups.filter(x=>d.has(x.id));return e.jsxs("div",{className:o,style:{...lh,...r},children:[t.title&&e.jsx("div",{style:ah,children:l(t.title)}),t.description&&e.jsx("div",{style:ch,children:l(t.description)}),m.map(x=>e.jsx(Vr,{label:x.label,color:x.color,nodes:d.get(x.id),incomingMap:a,siblingMap:p,nodeMap:c,renderLink:n},x.id)),u.length>0&&e.jsx(Vr,{label:s("lineage.otherGroup"),nodes:u,incomingMap:a,siblingMap:p,nodeMap:c,renderLink:n})]})},Vr=({label:t,color:n,nodes:o,incomingMap:r,siblingMap:s,nodeMap:l,renderLink:a})=>{const{convert:p}=Y();return e.jsxs("div",{style:dh,children:[e.jsx("div",{style:{...ph,borderLeftColor:n??i("widget-border")},children:p(t)}),o.map(c=>e.jsx(sh,{node:c,incoming:r.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:l,renderLink:a},c.id))]})},sh=({node:t,incoming:n,siblings:o,nodeMap:r,renderLink:s})=>{const l=t.kind==="hypothetical",a=t.bridge,{t:p,convert:c}=Y();return e.jsxs("div",{style:{...uh,borderStyle:l||a?"dashed":"solid",opacity:a?.55:t.status==="lost"?.7:1,background:a?i("bg-subtle"):void 0},title:a?p("lineage.bridgeTitle"):void 0,children:[e.jsxs("div",{style:mh,children:[e.jsx("span",{style:gh,children:l||!s?c(t.label):s(t.id,c(t.label))}),(t.year_text||t.year!=null)&&e.jsx("span",{style:hh,children:da(c(t.year_text),t.year,t.year_uncertain)})]}),e.jsxs("div",{style:xh,children:[t.category&&e.jsx(en,{children:c(t.category)}),t.status==="lost"&&e.jsx(en,{tone:"warn",children:p("lineage.lost")}),t.status==="fragment"&&e.jsx(en,{tone:"warn",children:p("lineage.fragment")}),l&&e.jsx(en,{tone:"info",children:p("lineage.hypothetical")}),a&&e.jsx(en,{tone:"info",children:p("lineage.bridge")})]}),t.extant_juan&&e.jsx("div",{style:fh,children:p("lineage.extant",{juan:c(t.extant_juan)})}),t.note&&e.jsx("div",{style:bh,children:c(t.note)}),n.length>0&&e.jsxs("div",{style:Yr,children:[e.jsx("div",{style:Kr,children:p("lineage.sources")}),n.map(d=>{const u=r.get(d.source);return e.jsxs("div",{style:qr(d.confidence),children:[e.jsx("span",{style:Zr,children:c(d.relation)}),e.jsx("span",{children:(u==null?void 0:u.kind)==="book"&&s?s(u.id,c(u.label)):c((u==null?void 0:u.label)??d.source)}),d.confidence!=="consensus"&&d.confidence!=="certain"&&e.jsx(Gr,{level:d.confidence}),d.evidence&&e.jsxs("span",{style:Jr,children:["· ",c(d.evidence)]})]},d.id)})]}),o.length>0&&e.jsxs("div",{style:Yr,children:[e.jsx("div",{style:Kr,children:p("lineage.related")}),o.map(d=>{const u=d.source===t.id?d.target:d.source,g=r.get(u);return e.jsxs("div",{style:qr(d.confidence),children:[e.jsx("span",{style:Zr,children:c(d.relation)}),e.jsx("span",{children:(g==null?void 0:g.kind)==="book"&&s?s(g.id,c(g.label)):c((g==null?void 0:g.label)??u)}),e.jsx(Gr,{level:d.confidence}),d.evidence&&e.jsxs("span",{style:Jr,children:["· ",c(d.evidence)]})]},d.id)})]})]})},en=({children:t,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 e.jsx("span",{style:{display:"inline-block",padding:"1px 8px",fontSize:"11px",borderRadius:"10px",background:r.bg,color:r.fg,marginRight:"4px"},children:t})},Gr=({level:t})=>{const{t:n}=Y(),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")}}[t];return r?e.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},lh={fontSize:"14px",color:i("fg")},ah={fontSize:"16px",fontWeight:600,marginBottom:"8px"},ch={fontSize:"13px",color:i("muted"),marginBottom:"16px",lineHeight:1.6},dh={marginBottom:"16px"},ph={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:i("fg")},uh={border:`1px solid ${i("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:i("bg")},mh={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},gh={fontSize:"15px",fontWeight:600},hh={fontSize:"12px",color:i("muted")},xh={marginBottom:"6px"},fh={fontSize:"12px",color:i("muted"),margin:"2px 0"},bh={fontSize:"12px",color:i("muted"),fontStyle:"italic",margin:"4px 0"},Yr={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${i("widget-border")}`},Kr={fontSize:"11px",color:i("muted"),marginBottom:"2px"},qr=t=>({fontSize:"12px",margin:"2px 0",opacity:t==="probable"||t==="disputed"?.85:1}),Zr={display:"inline-block",padding:"0 6px",fontSize:"11px",background:i("tag-bg"),color:i("fg"),borderRadius:"3px",marginRight:"6px"},Jr={fontSize:"11px",color:i("muted")},yh={padding:"20px",textAlign:"center",color:i("muted"),fontSize:"13px"},ua=({selectedNodeId:t,...n})=>{const{t:o}=Y(),[r,s]=h.useState("loading"),[l,a]=h.useState(null);return h.useEffect(()=>{let p=!1;return jh().then(c=>{p||(c?(a(c),s("ready")):s("missing"))}),()=>{p=!0}},[]),r==="loading"?e.jsx("div",{style:Qr,children:o("lineage.graphLoading")}):r==="missing"||!l?e.jsxs("div",{style:Qr,children:[e.jsx("div",{children:Xr(o("lineage.graphMissing"),{xyflow:e.jsx("code",{children:"@xyflow/react"}),dagre:e.jsx("code",{children:"@dagrejs/dagre"})})}),e.jsx("div",{style:{fontSize:"12px",marginTop:"4px"},children:Xr(o("lineage.graphMissingHint"),{list:e.jsx("code",{children:"VersionLineageList"})})})]}):e.jsx(vh,{modules:l,selectedNodeId:t,...n})};function Xr(t,n){return t.split(/(\{\w+\})/).map((o,r)=>{const s=/^\{(\w+)\}$/.exec(o);return e.jsx(h.Fragment,{children:s&&s[1]in n?n[s[1]]:o},r)})}async function jh(){try{const[t,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:t.ReactFlow,Background:t.Background,Controls:t.Controls,Handle:t.Handle,Position:t.Position,BaseEdge:t.BaseEdge,EdgeLabelRenderer:t.EdgeLabelRenderer,getSmoothStepPath:t.getSmoothStepPath,dagre:n,cssLoaded:o}}catch{return null}}const vh=({graph:t,renderLink:n,height:o=600,className:r,style:s,selectedNodeId:l,modules:a})=>{const{ReactFlow:p,Background:c,Controls:d,Handle:u,Position:g,BaseEdge:m,EdgeLabelRenderer:x,getSmoothStepPath:f,dagre:k}=a,b=h.useMemo(()=>({lineage:$=>{var V,ie,ae,P;const C=((V=$.data)==null?void 0:V.stepPosition)??.85,[z,E,T]=f({sourceX:$.sourceX,sourceY:$.sourceY,sourcePosition:$.sourcePosition,targetX:$.targetX,targetY:$.targetY,targetPosition:$.targetPosition,stepPosition:C,borderRadius:5}),_=!!((ie=$.data)!=null&&ie.isSibling),O=_?E:$.targetX-18,W=_?T:$.targetY-12,A=(ae=$.data)==null?void 0:ae.labelStyle,G=(P=$.data)==null?void 0:P.labelBgStyle;return e.jsxs(e.Fragment,{children:[e.jsx(m,{id:$.id,path:z,style:$.style,markerStart:$.markerStart,markerEnd:$.markerEnd}),$.label&&e.jsx(x,{children:e.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${O}px,${W}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:i("bg"),border:`0.5px solid ${i("widget-border")}`,...G,...A},children:$.label})})]})}}),[m,x,f]),w=h.useMemo(()=>({version:$=>{const{t:C}=Y(),z=$.data,E=z.kind==="hypothetical",T=z.status==="lost",_=z.isSelected,O=z.bridge,W=z.borderColor??i("muted"),A=O||E?"dashed":"solid",G=O?.5:T?.6:1;return e.jsxs("div",{style:{background:i(O?"bg-subtle":"bg"),border:`2px ${A} ${_?i("primary"):W}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:G,boxShadow:_?i("shadow-node-selected"):E||O?"none":i("shadow-node")},title:O?C("lineage.bridgeTitle"):void 0,children:[e.jsx(u,{type:"target",position:g.Left,style:{visibility:"hidden"}}),e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:E||!z.renderLink?z.label:z.renderLink(z.bookId,z.label)}),z.description&&e.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.25,marginTop:1},children:z.description}),z.yearText&&e.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.2},children:da(z.yearText,void 0,z.uncertain)}),T&&e.jsx("div",{style:{fontSize:9,color:i("lost-fg"),marginTop:1},children:C("lineage.lost")}),e.jsx(u,{type:"source",position:g.Right,style:{visibility:"hidden"}})]})}}),[u,g]),{convert:y}=Y(),{rfNodes:j,rfEdges:S}=h.useMemo(()=>kh(t,k,n,l,y),[t,k,n,l,y]);return e.jsx("div",{style:{width:"100%",height:o,...s},className:r,children:e.jsxs(p,{nodes:j,edges:S,nodeTypes:w,edgeTypes:b,fitView:!0,fitViewOptions:{padding:.15},proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,minZoom:.2,maxZoom:1.8,children:[e.jsx(c,{gap:16}),e.jsx(d,{showInteractive:!1})]})})};function kh(t,n,o,r,s=l=>l??""){const p=t.layout==="LR"||!t.layout,c=new n.graphlib.Graph;c.setGraph({rankdir:p?"LR":"TB",ranksep:160,nodesep:40,edgesep:16,marginx:20,marginy:20}),c.setDefaultEdgeLabel(()=>({}));const d=new Map(t.groups.map(w=>[w.id,w.color??i("muted")]));for(const w of t.nodes)c.setNode(w.id,{width:160,height:90});const u=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const w of t.edges)w.kind==="derive"&&(u.has(w.relation)||c.setEdge(w.source,w.target));n.layout(c);const g=t.nodes.map(w=>{const y=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??Sh(w)),uncertain:w.year_uncertain,category:w.category,status:w.status,borderColor:w.group?d.get(w.group):void 0,renderLink:o,isSelected:j,description:s(w.description),bridge:w.bridge};return{id:w.id,type:"version",position:{x:y.x-160/2,y:y.y-90/2},data:S,draggable:!1,selected:j}}),m=.78,x=.06,f=new Map;for(const w of t.edges)w.kind==="derive"&&(f.has(w.source)||f.set(w.source,[]),f.get(w.source).push(w));const k=new Map;for(const[w,y]of f){if(y.length<=1)continue;const j=[...y].sort((v,$)=>{var E,T;const C=((E=c.node(v.target))==null?void 0:E.y)??0,z=((T=c.node($.target))==null?void 0:T.y)??0;return C-z}),S=j.length;j.forEach((v,$)=>{const C=($-(S-1)/2)*x;k.set(v.id,m+C)})}const b=t.edges.map(w=>wh(w,k.get(w.id),s));return{rfNodes:g,rfEdges:b}}function wh(t,n,o=r=>r??""){const r=t.confidence==="probable"||t.confidence==="disputed",s=t.kind==="sibling",l=$h(t.confidence),a={type:"arrowclosed",color:l,width:14,height:14};return{id:t.id,source:t.source,target:t.target,type:"lineage",label:o(t.relation),data:{labelStyle:{color:i("fg")},isSibling:s,stepPosition:n},style:{stroke:l,strokeWidth:s?1:1.5,strokeDasharray:s?"4 3":r?"6 4":void 0,opacity:r?.75:1},animated:!1,markerEnd:a,markerStart:s?a:void 0,zIndex:1e3}}function Sh(t){if(t.year_range)return`~${t.year_range[0]}–${t.year_range[1]}`;if(typeof t.year=="number")return String(t.year)}function $h(t){switch(t){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 Qr={padding:"40px 20px",textAlign:"center",color:i("muted"),fontSize:"13px",border:`1px dashed ${i("widget-border")}`,borderRadius:8,background:i("bg")},_o=({graph:t,defaultMode:n="list",renderLink:o,graphHeight:r=600,selectedNodeId:s,onModeChange:l,collection:a,onCollectionChange:p,collectionsAvailable:c,collectionCounts:d,className:u,style:g})=>{var S;const{t:m,convert:x}=Y(),[f,k]=h.useState(n),b=v=>{k(v),l==null||l(v)},w=(()=>{if(!c)return[];const v=Object.entries(c);return v.length===0||c.all?v:[...v,["all",{label:m("lineage.collectionAll"),description:m("lineage.collectionAllDesc")}]]})(),y=!!(p&&w.length>0);if(!t.nodes.length)return e.jsx("div",{style:{padding:24,color:i("muted"),textAlign:"center"},children:m("lineage.empty")});const j=a?(S=c==null?void 0:c[a])==null?void 0:S.description:void 0;return e.jsxs("div",{className:u,style:g,children:[e.jsxs("div",{style:_h,children:[e.jsx("button",{onClick:()=>b("list"),style:ui(f==="list"),children:m("lineage.modeList")}),e.jsx("button",{onClick:()=>b("graph"),style:ui(f==="graph"),children:m("lineage.modeGraph")}),y&&e.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:12,color:i("muted"),marginRight:4},children:m("lineage.collectionLabel")}),w.map(([v,$])=>{const C=d==null?void 0:d[v];return e.jsxs("button",{onClick:()=>p==null?void 0:p(v),style:ui(a===v),title:$.description?x($.description):void 0,children:[x($.label),C!=null?` ${C}`:""]},v)})]})]}),y&&j&&e.jsx("div",{style:{fontSize:12,color:i("muted"),marginBottom:8,padding:"4px 8px",background:i("bg-subtle"),borderRadius:4},children:x(j)}),f==="list"?e.jsx(pa,{graph:t,renderLink:o}):e.jsx(ua,{graph:t,renderLink:o,height:r,selectedNodeId:s})]})},_h={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},ui=t=>({padding:"4px 12px",fontSize:12,border:`1px solid ${i("widget-border")}`,borderRadius:4,background:t?i("primary"):"transparent",color:i(t?"primary-fg":"fg"),cursor:"pointer"}),es=40,ts=2,Ch=9,zh=new Set(["certain","consensus","probable","disputed"]);function mi(t){if(!t)return["",""];const n=t.split(/[  ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",t]}const ma=({data:t,transport:n,onNavigate:o,renderLink:r,readAction:s,fullText:l,fullTextPending:a,chapterLink:p,railTop:c,back:d,railLinks:u})=>{var L,X,U,se,Se,Pe,$e,Fe,De,Z,Ae;const g=ke(),{t:m,convert:x}=Y(),[f,k]=h.useState(null),[b,w]=h.useState(new Map),[y,j]=h.useState([]),[S,v]=h.useState(new Map),[$,C]=h.useState(!1),[z,E]=h.useState("flow"),[T,_]=h.useState(null);h.useEffect(()=>{if(!n||!t.work_id){k(null);return}let N=!1;return n.getItem(t.work_id).then(J=>{!N&&J&&J.type==="work"&&k(J)}).catch(()=>{}),()=>{N=!0}},[n,t.work_id]),h.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!t.work_id){_(null);return}let N=!1;return n.getLineageGraph(t.work_id).then(J=>{N||_(J&&J.nodes.length>1?J:null)}).catch(()=>{N||_(null)}),()=>{N=!0}},[n,t.work_id]),h.useEffect(()=>{const N=t.contained_in||[];if(!n||N.length===0){w(new Map);return}let J=!1;return Promise.all(N.map(le=>{const te=typeof le=="string"?le:le.id;return n.getItem(te).then(pe=>[te,pe]).catch(()=>[te,null])})).then(le=>{if(J)return;const te=new Map;for(const[pe,_e]of le)_e&&te.set(pe,_e);w(te)}),()=>{J=!0}},[n,t.contained_in]);const O=h.useMemo(()=>{const N=new Set([...(f==null?void 0:f.books)||[],...t.related_books||[]]);return N.add(t.id),[...N]},[f==null?void 0:f.books,t.related_books,t.id]),W=O.length-1;h.useEffect(()=>{if(!n||W<=0){j([]);return}const N=O.length<=es,J=N?O:O.slice(0,8);let le=!1;return Promise.all(J.map(te=>te===t.id?Promise.resolve({id:te,title:t.title,edition:t.edition,year:zn(t)}):n.getItem(te).then(pe=>{const _e=pe??{};return{id:te,title:_e.title,edition:_e.edition,year:pe?zn(_e):void 0}}).catch(()=>({id:te})))).then(te=>{if(le)return;const pe=te.filter(_e=>_e.id===t.id||_e.title||_e.edition);N&&pe.sort((_e,H)=>(_e.year??1/0)-(H.year??1/0)),j(pe)}),()=>{le=!0}},[n,O,W,t]);const A=t.lineage,G=h.useMemo(()=>[...((A==null?void 0:A.derived_from)||[]).filter(N=>N.ref_type==="book").map(N=>N.ref),...((A==null?void 0:A.related_to)||[]).map(N=>N.book_id)].filter(Boolean),[A]);h.useEffect(()=>{if(!n||G.length===0){v(new Map);return}let N=!1;return Promise.all(G.map(J=>n.getItem(J).then(le=>[J,{id:J,title:le==null?void 0:le.title,edition:le==null?void 0:le.edition}]).catch(()=>[J,{id:J}]))).then(J=>{N||v(new Map(J))}),()=>{N=!0}},[n,G]);const V=h.useMemo(()=>sa(t.resources,t.resource_groups,m),[t.resources,t.resource_groups,m]),ie=V.groups.reduce((N,J)=>N+J.rows.length+J.mirrors.length,0),ae=V.groups.length>0&&V.groups.every(N=>N.key==="_physical"),P=dn(t),I=xl(t),q=bt(t,g.unit.juan),Q=new Set((t.contained_in||[]).map(N=>typeof N=="string"?0:sn(N.volume_index).length).filter(N=>N>0)),oe=N=>{var te;const J=(te=t.base_edition)==null?void 0:te.find(pe=>pe.book_id===N&&pe.name);if(J!=null&&J.name)return J.name;const le=S.get(N);return(le==null?void 0:le.edition)||(le==null?void 0:le.title)||""},je=h.useMemo(()=>{var ye,Ce,ve,xe,Oe;const N=[];I&&N.push({label:m("bookPage.fact.editionType"),value:x(I),title:t.edition_type||(ye=t.lineage)!=null&&ye.category?void 0:m("bookPage.inferredFromEdition")}),(Ce=t.publication_info)!=null&&Ce.details?N.push({label:m("bookPage.fact.publication"),value:x(t.publication_info.details)}):(P.era||P.reign)&&N.push({label:m("bookPage.fact.era"),value:x([P.era,P.reign].filter(Boolean).join(" ")),title:P.source==="edition"?m("bookPage.inferredFromEdition"):void 0}),q&&N.push({label:m("bookPage.fact.measure"),value:x(q)});const J=(t.contained_in||[]).flatMap(Te=>typeof Te=="string"?[]:sn(Te.volume_index));J.length&&N.push({label:m("bookPage.fact.volumes"),value:m("bookPage.volumesValue",{range:Dn(J,g.unit.volume),unit:g.unit.volume,n:J.length})});const le=(((ve=t.lineage)==null?void 0:ve.derived_from)||[]).find(Te=>Te.relation==="底本"&&Te.ref_type==="book");le&&oe(le.ref)&&N.push({label:m("bookPage.fact.baseEdition"),value:e.jsx(Ge,{id:le.ref,label:x(oe(le.ref)),onNavigate:o,renderLink:r,dense:!0})});const te=(t.base_edition||[]).filter(Te=>Te&&Te.name);for(const Te of["底本","配補","參校"]){if(Te==="底本"&&le&&oe(le.ref))continue;const Ve=te.filter(Be=>Be.role===Te);Ve.length&&N.push({label:x(Te),value:Ve.map((Be,lt)=>e.jsxs(h.Fragment,{children:[lt>0&&"、",Be.book_id?e.jsx(Ge,{id:Be.book_id,label:x(Be.name),onNavigate:o,renderLink:r,dense:!0}):x(Be.name)]},lt))})}const pe=(t.provenance||[]).filter(Te=>Te&&Te.institution),_e=(t.resources||[]).filter(Te=>(Te.types||(Te.type?[Te.type]:[])).includes("physical"));if(pe.length){N.push({label:m("bookPage.fact.holdings"),value:pe.slice(0,2).map(Be=>x(Be.institution)).join("、")+(pe.length>2?m("bookPage.andMorePlaces",{n:pe.length}):"")});const Te=pe.filter(Be=>Be.call_number).slice(0,2).map(Be=>`${x(Be.institution)} ${Be.call_number}`);Te.length&&N.push({label:m("bookPage.fact.callNumber"),value:Te.join(";")+(pe.filter(Be=>Be.call_number).length>2?"…":"")});const Ve=pe.flatMap(Be=>Be.seals||[]).filter(Boolean);Ve.length&&N.push({label:m("bookPage.fact.seals"),value:x(Ve.join("、"))})}else _e.length?N.push({label:m("bookPage.fact.holdings"),value:_e.slice(0,2).map(Te=>x(Te.name)).join("、")+(_e.length>2?m("bookPage.andMorePlaces",{n:_e.length}):"")}):(xe=t.current_location)!=null&&xe.name&&N.push({label:m("bookPage.fact.holdings"),value:x(t.current_location.name)});const H=t.physical_description;if(H){const Te=[[m("bookPage.fact.leafStyle"),H.leaf_style],[m("bookPage.fact.binding"),H.binding],[m("bookPage.fact.dimensions"),H.dimensions],[m("bookPage.fact.condition"),H.condition]];for(const[Ve,Be]of Te)Be&&Be.trim()&&N.push({label:Ve,value:x(Be)})}(Oe=t.page_count)!=null&&Oe.description&&N.push({label:g.label.pageCount,value:x(t.page_count.description)});const B=[...Ni(t.additional_titles),...Ni(t.attached_texts)];return B.length&&N.push({label:m("bookPage.fact.aliases"),value:B.map(x).join("、")}),N},[t,x,g,m,P,I,q,S,o,r]),Ie=x(t.title),K=t.edition?x(t.edition):void 0,me=((L=t.lineage)==null?void 0:L.year_text)||"",M=e.jsx(un,{kind:m("bookPage.kind"),title:Ie,subtitle:K,byline:e.jsx(So,{authors:t.authors??(f==null?void 0:f.authors),onNavigate:o,renderLink:r}),meta:(()=>{const N=[I?x(I):"",P.era?x([P.era,P.reign].filter(Boolean).join("")):"",q?x(q):""].filter(Boolean);return N.length?e.jsx("span",{className:"bim-d-tags",children:N.map((J,le)=>e.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(le,2)}`,children:J},le))}):null})(),description:(X=t.description)!=null&&X.text?e.jsx(ft,{text:t.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:so((U=t.description)==null?void 0:U.text)?6:void 0,facts:je,readAction:s,secondaryAction:s&&ie>0&&!ae?e.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:m("bookPage.viewImages")}):void 0,foot:e.jsx(mn,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo})}),ue=t.contained_in||[],ge=(l==null?void 0:l.chapters)||[],de=x(ge[0]&&mi(ge[0].title)[0].slice(-1)||"")||m("bookPage.chapterUnit"),Le=m("bookPage.chapterCount",{n:ge.length,unit:de}),Me=!!((se=A==null?void 0:A.derived_from)!=null&&se.length||(Se=A==null?void 0:A.related_to)!=null&&Se.length||(Pe=t.appendix)!=null&&Pe.length),Ee=[],ze=m(ae?"bookPage.sec.physical":"bookPage.sec.images");(ge.length||V.text.length||a)&&Ee.push({id:"fulltext",label:m("bookPage.sec.fulltext"),count:ge.length?Le:void 0}),V.groups.length&&Ee.push({id:"images",label:ze,count:ie}),Me&&Ee.push({id:"lineage",label:m("bookPage.sec.lineage")}),ue.length&&Ee.push({id:"collections",label:m("section.containedIn"),count:ue.length}),($e=t.location_history)!=null&&$e.length&&Ee.push({id:"provenance",label:m("section.locationHistory")});const He=N=>(p==null?void 0:p(N))??null,D=ge[0],re=D?He(D.file):null,ce=$?ge:ge.slice(0,Ch),we=(N,J,le)=>N?e.jsx("a",{className:le,href:N.href??"#",onClick:N.onClick?te=>{te.metaKey||te.ctrlKey||(te.preventDefault(),N.onClick())}:void 0,children:J}):e.jsx("span",{className:le,children:J}),F=e.jsxs(e.Fragment,{children:[(ge.length>0||V.text.length>0||a)&&e.jsxs(Ze,{id:"fulltext",title:m("bookPage.sec.fulltext"),meta:ge.length>0?e.jsx(qe,{items:[Le,(Fe=l==null?void 0:l.source)!=null&&Fe.name?m("bookPage.sourceBy",{src:x(`${l.source.name}${l.source.license?` ${l.source.license}`:""}`)}):""]}):void 0,children:[a&&!D&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bim-d-ft","aria-busy":"true",children:[e.jsx("span",{className:"bim-d-ft-h",children:" "}),e.jsx("span",{className:"bim-d-meta",children:" "})]}),e.jsx("div",{className:"bim-d-chap-pending","aria-hidden":"true"})]}),D&&e.jsxs("div",{className:"bim-d-ft",children:[e.jsx("h3",{className:"bim-d-ft-h",children:m("bookPage.readFrom",{ch:x(mi(D.title)[0])||m("bookPage.firstChapter")})}),e.jsx("span",{className:"bim-d-meta",children:x((D.title||"").replace(/^第.+?[回章卷篇節节][  ]*/,""))}),we(re,e.jsxs(e.Fragment,{children:[m("bookPage.enterReader")," ",e.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),ge.length>1&&e.jsx("ul",{className:"bim-d-chap",children:ce.map(N=>{const[J,le]=mi(N.title);return e.jsx("li",{children:we(He(N.file),e.jsxs(e.Fragment,{children:[J&&e.jsx("b",{children:x(J)}),x(le||N.file)]}))},N.file)})}),ge.length>ce.length&&e.jsx(ro,{label:m("detail.expandRest",{n:ge.length-ce.length,unit:de}),onClick:()=>C(!0)}),V.text.length>0&&e.jsxs(e.Fragment,{children:[(ge.length>0||a)&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:m("bookPage.externalText")}),e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:V.text.map((N,J)=>e.jsx($o,{item:N,siblings:V.text,listedVolumeCounts:Q},`${N.id||N.url||N.name}-${J}`))})})]})]}),V.groups.length>0&&e.jsx(Ze,{id:"images",title:ze,meta:e.jsx(qe,{items:[V.groups.length>1?m("bookPage.groupCount",{n:V.groups.length}):"",m("bookPage.placeCount",{n:ie})]}),children:e.jsx(aa,{groups:V.groups,listedVolumeCounts:Q})}),Me&&e.jsx(Ze,{id:"lineage",title:m("bookPage.sec.lineage"),meta:(De=A==null?void 0:A.derived_from)!=null&&De.length?m("bookPage.lineageMeta"):void 0,action:T?e.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":m("bookPage.lineageView"),children:[e.jsx("button",{type:"button","aria-pressed":z==="flow",onClick:()=>E("flow"),children:m("bookPage.viewCards")}),e.jsx("button",{type:"button","aria-pressed":z==="graph",onClick:()=>E("graph"),children:m("bookPage.viewGraph")})]}):void 0,children:z==="graph"&&T?e.jsx(_o,{graph:T,defaultMode:"graph",selectedNodeId:t.id,graphHeight:480,renderLink:(N,J)=>e.jsx(Ge,{id:N,label:x(J),onNavigate:o,renderLink:r,dense:!0})}):e.jsx(Nh,{data:t,heading:K||Ie,yearText:me,refName:oe,onNavigate:o,renderLink:r})}),ue.length>0&&e.jsx(Ze,{id:"collections",title:m("section.containedIn"),children:e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:ue.map((N,J)=>{var H,B;const le=typeof N=="string"?N:N.id,te=typeof N=="string"?[]:sn(N.volume_index),pe=b.get(le),_e=(pe==null?void 0:pe._member_count)||((H=pe==null?void 0:pe.books)==null?void 0:H.length)||((B=pe==null?void 0:pe.contained_works)==null?void 0:B.length)||0;return e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-d-zt-main",children:[e.jsx(Ge,{id:le,label:pe?x(pe.title):le,onNavigate:o,renderLink:r,dense:!0}),te.length>0&&e.jsx(Th,{volumes:te,unit:g.unit.volume})]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${_e?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:_e>0&&m("bookPage.totalOf",{n:_e,unit:g.unit.bu})})]},`${le}-${J}`)})})})}),(Z=t.location_history)!=null&&Z.length?e.jsx(Ze,{id:"provenance",title:m("section.locationHistory"),children:e.jsx("ul",{className:"bim-d-tl",children:t.location_history.map((N,J)=>e.jsxs("li",{children:[e.jsx("span",{className:"bim-d-tl-t",children:x(N.name)}),([N.start_date,N.end_date].filter(Boolean).join("—")||N.description)&&e.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:e.jsx(qe,{items:[[N.start_date,N.end_date].filter(Boolean).join("—"),N.description?x(N.description):""]})})]},J))})}):null,Ee.length===0&&e.jsx(Ze,{title:m("bookPage.sec.empty"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:m("bookPage.emptyText")})})]}),fe=y.findIndex(N=>N.id===t.id),Re=O.length<=es,R=Re&&fe>=0?y.slice(Math.max(0,fe-ts),fe+ts+1):y.filter(N=>N.id!==t.id),ee=e.jsxs(e.Fragment,{children:[f&&e.jsxs("div",{id:"work",className:"bim-d-side",style:{scrollMarginTop:16},children:[e.jsx("h2",{className:"bim-d-ui bim-d-side-h",children:x(g.section.belongsToWork)}),e.jsx("div",{style:{fontSize:17,fontWeight:500},children:e.jsx(Ge,{id:f.id,label:x(f.title),onNavigate:o,renderLink:r})}),e.jsx(qe,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(f.authors||[]).slice(0,2).map(N=>`${N.dynasty?`〔${x(N.dynasty)}〕`:""}${x(N.name)}`),x(bt(f,g.unit.juan)),f._edition_count?m("bookPage.editionCount",{n:f._edition_count}):""]}),((Ae=f.description)==null?void 0:Ae.text)&&e.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:x(f.description.text.replace(/[#*_>`[\]]/g,""))})]}),W>0&&R.length>0&&e.jsxs("div",{children:[e.jsx(zt,{id:"siblings",timeline:!0,title:Re?m("bookPage.siblings"):g.relation.siblingVersions,meta:Re?m("bookPage.byEra"):m("bookPage.kindCount",{n:W}),cap:R.length,items:R.map(N=>N.id===t.id?e.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:x(N.edition||N.title||N.id)}):e.jsx(Ge,{id:N.id,label:x(N.edition||N.title||N.id),onNavigate:o,renderLink:r,dense:!0})),metas:R.map(N=>[N.year!=null?N.year<0?m("detail.bce",{n:-N.year}):String(N.year):"",N.id===t.id?m("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:R.findIndex(N=>N.id===t.id)}),f&&e.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:e.jsx(Ge,{id:f.id,label:m("bookPage.viewAllInWork",{n:O.length}),onNavigate:o,renderLink:r,dense:!0})})]})]}),he=t.work_id?e.jsx(fl,{caption:g.section.belongsToWork,children:e.jsx(Ge,{id:t.work_id,label:f?x(f.title):" ",onNavigate:o,renderLink:r,dense:!0})}):void 0;return e.jsx(pn,{railTop:c,back:d,up:he,nav:Ee,railLinks:u,main:F,card:M,side:ee})};function Th({volumes:t,unit:n}){const{t:o}=Y();return e.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[o("bookPage.volumeRange",{range:Dn(t,n),unit:n}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-d-dot"}),o("bookPage.volumeCount",{n:t.length,unit:n})]})]})}function Nh({data:t,heading:n,yearText:o,refName:r,onNavigate:s,renderLink:l}){var w;const{t:a,convert:p}=Y(),c=t.lineage,d=(c==null?void 0:c.derived_from)||[],u=d.filter(y=>y.ref_type!=="book"),g=d.filter(y=>y.ref_type==="book"&&y.relation==="底本"),m=d.filter(y=>y.ref_type==="book"&&y.relation!=="底本"),x=(c==null?void 0:c.related_to)||[],f=d.length>0||x.length>0,k=y=>y&&zh.has(y)?a("bookPage.confidenceNote",{c:a(`bookPage.confidence.${y}`)}):"",b=(y,j)=>e.jsx(Ge,{id:y,label:p(j||y),onNavigate:s,renderLink:l,dense:!0});return e.jsxs("div",{className:"bim-d-lf",children:[f&&e.jsxs("ol",{className:"bim-d-lf-list",children:[u.map((y,j)=>e.jsx("li",{className:"bim-d-lf-node",children:e.jsxs("div",{className:"bim-d-lf-dash",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:y.relation?p(y.relation):a("bookPage.lineage.ancestor")}),e.jsx("span",{className:"bim-d-lf-name",children:a("bookPage.lineage.reconstructed")}),y.evidence&&e.jsxs("span",{className:"bim-d-meta",children:[p(y.evidence),k(y.confidence)]})]})},`a-${j}`)),g.map((y,j)=>e.jsx("li",{className:"bim-d-lf-node",children:e.jsxs("div",{className:"bim-d-lf-card",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:p(y.relation)}),e.jsx("span",{className:"bim-d-lf-name",children:b(y.ref,r(y.ref))}),y.evidence&&e.jsxs("p",{className:"bim-d-lf-ev",children:[p(y.evidence),k(y.confidence)]})]})},`b-${j}`)),e.jsxs("li",{className:"bim-d-lf-node bim-d-lf-cur",children:[e.jsxs("div",{className:"bim-d-lf-here",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:a("bookPage.lineage.thisEdition")}),e.jsx("span",{className:"bim-d-lf-name",children:n}),o&&e.jsx("span",{className:"bim-d-lf-yr",children:p(o)})]}),m.length>0&&e.jsx("div",{className:"bim-d-lf-side",children:m.map((y,j)=>e.jsxs("div",{className:"bim-d-lf-dash",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:p(y.relation)}),e.jsx("span",{className:"bim-d-lf-name",children:b(y.ref,r(y.ref))}),y.evidence&&e.jsxs("p",{className:"bim-d-lf-ev",children:[p(y.evidence),k(y.confidence)]})]},j))})]}),x.length>0&&e.jsxs("li",{className:"bim-d-lf-node bim-d-lf-out",children:[e.jsx("span",{className:"bim-d-lf-out-h bim-d-ui",children:a("bookPage.lineage.derivatives")}),e.jsx("span",{className:"bim-d-lf-chips",children:x.map((y,j)=>e.jsxs("span",{className:"bim-d-lf-chip",title:y.evidence?p(y.evidence):void 0,children:[b(y.book_id,r(y.book_id)),e.jsx("span",{className:"bim-d-meta",children:p(y.relation)})]},j))})]})]}),(w=t.appendix)==null?void 0:w.map((y,j)=>e.jsxs("details",{className:"bim-d-lf-app",children:[e.jsxs("summary",{className:"bim-d-ui",children:[e.jsx("span",{className:"bim-d-meta",children:a("bookPage.lineage.appendix")})," ",p(y.title)]}),e.jsx(ft,{text:y.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${j}`)),(c==null?void 0:c.note)&&e.jsx("p",{className:"bim-d-meta",style:{margin:"12px 0 0",maxWidth:"46em"},children:p(c.note)})]})}const tn=16,Ih=200,Rh=16,ga=({data:t,catalog:n,transport:o,onNavigate:r,renderLink:s,catalogAction:l,railTop:a,back:p,railLinks:c})=>{var we,F,fe,Re,R,ee,he;const{t:d,convert:u,messages:g}=Y(),[m,x]=h.useState(""),[f,k]=h.useState(!1),[b,w]=h.useState(null),[y,j]=h.useState(""),[S,v]=h.useState(!1),$=h.useMemo(()=>gl(t,n),[t,n]),[C,z]=h.useState(new Map),E=!!o&&$.rows.length>0&&$.rows.length<=Ih,T=E&&($.rows.length<=tn||S),_=T&&$.rows.every(L=>!L.id||C.has(L.id)),O=L=>{var X;return Pi(L?(X=C.get(L))==null?void 0:X.l1:void 0)},W=h.useMemo(()=>{const L=m.trim(),X=L?u(L):"";return $.rows.filter(U=>{var Se,Pe;if(y&&Pi(U.id?(Se=C.get(U.id))==null?void 0:Se.l1:void 0)!==y)return!1;if(!X)return!0;const se=U.id&&((Pe=C.get(U.id))==null?void 0:Pe.title)||U.title;return u(se).includes(X)||(U.subItems||[]).some($e=>u($e).includes(X))})},[$.rows,m,y,C,u]),A=f?W:W.slice(0,tn),G=h.useMemo(()=>(T?$.rows:A).filter(L=>L.id&&!C.has(L.id)).map(L=>L.id),[T,$.rows,A,C]);h.useEffect(()=>{if(!o||G.length===0)return;let L=!1;const X=G.slice(0,Rh);return Promise.all(X.map(U=>o.getItem(U).then(se=>{var $e,Fe;const Se=se??{},Pe={title:Se.title,edition:Se.edition,authors:Se.authors,measure:se?bt(se,g.unit.juan):void 0,versionCount:Se._edition_count??(($e=Se.books)==null?void 0:$e.length),l1:((Fe=Se.classification)==null?void 0:Fe.l1)||void 0};return[U,Pe]}).catch(()=>[U,{}]))).then(U=>{L||z(se=>{const Se=new Map(se);for(const[Pe,$e]of U)Se.set(Pe,$e);return Se})}),()=>{L=!0}},[o,G,g.unit.juan]);const V=(t.contained_in||[])[0];h.useEffect(()=>{if(!V){w(null);return}if(w({id:V}),!o)return;let L=!1;return o.getItem(V).then(X=>{L||w({id:V,title:X==null?void 0:X.title})}).catch(()=>{}),()=>{L=!0}},[o,V]);const ie=h.useMemo(()=>sa(t.resources,t.resource_groups,d),[t.resources,t.resource_groups,d]),ae=ie.text.length+ie.groups.reduce((L,X)=>L+X.rows.length+X.mirrors.length,0),P=t.contained_works||[],I=new Set($.rows.map(L=>L.id).filter(Boolean)),q=P.length>0&&!P.every(L=>I.has(L.id)),Q=(()=>{const L=$.rows.map(X=>X.edition).filter(Boolean);return L.length>1&&new Set(L).size===1})(),oe=$.rows.some(L=>L.volumes.length>0||L.expected!=null),je=t._member_count||((we=t.books)==null?void 0:we.length)||P.length,Ie=bt(t,g.unit.juan),K=t.count,me=L=>typeof L=="number"&&Number.isFinite(L)?L:null,M=me(K==null?void 0:K.juan)??me((F=t.juan_count)==null?void 0:F.number),ue=me(K==null?void 0:K.ce)??($.totalVolumes||null),ge=[{value:$.rows.length,label:d("collectionPage.stat.titles")},{value:M??0,label:g.unit.juan},{value:ue??0,label:g.unit.volume}],de=h.useMemo(()=>{var U,se;const L=[];if((U=t.publication_info)!=null&&U.details&&L.push({label:d("collectionPage.fact.publication"),value:u(t.publication_info.details)}),je&&je!==$.rows.length){const Se=t._member_type==="Book"?d("collectionPage.member.Book"):t._member_type==="Work"?d("collectionPage.member.Work"):d("collectionPage.member.other");L.push({label:Se,value:`${je} ${g.unit.bu}`,title:d("collectionPage.memberNote")})}const X=[me(K==null?void 0:K.zhong)!=null?d("collectionPage.nZhong",{n:K.zhong}):"",me(K==null?void 0:K.han)!=null?d("collectionPage.nHan",{n:K.han}):""].filter(Boolean);return X.length&&L.push({label:d("collectionPage.fact.expected"),value:X.join(" ")}),M==null&&Ie&&L.push({label:d("collectionPage.fact.measure"),value:u(Ie),title:(se=t.juan_count)!=null&&se.description?u(t.juan_count.description):void 0}),L},[t,je,$.rows.length,M,Ie,K,u,d,g]),Le=h.useMemo(()=>{if(!_)return[];const L=new Map;for(const U of $.rows){const se=O(U.id);se&&L.set(se,(L.get(se)??0)+1)}const X=an.filter(U=>(L.get(U.key)??0)>0);return X.length<2?[]:[{key:"",label:`${g.catalog.all} ${$.rows.length}`},...X.map(U=>({key:U.key,label:`${U.label} ${L.get(U.key)}`}))]},[_,$.rows,C,g]),Me=h.useMemo(()=>{if(!_||!$.rows.some(se=>se.volumes.length>0))return null;const L=[],X=$.rows.filter(se=>se.volumes.length>0).map(se=>({k:O(se.id)??"",from:Math.min(...se.volumes),to:Math.max(...se.volumes)})).sort((se,Se)=>se.from-Se.from);for(const se of X){const Se=se.to-se.from+1,Pe=L[L.length-1];Pe&&Pe.key===se.k?(Pe.to=Math.max(Pe.to,se.to),Pe.n+=Se):L.push({key:se.k,from:se.from,to:se.to,n:Se})}const U=X.reduce((se,Se)=>Math.max(se,Se.to),0);return L.length>1&&L.some(se=>se.key)?{segs:L,last:U}:null},[_,$.rows,C]),Ee=(fe=t.description)==null?void 0:fe.text,ze=e.jsx(un,{kind:d("collectionPage.kind"),title:u(t.title),byline:e.jsx(So,{authors:t.authors,onNavigate:r,renderLink:s}),meta:e.jsx(qe,{items:[t.subtype==="work_collection"?d("collectionPage.workCollection"):"",(Re=t.publication_info)!=null&&Re.year?u(t.publication_info.year):""]}),description:Ee||(R=t.history)!=null&&R.length?e.jsxs(e.Fragment,{children:[Ee&&e.jsx(ft,{text:Ee,style:{fontSize:15,lineHeight:1.85}}),(ee=t.history)!=null&&ee.length?e.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:t.history.map((L,X)=>e.jsx("li",{children:u(L)},X))}):null]}):void 0,clampDescription:so(Ee)||(((he=t.history)==null?void 0:he.length)??0)>2?6:void 0,stats:ge,facts:de,foot:e.jsx(mn,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo}),children:Me&&e.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[e.jsx("div",{className:"bim-d-dist-head",children:e.jsx("span",{children:d("collectionPage.dist.head")})}),e.jsx("div",{className:"bim-d-dist-bar",role:"group","aria-label":d("collectionPage.dist.head"),children:Me.segs.map((L,X)=>{const U=an.find(se=>se.key===L.key);return e.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!U,title:U?d("collectionPage.dist.segTitle",{section:u(U.label),from:L.from,to:L.to}):void 0,"aria-label":U?d("collectionPage.dist.only",{section:u(U.label)}):d("collectionPage.dist.unclassified"),"aria-pressed":!!U&&y===L.key,style:{flexGrow:L.n,background:i(U?U.token:"rule")},onClick:()=>{U&&(j(y===L.key?"":L.key),k(!1))}},X)})}),e.jsxs("div",{className:"bim-d-life-lab",children:[e.jsx("span",{children:d("catalog.volume",{n:1})}),e.jsx("span",{children:d("collectionPage.dist.hint")}),e.jsx("span",{children:d("catalog.volume",{n:Me.last})})]})]})}),He=[];$.rows.length&&He.push({id:"titles",label:d("collectionPage.sec.titles"),count:$.rows.length}),ae&&He.push({id:"resources",label:d("collectionPage.sec.resources"),count:ae}),q&&He.push({id:"works",label:g.section.containedWorks,count:P.length});const D=e.jsxs(e.Fragment,{children:[$.rows.length>0&&e.jsxs(Ze,{id:"titles",title:d("collectionPage.sec.titles"),meta:e.jsx(qe,{items:[`${$.rows.length} ${g.unit.items}`,$.totalVolumes?d("collectionPage.totalVolumes",{n:$.totalVolumes,unit:g.unit.volume}):"",W.length!==$.rows.length?d("collectionPage.currentN",{n:W.length,unit:g.unit.items}):""]}),action:l,children:[($.rows.length>tn||Le.length>0)&&e.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[Le.length>0&&e.jsx(Un,{items:Le,value:y,onChange:L=>{j(L),k(!1)}}),E&&$.rows.length>tn&&!_&&e.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:S,onClick:()=>v(!0),title:d("collectionPage.loadAllTitle",{n:$.rows.length,unit:g.unit.items}),children:d(S?"collectionPage.grouping":"collectionPage.groupBySection")}),e.jsx("span",{className:"bim-d-spacer"}),$.rows.length>tn&&e.jsx("input",{type:"search",className:"bim-d-find",value:m,placeholder:d("collectionPage.find"),"aria-label":d("collectionPage.find"),onChange:L=>{x(L.target.value),k(!1)}})]}),e.jsxs("table",{className:"bim-d-zt","data-ncap":!f&&Vn(W.length)?"":void 0,children:[e.jsx("thead",{className:"bim-d-ui",children:e.jsxs("tr",{children:[oe&&e.jsx("th",{style:{width:"8.5em"},children:d("collectionPage.col.volumes")}),e.jsx("th",{children:d("collectionPage.col.title")}),e.jsx("th",{style:{textAlign:"right"},children:d("collectionPage.col.versions")})]})}),e.jsx("tbody",{children:A.map((L,X)=>{var De;const U=L.id?C.get(L.id):void 0,se=U!=null&&U.title&&L.title===L.id?U.title:L.title,Se=((U==null?void 0:U.authors)||[]).find(Z=>Z&&Z.name),Pe=[Se?`${Se.dynasty?`〔${u(Se.dynasty)}〕`:""}${u(Se.name)}${Se.role?` ${u(Se.role)}`:""}`:"",U!=null&&U.measure?u(U.measure):"",(De=L.subItems)!=null&&De.length?L.subItems.map(Z=>u(Z)).join("、"):"",(U!=null&&U.edition||L.edition)&&!Q?u((U==null?void 0:U.edition)||L.edition||""):""].filter(Boolean),$e=an.find(Z=>Z.key===O(L.id)),Fe=L.volumes.length>0?d("collectionPage.volumeRange",{range:Dn(L.volumes,g.unit.volume),unit:g.unit.volume}):L.expected!=null?`${L.found??0}/${L.expected} ${g.unit.volume}`:"";return e.jsxs("tr",{children:[oe&&e.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Fe?"":" bim-d-zt-blank"}`,children:[$e&&e.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:i($e.token)}}),Fe||e.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),e.jsxs("td",{className:"bim-d-zt-main",children:[L.id?e.jsx(Ge,{id:L.id,label:u(se),onNavigate:r,renderLink:s,dense:!0}):e.jsx("span",{className:"bim-d-zt-name",children:u(se)}),Pe.length>0?e.jsx(qe,{items:Pe}):L.id&&!U&&o?e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${U!=null&&U.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:U!=null&&U.versionCount?d("collectionPage.nZhong",{n:U.versionCount}):""})]},`${L.id??L.title}-${X}`)})})]}),A.length===0&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:d("catalog.noMatch")}),!f&&e.jsx(oo,{total:W.length,shown:A.length,unit:g.unit.items,onClick:()=>k(!0)})]}),ae>0&&e.jsxs(Ze,{id:"resources",title:d("collectionPage.sec.resources"),meta:d("collectionPage.resourcesCount",{n:ae}),children:[ie.text.length>0&&e.jsxs("div",{className:"bim-d-rg",children:[ie.groups.length>0&&e.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:d("collectionPage.text")}),e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:ie.text.map((L,X)=>e.jsx($o,{item:L,siblings:ie.text},`${L.id||L.url||L.name}-${X}`))})})]}),e.jsx(aa,{groups:ie.groups})]}),$.rows.length===0&&ae===0&&e.jsx(Ze,{title:d("collectionPage.sec.titles"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:d("collectionPage.empty")})})]}),re=q?e.jsx(zt,{id:"works",title:g.section.containedWorks,meta:d("collectionPage.nZhong",{n:P.length}),cap:12,items:P.map(L=>e.jsx(Ge,{id:L.id,label:u(L.title),onNavigate:r,renderLink:s,dense:!0}))}):null,ce=b?e.jsx(fl,{caption:d("collectionPage.parent"),children:e.jsx(Ge,{id:b.id,label:u(b.title||b.id),onNavigate:r,renderLink:s,dense:!0})}):void 0;return e.jsx(pn,{railTop:a,back:p,up:ce,nav:He,railLinks:c,main:D,card:ze,side:re})},Eh=16,gi=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function ns(t){if(!t)return gi.length;const n=gi.indexOf(t);return n===-1?gi.length:n}function Lh(t,n){return t==null?"":t<0?n("entityPage.bce",{n:-t}):String(t)}const Ph={秦:[-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]},ha=({data:t,transport:n,onNavigate:o,renderLink:r,railTop:s,back:l,railLinks:a})=>{var ce,we,F,fe,Re;const{t:p,convert:c,messages:d}=Y(),u=R=>Lh(R,p),[g,m]=h.useState("全部"),[x,f]=h.useState(!1),[k,b]=h.useState("default"),[w,y]=h.useState(new Map),j=h.useMemo(()=>(t.works||[]).map(R=>{const ee=w.get(R.work_id);return{id:R.work_id,title:(ee==null?void 0:ee.title)??R.title??R.work_id,role:R.role||"",cls:no(R.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)}}),[t.works,w]),S=h.useMemo(()=>ml((t.works||[]).map(R=>R.role),p("detail.roleAll")),[t.works,p]),v=h.useMemo(()=>{const R=g==="全部"?j:j.filter(ee=>ee.cls===g);return k==="versions"?[...R].sort((ee,he)=>(he.versionCount??-1)-(ee.versionCount??-1)):R},[j,g,k]),$=x?v:v.slice(0,Eh),C=h.useMemo(()=>$.filter(R=>!w.has(R.id)).map(R=>R.id),[$,w]);h.useEffect(()=>{if(!n||C.length===0)return;let R=!1;return Promise.all(C.map(ee=>n.getItem(ee).then(he=>{var se,Se,Pe,$e,Fe;const L=he??{},X=L._edition_count??(((se=L.books)==null?void 0:se.length)??0)+(((Se=L.collections)==null?void 0:Se.length)??0),U=[(Pe=L.classification)==null?void 0:Pe.l1,($e=L.classification)==null?void 0:$e.l2].filter(Boolean).join(" ");return[ee,{id:ee,title:L.title,versionCount:X,loaded:!0,cls:U||void 0,l1:((Fe=L.classification)==null?void 0:Fe.l1)||void 0,measure:he&&bt(he,d.unit.juan)||void 0,hasImage:!!(L.has_image??L._has_image)}]}).catch(()=>[ee,{id:ee,loaded:!0}]))).then(ee=>{R||y(he=>{const L=new Map(he);for(const[X,U]of ee)L.set(X,U);return L})}),()=>{R=!0}},[n,C,d.unit.juan]);const z=h.useMemo(()=>{const R=new Map;for(const ee of t.alt_names||[]){const he=ee.type||d.section.aliases;R.has(he)||R.set(he,[]),R.get(he).push(ee.name)}return[...R.entries()].sort((ee,he)=>ns(ee[0])-ns(he[0])).map(([ee,he])=>({label:ee,names:he}))},[t.alt_names,d]),E=t.birth_year??((ce=t.dates)==null?void 0:ce.birth)??void 0,T=t.death_year??((we=t.dates)==null?void 0:we.death)??void 0,_=(F=t.dates)==null?void 0:F.floruit,O=E!=null||T!=null?`${u(E)||"?"}—${u(T)||"?"}`:Array.isArray(_)&&_.length===2&&_.every(R=>Number.isFinite(R))?p("entityPage.floruit",{from:u(_[0]),to:u(_[1])}):"",W=new Set(["本名","字","號","号"]),A=z.filter(R=>W.has(R.label)),G=z.filter(R=>!W.has(R.label)),V=G.reduce((R,ee)=>R+ee.names.length,0),ie=h.useMemo(()=>{const R=[];for(const he of A)R.push({label:he.label,value:he.names.map(L=>c(L)).join("、")});const ee=(t.works||[]).length;return ee&&R.push({label:p("entityPage.fact.works"),value:p("entityPage.nZhong",{n:ee})}),R},[t.works,A,c,p]),ae=R=>{var ee;return(ee=z.find(he=>R.includes(he.label)))==null?void 0:ee.names[0]},P=ae(["字"]),I=ae(["號","号"]),q=[P?p("entityPage.zi",{name:c(P)}):"",I?p("entityPage.hao",{name:c(I)}):""].filter(Boolean).join(","),Q=t.native_place,oe=t.dynasty?Ph[t.dynasty]:void 0,je=(()=>{if(!oe||E==null||T==null||T<E)return null;const[R,ee]=oe,he=Math.max(E,R),L=Math.min(T,ee);if(L<=he)return null;const X=ee-R;return e.jsxs("div",{className:"bim-d-life bim-d-ui",children:[e.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":p("entityPage.lifeAria",{birth:u(E),death:u(T),years:T-E+1}),children:e.jsx("i",{style:{left:`${(he-R)/X*100}%`,width:`${(L-he)/X*100}%`}})}),e.jsxs("div",{className:"bim-d-life-lab",children:[e.jsx("span",{children:`${u(R)} ${c(t.dynasty)}`}),e.jsx("span",{children:p("entityPage.lifeYears",{years:T-E+1})}),e.jsx("span",{children:u(ee)})]})]})})(),Ie=h.useMemo(()=>{if(!n||j.length===0||j.some(he=>!he.loaded))return null;const R=new Map;for(const he of j){const L=Pi(he.l1);L&&R.set(L,(R.get(L)??0)+1)}const ee=an.map(he=>({...he,n:R.get(he.key)??0})).filter(he=>he.n>0);return ee.length?ee:null},[j,n]),K=e.jsxs(un,{kind:d.entityPage.subtype[t.subtype]??p("entityPage.subtype.people"),title:c(t.primary_name||t.title),subtitle:q||void 0,meta:e.jsxs(e.Fragment,{children:[e.jsx(qe,{items:[t.dynasty?c(t.dynasty):"",O,Q?p("entityPage.nativePlace",{place:c(Q)}):""]}),je]}),description:(fe=t.description)!=null&&fe.text?e.jsx(ft,{text:t.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:so((Re=t.description)==null?void 0:Re.text)?6:void 0,facts:ie,foot:e.jsx(mn,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo}),children:[V>0&&e.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[e.jsx("summary",{children:p("entityPage.moreNames",{n:V})}),e.jsx("dl",{children:G.map(R=>e.jsxs(h.Fragment,{children:[e.jsx("dt",{children:c(R.label)}),e.jsx("dd",{children:R.names.map(ee=>c(ee)).join("、")})]},R.label))})]}),Ie&&e.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[e.jsx("div",{className:"bim-d-dist-head",children:e.jsx("span",{children:p("entityPage.dist")})}),e.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:Ie.map(R=>e.jsx("i",{style:{flexGrow:R.n,background:i(R.token)}},R.key))}),e.jsx("div",{className:"bim-d-dist-key",children:Ie.map(R=>e.jsxs("span",{children:[e.jsx("i",{style:{background:i(R.token)}}),c(R.label)," ",R.n]},R.key))})]})]}),me=h.useMemo(()=>j.filter(R=>R.loaded&&(R.versionCount??0)>0).sort((R,ee)=>(ee.versionCount??0)-(R.versionCount??0)).slice(0,3),[j]),M=!!n&&j.length>=3&&$.some(R=>!R.loaded),ue=g==="全部"&&(M||me.length>=2),ge=t.external_ids||{},de=[];ge.cbdb_id!=null&&de.push({label:"CBDB",id:String(ge.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${ge.cbdb_id}`,note:ge.cbdb_match==="auto"?p("entityPage.autoMatch"):void 0});const Le=ge.wikidata_id;Le&&de.push({label:"Wikidata",id:Le,href:`https://www.wikidata.org/wiki/${Le}`});const Me=ge.viaf_id;Me&&de.push({label:"VIAF",id:Me,href:`https://viaf.org/viaf/${Me}`});const Ee=S.map(R=>({key:R.cls,label:`${R.label} ${R.count}`})),ze=[...ue&&!M?[{id:"featured",label:p("entityPage.sec.featured"),count:me.length}]:[],...j.length?[{id:"works",label:p("entityPage.sec.allWorks"),count:j.length}]:[],...de.length?[{id:"external",label:p("entityPage.sec.external"),count:de.length}]:[]],He=ue?e.jsxs(Ze,{id:"featured",title:p("entityPage.sec.featured"),children:[e.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:p("entityPage.featuredSub")}),e.jsxs("div",{className:"bim-d-picks","aria-busy":M||void 0,children:[M&&[0,1,2].map(R=>e.jsxs("div",{className:"bim-d-pick","aria-hidden":"true",children:[e.jsx("span",{className:"bim-d-pick-t",children:" "}),e.jsx("span",{className:"bim-d-meta",children:" "}),e.jsx("div",{className:"bim-d-pick-n",children:" "})]},R)),!M&&me.map(R=>e.jsxs("div",{className:"bim-d-pick",children:[e.jsx("span",{className:"bim-d-pick-t",children:e.jsx(Ge,{id:R.id,label:c(R.title),onNavigate:o,renderLink:r,dense:!0})}),e.jsx(qe,{items:[R.section?c(R.section):"",R.measure?c(R.measure):""]}),e.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[e.jsx("span",{className:"bim-d-pick-num",children:R.versionCount}),e.jsx("span",{children:p("entityPage.versionsUnit")}),R.hasImage&&e.jsx("span",{className:"bim-d-flag",children:p("entityPage.hasImage")})]})]},R.id))]})]}):null,D=j.length===0?e.jsx(Ze,{title:p("entityPage.sec.works"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("entityPage.empty")})}):e.jsxs(e.Fragment,{children:[He,e.jsxs(Ze,{id:"works",title:p("entityPage.sec.works"),meta:e.jsx(qe,{items:[p("entityPage.total",{n:j.length}),v.length!==j.length?p("entityPage.current",{n:v.length}):""]}),children:[e.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[Ee.length>1&&e.jsx(Un,{items:Ee,value:g,onChange:R=>{m(R),f(!1)}}),e.jsx("span",{className:"bim-d-spacer"}),e.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":k==="versions",onClick:()=>{k==="default"&&f(!0),b(R=>R==="default"?"versions":"default")},children:p(k==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),e.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Vn(v.length)?"":void 0,children:[e.jsx("thead",{className:"bim-d-ui",children:e.jsxs("tr",{children:[e.jsx("th",{children:p("entityPage.col.work")}),e.jsx("th",{children:p("entityPage.col.section")}),e.jsx("th",{children:p("entityPage.col.role")}),e.jsx("th",{children:p("entityPage.col.versions")}),e.jsx("th",{"aria-label":p("entityPage.col.image")})]})}),e.jsx("tbody",{children:$.map(R=>e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-d-zt-main",children:[e.jsx(Ge,{id:R.id,label:c(R.title),onNavigate:o,renderLink:r,dense:!0}),R.measure?e.jsx(qe,{items:[c(R.measure)]}):!R.loaded&&n?e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${R.section||R.loaded?"":" bim-d-zt-blank"}`,children:R.section?c(R.section):null}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${R.role?"":" bim-d-zt-blank"}`,children:R.role?c(R.role):e.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${R.loaded?"":" bim-d-zt-blank"}`,children:R.loaded?R.versionCount?p("entityPage.nZhong",{n:R.versionCount}):e.jsx("span",{className:"bim-d-zt-empty",children:p("entityPage.notRecorded")}):""}),e.jsx("td",{className:R.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:R.hasImage&&e.jsx("span",{className:"bim-d-flag bim-d-ui",children:p("entityPage.hasImage")})})]},R.id))})]}),$.length===0&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("entityPage.emptyRole")}),!x&&e.jsx(oo,{total:v.length,shown:$.length,unit:p("entityPage.moreUnit"),onClick:()=>f(!0)})]})]}),re=de.length>0?e.jsx(zt,{id:"external",title:p("entityPage.sec.external"),items:de.map(R=>e.jsxs("a",{href:R.href,target:"_blank",rel:"noopener noreferrer",children:[R.label," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:de.map(R=>R.id),foot:ge.cbdb_id!=null&&ge.cbdb_match==="auto"?p("entityPage.cbdbAuto"):void 0}):null;return e.jsx(pn,{railTop:s,back:l,nav:ze,railLinks:a,main:D,card:K,side:re})},Co="(max-width: 719px)",Ah=`${Co}, (pointer: coarse)`,xa=`
1110
1110
  .bim-ct {
1111
1111
  display: grid; grid-template-columns: 248px minmax(0, 1fr); column-gap: 32px; align-items: start;
1112
1112
  max-width: 1440px; margin: 0 auto; padding: 20px 32px 48px; box-sizing: border-box;
@@ -1265,7 +1265,7 @@ ${Z??""}`,load:ne,files:L,activeFile:se??null,activeJuan:(Ce==null?void 0:Ce.jso
1265
1265
  /* 窄屏分类抽屉:界栏下按钮和面板都有框 */
1266
1266
  :root[data-layout="boxed"] .bim-ct-drawer-btn { border: ${i("fr-bd")}; background: ${i("fr-bg")}; }
1267
1267
  :root[data-layout="boxed"] .bim-ct-drawer { border: ${i("fr-bd")}; }
1268
- `,Ct="未分類",ht="all",zo=20;function hn(t){if(!t)return[];const n=[];for(const o of[t.l1,t.l2,t.l3,t.l4]){const r=(o??"").trim();if(!r)break;n.push(r)}return n}function Bh(t){const n=hn(t);return n.length?n.join("/"):Ct}function Mh(t){const n=hn(t);return n.length?n.map((o,r)=>n.slice(0,r+1).join("/")):[Ct]}function Wh(t,n=[]){const o=new Map;n.forEach((p,c)=>{const d=[p.cata_l1,p.cata_l2,p.cata_l3,p.cata_l4].filter(u=>!!u);d.forEach((u,g)=>{const m=d.slice(0,g+1).join("/");o.has(m)||o.set(m,c)})});const r=new Map;let s=0;for(const p of t){const c=hn(p.classification);if(!c.length){s++;continue}let d=r;c.forEach((u,g)=>{const m=c.slice(0,g+1).join("/");let h=d.get(u);h||(h={id:m,label:u,count:0,children:new Map},d.set(u,h)),h.count++,d=h.children})}const l=p=>[...p.values()].sort((c,d)=>{const u=c.label===Ct?1:0,g=d.label===Ct?1:0;if(u!==g)return u-g;const m=o.get(c.id)??1/0,h=o.get(d.id)??1/0;return m!==h?m-h:c.label.localeCompare(d.label,"zh")}).map(c=>{const d={id:c.id,label:c.label,count:c.count};return c.children.size&&(d.children=l(c.children)),d}),a=l(r);return s>0&&a.push({id:Ct,label:Ct,count:s}),a}function Bt(t,n){if(!n)return[];for(const o of t){if(o.id===n)return[o];if(o.children){const r=Bt(o.children,n);if(r.length)return[o,...r]}}return[]}function To(t){return t.reduce((n,o)=>n+o.count,0)}function Hh(t){return(t??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function Oh(t){var p;const n={id:t.id,title:t.title||t.id},o=t.juan_count,r=typeof o=="number"?o:o==null?void 0:o.number;typeof r=="number"&&r>0?n.juan=r:t.measure_info&&(n.juan=t.measure_info);const s=(t.authors??[]).filter(c=>c==null?void 0:c.name).map(c=>{const d=c.dynasty||(t.authors.length===1?t.dynasty:void 0);return d?{name:c.name,dynasty:d}:{name:c.name}});s.length&&(n.authors=s);const l=Hh(typeof t.description=="string"?t.description:(p=t.description)==null?void 0:p.text);l&&(n.summary=l);const a=hn(t.classification);return a.length&&(n.classification=a),n}function Fh(t,n){const o=t.summary?0:1,r=n.summary?0:1;return o!==r?o-r:t.title.localeCompare(n.title,"zh")}function Dh(t,n=zo){return Math.max(1,Math.ceil(t/n))}function fa(t,n,o=2){if(n<=1)return[1];const r=new Set([1,n]);for(let a=t-o;a<=t+o;a++)a>=1&&a<=n&&r.add(a);const s=[...r].sort((a,p)=>a-p),l=[];return s.forEach((a,p)=>{if(p>0){const c=a-s[p-1];c===2?l.push(a-1):c>2&&l.push(null)}l.push(a)}),l}const Uh=()=>e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:e.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Vh(t,n,o){const r=[];o&&r.push({id:ht,parentId:null,hasChildren:!1,firstChildId:null});const s=(l,a)=>{var p;for(const c of l){const d=(p=c.children)!=null&&p.length?c.children:null;r.push({id:c.id,parentId:a,hasChildren:!!d,firstChildId:d?d[0].id:null}),d&&n.has(c.id)&&s(d,c.id)}};return s(t,null),r}function ba({tree:t,selectedId:n,onSelect:o,allLabel:r,label:s}){const{t:l,convert:a}=G(),p=r===void 0?l("catalogPage.all"):r,c=s??l("catalogPage.classification"),d=x.useRef(null),u=n&&n!==ht?n:null,g=p!==null,[m,h]=x.useState(()=>{const z=new Set;for(const E of Bt(t,u))z.add(E.id);return z});x.useEffect(()=>{const z=Bt(t,u);z.length&&h(E=>{if(z.every(C=>E.has(C.id)))return E;const T=new Set(E);for(const C of z)T.add(C.id);return T})},[t,u]);const f=x.useMemo(()=>Vh(t,m,g),[t,m,g]),[v,y]=x.useState(null);x.useEffect(()=>{y(null)},[n]);const w=u??(g?ht:null),b=x.useMemo(()=>{var T;const z=new Set(f.map(C=>C.id));if(v&&z.has(v))return v;if(w&&z.has(w))return w;const E=Bt(t,u).map(C=>C.id).filter(C=>z.has(C));return E.length?E[E.length-1]:((T=f[0])==null?void 0:T.id)??null},[f,v,w,t,u]),j=x.useCallback((z,E)=>{h(T=>{const C=T.has(z),O=E??!C;if(O===C)return T;const W=new Set(T);return O?W.add(z):W.delete(z),W})},[]),S=x.useCallback(z=>{y(z),requestAnimationFrame(()=>{var T;const E=Array.from(((T=d.current)==null?void 0:T.querySelectorAll("[data-ct-id]"))??[]).find(C=>C.dataset.ctId===z);E==null||E.focus()})},[]),k=x.useCallback((z,E)=>{E&&j(z,!0),o(z)},[o,j]),$=x.useCallback(z=>{const E=z.target.closest("[data-ct-id]");if(!E)return;const T=E.dataset.ctId,C=f.findIndex(P=>P.id===T);if(C<0)return;const O=f[C];let W=null;switch(z.key){case"ArrowDown":W=f[Math.min(f.length-1,C+1)].id;break;case"ArrowUp":W=f[Math.max(0,C-1)].id;break;case"Home":W=f[0].id;break;case"End":W=f[f.length-1].id;break;case"ArrowRight":if(!O.hasChildren)break;m.has(T)?W=O.firstChildId:j(T,!0);break;case"ArrowLeft":O.hasChildren&&m.has(T)?j(T,!1):W=O.parentId;break;case"Enter":case" ":z.preventDefault(),k(T,O.hasChildren);return;default:return}z.preventDefault(),W&&W!==T&&S(W)},[f,m,j,S,k]),_=(z,E)=>z.map((T,C)=>{var V;const O=(V=T.children)!=null&&V.length?T.children:null,W=!!O&&m.has(T.id),P=T.id===u,Y=E===1&&z.length>1&&C===z.length-1;return e.jsxs("li",{role:"treeitem","aria-level":E,"aria-expanded":O?W:void 0,"aria-selected":P,tabIndex:b===T.id?0:-1,"data-ct-id":T.id,className:Y?"bim-ct-last":void 0,children:[e.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":E-1},onClick:()=>{y(T.id),k(T.id,!!O)},children:[e.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:O?Q=>{Q.stopPropagation(),y(T.id),j(T.id)}:void 0,children:O?e.jsx(Uh,{}):null}),e.jsx("span",{className:"bim-ct-lb",children:a(T.label)}),e.jsx("span",{className:"bim-ct-n",children:T.count.toLocaleString("en-US")})]}),W&&e.jsx("ul",{role:"group",children:_(O,E+1)})]},T.id)});return e.jsxs("ul",{ref:d,role:"tree","aria-label":a(c),className:"bim-ct-tree",onKeyDown:$,children:[g&&e.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!u,tabIndex:b===ht?0:-1,"data-ct-id":ht,children:e.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(ht),o(ht)},children:[e.jsx("span",{className:"bim-ct-tw","aria-hidden":"true"}),e.jsx("span",{className:"bim-ct-lb",children:a(p)}),e.jsx("span",{className:"bim-ct-n",children:To(t).toLocaleString("en-US")})]})}),_(t,1)]})}const ya=t=>`/item/${encodeURIComponent(t)}`;function Gh(t){return t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey}function ja(t,n){return t==null||t===""?null:typeof t=="number"?n("catalogPage.juanN",{n:t}):t}function va({work:t,href:n}){var p,c;const{t:o,convert:r}=G(),s=ja(t.juan,o),l=((p=t.authors)==null?void 0:p.filter(d=>d.name))??[],a=((c=t.classification)==null?void 0:c.filter(Boolean))??[];return e.jsx("li",{className:"bim-ct-card",children:e.jsxs("a",{href:n,children:[e.jsxs("div",{className:"bim-ct-ch",children:[e.jsx("h2",{className:"bim-ct-ct",children:r(t.title)}),s&&e.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),l.length>0&&e.jsx("span",{className:"bim-ct-by",children:l.map((d,u)=>e.jsxs(x.Fragment,{children:[u>0&&"、",d.dynasty&&e.jsxs("span",{className:"bim-ct-dy",children:["〔",r(d.dynasty),"〕"]}),r(d.name)]},u))}),t.summary&&e.jsx("p",{className:"bim-ct-sum",children:r(t.summary)}),a.length>0&&e.jsx("span",{className:"bim-ct-cls",children:a.map(d=>r(d)).join(" · ")})]})})}function ka({work:t,href:n}){var p,c;const{t:o,convert:r}=G(),s=ja(t.juan,o),l=((p=t.authors)==null?void 0:p.filter(d=>d.name))??[],a=((c=t.classification)==null?void 0:c.filter(Boolean))??[];return e.jsx("li",{className:"bim-ct-lrow",children:e.jsxs("a",{href:n,children:[e.jsxs("span",{className:"bim-ct-lt",children:[r(t.title),s&&e.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),e.jsx("span",{className:"bim-ct-by",children:l.map((d,u)=>e.jsxs(x.Fragment,{children:[u>0&&"、",d.dynasty&&e.jsxs("span",{className:"bim-ct-dy",children:["〔",r(d.dynasty),"〕"]}),r(d.name)]},u))}),e.jsx("span",{className:"bim-ct-cls",children:a.map(d=>r(d)).join(" · ")})]})})}function wa({page:t,pageCount:n,onPage:o,pageHref:r,label:s}){const{t:l,convert:a}=G();if(n<=1)return null;const p=d=>u=>{o&&(r&&!Gh(u)||(u.preventDefault(),o(d)))},c=(d,u,g)=>{if(g.disabled)return e.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:u});const m={className:"bim-ct-pg","aria-current":g.current?"page":void 0,"aria-label":g.aria};return r?e.jsx("a",{...m,href:r(d),onClick:p(d),children:u}):e.jsx("button",{type:"button",...m,onClick:g.current?void 0:p(d),children:u})};return e.jsxs("nav",{className:"bim-ct-pager","aria-label":s?a(s):l("catalogPage.pagerLabel"),children:[c(t-1,l("catalogPage.prevPage"),{disabled:t<=1}),e.jsx("ol",{children:fa(t,n).map((d,u)=>e.jsx("li",{style:{display:"contents"},children:d===null?e.jsx("span",{className:"bim-ct-gap","aria-hidden":"true",children:"…"}):c(d,d,{current:d===t,aria:l("catalogPage.pageN",{n:d})})},d??`gap${u}`))}),e.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[t," / ",n]}),c(t+1,l("catalogPage.nextPage"),{disabled:t>=n})]})}function Sa({works:t,workLink:n=ya,emptyText:o,view:r="card",...s}){const{t:l,convert:a}=G();return e.jsxs("div",{className:"bim-ct-works",children:[t.length===0?e.jsx("p",{className:"bim-ct-empty",children:o===void 0?l("catalogPage.emptyWorks"):typeof o=="string"?a(o):o}):r==="list"?e.jsx("ul",{className:"bim-ct-list",children:t.map(p=>e.jsx(ka,{work:p,href:n(p.id)},p.id))}):e.jsx("ul",{className:"bim-ct-grid",children:t.map(p=>e.jsx(va,{work:p,href:n(p.id)},p.id))}),e.jsx(wa,{...s})]})}const Yh=()=>e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:e.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Kh({tree:t,selectedId:n,page:o,pageCount:r,works:s,onSelect:l,onPage:a,searchSlot:p,workLink:c,pageHref:d,allLabel:u,allTitle:g,pageSize:m=zo,className:h,view:f,onViewChange:v}){const{t:y,convert:w}=G(),b=u===void 0?y("catalogPage.all"):u,j=g??y("catalogPage.allTitle"),k=`bim-ct-drawer-${x.useId().replace(/:/g,"")}`,[$,_]=x.useState(!1),[z,E]=x.useState("card"),T=f??z,C=Q=>{E(Q),v==null||v(Q)},O=Bt(t,n&&n!==ht?n:null),W=O.length?O[O.length-1]:null,P=W?W.label:j,Y=W?W.count:To(t),V=x.useCallback(Q=>{_(!1),l(Q)},[l]);return e.jsxs("div",{className:h?`bim-ct ${h}`:"bim-ct","data-drawer":$?"open":"closed",children:[e.jsx("style",{children:xa}),e.jsxs("aside",{className:"bim-ct-side","aria-label":y("catalogPage.sideNav"),children:[e.jsxs("button",{type:"button",className:"bim-ct-drawer-btn","aria-expanded":$,"aria-controls":k,onClick:()=>_(Q=>!Q),children:[e.jsx("span",{children:y("catalogPage.drawerLabel",{path:w(O.length?O.map(Q=>Q.label).join(" › "):b??j)})}),e.jsx(Yh,{})]}),e.jsxs("div",{className:"bim-ct-drawer",id:k,children:[e.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),e.jsx(ba,{tree:t,selectedId:n,onSelect:V,allLabel:b})]})]}),e.jsxs("div",{className:"bim-ct-main",children:[e.jsxs("header",{className:"bim-ct-head",children:[e.jsx("h1",{className:"bim-ct-title",children:w(P)}),O.length>1&&e.jsx("span",{className:"bim-ct-crumb",children:w(O.slice(0,-1).map(Q=>Q.label).join(" › "))}),e.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:Y.toLocaleString("en-US"),size:m}),r>1&&y("catalogPage.statPage",{page:o,pages:r})]}),e.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":y("catalogPage.viewLabel"),children:[e.jsx("button",{type:"button","aria-pressed":T==="card",onClick:()=>C("card"),children:y("catalogPage.viewCard")}),e.jsx("button",{type:"button","aria-pressed":T==="list",onClick:()=>C("list"),children:y("catalogPage.viewList")})]})]}),p&&e.jsx("div",{className:"bim-ct-search",children:p}),e.jsx(Sa,{works:s,view:T,workLink:c,page:o,pageCount:r,onPage:a,pageHref:d})]})]})}const xn="(max-width: 719px)",qh="(max-width: 1079px)",Zh=`${xn}, (pointer: coarse)`,Jh=[8,18,30,42,88],No=`
1268
+ `,Ct="未分類",ht="all",zo=20;function hn(t){if(!t)return[];const n=[];for(const o of[t.l1,t.l2,t.l3,t.l4]){const r=(o??"").trim();if(!r)break;n.push(r)}return n}function Bh(t){const n=hn(t);return n.length?n.join("/"):Ct}function Mh(t){const n=hn(t);return n.length?n.map((o,r)=>n.slice(0,r+1).join("/")):[Ct]}function Wh(t,n=[]){const o=new Map;n.forEach((p,c)=>{const d=[p.cata_l1,p.cata_l2,p.cata_l3,p.cata_l4].filter(u=>!!u);d.forEach((u,g)=>{const m=d.slice(0,g+1).join("/");o.has(m)||o.set(m,c)})});const r=new Map;let s=0;for(const p of t){const c=hn(p.classification);if(!c.length){s++;continue}let d=r;c.forEach((u,g)=>{const m=c.slice(0,g+1).join("/");let x=d.get(u);x||(x={id:m,label:u,count:0,children:new Map},d.set(u,x)),x.count++,d=x.children})}const l=p=>[...p.values()].sort((c,d)=>{const u=c.label===Ct?1:0,g=d.label===Ct?1:0;if(u!==g)return u-g;const m=o.get(c.id)??1/0,x=o.get(d.id)??1/0;return m!==x?m-x:c.label.localeCompare(d.label,"zh")}).map(c=>{const d={id:c.id,label:c.label,count:c.count};return c.children.size&&(d.children=l(c.children)),d}),a=l(r);return s>0&&a.push({id:Ct,label:Ct,count:s}),a}function Bt(t,n){if(!n)return[];for(const o of t){if(o.id===n)return[o];if(o.children){const r=Bt(o.children,n);if(r.length)return[o,...r]}}return[]}function To(t){return t.reduce((n,o)=>n+o.count,0)}function Hh(t){return(t??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function Oh(t){var p;const n={id:t.id,title:t.title||t.id},o=t.juan_count,r=typeof o=="number"?o:o==null?void 0:o.number;typeof r=="number"&&r>0?n.juan=r:t.measure_info&&(n.juan=t.measure_info);const s=(t.authors??[]).filter(c=>c==null?void 0:c.name).map(c=>{const d=c.dynasty||(t.authors.length===1?t.dynasty:void 0);return d?{name:c.name,dynasty:d}:{name:c.name}});s.length&&(n.authors=s);const l=Hh(typeof t.description=="string"?t.description:(p=t.description)==null?void 0:p.text);l&&(n.summary=l);const a=hn(t.classification);return a.length&&(n.classification=a),n}function Fh(t,n){const o=t.summary?0:1,r=n.summary?0:1;return o!==r?o-r:t.title.localeCompare(n.title,"zh")}function Dh(t,n=zo){return Math.max(1,Math.ceil(t/n))}function fa(t,n,o=2){if(n<=1)return[1];const r=new Set([1,n]);for(let a=t-o;a<=t+o;a++)a>=1&&a<=n&&r.add(a);const s=[...r].sort((a,p)=>a-p),l=[];return s.forEach((a,p)=>{if(p>0){const c=a-s[p-1];c===2?l.push(a-1):c>2&&l.push(null)}l.push(a)}),l}const Uh=()=>e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:e.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Vh(t,n,o){const r=[];o&&r.push({id:ht,parentId:null,hasChildren:!1,firstChildId:null});const s=(l,a)=>{var p;for(const c of l){const d=(p=c.children)!=null&&p.length?c.children:null;r.push({id:c.id,parentId:a,hasChildren:!!d,firstChildId:d?d[0].id:null}),d&&n.has(c.id)&&s(d,c.id)}};return s(t,null),r}function ba({tree:t,selectedId:n,onSelect:o,allLabel:r,label:s}){const{t:l,convert:a}=Y(),p=r===void 0?l("catalogPage.all"):r,c=s??l("catalogPage.classification"),d=h.useRef(null),u=n&&n!==ht?n:null,g=p!==null,[m,x]=h.useState(()=>{const z=new Set;for(const E of Bt(t,u))z.add(E.id);return z});h.useEffect(()=>{const z=Bt(t,u);z.length&&x(E=>{if(z.every(_=>E.has(_.id)))return E;const T=new Set(E);for(const _ of z)T.add(_.id);return T})},[t,u]);const f=h.useMemo(()=>Vh(t,m,g),[t,m,g]),[k,b]=h.useState(null);h.useEffect(()=>{b(null)},[n]);const w=u??(g?ht:null),y=h.useMemo(()=>{var T;const z=new Set(f.map(_=>_.id));if(k&&z.has(k))return k;if(w&&z.has(w))return w;const E=Bt(t,u).map(_=>_.id).filter(_=>z.has(_));return E.length?E[E.length-1]:((T=f[0])==null?void 0:T.id)??null},[f,k,w,t,u]),j=h.useCallback((z,E)=>{x(T=>{const _=T.has(z),O=E??!_;if(O===_)return T;const W=new Set(T);return O?W.add(z):W.delete(z),W})},[]),S=h.useCallback(z=>{b(z),requestAnimationFrame(()=>{var T;const E=Array.from(((T=d.current)==null?void 0:T.querySelectorAll("[data-ct-id]"))??[]).find(_=>_.dataset.ctId===z);E==null||E.focus()})},[]),v=h.useCallback((z,E)=>{E&&j(z,!0),o(z)},[o,j]),$=h.useCallback(z=>{const E=z.target.closest("[data-ct-id]");if(!E)return;const T=E.dataset.ctId,_=f.findIndex(A=>A.id===T);if(_<0)return;const O=f[_];let W=null;switch(z.key){case"ArrowDown":W=f[Math.min(f.length-1,_+1)].id;break;case"ArrowUp":W=f[Math.max(0,_-1)].id;break;case"Home":W=f[0].id;break;case"End":W=f[f.length-1].id;break;case"ArrowRight":if(!O.hasChildren)break;m.has(T)?W=O.firstChildId:j(T,!0);break;case"ArrowLeft":O.hasChildren&&m.has(T)?j(T,!1):W=O.parentId;break;case"Enter":case" ":z.preventDefault(),v(T,O.hasChildren);return;default:return}z.preventDefault(),W&&W!==T&&S(W)},[f,m,j,S,v]),C=(z,E)=>z.map((T,_)=>{var V;const O=(V=T.children)!=null&&V.length?T.children:null,W=!!O&&m.has(T.id),A=T.id===u,G=E===1&&z.length>1&&_===z.length-1;return e.jsxs("li",{role:"treeitem","aria-level":E,"aria-expanded":O?W:void 0,"aria-selected":A,tabIndex:y===T.id?0:-1,"data-ct-id":T.id,className:G?"bim-ct-last":void 0,children:[e.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":E-1},onClick:()=>{b(T.id),v(T.id,!!O)},children:[e.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:O?ie=>{ie.stopPropagation(),b(T.id),j(T.id)}:void 0,children:O?e.jsx(Uh,{}):null}),e.jsx("span",{className:"bim-ct-lb",children:a(T.label)}),e.jsx("span",{className:"bim-ct-n",children:T.count.toLocaleString("en-US")})]}),W&&e.jsx("ul",{role:"group",children:C(O,E+1)})]},T.id)});return e.jsxs("ul",{ref:d,role:"tree","aria-label":a(c),className:"bim-ct-tree",onKeyDown:$,children:[g&&e.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!u,tabIndex:y===ht?0:-1,"data-ct-id":ht,children:e.jsxs("div",{className:"bim-ct-row",onClick:()=>{b(ht),o(ht)},children:[e.jsx("span",{className:"bim-ct-tw","aria-hidden":"true"}),e.jsx("span",{className:"bim-ct-lb",children:a(p)}),e.jsx("span",{className:"bim-ct-n",children:To(t).toLocaleString("en-US")})]})}),C(t,1)]})}const ya=t=>`/item/${encodeURIComponent(t)}`;function Gh(t){return t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey}function ja(t,n){return t==null||t===""?null:typeof t=="number"?n("catalogPage.juanN",{n:t}):t}function va({work:t,href:n}){var p,c;const{t:o,convert:r}=Y(),s=ja(t.juan,o),l=((p=t.authors)==null?void 0:p.filter(d=>d.name))??[],a=((c=t.classification)==null?void 0:c.filter(Boolean))??[];return e.jsx("li",{className:"bim-ct-card",children:e.jsxs("a",{href:n,children:[e.jsxs("div",{className:"bim-ct-ch",children:[e.jsx("h2",{className:"bim-ct-ct",children:r(t.title)}),s&&e.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),l.length>0&&e.jsx("span",{className:"bim-ct-by",children:l.map((d,u)=>e.jsxs(h.Fragment,{children:[u>0&&"、",d.dynasty&&e.jsxs("span",{className:"bim-ct-dy",children:["〔",r(d.dynasty),"〕"]}),r(d.name)]},u))}),t.summary&&e.jsx("p",{className:"bim-ct-sum",children:r(t.summary)}),a.length>0&&e.jsx("span",{className:"bim-ct-cls",children:a.map(d=>r(d)).join(" · ")})]})})}function ka({work:t,href:n}){var p,c;const{t:o,convert:r}=Y(),s=ja(t.juan,o),l=((p=t.authors)==null?void 0:p.filter(d=>d.name))??[],a=((c=t.classification)==null?void 0:c.filter(Boolean))??[];return e.jsx("li",{className:"bim-ct-lrow",children:e.jsxs("a",{href:n,children:[e.jsxs("span",{className:"bim-ct-lt",children:[r(t.title),s&&e.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),e.jsx("span",{className:"bim-ct-by",children:l.map((d,u)=>e.jsxs(h.Fragment,{children:[u>0&&"、",d.dynasty&&e.jsxs("span",{className:"bim-ct-dy",children:["〔",r(d.dynasty),"〕"]}),r(d.name)]},u))}),e.jsx("span",{className:"bim-ct-cls",children:a.map(d=>r(d)).join(" · ")})]})})}function wa({page:t,pageCount:n,onPage:o,pageHref:r,label:s}){const{t:l,convert:a}=Y();if(n<=1)return null;const p=d=>u=>{o&&(r&&!Gh(u)||(u.preventDefault(),o(d)))},c=(d,u,g)=>{if(g.disabled)return e.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:u});const m={className:"bim-ct-pg","aria-current":g.current?"page":void 0,"aria-label":g.aria};return r?e.jsx("a",{...m,href:r(d),onClick:p(d),children:u}):e.jsx("button",{type:"button",...m,onClick:g.current?void 0:p(d),children:u})};return e.jsxs("nav",{className:"bim-ct-pager","aria-label":s?a(s):l("catalogPage.pagerLabel"),children:[c(t-1,l("catalogPage.prevPage"),{disabled:t<=1}),e.jsx("ol",{children:fa(t,n).map((d,u)=>e.jsx("li",{style:{display:"contents"},children:d===null?e.jsx("span",{className:"bim-ct-gap","aria-hidden":"true",children:"…"}):c(d,d,{current:d===t,aria:l("catalogPage.pageN",{n:d})})},d??`gap${u}`))}),e.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[t," / ",n]}),c(t+1,l("catalogPage.nextPage"),{disabled:t>=n})]})}function Sa({works:t,workLink:n=ya,emptyText:o,view:r="card",...s}){const{t:l,convert:a}=Y();return e.jsxs("div",{className:"bim-ct-works",children:[t.length===0?e.jsx("p",{className:"bim-ct-empty",children:o===void 0?l("catalogPage.emptyWorks"):typeof o=="string"?a(o):o}):r==="list"?e.jsx("ul",{className:"bim-ct-list",children:t.map(p=>e.jsx(ka,{work:p,href:n(p.id)},p.id))}):e.jsx("ul",{className:"bim-ct-grid",children:t.map(p=>e.jsx(va,{work:p,href:n(p.id)},p.id))}),e.jsx(wa,{...s})]})}const Yh=()=>e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:e.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Kh({tree:t,selectedId:n,page:o,pageCount:r,works:s,onSelect:l,onPage:a,searchSlot:p,workLink:c,pageHref:d,allLabel:u,allTitle:g,pageSize:m=zo,className:x,view:f,onViewChange:k}){const{t:b,convert:w}=Y(),y=u===void 0?b("catalogPage.all"):u,j=g??b("catalogPage.allTitle"),v=`bim-ct-drawer-${h.useId().replace(/:/g,"")}`,[$,C]=h.useState(!1),[z,E]=h.useState("card"),T=f??z,_=ie=>{E(ie),k==null||k(ie)},O=Bt(t,n&&n!==ht?n:null),W=O.length?O[O.length-1]:null,A=W?W.label:j,G=W?W.count:To(t),V=h.useCallback(ie=>{C(!1),l(ie)},[l]);return e.jsxs("div",{className:x?`bim-ct ${x}`:"bim-ct","data-drawer":$?"open":"closed",children:[e.jsx("style",{children:xa}),e.jsxs("aside",{className:"bim-ct-side","aria-label":b("catalogPage.sideNav"),children:[e.jsxs("button",{type:"button",className:"bim-ct-drawer-btn","aria-expanded":$,"aria-controls":v,onClick:()=>C(ie=>!ie),children:[e.jsx("span",{children:b("catalogPage.drawerLabel",{path:w(O.length?O.map(ie=>ie.label).join(" › "):y??j)})}),e.jsx(Yh,{})]}),e.jsxs("div",{className:"bim-ct-drawer",id:v,children:[e.jsx("h2",{className:"bim-ct-side-h",children:b("catalogPage.classification")}),e.jsx(ba,{tree:t,selectedId:n,onSelect:V,allLabel:y})]})]}),e.jsxs("div",{className:"bim-ct-main",children:[e.jsxs("header",{className:"bim-ct-head",children:[e.jsx("h1",{className:"bim-ct-title",children:w(A)}),O.length>1&&e.jsx("span",{className:"bim-ct-crumb",children:w(O.slice(0,-1).map(ie=>ie.label).join(" › "))}),e.jsxs("span",{className:"bim-ct-stat",children:[b("catalogPage.stat",{total:G.toLocaleString("en-US"),size:m}),r>1&&b("catalogPage.statPage",{page:o,pages:r})]}),e.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":b("catalogPage.viewLabel"),children:[e.jsx("button",{type:"button","aria-pressed":T==="card",onClick:()=>_("card"),children:b("catalogPage.viewCard")}),e.jsx("button",{type:"button","aria-pressed":T==="list",onClick:()=>_("list"),children:b("catalogPage.viewList")})]})]}),p&&e.jsx("div",{className:"bim-ct-search",children:p}),e.jsx(Sa,{works:s,view:T,workLink:c,page:o,pageCount:r,onPage:a,pageHref:d})]})]})}const xn="(max-width: 719px)",qh="(max-width: 1079px)",Zh=`${xn}, (pointer: coarse)`,Jh=[8,18,30,42,88],No=`
1269
1269
  .bim-rh { color: ${i("ink")}; font-family: ${i("font-ui")}; font-size: 14px; line-height: 1.6; }
1270
1270
  .bim-rh *, .bim-rh *::before, .bim-rh *::after { box-sizing: border-box; }
1271
1271
  .bim-rh a { color: ${i("accent")}; text-decoration: none; }
@@ -1495,7 +1495,7 @@ ${Jh.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1495
1495
  }
1496
1496
 
1497
1497
  @media (prefers-reduced-motion: reduce) { .bim-rh * { scroll-behavior: auto !important; transition: none !important; } }
1498
- `,Xh=Wi["zh-Hant"].period,$a={read:t=>`/read/${encodeURIComponent(t)}`,node:t=>`/read?node=${encodeURIComponent(t)}`,period:t=>`/read?period=${encodeURIComponent(t)}`,work:t=>`/item/${encodeURIComponent(t)}`};function vt(t){return{...$a,...t??{}}}function Io(t){var o;const n=(o=t.authors)==null?void 0:o.find(r=>r==null?void 0:r.name);return n?n.dynasty?`${n.dynasty} ${n.name}`:n.name:""}function Kn(t){return(t.authors??[]).filter(o=>o==null?void 0:o.name).map(o=>o.dynasty?`〔${o.dynasty}〕${o.name}`:o.name).join(" ")}function _a(t,n=Wi["zh-Hant"].shelfOther){var s;const o=[],r=new Map;for(const l of t){const a=((s=l.period_of)==null?void 0:s.trim())||n;let p=r.get(a);p||(p={label:a,items:[]},r.set(a,p),o.push(p)),p.items.push(l)}return o}function Ca(t){return Math.max(150,Array.from(t).length*18+44)}function za(t,n){if(n<=0||t<=0)return 0;const o=t/n;return o<.15?0:o<.35?1:o<.6?2:o<.85?3:4}const Ta=.04;function Ue(t){return t.toLocaleString("en-US")}function Na({text:t}){return e.jsx(e.Fragment,{children:Array.from(t).map((n,o)=>e.jsx("span",{children:n},o))})}function et({id:t,title:n,sub:o,more:r,children:s}){const{convert:l}=G(),a=`${t}-h`;return e.jsxs("section",{className:"bim-rh-sec",id:t,"aria-labelledby":a,children:[e.jsxs("div",{className:"bim-rh-hd",children:[e.jsx("h2",{id:a,children:l(n)}),o&&e.jsx("span",{className:"bim-rh-sub",children:o}),r]}),e.jsx("div",{className:"bim-rh-bd",children:s})]})}function Ia({counts:t}){const{t:n}=G();return e.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[e.jsxs("span",{children:[e.jsx("b",{children:Ue(t.readable)}),n("readHome.readable")]}),t.pieces>0&&e.jsxs("span",{children:[e.jsx("b",{children:Ue(t.pieces)}),n("readHome.pieces")]})]})}function Ra({picks:t,links:n}){const{t:o,convert:r}=G(),s=vt(n);return t.length?e.jsx("ul",{className:"bim-rh-picks",children:t.map(l=>{const a=Kn(l),p=[l.type_label,l.edition].filter(Boolean).join(" · ");return e.jsx("li",{children:e.jsxs("a",{className:"bim-rh-pk",href:s.read(l.id),children:[e.jsx("span",{className:"bim-rh-slip","aria-hidden":"true",children:e.jsx(Na,{text:r(l.slip||l.title)})}),e.jsxs("span",{className:"bim-rh-pk-body",children:[p&&e.jsx("span",{className:"bim-rh-badge",children:r(p)}),e.jsx("h3",{children:r(l.title)}),a&&e.jsx("span",{className:"bim-rh-by",children:r(a)}),l.blurb&&e.jsx("p",{children:r(l.blurb)}),e.jsx("span",{className:"bim-rh-go","aria-hidden":"true",children:o("readHome.startReading")})]})]})},l.id)})}):null}function Ea(t,n){return t&&t>1?n("readHome.nCopies",{n:t}):null}function Ro({topic:t,links:n,hint:o,legendCount:r,showTitle:s=!0,legendExtra:l}){const{t:a,convert:p}=G(),c=vt(n);if(!t.items.length)return null;const d=r===void 0?a("readHome.shelfLegendCount"):r,u=_a(t.items,a("readHome.shelfOther")),g=m=>{const h=m.records?Ue(m.records):Ea(m.text_count,a),f=Io(m),v=[p(m.title),m.orig?a("readHome.origZhi"):"",f?a("readHome.spineBy",{name:p(f)}):"",m.records?a("readHome.spineRecords",{n:h}):h?a("readHome.spineOnSite",{n:h}):""].filter(Boolean).join(",");return e.jsx("li",{children:e.jsxs("a",{className:"bim-rh-spine",href:c.read(m.id),"data-orig":m.orig?"":void 0,"aria-label":v,title:v,style:{height:Ca(m.title)},children:[e.jsx(Na,{text:p(m.title)}),h&&e.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":m.records?"":void 0,children:h})]})},m.id)};return e.jsxs("div",{className:"bim-rh-shelf-box",children:[s&&e.jsxs("h3",{className:"bim-rh-gt",children:[p(t.label),e.jsx("small",{children:o?p(o):a("readHome.shelfHint")})]}),e.jsx("div",{className:"bim-rh-shelf-wrap",tabIndex:0,role:"region","aria-label":a("readHome.shelfRegion",{label:p(t.label)}),children:e.jsx("ul",{className:"bim-rh-shelf",children:u.map(m=>e.jsxs("li",{className:"bim-rh-era",children:[e.jsx("ul",{className:"bim-rh-spines","aria-label":p(m.label),children:m.items.map(g)}),e.jsx("span",{"aria-hidden":"true",children:p(m.label)})]},m.label))})}),e.jsxs("p",{className:"bim-rh-legend",children:[e.jsxs("span",{children:[e.jsx("i",{"data-orig":"","aria-hidden":"true"}),a("readHome.origZhi")]}),e.jsxs("span",{children:[e.jsx("i",{"aria-hidden":"true"}),a("readHome.laterZhi")]}),d&&e.jsx("span",{children:p(d)}),l==null?void 0:l.map(m=>e.jsx("span",{children:p(m)},m))]})]})}const Qh=4,cn=t=>t>Qh+1;function La({topic:t,links:n}){const{t:o,convert:r}=G(),s=vt(n),[l,a]=x.useState(!1);if(!t.items.length)return null;const p=`bim-rh-g-${t.key}`;return e.jsxs("div",{className:"bim-rh-grp","data-cap":cn(t.items.length)?"":void 0,"data-open":l?"":void 0,children:[e.jsxs("h3",{className:"bim-rh-gt",id:p,children:[r(t.label),e.jsx("small",{className:"bim-rh-num",children:o("readHome.nWorks",{n:Ue(t.items.length)})})]}),e.jsx("ul",{className:"bim-rh-rows","aria-labelledby":p,children:t.items.map(c=>{const d=Ea(c.text_count,o),u=Io(c);return e.jsx("li",{children:e.jsxs("a",{href:s.read(c.id),children:[e.jsx("span",{className:"bim-rh-t",children:r(c.title)}),d&&e.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:d}),u&&e.jsx("small",{children:r(u)})]})},c.id)})}),cn(t.items.length)&&e.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":l,onClick:()=>a(c=>!c),children:l?o("action.collapse"):o("readHome.allNWorks",{n:t.items.length})})]})}function Pa({topics:t,links:n}){const o=t.filter(s=>s.shelf&&s.items.length),r=t.filter(s=>!s.shelf&&s.items.length);return!o.length&&!r.length?null:e.jsxs(e.Fragment,{children:[o.map(s=>e.jsx(Ro,{topic:s,links:n},s.key)),r.length>0&&e.jsx("div",{className:"bim-rh-groups",children:r.map(s=>e.jsx(La,{topic:s,links:n},s.key))})]})}function Aa({famous:t,links:n}){const{t:o,convert:r}=G(),s=vt(n);return t.length?e.jsx("ul",{className:"bim-rh-works",children:t.map(l=>e.jsx("li",{children:e.jsxs("article",{className:"bim-rh-wk",children:[e.jsxs("div",{className:"bim-rh-wk-h",children:[e.jsx("h3",{children:r(l.title)}),l.authors&&e.jsx("span",{className:"bim-rh-by",children:r(l.authors)}),e.jsx("span",{className:"bim-rh-c bim-rh-num",children:o("readHome.nCopiesCard",{n:l.text_count})})]}),l.systems.map((a,p)=>e.jsxs("div",{className:"bim-rh-lin",role:"group","aria-label":a.label?r(a.label):void 0,children:[a.label&&e.jsx("small",{"aria-hidden":"true",children:r(a.label)}),a.items.map(c=>e.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))]},p)),l.work_id&&e.jsx("div",{className:"bim-rh-wk-f",children:e.jsx("a",{href:s.work(l.work_id),children:o("readHome.workPageLink",{title:r(l.title)})})})]})},l.work_id??l.title))}):null}function Eo({bu:t,unclassified:n,links:o,unclassifiedNote:r}){const{t:s,convert:l}=G(),a=vt(o);return!t.length&&!n?null:e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"bim-rh-bu",children:t.map(p=>{var d;const c=((d=p.top[0])==null?void 0:d.count)||1;return e.jsxs("li",{className:"bim-rh-bu-c",children:[e.jsxs("a",{className:"bim-rh-bu-h",href:a.node(p.id),children:[e.jsx("b",{children:l(p.label)}),e.jsx("span",{className:"bim-rh-num",children:s("readHome.nWorks",{n:Ue(p.count)})})]}),p.top.length>0&&e.jsx("ul",{className:"bim-rh-bu-l","aria-label":s("readHome.subClasses",{label:l(p.label)}),children:p.top.map(u=>e.jsx("li",{children:e.jsxs("a",{href:a.node(u.id),children:[e.jsx("span",{children:l(u.label)}),e.jsx("small",{className:"bim-rh-num",children:Ue(u.count)}),e.jsx("span",{className:"bim-rh-bar","aria-hidden":"true",style:{"--bimrh-w":`${Math.round(u.count/c*100)}%`}})]})},u.id))}),p.children_total>p.top.length&&e.jsx("a",{className:"bim-rh-bu-more",href:a.node(p.id),children:s("readHome.allNClasses",{label:l(p.label),n:p.children_total})})]},p.id)})}),!!n&&e.jsxs("p",{className:"bim-rh-uncl bim-rh-num",children:[e.jsx("b",{children:s("readHome.unclassified")}),e.jsx("span",{children:s("readHome.nWorks",{n:Ue(n)})}),e.jsx("span",{children:r?l(r):s("readHome.sibuUnclassifiedNote")}),e.jsx("a",{href:a.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function Ba({periods:t,unknown:n,links:o}){const{t:r,convert:s,messages:l}=G(),a=l.readHome.period,p=vt(o),c=t.filter(g=>g.count>0);if(!c.length)return null;const d=c.reduce((g,m)=>g+m.count,0),u=Math.max(...c.map(g=>g.count));return e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"bim-rh-band",children:c.map(g=>{const m=g.label?s(g.label):a[g.key]??s(g.key),h=g.count/d,f=r("readHome.periodItem",{label:m,n:Ue(g.count)});return e.jsx("li",{style:{flex:`0 0 ${(h*100).toFixed(3)}%`},children:e.jsxs("a",{href:p.period(g.key),"data-k":za(g.count,u),"data-narrow":h<Ta?"":void 0,"aria-label":f,title:f,children:[e.jsx("span",{className:"bim-rh-pl",children:m}),e.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(m)[0]}),e.jsx("small",{className:"bim-rh-num",children:Ue(g.count)})]})},g.key)})}),e.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&e.jsx("span",{children:r("readHome.periodUnknown",{n:Ue(n)})}),e.jsx("span",{className:"bim-rh-hover-hint",children:r("readHome.hoverHint")})]})]})}function Ma({authors:t,links:n}){const{t:o,convert:r}=G(),s=vt(n);return t.length?e.jsx("ul",{className:"bim-rh-authors",children:t.map(l=>e.jsxs("li",{className:"bim-rh-au",children:[e.jsxs("h3",{className:"bim-rh-au-h",children:[r(l.name),l.dynasty&&e.jsx("span",{children:r(l.dynasty)}),e.jsx("small",{className:"bim-rh-num",children:o("readHome.nPieces",{n:Ue(l.count)})})]}),e.jsx("ul",{children:l.items.map(a=>e.jsx("li",{children:e.jsx("a",{href:s.read(a.id),children:r(a.title)})},a.id))}),s.author&&e.jsx("a",{className:"bim-rh-more",href:s.author(l.name),children:o("readHome.authorAll",{name:r(l.name),n:l.count})})]},l.name))}):null}const Wa={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function ex({sections:t,links:n,head:o,piecesMoreHref:r,className:s}){const{t:l}=G(),a=t,p=Wa,c=a.topics.filter(m=>!m.shelf),d={picks:a.picks.length>0,topics:c.some(m=>m.items.length>0),famous:a.famous.length>0,sibu:a.bu.length>0||a.unclassified>0,period:a.periods.some(m=>m.count>0),pieces:a.pieces.authors.length>0},u=Object.keys(p).filter(m=>d[m]),g=m=>l(`readHome.nav.${m}`);return e.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[e.jsx("style",{children:No}),e.jsxs("div",{className:"bim-rh-head",children:[o,e.jsx(Ia,{counts:a.counts})]}),u.length>1&&e.jsx("nav",{className:"bim-rh-secnav","aria-label":l("readHome.navLabel"),children:e.jsx("ul",{children:u.map(m=>e.jsx("li",{children:e.jsx("a",{href:`#${p[m]}`,children:g(m)})},m))})}),e.jsxs("div",{className:"bim-rh-main",children:[d.picks&&e.jsx(et,{id:p.picks,title:g("picks"),sub:l("readHome.picksSub"),children:e.jsx(Ra,{picks:a.picks,links:n})}),d.topics&&e.jsx(et,{id:p.topics,title:g("topics"),sub:l("readHome.topicsSub"),children:e.jsx(Pa,{topics:c,links:n})}),d.famous&&e.jsx(et,{id:p.famous,title:g("famous"),sub:l("readHome.famousSub"),children:e.jsx(Aa,{famous:a.famous,links:n})}),d.sibu&&e.jsx(et,{id:p.sibu,title:g("sibu"),sub:l("readHome.sibuSub"),children:e.jsx(Eo,{bu:a.bu,unclassified:a.unclassified,links:n})}),d.period&&e.jsx(et,{id:p.period,title:g("period"),sub:l("readHome.periodSub"),children:e.jsx(Ba,{periods:a.periods,unknown:a.period_unknown,links:n})}),d.pieces&&e.jsx(et,{id:p.pieces,title:g("pieces"),sub:l("readHome.piecesSub"),more:r?e.jsx("a",{className:"bim-rh-more",href:r,children:l("readHome.piecesMore")}):void 0,children:e.jsx(Ma,{authors:a.pieces.authors,links:n})})]})]})}const tx="(max-width: 1079px)",nx=`${xn}, (pointer: coarse)`,Ha=`
1498
+ `,Xh=Wi["zh-Hant"].period,$a={read:t=>`/read/${encodeURIComponent(t)}`,node:t=>`/read?node=${encodeURIComponent(t)}`,period:t=>`/read?period=${encodeURIComponent(t)}`,work:t=>`/item/${encodeURIComponent(t)}`};function vt(t){return{...$a,...t??{}}}function Io(t){var o;const n=(o=t.authors)==null?void 0:o.find(r=>r==null?void 0:r.name);return n?n.dynasty?`${n.dynasty} ${n.name}`:n.name:""}function Kn(t){return(t.authors??[]).filter(o=>o==null?void 0:o.name).map(o=>o.dynasty?`〔${o.dynasty}〕${o.name}`:o.name).join(" ")}function _a(t,n=Wi["zh-Hant"].shelfOther){var s;const o=[],r=new Map;for(const l of t){const a=((s=l.period_of)==null?void 0:s.trim())||n;let p=r.get(a);p||(p={label:a,items:[]},r.set(a,p),o.push(p)),p.items.push(l)}return o}function Ca(t){return Math.max(150,Array.from(t).length*18+44)}function za(t,n){if(n<=0||t<=0)return 0;const o=t/n;return o<.15?0:o<.35?1:o<.6?2:o<.85?3:4}const Ta=.04;function Ue(t){return t.toLocaleString("en-US")}function Na({text:t}){return e.jsx(e.Fragment,{children:Array.from(t).map((n,o)=>e.jsx("span",{children:n},o))})}function et({id:t,title:n,sub:o,more:r,children:s}){const{convert:l}=Y(),a=`${t}-h`;return e.jsxs("section",{className:"bim-rh-sec",id:t,"aria-labelledby":a,children:[e.jsxs("div",{className:"bim-rh-hd",children:[e.jsx("h2",{id:a,children:l(n)}),o&&e.jsx("span",{className:"bim-rh-sub",children:o}),r]}),e.jsx("div",{className:"bim-rh-bd",children:s})]})}function Ia({counts:t}){const{t:n}=Y();return e.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[e.jsxs("span",{children:[e.jsx("b",{children:Ue(t.readable)}),n("readHome.readable")]}),t.pieces>0&&e.jsxs("span",{children:[e.jsx("b",{children:Ue(t.pieces)}),n("readHome.pieces")]})]})}function Ra({picks:t,links:n}){const{t:o,convert:r}=Y(),s=vt(n);return t.length?e.jsx("ul",{className:"bim-rh-picks",children:t.map(l=>{const a=Kn(l),p=[l.type_label,l.edition].filter(Boolean).join(" · ");return e.jsx("li",{children:e.jsxs("a",{className:"bim-rh-pk",href:s.read(l.id),children:[e.jsx("span",{className:"bim-rh-slip","aria-hidden":"true",children:e.jsx(Na,{text:r(l.slip||l.title)})}),e.jsxs("span",{className:"bim-rh-pk-body",children:[p&&e.jsx("span",{className:"bim-rh-badge",children:r(p)}),e.jsx("h3",{children:r(l.title)}),a&&e.jsx("span",{className:"bim-rh-by",children:r(a)}),l.blurb&&e.jsx("p",{children:r(l.blurb)}),e.jsx("span",{className:"bim-rh-go","aria-hidden":"true",children:o("readHome.startReading")})]})]})},l.id)})}):null}function Ea(t,n){return t&&t>1?n("readHome.nCopies",{n:t}):null}function Ro({topic:t,links:n,hint:o,legendCount:r,showTitle:s=!0,legendExtra:l}){const{t:a,convert:p}=Y(),c=vt(n);if(!t.items.length)return null;const d=r===void 0?a("readHome.shelfLegendCount"):r,u=_a(t.items,a("readHome.shelfOther")),g=m=>{const x=m.records?Ue(m.records):Ea(m.text_count,a),f=Io(m),k=[p(m.title),m.orig?a("readHome.origZhi"):"",f?a("readHome.spineBy",{name:p(f)}):"",m.records?a("readHome.spineRecords",{n:x}):x?a("readHome.spineOnSite",{n:x}):""].filter(Boolean).join(",");return e.jsx("li",{children:e.jsxs("a",{className:"bim-rh-spine",href:c.read(m.id),"data-orig":m.orig?"":void 0,"aria-label":k,title:k,style:{height:Ca(m.title)},children:[e.jsx(Na,{text:p(m.title)}),x&&e.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":m.records?"":void 0,children:x})]})},m.id)};return e.jsxs("div",{className:"bim-rh-shelf-box",children:[s&&e.jsxs("h3",{className:"bim-rh-gt",children:[p(t.label),e.jsx("small",{children:o?p(o):a("readHome.shelfHint")})]}),e.jsx("div",{className:"bim-rh-shelf-wrap",tabIndex:0,role:"region","aria-label":a("readHome.shelfRegion",{label:p(t.label)}),children:e.jsx("ul",{className:"bim-rh-shelf",children:u.map(m=>e.jsxs("li",{className:"bim-rh-era",children:[e.jsx("ul",{className:"bim-rh-spines","aria-label":p(m.label),children:m.items.map(g)}),e.jsx("span",{"aria-hidden":"true",children:p(m.label)})]},m.label))})}),e.jsxs("p",{className:"bim-rh-legend",children:[e.jsxs("span",{children:[e.jsx("i",{"data-orig":"","aria-hidden":"true"}),a("readHome.origZhi")]}),e.jsxs("span",{children:[e.jsx("i",{"aria-hidden":"true"}),a("readHome.laterZhi")]}),d&&e.jsx("span",{children:p(d)}),l==null?void 0:l.map(m=>e.jsx("span",{children:p(m)},m))]})]})}const Qh=4,cn=t=>t>Qh+1;function La({topic:t,links:n}){const{t:o,convert:r}=Y(),s=vt(n),[l,a]=h.useState(!1);if(!t.items.length)return null;const p=`bim-rh-g-${t.key}`;return e.jsxs("div",{className:"bim-rh-grp","data-cap":cn(t.items.length)?"":void 0,"data-open":l?"":void 0,children:[e.jsxs("h3",{className:"bim-rh-gt",id:p,children:[r(t.label),e.jsx("small",{className:"bim-rh-num",children:o("readHome.nWorks",{n:Ue(t.items.length)})})]}),e.jsx("ul",{className:"bim-rh-rows","aria-labelledby":p,children:t.items.map(c=>{const d=Ea(c.text_count,o),u=Io(c);return e.jsx("li",{children:e.jsxs("a",{href:s.read(c.id),children:[e.jsx("span",{className:"bim-rh-t",children:r(c.title)}),d&&e.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:d}),u&&e.jsx("small",{children:r(u)})]})},c.id)})}),cn(t.items.length)&&e.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":l,onClick:()=>a(c=>!c),children:l?o("action.collapse"):o("readHome.allNWorks",{n:t.items.length})})]})}function Pa({topics:t,links:n}){const o=t.filter(s=>s.shelf&&s.items.length),r=t.filter(s=>!s.shelf&&s.items.length);return!o.length&&!r.length?null:e.jsxs(e.Fragment,{children:[o.map(s=>e.jsx(Ro,{topic:s,links:n},s.key)),r.length>0&&e.jsx("div",{className:"bim-rh-groups",children:r.map(s=>e.jsx(La,{topic:s,links:n},s.key))})]})}function Aa({famous:t,links:n}){const{t:o,convert:r}=Y(),s=vt(n);return t.length?e.jsx("ul",{className:"bim-rh-works",children:t.map(l=>e.jsx("li",{children:e.jsxs("article",{className:"bim-rh-wk",children:[e.jsxs("div",{className:"bim-rh-wk-h",children:[e.jsx("h3",{children:r(l.title)}),l.authors&&e.jsx("span",{className:"bim-rh-by",children:r(l.authors)}),e.jsx("span",{className:"bim-rh-c bim-rh-num",children:o("readHome.nCopiesCard",{n:l.text_count})})]}),l.systems.map((a,p)=>e.jsxs("div",{className:"bim-rh-lin",role:"group","aria-label":a.label?r(a.label):void 0,children:[a.label&&e.jsx("small",{"aria-hidden":"true",children:r(a.label)}),a.items.map(c=>e.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))]},p)),l.work_id&&e.jsx("div",{className:"bim-rh-wk-f",children:e.jsx("a",{href:s.work(l.work_id),children:o("readHome.workPageLink",{title:r(l.title)})})})]})},l.work_id??l.title))}):null}function Eo({bu:t,unclassified:n,links:o,unclassifiedNote:r}){const{t:s,convert:l}=Y(),a=vt(o);return!t.length&&!n?null:e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"bim-rh-bu",children:t.map(p=>{var d;const c=((d=p.top[0])==null?void 0:d.count)||1;return e.jsxs("li",{className:"bim-rh-bu-c",children:[e.jsxs("a",{className:"bim-rh-bu-h",href:a.node(p.id),children:[e.jsx("b",{children:l(p.label)}),e.jsx("span",{className:"bim-rh-num",children:s("readHome.nWorks",{n:Ue(p.count)})})]}),p.top.length>0&&e.jsx("ul",{className:"bim-rh-bu-l","aria-label":s("readHome.subClasses",{label:l(p.label)}),children:p.top.map(u=>e.jsx("li",{children:e.jsxs("a",{href:a.node(u.id),children:[e.jsx("span",{children:l(u.label)}),e.jsx("small",{className:"bim-rh-num",children:Ue(u.count)}),e.jsx("span",{className:"bim-rh-bar","aria-hidden":"true",style:{"--bimrh-w":`${Math.round(u.count/c*100)}%`}})]})},u.id))}),p.children_total>p.top.length&&e.jsx("a",{className:"bim-rh-bu-more",href:a.node(p.id),children:s("readHome.allNClasses",{label:l(p.label),n:p.children_total})})]},p.id)})}),!!n&&e.jsxs("p",{className:"bim-rh-uncl bim-rh-num",children:[e.jsx("b",{children:s("readHome.unclassified")}),e.jsx("span",{children:s("readHome.nWorks",{n:Ue(n)})}),e.jsx("span",{children:r?l(r):s("readHome.sibuUnclassifiedNote")}),e.jsx("a",{href:a.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function Ba({periods:t,unknown:n,links:o}){const{t:r,convert:s,messages:l}=Y(),a=l.readHome.period,p=vt(o),c=t.filter(g=>g.count>0);if(!c.length)return null;const d=c.reduce((g,m)=>g+m.count,0),u=Math.max(...c.map(g=>g.count));return e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"bim-rh-band",children:c.map(g=>{const m=g.label?s(g.label):a[g.key]??s(g.key),x=g.count/d,f=r("readHome.periodItem",{label:m,n:Ue(g.count)});return e.jsx("li",{style:{flex:`0 0 ${(x*100).toFixed(3)}%`},children:e.jsxs("a",{href:p.period(g.key),"data-k":za(g.count,u),"data-narrow":x<Ta?"":void 0,"aria-label":f,title:f,children:[e.jsx("span",{className:"bim-rh-pl",children:m}),e.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(m)[0]}),e.jsx("small",{className:"bim-rh-num",children:Ue(g.count)})]})},g.key)})}),e.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&e.jsx("span",{children:r("readHome.periodUnknown",{n:Ue(n)})}),e.jsx("span",{className:"bim-rh-hover-hint",children:r("readHome.hoverHint")})]})]})}function Ma({authors:t,links:n}){const{t:o,convert:r}=Y(),s=vt(n);return t.length?e.jsx("ul",{className:"bim-rh-authors",children:t.map(l=>e.jsxs("li",{className:"bim-rh-au",children:[e.jsxs("h3",{className:"bim-rh-au-h",children:[r(l.name),l.dynasty&&e.jsx("span",{children:r(l.dynasty)}),e.jsx("small",{className:"bim-rh-num",children:o("readHome.nPieces",{n:Ue(l.count)})})]}),e.jsx("ul",{children:l.items.map(a=>e.jsx("li",{children:e.jsx("a",{href:s.read(a.id),children:r(a.title)})},a.id))}),s.author&&e.jsx("a",{className:"bim-rh-more",href:s.author(l.name),children:o("readHome.authorAll",{name:r(l.name),n:l.count})})]},l.name))}):null}const Wa={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function ex({sections:t,links:n,head:o,piecesMoreHref:r,className:s}){const{t:l}=Y(),a=t,p=Wa,c=a.topics.filter(m=>!m.shelf),d={picks:a.picks.length>0,topics:c.some(m=>m.items.length>0),famous:a.famous.length>0,sibu:a.bu.length>0||a.unclassified>0,period:a.periods.some(m=>m.count>0),pieces:a.pieces.authors.length>0},u=Object.keys(p).filter(m=>d[m]),g=m=>l(`readHome.nav.${m}`);return e.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[e.jsx("style",{children:No}),e.jsxs("div",{className:"bim-rh-head",children:[o,e.jsx(Ia,{counts:a.counts})]}),u.length>1&&e.jsx("nav",{className:"bim-rh-secnav","aria-label":l("readHome.navLabel"),children:e.jsx("ul",{children:u.map(m=>e.jsx("li",{children:e.jsx("a",{href:`#${p[m]}`,children:g(m)})},m))})}),e.jsxs("div",{className:"bim-rh-main",children:[d.picks&&e.jsx(et,{id:p.picks,title:g("picks"),sub:l("readHome.picksSub"),children:e.jsx(Ra,{picks:a.picks,links:n})}),d.topics&&e.jsx(et,{id:p.topics,title:g("topics"),sub:l("readHome.topicsSub"),children:e.jsx(Pa,{topics:c,links:n})}),d.famous&&e.jsx(et,{id:p.famous,title:g("famous"),sub:l("readHome.famousSub"),children:e.jsx(Aa,{famous:a.famous,links:n})}),d.sibu&&e.jsx(et,{id:p.sibu,title:g("sibu"),sub:l("readHome.sibuSub"),children:e.jsx(Eo,{bu:a.bu,unclassified:a.unclassified,links:n})}),d.period&&e.jsx(et,{id:p.period,title:g("period"),sub:l("readHome.periodSub"),children:e.jsx(Ba,{periods:a.periods,unknown:a.period_unknown,links:n})}),d.pieces&&e.jsx(et,{id:p.pieces,title:g("pieces"),sub:l("readHome.piecesSub"),more:r?e.jsx("a",{className:"bim-rh-more",href:r,children:l("readHome.piecesMore")}):void 0,children:e.jsx(Ma,{authors:a.pieces.authors,links:n})})]})]})}const tx="(max-width: 1079px)",nx=`${xn}, (pointer: coarse)`,Ha=`
1499
1499
  /* ── 页首:检索(宿主插槽)+类型签|最近浏览 ── */
1500
1500
  .bim-mh-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 16px 48px; align-items: start; padding-top: 8px; }
1501
1501
  .bim-mh-q { min-width: 0; }
@@ -1666,4 +1666,4 @@ ${Jh.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1666
1666
  .bim-mh-recent li a, .bim-mh-types a, .bim-mh-tl-list a { min-height: 44px; align-items: center; }
1667
1667
  .bim-mh-recent-h button { min-height: 44px; }
1668
1668
  }
1669
- `,Oa={item:t=>`/item/${encodeURIComponent(t)}`,node:t=>`/catalog?node=${encodeURIComponent(t)}`};function kt(t){return{...Oa,...t??{}}}function Fa(t,n){if(t.lineage)return t.lineage(n);const o=t.item(n),r=o.indexOf("#"),[s,l]=r<0?[o,""]:[o.slice(0,r),o.slice(r)];return`${s}${s.includes("?")?"&":"?"}tab=lineage${l}`}function Lo(t,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(t/n*100)))}function Da(t){const n=t.filter(d=>Number.isFinite(d.birth_year)||Number.isFinite(d.death_year)),o=t.filter(d=>!n.includes(d));if(!n.length)return{min:0,max:0,placed:[],missing:o};const r=d=>{const u=Number.isFinite(d.birth_year)?d.birth_year:d.death_year-50,g=Number.isFinite(d.death_year)?d.death_year:d.birth_year+50;return[Math.min(u,g),Math.max(u,g)]},s=n.map(r),l=Math.min(...s.map(d=>d[0])),a=Math.max(...s.map(d=>d[1])),p=Math.max(1,a-l),c=n.map((d,u)=>({p:d,from:s[u][0],to:s[u][1]})).sort((d,u)=>d.from-u.from).map(d=>({...d,left:(d.from-l)/p*100,width:Math.max(.8,(d.to-d.from)/p*100)}));return{min:l,max:a,placed:c,missing:o}}function Rn(t,n=Dt("zh-Hant")){return t<0?n("metaHome.yearBC",{n:-t}):String(t)}function ix(t){return{read:t.item,work:t.item,node:t.node}}function Ua({counts:t,links:n}){const{t:o}=G(),r=n==null?void 0:n.type;if(!r)return null;const s=[["all",o("metaHome.typeAll"),null],["work",o("metaHome.typeLabel.work"),t.works],["book",o("metaHome.typeLabel.book"),t.books],["collection",o("metaHome.typeLabel.collection"),t.collections],["entity",o("metaHome.typeLabel.entity"),t.entities]];return e.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":o("metaHome.typeChipsLabel"),children:s.map(([l,a,p])=>e.jsx("li",{children:e.jsxs("a",{href:r(l),children:[e.jsx("b",{children:a}),p!=null&&p>0&&e.jsx("small",{children:Ue(p)})]})},l))})}function Va(t,n=5){const[o,r]=x.useState(null);x.useEffect(()=>{let l=!1;const a=jt().slice(0,n);if(!a.length||!t){r([]);return}return Promise.all(a.map(p=>Yi(t,p))).then(p=>{l||r(p.filter(c=>!c.notFound))}),()=>{l=!0}},[t,n]);const s=x.useCallback(()=>{Gi(),r([])},[]);return{entries:o,clear:s}}function ox(t,n,o){const r=t.type==="book"?t.edition||t.era:t.type==="collection"?"":t.dynasty;return r?o(r):Ga(t.type,n)}function Ga(t,n){return n(`metaHome.typeLabel.${t}`)}function Ya({entries:t,onClear:n,links:o}){const{t:r,convert:s}=G(),l=kt(o);return e.jsxs("aside",{className:"bim-mh-recent","aria-labelledby":"bim-mh-recent-h",children:[e.jsxs("div",{className:"bim-mh-recent-h",children:[e.jsx("h2",{id:"bim-mh-recent-h",children:r("metaHome.recentTitle")}),t&&t.length>0&&n&&e.jsx("button",{type:"button",onClick:n,children:r("metaHome.recentClear")})]}),t&&t.length>0&&e.jsx("ol",{children:t.map(a=>e.jsx("li",{children:e.jsxs("a",{href:l.item(a.id),"aria-label":r("metaHome.recentItemLabel",{type:a.type?Ga(a.type,r):"",title:s(a.title)}),children:[e.jsx("i",{className:"bim-mh-ty","aria-hidden":"true",children:a.type?r(`metaHome.typeShort.${a.type}`):""}),e.jsx("span",{children:s(a.title)}),e.jsx("small",{"aria-hidden":"true",children:ox(a,r,s)})]})},a.id))}),t&&t.length===0&&e.jsx("p",{className:"bim-mh-recent-empty",children:r("metaHome.recentEmpty")})]})}function Ka(t,n,o,r=!1){return r&&(t==="done"||t==="in_progress")?n(`metaHome.siteStatus.${t}`):t==="done"||t==="in_progress"||t==="todo"?n(`metaHome.status.${t}`):o(t)}function qa({rows:t,links:n}){const{t:o,convert:r}=G(),s=kt(n);return t.length?e.jsx("div",{className:"bim-mh-tbl-wrap",tabIndex:0,role:"region","aria-label":o("metaHome.catalogTitle"),children:e.jsxs("table",{className:"bim-mh-tbl",children:[e.jsxs("caption",{children:[o("metaHome.catalogTitle"),e.jsx("small",{children:o("metaHome.catalogNote")})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:o("metaHome.colCatalog")}),e.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colRecords")}),e.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colMatched")}),e.jsx("th",{scope:"col",children:o("metaHome.colProgress")}),e.jsx("th",{scope:"col",children:o("metaHome.colStatus")})]})}),e.jsx("tbody",{children:t.map(l=>{const a=Lo(l.imported,l.total),p=l.work_id??l.collection_id,c=r(l.edition?`${l.name}·${l.edition}`:l.name);return e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:p?e.jsx("a",{href:s.item(p),children:c}):c}),e.jsx("td",{className:"bim-mh-r",children:Ue(l.total)}),e.jsx("td",{className:"bim-mh-r",children:Ue(l.imported)}),e.jsx("td",{children:e.jsxs("span",{className:"bim-mh-meter",children:[e.jsx("i",{"aria-hidden":"true",style:{"--bimmh-w":`${a}%`}}),e.jsxs("small",{children:[a,"%"]})]})}),e.jsx("td",{children:l.status&&e.jsx("span",{className:"bim-mh-st","data-st":l.status,children:Ka(l.status,o,r)})})]},l.id||l.name)})})]})}):null}function Za({items:t,links:n,label:o}){const{convert:r}=G();return e.jsx("ul",{className:"bim-rh-rows","aria-label":o?r(o):void 0,children:t.map(s=>e.jsx("li",{children:e.jsxs("a",{href:n.item(s.id),children:[e.jsx("span",{className:"bim-rh-t",children:r(s.title)}),s.sub&&e.jsx("small",{children:r(s.sub)})]})},s.id))})}function Ja({works:t,links:n}){const{t:o}=G(),[r,s]=x.useState(!1);if(!t.length)return null;const l=cn(t.length);return e.jsxs("div",{className:"bim-rh-grp","data-cap":l?"":void 0,"data-open":r?"":void 0,children:[e.jsxs("h3",{className:"bim-rh-gt",children:[o("metaHome.relatedTitle"),e.jsx("small",{children:o("metaHome.relatedNote")})]}),e.jsx(Za,{items:t.map(a=>({id:a.id,title:a.title,sub:Kn(a)||void 0})),links:kt(n)}),l&&e.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":r,onClick:()=>s(a=>!a),children:r?o("action.collapse"):o("metaHome.allNWorks",{n:t.length})})]})}const Xa="siku_qige";function rx({group:t,links:n}){const{t:o,convert:r}=G(),[s,l]=x.useState(!1);return e.jsxs("div",{className:"bim-rh-grp","data-cap":cn(t.items.length)?"":void 0,"data-open":s?"":void 0,children:[e.jsxs("h3",{className:"bim-rh-gt",children:[r(t.label),e.jsx("small",{className:"bim-rh-num",children:o("metaHome.nKinds",{n:t.items.length})})]}),e.jsx(Za,{items:t.items,links:n,label:t.label}),cn(t.items.length)&&e.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":s,onClick:()=>l(a=>!a),children:s?o("action.collapse"):o("metaHome.allNKinds",{n:t.items.length})})]})}function Qa({groups:t,links:n}){const{t:o,convert:r}=G(),s=kt(n);if(!t.length)return null;const l=t.find(c=>c.key===Xa),a=t.filter(c=>c!==l),p=c=>{var d;return((d=c.match(/(文[^\s·・閣阁]+)[閣阁]/))==null?void 0:d[1])??c};return e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"bim-rh-gt",children:[r(l.label),e.jsx("small",{children:r(l.items.map(c=>p(c.title)).join("、"))})]}),e.jsx("ul",{className:"bim-mh-ge","aria-label":r(l.label),children:l.items.map(c=>e.jsx("li",{children:e.jsxs("a",{href:s.item(c.id),"aria-label":r(c.title),title:r(c.title),children:[e.jsx("span",{"aria-hidden":"true",children:r(p(c.title))}),p(c.title)!==c.title&&e.jsx("small",{"aria-hidden":"true",children:o("metaHome.pavilion")})]})},c.id))})]}),a.length>0&&e.jsx("div",{className:"bim-mh-cg",style:l?void 0:{marginTop:0},children:a.map(c=>e.jsx(rx,{group:c,links:s},c.key))})]})}const is=34,os=13;function rs(t,n){return t.birth_year==null&&t.death_year==null?"":`${t.birth_year!=null?Rn(t.birth_year,n):"?"}–${t.death_year!=null?Rn(t.death_year,n):"?"}`}function sx(t,n){const o=n-t,r=o>1200?300:o>400?100:50,s=[];for(let l=Math.ceil(t/r)*r;l<=n;l+=r)s.push(l);return s}function ec({people:t,links:n}){const{t:o,convert:r}=G(),s=kt(n);if(!t.length)return null;const{min:l,max:a,placed:p,missing:c}=Da(t),d=[],u=p.map(m=>{const h=m.left>70,f=h?Math.min(m.left,m.left+m.width-os):m.left;let v=0;for(;d[v]!=null&&d[v]>f;)v++;return d[v]=h?m.left+m.width:m.left+Math.max(m.width,os),{...m,lane:v,end:h}}),g=Math.max(1,a-l);return e.jsxs(e.Fragment,{children:[u.length>0&&e.jsxs("div",{className:"bim-mh-tl",children:[e.jsx("ul",{className:"bim-mh-tl-rows",style:{height:d.length*is+10},children:u.map(m=>e.jsxs("li",{className:"bim-mh-tl-bar","data-end":m.end?"":void 0,style:{left:`${m.left}%`,top:m.lane*is+4,width:`${Math.max(m.width,.5)}%`},children:[e.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),e.jsxs("a",{href:s.item(m.p.id),children:[r(m.p.name),e.jsx("small",{className:"bim-rh-num",children:rs(m.p,o)})]})]},m.p.id))}),e.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:sx(l,a).map(m=>e.jsx("span",{style:{left:`${(m-l)/g*100}%`},children:Rn(m,o)},m))})]}),e.jsx("ul",{className:"bim-mh-tl-list","data-only":u.length?void 0:"",children:(u.length?t:c).map(m=>e.jsx("li",{children:e.jsxs("a",{href:s.item(m.id),children:[e.jsx("span",{children:r(m.name)}),e.jsx("small",{className:"bim-rh-num",children:[m.dynasty?r(m.dynasty):"",rs(m,o)].filter(Boolean).join(" ")})]})},m.id))}),c.length>0&&u.length>0&&e.jsx("p",{className:"bim-mh-tl-foot",children:o("metaHome.missingLife",{names:r(c.map(m=>m.name).join("、"))})})]})}const lx=e.jsxs("svg",{width:"54",height:"34",viewBox:"0 0 54 34",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:[e.jsx("circle",{cx:"27",cy:"5",r:"3.5"}),e.jsx("circle",{cx:"10",cy:"29",r:"3.5"}),e.jsx("circle",{cx:"27",cy:"29",r:"3.5"}),e.jsx("circle",{cx:"44",cy:"29",r:"3.5"}),e.jsx("path",{d:"M27 8.5v17M27 15H10v10.5M27 15h17v10.5"})]});function tc({works:t,links:n}){const{t:o,convert:r}=G(),s=kt(n);return t.length?e.jsx("ul",{className:"bim-mh-lin",children:t.map(l=>{const a=Kn(l);return e.jsx("li",{children:e.jsxs("a",{href:Fa(s,l.id),children:[lx,e.jsx("b",{children:r(l.title)}),a&&e.jsx("small",{children:r(a)}),e.jsx("span",{children:o("metaHome.viewLineage")})]})},l.id)})}):null}function nc({sites:t}){const{t:n,convert:o}=G(),r=t.filter(l=>l.status!=="todo"&&l.total>0),s=t.filter(l=>!r.includes(l));return t.length?e.jsxs(e.Fragment,{children:[r.length>0&&e.jsx("ul",{className:"bim-mh-cov",children:r.map(l=>{const a=Lo(l.imported,l.total);return e.jsxs("li",{children:[l.url?e.jsx("a",{href:l.url,rel:"noopener noreferrer",target:"_blank",children:o(l.name)}):e.jsx("span",{children:o(l.name)}),e.jsx("span",{className:"bim-mh-bar","aria-hidden":"true",style:{"--bimmh-w":`${a}%`}}),e.jsxs("small",{children:[`${Ue(l.imported)} / ${Ue(l.total)} ${a}% `,l.status&&e.jsx("span",{className:"bim-mh-st","data-st":l.status,children:Ka(l.status,n,o,!0)})]})]},l.id||l.name)})}),s.length>0&&e.jsx("p",{className:"bim-mh-todo",children:n("metaHome.plannedSites",{names:o(s.map(l=>l.name).join("、"))})})]}):null}const ss=["extant","partially_extant","lost","unknown"];function ic({stats:t,links:n,version:o,repoUrl:r,downloadHref:s}){const{t:l}=G(),a=["works","books","collections","entities","has_image","has_text","article","poem"].map(d=>[t[d],l(`metaHome.stat.${d}`)]).filter(([d])=>d>0),p=n==null?void 0:n.loss,c=ss.some(d=>{var u;return(((u=t.loss)==null?void 0:u[d])??0)>0});return e.jsxs("div",{className:"bim-mh-data",children:[a.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"bim-rh-gt",children:l("metaHome.dataScale")}),e.jsx("ul",{className:"bim-mh-nums",children:a.map(([d,u])=>e.jsxs("li",{children:[e.jsx("b",{className:"bim-rh-num",children:Ue(d)}),e.jsx("span",{children:u})]},u))})]}),p&&e.jsxs("div",{children:[e.jsx("h3",{className:"bim-rh-gt",children:l("metaHome.byLoss")}),e.jsx("ul",{className:"bim-mh-loss",children:ss.map(d=>{var m;const u=((m=t.loss)==null?void 0:m[d])??0,g=l(`metaHome.lossNote.${d}`);return e.jsx("li",{children:e.jsxs("a",{href:p(d),children:[l(`metaHome.loss.${d}`),e.jsx("small",{className:"bim-rh-num",children:c&&u>0?l("metaHome.lossCount",{n:Ue(u),note:g}):g})]})},d)})})]}),e.jsxs("div",{className:"bim-mh-lic",children:[e.jsxs("p",{children:[e.jsx("span",{className:"bim-mh-cc0",children:"CC0"}),l("metaHome.license")]}),e.jsxs("p",{children:[l("metaHome.repo"),r?e.jsx("a",{href:r,children:e.jsx("code",{children:"book-index"})}):e.jsx("code",{children:"book-index"}),l("metaHome.repoNote")]}),o&&e.jsxs("p",{children:[l("metaHome.version"),e.jsx("code",{children:o})]}),s&&e.jsx("p",{children:e.jsx("a",{href:s,children:l("metaHome.download")})})]})]})}const oc={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function ax({sections:t,links:n,head:o,transport:r,catalogHref:s,collectionsHref:l,entitiesHref:a,version:p,repoUrl:c,downloadHref:d,className:u}){var k,$;const{t:g}=G(),m=t,h=kt(n),f=ix(h),v=oc,y=Va(r),w={zhi:!!((k=m.shelf)!=null&&k.items.length)||m.catalog_progress.length>0||m.related_catalogs.length>0,sibu:m.bu.length>0||m.unclassified>0,cong:m.collection_groups.length>0,people:m.bibliographers.length>0,lineage:m.lineage.length>0,sites:m.sites.length>0,data:!0},b=Object.keys(v).filter(_=>w[_]),j=_=>g(`metaHome.nav.${_}`),S=(_,z)=>_?e.jsx("a",{className:"bim-rh-more",href:_,children:z}):void 0;return e.jsxs("div",{className:u?`bim-rh bim-mh ${u}`:"bim-rh bim-mh",children:[e.jsx("style",{children:No+Ha}),e.jsxs("div",{className:"bim-mh-head",children:[e.jsxs("div",{className:"bim-mh-q",children:[o,e.jsx(Ua,{counts:m.counts,links:n})]}),r&&e.jsx(Ya,{entries:y.entries,onClear:y.clear,links:n})]}),b.length>1&&e.jsx("nav",{className:"bim-rh-secnav","aria-label":g("metaHome.navLabel"),children:e.jsx("ul",{children:b.map(_=>e.jsx("li",{children:e.jsx("a",{href:`#${v[_]}`,children:j(_)})},_))})}),e.jsxs("div",{className:"bim-rh-main",children:[w.zhi&&e.jsxs(et,{id:v.zhi,title:j("zhi"),sub:g("metaHome.zhiSub"),children:[m.shelf&&m.shelf.items.length>0&&e.jsx(Ro,{topic:{key:"shelf",label:m.shelf.label,shelf:!0,items:m.shelf.items},links:f,showTitle:!1,legendCount:m.shelf.items.some(_=>_.records)?g("metaHome.shelfLegendCount"):null,legendExtra:[g("metaHome.shelfLegendClick")]}),(m.catalog_progress.length>0||m.related_catalogs.length>0)&&e.jsxs("div",{className:"bim-mh-zhi",style:($=m.shelf)!=null&&$.items.length?void 0:{marginTop:0},children:[e.jsx(qa,{rows:m.catalog_progress,links:n}),e.jsx(Ja,{works:m.related_catalogs,links:n})]})]}),w.sibu&&e.jsx(et,{id:v.sibu,title:j("sibu"),sub:g("metaHome.sibuSub"),more:S(s,g("metaHome.toCatalog")),children:e.jsx(Eo,{bu:m.bu,unclassified:m.unclassified,links:f,unclassifiedNote:g("metaHome.unclassifiedNote")})}),w.cong&&e.jsx(et,{id:v.cong,title:j("cong"),sub:g("metaHome.congSub"),more:S(l,g("metaHome.allNKindsMore",{n:Ue(m.counts.collections)})),children:e.jsx(Qa,{groups:m.collection_groups,links:n})}),w.people&&e.jsx(et,{id:v.people,title:j("people"),sub:g("metaHome.peopleSub"),more:S(a,g("metaHome.allNPeopleMore",{n:Ue(m.counts.entities)})),children:e.jsx(ec,{people:m.bibliographers,links:n})}),w.lineage&&e.jsx(et,{id:v.lineage,title:j("lineage"),sub:g("metaHome.lineageSub"),children:e.jsx(tc,{works:m.lineage,links:n})}),w.sites&&e.jsx(et,{id:v.sites,title:j("sites"),sub:g("metaHome.sitesSub"),children:e.jsx(nc,{sites:m.sites})}),e.jsx(et,{id:v.data,title:j("data"),sub:g("metaHome.dataSub"),children:e.jsx(ic,{stats:m.stats,links:n,version:p,repoUrl:c,downloadHref:d})})]})]})}const Ai=({style:t})=>{const n=x.useContext(It),{t:o}=G();if(!n)return null;const{locale:r,setLocale:s}=n,l=r==="zh-Hant",a=()=>s(l?"zh-Hans":"zh-Hant");return e.jsxs("button",{type:"button",onClick:a,title:o(l?"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",...t},children:[e.jsx("span",{style:{color:l?i("primary"):void 0,fontWeight:l?700:400},children:o("common.localeShortHant")}),e.jsx("span",{style:{opacity:.3},children:"/"}),e.jsx("span",{style:{color:l?void 0:i("primary"),fontWeight:l?400:700},children:o("common.localeShortHans")})]})},Bi=({href:t,label:n,size:o=16,className:r,style:s})=>{const{t:l}=G(),a=n??l("common.repoSourceLink");return e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",title:a,"aria-label":a,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:p=>{p.currentTarget.style.color=i("fg")},onMouseLeave:p=>{p.currentTarget.style.color=i("desc-fg")},children:e.jsx("svg",{width:o,height:o,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:e.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 hi(t){const n=t.text_count;return typeof n=="number"&&n>0}function xi(t,n){return{id:t,title:n.title??n.primary_name??t,type:n.type??"book"}}function cx(t,n){if(!n)return!1;const o=n.id;return o===void 0||o===t}const dx=({id:t,transport:n,initialDetail:o,initialEntry:r,activeTab:s,onTabChange:l,activeJuan:a,onJuanChange:p,lineageMode:c="list",onLineageModeChange:d,lineageCollection:u,onLineageCollectionChange:g,initialPage:m=1,selectedLineageNodeId:h,onNavigate:f,onBack:v,backLabel:y,renderLink:w,enrichDetail:b,getSourceLink:j,readLink:S,railTop:k,extraTabs:$=[],showFeedbackTab:_=!0,feedbackApiUrl:z,height:E,footerExtra:T,hideHeaderControls:C=!1,className:O,style:W})=>{const P=ve(),{t:Y,convert:V}=G(),[Q]=x.useState(()=>{if(!cx(t,o))return null;const H={...o},B=r??xi(t,H);return b&&b(B,H),{id:t,entry:B,detail:H}}),[ge,A]=x.useState((Q==null?void 0:Q.entry)??null),[I,Z]=x.useState((Q==null?void 0:Q.detail)??null),[ee,ce]=x.useState(!Q),[fe,Ie]=x.useState(!1),[q,M]=x.useState([]),[K,Re]=x.useState(!1),[se,ye]=x.useState(null),[We,Be]=x.useState(null),[Ee,Ce]=x.useState(null),[He,D]=x.useState(!1),re=x.useRef(null),de=x.useRef(0),[ke,F]=x.useState(null),he=a!==void 0?a:ke,Ne=x.useCallback(H=>{p?p(H):F(H)},[p]),R=x.useCallback(async H=>{if(!n.getCollectionCatalogs&&!n.getCollectionCatalog){M([]);return}Re(!0);try{if(n.getCollectionCatalogs)M(await n.getCollectionCatalogs(H)||[]);else if(n.getCollectionCatalog){const B=await n.getCollectionCatalog(H);M(B?[{resource_id:"",data:B}]:[])}}catch{M([])}finally{Re(!1)}},[n]),ne=x.useCallback(async H=>{var B,be;if(!n.getTextManifest||!n.getTextIndex){ye(null),Be(H);return}try{const _e=xe.pickTextVersion(await n.getTextManifest(H)),je=_e?await n.getTextIndex(H,_e.key):null;ye(je&&je.chapters.length>0?{chapters:je.chapters.map(me=>({n:me.n,title:me.title,file:me.file})),source:{name:((B=je.source)==null?void 0:B.name)??(_e==null?void 0:_e.source_name),license:((be=je.source)==null?void 0:be.license)??(_e==null?void 0:_e.license)??void 0}}:null)}catch{ye(null)}finally{Be(H)}},[n]),ue=x.useCallback(async(H,B)=>{const be=++de.current,_e=()=>be!==de.current;D(!0);try{if(n.getLineageGraph){const Ae=await n.getLineageGraph(H);if(_e())return;Ae&&Ce(Ae)}const je=B.version_graph;if(!je||!je.enabled){Ee||Ce(null),re.current=null;return}const me=B.books??[],Oe=[];for(const Ae of me)try{const lt=await n.getItem(Ae);lt&&Oe.push(lt)}catch{}if(_e())return;re.current={work:B,books:Oe};const ze=u??je.default_collection??(je.core_books&&je.core_books.length>0?"core":"all"),Ve=ze==="core"&&Array.isArray(je.core_books)&&je.core_books.length>0?"core":ze??"all";Ce($n(B,Oe,Ve))}catch{if(_e())return;Ce(null),re.current=null}finally{_e()||D(!1)}},[n]),L=x.useRef({initialDetail:o,initialEntry:r});L.current={initialDetail:o,initialEntry:r},x.useEffect(()=>{let H=!1;de.current++,D(!1);const B=me=>{me.type==="collection"?R(t):me.type==="work"?(me.version_graph||n.getLineageGraph)&&ue(t,me):me.type==="book"&&hi(me)&&ne(t)},be=L.current;let _e=null;if(Q&&Q.id===t)_e=Q;else if(be.initialDetail&&be.initialDetail.id===t){const me={...be.initialDetail},Oe=be.initialEntry??xi(t,me);b&&b(Oe,me),_e={entry:Oe,detail:me}}return _e?(Ie(!1),M(me=>me.length?[]:me),ye(null),Ce(null),re.current=null,A(_e.entry),Z(_e.detail),ce(!1),B(_e.detail),()=>{H=!0}):((async()=>{ce(!0),Ie(!1),A(null),Z(null),M([]),ye(null),Ce(null),re.current=null;try{const me=await n.getItem(t);if(H)return;if(!me){Ie(!0);return}const Oe=me;let ze=null;if(n.getEntry&&(ze=await n.getEntry(t),H))return;ze||(ze=xi(t,Oe)),b&&b(ze,Oe),A(ze),Z(Oe),B(Oe)}catch{H||Ie(!0)}finally{H||ce(!1)}})(),()=>{H=!0})},[t,n,Q,b,R,ue,ne]),x.useEffect(()=>{const H=re.current;!H||!u||Ce($n(H.work,H.books,u))},[u]);const te=[];if(I){if(te.push({key:"basic",label:P.detailTab.basicInfo}),I.type==="collection"){K&&q.length===0&&te.push({key:"catalog:loading",label:`${P.detailTab.catalog}…`});for(const H of q)te.push({key:`catalog:${H.resource_id}`,label:H.short_name?`${V(H.short_name)}${P.detailTab.catalogSuffix}`:P.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&te.push({key:s,label:P.detailTab.fullText}),I.type==="work"&&(Ee||He)&&te.push({key:"lineage",label:He?`${P.detailTab.lineage}…`:P.detailTab.lineage});for(const H of $)(H.position??"before-feedback")==="before-feedback"&&H.shouldShow(I)&&te.push({key:H.key,label:H.label});_&&s==="feedback"&&te.push({key:"feedback",label:P.detailTab.feedback});for(const H of $)H.position==="after-feedback"&&H.shouldShow(I)&&te.push({key:H.key,label:H.label})}x.useEffect(()=>{if(s!=="emendated"||!I)return;l("basic");const H=setTimeout(()=>{var B;(B=document.getElementById("studies"))==null||B.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(H)},[s,I,l]);const U=ge&&I&&j?j({activeTab:s,activeJuan:he,entry:ge,detail:I}):null,le=x.useMemo(()=>{var je;if(!I)return null;const B=(I.authors??[]).map(me=>{const Oe=io(me.role);return`${me.dynasty?`〔${V(me.dynasty)}〕`:""}${V(me.name)}${Oe?` ${V(Oe)}`:""}`}).join(" · ");let be=!1;try{be=xe.extractStatus(I.id)==="draft"}catch{}if(I.type==="book"){const me=I;return{title:V(me.title),subtitle:me.edition?V(me.edition):B||void 0,aside:[be?P.status.draft:"",B&&me.edition?B:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(I.type==="collection"){const me=I;return{title:V(me.title),subtitle:V(bt(me,P.unit.juan))||void 0,aside:[(je=me.publication_info)==null?void 0:je.year,be?P.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:B||void 0}}if(I.type==="entity"){const me=I,Oe=Ve=>Ve==null?"":Ve<0?Y("detail.bce",{n:-Ve}):String(Ve),ze=me.birth_year!=null||me.death_year!=null?`${Oe(me.birth_year)||"?"}—${Oe(me.death_year)||"?"}`:"";return{title:V(me.primary_name||me.title),subtitle:[me.dynasty?`〔${V(me.dynasty)}〕`:"",ze].filter(Boolean).join(" ")||void 0,aside:be?P.status.draft:void 0,secondLine:void 0}}const _e=V(bt(I,P.unit.juan));return{title:V(I.title),subtitle:[_e,B].filter(Boolean).join(" · ")||void 0,aside:[ux(P,I.subtype),be?P.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[I,V,P,Y]),we=I&&hi(I)?"text":null,Le=()=>{Ne(null),l("fulltext")};let Se=null;if(I&&S){const H=S({detail:I,kind:we});H&&(Se=e.jsx(Ci,{href:H}))}else we&&(Se=e.jsx(Ci,{onClick:Le}));const Fe=H=>{if(!I)return null;const B=H.replace(/\.[^.]+$/,"");if(S){const be=S({detail:I,kind:we,juan:B});return be?{href:be}:null}return{onClick:()=>{Ne(B),l("fulltext")}}},De=new Set($.map(H=>H.key)),J=te.filter(H=>H.key.startsWith("catalog:")&&H.key!=="catalog:loading"||H.key==="lineage"&&!!Ee&&!He||De.has(H.key)).map(H=>({key:H.key,label:H.label,onClick:()=>l(H.key)})),Pe=()=>{var H;return I?I.type==="work"?e.jsx(ca,{data:I,transport:n,onNavigate:f,renderLink:w,readAction:Se,railTop:k,railLinks:J}):I.type==="book"?e.jsx(ma,{data:I,transport:n,onNavigate:f,renderLink:w,readAction:Se,fullText:se,fullTextPending:hi(I)&&!!n.getTextManifest&&We!==I.id,chapterLink:Fe,railTop:k,railLinks:J}):I.type==="collection"?e.jsx(ga,{data:I,catalog:(H=q[0])==null?void 0:H.data,transport:n,onNavigate:f,renderLink:w,readAction:Se,railTop:k,railLinks:J,catalogAction:q.length>0?e.jsxs("a",{href:"#catalog",onClick:B=>{B.preventDefault(),l(`catalog:${q[0].resource_id}`)},children:[V(P.detailTab.collectionCatalog)," →"]}):null}):e.jsx(ha,{data:I,transport:n,onNavigate:f,renderLink:w,railTop:k,railLinks:J}):null},N=()=>{var B,be,_e;if(!ge||!I)return null;if(s==="basic"||s==="emendated")return Pe();if(typeof s=="string"&&s.startsWith("catalog:")){const je=(B=q.find(me=>`catalog:${me.resource_id}`===s))==null?void 0:B.data;return e.jsx(qi,{data:je,onNavigate:f,renderLink:w})}if(s==="collated"||s==="fulltext")return e.jsx(vo,{id:t,transport:n,chapter:he,onLocationChange:je=>Ne(je.chapter),onNavigate:f});if(s==="lineage"){if(!Ee)return e.jsx("div",{style:{color:i("label-fg"),padding:"24px 0"},children:Y(He?"detail.loading":"detail.noLineageGraph")});const je=I.type==="work"?I:null;return e.jsx(_o,{graph:Ee,renderLink:w,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:d,selectedNodeId:h,collection:u??((be=je==null?void 0:je.version_graph)==null?void 0:be.default_collection),onCollectionChange:g,collectionsAvailable:(_e=je==null?void 0:je.version_graph)==null?void 0:_e.collections,collectionCounts:(()=>{var Ve,Ae,lt,oe,Me,Xe,wt;if(!je)return;const me={},Oe=((Ve=re.current)==null?void 0:Ve.books)??[];me.all=(((Ae=je.books)==null?void 0:Ae.length)??0)-(((oe=(lt=je.version_graph)==null?void 0:lt.excluded_books)==null?void 0:oe.length)??0);const ze=(Me=je.version_graph)==null?void 0:Me.collections;if(ze)for(const Yt of Object.keys(ze))me[Yt]=$n(je,Oe,Yt).nodes.filter(fn=>fn.kind==="book"&&!fn.bridge).length;return me.core==null&&((wt=(Xe=je.version_graph)==null?void 0:Xe.core_books)!=null&&wt.length)&&(me.core=je.version_graph.core_books.length),me})()})}if(s==="feedback"&&_)return e.jsx(ra,{resourceId:t,apiUrl:z});const H=$.find(je=>je.key===s);return H?H.render({detail:I,entry:ge,transport:n,onNavigate:f}):null};if(ee)return e.jsx(nn,{style:{minHeight:E,...W},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((H,B)=>e.jsx("div",{style:{height:B===1?40:16,width:H,opacity:.35,background:i("rule")}},B))})});if(fe||!I||!ge||!le)return e.jsx(nn,{style:{minHeight:E,...W},children:e.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:i("label-fg"),fontSize:14},children:Y("detail.notFound")})});const X=s==="basic"||s==="emendated",ae=[{label:y??P.detailTab.backToIndex,onClick:v}];if(I.type==="book"&&I.work_id){const H=I.work_id;ae.push({label:P.indexType.work,id:H,onClick:()=>f==null?void 0:f(H)})}ae.push({label:P.indexType[I.type]});const ie=s==="collated"||s==="fulltext",pe=typeof T=="string"?P.status[T.trim()]??T:T,$e=e.jsx(Nl,{left:e.jsxs(e.Fragment,{children:[pe,pe?" · ":"",e.jsx(px,{id:I.id,label:P.label.id,copied:P.action.copied,copyLabel:P.action.copy})]}),right:e.jsxs(e.Fragment,{children:[_&&!X&&e.jsx("button",{type:"button",onClick:()=>l("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:P.detailTab.submitVersion}),U&&e.jsx("a",{href:U.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:i("meta-fg")},children:P.detailTab.dataLicense})]})});return X?e.jsx("div",{className:O,children:e.jsxs(nn,{grid:!0,style:{minHeight:E,...W},children:[e.jsx(zi,{breadcrumb:e.jsx(Ti,{items:ae}),actions:e.jsxs(e.Fragment,{children:[!C&&e.jsx(Ai,{style:{border:"none",background:"transparent"}}),!C&&U&&e.jsx(Bi,{...U})]})}),Pe(),$e]})}):e.jsx("div",{className:O,children:e.jsxs(nn,{wide:ie,style:{minHeight:E,...W},children:[e.jsx(zi,{breadcrumb:e.jsxs(e.Fragment,{children:[e.jsx(lo,{char:"籍"}),e.jsx(Ti,{items:ae})]}),actions:e.jsxs(e.Fragment,{children:[!C&&e.jsx(Ai,{}),_&&e.jsx("button",{type:"button",onClick:()=>l("feedback"),className:"bim-d-ui",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:P.detailTab.feedback}),!C&&U&&e.jsx(Bi,{...U})]})}),e.jsx(vl,{...le,aside:ie?e.jsxs("button",{type:"button",onClick:()=>l("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:[Y("detail.workInfo")," →"]}):le.aside}),!ie&&te.length>1&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:te.map(H=>e.jsx(kl,{label:H.label,active:H.key===s||X&&H.key==="basic",onClick:()=>l(H.key)},H.key))}),e.jsx("div",{style:{marginTop:!ie&&te.length>1?8:0},children:N()}),$e]})})};function px({id:t,label:n,copied:o,copyLabel:r}){const[s,l]=x.useState(!1);return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[e.jsxs("span",{children:[n," ",t]}),e.jsx("button",{type:"button",onClick:()=>{var a;(a=navigator.clipboard)==null||a.writeText(t).then(()=>{l(!0),setTimeout(()=>l(!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 ux(t,n){return n?t.workSubtype[n]??n:""}const rc=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],qn="zhusha",Zn="bim-theme";function sc(t){return t==="zhusha"||t==="indigo"||t==="ink"}function Jn(t){return sc(t)?t:qn}function mx(){try{return Jn(window.localStorage.getItem(Zn))}catch{return qn}}function lc(t){try{window.localStorage.setItem(Zn,t)}catch{}}function ac(t){const n=Jn(t);return document.documentElement.setAttribute("data-theme",n),n}function cc(){return Jn(document.documentElement.getAttribute("data-theme"))}const gx=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Po="airy",Xn="bim-layout";function dc(t){return t==="airy"||t==="boxed"}function Qn(t){return dc(t)?t:Po}function hx(){try{return Qn(window.localStorage.getItem(Xn))}catch{return Po}}function xx(t){try{window.localStorage.setItem(Xn,t)}catch{}}function fx(t){const n=Qn(t);return document.documentElement.setAttribute("data-layout",n),n}function bx(){return Qn(document.documentElement.getAttribute("data-layout"))}const yx=`try{var t=localStorage.getItem(${JSON.stringify(Zn)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Xn)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,jx={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},vx=({onChange:t,style:n})=>{const{t:o}=G(),[r,s]=x.useState(qn);x.useEffect(()=>{s(cc())},[]);const l=a=>{s(ac(a)),lc(a),t==null||t(a)};return e.jsx("div",{role:"radiogroup","aria-label":o("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:rc.map(a=>{const p=r===a.name;return e.jsx("button",{type:"button",role:"radio","aria-checked":p,"aria-label":o(`common.theme.${a.name}`),title:o(`common.theme.${a.name}`),onClick:()=>l(a.name),style:{width:28,height:44,padding:0,border:0,background:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:e.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:"50%",boxSizing:"border-box",background:i(jx[a.name]),boxShadow:p?`0 0 0 2px ${i("page-bg")}, 0 0 0 3.5px ${i("aux-fg")}`:"none"}})},a.name)})})};exports.BidLink=xe.BidLink;exports.BookIndexError=xe.BookIndexError;exports.BookIndexManager=xe.BookIndexManager;exports.BookIndexStorage=xe.BookIndexStorage;exports.BundleStorage=xe.BundleStorage;exports.ConfigError=xe.ConfigError;exports.GithubStorage=xe.GithubStorage;exports.IdGenerationError=xe.IdGenerationError;exports.IdGenerator=xe.IdGenerator;exports.LocalStorage=xe.LocalStorage;exports.MigrationError=xe.MigrationError;exports.StorageError=xe.StorageError;exports.VARIANT_CHARS=xe.VARIANT_CHARS;exports.base36Decode=xe.base36Decode;exports.base36Encode=xe.base36Encode;exports.base58Decode=xe.base58Decode;exports.buildId=xe.buildId;exports.buildPromotionMap=xe.buildPromotionMap;exports.cleanName=xe.cleanName;exports.decodeId=xe.decodeId;exports.decodeIdString=xe.decodeIdString;exports.encodeId=xe.encodeId;exports.extractIdFromUrl=xe.extractIdFromUrl;exports.extractStatus=xe.extractStatus;exports.extractType=xe.extractType;exports.isChapterSegment=xe.isChapterSegment;exports.isTextKey=xe.isTextKey;exports.matchChapterAcrossVersions=xe.matchChapterAcrossVersions;exports.normalizeCatalog=xe.normalizeCatalog;exports.normalizeVariants=xe.normalizeVariants;exports.parseId=xe.parseId;exports.pickTextVersion=xe.pickTextVersion;exports.shardOf=xe.shardOf;exports.smartDecode=xe.smartDecode;exports.textVersionLabel=xe.textVersionLabel;exports.validateResource=xe.validateResource;exports.Badge=In;exports.BidUrlProvider=vc;exports.BookDetailLayout=dx;exports.BookPage=ma;exports.Breadcrumb=Ti;exports.CATALOG_ALL_ID=ht;exports.CATALOG_CSS=xa;exports.CATALOG_NARROW_QUERY=Co;exports.CATALOG_PAGE_SIZE=zo;exports.CATALOG_UNCLASSIFIED_ID=Ct;exports.CLASSIFICATIONS=Mn;exports.COMMON_TRADITIONAL_CHARS=gs;exports.CardFoot=mn;exports.CatalogPage=Kh;exports.CatalogPager=wa;exports.CatalogTree=ba;exports.CheckFilter=bl;exports.Chip=wl;exports.ChipWall=uu;exports.CollectionCatalog=qi;exports.CollectionPage=ga;exports.CreateEntityDialog=Jl;exports.DEFAULT_LAYOUT=Po;exports.DEFAULT_META_HOME_LINKS=Oa;exports.DEFAULT_READER_PREFS=Xi;exports.DEFAULT_READ_HOME_LINKS=$a;exports.DEFAULT_THEME=qn;exports.DETAIL_CSS=jl;exports.DYNASTY_GROUPS=Bn;exports.Dash=bu;exports.DataTable=gu;exports.DetailFooter=Nl;exports.DetailGrid=pn;exports.DetailHeader=vl;exports.EMPTY_FILTERS=An;exports.EmendatedBySection=Ms;exports.EmptyNote=$u;exports.EntityDetail=Rs;exports.EntityPage=ha;exports.EntityPickerDialog=Ql;exports.EntitySelector=Zl;exports.ExpandRow=yu;exports.ExtLink=_u;exports.FEEDBACK_FAB_OFFSET_VAR=Ei;exports.FILTER_SUPPORT=ws;exports.FONT_SIZE_STEPS=gt;exports.FactList=au;exports.FeedbackButton=Ag;exports.FeedbackDialog=ia;exports.FeedbackForm=oa;exports.FeedbackList=ko;exports.FeedbackTab=ra;exports.FilterChip=kl;exports.FormInput=nt;exports.FormTextArea=Tt;exports.GUJI_MARKDOWN_FIELD=mp;exports.GUJI_TABLE_NOTATION=Us;exports.GlyphBadge=lo;exports.GujiTable=co;exports.HomePage=Ii;exports.ImagePanel=vi;exports.IndexApp=Hm;exports.IndexBrowser=yi;exports.IndexDetail=Ki;exports.IndexEditor=ea;exports.IndexView=kg;exports.IntroGrid=lu;exports.LAYOUTS=gx;exports.LAYOUT_STORAGE_KEY=Xn;exports.LOSS_OPTIONS=ks;exports.LocaleContext=It;exports.LocaleProvider=Kc;exports.LocaleToggle=Ai;exports.META_HOME_CSS=Ha;exports.META_HOME_SECTION_IDS=oc;exports.MetaCatalogTable=qa;exports.MetaCollectionGroups=Qa;exports.MetaDataLicense=ic;exports.MetaHomeView=ax;exports.MetaLine=qe;exports.MetaLineageCards=tc;exports.MetaOnlineSites=nc;exports.MetaPeopleTimeline=ec;exports.MetaRecentPanel=Ya;exports.MetaRelatedCatalogs=Ja;exports.MetaTypeChips=Ua;exports.ModeIndicator=bs;exports.MoreButton=pu;exports.MoreLink=ro;exports.PAGE_MAX_WIDTH=wn;exports.PERIOD_NARROW_SHARE=Ta;exports.PageFrame=nn;exports.Quote=vu;exports.READER_CSS=Qs;exports.READ_HOME_CSS=No;exports.READ_HOME_NARROW_QUERY=xn;exports.READ_HOME_SECTION_IDS=Wa;exports.READ_PERIOD_LABELS=Xh;exports.RECENT_IDS_STORAGE_KEY=Mt;exports.ROLE_CLASS_ORDER=ul;exports.ReadButton=Ci;exports.ReadFamousWorks=Aa;exports.ReadHomeView=ex;exports.ReadPeriodBand=Ba;exports.ReadPicks=Ra;exports.ReadPieces=Ma;exports.ReadSection=et;exports.ReadShelf=Ro;exports.ReadSibu=Eo;exports.ReadStats=Ia;exports.ReadTopicGroup=La;exports.ReadTopics=Pa;exports.ReaderMdText=go;exports.ReaderShell=sl;exports.ReaderToc=tl;exports.RelationPanel=Kl;exports.RepoSourceLink=Bi;exports.ResourceEditor=fi;exports.ResourceGroup=ku;exports.ResourceLine=wu;exports.ResourceList=Ui;exports.ResourceRow=zl;exports.SEARCH_VIEW_STORAGE_KEY=Vi;exports.SEVEN_PAVILIONS_KEY=Xa;exports.SNIPPET_MARK_END=cs;exports.SNIPPET_MARK_START=as;exports.SORTABLE_TYPES=vs;exports.SearchInput=js;exports.SearchResults=Ts;exports.Sec=Ze;exports.Section=at;exports.SectionHead=cu;exports.SideList=zt;exports.SmartBidInput=Sn;exports.SourceEditor=Vl;exports.SummaryCard=un;exports.THEMES=rc;exports.THEME_INIT_SCRIPT=yx;exports.THEME_STORAGE_KEY=Zn;exports.TRADITIONAL_ALLOWLIST=hs;exports.TabFilter=Un;exports.TableHead=hu;exports.TableRow=xu;exports.TagRow=Tl;exports.TagRows=Su;exports.TextButton=du;exports.TextReader=vo;exports.ThemeToggle=vx;exports.TopStrip=zi;exports.VersionLineageGraph=ua;exports.VersionLineageList=pa;exports.VersionLineageView=_o;exports.VolumeChips=mu;exports.VolumeLinks=ao;exports.WorkCard=va;exports.WorkCardGrid=Sa;exports.WorkCatalog=Om;exports.WorkPage=ca;exports.WorkRow=ka;exports.applyLayout=fx;exports.applyTheme=ac;exports.authorsLine=Kn;exports.bucketResources=to;exports.buildCatalogTree=Wh;exports.buildCollectionTable=gl;exports.buildLineageGraph=$n;exports.buildMeiliFilter=pd;exports.buildPageUrl=Di;exports.buildParagraphBlocks=Pl;exports.buildVersionRow=dl;exports.buildVersionTable=pl;exports.canParagraphize=Tn;exports.catalogNodeIdOf=Bh;exports.catalogNodeIdsOf=Mh;exports.catalogPageCount=Dh;exports.catalogTotal=To;exports.classificationPath=hn;exports.clearAllRecentIds=Gi;exports.compareCatalogCards=Fh;exports.computeVersionPartition=Zp;exports.countActiveFilters=Wn;exports.createTextApi=Ks;exports.currentLayout=bx;exports.currentTheme=cc;exports.defaultWorkLink=ya;exports.deriveDating=Yp;exports.deriveEditionType=xl;exports.deriveEra=dn;exports.deriveYear=On;exports.deriveYearRange=eo;exports.detailToEditor=na;exports.detectGenre=Gn;exports.displayAuthorRole=io;exports.editorToDetail=vg;exports.eraRank=$i;exports.filtersFromParams=ud;exports.filtersToParams=_n;exports.findCatalogPath=Bt;exports.findTraditionalChars=Jc;exports.firstAuthorText=Io;exports.flattenTitles=Ni;exports.flattenToc=rl;exports.fmtCount=Ue;exports.formatHitCount=kn;exports.formatTemplate=it;exports.formatVolumeRange=Dn;exports.getDisplayNameFromUrl=Ut;exports.getMessages=Ft;exports.getStartPage=Fi;exports.getT=Dt;exports.getTypeGroupKey=Hi;exports.groupRelatedWorks=Kp;exports.gujiInlineToPlain=Ds;exports.hasActiveFilters=Ss;exports.hasGujiMarkdownV02=ji;exports.hasGujiTableNotation=Vs;exports.hasSearchOptions=ad;exports.isLayoutName=dc;exports.isThemeName=sc;exports.lineageHref=Fa;exports.loadRecentIds=jt;exports.measureText=bt;exports.mergeVolumeResources=Oi;exports.normalizeEra=Ke;exports.normalizeLayout=Qn;exports.normalizeRole=no;exports.normalizeTheme=Jn;exports.normalizeVolumeIndex=sn;exports.normalizeVolumes=fs;exports.numberToChinese=hl;exports.paginationItems=fa;exports.parseChineseNumber=Cn;exports.parseGujiInline=Fs;exports.parseGujiTable=Ys;exports.parseSourceString=Gl;exports.pct=Lo;exports.periodLevel=za;exports.pickReaderVersion=ol;exports.readStoredLayout=hx;exports.readStoredTheme=mx;exports.readerVersionOptionLabel=wi;exports.removeRecentId=Ns;exports.renderFullTextBody=Ru;exports.renderProperNames=Bl;exports.renderReaderInline=mo;exports.resolveRecentEntry=Yi;exports.resourceHref=Vt;exports.resourceNote=Fn;exports.resultTabFromParam=kd;exports.resultTabToParam=wd;exports.roleFacets=ml;exports.rowNo=fu;exports.sameFilters=md;exports.saveRecentId=bi;exports.shelfColumns=_a;exports.sortFor=cd;exports.sortYear=zn;exports.spineHeight=Ca;exports.splitFullTextTables=Zi;exports.splitHighlightSnippet=Mi;exports.splitTableRow=Gs;exports.storeLayout=xx;exports.storeTheme=lc;exports.stringifySources=Yl;exports.timelineLayout=Da;exports.toCatalogWorkCard=Oh;exports.typeSupportsFilters=$s;exports.useBidUrl=Ye;exports.useConvert=Te;exports.useI18n=G;exports.useReaderPrefs=il;exports.useRecentEntries=Va;exports.useT=ve;exports.validateLineageGraph=rh;exports.volumeStats=Ln;exports.withDefaultLinks=vt;exports.withMetaLinks=kt;exports.yearText=Rn;
1669
+ `,Oa={item:t=>`/item/${encodeURIComponent(t)}`,node:t=>`/catalog?node=${encodeURIComponent(t)}`};function kt(t){return{...Oa,...t??{}}}function Fa(t,n){if(t.lineage)return t.lineage(n);const o=t.item(n),r=o.indexOf("#"),[s,l]=r<0?[o,""]:[o.slice(0,r),o.slice(r)];return`${s}${s.includes("?")?"&":"?"}tab=lineage${l}`}function Lo(t,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(t/n*100)))}function Da(t){const n=t.filter(d=>Number.isFinite(d.birth_year)||Number.isFinite(d.death_year)),o=t.filter(d=>!n.includes(d));if(!n.length)return{min:0,max:0,placed:[],missing:o};const r=d=>{const u=Number.isFinite(d.birth_year)?d.birth_year:d.death_year-50,g=Number.isFinite(d.death_year)?d.death_year:d.birth_year+50;return[Math.min(u,g),Math.max(u,g)]},s=n.map(r),l=Math.min(...s.map(d=>d[0])),a=Math.max(...s.map(d=>d[1])),p=Math.max(1,a-l),c=n.map((d,u)=>({p:d,from:s[u][0],to:s[u][1]})).sort((d,u)=>d.from-u.from).map(d=>({...d,left:(d.from-l)/p*100,width:Math.max(.8,(d.to-d.from)/p*100)}));return{min:l,max:a,placed:c,missing:o}}function Rn(t,n=Dt("zh-Hant")){return t<0?n("metaHome.yearBC",{n:-t}):String(t)}function ix(t){return{read:t.item,work:t.item,node:t.node}}function Ua({counts:t,links:n}){const{t:o}=Y(),r=n==null?void 0:n.type;if(!r)return null;const s=[["all",o("metaHome.typeAll"),null],["work",o("metaHome.typeLabel.work"),t.works],["book",o("metaHome.typeLabel.book"),t.books],["collection",o("metaHome.typeLabel.collection"),t.collections],["entity",o("metaHome.typeLabel.entity"),t.entities]];return e.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":o("metaHome.typeChipsLabel"),children:s.map(([l,a,p])=>e.jsx("li",{children:e.jsxs("a",{href:r(l),children:[e.jsx("b",{children:a}),p!=null&&p>0&&e.jsx("small",{children:Ue(p)})]})},l))})}function Va(t,n=5){const[o,r]=h.useState(null);h.useEffect(()=>{let l=!1;const a=jt().slice(0,n);if(!a.length||!t){r([]);return}return Promise.all(a.map(p=>Yi(t,p))).then(p=>{l||r(p.filter(c=>!c.notFound))}),()=>{l=!0}},[t,n]);const s=h.useCallback(()=>{Gi(),r([])},[]);return{entries:o,clear:s}}function ox(t,n,o){const r=t.type==="book"?t.edition||t.era:t.type==="collection"?"":t.dynasty;return r?o(r):Ga(t.type,n)}function Ga(t,n){return n(`metaHome.typeLabel.${t}`)}function Ya({entries:t,onClear:n,links:o}){const{t:r,convert:s}=Y(),l=kt(o);return e.jsxs("aside",{className:"bim-mh-recent","aria-labelledby":"bim-mh-recent-h",children:[e.jsxs("div",{className:"bim-mh-recent-h",children:[e.jsx("h2",{id:"bim-mh-recent-h",children:r("metaHome.recentTitle")}),t&&t.length>0&&n&&e.jsx("button",{type:"button",onClick:n,children:r("metaHome.recentClear")})]}),t&&t.length>0&&e.jsx("ol",{children:t.map(a=>e.jsx("li",{children:e.jsxs("a",{href:l.item(a.id),"aria-label":r("metaHome.recentItemLabel",{type:a.type?Ga(a.type,r):"",title:s(a.title)}),children:[e.jsx("i",{className:"bim-mh-ty","aria-hidden":"true",children:a.type?r(`metaHome.typeShort.${a.type}`):""}),e.jsx("span",{children:s(a.title)}),e.jsx("small",{"aria-hidden":"true",children:ox(a,r,s)})]})},a.id))}),t&&t.length===0&&e.jsx("p",{className:"bim-mh-recent-empty",children:r("metaHome.recentEmpty")})]})}function Ka(t,n,o,r=!1){return r&&(t==="done"||t==="in_progress")?n(`metaHome.siteStatus.${t}`):t==="done"||t==="in_progress"||t==="todo"?n(`metaHome.status.${t}`):o(t)}function qa({rows:t,links:n}){const{t:o,convert:r}=Y(),s=kt(n);return t.length?e.jsx("div",{className:"bim-mh-tbl-wrap",tabIndex:0,role:"region","aria-label":o("metaHome.catalogTitle"),children:e.jsxs("table",{className:"bim-mh-tbl",children:[e.jsxs("caption",{children:[o("metaHome.catalogTitle"),e.jsx("small",{children:o("metaHome.catalogNote")})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:o("metaHome.colCatalog")}),e.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colRecords")}),e.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colMatched")}),e.jsx("th",{scope:"col",children:o("metaHome.colProgress")}),e.jsx("th",{scope:"col",children:o("metaHome.colStatus")})]})}),e.jsx("tbody",{children:t.map(l=>{const a=Lo(l.imported,l.total),p=l.work_id??l.collection_id,c=r(l.edition?`${l.name}·${l.edition}`:l.name);return e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:p?e.jsx("a",{href:s.item(p),children:c}):c}),e.jsx("td",{className:"bim-mh-r",children:Ue(l.total)}),e.jsx("td",{className:"bim-mh-r",children:Ue(l.imported)}),e.jsx("td",{children:e.jsxs("span",{className:"bim-mh-meter",children:[e.jsx("i",{"aria-hidden":"true",style:{"--bimmh-w":`${a}%`}}),e.jsxs("small",{children:[a,"%"]})]})}),e.jsx("td",{children:l.status&&e.jsx("span",{className:"bim-mh-st","data-st":l.status,children:Ka(l.status,o,r)})})]},l.id||l.name)})})]})}):null}function Za({items:t,links:n,label:o}){const{convert:r}=Y();return e.jsx("ul",{className:"bim-rh-rows","aria-label":o?r(o):void 0,children:t.map(s=>e.jsx("li",{children:e.jsxs("a",{href:n.item(s.id),children:[e.jsx("span",{className:"bim-rh-t",children:r(s.title)}),s.sub&&e.jsx("small",{children:r(s.sub)})]})},s.id))})}function Ja({works:t,links:n}){const{t:o}=Y(),[r,s]=h.useState(!1);if(!t.length)return null;const l=cn(t.length);return e.jsxs("div",{className:"bim-rh-grp","data-cap":l?"":void 0,"data-open":r?"":void 0,children:[e.jsxs("h3",{className:"bim-rh-gt",children:[o("metaHome.relatedTitle"),e.jsx("small",{children:o("metaHome.relatedNote")})]}),e.jsx(Za,{items:t.map(a=>({id:a.id,title:a.title,sub:Kn(a)||void 0})),links:kt(n)}),l&&e.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":r,onClick:()=>s(a=>!a),children:r?o("action.collapse"):o("metaHome.allNWorks",{n:t.length})})]})}const Xa="siku_qige";function rx({group:t,links:n}){const{t:o,convert:r}=Y(),[s,l]=h.useState(!1);return e.jsxs("div",{className:"bim-rh-grp","data-cap":cn(t.items.length)?"":void 0,"data-open":s?"":void 0,children:[e.jsxs("h3",{className:"bim-rh-gt",children:[r(t.label),e.jsx("small",{className:"bim-rh-num",children:o("metaHome.nKinds",{n:t.items.length})})]}),e.jsx(Za,{items:t.items,links:n,label:t.label}),cn(t.items.length)&&e.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":s,onClick:()=>l(a=>!a),children:s?o("action.collapse"):o("metaHome.allNKinds",{n:t.items.length})})]})}function Qa({groups:t,links:n}){const{t:o,convert:r}=Y(),s=kt(n);if(!t.length)return null;const l=t.find(c=>c.key===Xa),a=t.filter(c=>c!==l),p=c=>{var d;return((d=c.match(/(文[^\s·・閣阁]+)[閣阁]/))==null?void 0:d[1])??c};return e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"bim-rh-gt",children:[r(l.label),e.jsx("small",{children:r(l.items.map(c=>p(c.title)).join("、"))})]}),e.jsx("ul",{className:"bim-mh-ge","aria-label":r(l.label),children:l.items.map(c=>e.jsx("li",{children:e.jsxs("a",{href:s.item(c.id),"aria-label":r(c.title),title:r(c.title),children:[e.jsx("span",{"aria-hidden":"true",children:r(p(c.title))}),p(c.title)!==c.title&&e.jsx("small",{"aria-hidden":"true",children:o("metaHome.pavilion")})]})},c.id))})]}),a.length>0&&e.jsx("div",{className:"bim-mh-cg",style:l?void 0:{marginTop:0},children:a.map(c=>e.jsx(rx,{group:c,links:s},c.key))})]})}const is=34,os=13;function rs(t,n){return t.birth_year==null&&t.death_year==null?"":`${t.birth_year!=null?Rn(t.birth_year,n):"?"}–${t.death_year!=null?Rn(t.death_year,n):"?"}`}function sx(t,n){const o=n-t,r=o>1200?300:o>400?100:50,s=[];for(let l=Math.ceil(t/r)*r;l<=n;l+=r)s.push(l);return s}function ec({people:t,links:n}){const{t:o,convert:r}=Y(),s=kt(n);if(!t.length)return null;const{min:l,max:a,placed:p,missing:c}=Da(t),d=[],u=p.map(m=>{const x=m.left>70,f=x?Math.min(m.left,m.left+m.width-os):m.left;let k=0;for(;d[k]!=null&&d[k]>f;)k++;return d[k]=x?m.left+m.width:m.left+Math.max(m.width,os),{...m,lane:k,end:x}}),g=Math.max(1,a-l);return e.jsxs(e.Fragment,{children:[u.length>0&&e.jsxs("div",{className:"bim-mh-tl",children:[e.jsx("ul",{className:"bim-mh-tl-rows",style:{height:d.length*is+10},children:u.map(m=>e.jsxs("li",{className:"bim-mh-tl-bar","data-end":m.end?"":void 0,style:{left:`${m.left}%`,top:m.lane*is+4,width:`${Math.max(m.width,.5)}%`},children:[e.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),e.jsxs("a",{href:s.item(m.p.id),children:[r(m.p.name),e.jsx("small",{className:"bim-rh-num",children:rs(m.p,o)})]})]},m.p.id))}),e.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:sx(l,a).map(m=>e.jsx("span",{style:{left:`${(m-l)/g*100}%`},children:Rn(m,o)},m))})]}),e.jsx("ul",{className:"bim-mh-tl-list","data-only":u.length?void 0:"",children:(u.length?t:c).map(m=>e.jsx("li",{children:e.jsxs("a",{href:s.item(m.id),children:[e.jsx("span",{children:r(m.name)}),e.jsx("small",{className:"bim-rh-num",children:[m.dynasty?r(m.dynasty):"",rs(m,o)].filter(Boolean).join(" ")})]})},m.id))}),c.length>0&&u.length>0&&e.jsx("p",{className:"bim-mh-tl-foot",children:o("metaHome.missingLife",{names:r(c.map(m=>m.name).join("、"))})})]})}const lx=e.jsxs("svg",{width:"54",height:"34",viewBox:"0 0 54 34",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:[e.jsx("circle",{cx:"27",cy:"5",r:"3.5"}),e.jsx("circle",{cx:"10",cy:"29",r:"3.5"}),e.jsx("circle",{cx:"27",cy:"29",r:"3.5"}),e.jsx("circle",{cx:"44",cy:"29",r:"3.5"}),e.jsx("path",{d:"M27 8.5v17M27 15H10v10.5M27 15h17v10.5"})]});function tc({works:t,links:n}){const{t:o,convert:r}=Y(),s=kt(n);return t.length?e.jsx("ul",{className:"bim-mh-lin",children:t.map(l=>{const a=Kn(l);return e.jsx("li",{children:e.jsxs("a",{href:Fa(s,l.id),children:[lx,e.jsx("b",{children:r(l.title)}),a&&e.jsx("small",{children:r(a)}),e.jsx("span",{children:o("metaHome.viewLineage")})]})},l.id)})}):null}function nc({sites:t}){const{t:n,convert:o}=Y(),r=t.filter(l=>l.status!=="todo"&&l.total>0),s=t.filter(l=>!r.includes(l));return t.length?e.jsxs(e.Fragment,{children:[r.length>0&&e.jsx("ul",{className:"bim-mh-cov",children:r.map(l=>{const a=Lo(l.imported,l.total);return e.jsxs("li",{children:[l.url?e.jsx("a",{href:l.url,rel:"noopener noreferrer",target:"_blank",children:o(l.name)}):e.jsx("span",{children:o(l.name)}),e.jsx("span",{className:"bim-mh-bar","aria-hidden":"true",style:{"--bimmh-w":`${a}%`}}),e.jsxs("small",{children:[`${Ue(l.imported)} / ${Ue(l.total)} ${a}% `,l.status&&e.jsx("span",{className:"bim-mh-st","data-st":l.status,children:Ka(l.status,n,o,!0)})]})]},l.id||l.name)})}),s.length>0&&e.jsx("p",{className:"bim-mh-todo",children:n("metaHome.plannedSites",{names:o(s.map(l=>l.name).join("、"))})})]}):null}const ss=["extant","partially_extant","lost","unknown"];function ic({stats:t,links:n,version:o,repoUrl:r,downloadHref:s}){const{t:l}=Y(),a=["works","books","collections","entities","has_image","has_text","article","poem"].map(d=>[t[d],l(`metaHome.stat.${d}`)]).filter(([d])=>d>0),p=n==null?void 0:n.loss,c=ss.some(d=>{var u;return(((u=t.loss)==null?void 0:u[d])??0)>0});return e.jsxs("div",{className:"bim-mh-data",children:[a.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"bim-rh-gt",children:l("metaHome.dataScale")}),e.jsx("ul",{className:"bim-mh-nums",children:a.map(([d,u])=>e.jsxs("li",{children:[e.jsx("b",{className:"bim-rh-num",children:Ue(d)}),e.jsx("span",{children:u})]},u))})]}),p&&e.jsxs("div",{children:[e.jsx("h3",{className:"bim-rh-gt",children:l("metaHome.byLoss")}),e.jsx("ul",{className:"bim-mh-loss",children:ss.map(d=>{var m;const u=((m=t.loss)==null?void 0:m[d])??0,g=l(`metaHome.lossNote.${d}`);return e.jsx("li",{children:e.jsxs("a",{href:p(d),children:[l(`metaHome.loss.${d}`),e.jsx("small",{className:"bim-rh-num",children:c&&u>0?l("metaHome.lossCount",{n:Ue(u),note:g}):g})]})},d)})})]}),e.jsxs("div",{className:"bim-mh-lic",children:[e.jsxs("p",{children:[e.jsx("span",{className:"bim-mh-cc0",children:"CC0"}),l("metaHome.license")]}),e.jsxs("p",{children:[l("metaHome.repo"),r?e.jsx("a",{href:r,children:e.jsx("code",{children:"book-index"})}):e.jsx("code",{children:"book-index"}),l("metaHome.repoNote")]}),o&&e.jsxs("p",{children:[l("metaHome.version"),e.jsx("code",{children:o})]}),s&&e.jsx("p",{children:e.jsx("a",{href:s,children:l("metaHome.download")})})]})]})}const oc={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function ax({sections:t,links:n,head:o,transport:r,catalogHref:s,collectionsHref:l,entitiesHref:a,version:p,repoUrl:c,downloadHref:d,className:u}){var v,$;const{t:g}=Y(),m=t,x=kt(n),f=ix(x),k=oc,b=Va(r),w={zhi:!!((v=m.shelf)!=null&&v.items.length)||m.catalog_progress.length>0||m.related_catalogs.length>0,sibu:m.bu.length>0||m.unclassified>0,cong:m.collection_groups.length>0,people:m.bibliographers.length>0,lineage:m.lineage.length>0,sites:m.sites.length>0,data:!0},y=Object.keys(k).filter(C=>w[C]),j=C=>g(`metaHome.nav.${C}`),S=(C,z)=>C?e.jsx("a",{className:"bim-rh-more",href:C,children:z}):void 0;return e.jsxs("div",{className:u?`bim-rh bim-mh ${u}`:"bim-rh bim-mh",children:[e.jsx("style",{children:No+Ha}),e.jsxs("div",{className:"bim-mh-head",children:[e.jsxs("div",{className:"bim-mh-q",children:[o,e.jsx(Ua,{counts:m.counts,links:n})]}),r&&e.jsx(Ya,{entries:b.entries,onClear:b.clear,links:n})]}),y.length>1&&e.jsx("nav",{className:"bim-rh-secnav","aria-label":g("metaHome.navLabel"),children:e.jsx("ul",{children:y.map(C=>e.jsx("li",{children:e.jsx("a",{href:`#${k[C]}`,children:j(C)})},C))})}),e.jsxs("div",{className:"bim-rh-main",children:[w.zhi&&e.jsxs(et,{id:k.zhi,title:j("zhi"),sub:g("metaHome.zhiSub"),children:[m.shelf&&m.shelf.items.length>0&&e.jsx(Ro,{topic:{key:"shelf",label:m.shelf.label,shelf:!0,items:m.shelf.items},links:f,showTitle:!1,legendCount:m.shelf.items.some(C=>C.records)?g("metaHome.shelfLegendCount"):null,legendExtra:[g("metaHome.shelfLegendClick")]}),(m.catalog_progress.length>0||m.related_catalogs.length>0)&&e.jsxs("div",{className:"bim-mh-zhi",style:($=m.shelf)!=null&&$.items.length?void 0:{marginTop:0},children:[e.jsx(qa,{rows:m.catalog_progress,links:n}),e.jsx(Ja,{works:m.related_catalogs,links:n})]})]}),w.sibu&&e.jsx(et,{id:k.sibu,title:j("sibu"),sub:g("metaHome.sibuSub"),more:S(s,g("metaHome.toCatalog")),children:e.jsx(Eo,{bu:m.bu,unclassified:m.unclassified,links:f,unclassifiedNote:g("metaHome.unclassifiedNote")})}),w.cong&&e.jsx(et,{id:k.cong,title:j("cong"),sub:g("metaHome.congSub"),more:S(l,g("metaHome.allNKindsMore",{n:Ue(m.counts.collections)})),children:e.jsx(Qa,{groups:m.collection_groups,links:n})}),w.people&&e.jsx(et,{id:k.people,title:j("people"),sub:g("metaHome.peopleSub"),more:S(a,g("metaHome.allNPeopleMore",{n:Ue(m.counts.entities)})),children:e.jsx(ec,{people:m.bibliographers,links:n})}),w.lineage&&e.jsx(et,{id:k.lineage,title:j("lineage"),sub:g("metaHome.lineageSub"),children:e.jsx(tc,{works:m.lineage,links:n})}),w.sites&&e.jsx(et,{id:k.sites,title:j("sites"),sub:g("metaHome.sitesSub"),children:e.jsx(nc,{sites:m.sites})}),e.jsx(et,{id:k.data,title:j("data"),sub:g("metaHome.dataSub"),children:e.jsx(ic,{stats:m.stats,links:n,version:p,repoUrl:c,downloadHref:d})})]})]})}const Ai=({style:t})=>{const n=h.useContext(It),{t:o}=Y();if(!n)return null;const{locale:r,setLocale:s}=n,l=r==="zh-Hant",a=()=>s(l?"zh-Hans":"zh-Hant");return e.jsxs("button",{type:"button",onClick:a,title:o(l?"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",...t},children:[e.jsx("span",{style:{color:l?i("primary"):void 0,fontWeight:l?700:400},children:o("common.localeShortHant")}),e.jsx("span",{style:{opacity:.3},children:"/"}),e.jsx("span",{style:{color:l?void 0:i("primary"),fontWeight:l?400:700},children:o("common.localeShortHans")})]})},Bi=({href:t,label:n,size:o=16,className:r,style:s})=>{const{t:l}=Y(),a=n??l("common.repoSourceLink");return e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",title:a,"aria-label":a,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:p=>{p.currentTarget.style.color=i("fg")},onMouseLeave:p=>{p.currentTarget.style.color=i("desc-fg")},children:e.jsx("svg",{width:o,height:o,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:e.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 hi(t){const n=t.text_count;return typeof n=="number"&&n>0}function xi(t,n){return{id:t,title:n.title??n.primary_name??t,type:n.type??"book"}}function cx(t,n){if(!n)return!1;const o=n.id;return o===void 0||o===t}const dx=({id:t,transport:n,initialDetail:o,initialEntry:r,activeTab:s,onTabChange:l,activeJuan:a,onJuanChange:p,lineageMode:c="list",onLineageModeChange:d,lineageCollection:u,onLineageCollectionChange:g,initialPage:m=1,selectedLineageNodeId:x,onNavigate:f,onBack:k,backLabel:b,renderLink:w,enrichDetail:y,getSourceLink:j,readLink:S,railTop:v,extraTabs:$=[],showFeedbackTab:C=!0,feedbackApiUrl:z,height:E,footerExtra:T,hideHeaderControls:_=!1,className:O,style:W})=>{const A=ke(),{t:G,convert:V}=Y(),[ie]=h.useState(()=>{if(!cx(t,o))return null;const H={...o},B=r??xi(t,H);return y&&y(B,H),{id:t,entry:B,detail:H}}),[ae,P]=h.useState((ie==null?void 0:ie.entry)??null),[I,q]=h.useState((ie==null?void 0:ie.detail)??null),[Q,oe]=h.useState(!ie),[je,Ie]=h.useState(!1),[K,me]=h.useState([]),[M,ue]=h.useState(!1),[ge,de]=h.useState(null),[Le,Me]=h.useState(null),[Ee,ze]=h.useState(null),[He,D]=h.useState(!1),re=h.useRef(null),ce=h.useRef(0),[we,F]=h.useState(null),fe=a!==void 0?a:we,Re=h.useCallback(H=>{p?p(H):F(H)},[p]),R=h.useCallback(async H=>{if(!n.getCollectionCatalogs&&!n.getCollectionCatalog){me([]);return}ue(!0);try{if(n.getCollectionCatalogs)me(await n.getCollectionCatalogs(H)||[]);else if(n.getCollectionCatalog){const B=await n.getCollectionCatalog(H);me(B?[{resource_id:"",data:B}]:[])}}catch{me([])}finally{ue(!1)}},[n]),ee=h.useCallback(async H=>{var B,ye;if(!n.getTextManifest||!n.getTextIndex){de(null),Me(H);return}try{const Ce=be.pickTextVersion(await n.getTextManifest(H)),ve=Ce?await n.getTextIndex(H,Ce.key):null;de(ve&&ve.chapters.length>0?{chapters:ve.chapters.map(xe=>({n:xe.n,title:xe.title,file:xe.file})),source:{name:((B=ve.source)==null?void 0:B.name)??(Ce==null?void 0:Ce.source_name),license:((ye=ve.source)==null?void 0:ye.license)??(Ce==null?void 0:Ce.license)??void 0}}:null)}catch{de(null)}finally{Me(H)}},[n]),he=h.useCallback(async(H,B)=>{const ye=++ce.current,Ce=()=>ye!==ce.current;D(!0);try{if(n.getLineageGraph){const Be=await n.getLineageGraph(H);if(Ce())return;Be&&ze(Be)}const ve=B.version_graph;if(!ve||!ve.enabled){Ee||ze(null),re.current=null;return}const xe=B.books??[],Oe=[];for(const Be of xe)try{const lt=await n.getItem(Be);lt&&Oe.push(lt)}catch{}if(Ce())return;re.current={work:B,books:Oe};const Te=u??ve.default_collection??(ve.core_books&&ve.core_books.length>0?"core":"all"),Ve=Te==="core"&&Array.isArray(ve.core_books)&&ve.core_books.length>0?"core":Te??"all";ze($n(B,Oe,Ve))}catch{if(Ce())return;ze(null),re.current=null}finally{Ce()||D(!1)}},[n]),L=h.useRef({initialDetail:o,initialEntry:r});L.current={initialDetail:o,initialEntry:r},h.useEffect(()=>{let H=!1;ce.current++,D(!1);const B=xe=>{xe.type==="collection"?R(t):xe.type==="work"?(xe.version_graph||n.getLineageGraph)&&he(t,xe):xe.type==="book"&&hi(xe)&&ee(t)},ye=L.current;let Ce=null;if(ie&&ie.id===t)Ce=ie;else if(ye.initialDetail&&ye.initialDetail.id===t){const xe={...ye.initialDetail},Oe=ye.initialEntry??xi(t,xe);y&&y(Oe,xe),Ce={entry:Oe,detail:xe}}return Ce?(Ie(!1),me(xe=>xe.length?[]:xe),de(null),ze(null),re.current=null,P(Ce.entry),q(Ce.detail),oe(!1),B(Ce.detail),()=>{H=!0}):((async()=>{oe(!0),Ie(!1),P(null),q(null),me([]),de(null),ze(null),re.current=null;try{const xe=await n.getItem(t);if(H)return;if(!xe){Ie(!0);return}const Oe=xe;let Te=null;if(n.getEntry&&(Te=await n.getEntry(t),H))return;Te||(Te=xi(t,Oe)),y&&y(Te,Oe),P(Te),q(Oe),B(Oe)}catch{H||Ie(!0)}finally{H||oe(!1)}})(),()=>{H=!0})},[t,n,ie,y,R,he,ee]),h.useEffect(()=>{const H=re.current;!H||!u||ze($n(H.work,H.books,u))},[u]);const X=[];if(I){if(X.push({key:"basic",label:A.detailTab.basicInfo}),I.type==="collection"){M&&K.length===0&&X.push({key:"catalog:loading",label:`${A.detailTab.catalog}…`});for(const H of K)X.push({key:`catalog:${H.resource_id}`,label:H.short_name?`${V(H.short_name)}${A.detailTab.catalogSuffix}`:A.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&X.push({key:s,label:A.detailTab.fullText}),I.type==="work"&&(Ee||He)&&X.push({key:"lineage",label:He?`${A.detailTab.lineage}…`:A.detailTab.lineage});for(const H of $)(H.position??"before-feedback")==="before-feedback"&&H.shouldShow(I)&&X.push({key:H.key,label:H.label});C&&s==="feedback"&&X.push({key:"feedback",label:A.detailTab.feedback});for(const H of $)H.position==="after-feedback"&&H.shouldShow(I)&&X.push({key:H.key,label:H.label})}h.useEffect(()=>{if(s!=="emendated"||!I)return;l("basic");const H=setTimeout(()=>{var B;(B=document.getElementById("studies"))==null||B.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(H)},[s,I,l]);const U=ae&&I&&j?j({activeTab:s,activeJuan:fe,entry:ae,detail:I}):null,se=h.useMemo(()=>{var ve;if(!I)return null;const B=(I.authors??[]).map(xe=>{const Oe=io(xe.role);return`${xe.dynasty?`〔${V(xe.dynasty)}〕`:""}${V(xe.name)}${Oe?` ${V(Oe)}`:""}`}).join(" · ");let ye=!1;try{ye=be.extractStatus(I.id)==="draft"}catch{}if(I.type==="book"){const xe=I;return{title:V(xe.title),subtitle:xe.edition?V(xe.edition):B||void 0,aside:[ye?A.status.draft:"",B&&xe.edition?B:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(I.type==="collection"){const xe=I;return{title:V(xe.title),subtitle:V(bt(xe,A.unit.juan))||void 0,aside:[(ve=xe.publication_info)==null?void 0:ve.year,ye?A.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:B||void 0}}if(I.type==="entity"){const xe=I,Oe=Ve=>Ve==null?"":Ve<0?G("detail.bce",{n:-Ve}):String(Ve),Te=xe.birth_year!=null||xe.death_year!=null?`${Oe(xe.birth_year)||"?"}—${Oe(xe.death_year)||"?"}`:"";return{title:V(xe.primary_name||xe.title),subtitle:[xe.dynasty?`〔${V(xe.dynasty)}〕`:"",Te].filter(Boolean).join(" ")||void 0,aside:ye?A.status.draft:void 0,secondLine:void 0}}const Ce=V(bt(I,A.unit.juan));return{title:V(I.title),subtitle:[Ce,B].filter(Boolean).join(" · ")||void 0,aside:[ux(A,I.subtype),ye?A.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[I,V,A,G]),Se=I&&hi(I)?"text":null,Pe=()=>{Re(null),l("fulltext")};let $e=null;if(I&&S){const H=S({detail:I,kind:Se});H&&($e=e.jsx(Ci,{href:H}))}else Se&&($e=e.jsx(Ci,{onClick:Pe}));const Fe=H=>{if(!I)return null;const B=H.replace(/\.[^.]+$/,"");if(S){const ye=S({detail:I,kind:Se,juan:B});return ye?{href:ye}:null}return{onClick:()=>{Re(B),l("fulltext")}}},De=new Set($.map(H=>H.key)),Z=X.filter(H=>H.key.startsWith("catalog:")&&H.key!=="catalog:loading"||H.key==="lineage"&&!!Ee&&!He||De.has(H.key)).map(H=>({key:H.key,label:H.label,onClick:()=>l(H.key)})),Ae=()=>{var H;return I?I.type==="work"?e.jsx(ca,{data:I,transport:n,onNavigate:f,renderLink:w,readAction:$e,railTop:v,railLinks:Z}):I.type==="book"?e.jsx(ma,{data:I,transport:n,onNavigate:f,renderLink:w,readAction:$e,fullText:ge,fullTextPending:hi(I)&&!!n.getTextManifest&&Le!==I.id,chapterLink:Fe,railTop:v,railLinks:Z}):I.type==="collection"?e.jsx(ga,{data:I,catalog:(H=K[0])==null?void 0:H.data,transport:n,onNavigate:f,renderLink:w,readAction:$e,railTop:v,railLinks:Z,catalogAction:K.length>0?e.jsxs("a",{href:"#catalog",onClick:B=>{B.preventDefault(),l(`catalog:${K[0].resource_id}`)},children:[V(A.detailTab.collectionCatalog)," →"]}):null}):e.jsx(ha,{data:I,transport:n,onNavigate:f,renderLink:w,railTop:v,railLinks:Z}):null},N=()=>{var B,ye,Ce;if(!ae||!I)return null;if(s==="basic"||s==="emendated")return Ae();if(typeof s=="string"&&s.startsWith("catalog:")){const ve=(B=K.find(xe=>`catalog:${xe.resource_id}`===s))==null?void 0:B.data;return e.jsx(qi,{data:ve,onNavigate:f,renderLink:w})}if(s==="collated"||s==="fulltext")return e.jsx(vo,{id:t,transport:n,chapter:fe,onLocationChange:ve=>Re(ve.chapter),onNavigate:f});if(s==="lineage"){if(!Ee)return e.jsx("div",{style:{color:i("label-fg"),padding:"24px 0"},children:G(He?"detail.loading":"detail.noLineageGraph")});const ve=I.type==="work"?I:null;return e.jsx(_o,{graph:Ee,renderLink:w,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:d,selectedNodeId:x,collection:u??((ye=ve==null?void 0:ve.version_graph)==null?void 0:ye.default_collection),onCollectionChange:g,collectionsAvailable:(Ce=ve==null?void 0:ve.version_graph)==null?void 0:Ce.collections,collectionCounts:(()=>{var Ve,Be,lt,ne,We,Xe,wt;if(!ve)return;const xe={},Oe=((Ve=re.current)==null?void 0:Ve.books)??[];xe.all=(((Be=ve.books)==null?void 0:Be.length)??0)-(((ne=(lt=ve.version_graph)==null?void 0:lt.excluded_books)==null?void 0:ne.length)??0);const Te=(We=ve.version_graph)==null?void 0:We.collections;if(Te)for(const Yt of Object.keys(Te))xe[Yt]=$n(ve,Oe,Yt).nodes.filter(fn=>fn.kind==="book"&&!fn.bridge).length;return xe.core==null&&((wt=(Xe=ve.version_graph)==null?void 0:Xe.core_books)!=null&&wt.length)&&(xe.core=ve.version_graph.core_books.length),xe})()})}if(s==="feedback"&&C)return e.jsx(ra,{resourceId:t,apiUrl:z});const H=$.find(ve=>ve.key===s);return H?H.render({detail:I,entry:ae,transport:n,onNavigate:f}):null};if(Q)return e.jsx(nn,{style:{minHeight:E,...W},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((H,B)=>e.jsx("div",{style:{height:B===1?40:16,width:H,opacity:.35,background:i("rule")}},B))})});if(je||!I||!ae||!se)return e.jsx(nn,{style:{minHeight:E,...W},children:e.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:i("label-fg"),fontSize:14},children:G("detail.notFound")})});const J=s==="basic"||s==="emendated",le=[{label:b??A.detailTab.backToIndex,onClick:k}];if(I.type==="book"&&I.work_id){const H=I.work_id;le.push({label:A.indexType.work,id:H,onClick:()=>f==null?void 0:f(H)})}le.push({label:A.indexType[I.type]});const te=s==="collated"||s==="fulltext",pe=typeof T=="string"?A.status[T.trim()]??T:T,_e=e.jsx(Nl,{left:e.jsxs(e.Fragment,{children:[pe,pe?" · ":"",e.jsx(px,{id:I.id,label:A.label.id,copied:A.action.copied,copyLabel:A.action.copy})]}),right:e.jsxs(e.Fragment,{children:[C&&!J&&e.jsx("button",{type:"button",onClick:()=>l("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:A.detailTab.submitVersion}),U&&e.jsx("a",{href:U.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:i("meta-fg")},children:A.detailTab.dataLicense})]})});return J?e.jsx("div",{className:O,children:e.jsxs(nn,{grid:!0,style:{minHeight:E,...W},children:[e.jsx(zi,{breadcrumb:e.jsx(Ti,{items:le}),actions:e.jsxs(e.Fragment,{children:[!_&&e.jsx(Ai,{style:{border:"none",background:"transparent"}}),!_&&U&&e.jsx(Bi,{...U})]})}),Ae(),_e]})}):e.jsx("div",{className:O,children:e.jsxs(nn,{wide:te,style:{minHeight:E,...W},children:[e.jsx(zi,{breadcrumb:e.jsxs(e.Fragment,{children:[e.jsx(lo,{char:"籍"}),e.jsx(Ti,{items:le})]}),actions:e.jsxs(e.Fragment,{children:[!_&&e.jsx(Ai,{}),C&&e.jsx("button",{type:"button",onClick:()=>l("feedback"),className:"bim-d-ui",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:A.detailTab.feedback}),!_&&U&&e.jsx(Bi,{...U})]})}),e.jsx(vl,{...se,aside:te?e.jsxs("button",{type:"button",onClick:()=>l("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:[G("detail.workInfo")," →"]}):se.aside}),!te&&X.length>1&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:X.map(H=>e.jsx(kl,{label:H.label,active:H.key===s||J&&H.key==="basic",onClick:()=>l(H.key)},H.key))}),e.jsx("div",{style:{marginTop:!te&&X.length>1?8:0},children:N()}),_e]})})};function px({id:t,label:n,copied:o,copyLabel:r}){const[s,l]=h.useState(!1);return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[e.jsxs("span",{children:[n," ",t]}),e.jsx("button",{type:"button",onClick:()=>{var a;(a=navigator.clipboard)==null||a.writeText(t).then(()=>{l(!0),setTimeout(()=>l(!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 ux(t,n){return n?t.workSubtype[n]??n:""}const rc=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],qn="zhusha",Zn="bim-theme";function sc(t){return t==="zhusha"||t==="indigo"||t==="ink"}function Jn(t){return sc(t)?t:qn}function mx(){try{return Jn(window.localStorage.getItem(Zn))}catch{return qn}}function lc(t){try{window.localStorage.setItem(Zn,t)}catch{}}function ac(t){const n=Jn(t);return document.documentElement.setAttribute("data-theme",n),n}function cc(){return Jn(document.documentElement.getAttribute("data-theme"))}const gx=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Po="airy",Xn="bim-layout";function dc(t){return t==="airy"||t==="boxed"}function Qn(t){return dc(t)?t:Po}function hx(){try{return Qn(window.localStorage.getItem(Xn))}catch{return Po}}function xx(t){try{window.localStorage.setItem(Xn,t)}catch{}}function fx(t){const n=Qn(t);return document.documentElement.setAttribute("data-layout",n),n}function bx(){return Qn(document.documentElement.getAttribute("data-layout"))}const yx=`try{var t=localStorage.getItem(${JSON.stringify(Zn)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Xn)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,jx={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},vx=({onChange:t,style:n})=>{const{t:o}=Y(),[r,s]=h.useState(qn);h.useEffect(()=>{s(cc())},[]);const l=a=>{s(ac(a)),lc(a),t==null||t(a)};return e.jsx("div",{role:"radiogroup","aria-label":o("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:rc.map(a=>{const p=r===a.name;return e.jsx("button",{type:"button",role:"radio","aria-checked":p,"aria-label":o(`common.theme.${a.name}`),title:o(`common.theme.${a.name}`),onClick:()=>l(a.name),style:{width:28,height:44,padding:0,border:0,background:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:e.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:"50%",boxSizing:"border-box",background:i(jx[a.name]),boxShadow:p?`0 0 0 2px ${i("page-bg")}, 0 0 0 3.5px ${i("aux-fg")}`:"none"}})},a.name)})})};exports.BidLink=be.BidLink;exports.BookIndexError=be.BookIndexError;exports.BookIndexManager=be.BookIndexManager;exports.BookIndexStorage=be.BookIndexStorage;exports.BundleStorage=be.BundleStorage;exports.ConfigError=be.ConfigError;exports.GithubStorage=be.GithubStorage;exports.IdGenerationError=be.IdGenerationError;exports.IdGenerator=be.IdGenerator;exports.LocalStorage=be.LocalStorage;exports.MigrationError=be.MigrationError;exports.StorageError=be.StorageError;exports.VARIANT_CHARS=be.VARIANT_CHARS;exports.base36Decode=be.base36Decode;exports.base36Encode=be.base36Encode;exports.base58Decode=be.base58Decode;exports.buildId=be.buildId;exports.buildPromotionMap=be.buildPromotionMap;exports.cleanName=be.cleanName;exports.decodeId=be.decodeId;exports.decodeIdString=be.decodeIdString;exports.encodeId=be.encodeId;exports.extractIdFromUrl=be.extractIdFromUrl;exports.extractStatus=be.extractStatus;exports.extractType=be.extractType;exports.isChapterSegment=be.isChapterSegment;exports.isTextKey=be.isTextKey;exports.matchChapterAcrossVersions=be.matchChapterAcrossVersions;exports.normalizeCatalog=be.normalizeCatalog;exports.normalizeVariants=be.normalizeVariants;exports.parseId=be.parseId;exports.pickTextVersion=be.pickTextVersion;exports.shardOf=be.shardOf;exports.smartDecode=be.smartDecode;exports.textVersionLabel=be.textVersionLabel;exports.validateResource=be.validateResource;exports.Badge=In;exports.BidUrlProvider=vc;exports.BookDetailLayout=dx;exports.BookPage=ma;exports.Breadcrumb=Ti;exports.CATALOG_ALL_ID=ht;exports.CATALOG_CSS=xa;exports.CATALOG_NARROW_QUERY=Co;exports.CATALOG_PAGE_SIZE=zo;exports.CATALOG_UNCLASSIFIED_ID=Ct;exports.CLASSIFICATIONS=Mn;exports.COMMON_TRADITIONAL_CHARS=gs;exports.CardFoot=mn;exports.CatalogPage=Kh;exports.CatalogPager=wa;exports.CatalogTree=ba;exports.CheckFilter=bl;exports.Chip=wl;exports.ChipWall=uu;exports.CollectionCatalog=qi;exports.CollectionPage=ga;exports.CreateEntityDialog=Jl;exports.DEFAULT_LAYOUT=Po;exports.DEFAULT_META_HOME_LINKS=Oa;exports.DEFAULT_READER_PREFS=Xi;exports.DEFAULT_READ_HOME_LINKS=$a;exports.DEFAULT_THEME=qn;exports.DETAIL_CSS=jl;exports.DYNASTY_GROUPS=Bn;exports.Dash=bu;exports.DataTable=gu;exports.DetailFooter=Nl;exports.DetailGrid=pn;exports.DetailHeader=vl;exports.EMPTY_FILTERS=An;exports.EmendatedBySection=Ms;exports.EmptyNote=$u;exports.EntityDetail=Rs;exports.EntityPage=ha;exports.EntityPickerDialog=Ql;exports.EntitySelector=Zl;exports.ExpandRow=yu;exports.ExtLink=_u;exports.FEEDBACK_FAB_OFFSET_VAR=Ei;exports.FILTER_SUPPORT=ws;exports.FONT_SIZE_STEPS=gt;exports.FactList=au;exports.FeedbackButton=Ag;exports.FeedbackDialog=ia;exports.FeedbackForm=oa;exports.FeedbackList=ko;exports.FeedbackTab=ra;exports.FilterChip=kl;exports.FormInput=nt;exports.FormTextArea=Tt;exports.GUJI_MARKDOWN_FIELD=mp;exports.GUJI_TABLE_NOTATION=Us;exports.GlyphBadge=lo;exports.GujiTable=co;exports.HomePage=Ii;exports.ImagePanel=vi;exports.IndexApp=Hm;exports.IndexBrowser=yi;exports.IndexDetail=Ki;exports.IndexEditor=ea;exports.IndexView=kg;exports.IntroGrid=lu;exports.LAYOUTS=gx;exports.LAYOUT_STORAGE_KEY=Xn;exports.LOSS_OPTIONS=ks;exports.LocaleContext=It;exports.LocaleProvider=Kc;exports.LocaleToggle=Ai;exports.META_HOME_CSS=Ha;exports.META_HOME_SECTION_IDS=oc;exports.MetaCatalogTable=qa;exports.MetaCollectionGroups=Qa;exports.MetaDataLicense=ic;exports.MetaHomeView=ax;exports.MetaLine=qe;exports.MetaLineageCards=tc;exports.MetaOnlineSites=nc;exports.MetaPeopleTimeline=ec;exports.MetaRecentPanel=Ya;exports.MetaRelatedCatalogs=Ja;exports.MetaTypeChips=Ua;exports.ModeIndicator=bs;exports.MoreButton=pu;exports.MoreLink=ro;exports.PAGE_MAX_WIDTH=wn;exports.PERIOD_NARROW_SHARE=Ta;exports.PageFrame=nn;exports.Quote=vu;exports.READER_CSS=Qs;exports.READ_HOME_CSS=No;exports.READ_HOME_NARROW_QUERY=xn;exports.READ_HOME_SECTION_IDS=Wa;exports.READ_PERIOD_LABELS=Xh;exports.RECENT_IDS_STORAGE_KEY=Mt;exports.ROLE_CLASS_ORDER=ul;exports.ReadButton=Ci;exports.ReadFamousWorks=Aa;exports.ReadHomeView=ex;exports.ReadPeriodBand=Ba;exports.ReadPicks=Ra;exports.ReadPieces=Ma;exports.ReadSection=et;exports.ReadShelf=Ro;exports.ReadSibu=Eo;exports.ReadStats=Ia;exports.ReadTopicGroup=La;exports.ReadTopics=Pa;exports.ReaderMdText=go;exports.ReaderShell=sl;exports.ReaderToc=tl;exports.RelationPanel=Kl;exports.RepoSourceLink=Bi;exports.ResourceEditor=fi;exports.ResourceGroup=ku;exports.ResourceLine=wu;exports.ResourceList=Ui;exports.ResourceRow=zl;exports.SEARCH_VIEW_STORAGE_KEY=Vi;exports.SEVEN_PAVILIONS_KEY=Xa;exports.SNIPPET_MARK_END=cs;exports.SNIPPET_MARK_START=as;exports.SORTABLE_TYPES=vs;exports.SearchInput=js;exports.SearchResults=Ts;exports.Sec=Ze;exports.Section=at;exports.SectionHead=cu;exports.SideList=zt;exports.SmartBidInput=Sn;exports.SourceEditor=Vl;exports.SummaryCard=un;exports.THEMES=rc;exports.THEME_INIT_SCRIPT=yx;exports.THEME_STORAGE_KEY=Zn;exports.TRADITIONAL_ALLOWLIST=hs;exports.TabFilter=Un;exports.TableHead=hu;exports.TableRow=xu;exports.TagRow=Tl;exports.TagRows=Su;exports.TextButton=du;exports.TextReader=vo;exports.ThemeToggle=vx;exports.TopStrip=zi;exports.VersionLineageGraph=ua;exports.VersionLineageList=pa;exports.VersionLineageView=_o;exports.VolumeChips=mu;exports.VolumeLinks=ao;exports.WorkCard=va;exports.WorkCardGrid=Sa;exports.WorkCatalog=Om;exports.WorkPage=ca;exports.WorkRow=ka;exports.applyLayout=fx;exports.applyTheme=ac;exports.authorsLine=Kn;exports.bucketResources=to;exports.buildCatalogTree=Wh;exports.buildCollectionTable=gl;exports.buildLineageGraph=$n;exports.buildMeiliFilter=pd;exports.buildPageUrl=Di;exports.buildParagraphBlocks=Pl;exports.buildVersionRow=dl;exports.buildVersionTable=pl;exports.canParagraphize=Tn;exports.catalogNodeIdOf=Bh;exports.catalogNodeIdsOf=Mh;exports.catalogPageCount=Dh;exports.catalogTotal=To;exports.classificationPath=hn;exports.clearAllRecentIds=Gi;exports.compareCatalogCards=Fh;exports.computeVersionPartition=Zp;exports.countActiveFilters=Wn;exports.createTextApi=Ks;exports.currentLayout=bx;exports.currentTheme=cc;exports.defaultWorkLink=ya;exports.deriveDating=Yp;exports.deriveEditionType=xl;exports.deriveEra=dn;exports.deriveYear=On;exports.deriveYearRange=eo;exports.detailToEditor=na;exports.detectGenre=Gn;exports.displayAuthorRole=io;exports.editorToDetail=vg;exports.eraRank=$i;exports.filtersFromParams=ud;exports.filtersToParams=_n;exports.findCatalogPath=Bt;exports.findTraditionalChars=Jc;exports.firstAuthorText=Io;exports.flattenTitles=Ni;exports.flattenToc=rl;exports.fmtCount=Ue;exports.formatHitCount=kn;exports.formatTemplate=it;exports.formatVolumeRange=Dn;exports.getDisplayNameFromUrl=Ut;exports.getMessages=Ft;exports.getStartPage=Fi;exports.getT=Dt;exports.getTypeGroupKey=Hi;exports.groupRelatedWorks=Kp;exports.gujiInlineToPlain=Ds;exports.hasActiveFilters=Ss;exports.hasGujiMarkdownV02=ji;exports.hasGujiTableNotation=Vs;exports.hasSearchOptions=ad;exports.isLayoutName=dc;exports.isThemeName=sc;exports.lineageHref=Fa;exports.loadRecentIds=jt;exports.measureText=bt;exports.mergeVolumeResources=Oi;exports.normalizeEra=Ke;exports.normalizeLayout=Qn;exports.normalizeRole=no;exports.normalizeTheme=Jn;exports.normalizeVolumeIndex=sn;exports.normalizeVolumes=fs;exports.numberToChinese=hl;exports.paginationItems=fa;exports.parseChineseNumber=Cn;exports.parseGujiInline=Fs;exports.parseGujiTable=Ys;exports.parseSourceString=Gl;exports.pct=Lo;exports.periodLevel=za;exports.pickReaderVersion=ol;exports.readStoredLayout=hx;exports.readStoredTheme=mx;exports.readerVersionOptionLabel=wi;exports.removeRecentId=Ns;exports.renderFullTextBody=Ru;exports.renderProperNames=Bl;exports.renderReaderInline=mo;exports.resolveRecentEntry=Yi;exports.resourceHref=Vt;exports.resourceNote=Fn;exports.resultTabFromParam=kd;exports.resultTabToParam=wd;exports.roleFacets=ml;exports.rowNo=fu;exports.sameFilters=md;exports.saveRecentId=bi;exports.shelfColumns=_a;exports.sortFor=cd;exports.sortYear=zn;exports.spineHeight=Ca;exports.splitFullTextTables=Zi;exports.splitHighlightSnippet=Mi;exports.splitTableRow=Gs;exports.storeLayout=xx;exports.storeTheme=lc;exports.stringifySources=Yl;exports.timelineLayout=Da;exports.toCatalogWorkCard=Oh;exports.typeSupportsFilters=$s;exports.useBidUrl=Ye;exports.useConvert=Ne;exports.useI18n=Y;exports.useReaderPrefs=il;exports.useRecentEntries=Va;exports.useT=ke;exports.validateLineageGraph=rh;exports.volumeStats=Ln;exports.withDefaultLinks=vt;exports.withMetaLinks=kt;exports.yearText=Rn;