book-index-ui 0.66.2 → 0.66.4

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/editor.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),f=require("react"),t=require("./Badge-DdG0AdQo.cjs");require("opencc-js/t2cn");function Ye(n){if(!n)return"";try{const r=new URL(n).hostname,s={"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(s[r])return s[r];const o=r.split(".");return o.length>=2?o[o.length-2]:r}catch{return""}}function ie(n){return n==="text+image"?["text","image"]:[n]}function le(n){const r=t.getResourceTypes(n);return r.length===0?"text":t.getCombinedTypeKey(r)}function Ae(){return{id:"",name:"",url:"",types:["text"],details:""}}const D=({items:n,onChange:r,onDownload:s,downloadStatuses:o,filterType:u})=>{const p=t.useT(),[m,x]=f.useState(null),y=[{value:"text",label:p.resourceTypeShort.text},{value:"image",label:p.resourceTypeShort.image},{value:"text+image",label:p.resourceTypeShort.textImage},{value:"physical",label:p.resourceTypeShort.physical}],v=[{value:"catalog",label:p.rootType.catalog},{value:"search",label:p.rootType.search}],g=b=>{if(!u)return!0;const j=t.getResourceTypes(b);return u==="text"?j.includes("text"):u==="image"?j.includes("image")||j.includes("physical"):u==="physical"?j.includes("physical"):j.includes(u)},l=n.map((b,j)=>({item:b,originalIndex:j})).filter(({item:b})=>g(b)),a=()=>{const b=Ae();u&&(b.types=ie(u)),r([...n,b]),x(n.length)},i=b=>{r(n.filter((j,w)=>w!==b)),x(null)},k=(b,j,w)=>{const I=[...n];if(I[b]={...I[b],[j]:w},j==="url"&&!I[b].id){const S=Ye(w);S&&(I[b].id=S)}r(I)},C=(b,j)=>{const w=[...n],{type:I,...S}=w[b];w[b]={...S,types:ie(j)},r(w)},d=(b,j,w)=>{const S={...n[b].metadata||{}};w?S[j]=w:delete S[j],k(b,"metadata",Object.keys(S).length>0?S:void 0)},_=(b,j)=>{const w=j.trim()?j.split(/[,,、]/).map(I=>I.trim()).filter(Boolean):void 0;k(b,"structure",w)},T=(b,j,w)=>{const S=n[b].coverage||{level:1,ranges:""};j==="level"?S.level=parseInt(w)||1:S.ranges=w,k(b,"coverage",S.ranges?S:void 0)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[l.map(({item:b,originalIndex:j})=>{var w,I,S;return e.jsxs("div",{style:{border:`1px solid ${t.bim("widget-border")}`,borderRadius:"4px",background:t.bim("input-bg"),overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>x(m===j?null:j),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:m===j?"▼":"▶"}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:Ve(le(b)),color:t.bim("on-color-fg")},children:(()=>{var $,F;const h=t.getResourceTypes(b);return h.length===0?"text":h.length===1?(($=y.find(E=>E.value===h[0]))==null?void 0:$.label)??h[0]:h.includes("text")&&h.includes("image")?((F=y.find(E=>E.value==="text+image"))==null?void 0:F.label)??"text+image":h.join("+")})()}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:b.name||`${p.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:h=>h.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),s&&b.url&&Ne(j,o==null?void 0:o[j],s,p),e.jsx("button",{onClick:h=>{h.stopPropagation(),i(j)},style:{background:"transparent",border:"none",color:t.bim("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:p.editor.deleteThisResource,children:"✕"})]}),m===j&&e.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${t.bim("widget-border")}`},children:[t.hasResourceType(b,"image")&&b.url&&He(b,p),e.jsxs("div",{style:{display:"grid",gap:"8px"},children:[e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:A,children:[e.jsx("span",{style:V,children:p.label.type}),e.jsx("select",{value:le(b),onChange:h=>C(j,h.target.value),style:{...L,flex:1},children:y.map(h=>e.jsx("option",{value:h.value,children:h.label},h.value))})]}),e.jsxs("label",{style:A,children:[e.jsx("span",{style:V,children:p.label.rootType}),e.jsx("select",{value:b.root_type||"catalog",onChange:h=>k(j,"root_type",h.target.value),style:{...L,flex:1},children:v.map(h=>e.jsx("option",{value:h.value,children:h.label},h.value))})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("input",{type:"text",value:b.id,onChange:h=>k(j,"id",h.target.value),placeholder:p.editor.idAutoExtract,style:{...L,width:"140px",flexShrink:0}}),e.jsx("input",{type:"text",value:b.name,onChange:h=>k(j,"name",h.target.value),placeholder:p.editor.resourceName,style:{...L,flex:1}})]}),e.jsx("input",{type:"text",value:b.url,onChange:h=>k(j,"url",h.target.value),placeholder:p.editor.resourceUrl,style:L}),e.jsx("input",{type:"text",value:((w=b.structure)==null?void 0:w.join("、"))||"",onChange:h=>_(j,h.target.value),placeholder:p.editor.structurePlaceholder,style:L}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:A,children:[e.jsx("span",{style:V,children:p.label.coverageLevel}),e.jsx("input",{type:"number",min:1,value:((I=b.coverage)==null?void 0:I.level)??"",onChange:h=>T(j,"level",h.target.value),placeholder:"1",style:{...L,width:"60px"}})]}),e.jsxs("label",{style:{...A,flex:1},children:[e.jsx("span",{style:V,children:p.label.coverageRange}),e.jsx("input",{type:"text",value:((S=b.coverage)==null?void 0:S.ranges)||"",onChange:h=>T(j,"ranges",h.target.value),placeholder:p.editor.coverageRangePlaceholder,style:{...L,flex:1}})]})]}),e.jsx("textarea",{value:b.details||"",onChange:h=>k(j,"details",h.target.value),placeholder:p.editor.detailsPlaceholder,style:{...L,minHeight:"60px",resize:"vertical"}}),e.jsxs("div",{style:{borderTop:`1px solid ${t.bim("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[e.jsx("div",{style:{fontSize:"12px",color:t.bim("desc-fg"),marginBottom:"6px"},children:p.label.metadata}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(p.metadata).map(([h,$])=>{var F;return e.jsxs("label",{style:{...A,gap:"4px"},children:[e.jsx("span",{style:{...V,minWidth:"56px"},children:$}),e.jsx("input",{type:"text",value:((F=b.metadata)==null?void 0:F[h])||"",onChange:E=>d(j,h,E.target.value),placeholder:$,style:{...L,flex:1}})]},h)})})]})]})]})]},j)}),e.jsxs("button",{onClick:a,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${t.bim("widget-border")}`,borderRadius:"4px",background:"transparent",color:t.bim("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[e.jsx("span",{children:"+"}),e.jsx("span",{children:p.action.addResource})]})]})};function Ve(n){switch(n){case"text":return t.bim("restype-text");case"image":return t.bim("restype-image");case"text+image":return t.bim("restype-text-image");case"physical":return t.bim("restype-physical")}}function Ne(n,r,s,o){const u=(r==null?void 0:r.status)==="downloading",p=(r==null?void 0:r.status)==="completed";return e.jsx("button",{onClick:m=>{m.stopPropagation(),u||s(n,"")},disabled:u,style:{background:"transparent",border:"none",color:p?t.bim("success"):u?t.bim("desc-fg"):t.bim("link-fg"),cursor:u?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:u?.6:.9},title:p?o.download.completed:u?`${o.download.downloading} ${(r==null?void 0:r.progress)||0}%`:o.download.downloadThis,children:p?"✓":u?"⏳":"⬇"})}function He(n,r){const s=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(n.url)||n.url.includes("iiif")||n.url.includes("image");return e.jsx("div",{style:{marginBottom:"12px"},children:s?e.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:t.bim("overlay-bg")},children:e.jsx("img",{src:n.url,alt:n.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:o=>{o.target.style.display="none"}})}):e.jsx("div",{style:{padding:"12px",background:t.bim("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:t.bim("desc-fg")},children:r.editor.imageResourceLink})})}const L={width:"100%",padding:"6px 8px",background:t.bim("input-bg"),color:t.bim("input-fg"),border:`1px solid ${t.bim("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},A={display:"flex",alignItems:"center",gap:"6px"},V={fontSize:"12px",color:t.bim("desc-fg"),whiteSpace:"nowrap"};function Qe(n){const r=n.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return r?{name:r[1],id:r[2]}:null}const Q=({value:n,onChange:r,label:s})=>{const[o,u]=f.useState(!1),p=f.useRef(null),m=Qe(n||"");return f.useEffect(()=>{o&&p.current&&p.current.focus()},[o]),!o&&m?e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:re,children:s}),e.jsxs("div",{onClick:()=>u(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:`1px solid ${t.bim("input-border")}`,borderRadius:"2px",background:t.bim("input-bg"),cursor:"pointer",minHeight:"30px"},children:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:t.bim("fg")},children:m.name}),e.jsx(t.Badge,{children:m.id})]})]}):e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:re,children:s}),e.jsx("input",{ref:p,type:"text",value:n||"",onChange:x=>r(x.target.value),onBlur:()=>u(!1),style:{width:"100%",padding:"6px 8px",background:t.bim("input-bg"),color:t.bim("input-fg"),border:`1px solid ${t.bim("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},re={display:"block",fontSize:"11px",color:t.bim("desc-fg"),marginBottom:"4px",fontWeight:500};function Ke(n){switch(n){case"url":return t.bim("source-url");case"bookID":return t.bim("source-bookid");default:return t.bim("desc-fg")}}function qe(n){switch(n){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const ue=({items:n,onChange:r,onOpenEntityPicker:s})=>{const o=t.useT(),[u,p]=f.useState(null),m=()=>{r([...n,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),p(n.length)},x=l=>{r(n.filter((a,i)=>i!==l)),u===l&&p(null)},y=(l,a,i)=>{const k=[...n];k[l]={...k[l],[a]:i},r(k)},v=(l,a)=>{const i=[...n];i[l]={...i[l],type:a,id:"",name:""},r(i),a==="bookID"&&s&&s(k=>{const C=[...n];C[l]={...C[l],id:k.id,name:k.title,type:"bookID"},r(C)})},g=l=>{s&&s(a=>{const i=[...n];i[l]={...i[l],id:a.id,name:a.title,type:"bookID"},r(i)})};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[n.map((l,a)=>e.jsxs("div",{style:{border:`1px solid ${t.bim("widget-border")}`,borderRadius:"4px",background:t.bim("input-bg"),overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>p(u===a?null:a),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:u===a?"▼":"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:t.bim("fg")},children:l.name||`${o.editor.sourcePlaceholder} ${a+1}`}),l.type&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:Ke(l.type),color:t.bim("on-color-fg"),borderRadius:"3px",fontWeight:500},children:qe(l.type)}),e.jsx("button",{onClick:i=>{i.stopPropagation(),x(a)},style:{background:"transparent",border:"none",color:t.bim("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:o.editor.deleteThisSource,children:"✕"})]}),u===a&&e.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${t.bim("widget-border")}`},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!l.type&&e.jsxs("div",{children:[e.jsx("label",{style:W,children:o.editor.selectSourceType}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsxs("button",{onClick:()=>v(a,"bookID"),style:{...se,borderColor:t.bim("source-bookid"),color:t.bim("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:o.editor.fromExistingBook})]}),e.jsxs("button",{onClick:()=>v(a,"url"),style:{...se,borderColor:t.bim("source-url"),color:t.bim("source-url")},children:[e.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),e.jsx("span",{children:"URL"}),e.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.enterUrl})]})]})]}),l.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:W,children:o.action.selectBookOrWork}),e.jsx("button",{onClick:()=>{const i=[...n];i[a]={...i[a],type:"",id:"",name:""},r(i)},style:de,children:o.action.changeType})]}),l.id&&l.name?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:t.bim("bg"),border:`1px solid ${t.bim("source-bookid")}`,borderRadius:"6px"},children:[e.jsx("span",{style:{color:t.bim("source-bookid"),fontSize:"16px"},children:"✓"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:l.name}),e.jsx("code",{style:{fontSize:"11px",background:t.bim("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:l.id})]}),e.jsx("button",{onClick:()=>g(a),style:{background:"transparent",border:`1px solid ${t.bim("widget-border")}`,color:t.bim("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:o.action.reselect})]}):e.jsxs("button",{onClick:()=>g(a),style:{width:"100%",padding:"14px",border:`2px dashed ${t.bim("widget-border")}`,borderRadius:"6px",background:"transparent",color:t.bim("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[e.jsx("span",{children:"🔍"}),e.jsx("span",{children:o.action.clickToSelectBookOrWork})]})]})}),l.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:W,children:o.label.sourceName}),e.jsx("button",{onClick:()=>{const i=[...n];i[a]={...i[a],type:"",id:"",name:""},r(i)},style:de,children:o.action.changeType})]}),e.jsx("input",{type:"text",value:l.name,onChange:i=>y(a,"name",i.target.value),placeholder:o.editor.sourceNamePlaceholder,style:M})]}),e.jsxs("div",{children:[e.jsx("label",{style:W,children:o.label.urlAddress}),e.jsx("input",{type:"text",value:l.id,onChange:i=>y(a,"id",i.target.value),placeholder:"https://...",style:M})]})]}),l.type&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{borderTop:`1px dashed ${t.bim("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:e.jsx("label",{style:{...W,opacity:.7},children:o.label.optionalInfo})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:W,children:o.label.detailsOptional}),e.jsx("input",{type:"text",value:l.details,onChange:i=>y(a,"details",i.target.value),placeholder:o.editor.detailsPlaceholder,style:M})]}),e.jsxs("div",{children:[e.jsx("label",{style:W,children:o.label.positionOptional}),e.jsx("input",{type:"text",value:l.position,onChange:i=>y(a,"position",i.target.value),placeholder:"如: 卷三, p.52",style:M})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:W,children:o.label.dataVersionOptional}),e.jsx("input",{type:"text",value:l.version,onChange:i=>y(a,"version",i.target.value),placeholder:"如: v1.0, 2024-01",style:M})]}),e.jsxs("div",{children:[e.jsx("label",{style:W,children:o.label.processorVersionOptional}),e.jsx("input",{type:"text",value:l.processor_version,onChange:i=>y(a,"processor_version",i.target.value),placeholder:"如: v0.1",style:M})]})]})]})]})})]},a)),e.jsxs("button",{onClick:m,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${t.bim("widget-border")}`,borderRadius:"4px",background:"transparent",color:t.bim("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[e.jsx("span",{children:"+"}),e.jsx("span",{children:o.action.addSource})]})]})},W={display:"block",fontSize:"11px",color:t.bim("desc-fg"),marginBottom:"4px",fontWeight:500},M={width:"100%",padding:"6px 8px",background:t.bim("input-bg"),color:t.bim("input-fg"),border:`1px solid ${t.bim("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},se={flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",padding:"16px 12px",background:t.bim("bg"),border:"2px solid",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:500,transition:"all 0.2s"},de={background:"transparent",border:"none",color:t.bim("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function be(n){if(!n||!n.trim())return[];try{const r=JSON.parse(n);if(Array.isArray(r))return r.map(s=>({id:s.id||"",name:s.name||"",type:s.type||"",details:s.details||"",position:s.position||"",version:s.version||"",processor_version:s.processor_version||""}))}catch{}return[]}function ge(n){return!n||n.length===0?"":JSON.stringify(n)}const he=({entityType:n,entityId:r,entityTitle:s,parentWork:o,parentCollection:u,belongsToWork:p,belongsToCollection:m,childWorks:x,childCollections:y,containedBooks:v,siblingBooks:g,onLinkEntity:l,onUnlinkEntity:a,onViewEntity:i,onCreateAndLink:k,onSaveRelations:C})=>{const d=t.useT();return e.jsxs("div",{style:{background:t.bim("bg"),border:`1px solid ${t.bim("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[e.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:`1px solid ${t.bim("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:d.section.relations})]}),C&&e.jsx("button",{onClick:C,style:Je,children:d.action.save})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[n==="book"&&e.jsxs(e.Fragment,{children:[e.jsx(N,{direction:"up",title:d.relation.belongsToWork,entity:p,onView:i,onUnlink:()=>a("workId"),onLink:()=>l("workId","work"),onCreate:()=>k("workId","work",{title:s}),linkLabel:d.action.linkExisting,createLabel:d.action.createAndLink,notLinkedLabel:d.relation.notLinked,viewLabel:d.action.viewEntity,unlinkLabel:d.action.unlink}),e.jsx(N,{direction:"up",title:d.relation.containedInCollection,entity:m,onView:i,onUnlink:()=>a("collectionId"),onLink:()=>l("collectionId","collection"),onCreate:()=>k("collectionId","collection",{title:s}),linkLabel:d.action.linkExisting,createLabel:d.action.createAndLink,notLinkedLabel:d.relation.notLinked,viewLabel:d.action.viewEntity,unlinkLabel:d.action.unlink}),p&&g&&g.length>0&&e.jsx(U,{direction:"horizontal",title:`${d.relation.siblingVersions} (${g.length})`,entities:g,onView:i,onAdd:()=>k("siblingBook","book",{workId:p.id}),addLabel:d.relation.addVersionForWork,noneLabel:d.relation.none,expandMoreLabel:d.action.expandMore})]}),n==="work"&&e.jsxs(e.Fragment,{children:[e.jsx(N,{direction:"up",title:d.relation.parentWork,entity:o,onView:i,onUnlink:()=>a("parentWorkId"),onLink:()=>l("parentWorkId","work"),onCreate:()=>k("parentWorkId","work"),linkLabel:d.action.linkExisting,createLabel:d.action.createAndLink,notLinkedLabel:d.relation.notLinked,viewLabel:d.action.viewEntity,unlinkLabel:d.action.unlink}),x&&x.length>0&&e.jsx(U,{direction:"down",title:`${d.relation.childWorks} (${x.length})`,entities:x,onView:i,onAdd:()=>k("childWork","work",{parentWorkId:r}),addLabel:d.action.addSubWork,noneLabel:d.relation.none,expandMoreLabel:d.action.expandMore}),y&&y.length>0&&e.jsx(U,{direction:"down",title:`${d.relation.collectionImpl} (${y.length})`,entities:y,onView:i,onAdd:()=>k("childCollection","collection",{workId:r}),addLabel:d.action.addCollectionImpl,noneLabel:d.relation.none,expandMoreLabel:d.action.expandMore}),e.jsx(U,{direction:"down",title:`${d.relation.allVersions} (${(v==null?void 0:v.length)??0})`,entities:v||[],onView:i,onAdd:()=>k("childBook","book",{workId:r}),addLabel:d.action.addVersion,noneLabel:d.relation.none,expandMoreLabel:d.action.expandMore})]}),n==="collection"&&e.jsxs(e.Fragment,{children:[e.jsx(N,{direction:"up",title:d.relation.correspondingWork,entity:p,onView:i,onUnlink:()=>a("workId"),onLink:()=>l("workId","work"),onCreate:()=>k("workId","work",{title:s}),linkLabel:d.action.linkExisting,createLabel:d.action.createAndLink,notLinkedLabel:d.relation.notLinked,viewLabel:d.action.viewEntity,unlinkLabel:d.action.unlink}),e.jsx(N,{direction:"up",title:d.relation.parentCollection,entity:u,onView:i,onUnlink:()=>a("parentCollectionId"),onLink:()=>l("parentCollectionId","collection"),onCreate:()=>k("parentCollectionId","collection"),linkLabel:d.action.linkExisting,createLabel:d.action.createAndLink,notLinkedLabel:d.relation.notLinked,viewLabel:d.action.viewEntity,unlinkLabel:d.action.unlink}),e.jsx(U,{direction:"down",title:`${d.relation.childCollections} (${(y==null?void 0:y.length)??0})`,entities:y||[],onView:i,onAdd:()=>k("childCollection","collection",{parentCollectionId:r}),addLabel:d.action.addSubCollection,noneLabel:d.relation.none,expandMoreLabel:d.action.expandMore}),e.jsx(U,{direction:"down",title:`${d.relation.containedBooks} (${(v==null?void 0:v.length)??0})`,entities:v||[],onView:i,onAdd:()=>k("childBook","book",{collectionId:r}),addLabel:d.action.addBook,noneLabel:d.relation.none,expandMoreLabel:d.action.expandMore})]})]})]})},N=({direction:n,title:r,entity:s,onView:o,onUnlink:u,onLink:p,onCreate:m,linkLabel:x,createLabel:y,notLinkedLabel:v,viewLabel:g,unlinkLabel:l})=>{const a=n==="up"?t.bim("relation-up"):n==="down"?t.bim("relation-down"):t.bim("relation-flat"),i=n==="up"?"⬆️":n==="down"?"⬇️":"↔️";return e.jsxs("div",{style:{border:`1px solid ${t.bim("widget-border")}`,borderRadius:"4px",padding:"10px",background:t.bim("input-bg")},children:[e.jsxs("div",{style:{fontSize:"12px",color:a,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:i}),e.jsx("span",{children:r})]}),s?e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:t.bim("bg"),borderRadius:"4px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:ye(s.type)}),e.jsx("span",{style:{fontWeight:500},children:s.title}),e.jsx("span",{style:{fontSize:"11px",opacity:.6},children:s.id})]}),e.jsxs("div",{style:{display:"flex",gap:"4px"},children:[e.jsx(ae,{onClick:()=>o(s),title:g,children:"👁️"}),e.jsx(ae,{onClick:u,title:l,danger:!0,children:"✕"})]})]}):e.jsx("div",{style:{padding:"8px",background:t.bim("bg"),borderRadius:"4px",color:t.bim("desc-fg"),fontSize:"12px",textAlign:"center"},children:v}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsx(ee,{onClick:p,children:x}),e.jsx(ee,{onClick:m,primary:!0,children:y})]})]})},U=({direction:n,title:r,entities:s,onView:o,onAdd:u,addLabel:p,noneLabel:m,expandMoreLabel:x})=>{const[y,v]=f.useState(!1),g=n==="up"?t.bim("relation-up"):n==="down"?t.bim("relation-down"):t.bim("relation-flat"),l=n==="up"?"⬆️":n==="down"?"⬇️":"↔️",a=y?s:s.slice(0,5);return e.jsxs("div",{style:{border:`1px solid ${t.bim("widget-border")}`,borderRadius:"4px",padding:"10px",background:t.bim("input-bg")},children:[e.jsxs("div",{style:{fontSize:"12px",color:g,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:l}),e.jsx("span",{children:r})]}),s.length>0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[a.map(i=>e.jsxs("div",{onClick:()=>o(i),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:t.bim("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[e.jsx("span",{children:ye(i.type)}),e.jsx("span",{children:i.title})]},i.id)),s.length>5&&!y&&e.jsxs("div",{onClick:()=>v(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:t.bim("link-fg"),cursor:"pointer"},children:[x," (",s.length-5,")"]})]}):e.jsx("div",{style:{padding:"8px",background:t.bim("bg"),borderRadius:"4px",color:t.bim("desc-fg"),fontSize:"12px",textAlign:"center"},children:m}),e.jsx("div",{style:{marginTop:"8px"},children:e.jsxs(ee,{onClick:u,primary:!0,children:["+ ",p]})})]})},ae=({onClick:n,title:r,danger:s,children:o})=>e.jsx("button",{onClick:u=>{u.stopPropagation(),n()},title:r,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:s?t.bim("danger"):"inherit",opacity:.7},children:o}),ee=({onClick:n,primary:r,children:s})=>e.jsx("button",{onClick:n,style:{padding:"4px 10px",fontSize:"11px",border:r?"none":`1px solid ${t.bim("widget-border")}`,borderRadius:"4px",background:r?t.bim("primary"):"transparent",color:r?t.bim("primary-fg"):"inherit",cursor:"pointer"},children:s});function ye(n){switch(n){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const Je={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:t.bim("primary"),color:t.bim("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},fe=({isOpen:n,entityType:r,title:s,onSelect:o,onCancel:u,onCreate:p,searchResults:m,onSearch:x,isLoading:y,excludeId:v})=>{const[g,l]=f.useState(""),a=v?m.filter(d=>d.id!==v):m;f.useEffect(()=>{n&&(l(""),x(""))},[n]);const i=d=>{l(d),x(d)};if(!n)return null;const k=r==="work"?"作品":r==="book"?"书籍":"丛编",C=r==="work"?"📜":r==="book"?"📖":"📚";return e.jsx("div",{style:Ze,children:e.jsxs("div",{style:Ge,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${t.bim("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:s}),e.jsx("button",{onClick:u,style:Xe,children:"✕"})]}),e.jsx("div",{style:{padding:"12px 16px"},children:e.jsx("input",{type:"text",value:g,onChange:d=>i(d.target.value),placeholder:`搜索${k}名称或 ID...`,autoFocus:!0,style:De})}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:y?e.jsx("div",{style:G,children:"搜索中..."}):a.length>0?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:a.map(d=>e.jsxs("div",{onClick:()=>o(d),style:et,children:[e.jsx("span",{style:{fontSize:"16px"},children:C}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontWeight:500},children:[d.title,d.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:d.edition})]}),e.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[d.id,d.author&&` · ${d.author}`,d.dynasty&&` · ${d.dynasty}`]})]})]},d.id))}):g?e.jsxs("div",{style:G,children:["未找到匹配的",k]}):e.jsxs("div",{style:G,children:["输入关键词搜索",k]})}),e.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${t.bim("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),e.jsxs("button",{onClick:p,style:tt,children:["创建新",k,"并关联"]})]})]})})},Ze={position:"fixed",top:0,left:0,right:0,bottom:0,background:t.bim("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Ge={background:t.bim("bg"),border:`1px solid ${t.bim("widget-border")}`,borderRadius:"8px",width:"500px",maxWidth:"calc(100vw - 32px)",maxHeight:"70vh",display:"flex",flexDirection:"column",boxShadow:t.bim("shadow-dialog")},Xe={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},De={width:"100%",padding:"10px 12px",border:`1px solid ${t.bim("input-border")}`,borderRadius:"4px",background:t.bim("input-bg"),color:t.bim("input-fg"),fontSize:"13px",boxSizing:"border-box"},et={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:t.bim("primary-soft")},G={padding:"20px",textAlign:"center",color:t.bim("desc-fg")},tt={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:t.bim("primary"),color:t.bim("primary-fg"),cursor:"pointer"},ce={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},nt={work:"📜",book:"📖",collection:"📚",entity:"👤"},me=({isOpen:n,entityType:r,relationField:s,inheritData:o,onConfirm:u,onCancel:p})=>{const[m,x]=f.useState(""),y=f.useRef(null);f.useEffect(()=>{n&&(x((o==null?void 0:o.title)||""),setTimeout(()=>{var a,i;(a=y.current)==null||a.focus(),(i=y.current)==null||i.select()},100))},[n,o==null?void 0:o.title]);const v=a=>{a.key==="Enter"&&m.trim()?g():a.key==="Escape"&&p()},g=()=>{m.trim()&&u(m.trim(),{...o,title:m.trim()})};if(!n)return null;const l=()=>{switch(s){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`创建新${ce[r]}`}};return e.jsx("div",{style:ot,onClick:a=>{a.target===a.currentTarget&&p()},children:e.jsxs("div",{style:it,onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:nt[r]}),e.jsx("span",{children:l()})]}),e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:t.bim("fg")},children:[r==="work"?"作品名":r==="collection"?"丛编名":"书名",e.jsx("span",{style:{color:t.bim("danger"),marginLeft:"4px"},children:"*"})]}),e.jsx("input",{ref:y,type:"text",value:m,onChange:a=>x(a.target.value),onKeyDown:v,placeholder:`请输入${ce[r]}名称...`,style:lt})]}),((o==null?void 0:o.author)||(o==null?void 0:o.dynasty))&&e.jsxs("div",{style:{fontSize:"12px",color:t.bim("desc-fg"),background:t.bim("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[e.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(o==null?void 0:o.author)&&e.jsxs("div",{children:["作者: ",o.author]}),(o==null?void 0:o.dynasty)&&e.jsxs("div",{children:["朝代/年份: ",o.dynasty]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[e.jsx("button",{onClick:p,style:rt,children:"取消"}),e.jsx("button",{onClick:g,disabled:!m.trim(),style:{...st,opacity:m.trim()?1:.6,cursor:m.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},ot={position:"fixed",top:0,left:0,right:0,bottom:0,background:t.bim("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},it={background:t.bim("bg"),border:`1px solid ${t.bim("widget-border")}`,borderRadius:"8px",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:t.bim("shadow-dialog")},lt={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${t.bim("input-border")}`,borderRadius:"4px",background:t.bim("input-bg"),color:t.bim("input-fg"),outline:"none",boxSizing:"border-box"},rt={padding:"8px 16px",fontSize:"13px",border:`1px solid ${t.bim("widget-border")}`,borderRadius:"4px",background:"transparent",color:t.bim("fg"),cursor:"pointer"},st={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:t.bim("primary"),color:t.bim("primary-fg")};function dt(n){switch(n){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function je(n){switch(n){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function at(n){switch(n){case"work":return t.bim("editor-type-work");case"collection":return t.bim("editor-type-collection");case"book":return t.bim("editor-type-book");default:return t.bim("desc-fg")}}const ke=({isOpen:n,title:r,filterType:s="all",recentEntities:o=[],excludeId:u,showCreateButton:p=!1,createButtonText:m,onSelect:x,onCancel:y,onCreate:v,onSearch:g})=>{const[l,a]=f.useState(""),[i,k]=f.useState([]),[C,d]=f.useState(!1),[_,T]=f.useState("recent");f.useEffect(()=>{n&&(a(""),k([]),T(o.length>0?"recent":"search"))},[n,o.length]),f.useEffect(()=>{if(!l.trim()){k([]);return}const h=setTimeout(async()=>{d(!0);try{k(await g(l,s))}catch{k([])}finally{d(!1)}},300);return()=>clearTimeout(h)},[l,s,g]);const b=f.useCallback(h=>{a(h.target.value),h.target.value.trim()&&T("search")},[]),j=f.useCallback(h=>u?h.filter($=>$.id!==u):h,[u]);if(!n)return null;const w=r||(s==="all"?"选择实体":`选择${je(s)}`),I=j(o),S=j(i);return e.jsx("div",{style:pt,children:e.jsxs("div",{style:xt,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${t.bim("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:w}),e.jsx("button",{onClick:y,style:ut,children:"✕"})]}),e.jsx("div",{style:{padding:"16px 20px 12px"},children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{type:"text",value:l,onChange:b,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:bt}),e.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),C&&e.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),I.length>0&&e.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${t.bim("widget-border")}`},children:[e.jsxs(pe,{active:_==="recent",onClick:()=>T("recent"),children:["最近使用 (",I.length,")"]}),e.jsxs(pe,{active:_==="search",onClick:()=>T("search"),children:["搜索结果 ",S.length>0&&`(${S.length})`]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:_==="recent"&&I.length>0?e.jsx(xe,{entities:I,onSelect:x}):l.trim()?C?e.jsx(X,{message:"搜索中..."}):S.length>0?e.jsx(xe,{entities:S,onSelect:x}):e.jsx(X,{message:"未找到匹配的结果"}):e.jsx(X,{message:"输入关键词开始搜索"})}),p&&v&&e.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${t.bim("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),e.jsx("button",{onClick:v,style:gt,children:m||"创建新实体"})]})]})})},pe=({active:n,onClick:r,children:s})=>e.jsx("button",{onClick:r,style:{padding:"10px 16px",border:"none",borderBottom:n?`2px solid ${t.bim("primary")}`:"2px solid transparent",background:"transparent",color:n?t.bim("fg"):t.bim("desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:n?600:400,marginBottom:"-1px"},children:s}),xe=({entities:n,onSelect:r})=>e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:n.map(s=>e.jsx(ct,{entity:s,onClick:()=>r(s)},s.id))}),ct=({entity:n,onClick:r})=>{const[s,o]=f.useState(!1);return e.jsxs("div",{onClick:r,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:t.bim("primary-soft"),transition:"background 0.1s"},children:[e.jsx("span",{style:{fontSize:"18px"},children:dt(n.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:[n.title,n.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:t.bim("desc-fg"),marginLeft:"4px"},children:n.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:t.bim("primary-soft"),padding:"1px 4px",borderRadius:"2px"},children:n.id}),n.author&&e.jsx("span",{children:n.author}),n.dynasty&&e.jsx("span",{children:n.dynasty})]})]}),e.jsx("span",{style:{fontSize:"10px",padding:"3px 8px",background:at(n.type),color:t.bim("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:je(n.type)})]})},X=({message:n})=>e.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:t.bim("desc-fg"),fontSize:"13px"},children:n}),pt={position:"fixed",top:0,left:0,right:0,bottom:0,background:t.bim("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},xt={background:t.bim("bg"),border:`1px solid ${t.bim("widget-border")}`,borderRadius:"8px",width:"550px",maxWidth:"calc(100vw - 32px)",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:t.bim("shadow-dialog")},ut={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},bt={width:"100%",padding:"12px 16px",paddingLeft:"40px",border:`1px solid ${t.bim("input-border")}`,borderRadius:"6px",background:t.bim("input-bg"),color:t.bim("input-fg"),fontSize:"13px",boxSizing:"border-box"},gt={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:t.bim("primary"),color:t.bim("primary-fg"),cursor:"pointer"},ht={work:t.bim("editor-type-work"),collection:t.bim("editor-type-collection"),book:t.bim("editor-type-book"),entity:t.bim("editor-type-entity")},yt={work:"📜",collection:"📚",book:"📖",entity:"👤"},ft=({data:n,onChange:r,onSave:s,transport:o,onNavigate:u,showDelete:p,onDelete:m,onAskAI:x,renderSectionActions:y,onDownloadResource:v,downloadStatuses:g,relations:l,onRelationsChange:a})=>{var oe;const i=t.useT(),[k,C]=f.useState(!1),[d,_]=f.useState("work"),[T,b]=f.useState(""),[j,w]=f.useState(""),[I,S]=f.useState([]),[h,$]=f.useState(!1),[F,E]=f.useState(!1),[K,Se]=f.useState("work"),[q,we]=f.useState(""),[Ce,Ie]=f.useState(),[ze,J]=f.useState(!1),[H,Z]=f.useState(null),[Re,te]=f.useState([]);f.useRef(null);const P=n.type,Te=P==="work",Y=P==="collection",O=P==="book",z=f.useCallback((c,R)=>{r({...n,[c]:R})},[n,r]),$e=f.useCallback((c,R)=>{b(c),_(R),w(i.editor.selectToLink+i.indexType[R]),S([]),C(!0)},[i]),Le=f.useCallback(c=>{o!=null&&o.unlinkEntity&&o.unlinkEntity(n.id,c)},[o,n.id]),Ee=f.useCallback(c=>{u==null||u(c.id,c.type)},[u]),ne=f.useCallback((c,R,B)=>{const Ue={...B,author:(B==null?void 0:B.author)||n.author,dynasty:B==null?void 0:B.dynasty};Se(R),we(c),Ie(Ue),E(!0)},[n.author]),Be=f.useCallback((c,R)=>{o!=null&&o.createAndLink&&o.createAndLink(n.id,q,{type:K,title:c,inheritData:R}),E(!1)},[o,n.id,q,K]),We=f.useCallback(c=>{if(!c.trim()){S([]);return}$(!0),o!=null&&o.searchEntities&&o.searchEntities(c,d).then(R=>{S(R),$(!1)}).catch(()=>{S([]),$(!1)})},[o,d]),_e=f.useCallback(c=>{o!=null&&o.linkEntity&&o.linkEntity(n.id,T,c.id),C(!1)},[o,n.id,T]),Fe=f.useCallback(()=>{s()},[s]),Pe=f.useCallback(c=>{Z(()=>c),J(!0),o!=null&&o.getRecentEntities&&o.getRecentEntities().then(te).catch(()=>{})},[o]),Oe=f.useCallback((c,R)=>o!=null&&o.searchEntities?o.searchEntities(c,R==="all"?void 0:R):Promise.resolve([]),[o]),Me=f.useCallback(c=>{o!=null&&o.addRecentEntity&&o.addRecentEntity(c),te(R=>[c,...R.filter(B=>B.id!==c.id)].slice(0,10)),H==null||H(c),J(!1),Z(null)},[o,H]);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 ${t.bim("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:yt[P]}),e.jsx("span",{children:n.title||i.editor.untitled}),e.jsx(t.Badge,{children:n.id}),e.jsx(t.Badge,{color:ht[P],children:i.indexType[P]})]})}),e.jsx(t.Section,{title:i.section.basicInfo,onSave:s,onAskAI:x?()=>x("基本信息"):void 0,extraButtons:y==null?void 0:y("基本信息"),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[e.jsx(Q,{label:Te?i.editor.workTitle:Y?i.editor.collectionTitle:i.editor.bookTitle,value:n.title,onChange:c=>z("title",c)}),O&&e.jsx(Q,{label:i.editor.belongsToWork,value:n.workName||"",onChange:c=>z("workName",c)}),e.jsx(t.FormInput,{label:i.editor.authorLabel,value:n.author||"",onChange:c=>z("author",c)}),e.jsx(t.FormInput,{label:i.editor.publicationYearLabel,value:n.publicationYear||"",onChange:c=>z("publicationYear",c)}),(O||Y)&&e.jsx(Q,{label:i.editor.containedIn,value:n.collection||"",onChange:c=>z("collection",c)}),(O||Y)&&e.jsx(t.FormInput,{label:i.editor.holderLabel,value:n.holder||"",onChange:c=>z("holder",c)}),(O||Y)&&e.jsx(t.FormInput,{label:O?i.editor.pageLabel:i.editor.volumeLabel,value:n.pages||"",onChange:c=>z("pages",c)}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(t.FormInput,{label:i.editor.firstImageLabel,value:n.firstImage||"",onChange:c=>z("firstImage",c)})})]})}),e.jsx(t.Section,{title:i.section.description,onSave:s,onAskAI:x?()=>x("介绍"):void 0,children:e.jsx(t.FormTextArea,{value:n.description||"",onChange:c=>z("description",c),placeholder:i.editor.descriptionPlaceholder})}),(((oe=n.additional_works)==null?void 0:oe.length)||0)>0&&e.jsx(t.Section,{title:i.section.additionalWorks,onSave:s,children:e.jsx(mt,{items:n.additional_works||[],onChange:c=>z("additional_works",c)})}),e.jsx(t.Section,{title:i.section.indexedBy,onSave:s,onAskAI:x?()=>x("收录于"):void 0,children:e.jsx(jt,{items:n.indexed_by||[],onChange:c=>z("indexed_by",c)})}),e.jsx(t.Section,{title:i.section.emendatedBy,onSave:s,onAskAI:x?()=>x("考证"):void 0,children:e.jsx(kt,{items:n.emendated_by||[],onChange:c=>z("emendated_by",c)})}),e.jsx(t.Section,{title:i.section.textResources,onSave:s,onAskAI:x?()=>x("资源"):void 0,children:e.jsx(D,{items:n.resources||[],onChange:c=>z("resources",c),onDownload:v,downloadStatuses:g,filterType:"text"})}),e.jsx(t.Section,{title:i.section.imageResources,onSave:s,children:e.jsx(D,{items:n.resources||[],onChange:c=>z("resources",c),onDownload:v,downloadStatuses:g,filterType:"image"})}),e.jsx(t.Section,{title:i.section.sources,onSave:s,onAskAI:x?()=>x("资料来源"):void 0,children:e.jsx(ue,{items:be(n.sources||""),onChange:c=>z("sources",ge(c)),onOpenEntityPicker:Pe})}),(O||Y)&&e.jsx(t.Section,{title:i.section.provenance,onSave:s,onAskAI:x?()=>x("收藏历史"):void 0,children:e.jsx(t.FormTextArea,{value:n.provenance||"",onChange:c=>z("provenance",c),placeholder:i.editor.provenancePlaceholder})}),O&&e.jsx(t.Section,{title:i.section.otherEditions,onSave:s,onAskAI:x?()=>x("其他版本"):void 0,children:e.jsx(t.FormTextArea,{value:n.otherEditions||"",onChange:c=>z("otherEditions",c),placeholder:i.editor.otherEditionsPlaceholder})}),e.jsx(he,{entityType:P,entityId:n.id,entityTitle:n.title,parentWork:l==null?void 0:l.parentWork,parentCollection:l==null?void 0:l.parentCollection,belongsToWork:l==null?void 0:l.belongsToWork,belongsToCollection:l==null?void 0:l.belongsToCollection,childWorks:l==null?void 0:l.childWorks,childCollections:l==null?void 0:l.childCollections,containedBooks:l==null?void 0:l.containedBooks,siblingBooks:l==null?void 0:l.siblingBooks,onLinkEntity:$e,onUnlinkEntity:Le,onViewEntity:Ee,onCreateAndLink:ne,onSaveRelations:Fe}),p&&m&&e.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${t.bim("danger-soft-border")}`,background:t.bim("danger-soft-bg"),borderRadius:"4px"},children:[e.jsx("div",{style:{color:t.bim("danger"),fontWeight:600,marginBottom:"8px"},children:i.section.dangerZone}),e.jsx("p",{style:{fontSize:"12px",color:t.bim("desc-fg"),marginBottom:"12px"},children:i.editor.dangerZoneDesc}),e.jsx("button",{onClick:m,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${t.bim("danger")}`,borderRadius:"4px",background:"transparent",color:t.bim("danger"),cursor:"pointer"},children:i.editor.deleteEntity})]}),e.jsx(fe,{isOpen:k,entityType:d,title:j,onSelect:_e,onCancel:()=>C(!1),onCreate:()=>{C(!1),ne(T,d)},searchResults:I,onSearch:We,isLoading:h,excludeId:n.id}),e.jsx(me,{isOpen:F,entityType:K,relationField:q,inheritData:Ce,onConfirm:Be,onCancel:()=>E(!1)}),e.jsx(ke,{isOpen:ze,title:i.action.selectBookOrWork,filterType:"all",recentEntities:Re,excludeId:n.id,onSelect:Me,onCancel:()=>{J(!1),Z(null)},onSearch:Oe})]})};function mt({items:n,onChange:r}){const s=t.useT(),o=(m,x,y)=>{const v=n.map((g,l)=>l===m?{...g,[x]:y}:g);r(v)},u=m=>r(n.filter((x,y)=>y!==m)),p=()=>r([...n,{book_title:""}]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[n.map((m,x)=>e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx(t.FormInput,{label:s.editor.bookNameLabel,value:m.book_title,onChange:y=>o(x,"book_title",y)}),e.jsx("div",{style:{width:"100px"},children:e.jsx(t.FormInput,{label:s.label.juanCount,value:m.n_juan!=null?String(m.n_juan):"",onChange:y=>o(x,"n_juan",y&&parseInt(y,10)||void 0)})}),e.jsx("button",{onClick:()=>u(x),style:{padding:"4px 8px",fontSize:"12px",border:`1px solid ${t.bim("widget-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:t.bim("muted"),marginTop:"18px"},children:"✕"})]},x)),e.jsx("button",{onClick:p,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${t.bim("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:t.bim("desc-fg"),alignSelf:"flex-start"},children:s.action.addAdditionalWork})]})}function ve({items:n,onChange:r,showMeta:s,addLabel:o}){const u=t.useT(),[p,m]=f.useState(null),x=(g,l,a)=>{const i=n.map((k,C)=>C===g?{...k,[l]:a||void 0}:k);r(i)},y=g=>{r(n.filter((l,a)=>a!==g)),p===g&&m(null)},v=()=>{r([...n,{source:""}]),m(n.length)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[n.map((g,l)=>{const a=p===l;return e.jsxs("div",{style:{border:`1px solid ${t.bim("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:a?`color-mix(in srgb, ${t.bim("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>m(a?null:l),children:[e.jsx("span",{style:{fontSize:"10px",color:t.bim("desc-fg"),transition:"transform 0.2s",transform:a?"rotate(90deg)":"none"},children:"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:g.source||u.editor.unnamedSource}),g.source_bid&&e.jsx("span",{style:{fontSize:"11px",color:t.bim("desc-fg")},children:g.source_bid}),e.jsx("button",{onClick:i=>{i.stopPropagation(),y(l)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${t.bim("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:t.bim("muted")},children:"✕"})]}),!a&&s&&(g.title_info||g.author_info)&&e.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:t.bim("desc-fg")},children:[g.title_info,g.title_info&&g.author_info&&" — ",g.author_info]}),a&&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(t.FormInput,{label:u.label.sourceName,value:g.source,onChange:i=>x(l,"source",i)}),e.jsx(t.FormInput,{label:u.label.sourceBid,value:g.source_bid||"",onChange:i=>x(l,"source_bid",i)})]}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsx(t.FormInput,{label:u.label.titleInfo,value:g.title_info||"",onChange:i=>x(l,"title_info",i)}),e.jsx(t.FormInput,{label:u.label.authorInfo,value:g.author_info||"",onChange:i=>x(l,"author_info",i)})]}),e.jsx(t.FormInput,{label:u.label.edition,value:g.edition||"",onChange:i=>x(l,"edition",i)})]}),e.jsx(t.FormTextArea,{value:g.summary||"",onChange:i=>x(l,"summary",i),placeholder:u.editor.summaryPlaceholder}),e.jsx(t.FormTextArea,{value:g.comment||"",onChange:i=>x(l,"comment",i),placeholder:u.editor.commentPlaceholder}),e.jsx(t.FormTextArea,{value:g.additional_comment||"",onChange:i=>x(l,"additional_comment",i),placeholder:u.editor.additionalCommentPlaceholder})]})]},l)}),e.jsx("button",{onClick:v,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${t.bim("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:t.bim("desc-fg"),alignSelf:"flex-start"},children:o})]})}function jt({items:n,onChange:r}){const s=t.useT();return e.jsx(ve,{items:n,onChange:r,showMeta:!0,addLabel:s.action.addIndexedBy})}function kt({items:n,onChange:r}){const s=t.useT();return e.jsx(ve,{items:n,onChange:r,addLabel:s.action.addEmendatedBy})}exports.CreateEntityDialog=me;exports.EntityPickerDialog=ke;exports.EntitySelector=fe;exports.IndexEditor=ft;exports.RelationPanel=he;exports.ResourceEditor=D;exports.SmartBidInput=Q;exports.SourceEditor=ue;exports.parseSourceString=be;exports.stringifySources=ge;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),f=require("react"),t=require("./Badge-DYhcDQxi.cjs");require("opencc-js/t2cn");function Ye(n){if(!n)return"";try{const r=new URL(n).hostname,s={"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(s[r])return s[r];const o=r.split(".");return o.length>=2?o[o.length-2]:r}catch{return""}}function ie(n){return n==="text+image"?["text","image"]:[n]}function le(n){const r=t.getResourceTypes(n);return r.length===0?"text":t.getCombinedTypeKey(r)}function Ae(){return{id:"",name:"",url:"",types:["text"],details:""}}const D=({items:n,onChange:r,onDownload:s,downloadStatuses:o,filterType:u})=>{const p=t.useT(),[m,x]=f.useState(null),y=[{value:"text",label:p.resourceTypeShort.text},{value:"image",label:p.resourceTypeShort.image},{value:"text+image",label:p.resourceTypeShort.textImage},{value:"physical",label:p.resourceTypeShort.physical}],v=[{value:"catalog",label:p.rootType.catalog},{value:"search",label:p.rootType.search}],g=b=>{if(!u)return!0;const j=t.getResourceTypes(b);return u==="text"?j.includes("text"):u==="image"?j.includes("image")||j.includes("physical"):u==="physical"?j.includes("physical"):j.includes(u)},l=n.map((b,j)=>({item:b,originalIndex:j})).filter(({item:b})=>g(b)),a=()=>{const b=Ae();u&&(b.types=ie(u)),r([...n,b]),x(n.length)},i=b=>{r(n.filter((j,w)=>w!==b)),x(null)},k=(b,j,w)=>{const I=[...n];if(I[b]={...I[b],[j]:w},j==="url"&&!I[b].id){const S=Ye(w);S&&(I[b].id=S)}r(I)},C=(b,j)=>{const w=[...n],{type:I,...S}=w[b];w[b]={...S,types:ie(j)},r(w)},d=(b,j,w)=>{const S={...n[b].metadata||{}};w?S[j]=w:delete S[j],k(b,"metadata",Object.keys(S).length>0?S:void 0)},_=(b,j)=>{const w=j.trim()?j.split(/[,,、]/).map(I=>I.trim()).filter(Boolean):void 0;k(b,"structure",w)},T=(b,j,w)=>{const S=n[b].coverage||{level:1,ranges:""};j==="level"?S.level=parseInt(w)||1:S.ranges=w,k(b,"coverage",S.ranges?S:void 0)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[l.map(({item:b,originalIndex:j})=>{var w,I,S;return e.jsxs("div",{style:{border:`1px solid ${t.bim("widget-border")}`,borderRadius:"4px",background:t.bim("input-bg"),overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>x(m===j?null:j),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:m===j?"▼":"▶"}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:Ve(le(b)),color:t.bim("on-color-fg")},children:(()=>{var $,F;const h=t.getResourceTypes(b);return h.length===0?"text":h.length===1?(($=y.find(E=>E.value===h[0]))==null?void 0:$.label)??h[0]:h.includes("text")&&h.includes("image")?((F=y.find(E=>E.value==="text+image"))==null?void 0:F.label)??"text+image":h.join("+")})()}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:b.name||`${p.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:h=>h.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),s&&b.url&&Ne(j,o==null?void 0:o[j],s,p),e.jsx("button",{onClick:h=>{h.stopPropagation(),i(j)},style:{background:"transparent",border:"none",color:t.bim("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:p.editor.deleteThisResource,children:"✕"})]}),m===j&&e.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${t.bim("widget-border")}`},children:[t.hasResourceType(b,"image")&&b.url&&He(b,p),e.jsxs("div",{style:{display:"grid",gap:"8px"},children:[e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:A,children:[e.jsx("span",{style:V,children:p.label.type}),e.jsx("select",{value:le(b),onChange:h=>C(j,h.target.value),style:{...L,flex:1},children:y.map(h=>e.jsx("option",{value:h.value,children:h.label},h.value))})]}),e.jsxs("label",{style:A,children:[e.jsx("span",{style:V,children:p.label.rootType}),e.jsx("select",{value:b.root_type||"catalog",onChange:h=>k(j,"root_type",h.target.value),style:{...L,flex:1},children:v.map(h=>e.jsx("option",{value:h.value,children:h.label},h.value))})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("input",{type:"text",value:b.id,onChange:h=>k(j,"id",h.target.value),placeholder:p.editor.idAutoExtract,style:{...L,width:"140px",flexShrink:0}}),e.jsx("input",{type:"text",value:b.name,onChange:h=>k(j,"name",h.target.value),placeholder:p.editor.resourceName,style:{...L,flex:1}})]}),e.jsx("input",{type:"text",value:b.url,onChange:h=>k(j,"url",h.target.value),placeholder:p.editor.resourceUrl,style:L}),e.jsx("input",{type:"text",value:((w=b.structure)==null?void 0:w.join("、"))||"",onChange:h=>_(j,h.target.value),placeholder:p.editor.structurePlaceholder,style:L}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:A,children:[e.jsx("span",{style:V,children:p.label.coverageLevel}),e.jsx("input",{type:"number",min:1,value:((I=b.coverage)==null?void 0:I.level)??"",onChange:h=>T(j,"level",h.target.value),placeholder:"1",style:{...L,width:"60px"}})]}),e.jsxs("label",{style:{...A,flex:1},children:[e.jsx("span",{style:V,children:p.label.coverageRange}),e.jsx("input",{type:"text",value:((S=b.coverage)==null?void 0:S.ranges)||"",onChange:h=>T(j,"ranges",h.target.value),placeholder:p.editor.coverageRangePlaceholder,style:{...L,flex:1}})]})]}),e.jsx("textarea",{value:b.details||"",onChange:h=>k(j,"details",h.target.value),placeholder:p.editor.detailsPlaceholder,style:{...L,minHeight:"60px",resize:"vertical"}}),e.jsxs("div",{style:{borderTop:`1px solid ${t.bim("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[e.jsx("div",{style:{fontSize:"12px",color:t.bim("desc-fg"),marginBottom:"6px"},children:p.label.metadata}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(p.metadata).map(([h,$])=>{var F;return e.jsxs("label",{style:{...A,gap:"4px"},children:[e.jsx("span",{style:{...V,minWidth:"56px"},children:$}),e.jsx("input",{type:"text",value:((F=b.metadata)==null?void 0:F[h])||"",onChange:E=>d(j,h,E.target.value),placeholder:$,style:{...L,flex:1}})]},h)})})]})]})]})]},j)}),e.jsxs("button",{onClick:a,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${t.bim("widget-border")}`,borderRadius:"4px",background:"transparent",color:t.bim("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[e.jsx("span",{children:"+"}),e.jsx("span",{children:p.action.addResource})]})]})};function Ve(n){switch(n){case"text":return t.bim("restype-text");case"image":return t.bim("restype-image");case"text+image":return t.bim("restype-text-image");case"physical":return t.bim("restype-physical")}}function Ne(n,r,s,o){const u=(r==null?void 0:r.status)==="downloading",p=(r==null?void 0:r.status)==="completed";return e.jsx("button",{onClick:m=>{m.stopPropagation(),u||s(n,"")},disabled:u,style:{background:"transparent",border:"none",color:p?t.bim("success"):u?t.bim("desc-fg"):t.bim("link-fg"),cursor:u?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:u?.6:.9},title:p?o.download.completed:u?`${o.download.downloading} ${(r==null?void 0:r.progress)||0}%`:o.download.downloadThis,children:p?"✓":u?"⏳":"⬇"})}function He(n,r){const s=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(n.url)||n.url.includes("iiif")||n.url.includes("image");return e.jsx("div",{style:{marginBottom:"12px"},children:s?e.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:t.bim("overlay-bg")},children:e.jsx("img",{src:n.url,alt:n.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:o=>{o.target.style.display="none"}})}):e.jsx("div",{style:{padding:"12px",background:t.bim("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:t.bim("desc-fg")},children:r.editor.imageResourceLink})})}const L={width:"100%",padding:"6px 8px",background:t.bim("input-bg"),color:t.bim("input-fg"),border:`1px solid ${t.bim("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},A={display:"flex",alignItems:"center",gap:"6px"},V={fontSize:"12px",color:t.bim("desc-fg"),whiteSpace:"nowrap"};function Qe(n){const r=n.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return r?{name:r[1],id:r[2]}:null}const Q=({value:n,onChange:r,label:s})=>{const[o,u]=f.useState(!1),p=f.useRef(null),m=Qe(n||"");return f.useEffect(()=>{o&&p.current&&p.current.focus()},[o]),!o&&m?e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:re,children:s}),e.jsxs("div",{onClick:()=>u(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:`1px solid ${t.bim("input-border")}`,borderRadius:"2px",background:t.bim("input-bg"),cursor:"pointer",minHeight:"30px"},children:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:t.bim("fg")},children:m.name}),e.jsx(t.Badge,{children:m.id})]})]}):e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:re,children:s}),e.jsx("input",{ref:p,type:"text",value:n||"",onChange:x=>r(x.target.value),onBlur:()=>u(!1),style:{width:"100%",padding:"6px 8px",background:t.bim("input-bg"),color:t.bim("input-fg"),border:`1px solid ${t.bim("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},re={display:"block",fontSize:"11px",color:t.bim("desc-fg"),marginBottom:"4px",fontWeight:500};function Ke(n){switch(n){case"url":return t.bim("source-url");case"bookID":return t.bim("source-bookid");default:return t.bim("desc-fg")}}function qe(n){switch(n){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const ue=({items:n,onChange:r,onOpenEntityPicker:s})=>{const o=t.useT(),[u,p]=f.useState(null),m=()=>{r([...n,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),p(n.length)},x=l=>{r(n.filter((a,i)=>i!==l)),u===l&&p(null)},y=(l,a,i)=>{const k=[...n];k[l]={...k[l],[a]:i},r(k)},v=(l,a)=>{const i=[...n];i[l]={...i[l],type:a,id:"",name:""},r(i),a==="bookID"&&s&&s(k=>{const C=[...n];C[l]={...C[l],id:k.id,name:k.title,type:"bookID"},r(C)})},g=l=>{s&&s(a=>{const i=[...n];i[l]={...i[l],id:a.id,name:a.title,type:"bookID"},r(i)})};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[n.map((l,a)=>e.jsxs("div",{style:{border:`1px solid ${t.bim("widget-border")}`,borderRadius:"4px",background:t.bim("input-bg"),overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>p(u===a?null:a),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:u===a?"▼":"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:t.bim("fg")},children:l.name||`${o.editor.sourcePlaceholder} ${a+1}`}),l.type&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:Ke(l.type),color:t.bim("on-color-fg"),borderRadius:"3px",fontWeight:500},children:qe(l.type)}),e.jsx("button",{onClick:i=>{i.stopPropagation(),x(a)},style:{background:"transparent",border:"none",color:t.bim("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:o.editor.deleteThisSource,children:"✕"})]}),u===a&&e.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${t.bim("widget-border")}`},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!l.type&&e.jsxs("div",{children:[e.jsx("label",{style:W,children:o.editor.selectSourceType}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsxs("button",{onClick:()=>v(a,"bookID"),style:{...se,borderColor:t.bim("source-bookid"),color:t.bim("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:o.editor.fromExistingBook})]}),e.jsxs("button",{onClick:()=>v(a,"url"),style:{...se,borderColor:t.bim("source-url"),color:t.bim("source-url")},children:[e.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),e.jsx("span",{children:"URL"}),e.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.enterUrl})]})]})]}),l.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:W,children:o.action.selectBookOrWork}),e.jsx("button",{onClick:()=>{const i=[...n];i[a]={...i[a],type:"",id:"",name:""},r(i)},style:de,children:o.action.changeType})]}),l.id&&l.name?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:t.bim("bg"),border:`1px solid ${t.bim("source-bookid")}`,borderRadius:"6px"},children:[e.jsx("span",{style:{color:t.bim("source-bookid"),fontSize:"16px"},children:"✓"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:l.name}),e.jsx("code",{style:{fontSize:"11px",background:t.bim("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:l.id})]}),e.jsx("button",{onClick:()=>g(a),style:{background:"transparent",border:`1px solid ${t.bim("widget-border")}`,color:t.bim("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:o.action.reselect})]}):e.jsxs("button",{onClick:()=>g(a),style:{width:"100%",padding:"14px",border:`2px dashed ${t.bim("widget-border")}`,borderRadius:"6px",background:"transparent",color:t.bim("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[e.jsx("span",{children:"🔍"}),e.jsx("span",{children:o.action.clickToSelectBookOrWork})]})]})}),l.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:W,children:o.label.sourceName}),e.jsx("button",{onClick:()=>{const i=[...n];i[a]={...i[a],type:"",id:"",name:""},r(i)},style:de,children:o.action.changeType})]}),e.jsx("input",{type:"text",value:l.name,onChange:i=>y(a,"name",i.target.value),placeholder:o.editor.sourceNamePlaceholder,style:M})]}),e.jsxs("div",{children:[e.jsx("label",{style:W,children:o.label.urlAddress}),e.jsx("input",{type:"text",value:l.id,onChange:i=>y(a,"id",i.target.value),placeholder:"https://...",style:M})]})]}),l.type&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{borderTop:`1px dashed ${t.bim("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:e.jsx("label",{style:{...W,opacity:.7},children:o.label.optionalInfo})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:W,children:o.label.detailsOptional}),e.jsx("input",{type:"text",value:l.details,onChange:i=>y(a,"details",i.target.value),placeholder:o.editor.detailsPlaceholder,style:M})]}),e.jsxs("div",{children:[e.jsx("label",{style:W,children:o.label.positionOptional}),e.jsx("input",{type:"text",value:l.position,onChange:i=>y(a,"position",i.target.value),placeholder:"如: 卷三, p.52",style:M})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:W,children:o.label.dataVersionOptional}),e.jsx("input",{type:"text",value:l.version,onChange:i=>y(a,"version",i.target.value),placeholder:"如: v1.0, 2024-01",style:M})]}),e.jsxs("div",{children:[e.jsx("label",{style:W,children:o.label.processorVersionOptional}),e.jsx("input",{type:"text",value:l.processor_version,onChange:i=>y(a,"processor_version",i.target.value),placeholder:"如: v0.1",style:M})]})]})]})]})})]},a)),e.jsxs("button",{onClick:m,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${t.bim("widget-border")}`,borderRadius:"4px",background:"transparent",color:t.bim("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[e.jsx("span",{children:"+"}),e.jsx("span",{children:o.action.addSource})]})]})},W={display:"block",fontSize:"11px",color:t.bim("desc-fg"),marginBottom:"4px",fontWeight:500},M={width:"100%",padding:"6px 8px",background:t.bim("input-bg"),color:t.bim("input-fg"),border:`1px solid ${t.bim("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},se={flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",padding:"16px 12px",background:t.bim("bg"),border:"2px solid",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:500,transition:"all 0.2s"},de={background:"transparent",border:"none",color:t.bim("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function be(n){if(!n||!n.trim())return[];try{const r=JSON.parse(n);if(Array.isArray(r))return r.map(s=>({id:s.id||"",name:s.name||"",type:s.type||"",details:s.details||"",position:s.position||"",version:s.version||"",processor_version:s.processor_version||""}))}catch{}return[]}function ge(n){return!n||n.length===0?"":JSON.stringify(n)}const he=({entityType:n,entityId:r,entityTitle:s,parentWork:o,parentCollection:u,belongsToWork:p,belongsToCollection:m,childWorks:x,childCollections:y,containedBooks:v,siblingBooks:g,onLinkEntity:l,onUnlinkEntity:a,onViewEntity:i,onCreateAndLink:k,onSaveRelations:C})=>{const d=t.useT();return e.jsxs("div",{style:{background:t.bim("bg"),border:`1px solid ${t.bim("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[e.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:`1px solid ${t.bim("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:d.section.relations})]}),C&&e.jsx("button",{onClick:C,style:Je,children:d.action.save})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[n==="book"&&e.jsxs(e.Fragment,{children:[e.jsx(N,{direction:"up",title:d.relation.belongsToWork,entity:p,onView:i,onUnlink:()=>a("workId"),onLink:()=>l("workId","work"),onCreate:()=>k("workId","work",{title:s}),linkLabel:d.action.linkExisting,createLabel:d.action.createAndLink,notLinkedLabel:d.relation.notLinked,viewLabel:d.action.viewEntity,unlinkLabel:d.action.unlink}),e.jsx(N,{direction:"up",title:d.relation.containedInCollection,entity:m,onView:i,onUnlink:()=>a("collectionId"),onLink:()=>l("collectionId","collection"),onCreate:()=>k("collectionId","collection",{title:s}),linkLabel:d.action.linkExisting,createLabel:d.action.createAndLink,notLinkedLabel:d.relation.notLinked,viewLabel:d.action.viewEntity,unlinkLabel:d.action.unlink}),p&&g&&g.length>0&&e.jsx(U,{direction:"horizontal",title:`${d.relation.siblingVersions} (${g.length})`,entities:g,onView:i,onAdd:()=>k("siblingBook","book",{workId:p.id}),addLabel:d.relation.addVersionForWork,noneLabel:d.relation.none,expandMoreLabel:d.action.expandMore})]}),n==="work"&&e.jsxs(e.Fragment,{children:[e.jsx(N,{direction:"up",title:d.relation.parentWork,entity:o,onView:i,onUnlink:()=>a("parentWorkId"),onLink:()=>l("parentWorkId","work"),onCreate:()=>k("parentWorkId","work"),linkLabel:d.action.linkExisting,createLabel:d.action.createAndLink,notLinkedLabel:d.relation.notLinked,viewLabel:d.action.viewEntity,unlinkLabel:d.action.unlink}),x&&x.length>0&&e.jsx(U,{direction:"down",title:`${d.relation.childWorks} (${x.length})`,entities:x,onView:i,onAdd:()=>k("childWork","work",{parentWorkId:r}),addLabel:d.action.addSubWork,noneLabel:d.relation.none,expandMoreLabel:d.action.expandMore}),y&&y.length>0&&e.jsx(U,{direction:"down",title:`${d.relation.collectionImpl} (${y.length})`,entities:y,onView:i,onAdd:()=>k("childCollection","collection",{workId:r}),addLabel:d.action.addCollectionImpl,noneLabel:d.relation.none,expandMoreLabel:d.action.expandMore}),e.jsx(U,{direction:"down",title:`${d.relation.allVersions} (${(v==null?void 0:v.length)??0})`,entities:v||[],onView:i,onAdd:()=>k("childBook","book",{workId:r}),addLabel:d.action.addVersion,noneLabel:d.relation.none,expandMoreLabel:d.action.expandMore})]}),n==="collection"&&e.jsxs(e.Fragment,{children:[e.jsx(N,{direction:"up",title:d.relation.correspondingWork,entity:p,onView:i,onUnlink:()=>a("workId"),onLink:()=>l("workId","work"),onCreate:()=>k("workId","work",{title:s}),linkLabel:d.action.linkExisting,createLabel:d.action.createAndLink,notLinkedLabel:d.relation.notLinked,viewLabel:d.action.viewEntity,unlinkLabel:d.action.unlink}),e.jsx(N,{direction:"up",title:d.relation.parentCollection,entity:u,onView:i,onUnlink:()=>a("parentCollectionId"),onLink:()=>l("parentCollectionId","collection"),onCreate:()=>k("parentCollectionId","collection"),linkLabel:d.action.linkExisting,createLabel:d.action.createAndLink,notLinkedLabel:d.relation.notLinked,viewLabel:d.action.viewEntity,unlinkLabel:d.action.unlink}),e.jsx(U,{direction:"down",title:`${d.relation.childCollections} (${(y==null?void 0:y.length)??0})`,entities:y||[],onView:i,onAdd:()=>k("childCollection","collection",{parentCollectionId:r}),addLabel:d.action.addSubCollection,noneLabel:d.relation.none,expandMoreLabel:d.action.expandMore}),e.jsx(U,{direction:"down",title:`${d.relation.containedBooks} (${(v==null?void 0:v.length)??0})`,entities:v||[],onView:i,onAdd:()=>k("childBook","book",{collectionId:r}),addLabel:d.action.addBook,noneLabel:d.relation.none,expandMoreLabel:d.action.expandMore})]})]})]})},N=({direction:n,title:r,entity:s,onView:o,onUnlink:u,onLink:p,onCreate:m,linkLabel:x,createLabel:y,notLinkedLabel:v,viewLabel:g,unlinkLabel:l})=>{const a=n==="up"?t.bim("relation-up"):n==="down"?t.bim("relation-down"):t.bim("relation-flat"),i=n==="up"?"⬆️":n==="down"?"⬇️":"↔️";return e.jsxs("div",{style:{border:`1px solid ${t.bim("widget-border")}`,borderRadius:"4px",padding:"10px",background:t.bim("input-bg")},children:[e.jsxs("div",{style:{fontSize:"12px",color:a,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:i}),e.jsx("span",{children:r})]}),s?e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:t.bim("bg"),borderRadius:"4px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:ye(s.type)}),e.jsx("span",{style:{fontWeight:500},children:s.title}),e.jsx("span",{style:{fontSize:"11px",opacity:.6},children:s.id})]}),e.jsxs("div",{style:{display:"flex",gap:"4px"},children:[e.jsx(ae,{onClick:()=>o(s),title:g,children:"👁️"}),e.jsx(ae,{onClick:u,title:l,danger:!0,children:"✕"})]})]}):e.jsx("div",{style:{padding:"8px",background:t.bim("bg"),borderRadius:"4px",color:t.bim("desc-fg"),fontSize:"12px",textAlign:"center"},children:v}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsx(ee,{onClick:p,children:x}),e.jsx(ee,{onClick:m,primary:!0,children:y})]})]})},U=({direction:n,title:r,entities:s,onView:o,onAdd:u,addLabel:p,noneLabel:m,expandMoreLabel:x})=>{const[y,v]=f.useState(!1),g=n==="up"?t.bim("relation-up"):n==="down"?t.bim("relation-down"):t.bim("relation-flat"),l=n==="up"?"⬆️":n==="down"?"⬇️":"↔️",a=y?s:s.slice(0,5);return e.jsxs("div",{style:{border:`1px solid ${t.bim("widget-border")}`,borderRadius:"4px",padding:"10px",background:t.bim("input-bg")},children:[e.jsxs("div",{style:{fontSize:"12px",color:g,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:l}),e.jsx("span",{children:r})]}),s.length>0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[a.map(i=>e.jsxs("div",{onClick:()=>o(i),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:t.bim("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[e.jsx("span",{children:ye(i.type)}),e.jsx("span",{children:i.title})]},i.id)),s.length>5&&!y&&e.jsxs("div",{onClick:()=>v(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:t.bim("link-fg"),cursor:"pointer"},children:[x," (",s.length-5,")"]})]}):e.jsx("div",{style:{padding:"8px",background:t.bim("bg"),borderRadius:"4px",color:t.bim("desc-fg"),fontSize:"12px",textAlign:"center"},children:m}),e.jsx("div",{style:{marginTop:"8px"},children:e.jsxs(ee,{onClick:u,primary:!0,children:["+ ",p]})})]})},ae=({onClick:n,title:r,danger:s,children:o})=>e.jsx("button",{onClick:u=>{u.stopPropagation(),n()},title:r,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:s?t.bim("danger"):"inherit",opacity:.7},children:o}),ee=({onClick:n,primary:r,children:s})=>e.jsx("button",{onClick:n,style:{padding:"4px 10px",fontSize:"11px",border:r?"none":`1px solid ${t.bim("widget-border")}`,borderRadius:"4px",background:r?t.bim("primary"):"transparent",color:r?t.bim("primary-fg"):"inherit",cursor:"pointer"},children:s});function ye(n){switch(n){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const Je={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:t.bim("primary"),color:t.bim("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},fe=({isOpen:n,entityType:r,title:s,onSelect:o,onCancel:u,onCreate:p,searchResults:m,onSearch:x,isLoading:y,excludeId:v})=>{const[g,l]=f.useState(""),a=v?m.filter(d=>d.id!==v):m;f.useEffect(()=>{n&&(l(""),x(""))},[n]);const i=d=>{l(d),x(d)};if(!n)return null;const k=r==="work"?"作品":r==="book"?"书籍":"丛编",C=r==="work"?"📜":r==="book"?"📖":"📚";return e.jsx("div",{style:Ze,children:e.jsxs("div",{style:Ge,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${t.bim("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:s}),e.jsx("button",{onClick:u,style:Xe,children:"✕"})]}),e.jsx("div",{style:{padding:"12px 16px"},children:e.jsx("input",{type:"text",value:g,onChange:d=>i(d.target.value),placeholder:`搜索${k}名称或 ID...`,autoFocus:!0,style:De})}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:y?e.jsx("div",{style:G,children:"搜索中..."}):a.length>0?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:a.map(d=>e.jsxs("div",{onClick:()=>o(d),style:et,children:[e.jsx("span",{style:{fontSize:"16px"},children:C}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontWeight:500},children:[d.title,d.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:d.edition})]}),e.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[d.id,d.author&&` · ${d.author}`,d.dynasty&&` · ${d.dynasty}`]})]})]},d.id))}):g?e.jsxs("div",{style:G,children:["未找到匹配的",k]}):e.jsxs("div",{style:G,children:["输入关键词搜索",k]})}),e.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${t.bim("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),e.jsxs("button",{onClick:p,style:tt,children:["创建新",k,"并关联"]})]})]})})},Ze={position:"fixed",top:0,left:0,right:0,bottom:0,background:t.bim("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Ge={background:t.bim("bg"),border:`1px solid ${t.bim("widget-border")}`,borderRadius:"8px",width:"500px",maxWidth:"calc(100vw - 32px)",maxHeight:"70vh",display:"flex",flexDirection:"column",boxShadow:t.bim("shadow-dialog")},Xe={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},De={width:"100%",padding:"10px 12px",border:`1px solid ${t.bim("input-border")}`,borderRadius:"4px",background:t.bim("input-bg"),color:t.bim("input-fg"),fontSize:"13px",boxSizing:"border-box"},et={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:t.bim("primary-soft")},G={padding:"20px",textAlign:"center",color:t.bim("desc-fg")},tt={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:t.bim("primary"),color:t.bim("primary-fg"),cursor:"pointer"},ce={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},nt={work:"📜",book:"📖",collection:"📚",entity:"👤"},me=({isOpen:n,entityType:r,relationField:s,inheritData:o,onConfirm:u,onCancel:p})=>{const[m,x]=f.useState(""),y=f.useRef(null);f.useEffect(()=>{n&&(x((o==null?void 0:o.title)||""),setTimeout(()=>{var a,i;(a=y.current)==null||a.focus(),(i=y.current)==null||i.select()},100))},[n,o==null?void 0:o.title]);const v=a=>{a.key==="Enter"&&m.trim()?g():a.key==="Escape"&&p()},g=()=>{m.trim()&&u(m.trim(),{...o,title:m.trim()})};if(!n)return null;const l=()=>{switch(s){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`创建新${ce[r]}`}};return e.jsx("div",{style:ot,onClick:a=>{a.target===a.currentTarget&&p()},children:e.jsxs("div",{style:it,onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:nt[r]}),e.jsx("span",{children:l()})]}),e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:t.bim("fg")},children:[r==="work"?"作品名":r==="collection"?"丛编名":"书名",e.jsx("span",{style:{color:t.bim("danger"),marginLeft:"4px"},children:"*"})]}),e.jsx("input",{ref:y,type:"text",value:m,onChange:a=>x(a.target.value),onKeyDown:v,placeholder:`请输入${ce[r]}名称...`,style:lt})]}),((o==null?void 0:o.author)||(o==null?void 0:o.dynasty))&&e.jsxs("div",{style:{fontSize:"12px",color:t.bim("desc-fg"),background:t.bim("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[e.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(o==null?void 0:o.author)&&e.jsxs("div",{children:["作者: ",o.author]}),(o==null?void 0:o.dynasty)&&e.jsxs("div",{children:["朝代/年份: ",o.dynasty]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[e.jsx("button",{onClick:p,style:rt,children:"取消"}),e.jsx("button",{onClick:g,disabled:!m.trim(),style:{...st,opacity:m.trim()?1:.6,cursor:m.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},ot={position:"fixed",top:0,left:0,right:0,bottom:0,background:t.bim("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},it={background:t.bim("bg"),border:`1px solid ${t.bim("widget-border")}`,borderRadius:"8px",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:t.bim("shadow-dialog")},lt={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${t.bim("input-border")}`,borderRadius:"4px",background:t.bim("input-bg"),color:t.bim("input-fg"),outline:"none",boxSizing:"border-box"},rt={padding:"8px 16px",fontSize:"13px",border:`1px solid ${t.bim("widget-border")}`,borderRadius:"4px",background:"transparent",color:t.bim("fg"),cursor:"pointer"},st={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:t.bim("primary"),color:t.bim("primary-fg")};function dt(n){switch(n){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function je(n){switch(n){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function at(n){switch(n){case"work":return t.bim("editor-type-work");case"collection":return t.bim("editor-type-collection");case"book":return t.bim("editor-type-book");default:return t.bim("desc-fg")}}const ke=({isOpen:n,title:r,filterType:s="all",recentEntities:o=[],excludeId:u,showCreateButton:p=!1,createButtonText:m,onSelect:x,onCancel:y,onCreate:v,onSearch:g})=>{const[l,a]=f.useState(""),[i,k]=f.useState([]),[C,d]=f.useState(!1),[_,T]=f.useState("recent");f.useEffect(()=>{n&&(a(""),k([]),T(o.length>0?"recent":"search"))},[n,o.length]),f.useEffect(()=>{if(!l.trim()){k([]);return}const h=setTimeout(async()=>{d(!0);try{k(await g(l,s))}catch{k([])}finally{d(!1)}},300);return()=>clearTimeout(h)},[l,s,g]);const b=f.useCallback(h=>{a(h.target.value),h.target.value.trim()&&T("search")},[]),j=f.useCallback(h=>u?h.filter($=>$.id!==u):h,[u]);if(!n)return null;const w=r||(s==="all"?"选择实体":`选择${je(s)}`),I=j(o),S=j(i);return e.jsx("div",{style:pt,children:e.jsxs("div",{style:xt,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${t.bim("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:w}),e.jsx("button",{onClick:y,style:ut,children:"✕"})]}),e.jsx("div",{style:{padding:"16px 20px 12px"},children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{type:"text",value:l,onChange:b,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:bt}),e.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),C&&e.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),I.length>0&&e.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${t.bim("widget-border")}`},children:[e.jsxs(pe,{active:_==="recent",onClick:()=>T("recent"),children:["最近使用 (",I.length,")"]}),e.jsxs(pe,{active:_==="search",onClick:()=>T("search"),children:["搜索结果 ",S.length>0&&`(${S.length})`]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:_==="recent"&&I.length>0?e.jsx(xe,{entities:I,onSelect:x}):l.trim()?C?e.jsx(X,{message:"搜索中..."}):S.length>0?e.jsx(xe,{entities:S,onSelect:x}):e.jsx(X,{message:"未找到匹配的结果"}):e.jsx(X,{message:"输入关键词开始搜索"})}),p&&v&&e.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${t.bim("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),e.jsx("button",{onClick:v,style:gt,children:m||"创建新实体"})]})]})})},pe=({active:n,onClick:r,children:s})=>e.jsx("button",{onClick:r,style:{padding:"10px 16px",border:"none",borderBottom:n?`2px solid ${t.bim("primary")}`:"2px solid transparent",background:"transparent",color:n?t.bim("fg"):t.bim("desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:n?600:400,marginBottom:"-1px"},children:s}),xe=({entities:n,onSelect:r})=>e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:n.map(s=>e.jsx(ct,{entity:s,onClick:()=>r(s)},s.id))}),ct=({entity:n,onClick:r})=>{const[s,o]=f.useState(!1);return e.jsxs("div",{onClick:r,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:t.bim("primary-soft"),transition:"background 0.1s"},children:[e.jsx("span",{style:{fontSize:"18px"},children:dt(n.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:[n.title,n.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:t.bim("desc-fg"),marginLeft:"4px"},children:n.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:t.bim("primary-soft"),padding:"1px 4px",borderRadius:"2px"},children:n.id}),n.author&&e.jsx("span",{children:n.author}),n.dynasty&&e.jsx("span",{children:n.dynasty})]})]}),e.jsx("span",{style:{fontSize:"10px",padding:"3px 8px",background:at(n.type),color:t.bim("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:je(n.type)})]})},X=({message:n})=>e.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:t.bim("desc-fg"),fontSize:"13px"},children:n}),pt={position:"fixed",top:0,left:0,right:0,bottom:0,background:t.bim("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},xt={background:t.bim("bg"),border:`1px solid ${t.bim("widget-border")}`,borderRadius:"8px",width:"550px",maxWidth:"calc(100vw - 32px)",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:t.bim("shadow-dialog")},ut={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},bt={width:"100%",padding:"12px 16px",paddingLeft:"40px",border:`1px solid ${t.bim("input-border")}`,borderRadius:"6px",background:t.bim("input-bg"),color:t.bim("input-fg"),fontSize:"13px",boxSizing:"border-box"},gt={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:t.bim("primary"),color:t.bim("primary-fg"),cursor:"pointer"},ht={work:t.bim("editor-type-work"),collection:t.bim("editor-type-collection"),book:t.bim("editor-type-book"),entity:t.bim("editor-type-entity")},yt={work:"📜",collection:"📚",book:"📖",entity:"👤"},ft=({data:n,onChange:r,onSave:s,transport:o,onNavigate:u,showDelete:p,onDelete:m,onAskAI:x,renderSectionActions:y,onDownloadResource:v,downloadStatuses:g,relations:l,onRelationsChange:a})=>{var oe;const i=t.useT(),[k,C]=f.useState(!1),[d,_]=f.useState("work"),[T,b]=f.useState(""),[j,w]=f.useState(""),[I,S]=f.useState([]),[h,$]=f.useState(!1),[F,E]=f.useState(!1),[K,Se]=f.useState("work"),[q,we]=f.useState(""),[Ce,Ie]=f.useState(),[ze,J]=f.useState(!1),[H,Z]=f.useState(null),[Re,te]=f.useState([]);f.useRef(null);const P=n.type,Te=P==="work",Y=P==="collection",O=P==="book",z=f.useCallback((c,R)=>{r({...n,[c]:R})},[n,r]),$e=f.useCallback((c,R)=>{b(c),_(R),w(i.editor.selectToLink+i.indexType[R]),S([]),C(!0)},[i]),Le=f.useCallback(c=>{o!=null&&o.unlinkEntity&&o.unlinkEntity(n.id,c)},[o,n.id]),Ee=f.useCallback(c=>{u==null||u(c.id,c.type)},[u]),ne=f.useCallback((c,R,B)=>{const Ue={...B,author:(B==null?void 0:B.author)||n.author,dynasty:B==null?void 0:B.dynasty};Se(R),we(c),Ie(Ue),E(!0)},[n.author]),Be=f.useCallback((c,R)=>{o!=null&&o.createAndLink&&o.createAndLink(n.id,q,{type:K,title:c,inheritData:R}),E(!1)},[o,n.id,q,K]),We=f.useCallback(c=>{if(!c.trim()){S([]);return}$(!0),o!=null&&o.searchEntities&&o.searchEntities(c,d).then(R=>{S(R),$(!1)}).catch(()=>{S([]),$(!1)})},[o,d]),_e=f.useCallback(c=>{o!=null&&o.linkEntity&&o.linkEntity(n.id,T,c.id),C(!1)},[o,n.id,T]),Fe=f.useCallback(()=>{s()},[s]),Pe=f.useCallback(c=>{Z(()=>c),J(!0),o!=null&&o.getRecentEntities&&o.getRecentEntities().then(te).catch(()=>{})},[o]),Oe=f.useCallback((c,R)=>o!=null&&o.searchEntities?o.searchEntities(c,R==="all"?void 0:R):Promise.resolve([]),[o]),Me=f.useCallback(c=>{o!=null&&o.addRecentEntity&&o.addRecentEntity(c),te(R=>[c,...R.filter(B=>B.id!==c.id)].slice(0,10)),H==null||H(c),J(!1),Z(null)},[o,H]);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 ${t.bim("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:yt[P]}),e.jsx("span",{children:n.title||i.editor.untitled}),e.jsx(t.Badge,{children:n.id}),e.jsx(t.Badge,{color:ht[P],children:i.indexType[P]})]})}),e.jsx(t.Section,{title:i.section.basicInfo,onSave:s,onAskAI:x?()=>x("基本信息"):void 0,extraButtons:y==null?void 0:y("基本信息"),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[e.jsx(Q,{label:Te?i.editor.workTitle:Y?i.editor.collectionTitle:i.editor.bookTitle,value:n.title,onChange:c=>z("title",c)}),O&&e.jsx(Q,{label:i.editor.belongsToWork,value:n.workName||"",onChange:c=>z("workName",c)}),e.jsx(t.FormInput,{label:i.editor.authorLabel,value:n.author||"",onChange:c=>z("author",c)}),e.jsx(t.FormInput,{label:i.editor.publicationYearLabel,value:n.publicationYear||"",onChange:c=>z("publicationYear",c)}),(O||Y)&&e.jsx(Q,{label:i.editor.containedIn,value:n.collection||"",onChange:c=>z("collection",c)}),(O||Y)&&e.jsx(t.FormInput,{label:i.editor.holderLabel,value:n.holder||"",onChange:c=>z("holder",c)}),(O||Y)&&e.jsx(t.FormInput,{label:O?i.editor.pageLabel:i.editor.volumeLabel,value:n.pages||"",onChange:c=>z("pages",c)}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(t.FormInput,{label:i.editor.firstImageLabel,value:n.firstImage||"",onChange:c=>z("firstImage",c)})})]})}),e.jsx(t.Section,{title:i.section.description,onSave:s,onAskAI:x?()=>x("介绍"):void 0,children:e.jsx(t.FormTextArea,{value:n.description||"",onChange:c=>z("description",c),placeholder:i.editor.descriptionPlaceholder})}),(((oe=n.additional_works)==null?void 0:oe.length)||0)>0&&e.jsx(t.Section,{title:i.section.additionalWorks,onSave:s,children:e.jsx(mt,{items:n.additional_works||[],onChange:c=>z("additional_works",c)})}),e.jsx(t.Section,{title:i.section.indexedBy,onSave:s,onAskAI:x?()=>x("收录于"):void 0,children:e.jsx(jt,{items:n.indexed_by||[],onChange:c=>z("indexed_by",c)})}),e.jsx(t.Section,{title:i.section.emendatedBy,onSave:s,onAskAI:x?()=>x("考证"):void 0,children:e.jsx(kt,{items:n.emendated_by||[],onChange:c=>z("emendated_by",c)})}),e.jsx(t.Section,{title:i.section.textResources,onSave:s,onAskAI:x?()=>x("资源"):void 0,children:e.jsx(D,{items:n.resources||[],onChange:c=>z("resources",c),onDownload:v,downloadStatuses:g,filterType:"text"})}),e.jsx(t.Section,{title:i.section.imageResources,onSave:s,children:e.jsx(D,{items:n.resources||[],onChange:c=>z("resources",c),onDownload:v,downloadStatuses:g,filterType:"image"})}),e.jsx(t.Section,{title:i.section.sources,onSave:s,onAskAI:x?()=>x("资料来源"):void 0,children:e.jsx(ue,{items:be(n.sources||""),onChange:c=>z("sources",ge(c)),onOpenEntityPicker:Pe})}),(O||Y)&&e.jsx(t.Section,{title:i.section.provenance,onSave:s,onAskAI:x?()=>x("收藏历史"):void 0,children:e.jsx(t.FormTextArea,{value:n.provenance||"",onChange:c=>z("provenance",c),placeholder:i.editor.provenancePlaceholder})}),O&&e.jsx(t.Section,{title:i.section.otherEditions,onSave:s,onAskAI:x?()=>x("其他版本"):void 0,children:e.jsx(t.FormTextArea,{value:n.otherEditions||"",onChange:c=>z("otherEditions",c),placeholder:i.editor.otherEditionsPlaceholder})}),e.jsx(he,{entityType:P,entityId:n.id,entityTitle:n.title,parentWork:l==null?void 0:l.parentWork,parentCollection:l==null?void 0:l.parentCollection,belongsToWork:l==null?void 0:l.belongsToWork,belongsToCollection:l==null?void 0:l.belongsToCollection,childWorks:l==null?void 0:l.childWorks,childCollections:l==null?void 0:l.childCollections,containedBooks:l==null?void 0:l.containedBooks,siblingBooks:l==null?void 0:l.siblingBooks,onLinkEntity:$e,onUnlinkEntity:Le,onViewEntity:Ee,onCreateAndLink:ne,onSaveRelations:Fe}),p&&m&&e.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${t.bim("danger-soft-border")}`,background:t.bim("danger-soft-bg"),borderRadius:"4px"},children:[e.jsx("div",{style:{color:t.bim("danger"),fontWeight:600,marginBottom:"8px"},children:i.section.dangerZone}),e.jsx("p",{style:{fontSize:"12px",color:t.bim("desc-fg"),marginBottom:"12px"},children:i.editor.dangerZoneDesc}),e.jsx("button",{onClick:m,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${t.bim("danger")}`,borderRadius:"4px",background:"transparent",color:t.bim("danger"),cursor:"pointer"},children:i.editor.deleteEntity})]}),e.jsx(fe,{isOpen:k,entityType:d,title:j,onSelect:_e,onCancel:()=>C(!1),onCreate:()=>{C(!1),ne(T,d)},searchResults:I,onSearch:We,isLoading:h,excludeId:n.id}),e.jsx(me,{isOpen:F,entityType:K,relationField:q,inheritData:Ce,onConfirm:Be,onCancel:()=>E(!1)}),e.jsx(ke,{isOpen:ze,title:i.action.selectBookOrWork,filterType:"all",recentEntities:Re,excludeId:n.id,onSelect:Me,onCancel:()=>{J(!1),Z(null)},onSearch:Oe})]})};function mt({items:n,onChange:r}){const s=t.useT(),o=(m,x,y)=>{const v=n.map((g,l)=>l===m?{...g,[x]:y}:g);r(v)},u=m=>r(n.filter((x,y)=>y!==m)),p=()=>r([...n,{book_title:""}]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[n.map((m,x)=>e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx(t.FormInput,{label:s.editor.bookNameLabel,value:m.book_title,onChange:y=>o(x,"book_title",y)}),e.jsx("div",{style:{width:"100px"},children:e.jsx(t.FormInput,{label:s.label.juanCount,value:m.n_juan!=null?String(m.n_juan):"",onChange:y=>o(x,"n_juan",y&&parseInt(y,10)||void 0)})}),e.jsx("button",{onClick:()=>u(x),style:{padding:"4px 8px",fontSize:"12px",border:`1px solid ${t.bim("widget-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:t.bim("muted"),marginTop:"18px"},children:"✕"})]},x)),e.jsx("button",{onClick:p,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${t.bim("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:t.bim("desc-fg"),alignSelf:"flex-start"},children:s.action.addAdditionalWork})]})}function ve({items:n,onChange:r,showMeta:s,addLabel:o}){const u=t.useT(),[p,m]=f.useState(null),x=(g,l,a)=>{const i=n.map((k,C)=>C===g?{...k,[l]:a||void 0}:k);r(i)},y=g=>{r(n.filter((l,a)=>a!==g)),p===g&&m(null)},v=()=>{r([...n,{source:""}]),m(n.length)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[n.map((g,l)=>{const a=p===l;return e.jsxs("div",{style:{border:`1px solid ${t.bim("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:a?`color-mix(in srgb, ${t.bim("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>m(a?null:l),children:[e.jsx("span",{style:{fontSize:"10px",color:t.bim("desc-fg"),transition:"transform 0.2s",transform:a?"rotate(90deg)":"none"},children:"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:g.source||u.editor.unnamedSource}),g.source_bid&&e.jsx("span",{style:{fontSize:"11px",color:t.bim("desc-fg")},children:g.source_bid}),e.jsx("button",{onClick:i=>{i.stopPropagation(),y(l)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${t.bim("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:t.bim("muted")},children:"✕"})]}),!a&&s&&(g.title_info||g.author_info)&&e.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:t.bim("desc-fg")},children:[g.title_info,g.title_info&&g.author_info&&" — ",g.author_info]}),a&&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(t.FormInput,{label:u.label.sourceName,value:g.source,onChange:i=>x(l,"source",i)}),e.jsx(t.FormInput,{label:u.label.sourceBid,value:g.source_bid||"",onChange:i=>x(l,"source_bid",i)})]}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsx(t.FormInput,{label:u.label.titleInfo,value:g.title_info||"",onChange:i=>x(l,"title_info",i)}),e.jsx(t.FormInput,{label:u.label.authorInfo,value:g.author_info||"",onChange:i=>x(l,"author_info",i)})]}),e.jsx(t.FormInput,{label:u.label.edition,value:g.edition||"",onChange:i=>x(l,"edition",i)})]}),e.jsx(t.FormTextArea,{value:g.summary||"",onChange:i=>x(l,"summary",i),placeholder:u.editor.summaryPlaceholder}),e.jsx(t.FormTextArea,{value:g.comment||"",onChange:i=>x(l,"comment",i),placeholder:u.editor.commentPlaceholder}),e.jsx(t.FormTextArea,{value:g.additional_comment||"",onChange:i=>x(l,"additional_comment",i),placeholder:u.editor.additionalCommentPlaceholder})]})]},l)}),e.jsx("button",{onClick:v,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${t.bim("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:t.bim("desc-fg"),alignSelf:"flex-start"},children:o})]})}function jt({items:n,onChange:r}){const s=t.useT();return e.jsx(ve,{items:n,onChange:r,showMeta:!0,addLabel:s.action.addIndexedBy})}function kt({items:n,onChange:r}){const s=t.useT();return e.jsx(ve,{items:n,onChange:r,addLabel:s.action.addEmendatedBy})}exports.CreateEntityDialog=me;exports.EntityPickerDialog=ke;exports.EntitySelector=fe;exports.IndexEditor=ft;exports.RelationPanel=he;exports.ResourceEditor=D;exports.SmartBidInput=Q;exports.SourceEditor=ue;exports.parseSourceString=be;exports.stringifySources=ge;
package/dist/editor.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsxs as r, jsx as e, Fragment as H } from "react/jsx-runtime";
2
2
  import Ae, { useState as C, useRef as pe, useEffect as q, useCallback as T } from "react";
3
- import { b as t, u as F, g as de, h as Qe, a as Ke, B as ce, S as _, F as B, c as K } from "./Badge-CuDvPqI8.js";
3
+ import { b as t, u as F, g as de, h as Qe, a as Ke, B as ce, S as _, F as B, c as K } from "./Badge-S4yWZQv1.js";
4
4
  import "opencc-js/t2cn";
5
5
  function Je(n) {
6
6
  if (!n) return "";