book-index-ui 0.54.2 → 0.54.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -677,7 +677,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
677
677
  `),[pe]),ye=g.useRef(null),We=U=>{U!==Ve&&(F||(ye.current={key:U,sig:Q,done:!1}),B===void 0&&Re(U),N==null||N(U))};g.useEffect(()=>{const U=ye.current;if(!U||U.key!==Ve)return;const De=pe.find(jt=>!jt.disabled);if(!De)return;const Xe=Q!==U.sig;!Xe&&U.done||(Xe?ye.current=null:U.done=!0,De.key!==o&&D(De.key))},[Ve,Q,pe,o,D]);const Me=pe.find(U=>U.key===o),Ie=()=>{var U;k==null||k({chapterKey:o,chapterLabel:typeof(Me==null?void 0:Me.label)=="string"?Me.label:void 0,anchor:th(O.current,((U=ee.current)==null?void 0:U.getBoundingClientRect().bottom)??0),selectedText:nh(O.current)})},je=pe.findIndex(U=>U.key===o),$e=je>0?pe.slice(0,je).reverse().find(U=>!U.disabled):void 0,Oe=je>=0?pe.slice(je+1).find(U=>!U.disabled):void 0,Le=u.fontSize??_r,ft=Ym(u.fontFamily),yt={...de,...u.fontSize?{"--bimrd-fs":`${u.fontSize}px`}:null,...ft?{"--bimrd-ff":ft}:null},sn={song:H("reader.fontSong"),kai:H("reader.fontKai"),system:H("reader.fontSystem")},Yt=x||!!ae,Ot=t.jsxs("div",{className:"bim-rd-sp",children:[t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Ee}-g1`,children:[t.jsx("h3",{id:`${Ee}-g1`,className:"bim-rd-sp-h",children:H("reader.groupText")}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:H("reader.font")}),t.jsx("select",{className:"bim-rd-sp-sel","aria-label":H("reader.font"),value:u.fontFamily,onChange:U=>m({fontFamily:U.target.value}),children:Fl.map(U=>t.jsx("option",{value:U.key,children:sn[U.key]},U.key))})]}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:H("reader.fontSize")}),t.jsxs("span",{className:"bim-rd-sp-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":H("reader.fontSmaller"),disabled:Le<=Et[0],onClick:()=>m({fontSize:oi(u.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[Le,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":H("reader.fontLarger"),disabled:Le>=Et[Et.length-1],onClick:()=>m({fontSize:oi(u.fontSize,1)}),children:"A+"})]})]}),t.jsx(eh,{prefs:u,onPrefsChange:m,origAvailable:y}),t.jsx(pi,{label:H("reader.quoteStyle"),value:u.quoteStyle,options:[{key:"modern",label:H("reader.quoteModern")},{key:"classic",label:H("reader.quoteClassic")},{key:"original",label:H("reader.quoteOriginal")}],onPick:U=>m({quoteStyle:U})})]}),Yt&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Ee}-g2`,children:[t.jsx("h3",{id:`${Ee}-g2`,className:"bim-rd-sp-h",children:H("reader.groupMark")}),x&&t.jsxs(t.Fragment,{children:[t.jsx(pi,{label:H("reader.properName"),value:u.properNameMode,title:H("reader.properNameTitle"),options:[{key:"off",label:H("reader.properNameOff")},{key:"lite",label:H("reader.properNameLite"),title:H("reader.properNameLiteTitle")},{key:"full",label:H("reader.properNameFull")}],onPick:U=>m({properNameMode:U})}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.showWorks,onChange:U=>m({showWorks:U.target.checked})}),t.jsx("span",{children:H("reader.showWorks")})]}),t.jsx(pi,{label:H("reader.bookTitleStyle"),value:u.bookTitleStyle,options:[{key:"wavy",label:H("reader.bookTitleWavy")},{key:"bracket",label:H("reader.bookTitleBracket")}],onPick:U=>m({bookTitleStyle:U})})]}),ae]}),t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Ee}-g3`,children:[t.jsx("h3",{id:`${Ee}-g3`,className:"bim-rd-sp-h",children:H("reader.groupLayout")}),f&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.readingMode==="paragraph",title:H("reader.paragraphTitle"),onClick:()=>m({readingMode:u.readingMode==="paragraph"?"line":"paragraph"}),children:H("reader.paragraph")}),w&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.workLinks,onChange:U=>m({workLinks:U.target.checked})}),t.jsx("span",{children:H("reader.workLinks")})]}),v&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.writingMode==="vertical",onClick:()=>m({writingMode:u.writingMode==="vertical"?"horizontal":"vertical"}),children:H("reader.vertical")}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.pageBreaks,onChange:U=>m({pageBreaks:U.target.checked})}),t.jsx("span",{children:H("reader.pageBreaks")})]}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.preserveMargins,onChange:U=>m({preserveMargins:U.target.checked})}),t.jsx("span",{children:H("reader.preserveMargins")})]}),G]})]});return t.jsxs("div",{className:["bim-rd",u.writingMode==="vertical"&&v?"bim-rd-vertical":"",J].filter(Boolean).join(" "),"data-toc":M,"data-img":Ke?"open":"closed","data-bb":K?"":void 0,"data-set":!K&&Z?"open":void 0,"data-warp":V?"true":void 0,style:yt,children:[t.jsx("style",{children:Bl}),t.jsx("a",{className:"bim-rd-skip",href:`#${Fe}`,onClick:U=>{var De,Xe,jt;U.preventDefault(),(De=O.current)==null||De.focus(),(jt=(Xe=O.current)==null?void 0:Xe.scrollIntoView)==null||jt.call(Xe,{block:"start"})},children:H("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:ee,children:[S&&t.jsxs("a",{className:"bim-rd-back",href:S,"aria-label":H("reader.backAria",{label:ke}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:ke})]}),(e||n||$||b)&&t.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[e&&t.jsx("b",{children:e}),$&&t.jsx("span",{className:"bim-rd-by",children:$}),b&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-rd-cur",children:b})]}),n&&t.jsx("span",{className:"bim-rd-ttl-src",children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":H("reader.settings"),children:[P&&P.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:le?ue($r(le)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:H("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:H("reader.versionShort")}),t.jsx("select",{"aria-label":H("reader.version"),value:Ve??"",onChange:U=>We(U.target.value),children:P.map(U=>t.jsx("option",{value:U.key,children:ue($r(U))},U.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),z&&($e||Oe)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":H("reader.pagerGroup",{unit:ie}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":H("reader.prevUnit",{unit:ie}),title:$e?typeof $e.label=="string"&&$e.label?H("reader.prevUnitTitle",{unit:ie,label:$e.label}):H("reader.prevUnit",{unit:ie}):H("reader.firstUnit",{unit:ie}),disabled:!$e,onClick:()=>$e&&D($e.key),children:t.jsx(Zm,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":H("reader.nextUnit",{unit:ie}),title:Oe?typeof Oe.label=="string"&&Oe.label?H("reader.nextUnitTitle",{unit:ie,label:Oe.label}):H("reader.nextUnit",{unit:ie}):H("reader.lastUnit",{unit:ie}),disabled:!Oe,onClick:()=>Oe&&D(Oe.key),children:t.jsx(Jm,{})})]}),z&&($e||Oe)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:fe,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":ce,"aria-controls":Ce,onClick:I,children:[t.jsx(Ds,{}),t.jsx("span",{className:"bim-rd-tlabel",children:H("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":Ke,onClick:()=>Ye(Ke?"closed":"open"),children:[t.jsx(Vs,{}),H("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(Qm,{prefs:u,onPrefsChange:m,origAvailable:y}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":H("reader.fontSmaller"),disabled:Le<=Et[0],onClick:()=>m({fontSize:oi(u.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":H("reader.fontLarger"),disabled:Le>=Et[Et.length-1],onClick:()=>m({fontSize:oi(u.fontSize,1)}),children:"A+"}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsxs("button",{ref:Te,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":Z,"aria-controls":Ee,onClick:()=>oe(U=>!U),children:[t.jsx(Us,{}),t.jsx("span",{className:"bim-rd-tlabel",children:H("reader.settings")})]}),ne]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:Ce,ref:Y,role:be&&ce?"dialog":void 0,"aria-modal":be&&ce?!0:void 0,"aria-label":be&&ce?H("reader.toc"):void 0,onKeyDown:U=>{if(!(!be||!ce)){if(U.key==="Escape"){U.stopPropagation(),Ge(!0);return}U.key==="Tab"&&Gs(U,Y.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:l??H("reader.toc")}),be&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":H("reader.closeToc"),onClick:()=>Ge(!0),children:"✕"})]}),a]}),t.jsx(Wl,{items:i,activeKey:o,onSelect:D})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>Ge(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":H("reader.images"),children:Ke&&(q||t.jsx(Sr,{pages:d??null,loading:c,renderOverlay:p,preserveMargins:u.preserveMargins}))}),!K&&Z&&t.jsxs("aside",{className:"bim-rd-set",id:Ee,"aria-label":H("reader.settings"),onKeyDown:U=>{var De;U.key==="Escape"&&(U.stopPropagation(),oe(!1),(De=Te.current)==null||De.focus())},children:[t.jsxs("div",{className:"bim-rd-sp-top",children:[t.jsx("span",{children:H("reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":H("reader.closeSettings"),onClick:()=>{var U;oe(!1),(U=Te.current)==null||U.focus()},children:"✕"})]}),Ot]}),t.jsxs("div",{className:"bim-rd-text",id:Fe,ref:O,tabIndex:-1,"data-rail":(j||k)&&!V?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[ge,E&&le&&(le.sourceName||le.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":le.key,children:[le.sourceName&&t.jsxs(t.Fragment,{children:[H("reader.sourceLabel")," ",le.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:le.sourceUrl,target:"_blank",rel:"noreferrer",children:ue(le.sourceName)}):ue(le.sourceName)]}),le.sourceName&&le.license&&t.jsx("span",{className:"bim-rd-dot"}),le.license&&t.jsx(t.Fragment,{children:H("reader.licenseOf",{license:le.license})})]}),C&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:H("reader.revisedAt",{date:C})}),k&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:U=>U.preventDefault(),onClick:Ie,children:H("reader.reportError")})}),z&&($e||Oe)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":H("reader.pagerNav"),children:[$e?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>D($e.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),H("reader.prevUnit",{unit:ie})]}),t.jsx("span",{className:"bim-rd-pglabel",children:$e.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",H("reader.firstUnit",{unit:ie})]}),Oe?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>D(Oe.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[H("reader.nextUnit",{unit:ie}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:Oe.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[H("reader.lastUnit",{unit:ie})," →"]})]})]}),(j||k)&&!V&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":H("reader.rail"),children:[j,k&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:U=>U.preventDefault(),onClick:Ie,children:H("reader.reportError")})})]})]})]}),K&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":H("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":ce,"aria-controls":Ce,onClick:()=>{he(null),I()},children:[t.jsx(Ds,{}),t.jsx("span",{children:H("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":se==="img","aria-haspopup":"dialog",onClick:U=>ve("img",U.currentTarget),children:[t.jsx(Vs,{}),t.jsx("span",{children:H("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":se==="set","aria-haspopup":"dialog",onClick:U=>ve("set",U.currentTarget),children:[t.jsx(Us,{}),t.jsx("span",{children:H("reader.settingsShort")})]}),k&&t.jsxs("button",{type:"button",onMouseDown:U=>U.preventDefault(),onClick:()=>{he(null),Ie()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:H("reader.reportError")})]})]}),K&&se&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:_e}),t.jsxs("div",{className:"bim-rd-sheet",ref:W,role:"dialog","aria-modal":"true","aria-label":H(se==="img"?"reader.images":"reader.settings"),onKeyDown:U=>{if(U.key==="Escape"){U.stopPropagation(),_e();return}U.key==="Tab"&&Gs(U,W.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:H(se==="img"?"reader.images":"reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":H("reader.close"),onClick:_e,children:"✕"})]}),se==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(Sr,{pages:d??null,loading:c,renderOverlay:p,preserveMargins:u.preserveMargins})}):Ot]})]})]})}const Yl=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],ih={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function nt(e){return ih[e]??e}const hn=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],gn={熹平: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},ql={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function Ni(e){const n=e.match(/^\s*(\d{3,4})(?:\s*[-–—~至]\s*(\d{3,4}))?/);if(!n)return;const i=parseInt(n[1],10);if(i<100||i>2100)return;const o=n[2]?parseInt(n[2],10):void 0;return{from:i,to:o!=null&&o>=i&&o<=2100?o:void 0}}function rh(e){return e>=1950?"":e>=1912?"民國":e>=1645?"清":e>=1368?"明":e>=1279?"元":e>=960?"宋":e>=907?"五代":e>=618?"唐":e>=581?"隋":e>=420?"南北朝":e>=265?"晉":e>=220?"三國":e>=-202?"漢":""}const oh=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,qs={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function so(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(qs))if(n.startsWith(s))return qs[s];const i=nt(n);if(Jt[i]!=null)return i;const o=At(n);if(o&&n.length<=o.length+1)return nt(o)}function Zt(e,n){if(n){const i=ql[`${n}|${e}`];if(i!=null)return i}return gn[e]}const sh=1911;function ah(e){const n=gn[e];if(n==null)return;const i=Ct[e];let o;for(const[s,a]of Object.entries(gn))Ct[s]===i&&a>n&&(o==null||a<o)&&(o=a);return o!=null?o-1:void 0}const lh={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function xi(e){if(!e)return;if(/^\d+$/.test(e))return parseInt(e,10);let n=0,i=0,o=!1;for(const a of e){const l=lh[a];if(l===void 0)return;o=!0,a==="十"?i=(i||1)*10:a==="廿"||a==="卅"?(n+=l,i=0):i>=10?(n+=i+l,i=0):i=i*10+l}const s=n+i;return o&&s>0?s:void 0}function At(e){for(const n of Yl)if(e.startsWith(n))return n}const Ct={};{const e=(n,i)=>{for(const o of i)Ct[o]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function Qt(e,n){const i=n==="北宋"||n==="南宋"?"宋":n;for(const o of Object.keys(gn))if(e.includes(o)&&!(i&&Ct[o]&&Ct[o]!==i&&ql[`${i}|${o}`]==null))return o}function Wn(e){var l,d,c;const n={era:"",reign:"",source:"none"},i=e.dating;if(i!=null&&i.era||i!=null&&i.reign)return{era:i.era??"",reign:i.reign??"",source:i.certainty==="attested"?"catalog":"edition"};const o=(l=e.lineage)==null?void 0:l.year_text;if(o){const p=At(o)??"";return{era:nt(p),reign:Qt(o,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=Ni(s);if(p)return{era:rh(p.from),reign:"",source:"publication"};const h=At(s)??so(s)??((c=hn.find(f=>f.pattern.test(s)))==null?void 0:c.era)??"",u=Qt(s,h)??"",m=h||(u?Ct[u]??"":"");if(m||u)return{era:nt(m),reign:u,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=At(a);if(p)return{era:nt(p),reign:Qt(a,p)??"",source:"edition"};const h=hn.find(u=>u.pattern.test(a));if(h)return{era:nt(h.era),reign:Qt(a,h.era)??h.reign??"",source:"edition"}}return n}function Ii(e){var o,s,a,l,d,c,p,h,u;if(((o=e.dating)==null?void 0:o.year)!=null)return e.dating.year;if(typeof((s=e.lineage)==null?void 0:s.year)=="number")return e.lineage.year;const n=(a=e.publication_info)==null?void 0:a.year;if(n){const m=Ni(n);if(m)return m.from}const i=[(l=e.lineage)==null?void 0:l.year_text,(d=e.publication_info)==null?void 0:d.year,e.edition,e.edition?void 0:e.title].filter(Boolean);for(const m of i){const f=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(f&&m!==f&&(At(f)||so(f)))break;const x=m.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??m.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(x){const w=parseInt(x[1],10);if(w>=100&&w<=2100)return w}const v=m.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(v){const w=At(m);if(!w||nt(w)==="民國"){const k=xi(v[1]);if(k!=null&&k>=1&&k<=120)return sh+k}}const y=At(m)??((h=hn.find(w=>w.pattern.test(m)))==null?void 0:h.era),$=y?nt(y):void 0,b=Qt(m,$)??(At(m)||(u=hn.find(w=>w.pattern.test(m)))==null?void 0:u.reign);if(b){const w=Zt(b,$);if(w==null)continue;const j=m.indexOf(b),k=j>=0?m.slice(j+b.length):"",C=k.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??k.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),S=C?xi(C[1]):void 0;return w+(S?S-1:0)}}}function ao(e){var l,d,c,p,h,u;const n=(l=e.dating)==null?void 0:l.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const i=(d=e.lineage)==null?void 0:d.year_range;if(i&&i.length===2)return{from:i[0],to:i[1]};const o=(c=e.lineage)==null?void 0:c.year_text;if(o){const m=o.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(m){const f=Cr[nt(m[1])],x=Jt[nt(m[2])];if(f!=null&&x!=null)return{from:Math.min(f,x)-20,to:Math.max(f,x)+40}}}const s=(p=e.publication_info)==null?void 0:p.year;if(s){const m=Ni(s);if((m==null?void 0:m.to)!=null)return{from:m.from,to:m.to};const f=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(f){const x=Cr[nt(f[1])],v=Jt[nt(f[2])];if(x!=null&&v!=null)return{from:Math.min(x,v)-20,to:Math.max(x,v)+40}}}const a=[(h=e.publication_info)==null?void 0:h.year,e.edition,e.title].filter(Boolean);for(const m of a){if(!/[間间]/.test(m))continue;const f=At(m)??so(m)??((u=hn.find(y=>y.pattern.test(m)))==null?void 0:u.era),x=f?nt(f):void 0,v=[];for(const y of Object.keys(gn))m.includes(y)&&(x&&Ct[y]&&Ct[y]!==x||Zt(y,x)!=null&&v.push(y));if(v.length===0){const y=m.match(/([一-鿿])([一-鿿])[間间]/);if(y&&x){for(const $ of[y[1],y[2]])for(const b of Object.keys(gn))if(Ct[b]===x&&!(b[0]!==$&&b[b.length-1]!==$)&&Zt(b,x)!=null){v.push(b);break}}}if(v.length>0){const y=v.map(j=>Zt(j,x)).filter(j=>j!=null),$=Math.min(...y),b=v.reduce((j,k)=>Zt(j,x)>=Zt(k,x)?j:k),w=ah(b)??cr(x??"")??Math.max(...y);return{from:$,to:w>$?w:cr(x??Ct[b]??"")??$}}if(x&&Jt[x]!=null)return{from:Jt[x],to:cr(x)??Jt[x]}}}const Jt={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},ch=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],dh=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,Ks=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function Xs(e,n){for(const i of Yl){const o=e.indexOf(i);if(o<0)continue;if(i.length===1){const c=e[o+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!Qt(e.slice(o),nt(i)))continue}const s=nt(i);if(s===n)continue;const a=e.slice(o),l=Qt(a,s)??"";let d;if(l){const c=Zt(l,s);if(c!=null){const h=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),u=h?xi(h[1]):void 0;d=c+(u?u-1:0)}}return{era:s,reign:l,year:d}}for(const i of hn)if(i.pattern.test(e))return{era:nt(i.era),reign:i.reign??""}}function ph(e){var $,b,w,j,k;const n=Wn(e),i=(($=e.publication_info)==null?void 0:$.year)??"",o=i?Ni(i):void 0;if(!n.era&&!n.reign&&!o)return;const s=e.edition||e.title||"",a=/[間间]/.test(s),l=((b=e.lineage)==null?void 0:b.year_text)??"",d=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(l),c=n.source==="publication"&&oh.test(i),p=n.source==="publication"&&/[間间]/.test(i),h=l.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let u;a||d||c||p?u=void 0:h?u=parseInt(h[2],10):u=Ii(e);const m=u==null?ao(e):void 0;let f;n.source==="publication"&&(c||Ks.test(i))?f="uncertain":n.source==="lineage"||n.source==="publication"?f="attested":Ks.test(s)||!n.reign&&u==null?f="uncertain":f="inferred";const x=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((w=e.lineage)==null?void 0:w.year_text)??((j=e.lineage)==null?void 0:j.year)??""}」`:`出版著錄「${((k=e.publication_info)==null?void 0:k.year)??""}」`,v={era:n.era,reign:n.reign,year:u,yearRange:m,certainty:f,source:n.source==="edition"?"edition":"catalog",basis:x};if(h){const C=l.match(/[、,,]\s*([宋元明清])/);C&&C[1]!==v.era&&(v.laterRepair={era:C[1]})}if(!v.laterRepair&&dh.test(s)){const C=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);C&&C[1]!==n.era&&(v.laterRepair={era:C[1]})}const y=ch.find(C=>C.re.test(s));if(y){const C=s.search(y.re),S=s.slice(C),_=Xs(S,n.era)??Xs(s,n.era);_&&(v.basedOn={era:_.era,reign:_.reign,year:_.year,relation:y.relation})}return v}const Cr={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function cr(e){return Cr[e]}function bi(e){const n=Ii(e);if(n!=null)return n;const i=ao(e);if(i)return i.from;const o=Wn(e).era;return o?Jt[o]:void 0}const Zs=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function Tr(e){const n=Zs.indexOf(e);return n===-1?Zs.length:n}function uh(e){const n={belongsTo:[],collected:[],contains:[],derivative:[],studies:[],related:[]};for(const s of e){const a=s.relation;a==="part_of"?n.belongsTo.push(s):a==="collected_in"?n.collected.push(s):a==="has_part"||a==="contains_text_of"?n.contains.push(s):a==="text_carried_by"||a==="studied_by"||a==="derived_from"||a==="followed_by"||a==="has_adaptation"?n.derivative.push(s):a==="studies"||a==="preceded_by"?n.studies.push(s):n.related.push(s)}const i=[],o=(s,a)=>{n[s].length&&i.push({key:s,labelKey:a,items:n[s]})};return o("belongsTo","belongsToWork"),o("collected","collectedIn"),o("contains","containedWorks"),o("derivative","derivativeWorks"),o("studies","studies"),o("related","relatedWorks"),i}function lo(e,n){const i=qr(e||[]),o=new Map,s=[];for(const p of i)p.group?(o.has(p.group)||o.set(p.group,[]),o.get(p.group).push(p)):s.push(p);for(const p of o.values())p.sort((h,u)=>{const m=f=>f.group_role==="origin"?0:f.group_role==="mirror"?1:2;return m(h)-m(u)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const h=Mt(p),u=h.includes("text"),m=h.includes("image");u&&m?a.textImage.push(p):u?a.text.push(p):m?a.image.push(p):a.physical.push(p)}const d=["text","image","textImage","physical"].filter(p=>a[p].length>0).map(p=>({key:p,items:a[p]})),c=[...o.entries()].map(([p,h])=>{var u,m;return{key:p,label:((u=n==null?void 0:n[p])==null?void 0:u.label)||p,description:(m=n==null?void 0:n[p])==null?void 0:m.description,items:h}});return{buckets:d,mirrors:c,total:i.length}}function Ri(e,n=jn("zh-Hant")){const i=[],o=e.metadata||{};o.edition&&i.push(String(o.edition)),e.source_label&&i.push(e.source_label),e.details&&i.push(e.details);const s=wi(e);return s&&s.expected>0&&i.push(s.missing>0?n("detail.volumeStatsMissing",{found:s.found,expected:s.expected,missing:s.missing}):n("detail.volumeStats",{found:s.found,expected:s.expected})),o.version&&i.push(String(o.version)),i.join(" · ")}function Kl(e,n){if(Ri(e)||n.filter(o=>o.name===e.name).length<2)return"";try{const o=new URL(e.url),s=o.searchParams.get("res")||o.searchParams.get("id");if(s)return s;const a=o.pathname.split("/").filter(Boolean).pop();if(a)return decodeURIComponent(a)}catch{}return""}function Xl(e,n){var a,l;const i=e.resources||[],o=[],s=[];for(const d of i){const c=Mt(d);c.includes("image")&&o.push(d),c.includes("physical")&&s.push(d)}return{id:e.id,name:e.edition||e.title||e.id,era:Wn(e),year:Ii(e),sortYear:bi(e),images:o,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,important:mh(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:o.length>0}}function mh(e,n){var d,c;if(!n)return!1;const i=n.default_collection;if(!i)return!1;const o=(d=n.collections)==null?void 0:d[i];if(((o==null?void 0:o.book_ids)??(i==="core"?n.core_books??[]:[])).includes(e))return!0;const a=(o==null?void 0:o.groups)??[],l=(c=n.node_groups)==null?void 0:c[e];return!!l&&a.includes(l)}function Zl(e,n,i={}){const o=new Set((n==null?void 0:n.excluded_books)??[]),s=e.filter(c=>!o.has(c.id)).map(c=>Xl(c,n));let a=s;i.era&&(a=a.filter(c=>c.era.era===i.era)),i.scanOnly&&(a=a.filter(c=>c.hasImage)),i.sort==="year"?a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const h=c.r.sortYear,u=p.r.sortYear;return h!=null&&u!=null?h-u||c.i-p.i:h!=null?-1:u!=null?1:c.i-p.i}).map(c=>c.r):a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const h=u=>(u.important?0:1)*2+(u.hasImage?0:1);return h(c.r)-h(p.r)||c.i-p.i}).map(c=>c.r);const d=[...new Set(s.map(c=>c.era.era).filter(Boolean))].sort((c,p)=>Tr(c)-Tr(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function hh(e,n){var y,$;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const i=(y=n.collections)==null?void 0:y[n.default_collection],o=(i==null?void 0:i.groups)??[],s=(i==null?void 0:i.book_ids)??[],a=o.length>0||s.length>0,l=!a&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!a&&l.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const d=new Set(o),c=new Set([...s,...l]),p=b=>{if(c.has(b))return!0;const w=n.node_groups[b];return w!=null&&d.has(w)},h=[],u=new Map,m=[];for(const b of e)if(!(($=n.excluded_books)!=null&&$.includes(b)))if(p(b))h.push(b);else{const w=n.node_groups[b];w?(u.has(w)||u.set(w,[]),u.get(w).push(b)):m.push(b)}if(m.length+[...u.values()].reduce((b,w)=>b+w.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const x=new Map((n.groups??[]).map(b=>[b.id,b])),v=[...u.entries()].map(([b,w])=>{const j=x.get(b);return{id:b,label:(j==null?void 0:j.label)??b,description:j==null?void 0:j.description,ids:w}});return m.length>0&&v.push({id:"__other__",label:"其他版本",description:void 0,ids:m}),{useGrouping:!0,coreIds:h,groupedIds:v}}const Jl=["撰","編","注","校","譯","繪","其他"],gh=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function co(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n)return"撰";for(const{cls:i,re:o}of gh)if(o.test(n))return i;return"其他"}function po(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function Ql(e,n="全部"){const i=new Map;for(const s of e){const a=co(s);i.set(a,(i.get(a)??0)+1)}const o=[{cls:"全部",label:n,count:e.length}];for(const s of Jl){const a=i.get(s);a&&o.push({cls:s,label:s,count:a})}return o.length>2?o:[]}function uo(e){return(e._books??[]).map(n=>n.id).filter(n=>typeof n=="string")}function mo(e){const n=e._classifications??[],i=n.find(o=>o.scheme==="zongmu")??n[0];if(i)return{l1:i.l1??"",l2:i.l2??"",l3:i.l3??"",l4:i.l4??"",...i.source?{source:i.source}:{}}}function ec(e){const n=e._members??[],i=typeof e._member_count=="number"?e._member_count:n.length;return{works:n.filter(o=>o.t==="work").map(o=>({id:o.id,title:o.title??"",volumes:An(o.vol)})),bookIds:n.filter(o=>o.t!=="work").map(o=>o.id).filter(o=>typeof o=="string"),total:i,truncated:i>n.length}}function fh(e){var n;return(e==null?void 0:e._member_count)||((n=e==null?void 0:e._members)==null?void 0:n.length)||0}function tc(e,n,i){if(n&&n.books&&n.books.length>0){const l=n.books.map(c=>({id:c.work_id||c.book_id||void 0,title:c.title,section:c.section,volumes:c.volumes||[],subItems:c.sub_items,edition:c.edition,found:c.found_volumes,expected:c.expected_volumes})),d=[...new Set(l.map(c=>c.section).filter(Boolean))];return{rows:l,source:"catalog",sections:d,totalVolumes:n.total_volumes}}const{works:o,bookIds:s}=ec(e);return o.length>0?{rows:o.map(d=>({id:d.id,title:d.title,volumes:d.volumes})),source:"works",sections:[]}:{rows:s.map(l=>{var d,c;return{id:l,title:((d=i==null?void 0:i.get(l))==null?void 0:d.title)||l,edition:(c=i==null?void 0:i.get(l))==null?void 0:c.edition,volumes:[]}}),source:"books",sections:[]}}function An(e){if(e==null)return[];if(typeof e=="number")return[e];if(Array.isArray(e))return e.filter(n=>typeof n=="number");if(typeof e=="string"){const n=e.match(/^(\d+)\s*[-–~]\s*(\d+)$/);if(n){const[i,o]=[parseInt(n[1]),parseInt(n[2])];return Array.from({length:Math.max(0,o-i+1)},(s,a)=>i+a)}return e.split(/[,、]/).map(i=>parseInt(i.trim())).filter(i=>!isNaN(i))}return[]}function Ei(e,n="冊"){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const i=[...e].sort((a,l)=>a-l),o=i[0],s=i[i.length-1];return s-o+1===i.length?`${o}–${s}`:i.length<=3?i.join(", "):`${o}–${s} (${i.length}${n})`}const xh=["〇","一","二","三","四","五","六","七","八","九"],Js=["","十","百","千"];function nc(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),i=n.length;let o="",s=!1;for(let a=0;a<i;a++){const l=parseInt(n[a]),d=i-1-a;l===0?s=!0:(s&&o&&(o+="〇"),s=!1,l===1&&d===1&&a===0?o+=Js[d]:o+=xh[l]+Js[d])}return o}function bh(e){return e==null?"":typeof e=="string"?e:"name"in e&&e.name?e.name:"title"in e&&e.title||""}function yh(e){if(e==null||typeof e=="string")return;const n="url"in e&&e.url?e.url:"type"in e&&e.type==="url"?e.details:void 0;return n&&/^https?:\/\//i.test(n)?n:void 0}function Bt(e,n="卷"){var o,s;const i=e;return i.measure_info?i.measure_info:(o=i.juan_count)!=null&&o.number?nc(i.juan_count.number)+n:(s=i.juan_count)!=null&&s.description?i.juan_count.description:""}function ic(e){var o;if(e.edition_type)return e.edition_type;if((o=e.lineage)!=null&&o.category)return e.lineage.category;const n=e.edition||e.title||"",i=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,a]of i)if(s.test(n))return a;return""}const jh=65536,vh="guji_markdown";function kh(e){const n=e==null?void 0:e.guji_markdown;if(typeof n!="string")return!1;const i=/^(\d+)\.(\d+)(?:\.\d+)?$/.exec(n.trim());if(!i)return!1;const o=parseInt(i[1],10),s=parseInt(i[2],10);return o>0||s>=2}const wh=/^□\{guess=([^\s{}]+)\}/;function Sh(e,n){const i=e[n+1];return i!==void 0&&!/[A-Za-z/!?>\s]/.test(i)}function rc(e,n){let i=0;for(let o=n;o<e.length;o++){const s=e[o];if(s===`
678
678
  `)return-1;if(s==="\\"){o++;continue}if(s==="[")i++;else if(s==="]"&&(i--,i===0))return o}return-1}function _h(e){return e.replace(/\\([\\[\]<>|{}])/g,"$1")}function $h(e,n){const i=e[n];if(i==="["&&e[n+1]==="["){const o=e.indexOf("]]",n+2);return o>=0&&e.slice(n+2,o).indexOf(`
679
679
  `)<0?{node:{type:"qw",label:e.slice(n+2,o)},end:o+2}:null}if(i===":"&&e.startsWith(":zi[",n)){const o=rc(e,n+3);return o>n+4?{node:{type:"zi",label:_h(e.slice(n+4,o))},end:o+1}:null}if(i==="□"&&e[n+1]==="{"){const o=wh.exec(e.slice(n,n+64));if(o)return{node:{type:"qz",guess:o[1]},end:n+o[0].length}}return null}function oc(e,n,i,o,s){const a=[];let l="",d=!1;const c=()=>{if(!l)return;let p=l;o&&(p=l.replace(/\\?\|/g,h=>d?"|":(d=!0,""))),p&&a.push({type:"text",text:p}),l=""};for(;n<e.length;){const p=e[n];if(p==="\\"&&(e[n+1]==="<"||e[n+1]===">")){l+=e[n+1],n+=2;continue}if(i!==null){if(p===i)return c(),{nodes:a,end:n};if(p===`
680
- `)return null}const h=$h(e,n);if(h){c(),a.push(h.node),n=h.end;continue}let u=null;if(p==="⟨"?u="⟩":p==="<"&&Sh(e,n)&&(u=">"),u){const m=oc(e,n+1,u,!0,s);if(m&&!(p==="<"&&m.end-(n+1)>s)){c(),a.push({type:"jz",children:m.nodes}),n=m.end+1;continue}}l+=p,n++}return i!==null?null:(c(),{nodes:a,end:n})}function sc(e,n){return oc(e,0,null,!1,(n==null?void 0:n.jzMaxLength)??jh).nodes}function Ch(e){return/[<⟨□]|\[\[|:zi\[/.test(e)}function ac(e){return e.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${ac(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const Th=216,Qs="clamp(280px, 23vw, 360px)",zh=1440,zr="(max-width: 719px)",Nh=`${zr}, (pointer: coarse)`,Ih=`
680
+ `)return null}const h=$h(e,n);if(h){c(),a.push(h.node),n=h.end;continue}let u=null;if(p==="<"&&Sh(e,n)&&(u=">"),u){const m=oc(e,n+1,u,!0,s);if(m&&!(m.end-(n+1)>s)){c(),a.push({type:"jz",children:m.nodes}),n=m.end+1;continue}}l+=p,n++}return i!==null?null:(c(),{nodes:a,end:n})}function sc(e,n){return oc(e,0,null,!1,(n==null?void 0:n.jzMaxLength)??jh).nodes}function Ch(e){return/[<□]|\[\[|:zi\[/.test(e)}function ac(e){return e.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${ac(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const Th=216,Qs="clamp(280px, 23vw, 360px)",zh=1440,zr="(max-width: 719px)",Nh=`${zr}, (pointer: coarse)`,Ih=`
681
681
  .bim-d-main.bim-d-main-grid { max-width: ${zh}px; padding: 16px 32px 0; }
682
682
  .bim-d-grid {
683
683
  display: grid;
@@ -1256,13 +1256,13 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1256
1256
  padding-right: 0; padding-bottom: 12px;
1257
1257
  }
1258
1258
  }
1259
- ${Ih}`;function Rn({children:e,style:n,wide:i,grid:o}){return t.jsxs("div",{className:"bim-d-page",style:n,children:[t.jsx("style",{children:pc}),t.jsx("div",{className:o?"bim-d-main bim-d-main-grid":i?"bim-d-main bim-d-main-wide":"bim-d-main",children:e})]})}function Ir({breadcrumb:e,actions:n}){return t.jsxs("div",{className:"bim-d-ui bim-d-top",style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:"8px 16px",marginBottom:24,fontSize:12,color:r("aux-fg")},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:e}),n&&t.jsx("div",{style:{display:"flex",alignItems:"center",gap:16},children:n})]})}function xo({char:e,tone:n="accent"}){return t.jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,flex:"none",fontSize:11,fontFamily:"var(--bim-font-ui, system-ui, sans-serif)",background:r(n==="accent"?"accent":"ink"),color:r("page-bg")},children:e})}function Rr({items:e}){const n=tt();return t.jsx(t.Fragment,{children:e.map((i,o)=>{const s=o===e.length-1,a=o>0&&t.jsx("span",{style:{color:r("hint-fg")},children:"/"},`s${o}`),l=i.id?n(i.id):i.href,d=s||!i.onClick&&!l?t.jsx("span",{style:{color:r("ink")},children:i.label},o):t.jsx("a",{href:l??"#",onClick:i.onClick?c=>{c.metaKey||c.ctrlKey||(c.preventDefault(),i.onClick())}:void 0,style:{color:r("meta-fg")},children:i.label},o);return t.jsxs(g.Fragment,{children:[a,d]},o)})})}function uc({title:e,subtitle:n,aside:i,secondLine:o}){return t.jsxs("header",{style:{borderBottom:`2px solid ${r("rule-strong")}`,paddingBottom:18},children:[t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"flex-end",justifyContent:"space-between",gap:"10px 24px"},children:[t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"6px 14px",minWidth:0},children:[t.jsx("h1",{className:"bim-d-h1",style:{margin:0,fontSize:42,fontWeight:700,letterSpacing:".06em",lineHeight:1.1,wordBreak:"break-word"},children:e}),n&&t.jsx("span",{style:{fontSize:15,color:r("meta-fg"),letterSpacing:".06em"},children:n})]}),i&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg"),letterSpacing:".06em"},children:i})]}),o&&t.jsx("div",{style:{marginTop:12,fontSize:13.5,color:r("quiet-fg")},children:o})]})}function Ah({children:e,facts:n}){return!e&&n?t.jsx("div",{style:{padding:"20px 0 26px",borderBottom:`1px solid ${r("rule")}`,marginBottom:40},children:n}):t.jsxs("div",{className:"bim-d-intro",children:[t.jsx("div",{style:{minWidth:0},children:e}),n]})}function Mh({items:e,horizontal:n}){const{convert:i}=Pe();return e.length?t.jsx("div",{style:{borderLeft:`2px solid ${r("accent")}`,paddingLeft:16,display:n?"grid":"flex",gridTemplateColumns:n?"repeat(auto-fit, minmax(150px, max-content))":void 0,flexDirection:n?void 0:"column",gap:n?"14px 40px":10,fontSize:13},children:e.map((o,s)=>t.jsxs("div",{title:o.title,style:n?{display:"flex",flexDirection:"column",gap:3}:{display:"flex",justifyContent:"space-between",gap:10},children:[t.jsx("span",{className:"bim-d-ui",style:{color:r("label-fg"),letterSpacing:".08em",flex:"none"},children:i(o.label)}),t.jsx("span",{style:{color:r("body-fg"),textAlign:n?"left":"right",minWidth:0},children:o.value})]},s))}):null}function Ph({glyph:e,tone:n,title:i,count:o,actions:s,id:a}){const{convert:l}=Pe();return t.jsxs("div",{id:a,style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",justifyContent:"space-between",gap:"10px 16px",marginBottom:14,scrollMarginTop:16},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx(xo,{char:e,tone:n}),t.jsx("h2",{style:{margin:0,fontSize:19,fontWeight:600,letterSpacing:".1em"},children:l(i)}),o!=null&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg")},children:o})]}),s&&t.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:14,fontSize:12},children:s})]})}function mc({label:e,active:n,onClick:i,dashed:o}){const{convert:s}=Pe();return t.jsx("button",{type:"button",onClick:i,"aria-pressed":n,className:"bim-d-ui",style:{padding:"5px 13px",border:`1px ${o&&!n?"dashed":"solid"} ${r(n?"accent":"rule")}`,background:n?r("accent"):"transparent",color:r(n?"page-bg":"meta-fg"),fontSize:12,cursor:"pointer",letterSpacing:".04em",lineHeight:1.4},children:s(e)})}function Bh({label:e,onClick:n}){const{convert:i}=Pe();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg"),borderBottom:`1px solid ${r("rule")}`},children:i(e)})}function Oh({label:e,onClick:n,inline:i}){const{convert:o}=Pe();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{marginTop:i?0:12,width:i?void 0:"100%",padding:i?"4px 12px":9,background:"none",border:`1px dashed ${r("rule-dashed")}`,cursor:"pointer",fontSize:12,color:r("meta-fg"),letterSpacing:i?void 0:".08em"},children:o(e)})}function hc({children:e,href:n,onClick:i,title:o}){const s={display:"inline-block",padding:"4px 10px",border:`1px solid ${r("rule")}`,fontSize:13,color:r("body-fg"),lineHeight:1.5};return n||i?t.jsx("a",{href:n??"#",title:o,onClick:i?a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i())}:void 0,style:s,children:e}):t.jsx("span",{title:o,style:s,children:e})}function Wh({children:e}){return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e})}function Fh({volumes:e,unit:n,max:i=60}){const{t:o}=te(),s=n??o("unit.volume"),[a,l]=g.useState(!1);if(!e.length)return null;const d=a?e:e.slice(0,i);return t.jsxs("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,fontSize:11.5},children:[d.map(c=>t.jsx("span",{style:{minWidth:30,textAlign:"center",padding:"2px 5px",border:`1px solid ${r("rule")}`,color:r("meta-fg")},children:c},c)),!a&&e.length>i&&t.jsxs("button",{type:"button",onClick:()=>l(!0),style:{padding:"2px 8px",background:"none",cursor:"pointer",border:`1px dashed ${r("rule-dashed")}`,fontFamily:"inherit",fontSize:11.5,color:r("meta-fg")},children:["+",e.length-i]}),t.jsx("span",{style:{padding:"2px 6px",color:r("hint-fg")},children:s})]})}function Hh({children:e}){return t.jsx("div",{style:{borderTop:`1px solid ${r("rule-strong")}`},children:e})}function Dh({spec:e}){const{convert:n}=Pe();return t.jsxs("div",{className:"bim-d-thead bim-d-ui",style:{display:"grid",gridTemplateColumns:`${e.leadWidth}px 1fr ${e.metaWidth}px`,gap:12,padding:"7px 4px",borderBottom:`1px solid ${r("rule-strong")}`,fontSize:11,color:r("label-fg"),letterSpacing:".1em"},children:[t.jsx("span",{}),t.jsx("span",{children:n(e.mainLabel)}),t.jsx("span",{style:{display:"grid",gridTemplateColumns:e.columns.map(i=>i.width).join(" "),gap:12},children:e.columns.map(i=>t.jsx("span",{children:n(i.label)},i.label))})]})}function Uh({no:e,main:n,meta:i,spec:o}){return t.jsxs("div",{className:"bim-d-row",style:{gridTemplateColumns:`${o.leadWidth}px 1fr ${o.metaWidth}px`,gap:12},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:r("hint-fg"),textAlign:"right"},children:e}),t.jsx("span",{style:{minWidth:0},children:n}),t.jsx("span",{className:"bim-d-row-meta",style:{display:"grid",gridTemplateColumns:o.columns.map(s=>s.width).join(" "),gap:12,alignItems:"center",fontSize:12},children:i})]})}function Vh(e){return String(e+1).padStart(2,"0")}function Gh(){return t.jsx("span",{style:{color:r("hint-fg")},children:"—"})}function Yh({open:e,onToggle:n,main:i,action:o,children:s}){return t.jsxs("div",{style:{borderBottom:`1px solid ${r("rule")}`},children:[t.jsxs("div",{className:"bim-d-expand-head",style:{display:"grid",gridTemplateColumns:"26px 1fr auto",gap:12,alignItems:"baseline",padding:"9px 4px"},children:[t.jsx("button",{type:"button",onClick:n,"aria-expanded":e,className:"bim-d-ui",style:{width:18,height:18,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,cursor:"pointer",fontSize:12,lineHeight:1,border:`1px solid ${r(e?"accent":"rule-dashed")}`,background:e?r("accent"):"transparent",color:r(e?"page-bg":"accent")},children:e?"-":"+"}),t.jsx("span",{style:{fontSize:14,minWidth:0},children:i}),o]}),e&&s&&t.jsx("div",{style:{padding:"2px 4px 14px 38px",borderLeft:`2px solid ${r("rule-accent-soft")}`,marginLeft:12},children:s})]})}function gc(e){const n=[];for(let i=0;i<e.length;i++){const o=e[i];let s;if(o==="⟨")s="⟩";else if(o==="<"){const d=e[i+1];if(d===void 0||/[A-Za-z/!?>\s]/.test(d))continue;s=">"}else continue;const a=e.indexOf(s,i+1);if(a<0)continue;const l=e.slice(i+1,a);l.includes(`
1260
- `)||(n.push({start:i,end:a+1,inner:l}),i=a)}return n}function fc(e,n){if(e.length<=n)return e;let i=n;for(const o of gc(e)){if(o.start>=i)break;if(o.end>i){i=o.start>0?o.start:o.end;break}}return e.slice(0,i)}const xc={fontSize:".78em",color:r("meta-fg"),lineHeight:1.55},qh={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 bc(e,n,i,o){return e.map((s,a)=>{switch(s.type){case"text":return t.jsx(g.Fragment,{children:n(s.text)},a);case"jz":return t.jsx("span",{className:"bim-jiazhu",style:i===0?xc:void 0,children:bc(s.children,n,i+1,o)},a);case"qw":return t.jsx("span",{className:"bim-qw guji-qw",title:s.label?o("detail.lacunaWith",{label:s.label}):o("detail.lacuna"),children:"□"},a);case"qz":return t.jsx("span",{className:"bim-qz guji-qz","data-guji-guess":s.guess,children:"□"},a);case"zi":return t.jsx("span",{className:"bim-zi guji-zi",title:o("detail.composedChar",{label:s.label}),style:qh,children:s.label},a)}})}function gt(e,n=o=>o,i){if(!e)return"";if(i!=null&&i.gujiMarkdown)return Ch(e)?bc(sc(e,{jzMaxLength:i.jzMaxLength}),n,0,i.t??jn("zh-Hant")):n(e);if(e.indexOf("⟨")<0&&e.indexOf("<")<0)return n(e);const o=[];let s=0,a=0;for(const l of gc(e))l.start>s&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s,l.start))},a++)),o.push(t.jsx("span",{className:"bim-jiazhu",style:xc,children:n(l.inner)},a++)),s=l.end;return s<e.length&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s))},a++)),o}function Kh({label:e,children:n}){return t.jsxs("div",{style:{marginBottom:10},children:[e&&t.jsx("div",{className:"bim-d-ui",style:{fontSize:11,fontWeight:600,letterSpacing:".1em",color:r("label-fg"),marginBottom:4},children:e}),t.jsx("div",{style:{fontSize:13.5,lineHeight:2,color:r("quiet-fg"),textAlign:"justify"},children:n})]})}function Xh({title:e,tag:n,children:i}){const{convert:o}=Pe();return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,paddingBottom:7,borderBottom:`1px solid ${r("rule-strong")}`,marginBottom:2},children:[t.jsx("span",{style:{fontSize:14.5,letterSpacing:".08em"},children:o(e)}),n&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:r("accent"),letterSpacing:".06em"},children:o(n)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column"},children:i})]})}function yc({name:e,note:n,href:i,extra:o}){const s=t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{fontSize:14,minWidth:0},children:e}),t.jsx("span",{className:"bim-d-ui",style:{fontSize:11,color:r("hint-fg"),flex:"none"},children:i?"↗":""}),n&&t.jsx("span",{className:"bim-d-ui",style:{gridColumn:"1 / -1",fontSize:11.5,color:r("label-fg")},children:n})]}),a={display:"grid",gridTemplateColumns:"1fr auto",gap:"4px 12px",padding:"9px 4px",borderBottom:`1px solid ${r("rule")}`,color:r("body-fg"),alignItems:"baseline"};return t.jsxs(t.Fragment,{children:[i?t.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",style:a,children:s}):t.jsx("div",{style:a,children:s}),o]})}function Zh({item:e,siblings:n,showVolumes:i=!0,fallbackNote:o}){const{t:s,convert:a}=te(),[l,d]=g.useState(!1),c=wi(e),p=i&&!!c&&c.expected>0,h=(e.url?xn(e.url):void 0)||a(e.name),u=n?Kl(e,n):"",m=u?`${h}(${u})`:h;return t.jsx(yc,{name:m,note:Ri(e,s)||o,href:bn(e),extra:p?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>d(f=>!f),className:"bim-d-ui",style:{alignSelf:"flex-start",padding:"2px 0",marginTop:4,background:"none",border:"none",cursor:"pointer",fontSize:11,color:r("meta-fg"),borderBottom:`1px solid ${r("rule")}`},children:l?s("detail.collapseVolumes"):s("detail.expandVolumes",{n:c.expected})}),l&&t.jsx(bo,{item:e})]}):void 0})}function bo({item:e}){return t.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,padding:"6px 0 10px",fontSize:11},children:(e.volumes||[]).map((n,i)=>{const o=n.status==="missing";return n.url&&!o?t.jsx("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{padding:"4px 8px",borderRadius:4,background:r("zebra-bg")},children:n.volume},i):t.jsx("span",{style:{padding:"1px 5px",color:r(o?"missing-fg":"hint-fg"),textDecoration:o?"line-through":void 0},children:n.volume},i)})})}function jc({label:e,items:n}){const{convert:i}=Pe();return n.length?t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg"),letterSpacing:".08em"},children:e}),n.map((o,s)=>t.jsx(hc,{children:i(o)},s))]}):null}function Jh({rows:e}){const n=e.filter(i=>i.items.length>0);return n.length?t.jsx("div",{style:{marginTop:16,display:"flex",flexDirection:"column",gap:8},children:n.map(i=>t.jsx(jc,{label:i.label,items:i.items},i.label))}):null}function Er(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function vc({left:e,right:n}){return t.jsxs("footer",{className:"bim-d-ui",style:{marginTop:52,paddingTop:14,borderTop:`1px solid ${r("rule")}`,display:"flex",flexWrap:"wrap",justifyContent:"space-between",gap:"8px 16px",fontSize:11.5,color:r("aux-fg")},children:[t.jsx("span",{children:e}),n&&t.jsx("span",{style:{display:"flex",gap:16},children:n})]})}function Qh({children:e,action:n}){return t.jsxs("div",{className:"bim-d-ui",style:{padding:"18px 4px",fontSize:12.5,color:r("aux-fg"),borderBottom:`1px solid ${r("rule")}`,display:"flex",flexWrap:"wrap",alignItems:"center",gap:12},children:[t.jsx("span",{children:e}),n]})}function et({id:e,label:n,onNavigate:i,renderLink:o,style:s,dense:a}){const l=tt();return o?t.jsx(t.Fragment,{children:o(e,typeof n=="string"?n:void 0,{dense:a})}):t.jsx("a",{href:l(e),onClick:i?d=>{d.metaKey||d.ctrlKey||(d.preventDefault(),i(e))}:void 0,style:s,children:n??e})}function eg({href:e,children:n}){return t.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[n," ",t.jsx("span",{className:"bim-d-ui",style:{fontSize:11},children:"↗"})]})}const kc="guji-table-v1";function tg(e){return!!e&&e.table_notation===kc}const ng=/^:::table(?:\{[^}]*\})?[ \t]*$/,ig=/^:::[ \t]*$/;function wc(e){const n=[];let i="";for(let o=0;o<e.length;o++){const s=e[o];if(s===":"&&e.startsWith(":zi[",o)){const l=rc(e,o+3);if(l>o+4){i+=e.slice(o,l+1),o=l;continue}}let a=null;if(s==="⟨")a="⟩";else if(s==="<"){const l=e[o+1];l!==void 0&&!/[A-Za-z/!?>\s]/.test(l)&&(a=">")}if(a){const l=e.indexOf(a,o+1);if(l>0){i+=e.slice(o,l+1),o=l;continue}}s==="|"?(n.push(i),i=""):i+=s}return n.push(i),n.map(o=>o.trim())}const rg=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function og(e){if(e==="^")return{cont:!0};const n=rg.exec(e),i=n[1].trim(),o=n[2]?Math.max(1,parseInt(n[2],10)):1,s=n[3]?Math.max(1,parseInt(n[3],10)):1,a=i==="_";return{cont:!1,cell:{text:a?"":i,empty:a,colspan:o,rowspan:s}}}function Sc(e,n=1){const i=[],o=[],s=[];let a=[];e.forEach((d,c)=>{const p=c+n+1;let h=d.trim();if(!h)return;let u=!1;h.startsWith("!")&&(u=!0,h=h.slice(1));const m=wc(h).map(og),f=a.map($=>$>0),x=a.map($=>$>0?$-1:0),v=[];let y=0;for(const $ of m){if($.cont){f[y]||i.push(`第 ${p} 行第 ${y+1} 列:续格 ^ 上方没有跨行格`),y+=1;continue}const{cell:b}=$;for(let w=y;w<y+b.colspan;w++)if(f[w]){i.push(`第 ${p} 行第 ${w+1} 列:此处被上方跨行格占住,应写 ^`);break}if(b.rowspan>1)for(let w=y;w<y+b.colspan;w++)x[w]=b.rowspan-1;v.push(b),y+=b.colspan}for(let $=y;$<f.length;$++)f[$]&&i.push(`第 ${p} 行第 ${$+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let $=0;$<x.length;$++)x[$]===void 0&&(x[$]=0);a=x,o.push({header:u,cells:v}),s.push({width:y,line:p})});const l=s.reduce((d,c)=>Math.max(d,c.width),0);for(const d of s)d.width!==l&&i.push(`第 ${d.line} 行:占 ${d.width} 列,与总列数 ${l} 不符`);return a.some(d=>d>0)&&i.push("表尾:有跨行格超出了表的最后一行"),o.length===0&&i.push("空表"),{rows:o,columns:l,warnings:i}}function yo(e){const n=e.split(`
1259
+ ${Ih}`;function Rn({children:e,style:n,wide:i,grid:o}){return t.jsxs("div",{className:"bim-d-page",style:n,children:[t.jsx("style",{children:pc}),t.jsx("div",{className:o?"bim-d-main bim-d-main-grid":i?"bim-d-main bim-d-main-wide":"bim-d-main",children:e})]})}function Ir({breadcrumb:e,actions:n}){return t.jsxs("div",{className:"bim-d-ui bim-d-top",style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:"8px 16px",marginBottom:24,fontSize:12,color:r("aux-fg")},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:e}),n&&t.jsx("div",{style:{display:"flex",alignItems:"center",gap:16},children:n})]})}function xo({char:e,tone:n="accent"}){return t.jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,flex:"none",fontSize:11,fontFamily:"var(--bim-font-ui, system-ui, sans-serif)",background:r(n==="accent"?"accent":"ink"),color:r("page-bg")},children:e})}function Rr({items:e}){const n=tt();return t.jsx(t.Fragment,{children:e.map((i,o)=>{const s=o===e.length-1,a=o>0&&t.jsx("span",{style:{color:r("hint-fg")},children:"/"},`s${o}`),l=i.id?n(i.id):i.href,d=s||!i.onClick&&!l?t.jsx("span",{style:{color:r("ink")},children:i.label},o):t.jsx("a",{href:l??"#",onClick:i.onClick?c=>{c.metaKey||c.ctrlKey||(c.preventDefault(),i.onClick())}:void 0,style:{color:r("meta-fg")},children:i.label},o);return t.jsxs(g.Fragment,{children:[a,d]},o)})})}function uc({title:e,subtitle:n,aside:i,secondLine:o}){return t.jsxs("header",{style:{borderBottom:`2px solid ${r("rule-strong")}`,paddingBottom:18},children:[t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"flex-end",justifyContent:"space-between",gap:"10px 24px"},children:[t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"6px 14px",minWidth:0},children:[t.jsx("h1",{className:"bim-d-h1",style:{margin:0,fontSize:42,fontWeight:700,letterSpacing:".06em",lineHeight:1.1,wordBreak:"break-word"},children:e}),n&&t.jsx("span",{style:{fontSize:15,color:r("meta-fg"),letterSpacing:".06em"},children:n})]}),i&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg"),letterSpacing:".06em"},children:i})]}),o&&t.jsx("div",{style:{marginTop:12,fontSize:13.5,color:r("quiet-fg")},children:o})]})}function Ah({children:e,facts:n}){return!e&&n?t.jsx("div",{style:{padding:"20px 0 26px",borderBottom:`1px solid ${r("rule")}`,marginBottom:40},children:n}):t.jsxs("div",{className:"bim-d-intro",children:[t.jsx("div",{style:{minWidth:0},children:e}),n]})}function Mh({items:e,horizontal:n}){const{convert:i}=Pe();return e.length?t.jsx("div",{style:{borderLeft:`2px solid ${r("accent")}`,paddingLeft:16,display:n?"grid":"flex",gridTemplateColumns:n?"repeat(auto-fit, minmax(150px, max-content))":void 0,flexDirection:n?void 0:"column",gap:n?"14px 40px":10,fontSize:13},children:e.map((o,s)=>t.jsxs("div",{title:o.title,style:n?{display:"flex",flexDirection:"column",gap:3}:{display:"flex",justifyContent:"space-between",gap:10},children:[t.jsx("span",{className:"bim-d-ui",style:{color:r("label-fg"),letterSpacing:".08em",flex:"none"},children:i(o.label)}),t.jsx("span",{style:{color:r("body-fg"),textAlign:n?"left":"right",minWidth:0},children:o.value})]},s))}):null}function Ph({glyph:e,tone:n,title:i,count:o,actions:s,id:a}){const{convert:l}=Pe();return t.jsxs("div",{id:a,style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",justifyContent:"space-between",gap:"10px 16px",marginBottom:14,scrollMarginTop:16},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx(xo,{char:e,tone:n}),t.jsx("h2",{style:{margin:0,fontSize:19,fontWeight:600,letterSpacing:".1em"},children:l(i)}),o!=null&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg")},children:o})]}),s&&t.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:14,fontSize:12},children:s})]})}function mc({label:e,active:n,onClick:i,dashed:o}){const{convert:s}=Pe();return t.jsx("button",{type:"button",onClick:i,"aria-pressed":n,className:"bim-d-ui",style:{padding:"5px 13px",border:`1px ${o&&!n?"dashed":"solid"} ${r(n?"accent":"rule")}`,background:n?r("accent"):"transparent",color:r(n?"page-bg":"meta-fg"),fontSize:12,cursor:"pointer",letterSpacing:".04em",lineHeight:1.4},children:s(e)})}function Bh({label:e,onClick:n}){const{convert:i}=Pe();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg"),borderBottom:`1px solid ${r("rule")}`},children:i(e)})}function Oh({label:e,onClick:n,inline:i}){const{convert:o}=Pe();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{marginTop:i?0:12,width:i?void 0:"100%",padding:i?"4px 12px":9,background:"none",border:`1px dashed ${r("rule-dashed")}`,cursor:"pointer",fontSize:12,color:r("meta-fg"),letterSpacing:i?void 0:".08em"},children:o(e)})}function hc({children:e,href:n,onClick:i,title:o}){const s={display:"inline-block",padding:"4px 10px",border:`1px solid ${r("rule")}`,fontSize:13,color:r("body-fg"),lineHeight:1.5};return n||i?t.jsx("a",{href:n??"#",title:o,onClick:i?a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i())}:void 0,style:s,children:e}):t.jsx("span",{title:o,style:s,children:e})}function Wh({children:e}){return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e})}function Fh({volumes:e,unit:n,max:i=60}){const{t:o}=te(),s=n??o("unit.volume"),[a,l]=g.useState(!1);if(!e.length)return null;const d=a?e:e.slice(0,i);return t.jsxs("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,fontSize:11.5},children:[d.map(c=>t.jsx("span",{style:{minWidth:30,textAlign:"center",padding:"2px 5px",border:`1px solid ${r("rule")}`,color:r("meta-fg")},children:c},c)),!a&&e.length>i&&t.jsxs("button",{type:"button",onClick:()=>l(!0),style:{padding:"2px 8px",background:"none",cursor:"pointer",border:`1px dashed ${r("rule-dashed")}`,fontFamily:"inherit",fontSize:11.5,color:r("meta-fg")},children:["+",e.length-i]}),t.jsx("span",{style:{padding:"2px 6px",color:r("hint-fg")},children:s})]})}function Hh({children:e}){return t.jsx("div",{style:{borderTop:`1px solid ${r("rule-strong")}`},children:e})}function Dh({spec:e}){const{convert:n}=Pe();return t.jsxs("div",{className:"bim-d-thead bim-d-ui",style:{display:"grid",gridTemplateColumns:`${e.leadWidth}px 1fr ${e.metaWidth}px`,gap:12,padding:"7px 4px",borderBottom:`1px solid ${r("rule-strong")}`,fontSize:11,color:r("label-fg"),letterSpacing:".1em"},children:[t.jsx("span",{}),t.jsx("span",{children:n(e.mainLabel)}),t.jsx("span",{style:{display:"grid",gridTemplateColumns:e.columns.map(i=>i.width).join(" "),gap:12},children:e.columns.map(i=>t.jsx("span",{children:n(i.label)},i.label))})]})}function Uh({no:e,main:n,meta:i,spec:o}){return t.jsxs("div",{className:"bim-d-row",style:{gridTemplateColumns:`${o.leadWidth}px 1fr ${o.metaWidth}px`,gap:12},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:r("hint-fg"),textAlign:"right"},children:e}),t.jsx("span",{style:{minWidth:0},children:n}),t.jsx("span",{className:"bim-d-row-meta",style:{display:"grid",gridTemplateColumns:o.columns.map(s=>s.width).join(" "),gap:12,alignItems:"center",fontSize:12},children:i})]})}function Vh(e){return String(e+1).padStart(2,"0")}function Gh(){return t.jsx("span",{style:{color:r("hint-fg")},children:"—"})}function Yh({open:e,onToggle:n,main:i,action:o,children:s}){return t.jsxs("div",{style:{borderBottom:`1px solid ${r("rule")}`},children:[t.jsxs("div",{className:"bim-d-expand-head",style:{display:"grid",gridTemplateColumns:"26px 1fr auto",gap:12,alignItems:"baseline",padding:"9px 4px"},children:[t.jsx("button",{type:"button",onClick:n,"aria-expanded":e,className:"bim-d-ui",style:{width:18,height:18,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,cursor:"pointer",fontSize:12,lineHeight:1,border:`1px solid ${r(e?"accent":"rule-dashed")}`,background:e?r("accent"):"transparent",color:r(e?"page-bg":"accent")},children:e?"-":"+"}),t.jsx("span",{style:{fontSize:14,minWidth:0},children:i}),o]}),e&&s&&t.jsx("div",{style:{padding:"2px 4px 14px 38px",borderLeft:`2px solid ${r("rule-accent-soft")}`,marginLeft:12},children:s})]})}function gc(e){const n=[];for(let i=0;i<e.length;i++){if(e[i]!=="<")continue;const s=e[i+1];if(s===void 0||/[A-Za-z/!?>\s]/.test(s))continue;const l=e.indexOf(">",i+1);if(l<0)continue;const d=e.slice(i+1,l);d.includes(`
1260
+ `)||(n.push({start:i,end:l+1,inner:d}),i=l)}return n}function fc(e,n){if(e.length<=n)return e;let i=n;for(const o of gc(e)){if(o.start>=i)break;if(o.end>i){i=o.start>0?o.start:o.end;break}}return e.slice(0,i)}const xc={fontSize:".78em",color:r("meta-fg"),lineHeight:1.55},qh={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 bc(e,n,i,o){return e.map((s,a)=>{switch(s.type){case"text":return t.jsx(g.Fragment,{children:n(s.text)},a);case"jz":return t.jsx("span",{className:"bim-jiazhu",style:i===0?xc:void 0,children:bc(s.children,n,i+1,o)},a);case"qw":return t.jsx("span",{className:"bim-qw guji-qw",title:s.label?o("detail.lacunaWith",{label:s.label}):o("detail.lacuna"),children:"□"},a);case"qz":return t.jsx("span",{className:"bim-qz guji-qz","data-guji-guess":s.guess,children:"□"},a);case"zi":return t.jsx("span",{className:"bim-zi guji-zi",title:o("detail.composedChar",{label:s.label}),style:qh,children:s.label},a)}})}function gt(e,n=o=>o,i){if(!e)return"";if(i!=null&&i.gujiMarkdown)return Ch(e)?bc(sc(e,{jzMaxLength:i.jzMaxLength}),n,0,i.t??jn("zh-Hant")):n(e);if(e.indexOf("<")<0)return n(e);const o=[];let s=0,a=0;for(const l of gc(e))l.start>s&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s,l.start))},a++)),o.push(t.jsx("span",{className:"bim-jiazhu",style:xc,children:n(l.inner)},a++)),s=l.end;return s<e.length&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s))},a++)),o}function Kh({label:e,children:n}){return t.jsxs("div",{style:{marginBottom:10},children:[e&&t.jsx("div",{className:"bim-d-ui",style:{fontSize:11,fontWeight:600,letterSpacing:".1em",color:r("label-fg"),marginBottom:4},children:e}),t.jsx("div",{style:{fontSize:13.5,lineHeight:2,color:r("quiet-fg"),textAlign:"justify"},children:n})]})}function Xh({title:e,tag:n,children:i}){const{convert:o}=Pe();return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,paddingBottom:7,borderBottom:`1px solid ${r("rule-strong")}`,marginBottom:2},children:[t.jsx("span",{style:{fontSize:14.5,letterSpacing:".08em"},children:o(e)}),n&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:r("accent"),letterSpacing:".06em"},children:o(n)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column"},children:i})]})}function yc({name:e,note:n,href:i,extra:o}){const s=t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{fontSize:14,minWidth:0},children:e}),t.jsx("span",{className:"bim-d-ui",style:{fontSize:11,color:r("hint-fg"),flex:"none"},children:i?"↗":""}),n&&t.jsx("span",{className:"bim-d-ui",style:{gridColumn:"1 / -1",fontSize:11.5,color:r("label-fg")},children:n})]}),a={display:"grid",gridTemplateColumns:"1fr auto",gap:"4px 12px",padding:"9px 4px",borderBottom:`1px solid ${r("rule")}`,color:r("body-fg"),alignItems:"baseline"};return t.jsxs(t.Fragment,{children:[i?t.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",style:a,children:s}):t.jsx("div",{style:a,children:s}),o]})}function Zh({item:e,siblings:n,showVolumes:i=!0,fallbackNote:o}){const{t:s,convert:a}=te(),[l,d]=g.useState(!1),c=wi(e),p=i&&!!c&&c.expected>0,h=(e.url?xn(e.url):void 0)||a(e.name),u=n?Kl(e,n):"",m=u?`${h}(${u})`:h;return t.jsx(yc,{name:m,note:Ri(e,s)||o,href:bn(e),extra:p?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>d(f=>!f),className:"bim-d-ui",style:{alignSelf:"flex-start",padding:"2px 0",marginTop:4,background:"none",border:"none",cursor:"pointer",fontSize:11,color:r("meta-fg"),borderBottom:`1px solid ${r("rule")}`},children:l?s("detail.collapseVolumes"):s("detail.expandVolumes",{n:c.expected})}),l&&t.jsx(bo,{item:e})]}):void 0})}function bo({item:e}){return t.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,padding:"6px 0 10px",fontSize:11},children:(e.volumes||[]).map((n,i)=>{const o=n.status==="missing";return n.url&&!o?t.jsx("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{padding:"4px 8px",borderRadius:4,background:r("zebra-bg")},children:n.volume},i):t.jsx("span",{style:{padding:"1px 5px",color:r(o?"missing-fg":"hint-fg"),textDecoration:o?"line-through":void 0},children:n.volume},i)})})}function jc({label:e,items:n}){const{convert:i}=Pe();return n.length?t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg"),letterSpacing:".08em"},children:e}),n.map((o,s)=>t.jsx(hc,{children:i(o)},s))]}):null}function Jh({rows:e}){const n=e.filter(i=>i.items.length>0);return n.length?t.jsx("div",{style:{marginTop:16,display:"flex",flexDirection:"column",gap:8},children:n.map(i=>t.jsx(jc,{label:i.label,items:i.items},i.label))}):null}function Er(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function vc({left:e,right:n}){return t.jsxs("footer",{className:"bim-d-ui",style:{marginTop:52,paddingTop:14,borderTop:`1px solid ${r("rule")}`,display:"flex",flexWrap:"wrap",justifyContent:"space-between",gap:"8px 16px",fontSize:11.5,color:r("aux-fg")},children:[t.jsx("span",{children:e}),n&&t.jsx("span",{style:{display:"flex",gap:16},children:n})]})}function Qh({children:e,action:n}){return t.jsxs("div",{className:"bim-d-ui",style:{padding:"18px 4px",fontSize:12.5,color:r("aux-fg"),borderBottom:`1px solid ${r("rule")}`,display:"flex",flexWrap:"wrap",alignItems:"center",gap:12},children:[t.jsx("span",{children:e}),n]})}function et({id:e,label:n,onNavigate:i,renderLink:o,style:s,dense:a}){const l=tt();return o?t.jsx(t.Fragment,{children:o(e,typeof n=="string"?n:void 0,{dense:a})}):t.jsx("a",{href:l(e),onClick:i?d=>{d.metaKey||d.ctrlKey||(d.preventDefault(),i(e))}:void 0,style:s,children:n??e})}function eg({href:e,children:n}){return t.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[n," ",t.jsx("span",{className:"bim-d-ui",style:{fontSize:11},children:"↗"})]})}const kc="guji-table-v1";function tg(e){return!!e&&e.table_notation===kc}const ng=/^:::table(?:\{[^}]*\})?[ \t]*$/,ig=/^:::[ \t]*$/;function wc(e){const n=[];let i="";for(let o=0;o<e.length;o++){const s=e[o];if(s===":"&&e.startsWith(":zi[",o)){const l=rc(e,o+3);if(l>o+4){i+=e.slice(o,l+1),o=l;continue}}let a=null;if(s==="<"){const l=e[o+1];l!==void 0&&!/[A-Za-z/!?>\s]/.test(l)&&(a=">")}if(a){const l=e.indexOf(a,o+1);if(l>0){i+=e.slice(o,l+1),o=l;continue}}s==="|"?(n.push(i),i=""):i+=s}return n.push(i),n.map(o=>o.trim())}const rg=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function og(e){if(e==="^")return{cont:!0};const n=rg.exec(e),i=n[1].trim(),o=n[2]?Math.max(1,parseInt(n[2],10)):1,s=n[3]?Math.max(1,parseInt(n[3],10)):1,a=i==="_";return{cont:!1,cell:{text:a?"":i,empty:a,colspan:o,rowspan:s}}}function Sc(e,n=1){const i=[],o=[],s=[];let a=[];e.forEach((d,c)=>{const p=c+n+1;let h=d.trim();if(!h)return;let u=!1;h.startsWith("!")&&(u=!0,h=h.slice(1));const m=wc(h).map(og),f=a.map($=>$>0),x=a.map($=>$>0?$-1:0),v=[];let y=0;for(const $ of m){if($.cont){f[y]||i.push(`第 ${p} 行第 ${y+1} 列:续格 ^ 上方没有跨行格`),y+=1;continue}const{cell:b}=$;for(let w=y;w<y+b.colspan;w++)if(f[w]){i.push(`第 ${p} 行第 ${w+1} 列:此处被上方跨行格占住,应写 ^`);break}if(b.rowspan>1)for(let w=y;w<y+b.colspan;w++)x[w]=b.rowspan-1;v.push(b),y+=b.colspan}for(let $=y;$<f.length;$++)f[$]&&i.push(`第 ${p} 行第 ${$+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let $=0;$<x.length;$++)x[$]===void 0&&(x[$]=0);a=x,o.push({header:u,cells:v}),s.push({width:y,line:p})});const l=s.reduce((d,c)=>Math.max(d,c.width),0);for(const d of s)d.width!==l&&i.push(`第 ${d.line} 行:占 ${d.width} 列,与总列数 ${l} 不符`);return a.some(d=>d>0)&&i.push("表尾:有跨行格超出了表的最后一行"),o.length===0&&i.push("空表"),{rows:o,columns:l,warnings:i}}function yo(e){const n=e.split(`
1261
1261
  `),i=[];let o=[];const s=()=>{if(o.length===0)return;const l=o.join(`
1262
1262
  `);o=[],i.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(ng.test(n[a].trim())){let l=a+1;for(;l<n.length&&!ig.test(n[l].trim());)l++;if(l<n.length){s();const d=n.slice(a+1,l);i.push({type:"table",table:Sc(d,a+1),source:n.slice(a,l+1).join(`
1263
1263
  `)}),a=l+1;continue}}o.push(n[a]),a++}return s(),i.map((l,d)=>{var p,h;if(l.type!=="text")return l;let c=l.text;return((p=i[d-1])==null?void 0:p.type)==="table"&&(c=c.replace(/^\n+/,"")),((h=i[d+1])==null?void 0:h.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(l=>l.type!=="text"||l.text!=="")}const sg={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},ag={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},lg=`1px solid ${r("table-border")}`,_c={border:lg,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},cg={..._c,background:r("table-head-bg"),fontWeight:600};function jo({table:e,opts:n}){return t.jsx("div",{className:"bim-guji-table-wrap",style:sg,children:t.jsx("table",{className:"bim-guji-table",style:ag,children:t.jsx("tbody",{children:e.rows.map((i,o)=>t.jsx("tr",{children:i.cells.map((s,a)=>{const l=i.header?"th":"td";return t.jsx(l,{colSpan:s.colspan>1?s.colspan:void 0,rowSpan:s.rowspan>1?s.rowspan:void 0,style:i.header?cg:_c,children:s.empty?null:gt(s.text,void 0,n)},a)})},o))})})})}function dg(e,n){return e.indexOf("**")<0?gt(e,void 0,n):e.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((o,s)=>s%2===1?t.jsx("strong",{children:gt(o.trim().slice(2,-2),void 0,n)},s):t.jsx(g.Fragment,{children:gt(o,void 0,n)},s))}function pg(e,n,i=!1){const o=i?{gujiMarkdown:!0}:void 0;return n?yo(e).map((s,a)=>s.type==="table"?t.jsx(jo,{table:s.table,opts:o},a):t.jsx(g.Fragment,{children:dg(s.text,o)},a)):gt(e,void 0,o)}const ug=/^(#{1,6})\s+(.*)$/,mg=/^\*\*([^*\n]+)\*\*\s*$/;function vo(e){const n=e.match(ug);if(n)return{level:n[1].length,text:n[2].trim()};const i=e.trim().match(mg);return i?{level:3,text:i[1].trim()}:null}const ko=/^<!--.*-->$/;function $c(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function Cc(e){return e.split(`
1264
1264
  `).map(n=>n.trim()).filter(n=>n&&!ko.test(n))}const hg=60;function Tc(e){let n=0,i=0;for(const o of e.split(`
1265
- `)){const s=o.trim();if(!s||ko.test(s)||vo(s))continue;const a=s.replace(/<[^<>\n]*>|\u27e8[^\u27e9\n]*\u27e9/g,"").replace(/\s/g,"").length;n+=a,a>hg&&(i+=a)}return n>0&&i*2>=n}function gg(e){return e.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function Mi(e){if(e=gg(e),Tc(e))return"unknown";const n=$c(e);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const i=n.map(s=>Cc(s).length).filter(s=>s>0);if(i.length===0)return"unknown";const o=i.reduce((s,a)=>s+a,0)/i.length;return o<=4?"record":o>=8?"catalog":"unknown"}function fg(e){const n=e.split(`
1265
+ `)){const s=o.trim();if(!s||ko.test(s)||vo(s))continue;const a=s.replace(/<[^<>\n]*>/g,"").replace(/\s/g,"").length;n+=a,a>hg&&(i+=a)}return n>0&&i*2>=n}function gg(e){return e.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function Mi(e){if(e=gg(e),Tc(e))return"unknown";const n=$c(e);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const i=n.map(s=>Cc(s).length).filter(s=>s>0);if(i.length===0)return"unknown";const o=i.reduce((s,a)=>s+a,0)/i.length;return o<=4?"record":o>=8?"catalog":"unknown"}function fg(e){const n=e.split(`
1266
1266
  `),i=[];let o=null,s=[];const a=()=>{i.push({heading:o,body:s.join(`
1267
1267
  `)}),s=[]};for(const l of n){const d=vo(l);if(d){a(),o={kind:"heading",level:d.level,text:d.text};continue}s.push(l)}return a(),i}function ta(e){const n=[];for(const i of e.split(`
1268
1268
  `)){const o=vo(i);if(o){n.push({kind:"heading",level:o.level,text:o.text});continue}const s=i.trim();!s||ko.test(s)||n.push({kind:"body",text:i})}return n}function zc(e){if(!e)return[];const n=Mi(e);if(n==="unknown")return ta(e);const i=[];for(const{heading:o,body:s}of fg(e)){o&&i.push(o);const a=$c(s);if(a.length!==0){if(Tc(s)){i.push(...ta(s));continue}if(n==="record"){const l=a.join(" ");l&&i.push({kind:"body",text:l})}else for(const l of a){const d=Cc(l);d.length&&i.push({kind:"body",text:d.join(" ")})}}}return i}const xg={"「":"“","」":"”","『":"‘","』":"’"},bg={"“":"「","”":"」","‘":"『","’":"』"},yg=new Set(["《","》","〈","〉"]);function Nc(e,n){const i=n.quoteStyle==="modern"?xg:n.quoteStyle==="classic"?bg:null;let o="";for(const s of e)n.hideBookBrackets&&yg.has(s)||(o+=(i==null?void 0:i[s])??s);return o}const Ic=e=>e;function wo(e){return e.showWorks?e.bookTitleStyle==="bracket"?"bracket":Gm(e.properNameMode)?"wavy":"bracket":"none"}function Rc(e,n=Ic,i="wavy"){if(e.indexOf("《")<0)return n(e);const o=[],s=/《([^《》\n]+)》/g;let a=0,l=0,d;for(;d=s.exec(e);){d.index>a&&o.push(t.jsx(g.Fragment,{children:n(e.slice(a,d.index))},l++));const c=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-sr",children:"《"}),n(d[1]),t.jsx("span",{className:"bim-rd-sr",children:"》"})]});o.push(i==="wavy"?t.jsx("span",{className:"bim-rd-pn",children:c},l++):t.jsx(g.Fragment,{children:c},l++)),a=d.index+d[0].length}return a===0?n(e):(a<e.length&&o.push(t.jsx(g.Fragment,{children:n(e.slice(a))},l++)),o)}function Pi(e,n={}){let i=n.renderText??Ic;const o=n.quoteStyle;if(o&&o!=="original"){const d=i;i=c=>d(Nc(c,{quoteStyle:o}))}const s=n.bookMarking??(n.properNames?"wavy":"bracket"),a=s==="bracket"?i:d=>Rc(d,i,s),l=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return gt(e,a,l)}function na(e,n,i){return e.indexOf("**")<0?n(e):e.split(/(\*\*[^*]+\*\*)/g).map((s,a)=>s.startsWith("**")&&s.endsWith("**")&&s.length>4?t.jsx("strong",{children:n(s.slice(2,-2))},`${i}-${a}`):t.jsx(g.Fragment,{children:n(s)},`${i}-${a}`))}const dr=/^(#{1,6})\s+(.*)$/,jg=/^\s*<!--.*-->\s*$/;function Ec(e){return e.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
package/dist/index.d.ts CHANGED
@@ -2810,7 +2810,7 @@ export declare type GujiInlineNode = {
2810
2810
  };
2811
2811
 
2812
2812
  declare interface GujiInlineOptions {
2813
- /** 夹注内容长度上限;缺省 `JZ_MAX_LENGTH`。只管 `<…>`,旧 `⟨…⟩` 不设限 */
2813
+ /** 夹注内容长度上限;缺省 `JZ_MAX_LENGTH`。只管 `<…>` */
2814
2814
  jzMaxLength?: number;
2815
2815
  }
2816
2816
 
@@ -5516,7 +5516,7 @@ export declare type ReadingCapability = 'text' | 'facsimile' | 'interactive_warp
5516
5516
  * (即 `buildParagraphBlocks` 与「分行」模式产出一致的逐行分块,不合并)。
5517
5517
  * 整行粗体(整理本的条目名)与 `#` 标题同样分节;一章里夹着的散文小节照分行排。
5518
5518
  *
5519
- * 夹注安全:本文件只做字符串拼接,`<…>`/`⟨…⟩` 的扫描与渲染交给调用方
5519
+ * 夹注安全:本文件只做字符串拼接,`<…>` 的扫描与渲染交给调用方
5520
5520
  * (`detail/primitives.tsx` 的 `renderInterlinear`)在拼好的整段字符串上
5521
5521
  * 统一处理——不对拼好的 React 节点二次拼接,跨条边界不会把夾注切两半
5522
5522
  * (夹注起止须同行,`\n`/` ` 都不会跨行,安全)。
@@ -6322,7 +6322,7 @@ export declare function splitFullTextTables(text: string): FullTextSegment[];
6322
6322
  export declare function splitHighlightSnippet(snippet: string): HighlightSegment[];
6323
6323
 
6324
6324
  /**
6325
- * 按 `|` 切格,但不切夹注 `<…>`/`⟨…⟩` 与组字 `:zi[…]` 里面的 `|`。
6325
+ * 按 `|` 切格,但不切夹注 `<…>` 与组字 `:zi[…]` 里面的 `|`。
6326
6326
  * `<` 的生效条件与 `scanJiazhu` 相同(其后不是 ASCII 字母、`/`、`!`、`?`、`>`、空白),
6327
6327
  * 且须在本行内闭合,否则按字面。
6328
6328
  * `:zi[…]` 的方括号按 `guji-inline` 的 `matchZi` 配对(计数嵌套、`\` 转义跳过);
package/dist/index.js CHANGED
@@ -9446,9 +9446,9 @@ function bs(e, t, i, o, l) {
9446
9446
  continue;
9447
9447
  }
9448
9448
  let m = null;
9449
- if (u === "⟨" ? m = "⟩" : u === "<" && Uu(e, t) && (m = ">"), m) {
9449
+ if (u === "<" && Uu(e, t) && (m = ">"), m) {
9450
9450
  const h = bs(e, t + 1, m, !0, l);
9451
- if (h && !(u === "<" && h.end - (t + 1) > l)) {
9451
+ if (h && !(h.end - (t + 1) > l)) {
9452
9452
  c(), a.push({ type: "jz", children: h.nodes }), t = h.end + 1;
9453
9453
  continue;
9454
9454
  }
@@ -9461,7 +9461,7 @@ function qu(e, t) {
9461
9461
  return bs(e, 0, null, !1, (t == null ? void 0 : t.jzMaxLength) ?? Fu).nodes;
9462
9462
  }
9463
9463
  function Gu(e) {
9464
- return /[<⟨□]|\[\[|:zi\[/.test(e);
9464
+ return /[<□]|\[\[|:zi\[/.test(e);
9465
9465
  }
9466
9466
  function Ku(e) {
9467
9467
  return e.map((t) => {
@@ -10704,21 +10704,14 @@ function My({ open: e, onToggle: t, main: i, action: o, children: l }) {
10704
10704
  function ws(e) {
10705
10705
  const t = [];
10706
10706
  for (let i = 0; i < e.length; i++) {
10707
- const o = e[i];
10708
- let l;
10709
- if (o === "⟨")
10710
- l = "⟩";
10711
- else if (o === "<") {
10712
- const d = e[i + 1];
10713
- if (d === void 0 || /[A-Za-z/!?>\s]/.test(d)) continue;
10714
- l = ">";
10715
- } else
10716
- continue;
10717
- const a = e.indexOf(l, i + 1);
10718
- if (a < 0) continue;
10719
- const s = e.slice(i + 1, a);
10720
- s.includes(`
10721
- `) || (t.push({ start: i, end: a + 1, inner: s }), i = a);
10707
+ if (e[i] !== "<") continue;
10708
+ const l = e[i + 1];
10709
+ if (l === void 0 || /[A-Za-z/!?>\s]/.test(l)) continue;
10710
+ const s = e.indexOf(">", i + 1);
10711
+ if (s < 0) continue;
10712
+ const d = e.slice(i + 1, s);
10713
+ d.includes(`
10714
+ `) || (t.push({ start: i, end: s + 1, inner: d }), i = s);
10722
10715
  }
10723
10716
  return t;
10724
10717
  }
@@ -10770,7 +10763,7 @@ function yt(e, t = (o) => o, i) {
10770
10763
  if (!e) return "";
10771
10764
  if (i != null && i.gujiMarkdown)
10772
10765
  return Gu(e) ? _s(qu(e, { jzMaxLength: i.jzMaxLength }), t, 0, i.t ?? Vn("zh-Hant")) : t(e);
10773
- if (e.indexOf("⟨") < 0 && e.indexOf("<") < 0) return t(e);
10766
+ if (e.indexOf("<") < 0) return t(e);
10774
10767
  const o = [];
10775
10768
  let l = 0, a = 0;
10776
10769
  for (const s of ws(e))
@@ -11007,8 +11000,7 @@ function gm(e) {
11007
11000
  }
11008
11001
  }
11009
11002
  let a = null;
11010
- if (l === "⟨") a = "⟩";
11011
- else if (l === "<") {
11003
+ if (l === "<") {
11012
11004
  const s = e[o + 1];
11013
11005
  s !== void 0 && !/[A-Za-z/!?>\s]/.test(s) && (a = ">");
11014
11006
  }
@@ -11170,7 +11162,7 @@ function Es(e) {
11170
11162
  `)) {
11171
11163
  const l = o.trim();
11172
11164
  if (!l || jr.test(l) || Hr(l)) continue;
11173
- const a = l.replace(/<[^<>\n]*>|\u27e8[^\u27e9\n]*\u27e9/g, "").replace(/\s/g, "").length;
11165
+ const a = l.replace(/<[^<>\n]*>/g, "").replace(/\s/g, "").length;
11174
11166
  t += a, a > zm && (i += a);
11175
11167
  }
11176
11168
  return t > 0 && i * 2 >= t;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "book-index-ui",
3
- "version": "0.54.2",
3
+ "version": "0.54.3",
4
4
  "description": "React components for browsing and editing ancient book index metadata",
5
5
  "author": "Li Shaodong",
6
6
  "repository": {