@akairos/typeset-studio 0.2.4 → 0.2.5
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/README.md +2 -2
- package/dist/assets/{index-C9J0f4Lf.js → index-De-aHsvp.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/lib/adapter.js +1 -1
- package/dist/lib/{index-qhpfzwj4.js → index-h2580xma.js} +1 -1
- package/dist/lib/index.js +1 -1
- package/package.json +1 -1
- package/src/adapter.ts +1 -1
- package/src/server/index.ts +1 -1
- package/src/web/components/Header.tsx +1 -1
package/README.md
CHANGED
|
@@ -162,7 +162,7 @@ npm install @akairos/typeset-studio
|
|
|
162
162
|
### 1. 服务健康检查 (`GET /api/health`)
|
|
163
163
|
```bash
|
|
164
164
|
curl http://localhost:4890/api/health
|
|
165
|
-
# {"status":"ok","name":"Typeset Studio Server","version":"0.2.
|
|
165
|
+
# {"status":"ok","name":"Typeset Studio Server","version":"0.2.5"}
|
|
166
166
|
```
|
|
167
167
|
|
|
168
168
|
### 2. 槽位解析与排版 (`POST /api/render`)
|
|
@@ -359,4 +359,4 @@ zzp render --state /absolute/path/workflow-state.json \
|
|
|
359
359
|
|
|
360
360
|
模板只保存文件或 URL 引用,不嵌入、不自动打包迁移。`/uploads/...` 由实际渲染方的 `TYPESET_DATA_DIR` 解析,本地插件和编辑器应使用同一目录;远程模式使用服务端目录。模板中的绝对路径必须在渲染机器存在,HTTP URL 必须可访问。远程调用会传输任务替换中本地文件的字节,但不会复制原模板素材。缺失固定素材、未知替换标识或重复标识会明确报错,终止出图。
|
|
361
361
|
|
|
362
|
-
|
|
362
|
+
固定素材和模板优先渲染已随 `@akairos/typeset-studio@0.2.5` 发布。正式 Pipeline 使用 npm 入口;本地源码入口仅用于联调未发布的改动。运行时模板和上传图片不打进 npm 包,应通过 Pipeline 运行时配置包同步。
|
|
@@ -289,7 +289,7 @@ Error generating stack: `+n.message+`
|
|
|
289
289
|
*/const Ch={name:"zoom-out",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]};Ch.node;const wp=Ae(Ch),Dp=({isOpen:u,onClose:c,currentKey:o,onSaveKey:r,isVerified:d})=>{const[h,b]=me.useState(o),[v,y]=me.useState(null);if(!u)return null;const m=()=>{r(h.trim()),y("密钥已更新并保存至本地存储"),setTimeout(()=>{c()},800)};return f.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 dark:bg-black/70 backdrop-blur-sm flex items-center justify-center p-4",children:f.jsxs("div",{className:"bg-white dark:bg-[#0f0f0f] border border-[#eaeaea] dark:border-[#262626] rounded-xl w-full max-w-md flex flex-col shadow-2xl overflow-hidden animate-in fade-in zoom-in-95 duration-150 transition-colors",children:[f.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-[#eaeaea] dark:border-[#222222]",children:[f.jsxs("div",{className:"flex items-center gap-2 font-semibold text-sm text-[#171717] dark:text-white",children:[f.jsx(W1,{className:"w-4 h-4 text-amber-500 dark:text-amber-400"}),f.jsx("span",{children:"超管密钥授权"})]}),f.jsx("button",{onClick:c,className:"text-[#888888] hover:text-black dark:hover:text-white p-1 rounded-md hover:bg-[#f5f5f5] dark:hover:bg-[#1a1a1a]",children:f.jsx(Sh,{className:"w-4 h-4"})})]}),f.jsxs("div",{className:"p-5 flex flex-col gap-4",children:[f.jsxs("div",{className:"text-xs text-[#666666] dark:text-[#888888] leading-relaxed",children:["服务端默认通过 ",f.jsx("code",{className:"text-black dark:text-[#ededed] font-mono font-semibold",children:"TYPESET_ADMIN_KEY"})," 保护模板持久化、图片上传和无头出图 API。请填入服务启动时控制台打印的管理员密钥。"]}),f.jsxs("div",{className:"flex flex-col gap-1.5",children:[f.jsx("label",{className:"text-[11px] font-mono text-[#888888] dark:text-[#666666]",children:"X-Admin-Key"}),f.jsx("input",{type:"password",value:h,onChange:p=>b(p.target.value),placeholder:"tsk_...",className:"bg-[#fafafa] dark:bg-[#0a0a0a] border border-[#d4d4d4] dark:border-[#2a2a2a] rounded-lg px-3 py-2 text-xs font-mono text-black dark:text-white focus:outline-none focus:border-black dark:focus:border-[#444444]"})]}),v?f.jsxs("div",{className:"text-xs text-emerald-700 dark:text-emerald-400 bg-emerald-50 dark:bg-emerald-500/10 border border-emerald-200 dark:border-emerald-500/20 px-3 py-2 rounded-lg flex items-center gap-2 font-medium",children:[f.jsx(q1,{className:"w-3.5 h-3.5"}),f.jsx("span",{children:v})]}):d?f.jsxs("div",{className:"text-xs text-emerald-700 dark:text-emerald-400 bg-emerald-50 dark:bg-emerald-500/10 border border-emerald-200 dark:border-emerald-500/20 px-3 py-2 rounded-lg flex items-center gap-2 font-medium",children:[f.jsx(Np,{className:"w-3.5 h-3.5"}),f.jsx("span",{children:"密钥已通过验证,拥有超管权限"})]}):f.jsx("div",{className:"text-xs text-amber-700 dark:text-amber-400 bg-amber-50 dark:bg-amber-500/10 border border-amber-200 dark:border-amber-500/20 px-3 py-2 rounded-lg",children:"当前密钥未验证或已失效,请检查后端 .env 配置"}),f.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[f.jsx("button",{onClick:c,className:"px-3 py-1.5 rounded-lg border border-[#eaeaea] dark:border-[#262626] text-xs text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-white hover:bg-[#f5f5f5] dark:hover:bg-[#161616]",children:"取消"}),f.jsx("button",{onClick:m,className:"px-4 py-1.5 bg-black text-white hover:bg-[#262626] dark:bg-white dark:text-black dark:hover:bg-[#eaeaea] text-xs font-semibold rounded-lg transition-all btn-vercel",children:"保存并授权"})]})]})]})})},m1={"wechat-cover-2.35":{id:"wechat-cover-2.35",name:"微信文章封面",ratio:2.35,width:2350,height:1e3,description:"微信公众号官方推荐大图封面 (2.35:1),适合主标题视觉张力、副标题与装饰图层",defaultSafeArea:{top:120,right:140,bottom:120,left:140}},"longform-3-4":{id:"longform-3-4",name:"通用长图文",ratio:3/4,width:1080,height:1440,description:"3:4 手机端阅读长文/图文卡片,支持多页分页、矩形图片绕排、目标填充率优化",defaultSafeArea:{top:96,right:88,bottom:96,left:88}},"wide-16-9":{id:"wide-16-9",name:"通用宽屏",ratio:16/9,width:1920,height:1080,description:"16:9 横版宽屏,适合推特/X 动态配图、技术博客 Banner、视频封面与分栏排版",defaultSafeArea:{top:100,right:120,bottom:100,left:120}},"square-1-1":{id:"square-1-1",name:"通用正方形",ratio:1,width:1200,height:1200,description:"1:1 正方形卡片,适合金句名言卡、公众号次条、小红书方图与社交媒体方版海报",defaultSafeArea:{top:100,right:100,bottom:100,left:100}}};function Fl(u){return m1[u]??m1["longform-3-4"]}function jn(u,c,o=20){const r=Math.max(100,u.width-c.left-c.right),d=Math.max(100,u.height-c.top-c.bottom-o);return{stageWidth:r,stageHeight:d,stageX:c.left,stageY:c.top}}function Bp(u,c=!1){const r=((u||"").split(",")[0]||"").replace(/["'\\]/g,"").trim();return r.includes("Noto Sans")?c?'"Hiragino Sans GB", sans-serif':'"Noto Sans SC", "PingFang SC", sans-serif':r.includes("PingFang")?c?'"Hiragino Sans GB", sans-serif':'"PingFang SC", "Noto Sans SC", sans-serif':r.includes("Noto Serif")?c?'"Songti SC", serif':'"Noto Serif SC", "Songti SC", serif':r.includes("Songti")||r==="STSong"?c?'"Songti SC", serif':'"Songti SC", "Noto Serif SC", serif':r.includes("Kai")||r.includes("WenKai")?c?'"STKaiti", "Kaiti SC", "Songti SC", serif':'"LXGW WenKai GB Screen", "LXGW WenKai Screen", "Kaiti SC", "STKaiti", serif':r.includes("Yuan")?c?'"STYuanti", "Yuanti SC", "Hiragino Sans GB", sans-serif':'"Yuanti SC", "STYuanti", "PingFang SC", sans-serif':r.includes("Inter")?c?'Inter, "Hiragino Sans GB", sans-serif':'Inter, "PingFang SC", sans-serif':r.includes("Georgia")?'Georgia, "Songti SC", serif':r.toLowerCase().includes("serif")||r.includes("Song")?`"${r}", "Songti SC", serif`:c?`"${r}", "Hiragino Sans GB", "PingFang SC", sans-serif`:`"${r}", "PingFang SC", sans-serif`}function wa(u,c=!1){if(!u)return'16px "PingFang SC", sans-serif';const o=u.match(/^(.*?)([\d.]+(?:px|pt|em|rem))\s+(.+)$/);if(!o)return u;const r=o[1],d=o[2],h=o[3];return`${r}${d} ${Bp(h,c)}`}async function Op(u,c){const{page:o,spec:r,config:d,totalPageCount:h=1,getImage:b,isServer:v=!1}=c,{algorithm:y,theme:m,chrome:p}=d;u.save(),u.fillStyle=m.bgColor,u.fillRect(0,0,r.width,r.height),u.restore();const g=d.coverTheme,N=async G=>{if(!G)return;const A=await b(G.src);if(!A)throw new Error("Failed to load cover theme image");const X=G.fit==="contain"?Math.min(r.width/A.width,r.height/A.height):Math.max(r.width/A.width,r.height/A.height),D=G.fit==="fill"?r.width:A.width*X,$=G.fit==="fill"?r.height:A.height*X;u.save(),u.globalAlpha=G.opacity,u.drawImage(A,(r.width-D)*G.position.x/100,(r.height-$)*G.position.y/100,D,$),u.restore()};if(g){const G=g.background.fill;if(u.save(),G.type==="solid")u.fillStyle=G.color;else{let D;if(G.type==="linear"){const $=G.angle*Math.PI/180,Y=Math.cos($)*r.width/2,ae=Math.sin($)*r.height/2;D=u.createLinearGradient(r.width/2-Y,r.height/2-ae,r.width/2+Y,r.height/2+ae)}else{const $=r.width*G.position.x/100,Y=r.height*G.position.y/100;D=u.createRadialGradient($,Y,0,$,Y,Math.hypot(r.width,r.height))}for(const $ of G.stops)D.addColorStop($.offset/100,$.color);u.fillStyle=D}u.fillRect(0,0,r.width,r.height),u.restore(),await N(g.background.image),g.background.overlay&&(u.save(),u.fillStyle=g.background.overlay.color,u.globalAlpha=g.background.overlay.opacity,u.fillRect(0,0,r.width,r.height),u.restore());const A=g.decoration;u.save(),u.strokeStyle=u.fillStyle=A.color,u.globalAlpha=A.opacity;const X=Math.max(8,A.size);if(u.beginPath(),["lines","grid","dots"].includes(A.pattern)){for(let D=0;D<r.width;D+=X)if(A.pattern==="grid"&&(u.moveTo(D,0),u.lineTo(D,r.height)),A.pattern==="dots")for(let $=0;$<r.height;$+=X)u.moveTo(D+2,$),u.arc(D,$,2,0,Math.PI*2);if(A.pattern!=="dots")for(let D=0;D<r.height;D+=X)u.moveTo(0,D),u.lineTo(r.width,D)}else if(A.pattern==="rings")for(let D=X;D<Math.hypot(r.width,r.height);D+=X)u.moveTo(r.width/2+D,r.height/2),u.arc(r.width/2,r.height/2,D,0,Math.PI*2);else if(A.pattern==="burst")for(let D=0;D<Math.PI*2;D+=Math.PI/Math.max(8,Math.round(X/3)))u.moveTo(r.width/2,r.height/2),u.lineTo(r.width/2+Math.cos(D)*r.width,r.height/2+Math.sin(D)*r.height);A.pattern==="dots"?u.fill():u.stroke(),u.restore(),await N(A.image)}const{stageX:C,stageY:V}=jn(r,y.safeArea,y.contentBottomGap),W=d.aspectRatio==="wechat-cover-2.35",L=p?.showHeader??!W,U=(p?.showWatermark??!W)&&!!d.watermarkText?.trim(),te=(p?.showPageNumber??(!W&&h>1))&&h>1;if(L&&(U||te)){const G=Math.max(24,Math.floor(y.safeArea.top*.45));if(U&&(u.save(),u.font=wa("600 14px PingFang SC",v),u.fillStyle=m.watermarkColor,u.globalAlpha=.45,u.textBaseline="middle",u.textAlign="left",u.fillText(d.watermarkText.toUpperCase(),y.safeArea.left,G),u.restore()),te){u.save();const A=`P.${String(o.pageNumber).padStart(2,"0")}`;u.font='500 12px "SF Mono", Monaco, Menlo, Consolas, monospace',u.textBaseline="middle",u.textAlign="left";const D=u.measureText(A).width+16,$=24,Y=r.width-y.safeArea.right-D,ae=G-$/2;u.strokeStyle=m.textColor,u.globalAlpha=.4,u.lineWidth=1,u.beginPath(),u.roundRect(Y,ae,D,$,12),u.stroke(),u.fillStyle=m.textColor,u.fillText(A,Y+8,G),u.restore()}}const le=[...o.images||[]].sort((G,A)=>{const X=G.zIndex??(G.isAbsolute?20:5),D=A.zIndex??(A.isAbsolute?20:5);return X-D}),oe=async G=>{for(const A of G){let X;try{X=await b(A.src)}catch(O){throw A.templateAssetKey?new Error(`模板素材 ${A.templateAssetKey} 加载失败:${O instanceof Error?O.message:String(O)}`):O}if(!X&&A.templateAssetKey)throw new Error(`模板素材 ${A.templateAssetKey} 加载失败:图片不存在或无法读取`);const D=C+A.x,$=V+A.y,Y=D+A.width/2,ae=$+A.height/2;u.save(),u.translate(Y,ae),A.rotate&&u.rotate(A.rotate*Math.PI/180),u.globalAlpha=A.opacity??1;const j=A.width,B=A.height,k=Math.min(A.borderRadius??12,j/2,B/2);if(u.beginPath(),u.roundRect(-j/2,-B/2,j,B,k),u.clip(),X?u.drawImage(X,-j/2,-B/2,j,B):(u.fillStyle=m.cardBg||"#222222",u.fillRect(-j/2,-B/2,j,B)),u.restore(),A.caption?.trim()){u.save();const O=Math.max(14,Math.round(y.baseFontSize*.45));u.font=wa(`400 ${O}px PingFang SC`,v),u.fillStyle=m.captionColor,u.textBaseline="top",u.textAlign="center",u.fillText(A.caption,Y,$+B+12),u.restore()}}};await oe(le.filter(G=>(G.zIndex??(G.isAbsolute?20:5))<10));for(const G of o.lines){const A=C+G.x,X=V+G.y;if(G.className==="body-quote"){u.save(),u.fillStyle=m.accentColor,u.globalAlpha=.85,u.beginPath();const $=Math.max(1,G.lineHeight-8);typeof u.roundRect=="function"?u.roundRect(C,X+4,3.5,$,2):u.rect(C,X+4,3.5,$),u.fill(),u.restore()}if(G.bullet&&G.bulletX!==void 0){if(u.save(),u.fillStyle=m.accentColor,G.bullet==="•"){const $=Math.max(3,Math.round(y.baseFontSize*.08)),Y=C+G.bulletX+8,ae=X+Math.round(G.lineHeight*.42);u.beginPath(),u.arc(Y,ae,$,0,Math.PI*2),u.fill()}else u.font=wa(G.font,v),u.textBaseline="top",u.textAlign="left",u.fillText(G.bullet,C+G.bulletX,X);u.restore()}let D=A;for(const $ of G.fragments){const Y=$.font||G.font,ae=wa(Y,v);u.font=ae,u.textBaseline="top",u.textAlign="left",$.highlight?u.fillStyle=m.accentColor:G.className.includes("heading")?u.fillStyle=m.headingColor||m.textColor:G.className.includes("quote")?u.fillStyle=m.quoteColor||m.textColor:u.fillStyle=m.textColor,u.letterSpacing=`${$.letterSpacing||0}px`,u.fillText($.text,D,X);const j=$.letterSpacing?$.occupiedWidth:u.measureText($.text).width;D+=j+($.gapBefore||0)}}await oe(le.filter(G=>(G.zIndex??(G.isAbsolute?20:5))>=10)),u.letterSpacing="0px";const ce=p?.showFooter??!W,Z=p?.showFooterDivider??(!W&&!!d.footerText?.trim()),ee=(p?.showFooterText??!W)&&!!d.footerText?.trim();if(ce){const G=r.height-Math.max(24,Math.floor(y.safeArea.bottom*.45));if(Z&&(u.save(),u.strokeStyle=m.borderSubtle||"#e5e5e5",u.lineWidth=1,u.beginPath(),u.moveTo(y.safeArea.left,G-14),u.lineTo(r.width-y.safeArea.right,G-14),u.stroke(),u.restore()),p?.showFillRatio&&(u.save(),u.font=wa("500 13px PingFang SC",v),u.fillStyle=m.captionColor,u.textBaseline="middle",u.textAlign="right",u.fillText(`填充率 ${Math.round(o.fillRatio*100)}%`,r.width-y.safeArea.right,G),u.restore()),ee){u.save();const A=g?.typography.footer;u.font=wa(A?`${A.fontWeight} ${A.fontSize}px "${A.fontFamily}"`:"500 13px PingFang SC",v),u.letterSpacing=`${A?.letterSpacing||0}px`,u.fillStyle=m.watermarkColor||m.captionColor,u.globalAlpha=.6,u.textBaseline="middle",u.textAlign="left",u.fillText(d.footerText,y.safeArea.left,G),u.restore()}}}const jp=({page:u,spec:c,config:o,totalPageCount:r,zoom:d})=>{const h=me.useRef(null),[b,v]=me.useState(null);return me.useEffect(()=>{const y=h.current;if(!y)return;const m=y.getContext("2d");if(!m)return;y.dataset.renderState="loading",v(null);let p=!1;const g=new AbortController,N=V=>V?new Promise(W=>{const L=new Image;let U;const te=oe=>{g.signal.removeEventListener("abort",le),L.onload=L.onerror=null,U&&(U.onload=U.onerror=null),W(oe)},le=()=>te(null);if(g.signal.aborted){te(null);return}g.signal.addEventListener("abort",le,{once:!0}),L.crossOrigin="anonymous",L.onload=()=>te(L),L.onerror=()=>{U=new Image,U.onload=()=>te(U),U.onerror=()=>te(null),U.src=V},L.src=V}):Promise.resolve(null);return(async()=>{const V=document.createElement("canvas");V.width=c.width,V.height=c.height;const W=V.getContext("2d");W&&(await Op(W,{page:u,spec:c,config:o,totalPageCount:r,getImage:N,isServer:!1}),p||(m.clearRect(0,0,c.width,c.height),m.drawImage(V,0,0),y.dataset.renderState="ready"))})().catch(V=>{p||(y.dataset.renderState="error",m.clearRect(0,0,c.width,c.height),v(V instanceof Error?V.message:"画布绘制失败"))}),()=>{p=!0,g.abort()}},[u,c,o,r]),f.jsxs(f.Fragment,{children:[f.jsx("canvas",{id:`typeset-page-${u.pageNumber}`,ref:h,width:c.width,height:c.height,className:"typeset-page absolute top-0 left-0 border border-[#e0e0e0] dark:border-[#222222] shadow-sm select-none",style:{width:c.width*d,height:c.height*d,backgroundColor:o.theme.bgColor}}),b&&f.jsx("div",{role:"alert",className:"absolute inset-0 flex items-center justify-center bg-white/90 p-4 text-sm text-red-600",children:b})]})},zp=({result:u,zoom:c,viewportRef:o,onAutoFit:r,isAutoFit:d,viewMode:h="grid",onToggleViewMode:b,onFocusPage:v})=>{const{pages:y,canvasSpec:m,config:p}=u;return f.jsxs("main",{ref:o,className:"flex-1 min-w-0 overflow-auto bg-[#f5f5f5] dark:bg-[#050505] bg-grid flex flex-col p-6 select-none relative transition-colors",children:[f.jsxs("div",{className:"sticky top-0 z-20 self-center mb-6 px-3.5 py-1.5 rounded-full bg-white/90 dark:bg-[#111111]/90 backdrop-blur border border-[#eaeaea] dark:border-[#222222] text-[11px] font-mono text-[#666666] dark:text-[#888888] flex items-center gap-2.5 shadow-sm",children:[f.jsx("span",{className:"text-[#171717] dark:text-white font-semibold",children:m.name}),f.jsx("span",{children:"•"}),f.jsxs("span",{children:[m.width," × ",m.height,"px"]}),f.jsx("span",{children:"•"}),f.jsxs("span",{className:"text-black dark:text-white font-medium",children:[y.length," 张图片"]}),y.length>1&&b&&f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"•"}),f.jsxs("div",{className:"flex items-center bg-[#eaeaea] dark:bg-[#1a1a1a] rounded-md p-0.5 border border-[#dfdfdf] dark:border-[#262626]",children:[f.jsxs("button",{onClick:()=>b("grid"),className:`flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium transition-all ${h==="grid"?"bg-white dark:bg-[#2b2b2b] text-black dark:text-white shadow-xs font-semibold":"text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-white"}`,title:"多图瀑布流平铺全览",children:[f.jsx(hp,{className:"w-3 h-3"}),f.jsx("span",{children:"多图平铺"})]}),f.jsxs("button",{onClick:()=>b("stack"),className:`flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium transition-all ${h==="stack"?"bg-white dark:bg-[#2b2b2b] text-black dark:text-white shadow-xs font-semibold":"text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-white"}`,title:"单列纵向逐页滚动",children:[f.jsx(yp,{className:"w-3 h-3"}),f.jsx("span",{children:"纵向单列"})]})]})]}),r&&f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"•"}),f.jsx("button",{onClick:r,className:`hover:text-black dark:hover:text-white transition-colors underline underline-offset-2 ${d?"text-emerald-600 dark:text-emerald-400 font-semibold":""}`,title:y.length>1?"缩放至视口内完整排列多张图片":"自适应画布比例",children:d?y.length>1?"已平铺适配":"已自适应":y.length>1?"平铺适配":"自适应"})]})]}),f.jsx("div",{className:"min-w-fit w-full flex-1 flex flex-col items-center justify-start pb-32",children:f.jsx("div",{className:`flex items-start justify-center gap-7 transition-all duration-300 ${h==="grid"?"flex-wrap max-w-full":"flex-col items-center"}`,children:y.map(g=>f.jsxs("div",{className:"flex flex-col items-center",children:[y.length>1&&f.jsxs("div",{className:"mb-2 px-2.5 py-1 rounded-md bg-white/90 dark:bg-[#181818]/90 border border-[#eaeaea] dark:border-[#262626] text-[11px] font-mono text-[#666666] dark:text-[#888888] shadow-xs flex items-center justify-between transition-colors",style:{width:m.width*c},children:[f.jsxs("div",{className:"flex items-center gap-1.5 truncate",children:[f.jsxs("span",{className:"font-semibold text-[#171717] dark:text-white",children:["第 ",g.pageNumber," / ",y.length," 页"]}),f.jsx("span",{children:"•"}),f.jsx("span",{className:"truncate",children:m.name})]}),v&&f.jsxs("button",{onClick:N=>{N.stopPropagation(),v(g.pageNumber)},className:"shrink-0 text-[10px] px-1.5 py-0.5 rounded bg-[#f5f5f5] dark:bg-[#242424] hover:bg-[#eaeaea] dark:hover:bg-[#333333] text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium transition-colors flex items-center gap-1 cursor-pointer",title:"放大聚焦此页",children:[f.jsx(Ah,{className:"w-2.5 h-2.5"}),f.jsx("span",{children:"聚焦单图"})]})]}),f.jsx("div",{onDoubleClick:()=>v?.(g.pageNumber),className:"relative shrink-0 shadow-xl dark:shadow-2xl rounded-sm transition-shadow hover:shadow-2xl cursor-pointer",title:y.length>1?"双击放大聚焦此页":void 0,style:{width:m.width*c,height:m.height*c},children:f.jsx(jp,{page:g,spec:m,config:p,totalPageCount:y.length,zoom:c})})]},g.pageNumber))})})]})},_p=({markdown:u,onMarkdownChange:c,images:o,onAddImage:r,onToggleBackground:d,onResetImageLayout:h,backgroundImageIds:b,onUpdateImage:v,onRemoveImage:y,onMoveImage:m,pageCount:p=1,highlightWords:g,onHighlightWordsChange:N,adminKey:C})=>{const[V,W]=me.useState("text"),[L,U]=me.useState(""),te=me.useRef(null),[le,oe]=me.useState(!1),ce=A=>{c(u?`${u}
|
|
290
290
|
|
|
291
291
|
${A}`:A)},Z=async A=>{const X=A.target.files?.[0];if(!X)return;const D=Y=>r({src:Y,alt:X.name,caption:"",x:40,y:400,width:440,height:300,captionHeight:36,layoutPreset:"auto"}),$=()=>{const Y=new FileReader;Y.onload=()=>{typeof Y.result=="string"&&D(Y.result)},Y.readAsDataURL(X)};oe(!0);try{const Y=new FormData;Y.append("file",X);const j=await(await fetch("/api/upload",{method:"POST",headers:C?{"x-admin-key":C}:{},body:Y})).json();j.ok&&j.url?D(j.url):$()}catch{$()}finally{oe(!1),te.current&&(te.current.value="")}},ee=()=>{L.trim()&&(g.includes(L.trim())||N([...g,L.trim()]),U(""))},G=A=>{N(g.filter(X=>X!==A))};return f.jsxs("aside",{className:"w-80 border-r border-[#eaeaea] dark:border-[#222222] bg-white dark:bg-[#0a0a0a] flex flex-col shrink-0 select-none transition-colors",children:[f.jsxs("div",{className:"flex border-b border-[#eaeaea] dark:border-[#222222] bg-[#f9f9f9] dark:bg-[#050505] p-1 gap-1",children:[f.jsxs("button",{onClick:()=>W("text"),className:`flex-1 flex items-center justify-center gap-1.5 py-1.5 text-xs rounded font-medium transition-all ${V==="text"?"bg-white dark:bg-[#1f1f1f] text-black dark:text-white shadow-sm font-semibold":"text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-[#cccccc]"}`,children:[f.jsx(up,{className:"w-3.5 h-3.5"}),f.jsx("span",{children:"正文"})]}),f.jsxs("button",{onClick:()=>W("images"),className:`flex-1 flex items-center justify-center gap-1.5 py-1.5 text-xs rounded font-medium transition-all ${V==="images"?"bg-white dark:bg-[#1f1f1f] text-black dark:text-white shadow-sm font-semibold":"text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-[#cccccc]"}`,children:[f.jsx(dp,{className:"w-3.5 h-3.5"}),f.jsxs("span",{children:["配图 (",o.length,")"]})]}),f.jsxs("button",{onClick:()=>W("highlights"),className:`flex-1 flex items-center justify-center gap-1.5 py-1.5 text-xs rounded font-medium transition-all ${V==="highlights"?"bg-white dark:bg-[#1f1f1f] text-black dark:text-white shadow-sm font-semibold":"text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-[#cccccc]"}`,children:[f.jsx(fp,{className:"w-3.5 h-3.5"}),f.jsx("span",{children:"重点词"})]})]}),V==="text"&&f.jsxs("div",{className:"flex-1 flex flex-col p-3 gap-2 overflow-hidden",children:[f.jsxs("div",{className:"flex items-center gap-1 pb-1 flex-wrap border-b border-[#f0f0f0] dark:border-[#1c1c1c]",children:[f.jsxs("button",{onClick:()=>ce("# 标题"),className:"px-2 py-1 bg-[#f5f5f5] dark:bg-[#141414] hover:bg-[#eaeaea] dark:hover:bg-[#202020] text-[#555555] dark:text-[#aaaaaa] hover:text-black dark:hover:text-white rounded text-[11px] font-mono flex items-center gap-1 transition-colors",title:"插入主标题",children:[f.jsx(op,{className:"w-3 h-3"}),f.jsx("span",{children:"H1"})]}),f.jsxs("button",{onClick:()=>ce("## 二级标题"),className:"px-2 py-1 bg-[#f5f5f5] dark:bg-[#141414] hover:bg-[#eaeaea] dark:hover:bg-[#202020] text-[#555555] dark:text-[#aaaaaa] hover:text-black dark:hover:text-white rounded text-[11px] font-mono flex items-center gap-1 transition-colors",title:"插入副标题",children:[f.jsx(sp,{className:"w-3 h-3"}),f.jsx("span",{children:"H2"})]}),f.jsx("button",{onClick:()=>ce("> 引用格言名句..."),className:"px-2 py-1 bg-[#f5f5f5] dark:bg-[#141414] hover:bg-[#eaeaea] dark:hover:bg-[#202020] text-[#555555] dark:text-[#aaaaaa] hover:text-black dark:hover:text-white rounded text-[11px] font-mono transition-colors",title:"插入引用块",children:"Quote"}),f.jsxs("button",{onClick:()=>ce("【第二页】"),className:"px-2 py-1 bg-blue-500/10 hover:bg-blue-500/20 text-blue-600 dark:text-blue-400 rounded text-[11px] font-mono flex items-center gap-1 transition-colors",title:"显式分页标记",children:[f.jsx(xp,{className:"w-3 h-3"}),f.jsx("span",{children:"分页面"})]})]}),f.jsx("textarea",{value:u,onChange:A=>c(A.target.value),placeholder:"在此输入 Markdown 内容,纯算法即时排版...",className:"flex-1 w-full bg-[#fafafa] dark:bg-[#0d0d0d] border border-[#eaeaea] dark:border-[#222222] rounded-lg p-3 text-xs font-mono text-[#171717] dark:text-[#ededed] placeholder-[#999999] dark:placeholder-[#444444] resize-none focus:outline-none focus:border-black dark:focus:border-[#444444] transition-all leading-relaxed"}),f.jsxs("div",{className:"flex items-center justify-between text-[11px] text-[#888888] dark:text-[#555555] font-mono px-1",children:[f.jsxs("span",{children:["字符数: ",u.length]}),f.jsxs("span",{children:["行数: ",u.split(`
|
|
292
|
-
`).length]})]})]}),V==="images"&&f.jsxs("div",{className:"flex-1 flex flex-col p-3 gap-3 overflow-y-auto",children:[f.jsxs("div",{className:"flex gap-2",children:[f.jsx("input",{type:"file",ref:te,onChange:Z,accept:"image/*",className:"hidden"}),f.jsxs("button",{onClick:()=>te.current?.click(),disabled:le,className:"flex-1 flex items-center justify-center gap-2 py-2.5 rounded-lg border border-dashed border-[#d4d4d4] dark:border-[#333333] hover:border-black dark:hover:border-[#555555] bg-[#fafafa] dark:bg-[#0f0f0f] hover:bg-[#f5f5f5] dark:hover:bg-[#141414] text-xs text-[#555555] dark:text-[#cccccc] hover:text-black dark:hover:text-white transition-all",children:[f.jsx(Tp,{className:"w-3.5 h-3.5"}),f.jsx("span",{children:le?"正在上传...":"上传配图素材"})]}),f.jsx("button",{onClick:()=>r({src:"https://images.unsplash.com/photo-1579783900882-c0d3dad7b119?w=800&auto=format&fit=crop&q=80",alt:"艺术插画",caption:"示例艺术配图",x:36,y:400,width:440,height:300,captionHeight:36,layoutPreset:"auto"}),className:"px-3 py-2.5 rounded-lg border border-[#eaeaea] dark:border-[#222222] bg-[#fafafa] dark:bg-[#0f0f0f] hover:bg-[#f5f5f5] dark:hover:bg-[#141414] text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-white transition-all",title:"插入在线示例图",children:f.jsx(vp,{className:"w-3.5 h-3.5"})})]}),f.jsx("div",{className:"flex flex-col gap-2.5",children:o.length===0?f.jsx("div",{className:"text-center py-8 text-xs text-[#888888] dark:text-[#555555]",children:"暂无配图素材,点击上方按钮上传或插入"}):o.map((A,X)=>f.jsxs("div",{className:"bg-[#fafafa] dark:bg-[#0f0f0f] border border-[#eaeaea] dark:border-[#222222] rounded-lg p-2.5 flex flex-col gap-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("img",{src:A.src,alt:A.alt,className:"w-12 h-12 object-cover rounded bg-[#eeeeee] dark:bg-[#1a1a1a] border border-[#e5e5e5] dark:border-[#262626] shrink-0"}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[f.jsxs("span",{className:"text-[10px] px-1 rounded bg-[#eaeaea] dark:bg-[#262626] font-mono text-[#555555] dark:text-[#aaaaaa] font-semibold shrink-0",children:["#",X+1]}),f.jsx("span",{className:"text-xs font-medium text-[#171717] dark:text-white truncate max-w-[120px]",children:A.caption||A.alt||`配图 #${X+1}`}),f.jsxs("span",{className:"text-[10px] px-1.5 py-0.2 rounded bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20 font-medium shrink-0",children:["第 ",A.pageIndex||1," 页"]})]}),f.jsxs("div",{className:"text-[10px] text-[#888888] dark:text-[#666666] font-mono mt-0.5",children:[A.width," × ",A.height,"px · X: ",A.x??0,", Y: ",A.y??0]})]}),f.jsxs("div",{className:"flex items-center gap-0.5",children:[f.jsx("button",{onClick:()=>m?.(A.id,"up"),disabled:X===0,className:"p-1 text-[#888888] hover:text-black dark:hover:text-white disabled:opacity-20 rounded hover:bg-[#eeeeee] dark:hover:bg-[#1f1f1f]",title:"上移顺序 (调整在同一页中的先后次序)",children:f.jsx(np,{className:"w-3.5 h-3.5"})}),f.jsx("button",{onClick:()=>m?.(A.id,"down"),disabled:X===o.length-1,className:"p-1 text-[#888888] hover:text-black dark:hover:text-white disabled:opacity-20 rounded hover:bg-[#eeeeee] dark:hover:bg-[#1f1f1f]",title:"下移顺序 (调整在同一页中的先后次序)",children:f.jsx(tp,{className:"w-3.5 h-3.5"})}),f.jsx("button",{onClick:()=>y(A.id),className:"p-1 text-[#888888] hover:text-red-500 rounded hover:bg-[#eeeeee] dark:hover:bg-[#1f1f1f]",title:"删除该图",children:f.jsx(vh,{className:"w-3.5 h-3.5"})})]})]}),f.jsxs("div",{className:"flex bg-[#eeeeee] dark:bg-[#1a1a1a] p-0.5 rounded text-[11px] font-medium pt-1 border-t border-[#eeeeee] dark:border-[#1a1a1a]",children:[f.jsx("button",{onClick:()=>v(A.id,{isAbsolute:!1}),className:`flex-1 py-1 rounded transition-all text-center ${A.isAbsolute?"text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-white":"bg-white dark:bg-[#262626] text-black dark:text-white shadow-sm font-semibold"}`,children:"绕排避让 (Flow)"}),f.jsx("button",{onClick:()=>v(A.id,{isAbsolute:!0,layoutPreset:"custom",zIndex:A.zIndex??15,rotate:A.rotate??0,opacity:A.opacity??1}),className:`flex-1 py-1 rounded transition-all text-center ${A.isAbsolute?"bg-white dark:bg-[#262626] text-black dark:text-white shadow-sm font-semibold":"text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-white"}`,children:"自由图层 (Absolute)"})]}),f.jsxs("div",{className:"flex flex-col gap-2 text-[11px]",children:[f.jsxs("label",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",checked:A.templateAssetKey!==void 0,onChange:D=>v(A.id,{templateAssetKey:D.target.checked?`asset_${A.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`:void 0,repeatEveryPage:!1})}),"固定模板素材"]}),A.templateAssetKey!==void 0&&f.jsxs(f.Fragment,{children:[f.jsxs("label",{className:"flex flex-col gap-1",children:["素材标识",f.jsx("input",{"aria-label":"素材标识",value:A.templateAssetKey,onChange:D=>v(A.id,{templateAssetKey:D.target.value}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1"})]}),o.some(D=>D.id!==A.id&&D.templateAssetKey===A.templateAssetKey)&&f.jsx("span",{role:"alert",className:"text-red-600",children:"素材标识不能重复"}),f.jsxs("label",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",disabled:!A.isAbsolute,checked:!!(A.isAbsolute&&A.repeatEveryPage),onChange:D=>v(A.id,{repeatEveryPage:D.target.checked})}),"每页重复"]}),!A.isAbsolute&&f.jsx("span",{className:"text-[#888888]",children:"每页重复仅支持自由图层,避免阻塞文字排版。"}),f.jsx("span",{className:"text-[#888888]",children:"默认保留此图,仅按素材标识明确替换。"})]}),A.isAbsolute&&f.jsxs("label",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",checked:b.includes(A.id),onChange:D=>d(A.id,D.target.checked)}),"设为整页背景"]}),f.jsx("button",{type:"button",onClick:()=>h(A.id),title:"恢复上传或应用模板时的尺寸、位置和图层设置",className:"rounded border border-[#d4d4d4] dark:border-[#333333] px-2 py-1.5 hover:bg-[#eeeeee] dark:hover:bg-[#222222]",children:"重置布局"})]}),A.isAbsolute?f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"text-[10px] text-blue-600 dark:text-blue-400 bg-blue-500/10 p-1.5 rounded flex items-center gap-1 font-medium",children:[f.jsx(bo,{className:"w-3 h-3 shrink-0"}),f.jsx("span",{children:"自由定位图层:脱离文本流,不触发障碍物绕排"})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"所属页面"}),f.jsx("select",{value:A.pageIndex||1,onChange:D=>v(A.id,{pageIndex:parseInt(D.target.value,10)||1}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] focus:outline-none",children:Array.from({length:Math.max(p,2)},(D,$)=>$+1).map(D=>f.jsxs("option",{value:D,children:["第 ",D," 页 ",D===1?"(首页/封面)":""]},D))})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex justify-between text-[#666666] mb-1",children:[f.jsx("span",{children:"层级 (Z-Index)"}),f.jsx("span",{className:"font-mono text-black dark:text-white font-semibold",children:A.zIndex??15})]}),f.jsx("div",{className:"flex gap-1",children:[{label:"底",val:0,title:"底层背景"},{label:"文字",val:10,title:"正文同层"},{label:"顶",val:20,title:"置顶贴纸"}].map(D=>f.jsx("button",{onClick:()=>v(A.id,{zIndex:D.val}),title:D.title,className:`flex-1 py-0.5 text-[10px] rounded border ${(A.zIndex??15)===D.val?"bg-black dark:bg-white text-white dark:text-black border-transparent font-bold":"border-[#d4d4d4] dark:border-[#262626] text-[#666666] dark:text-[#888888]"}`,children:D.label},D.val))})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex justify-between text-[#666666] mb-1",children:[f.jsxs("span",{className:"flex items-center gap-0.5",children:[f.jsx(bp,{className:"w-2.5 h-2.5"})," 旋转角度"]}),f.jsxs("span",{className:"font-mono text-black dark:text-white font-semibold",children:[A.rotate??0,"°"]})]}),f.jsx("input",{type:"range",min:"-45",max:"45",step:"1",value:A.rotate??0,onChange:D=>v(A.id,{rotate:parseInt(D.target.value,10)}),className:"w-full h-1.5 bg-[#e5e5e5] dark:bg-[#222222] rounded cursor-pointer mt-1"})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex justify-between text-[#666666] mb-1",children:[f.jsx("span",{children:"不透明度"}),f.jsxs("span",{className:"font-mono text-black dark:text-white font-semibold",children:[Math.round((A.opacity??1)*100),"%"]})]}),f.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:A.opacity??1,onChange:D=>v(A.id,{opacity:parseFloat(D.target.value)}),className:"w-full h-1.5 bg-[#e5e5e5] dark:bg-[#222222] rounded cursor-pointer mt-1"})]})]}),f.jsxs("div",{className:"text-[11px]",children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"圆角半径 (px)"}),f.jsx("input",{type:"number",min:"0",step:"4",value:A.borderRadius??12,onChange:D=>v(A.id,{borderRadius:parseInt(D.target.value,10)||0}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"横向 X"}),f.jsx("input",{type:"number",step:"10",value:A.x??0,onChange:D=>v(A.id,{x:parseInt(D.target.value,10)||0}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"纵向 Y"}),f.jsx("input",{type:"number",step:"10",value:A.y??0,onChange:D=>v(A.id,{y:parseInt(D.target.value,10)||0}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"宽度 (W)"}),f.jsx("input",{type:"number",step:"10",value:A.width??420,onChange:D=>v(A.id,{width:Math.max(20,parseInt(D.target.value,10)||20)}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"高度 (H)"}),f.jsx("input",{type:"number",step:"10",value:A.height??280,onChange:D=>v(A.id,{height:Math.max(20,parseInt(D.target.value,10)||20)}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]})]})]}):f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"排版预设"}),f.jsxs("select",{value:A.layoutPreset||"auto",onChange:D=>v(A.id,{layoutPreset:D.target.value}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] focus:outline-none",children:[f.jsx("option",{value:"auto",children:"自适应 (Auto)"}),f.jsx("option",{value:"mid-left",children:"居左浮动 (Left)"}),f.jsx("option",{value:"mid-right",children:"居右浮动 (Right)"}),f.jsx("option",{value:"center",children:"居中横幅 (Center)"}),f.jsx("option",{value:"staggered",children:"交错排版 (Staggered)"}),f.jsx("option",{value:"corner-soft",children:"角落软着陆 (Corner)"}),f.jsx("option",{value:"fill",children:"底部填满 (Fill)"}),f.jsx("option",{value:"custom",children:"自定义坐标 (Custom)"})]})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"所属页面"}),f.jsx("select",{value:A.pageIndex||1,onChange:D=>v(A.id,{pageIndex:parseInt(D.target.value,10)||1}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] focus:outline-none",children:Array.from({length:Math.max(p,2)},(D,$)=>$+1).map(D=>f.jsxs("option",{value:D,children:["第 ",D," 页 ",D===1?"(首页/封面)":""]},D))})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"宽度 (W)"}),f.jsx("input",{type:"number",min:"50",step:"10",value:A.width??420,onChange:D=>v(A.id,{width:Math.max(50,parseInt(D.target.value,10)||50)}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"高度 (H)"}),f.jsx("input",{type:"number",min:"50",step:"10",value:A.height??280,onChange:D=>v(A.id,{height:Math.max(50,parseInt(D.target.value,10)||50)}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"纵向位置 Y"}),f.jsx("input",{type:"number",step:"20",value:A.y??300,onChange:D=>v(A.id,{y:parseInt(D.target.value,10)||0,layoutPreset:"custom"}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"横向坐标 X"}),f.jsx("input",{type:"number",step:"10",value:A.x??16,onChange:D=>v(A.id,{x:parseInt(D.target.value,10)||0,layoutPreset:"custom"}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] text-[11px] block mb-1",children:"图片说明 (Caption)"}),f.jsx("input",{type:"text",placeholder:"下方说明文字...",value:A.caption||"",onChange:D=>v(A.id,{caption:D.target.value}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-2 py-1 text-black dark:text-white text-[11px] focus:outline-none"})]})]})]},A.id))})]}),V==="highlights"&&f.jsxs("div",{className:"flex-1 flex flex-col p-3 gap-3 overflow-y-auto",children:[f.jsx("div",{className:"text-xs text-[#666666] dark:text-[#888888] leading-relaxed",children:"在正文中出现的高亮词,将被算法自动匹配并渲染为品牌强调色。"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx("input",{type:"text",placeholder:"新增高亮关键词...",value:L,onChange:A=>U(A.target.value),onKeyDown:A=>A.key==="Enter"&&ee(),className:"flex-1 bg-white dark:bg-[#0d0d0d] border border-[#d4d4d4] dark:border-[#222222] rounded-lg px-2.5 py-1.5 text-xs text-black dark:text-white placeholder-[#888888] dark:placeholder-[#555555] focus:outline-none focus:border-black dark:focus:border-[#444444]"}),f.jsx("button",{onClick:ee,className:"px-3 py-1.5 bg-black dark:bg-[#1f1f1f] hover:bg-[#262626] text-white rounded-lg text-xs font-medium",children:"添加"})]}),f.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:g.map(A=>f.jsxs("span",{className:"flex items-center gap-1 px-2.5 py-1 rounded-md bg-[#f0fdf4] dark:bg-[#161616] border border-[#bbf7d0] dark:border-[#262626] text-xs text-emerald-700 dark:text-emerald-400 font-medium",children:[f.jsx(bo,{className:"w-3 h-3"}),f.jsx("span",{children:A}),f.jsx("button",{onClick:()=>G(A),className:"hover:text-red-500 ml-1",children:"×"})]},A))})]})]})},Rp=[{id:"wechat-cover-2.35",label:"微信封面",ratioTag:"2.35:1"},{id:"longform-3-4",label:"通用长图文",ratioTag:"3:4"},{id:"wide-16-9",label:"通用宽屏",ratioTag:"16:9"},{id:"square-1-1",label:"通用正方形",ratioTag:"1:1"}],Lp=({currentRatio:u,onSelectRatio:c,zoom:o,onZoomChange:r,onAutoFit:d,isAutoFit:h,onOpenTemplates:b,onOpenAuth:v,onExport:y,isExporting:m,isAuthed:p,pageCount:g,themeMode:N,onToggleThemeMode:C})=>f.jsxs("header",{className:"h-14 border-b border-[#eaeaea] dark:border-[#222222] bg-white/80 dark:bg-[#000000]/80 backdrop-blur-md px-4 flex items-center justify-between select-none z-30 shrink-0 transition-colors",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsxs("div",{className:"flex items-center gap-2 font-semibold text-[#171717] dark:text-white tracking-tight text-sm",children:[f.jsx("span",{className:"flex items-center justify-center w-6 h-6 rounded bg-black dark:bg-white text-white dark:text-black font-black text-xs shadow-sm",children:"▲"}),f.jsx("span",{children:"Typeset Studio"})]}),f.jsx("span",{className:"text-xs text-[#888888] dark:text-[#555555] font-mono hidden md:inline",children:"v0.2.2"}),f.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-[#f5f5f5] dark:bg-[#111111] border border-[#e5e5e5] dark:border-[#222222] text-[11px] text-emerald-600 dark:text-[#00e676]",children:[f.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 dark:bg-[#00e676] animate-pulse"}),f.jsx("span",{className:"font-mono",children:"Ready"})]})]}),f.jsx("div",{className:"flex items-center bg-[#f5f5f5] dark:bg-[#0a0a0a] border border-[#eaeaea] dark:border-[#222222] rounded-lg p-0.5 shadow-inner",children:Rp.map(V=>{const W=u===V.id;return f.jsxs("button",{onClick:()=>c(V.id),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-all ${W?"bg-white dark:bg-[#1f1f1f] text-black dark:text-white shadow-sm font-semibold":"text-[#666666] dark:text-[#888888] hover:text-[#171717] dark:hover:text-[#cccccc] hover:bg-[#eaeaea] dark:hover:bg-[#141414]"}`,children:[f.jsx("span",{children:V.label}),f.jsx("span",{className:`text-[10px] font-mono px-1 py-0.2 rounded ${W?"bg-[#eaeaea] dark:bg-[#333333] text-black dark:text-white font-semibold":"bg-[#e5e5e5] dark:bg-[#181818] text-[#777777] dark:text-[#666666]"}`,children:V.ratioTag})]},V.id)})}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"flex items-center bg-[#f5f5f5] dark:bg-[#0a0a0a] border border-[#eaeaea] dark:border-[#222222] rounded-lg p-0.5 text-xs text-[#666666] dark:text-[#888888]",children:[f.jsx("button",{onClick:()=>r(Math.max(.2,Number((o-.05).toFixed(2)))),className:"p-1 hover:text-black dark:hover:text-white rounded hover:bg-[#e8e8e8] dark:hover:bg-[#1f1f1f]",title:"缩小",children:f.jsx(wp,{className:"w-3.5 h-3.5"})}),f.jsxs("span",{onDoubleClick:d,className:"w-11 text-center font-mono text-[11px] text-[#333333] dark:text-[#cccccc] cursor-pointer hover:underline select-none",title:"双击恢复自适应",children:[Math.round(o*100),"%"]}),f.jsx("button",{onClick:()=>r(Math.min(1.5,Number((o+.05).toFixed(2)))),className:"p-1 hover:text-black dark:hover:text-white rounded hover:bg-[#e8e8e8] dark:hover:bg-[#1f1f1f]",title:"放大",children:f.jsx(Ah,{className:"w-3.5 h-3.5"})}),d&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"w-[1px] h-3 bg-[#e0e0e0] dark:bg-[#262626] mx-0.5"}),f.jsxs("button",{onClick:d,className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] transition-all ${h?"bg-white dark:bg-[#1f1f1f] text-black dark:text-white shadow-xs font-semibold":"hover:text-black dark:hover:text-white hover:bg-[#e8e8e8] dark:hover:bg-[#1f1f1f]"}`,title:g>1?"缩放至视口内完整排列多张图片(瀑布流平铺)":"自适应画布大小",children:[f.jsx(mp,{className:"w-3 h-3"}),f.jsx("span",{children:g>1?"多图平铺":"自适应"})]})]})]}),f.jsx("button",{onClick:C,className:"p-2 rounded-lg border border-[#eaeaea] dark:border-[#222222] bg-white dark:bg-[#0a0a0a] hover:bg-[#f5f5f5] dark:hover:bg-[#161616] text-[#444444] dark:text-[#cccccc] transition-all btn-vercel",title:N==="light"?"切换至深色模式":"切换至浅色模式",children:N==="light"?f.jsx(gp,{className:"w-3.5 h-3.5 text-[#555555]"}):f.jsx(Ap,{className:"w-3.5 h-3.5 text-amber-400"})}),f.jsxs("button",{onClick:b,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg border border-[#eaeaea] dark:border-[#222222] bg-white dark:bg-[#0a0a0a] hover:bg-[#f5f5f5] dark:hover:bg-[#161616] text-xs text-[#333333] dark:text-[#cccccc] hover:text-black dark:hover:text-white transition-all btn-vercel",children:[f.jsx(cp,{className:"w-3.5 h-3.5 text-[#777777] dark:text-[#888888]"}),f.jsx("span",{children:"模板库"})]}),f.jsxs("button",{onClick:y,disabled:m,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-black text-white hover:bg-[#262626] dark:bg-white dark:text-black dark:hover:bg-[#eaeaea] text-xs font-semibold transition-all btn-vercel shadow-sm disabled:opacity-50",children:[m?f.jsx(ih,{className:"w-3.5 h-3.5 animate-spin"}):f.jsx(ip,{className:"w-3.5 h-3.5"}),f.jsx("span",{children:m?"导出中...":"导出图片"}),g>1&&f.jsxs("span",{className:"text-[10px] bg-white/20 dark:bg-black text-white px-1.5 py-0.2 rounded font-mono",children:[g,"P"]})]}),f.jsx("button",{onClick:v,className:`p-1.5 rounded-lg border transition-all btn-vercel ${p?"border-[#eaeaea] dark:border-[#222222] bg-white dark:bg-[#0a0a0a] text-[#777777] dark:text-[#888888] hover:text-black dark:hover:text-white hover:bg-[#f5f5f5] dark:hover:bg-[#161616]":"border-amber-500/50 bg-amber-500/10 text-amber-600 dark:text-amber-400"}`,title:p?"超管密钥已就绪":"配置超管密钥",children:f.jsx(W1,{className:"w-3.5 h-3.5"})})]})]});function Hp(){const[u,c]=me.useState([]),[o,r]=me.useState(!1),d=me.useCallback(async(h=!1)=>{try{r(!0);const b=await fetch(`/api/fonts${h?"?refresh=1":""}`);if(!b.ok)return;const v=await b.json();if(!v.ok||!Array.isArray(v.fonts))return;c(v.fonts);let y=!1;if(typeof window<"u"&&"FontFace"in window&&document.fonts)for(const m of v.fonts)try{let p=!1;const g=[];if(document.fonts.forEach(N=>{(N.family===m.family||N.family===`"${m.family}"`)&&(p=!0,g.push(N))}),h&&(g.forEach(N=>document.fonts.delete(N)),p=!1),!p){const C=await new FontFace(m.family,`url(${m.url}${h?`?v=${Date.now()}`:""})`).load();document.fonts.add(C),y=!0}}catch(p){console.warn(`[useLocalFonts] Failed to load web font ${m.family}:`,p)}y&&window.dispatchEvent(new Event("typeset-fonts-loaded"))}catch(b){console.warn("[useLocalFonts] Failed to fetch local fonts:",b)}finally{r(!1)}},[]);return me.useEffect(()=>{d()},[d]),{fonts:u,loading:o,refreshFonts:()=>d(!0)}}const g1=[{label:"苹方 / 极简黑体 (默认清爽)",value:"PingFang SC"},{label:"思源黑体 (现代极简·粗黑)",value:"Noto Sans SC"},{label:"典雅宋体 (经典报刊·书卷)",value:"Songti SC"},{label:"思源宋体 (高阶报刊·典雅)",value:"Noto Serif SC"},{label:"人文楷体 (温润随笔·手写)",value:"Kaiti SC"},{label:"柔和圆体 (亲和灵动·现代)",value:"Yuanti SC"},{label:"Inter / 国际西文无衬线",value:"Inter"},{label:"Georgia / 文艺西文衬线",value:"Georgia"}],Up=({config:u,onUpdateAlgorithm:c,onUpdateTheme:o,onUpdateTypography:r,onUpdateSafeArea:d,onUpdateBranding:h,onUpdateChrome:b})=>{const{algorithm:v,theme:y,typography:m}=u,{fonts:p,loading:g,refreshFonts:N}=Hp();return f.jsxs("aside",{className:"w-80 border-l border-[#eaeaea] dark:border-[#222222] bg-white dark:bg-[#0a0a0a] flex flex-col shrink-0 select-none overflow-y-auto transition-colors",children:[f.jsxs("div",{className:"p-3.5 border-b border-[#f0f0f0] dark:border-[#1c1c1c]",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[#171717] dark:text-white mb-3",children:[f.jsx(lp,{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400"}),f.jsx("span",{children:"文字对齐与空间居中"})]}),f.jsxs("div",{className:"flex flex-col gap-3 text-xs",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] dark:text-[#888888] text-[11px] block mb-1.5 font-medium",children:"垂直排版对齐 (封面必备)"}),f.jsx("div",{className:"grid grid-cols-3 gap-1 bg-[#f5f5f5] dark:bg-[#141414] p-1 rounded-lg border border-[#e5e5e5] dark:border-[#262626]",children:[{id:"top",label:"顶端对齐"},{id:"center",label:"垂直居中"},{id:"bottom",label:"底端对齐"}].map(C=>f.jsx("button",{onClick:()=>c({verticalAlign:C.id}),className:`py-1 text-[11px] rounded transition-all font-medium ${(v.verticalAlign||"top")===C.id?"bg-white dark:bg-[#262626] text-black dark:text-white shadow-sm font-semibold":"text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-white"}`,children:C.label},C.id))})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] dark:text-[#888888] text-[11px] block mb-1.5 font-medium",children:"水平排版对齐"}),f.jsxs("div",{className:"grid grid-cols-3 gap-1 bg-[#f5f5f5] dark:bg-[#141414] p-1 rounded-lg border border-[#e5e5e5] dark:border-[#262626]",children:[f.jsxs("button",{onClick:()=>c({textAlign:"left"}),className:`py-1 flex items-center justify-center gap-1 text-[11px] rounded transition-all font-medium ${(v.textAlign||"left")==="left"?"bg-white dark:bg-[#262626] text-black dark:text-white shadow-sm font-semibold":"text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-white"}`,children:[f.jsx(kp,{className:"w-3 h-3"}),f.jsx("span",{children:"居左"})]}),f.jsxs("button",{onClick:()=>c({textAlign:"center"}),className:`py-1 flex items-center justify-center gap-1 text-[11px] rounded transition-all font-medium ${v.textAlign==="center"?"bg-white dark:bg-[#262626] text-black dark:text-white shadow-sm font-semibold":"text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-white"}`,children:[f.jsx(Mp,{className:"w-3 h-3"}),f.jsx("span",{children:"居中"})]}),f.jsxs("button",{onClick:()=>c({textAlign:"right"}),className:`py-1 flex items-center justify-center gap-1 text-[11px] rounded transition-all font-medium ${v.textAlign==="right"?"bg-white dark:bg-[#262626] text-black dark:text-white shadow-sm font-semibold":"text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-white"}`,children:[f.jsx(Cp,{className:"w-3 h-3"}),f.jsx("span",{children:"居右"})]})]})]})]})]}),f.jsxs("div",{className:"p-3.5 border-b border-[#f0f0f0] dark:border-[#1c1c1c]",children:[f.jsxs("div",{className:"flex items-center justify-between text-xs font-semibold text-[#171717] dark:text-white mb-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Fp,{className:"w-3.5 h-3.5 text-indigo-500 dark:text-indigo-400"}),f.jsx("span",{children:"字体与排版字阶"})]}),f.jsx("button",{onClick:()=>N(),disabled:g,title:"重新扫描 public/fonts 目录",className:"p-1 text-[#888888] hover:text-black dark:hover:text-white rounded hover:bg-[#eaeaea] dark:hover:bg-[#222222] transition-colors",children:f.jsx(ih,{className:`w-3 h-3 ${g?"animate-spin text-blue-500":""}`})})]}),f.jsxs("div",{className:"flex flex-col gap-3 text-xs",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] dark:text-[#888888] text-[11px] block mb-1",children:"标题字体 (Heading Font)"}),f.jsxs("select",{value:m.headingFont,onChange:C=>r({headingFont:C.target.value}),className:"w-full bg-[#fafafa] dark:bg-[#141414] border border-[#d4d4d4] dark:border-[#262626] rounded-md px-2 py-1.5 text-black dark:text-white text-xs focus:outline-none",children:[p.length>0&&f.jsx("optgroup",{label:"✨ 项目本地字体 (public/fonts)",children:p.map(C=>f.jsx("option",{value:C.family,children:C.label},`head-local-${C.family}`))}),f.jsx("optgroup",{label:"🌐 系统 / 云端预设",children:g1.map(C=>f.jsx("option",{value:C.value,children:C.label},`head-preset-${C.value}`))})]})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] dark:text-[#888888] text-[11px] block mb-1",children:"正文字体 (Body Font)"}),f.jsxs("select",{value:m.bodyFont,onChange:C=>r({bodyFont:C.target.value}),className:"w-full bg-[#fafafa] dark:bg-[#141414] border border-[#d4d4d4] dark:border-[#262626] rounded-md px-2 py-1.5 text-black dark:text-white text-xs focus:outline-none",children:[p.length>0&&f.jsx("optgroup",{label:"✨ 项目本地字体 (public/fonts)",children:p.map(C=>f.jsx("option",{value:C.family,children:C.label},`body-local-${C.family}`))}),f.jsx("optgroup",{label:"🌐 系统 / 云端预设",children:g1.map(C=>f.jsx("option",{value:C.value,children:C.label},`body-preset-${C.value}`))})]})]}),p.length===0?f.jsx("div",{className:"text-[10px] text-[#888888] dark:text-[#666666] flex items-center justify-between pt-1 border-t border-[#f5f5f5] dark:border-[#1a1a1a]",children:f.jsxs("span",{children:["💡 将 .ttf / .otf 放入 ",f.jsx("code",{children:"public/fonts/"})," 即可识别"]})}):f.jsx("div",{className:"text-[10px] text-emerald-600 dark:text-emerald-400 flex items-center justify-between pt-1 border-t border-[#f5f5f5] dark:border-[#1a1a1a]",children:f.jsxs("span",{children:["✨ 已加载 ",p.length," 个项目本地字体"]})})]})]}),f.jsxs("div",{className:"p-3.5 border-b border-[#f0f0f0] dark:border-[#1c1c1c]",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[#171717] dark:text-white mb-3",children:[f.jsx(Ep,{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400"}),f.jsx("span",{children:"字号与比例参数"})]}),f.jsxs("div",{className:"flex flex-col gap-3.5 text-xs",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex justify-between text-[#666666] dark:text-[#888888] mb-1 font-mono text-[11px]",children:[f.jsx("span",{children:"基准字号 (Base Size)"}),f.jsxs("span",{className:"text-[#171717] dark:text-white font-semibold",children:[v.baseFontSize,"px"]})]}),f.jsx("input",{type:"range",min:"24",max:"96",step:"1",value:v.baseFontSize,onChange:C=>c({baseFontSize:parseInt(C.target.value,10)}),className:"w-full h-1.5 bg-[#e5e5e5] dark:bg-[#222222] rounded-lg cursor-pointer"})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex justify-between text-[#666666] dark:text-[#888888] mb-1 font-mono text-[11px]",children:[f.jsx("span",{children:"比例字阶系数 (大标题倍率)"}),f.jsxs("span",{className:"text-[#171717] dark:text-white font-semibold",children:[v.scaleRatio.toFixed(2),"x"]})]}),f.jsx("input",{type:"range",min:"1.15",max:"1.6",step:"0.01",value:v.scaleRatio,onChange:C=>c({scaleRatio:parseFloat(C.target.value)}),className:"w-full h-1.5 bg-[#e5e5e5] dark:bg-[#222222] rounded-lg cursor-pointer"})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex justify-between text-[#666666] dark:text-[#888888] mb-1 font-mono text-[11px]",children:[f.jsx("span",{children:"行高舒展倍率"}),f.jsx("span",{className:"text-[#171717] dark:text-white font-semibold",children:v.lineHeightMultiplier.toFixed(2)})]}),f.jsx("input",{type:"range",min:"1.2",max:"1.8",step:"0.02",value:v.lineHeightMultiplier,onChange:C=>c({lineHeightMultiplier:parseFloat(C.target.value)}),className:"w-full h-1.5 bg-[#e5e5e5] dark:bg-[#222222] rounded-lg cursor-pointer"})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex justify-between text-[#666666] dark:text-[#888888] mb-1 font-mono text-[11px]",children:[f.jsx("span",{children:"配图避让间隙 (Gap)"}),f.jsxs("span",{className:"text-[#171717] dark:text-white font-semibold",children:[v.obstacleGap,"px"]})]}),f.jsx("input",{type:"range",min:"12",max:"48",step:"2",value:v.obstacleGap,onChange:C=>c({obstacleGap:parseInt(C.target.value,10)}),className:"w-full h-1.5 bg-[#e5e5e5] dark:bg-[#222222] rounded-lg cursor-pointer"})]})]})]}),f.jsxs("div",{className:"p-3.5 border-b border-[#f0f0f0] dark:border-[#1c1c1c]",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[#171717] dark:text-white mb-3",children:[f.jsx(Sp,{className:"w-3.5 h-3.5 text-emerald-600 dark:text-emerald-400"}),f.jsx("span",{children:"版心安全边距"})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px] font-mono",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#777777] dark:text-[#666666] block mb-1",children:"上边距 (Top)"}),f.jsx("input",{type:"number",value:v.safeArea.top,onChange:C=>d({top:parseInt(C.target.value,10)||0}),className:"w-full bg-[#fafafa] dark:bg-[#141414] border border-[#d4d4d4] dark:border-[#262626] rounded px-2 py-1 text-black dark:text-white"})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#777777] dark:text-[#666666] block mb-1",children:"下边距 (Bottom)"}),f.jsx("input",{type:"number",value:v.safeArea.bottom,onChange:C=>d({bottom:parseInt(C.target.value,10)||0}),className:"w-full bg-[#fafafa] dark:bg-[#141414] border border-[#d4d4d4] dark:border-[#262626] rounded px-2 py-1 text-black dark:text-white"})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#777777] dark:text-[#666666] block mb-1",children:"左边距 (Left)"}),f.jsx("input",{type:"number",value:v.safeArea.left,onChange:C=>d({left:parseInt(C.target.value,10)||0}),className:"w-full bg-[#fafafa] dark:bg-[#141414] border border-[#d4d4d4] dark:border-[#262626] rounded px-2 py-1 text-black dark:text-white"})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#777777] dark:text-[#666666] block mb-1",children:"右边距 (Right)"}),f.jsx("input",{type:"number",value:v.safeArea.right,onChange:C=>d({right:parseInt(C.target.value,10)||0}),className:"w-full bg-[#fafafa] dark:bg-[#141414] border border-[#d4d4d4] dark:border-[#262626] rounded px-2 py-1 text-black dark:text-white"})]})]})]}),f.jsxs("div",{className:"p-3.5 border-b border-[#f0f0f0] dark:border-[#1c1c1c]",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[#171717] dark:text-white mb-3",children:[f.jsx(pp,{className:"w-3.5 h-3.5 text-purple-600 dark:text-purple-400"}),f.jsx("span",{children:"视觉色彩主题"})]}),f.jsxs("div",{className:"flex flex-col gap-2.5 text-xs",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx("button",{onClick:()=>o({bgColor:"#ffffff",textColor:"#171717",headingColor:"#171717",accentColor:"#059669",quoteColor:"#525252",cardBg:"#f5f5f5"}),className:"w-6 h-6 rounded-full bg-[#ffffff] border-2 border-emerald-500 shadow-sm hover:scale-105 transition-all",title:"素白雅致 (推荐)"}),f.jsx("button",{onClick:()=>o({bgColor:"#f9fcfa",textColor:"#22201d",headingColor:"#0f2e22",accentColor:"#1d4f39",quoteColor:"#474038",cardBg:"#ffffff"}),className:"w-6 h-6 rounded-full bg-[#f9fcfa] border border-[#ccc] shadow-sm hover:scale-105 transition-all",title:"纸白浅草"}),f.jsx("button",{onClick:()=>o({bgColor:"#0a0a0a",textColor:"#ededed",headingColor:"#ffffff",accentColor:"#00e676",quoteColor:"#a0a0a0",cardBg:"#121212"}),className:"w-6 h-6 rounded-full bg-[#0a0a0a] border border-[#444] shadow-sm hover:scale-105 transition-all",title:"深邃暗夜"}),f.jsx("button",{onClick:()=>o({bgColor:"#09090b",textColor:"#fafafa",headingColor:"#ffffff",accentColor:"#3b82f6",quoteColor:"#a1a1aa",cardBg:"#18181b"}),className:"w-6 h-6 rounded-full bg-[#09090b] border border-blue-500 shadow-sm hover:scale-105 transition-all",title:"数码蓝暗黑"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-[#666666] dark:text-[#888888] font-medium",children:"标题颜色 (Heading)"}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("input",{type:"color",value:y.headingColor||y.textColor,onChange:C=>o({headingColor:C.target.value}),className:"w-6 h-6 rounded cursor-pointer bg-transparent border-0"}),f.jsx("span",{className:"font-mono text-[11px] text-[#444444] dark:text-[#cccccc]",children:y.headingColor||y.textColor})]})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-[#666666] dark:text-[#888888]",children:"正文字色 (Text)"}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("input",{type:"color",value:y.textColor,onChange:C=>o({textColor:C.target.value}),className:"w-6 h-6 rounded cursor-pointer bg-transparent border-0"}),f.jsx("span",{className:"font-mono text-[11px] text-[#444444] dark:text-[#cccccc]",children:y.textColor})]})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-[#666666] dark:text-[#888888]",children:"重点强调色 (Accent)"}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("input",{type:"color",value:y.accentColor,onChange:C=>o({accentColor:C.target.value}),className:"w-6 h-6 rounded cursor-pointer bg-transparent border-0"}),f.jsx("span",{className:"font-mono text-[11px] text-[#444444] dark:text-[#cccccc]",children:y.accentColor})]})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-[#666666] dark:text-[#888888]",children:"背景底色 (Canvas)"}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("input",{type:"color",value:y.bgColor,onChange:C=>o({bgColor:C.target.value}),className:"w-6 h-6 rounded cursor-pointer bg-transparent border-0"}),f.jsx("span",{className:"font-mono text-[11px] text-[#444444] dark:text-[#cccccc]",children:y.bgColor})]})]})]})]}),f.jsxs("div",{className:"p-3.5",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[#171717] dark:text-white mb-3",children:[f.jsx(ap,{className:"w-3.5 h-3.5 text-amber-500 dark:text-amber-400"}),f.jsx("span",{children:"页眉页脚与版式装饰 (Chrome)"})]}),f.jsxs("div",{className:"flex flex-col gap-3 text-xs",children:[f.jsxs("div",{className:"bg-[#f9f9f9] dark:bg-[#141414] p-2.5 rounded-lg border border-[#eaeaea] dark:border-[#222222] flex flex-col gap-2",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"font-semibold text-[#333333] dark:text-[#cccccc] text-[11px]",children:"顶部栏 (Header)"}),f.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:u.chrome?.showHeader??!!u.watermarkText?.trim(),onChange:C=>b({showHeader:C.target.checked}),className:"rounded text-emerald-500 accent-emerald-500 cursor-pointer"}),f.jsx("span",{className:"text-[10px] text-[#666666] dark:text-[#888888]",children:"启用"})]})]}),(u.chrome?.showHeader??!!u.watermarkText?.trim())&&f.jsxs("div",{className:"flex flex-col gap-2 pl-2 border-l-2 border-[#e0e0e0] dark:border-[#2a2a2a] mt-1",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-1",children:[f.jsx("span",{className:"text-[#777777] dark:text-[#888888] text-[10px]",children:"水印 / 品牌标识"}),f.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-[#666666] dark:text-[#888888] cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:u.chrome?.showWatermark??!0,onChange:C=>b({showWatermark:C.target.checked}),className:"rounded accent-emerald-500 cursor-pointer"}),f.jsx("span",{children:"显示"})]})]}),f.jsx("input",{type:"text",value:u.watermarkText,onChange:C=>h(u.footerText,C.target.value),placeholder:"作者水印/标识文本...",className:"w-full bg-white dark:bg-[#0a0a0a] border border-[#d4d4d4] dark:border-[#262626] rounded px-2 py-1 text-black dark:text-white text-[11px]"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-[#777777] dark:text-[#888888] text-[10px]",children:"页码角标 (P.01)"}),f.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-[#666666] dark:text-[#888888] cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:u.chrome?.showPageNumber??u.aspectRatio==="longform-3-4",onChange:C=>b({showPageNumber:C.target.checked}),className:"rounded accent-emerald-500 cursor-pointer"}),f.jsx("span",{children:"显示"})]})]})]})]}),f.jsxs("div",{className:"bg-[#f9f9f9] dark:bg-[#141414] p-2.5 rounded-lg border border-[#eaeaea] dark:border-[#222222] flex flex-col gap-2",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"font-semibold text-[#333333] dark:text-[#cccccc] text-[11px]",children:"底部栏 (Footer)"}),f.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:u.chrome?.showFooter??!!u.footerText?.trim(),onChange:C=>b({showFooter:C.target.checked}),className:"rounded text-emerald-500 accent-emerald-500 cursor-pointer"}),f.jsx("span",{className:"text-[10px] text-[#666666] dark:text-[#888888]",children:"启用"})]})]}),(u.chrome?.showFooter??!!u.footerText?.trim())&&f.jsxs("div",{className:"flex flex-col gap-2 pl-2 border-l-2 border-[#e0e0e0] dark:border-[#2a2a2a] mt-1",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-1",children:[f.jsx("span",{className:"text-[#777777] dark:text-[#888888] text-[10px]",children:"页脚署名 / 版权"}),f.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-[#666666] dark:text-[#888888] cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:u.chrome?.showFooterText??!0,onChange:C=>b({showFooterText:C.target.checked}),className:"rounded accent-emerald-500 cursor-pointer"}),f.jsx("span",{children:"显示"})]})]}),f.jsx("input",{type:"text",value:u.footerText,onChange:C=>h(C.target.value,u.watermarkText),placeholder:"页脚版权/署名...",className:"w-full bg-white dark:bg-[#0a0a0a] border border-[#d4d4d4] dark:border-[#262626] rounded px-2 py-1 text-black dark:text-white text-[11px]"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-[#777777] dark:text-[#888888] text-[10px]",children:"顶部分割细线"}),f.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-[#666666] dark:text-[#888888] cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:u.chrome?.showFooterDivider??!!u.footerText?.trim(),onChange:C=>b({showFooterDivider:C.target.checked}),className:"rounded accent-emerald-500 cursor-pointer"}),f.jsx("span",{children:"显示"})]})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-[#777777] dark:text-[#888888] text-[10px]",children:"算法填充率提示"}),f.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-[#666666] dark:text-[#888888] cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:u.chrome?.showFillRatio??!1,onChange:C=>b({showFillRatio:C.target.checked}),className:"rounded accent-emerald-500 cursor-pointer"}),f.jsx("span",{children:"显示"})]})]})]})]})]})]})]})};function Ac(u=[]){if(!Array.isArray(u))throw new RangeError("模板图片必须是数组");const c=new Set;for(const o of u){if(!o||typeof o!="object")throw new RangeError("无效的模板图片");if(o.templateAssetKey===void 0)continue;const r=o.templateAssetKey;if(o.repeatEveryPage!==void 0&&typeof o.repeatEveryPage!="boolean")throw new RangeError(`素材 ${r} 的每页重复开关必须是布尔值`);if(typeof r!="string"||!/^[a-zA-Z0-9_-]+$/.test(r))throw new RangeError("素材标识只能包含字母、数字、下划线和短横线");if(o.repeatEveryPage&&!o.isAbsolute)throw new RangeError(`素材 ${r} 的每页重复仅支持自由定位模式`);if(c.has(r))throw new RangeError(`重复的模板素材标识:${r}`);c.add(r)}}function qp(u,c=[],o={}){if(Ac(c),!o||typeof o!="object"||Array.isArray(o))throw new RangeError("素材替换必须是标识到图片地址的映射");const r=c.filter(v=>v.templateAssetKey);for(const[v,y]of Object.entries(o)){if(!r.some(m=>m.templateAssetKey===v))throw new RangeError(`未知模板素材:${v}`);if(typeof y!="string"||!y.trim())throw new RangeError(`素材 ${v} 的替换图片不能为空`)}const d=u.filter(v=>!v.templateAssetKey),h=c.filter(v=>!v.templateAssetKey);return[...d.length===0?h.map(v=>({...v,id:`img_${crypto.randomUUID()}`})):d.map((v,y)=>{const m=h[y];return m?{...v,layoutPreset:m.layoutPreset??v.layoutPreset,isAbsolute:m.isAbsolute??v.isAbsolute,x:m.x??v.x,y:m.y??v.y,width:m.width??v.width,height:m.height??v.height,rotate:m.rotate??v.rotate,opacity:m.opacity??v.opacity,zIndex:m.zIndex??v.zIndex,borderRadius:m.borderRadius??v.borderRadius,captionHeight:m.captionHeight??v.captionHeight,pageIndex:m.pageIndex??v.pageIndex}:v}),...r.map(v=>({...v,src:Object.hasOwn(o,v.templateAssetKey)?o[v.templateAssetKey]:v.src}))]}const Gp=({isOpen:u,onClose:c,currentConfig:o,onApplyTemplate:r,adminKey:d})=>{const[h,b]=me.useState([]),[v,y]=me.useState({}),[m,p]=me.useState("default"),[g,N]=me.useState("all"),[C,V]=me.useState(!1),[W,L]=me.useState(""),[U,te]=me.useState(()=>o.aspectRatio==="wechat-cover-2.35"?"article_cover":"newspic_content"),[le,oe]=me.useState(!1),[ce,Z]=me.useState(null),ee=async(Y=m)=>{try{const ae=await fetch(`/api/templates/slots?account=${encodeURIComponent(Y)}`,{headers:{"x-admin-key":d}}),j=await ae.json();if(!ae.ok||!j.ok)throw new Error(j.message||j.error||"获取槽位失败");j.ok&&j.slots&&y(j.slots)}catch(ae){Z(ae instanceof Error?ae.message:"模板请求失败")}},G=async(Y,ae)=>{try{const j=await fetch("/api/templates/slots",{method:"POST",headers:{"Content-Type":"application/json",...d?{"x-admin-key":d}:{}},body:JSON.stringify({slot:Y,templateId:ae,account:m})}),B=await j.json();if(!j.ok||!B.ok)throw new Error(B.message||B.error||"设置默认模板失败");B.ok&&await ee(m)}catch(j){Z(j instanceof Error?j.message:"模板请求失败")}},A=async()=>{V(!0),Z(null);try{const Y=await fetch("/api/templates",{headers:d?{"x-admin-key":d}:{}}),ae=await Y.json();Y.ok&&ae.ok&&Array.isArray(ae.templates)?b(ae.templates):Z(ae.message||"获取模板失败,请检查密钥")}catch{Z("连接后端服务失败")}finally{V(!1)}};me.useEffect(()=>{u&&(A(),ee(m),L(o.name?`${o.name} 副本`:"我的自定义模板"),te(o.aspectRatio==="wechat-cover-2.35"?"article_cover":"newspic_content"))},[u,m,d]);const X=async()=>{if(W.trim()){oe(!0);try{Ac(o.images);const Y={...o,id:void 0,name:W.trim(),slot:U!=="none"?U:void 0},ae=await fetch("/api/templates",{method:"POST",headers:{"Content-Type":"application/json",...d?{"x-admin-key":d}:{}},body:JSON.stringify(Y)}),j=await ae.json();ae.ok&&j.ok?(await A(),await ee(m)):Z(j.message||j.error||"保存模板失败")}catch(Y){Z(Y instanceof Error?Y.message:"保存模板请求异常")}finally{oe(!1)}}},D=async Y=>{try{const ae=await fetch(`/api/templates/${encodeURIComponent(Y)}`,{method:"DELETE",headers:d?{"x-admin-key":d}:{}}),j=await ae.json();if(!ae.ok||!j.ok)throw new Error(j.message||j.error||"删除模板失败");b(B=>B.filter(k=>k.id!==Y)),await ee(m)}catch(ae){Z(ae instanceof Error?ae.message:"模板请求失败")}};if(!u)return null;const $=h.filter(Y=>g==="all"?!0:Y.slot===g);return f.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 dark:bg-black/70 backdrop-blur-sm flex items-center justify-center p-4",children:f.jsxs("div",{className:"bg-white dark:bg-[#0f0f0f] border border-[#eaeaea] dark:border-[#262626] rounded-xl w-full max-w-xl flex flex-col shadow-2xl overflow-hidden animate-in fade-in zoom-in-95 duration-150 transition-colors",children:[f.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-[#eaeaea] dark:border-[#222222]",children:[f.jsxs("div",{className:"flex items-center gap-2 font-semibold text-sm text-[#171717] dark:text-white",children:[f.jsx(bo,{className:"w-4 h-4 text-emerald-500 dark:text-emerald-400"}),f.jsx("span",{children:"排版模板中心"})]}),f.jsx("button",{onClick:c,className:"text-[#888888] hover:text-black dark:hover:text-white p-1 rounded-md hover:bg-[#f5f5f5] dark:hover:bg-[#1a1a1a]",children:f.jsx(Sh,{className:"w-4 h-4"})})]}),f.jsxs("div",{className:"p-5 flex flex-col gap-4 max-h-[75vh] overflow-y-auto",children:[f.jsxs("div",{className:"bg-[#f9f9f9] dark:bg-[#141414] border border-[#eaeaea] dark:border-[#222222] rounded-lg p-3 flex flex-col gap-2.5",children:[f.jsx("span",{className:"text-xs text-[#666666] dark:text-[#888888] font-medium",children:"将当前参数另存为模板"}),f.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[f.jsx("input",{type:"text",value:W,onChange:Y=>L(Y.target.value),placeholder:"模板名称...",className:"flex-1 bg-white dark:bg-[#0a0a0a] border border-[#d4d4d4] dark:border-[#2a2a2a] rounded px-3 py-1.5 text-xs text-black dark:text-white focus:outline-none focus:border-black dark:focus:border-[#444444]"}),f.jsxs("select",{value:U,onChange:Y=>te(Y.target.value),className:"bg-white dark:bg-[#0a0a0a] border border-[#d4d4d4] dark:border-[#2a2a2a] rounded px-2 py-1.5 text-xs text-black dark:text-white focus:outline-none focus:border-black dark:focus:border-[#444444]",children:[f.jsx("option",{value:"article_cover",children:"槽位: 文章封面 (2.35:1)"}),f.jsx("option",{value:"newspic_cover",children:"槽位: 贴图封面 (3:4)"}),f.jsx("option",{value:"newspic_content",children:"槽位: 贴图内容 (3:4)"}),f.jsx("option",{value:"none",children:"槽位: 通用模板"})]}),f.jsxs("button",{onClick:X,disabled:le,className:"flex items-center justify-center gap-1.5 px-3 py-1.5 bg-black text-white hover:bg-[#262626] dark:bg-white dark:text-black dark:hover:bg-[#eaeaea] text-xs font-semibold rounded transition-all btn-vercel disabled:opacity-50 shrink-0",children:[f.jsx(rp,{className:"w-3.5 h-3.5"}),f.jsx("span",{children:le?"保存中...":"保存模板"})]})]})]}),ce&&f.jsx("div",{className:"text-xs text-amber-600 dark:text-amber-400 bg-amber-500/10 border border-amber-500/20 px-3 py-2 rounded-lg",children:ce}),f.jsxs("div",{className:"flex flex-col gap-2 pt-1 border-t border-[#eaeaea] dark:border-[#222222]",children:[f.jsx("div",{className:"flex items-center justify-between text-xs",children:f.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-[#666666] dark:text-[#888888]",children:[f.jsx("span",{children:"默认槽位配置账号:"}),f.jsxs("select",{value:m,onChange:Y=>p(Y.target.value),className:"bg-white dark:bg-[#141414] border border-[#d4d4d4] dark:border-[#2a2a2a] rounded px-2 py-0.5 text-xs text-black dark:text-white focus:outline-none font-mono",children:[f.jsx("option",{value:"default",children:"default (主账号)"}),f.jsx("option",{value:"ancientone",children:"ancientone"})]})]})}),f.jsxs("div",{className:"flex items-center gap-1.5 text-xs overflow-x-auto pb-1",children:[f.jsx("button",{onClick:()=>N("all"),className:`px-2.5 py-1 rounded text-xs transition-colors font-medium ${g==="all"?"bg-black text-white dark:bg-white dark:text-black":"text-[#666666] dark:text-[#888888] hover:bg-[#f5f5f5] dark:hover:bg-[#1c1c1c]"}`,children:"全部"}),f.jsx("button",{onClick:()=>N("article_cover"),className:`px-2.5 py-1 rounded text-xs transition-colors font-medium ${g==="article_cover"?"bg-black text-white dark:bg-white dark:text-black":"text-[#666666] dark:text-[#888888] hover:bg-[#f5f5f5] dark:hover:bg-[#1c1c1c]"}`,children:"文章封面"}),f.jsx("button",{onClick:()=>N("newspic_cover"),className:`px-2.5 py-1 rounded text-xs transition-colors font-medium ${g==="newspic_cover"?"bg-black text-white dark:bg-white dark:text-black":"text-[#666666] dark:text-[#888888] hover:bg-[#f5f5f5] dark:hover:bg-[#1c1c1c]"}`,children:"贴图封面"}),f.jsx("button",{onClick:()=>N("newspic_content"),className:`px-2.5 py-1 rounded text-xs transition-colors font-medium ${g==="newspic_content"?"bg-black text-white dark:bg-white dark:text-black":"text-[#666666] dark:text-[#888888] hover:bg-[#f5f5f5] dark:hover:bg-[#1c1c1c]"}`,children:"贴图内容"})]})]}),f.jsx("div",{className:"flex flex-col gap-2",children:C?f.jsx("div",{className:"text-center py-8 text-xs text-[#888888] dark:text-[#555555]",children:"正在加载模板..."}):$.length===0?f.jsx("div",{className:"text-center py-8 text-xs text-[#888888] dark:text-[#555555]",children:"暂无匹配模板"}):$.map(Y=>{const ae=v.article_cover?.id===Y.id,j=v.newspic_cover?.id===Y.id,B=v.newspic_content?.id===Y.id;return f.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between p-3 rounded-lg bg-[#fafafa] dark:bg-[#141414] border border-[#eaeaea] dark:border-[#222222] hover:border-[#cccccc] dark:hover:border-[#333333] transition-all gap-2 group",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-5 h-5 rounded border border-[#d4d4d4] dark:border-[#333333] shrink-0",style:{backgroundColor:Y.theme.bgColor}}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[f.jsx("span",{className:"text-xs font-semibold text-[#171717] dark:text-white",children:Y.name}),Y.slot&&f.jsx("span",{className:"text-[10px] px-1.5 py-0.2 rounded bg-blue-500/10 text-blue-600 dark:text-blue-400 border border-blue-500/20 font-medium",children:Y.slot==="article_cover"?"文章封面":Y.slot==="newspic_cover"?"贴图封面":"贴图内容"}),ae&&f.jsxs("span",{className:"text-[10px] px-1.5 py-0.2 rounded bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20 font-medium flex items-center gap-0.5",children:[f.jsx(fo,{className:"w-2.5 h-2.5 fill-amber-500"})," 文章封面默认"]}),j&&f.jsxs("span",{className:"text-[10px] px-1.5 py-0.2 rounded bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20 font-medium flex items-center gap-0.5",children:[f.jsx(fo,{className:"w-2.5 h-2.5 fill-amber-500"})," 贴图封面默认"]}),B&&f.jsxs("span",{className:"text-[10px] px-1.5 py-0.2 rounded bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20 font-medium flex items-center gap-0.5",children:[f.jsx(fo,{className:"w-2.5 h-2.5 fill-emerald-500"})," 贴图内容默认"]})]}),f.jsxs("div",{className:"text-[10px] text-[#888888] dark:text-[#666666] font-mono mt-0.5",children:[Y.aspectRatio," • 字号: ",Y.algorithm.baseFontSize,"px",Y.images&&Y.images.length>0&&` • 配图: ${Y.images.length}个`]})]})]}),f.jsxs("div",{className:"flex items-center gap-2 self-end sm:self-auto",children:[Y.id&&f.jsxs("select",{value:"",onChange:k=>{k.target.value&&G(k.target.value,Y.id)},className:"text-[11px] bg-white dark:bg-[#1a1a1a] border border-[#d4d4d4] dark:border-[#333333] text-[#666666] dark:text-[#aaaaaa] rounded px-2 py-1 focus:outline-none",title:"为此账号设为某个槽位的默认模板",children:[f.jsx("option",{value:"",children:"设为槽位默认..."}),f.jsx("option",{value:"article_cover",children:"设为「文章封面默认」"}),f.jsx("option",{value:"newspic_cover",children:"设为「贴图封面默认」"}),f.jsx("option",{value:"newspic_content",children:"设为「贴图内容默认」"})]}),f.jsxs("button",{onClick:()=>{r(Y),c()},className:"flex items-center gap-1 px-2.5 py-1 bg-white dark:bg-[#1f1f1f] hover:bg-emerald-50 dark:hover:bg-emerald-500/20 text-[#333333] dark:text-[#cccccc] hover:text-emerald-700 dark:hover:text-emerald-400 border border-[#d4d4d4] dark:border-[#2a2a2a] hover:border-emerald-500/40 rounded text-xs transition-all font-medium",children:[f.jsx(q1,{className:"w-3 h-3"}),f.jsx("span",{children:"套用"})]}),Y.id&&!Y.id.startsWith("tpl_wechat_")&&!Y.id.startsWith("tpl_longform_")&&!Y.id.startsWith("tpl_square_")&&!Y.id.startsWith("tpl_wide_")&&f.jsx("button",{onClick:()=>D(Y.id),className:"p-1 text-[#888888] dark:text-[#555555] hover:text-red-500 rounded hover:bg-[#f0f0f0] dark:hover:bg-[#1f1f1f]",title:"删除自定义模板",children:f.jsx(vh,{className:"w-3.5 h-3.5"})})]})]},Y.id)})})]})]})})},xo="typeset_studio_admin_key";function Yp(){const[u,c]=me.useState(()=>localStorage.getItem(xo)||""),[o,r]=me.useState(null),[d,h]=me.useState(!1),b=async y=>{if(!y)return r(!1),!1;h(!0);try{const g=!!(await(await fetch("/api/auth/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:y})})).json()).ok;return r(g),g}catch{return r(!1),!1}finally{h(!1)}},v=y=>{localStorage.setItem(xo,y),c(y),b(y)};return me.useEffect(()=>{(async()=>{let m=u;if(!m)try{const g=await(await fetch("/api/auth/current-key")).json();g.ok&&g.key&&(m=g.key,c(g.key),localStorage.setItem(xo,g.key))}catch{}m?b(m):r(!1)})()},[]),{adminKey:u,setAdminKey:v,isVerified:o,isVerifying:d,verifyKey:b}}const Xp=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","BN","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],p1=[[697,698,"ON"],[706,719,"ON"],[722,735,"ON"],[741,749,"ON"],[751,767,"ON"],[768,879,"NSM"],[884,885,"ON"],[894,894,"ON"],[900,901,"ON"],[903,903,"ON"],[1014,1014,"ON"],[1155,1161,"NSM"],[1418,1418,"ON"],[1421,1422,"ON"],[1423,1423,"ET"],[1424,1424,"R"],[1425,1469,"NSM"],[1470,1470,"R"],[1471,1471,"NSM"],[1472,1472,"R"],[1473,1474,"NSM"],[1475,1475,"R"],[1476,1477,"NSM"],[1478,1478,"R"],[1479,1479,"NSM"],[1480,1535,"R"],[1536,1541,"AN"],[1542,1543,"ON"],[1544,1544,"AL"],[1545,1546,"ET"],[1547,1547,"AL"],[1548,1548,"CS"],[1549,1549,"AL"],[1550,1551,"ON"],[1552,1562,"NSM"],[1563,1610,"AL"],[1611,1631,"NSM"],[1632,1641,"AN"],[1642,1642,"ET"],[1643,1644,"AN"],[1645,1647,"AL"],[1648,1648,"NSM"],[1649,1749,"AL"],[1750,1756,"NSM"],[1757,1757,"AN"],[1758,1758,"ON"],[1759,1764,"NSM"],[1765,1766,"AL"],[1767,1768,"NSM"],[1769,1769,"ON"],[1770,1773,"NSM"],[1774,1775,"AL"],[1776,1785,"EN"],[1786,1808,"AL"],[1809,1809,"NSM"],[1810,1839,"AL"],[1840,1866,"NSM"],[1867,1957,"AL"],[1958,1968,"NSM"],[1969,1983,"AL"],[1984,2026,"R"],[2027,2035,"NSM"],[2036,2037,"R"],[2038,2041,"ON"],[2042,2044,"R"],[2045,2045,"NSM"],[2046,2069,"R"],[2070,2073,"NSM"],[2074,2074,"R"],[2075,2083,"NSM"],[2084,2084,"R"],[2085,2087,"NSM"],[2088,2088,"R"],[2089,2093,"NSM"],[2094,2136,"R"],[2137,2139,"NSM"],[2140,2143,"R"],[2144,2191,"AL"],[2192,2193,"AN"],[2194,2198,"AL"],[2199,2207,"NSM"],[2208,2249,"AL"],[2250,2273,"NSM"],[2274,2274,"AN"],[2275,2306,"NSM"],[2362,2362,"NSM"],[2364,2364,"NSM"],[2369,2376,"NSM"],[2381,2381,"NSM"],[2385,2391,"NSM"],[2402,2403,"NSM"],[2433,2433,"NSM"],[2492,2492,"NSM"],[2497,2500,"NSM"],[2509,2509,"NSM"],[2530,2531,"NSM"],[2546,2547,"ET"],[2555,2555,"ET"],[2558,2558,"NSM"],[2561,2562,"NSM"],[2620,2620,"NSM"],[2625,2626,"NSM"],[2631,2632,"NSM"],[2635,2637,"NSM"],[2641,2641,"NSM"],[2672,2673,"NSM"],[2677,2677,"NSM"],[2689,2690,"NSM"],[2748,2748,"NSM"],[2753,2757,"NSM"],[2759,2760,"NSM"],[2765,2765,"NSM"],[2786,2787,"NSM"],[2801,2801,"ET"],[2810,2815,"NSM"],[2817,2817,"NSM"],[2876,2876,"NSM"],[2879,2879,"NSM"],[2881,2884,"NSM"],[2893,2893,"NSM"],[2901,2902,"NSM"],[2914,2915,"NSM"],[2946,2946,"NSM"],[3008,3008,"NSM"],[3021,3021,"NSM"],[3059,3064,"ON"],[3065,3065,"ET"],[3066,3066,"ON"],[3072,3072,"NSM"],[3076,3076,"NSM"],[3132,3132,"NSM"],[3134,3136,"NSM"],[3142,3144,"NSM"],[3146,3149,"NSM"],[3157,3158,"NSM"],[3170,3171,"NSM"],[3192,3198,"ON"],[3201,3201,"NSM"],[3260,3260,"NSM"],[3276,3277,"NSM"],[3298,3299,"NSM"],[3328,3329,"NSM"],[3387,3388,"NSM"],[3393,3396,"NSM"],[3405,3405,"NSM"],[3426,3427,"NSM"],[3457,3457,"NSM"],[3530,3530,"NSM"],[3538,3540,"NSM"],[3542,3542,"NSM"],[3633,3633,"NSM"],[3636,3642,"NSM"],[3647,3647,"ET"],[3655,3662,"NSM"],[3761,3761,"NSM"],[3764,3772,"NSM"],[3784,3790,"NSM"],[3864,3865,"NSM"],[3893,3893,"NSM"],[3895,3895,"NSM"],[3897,3897,"NSM"],[3898,3901,"ON"],[3953,3966,"NSM"],[3968,3972,"NSM"],[3974,3975,"NSM"],[3981,3991,"NSM"],[3993,4028,"NSM"],[4038,4038,"NSM"],[4141,4144,"NSM"],[4146,4151,"NSM"],[4153,4154,"NSM"],[4157,4158,"NSM"],[4184,4185,"NSM"],[4190,4192,"NSM"],[4209,4212,"NSM"],[4226,4226,"NSM"],[4229,4230,"NSM"],[4237,4237,"NSM"],[4253,4253,"NSM"],[4957,4959,"NSM"],[5008,5017,"ON"],[5120,5120,"ON"],[5760,5760,"WS"],[5787,5788,"ON"],[5906,5908,"NSM"],[5938,5939,"NSM"],[5970,5971,"NSM"],[6002,6003,"NSM"],[6068,6069,"NSM"],[6071,6077,"NSM"],[6086,6086,"NSM"],[6089,6099,"NSM"],[6107,6107,"ET"],[6109,6109,"NSM"],[6128,6137,"ON"],[6144,6154,"ON"],[6155,6157,"NSM"],[6158,6158,"BN"],[6159,6159,"NSM"],[6277,6278,"NSM"],[6313,6313,"NSM"],[6432,6434,"NSM"],[6439,6440,"NSM"],[6450,6450,"NSM"],[6457,6459,"NSM"],[6464,6464,"ON"],[6468,6469,"ON"],[6622,6655,"ON"],[6679,6680,"NSM"],[6683,6683,"NSM"],[6742,6742,"NSM"],[6744,6750,"NSM"],[6752,6752,"NSM"],[6754,6754,"NSM"],[6757,6764,"NSM"],[6771,6780,"NSM"],[6783,6783,"NSM"],[6832,6877,"NSM"],[6880,6891,"NSM"],[6912,6915,"NSM"],[6964,6964,"NSM"],[6966,6970,"NSM"],[6972,6972,"NSM"],[6978,6978,"NSM"],[7019,7027,"NSM"],[7040,7041,"NSM"],[7074,7077,"NSM"],[7080,7081,"NSM"],[7083,7085,"NSM"],[7142,7142,"NSM"],[7144,7145,"NSM"],[7149,7149,"NSM"],[7151,7153,"NSM"],[7212,7219,"NSM"],[7222,7223,"NSM"],[7376,7378,"NSM"],[7380,7392,"NSM"],[7394,7400,"NSM"],[7405,7405,"NSM"],[7412,7412,"NSM"],[7416,7417,"NSM"],[7616,7679,"NSM"],[8125,8125,"ON"],[8127,8129,"ON"],[8141,8143,"ON"],[8157,8159,"ON"],[8173,8175,"ON"],[8189,8190,"ON"],[8192,8202,"WS"],[8203,8205,"BN"],[8207,8207,"R"],[8208,8231,"ON"],[8232,8232,"WS"],[8233,8233,"B"],[8234,8238,"BN"],[8239,8239,"CS"],[8240,8244,"ET"],[8245,8259,"ON"],[8260,8260,"CS"],[8261,8286,"ON"],[8287,8287,"WS"],[8288,8303,"BN"],[8304,8304,"EN"],[8308,8313,"EN"],[8314,8315,"ES"],[8316,8318,"ON"],[8320,8329,"EN"],[8330,8331,"ES"],[8332,8334,"ON"],[8352,8399,"ET"],[8400,8432,"NSM"],[8448,8449,"ON"],[8451,8454,"ON"],[8456,8457,"ON"],[8468,8468,"ON"],[8470,8472,"ON"],[8478,8483,"ON"],[8485,8485,"ON"],[8487,8487,"ON"],[8489,8489,"ON"],[8494,8494,"ET"],[8506,8507,"ON"],[8512,8516,"ON"],[8522,8525,"ON"],[8528,8543,"ON"],[8585,8587,"ON"],[8592,8721,"ON"],[8722,8722,"ES"],[8723,8723,"ET"],[8724,9013,"ON"],[9083,9108,"ON"],[9110,9257,"ON"],[9280,9290,"ON"],[9312,9351,"ON"],[9352,9371,"EN"],[9450,9899,"ON"],[9901,10239,"ON"],[10496,11123,"ON"],[11126,11263,"ON"],[11493,11498,"ON"],[11503,11505,"NSM"],[11513,11519,"ON"],[11647,11647,"NSM"],[11744,11775,"NSM"],[11776,11869,"ON"],[11904,11929,"ON"],[11931,12019,"ON"],[12032,12245,"ON"],[12272,12287,"ON"],[12288,12288,"WS"],[12289,12292,"ON"],[12296,12320,"ON"],[12330,12333,"NSM"],[12336,12336,"ON"],[12342,12343,"ON"],[12349,12351,"ON"],[12441,12442,"NSM"],[12443,12444,"ON"],[12448,12448,"ON"],[12539,12539,"ON"],[12736,12773,"ON"],[12783,12783,"ON"],[12829,12830,"ON"],[12880,12895,"ON"],[12924,12926,"ON"],[12977,12991,"ON"],[13004,13007,"ON"],[13175,13178,"ON"],[13278,13279,"ON"],[13311,13311,"ON"],[19904,19967,"ON"],[42128,42182,"ON"],[42509,42511,"ON"],[42607,42610,"NSM"],[42611,42611,"ON"],[42612,42621,"NSM"],[42622,42623,"ON"],[42654,42655,"NSM"],[42736,42737,"NSM"],[42752,42785,"ON"],[42888,42888,"ON"],[43010,43010,"NSM"],[43014,43014,"NSM"],[43019,43019,"NSM"],[43045,43046,"NSM"],[43048,43051,"ON"],[43052,43052,"NSM"],[43064,43065,"ET"],[43124,43127,"ON"],[43204,43205,"NSM"],[43232,43249,"NSM"],[43263,43263,"NSM"],[43302,43309,"NSM"],[43335,43345,"NSM"],[43392,43394,"NSM"],[43443,43443,"NSM"],[43446,43449,"NSM"],[43452,43453,"NSM"],[43493,43493,"NSM"],[43561,43566,"NSM"],[43569,43570,"NSM"],[43573,43574,"NSM"],[43587,43587,"NSM"],[43596,43596,"NSM"],[43644,43644,"NSM"],[43696,43696,"NSM"],[43698,43700,"NSM"],[43703,43704,"NSM"],[43710,43711,"NSM"],[43713,43713,"NSM"],[43756,43757,"NSM"],[43766,43766,"NSM"],[43882,43883,"ON"],[44005,44005,"NSM"],[44008,44008,"NSM"],[44013,44013,"NSM"],[64285,64285,"R"],[64286,64286,"NSM"],[64287,64296,"R"],[64297,64297,"ES"],[64298,64335,"R"],[64336,64450,"AL"],[64451,64466,"ON"],[64467,64829,"AL"],[64830,64847,"ON"],[64848,64911,"AL"],[64912,64913,"ON"],[64914,64967,"AL"],[64968,64975,"ON"],[64976,65007,"BN"],[65008,65020,"AL"],[65021,65023,"ON"],[65024,65039,"NSM"],[65040,65049,"ON"],[65056,65071,"NSM"],[65072,65103,"ON"],[65104,65104,"CS"],[65105,65105,"ON"],[65106,65106,"CS"],[65108,65108,"ON"],[65109,65109,"CS"],[65110,65118,"ON"],[65119,65119,"ET"],[65120,65121,"ON"],[65122,65123,"ES"],[65124,65126,"ON"],[65128,65128,"ON"],[65129,65130,"ET"],[65131,65131,"ON"],[65136,65278,"AL"],[65279,65279,"BN"],[65281,65282,"ON"],[65283,65285,"ET"],[65286,65290,"ON"],[65291,65291,"ES"],[65292,65292,"CS"],[65293,65293,"ES"],[65294,65295,"CS"],[65296,65305,"EN"],[65306,65306,"CS"],[65307,65312,"ON"],[65339,65344,"ON"],[65371,65381,"ON"],[65504,65505,"ET"],[65506,65508,"ON"],[65509,65510,"ET"],[65512,65518,"ON"],[65520,65528,"BN"],[65529,65533,"ON"],[65534,65535,"BN"],[65793,65793,"ON"],[65856,65932,"ON"],[65936,65948,"ON"],[65952,65952,"ON"],[66045,66045,"NSM"],[66272,66272,"NSM"],[66273,66299,"EN"],[66422,66426,"NSM"],[67584,67870,"R"],[67871,67871,"ON"],[67872,68096,"R"],[68097,68099,"NSM"],[68100,68100,"R"],[68101,68102,"NSM"],[68103,68107,"R"],[68108,68111,"NSM"],[68112,68151,"R"],[68152,68154,"NSM"],[68155,68158,"R"],[68159,68159,"NSM"],[68160,68324,"R"],[68325,68326,"NSM"],[68327,68408,"R"],[68409,68415,"ON"],[68416,68863,"R"],[68864,68899,"AL"],[68900,68903,"NSM"],[68904,68911,"AL"],[68912,68921,"AN"],[68922,68927,"AL"],[68928,68937,"AN"],[68938,68968,"R"],[68969,68973,"NSM"],[68974,68974,"ON"],[68975,69215,"R"],[69216,69246,"AN"],[69247,69290,"R"],[69291,69292,"NSM"],[69293,69311,"R"],[69312,69327,"AL"],[69328,69336,"ON"],[69337,69369,"AL"],[69370,69375,"NSM"],[69376,69423,"R"],[69424,69445,"AL"],[69446,69456,"NSM"],[69457,69487,"AL"],[69488,69505,"R"],[69506,69509,"NSM"],[69510,69631,"R"],[69633,69633,"NSM"],[69688,69702,"NSM"],[69714,69733,"ON"],[69744,69744,"NSM"],[69747,69748,"NSM"],[69759,69761,"NSM"],[69811,69814,"NSM"],[69817,69818,"NSM"],[69826,69826,"NSM"],[69888,69890,"NSM"],[69927,69931,"NSM"],[69933,69940,"NSM"],[70003,70003,"NSM"],[70016,70017,"NSM"],[70070,70078,"NSM"],[70089,70092,"NSM"],[70095,70095,"NSM"],[70191,70193,"NSM"],[70196,70196,"NSM"],[70198,70199,"NSM"],[70206,70206,"NSM"],[70209,70209,"NSM"],[70367,70367,"NSM"],[70371,70378,"NSM"],[70400,70401,"NSM"],[70459,70460,"NSM"],[70464,70464,"NSM"],[70502,70508,"NSM"],[70512,70516,"NSM"],[70587,70592,"NSM"],[70606,70606,"NSM"],[70608,70608,"NSM"],[70610,70610,"NSM"],[70625,70626,"NSM"],[70712,70719,"NSM"],[70722,70724,"NSM"],[70726,70726,"NSM"],[70750,70750,"NSM"],[70835,70840,"NSM"],[70842,70842,"NSM"],[70847,70848,"NSM"],[70850,70851,"NSM"],[71090,71093,"NSM"],[71100,71101,"NSM"],[71103,71104,"NSM"],[71132,71133,"NSM"],[71219,71226,"NSM"],[71229,71229,"NSM"],[71231,71232,"NSM"],[71264,71276,"ON"],[71339,71339,"NSM"],[71341,71341,"NSM"],[71344,71349,"NSM"],[71351,71351,"NSM"],[71453,71453,"NSM"],[71455,71455,"NSM"],[71458,71461,"NSM"],[71463,71467,"NSM"],[71727,71735,"NSM"],[71737,71738,"NSM"],[71995,71996,"NSM"],[71998,71998,"NSM"],[72003,72003,"NSM"],[72148,72151,"NSM"],[72154,72155,"NSM"],[72160,72160,"NSM"],[72193,72198,"NSM"],[72201,72202,"NSM"],[72243,72248,"NSM"],[72251,72254,"NSM"],[72263,72263,"NSM"],[72273,72278,"NSM"],[72281,72283,"NSM"],[72330,72342,"NSM"],[72344,72345,"NSM"],[72544,72544,"NSM"],[72546,72548,"NSM"],[72550,72550,"NSM"],[72752,72758,"NSM"],[72760,72765,"NSM"],[72850,72871,"NSM"],[72874,72880,"NSM"],[72882,72883,"NSM"],[72885,72886,"NSM"],[73009,73014,"NSM"],[73018,73018,"NSM"],[73020,73021,"NSM"],[73023,73029,"NSM"],[73031,73031,"NSM"],[73104,73105,"NSM"],[73109,73109,"NSM"],[73111,73111,"NSM"],[73459,73460,"NSM"],[73472,73473,"NSM"],[73526,73530,"NSM"],[73536,73536,"NSM"],[73538,73538,"NSM"],[73562,73562,"NSM"],[73685,73692,"ON"],[73693,73696,"ET"],[73697,73713,"ON"],[78912,78912,"NSM"],[78919,78933,"NSM"],[90398,90409,"NSM"],[90413,90415,"NSM"],[92912,92916,"NSM"],[92976,92982,"NSM"],[94031,94031,"NSM"],[94095,94098,"NSM"],[94178,94178,"ON"],[94180,94180,"NSM"],[113821,113822,"NSM"],[113824,113827,"BN"],[117760,117973,"ON"],[118e3,118009,"EN"],[118010,118012,"ON"],[118016,118451,"ON"],[118458,118480,"ON"],[118496,118512,"ON"],[118528,118573,"NSM"],[118576,118598,"NSM"],[119143,119145,"NSM"],[119155,119162,"BN"],[119163,119170,"NSM"],[119173,119179,"NSM"],[119210,119213,"NSM"],[119273,119274,"ON"],[119296,119361,"ON"],[119362,119364,"NSM"],[119365,119365,"ON"],[119552,119638,"ON"],[120513,120513,"ON"],[120539,120539,"ON"],[120571,120571,"ON"],[120597,120597,"ON"],[120629,120629,"ON"],[120655,120655,"ON"],[120687,120687,"ON"],[120713,120713,"ON"],[120745,120745,"ON"],[120771,120771,"ON"],[120782,120831,"EN"],[121344,121398,"NSM"],[121403,121452,"NSM"],[121461,121461,"NSM"],[121476,121476,"NSM"],[121499,121503,"NSM"],[121505,121519,"NSM"],[122880,122886,"NSM"],[122888,122904,"NSM"],[122907,122913,"NSM"],[122915,122916,"NSM"],[122918,122922,"NSM"],[123023,123023,"NSM"],[123184,123190,"NSM"],[123566,123566,"NSM"],[123628,123631,"NSM"],[123647,123647,"ET"],[124140,124143,"NSM"],[124398,124399,"NSM"],[124643,124643,"NSM"],[124646,124646,"NSM"],[124654,124655,"NSM"],[124661,124661,"NSM"],[124928,125135,"R"],[125136,125142,"NSM"],[125143,125251,"R"],[125252,125258,"NSM"],[125259,126063,"R"],[126064,126143,"AL"],[126144,126207,"R"],[126208,126287,"AL"],[126288,126463,"R"],[126464,126703,"AL"],[126704,126705,"ON"],[126706,126719,"AL"],[126720,126975,"R"],[126976,127019,"ON"],[127024,127123,"ON"],[127136,127150,"ON"],[127153,127167,"ON"],[127169,127183,"ON"],[127185,127221,"ON"],[127232,127242,"EN"],[127243,127247,"ON"],[127279,127279,"ON"],[127338,127343,"ON"],[127405,127405,"ON"],[127584,127589,"ON"],[127744,128728,"ON"],[128732,128748,"ON"],[128752,128764,"ON"],[128768,128985,"ON"],[128992,129003,"ON"],[129008,129008,"ON"],[129024,129035,"ON"],[129040,129095,"ON"],[129104,129113,"ON"],[129120,129159,"ON"],[129168,129197,"ON"],[129200,129211,"ON"],[129216,129217,"ON"],[129232,129240,"ON"],[129280,129623,"ON"],[129632,129645,"ON"],[129648,129660,"ON"],[129664,129674,"ON"],[129678,129734,"ON"],[129736,129736,"ON"],[129741,129756,"ON"],[129759,129770,"ON"],[129775,129784,"ON"],[129792,129938,"ON"],[129940,130031,"ON"],[130032,130041,"EN"],[130042,130042,"ON"],[131070,131071,"BN"],[196606,196607,"BN"],[262142,262143,"BN"],[327678,327679,"BN"],[393214,393215,"BN"],[458750,458751,"BN"],[524286,524287,"BN"],[589822,589823,"BN"],[655358,655359,"BN"],[720894,720895,"BN"],[786430,786431,"BN"],[851966,851967,"BN"],[917502,917759,"BN"],[917760,917999,"NSM"],[918e3,921599,"BN"],[983038,983039,"BN"],[1048574,1048575,"BN"],[1114110,1114111,"BN"]];function Qp(u){if(u<=255)return Xp[u];let c=0,o=p1.length-1;for(;c<=o;){const r=c+o>>1,d=p1[r];if(u<d[0]){o=r-1;continue}if(u>d[1]){c=r+1;continue}return d[2]}return"L"}function Vp(u){const c=u.length;if(c===0)return null;const o=new Array(c);let r=!1;for(let m=0;m<c;){const p=u.charCodeAt(m);let g=p,N=1;if(p>=55296&&p<=56319&&m+1<c){const V=u.charCodeAt(m+1);V>=56320&&V<=57343&&(g=(p-55296<<10)+(V-56320)+65536,N=2)}const C=Qp(g);(C==="R"||C==="AL"||C==="AN")&&(r=!0);for(let V=0;V<N;V++)o[m+V]=C;m+=N}if(!r)return null;let d=0;for(let m=0;m<c;m++){const p=o[m];if(p==="L"){d=0;break}if(p==="R"||p==="AL"){d=1;break}}const h=new Int8Array(c);for(let m=0;m<c;m++)h[m]=d;const b=d&1?"R":"L",v=b;let y=v;for(let m=0;m<c;m++)o[m]==="NSM"?o[m]=y:y=o[m];y=v;for(let m=0;m<c;m++){const p=o[m];p==="EN"?o[m]=y==="AL"?"AN":"EN":(p==="R"||p==="L"||p==="AL")&&(y=p)}for(let m=0;m<c;m++)o[m]==="AL"&&(o[m]="R");for(let m=1;m<c-1;m++)o[m]==="ES"&&o[m-1]==="EN"&&o[m+1]==="EN"&&(o[m]="EN"),o[m]==="CS"&&(o[m-1]==="EN"||o[m-1]==="AN")&&o[m+1]===o[m-1]&&(o[m]=o[m-1]);for(let m=0;m<c;m++){if(o[m]!=="EN")continue;let p;for(p=m-1;p>=0&&o[p]==="ET";p--)o[p]="EN";for(p=m+1;p<c&&o[p]==="ET";p++)o[p]="EN"}for(let m=0;m<c;m++){const p=o[m];(p==="WS"||p==="ES"||p==="ET"||p==="CS")&&(o[m]="ON")}y=v;for(let m=0;m<c;m++){const p=o[m];p==="EN"?o[m]=y==="L"?"L":"EN":(p==="R"||p==="L")&&(y=p)}for(let m=0;m<c;m++){if(o[m]!=="ON")continue;let p=m+1;for(;p<c&&o[p]==="ON";)p++;const g=m>0?o[m-1]:v,N=p<c?o[p]:v,C=g!=="L"?"R":"L";if(C===(N!=="L"?"R":"L"))for(let W=m;W<p;W++)o[W]=C;m=p-1}for(let m=0;m<c;m++)o[m]==="ON"&&(o[m]=b);for(let m=0;m<c;m++){const p=o[m];(h[m]&1)===0?p==="R"?h[m]++:(p==="AN"||p==="EN")&&(h[m]+=2):(p==="L"||p==="AN"||p==="EN")&&h[m]++}return h}function Zp(u,c){const o=Vp(u);if(o===null)return null;const r=new Int8Array(c.length);for(let d=0;d<c.length;d++)r[d]=o[c[d]];return r}const Kp=/[ \t\n\r\f]+/g,Jp=/[\t\n\r\f]| {2,}|^ | $/;function Ip(u){const c=u??"normal";return c==="pre-wrap"?{mode:c,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:c,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function Wp(u){if(!Jp.test(u))return u;let c=u.replace(Kp," ");return c.charCodeAt(0)===32&&(c=c.slice(1)),c.length>0&&c.charCodeAt(c.length-1)===32&&(c=c.slice(0,-1)),c}function $p(u){return/[\r\f]/.test(u)?u.replace(/\r\n/g,`
|
|
292
|
+
`).length]})]})]}),V==="images"&&f.jsxs("div",{className:"flex-1 flex flex-col p-3 gap-3 overflow-y-auto",children:[f.jsxs("div",{className:"flex gap-2",children:[f.jsx("input",{type:"file",ref:te,onChange:Z,accept:"image/*",className:"hidden"}),f.jsxs("button",{onClick:()=>te.current?.click(),disabled:le,className:"flex-1 flex items-center justify-center gap-2 py-2.5 rounded-lg border border-dashed border-[#d4d4d4] dark:border-[#333333] hover:border-black dark:hover:border-[#555555] bg-[#fafafa] dark:bg-[#0f0f0f] hover:bg-[#f5f5f5] dark:hover:bg-[#141414] text-xs text-[#555555] dark:text-[#cccccc] hover:text-black dark:hover:text-white transition-all",children:[f.jsx(Tp,{className:"w-3.5 h-3.5"}),f.jsx("span",{children:le?"正在上传...":"上传配图素材"})]}),f.jsx("button",{onClick:()=>r({src:"https://images.unsplash.com/photo-1579783900882-c0d3dad7b119?w=800&auto=format&fit=crop&q=80",alt:"艺术插画",caption:"示例艺术配图",x:36,y:400,width:440,height:300,captionHeight:36,layoutPreset:"auto"}),className:"px-3 py-2.5 rounded-lg border border-[#eaeaea] dark:border-[#222222] bg-[#fafafa] dark:bg-[#0f0f0f] hover:bg-[#f5f5f5] dark:hover:bg-[#141414] text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-white transition-all",title:"插入在线示例图",children:f.jsx(vp,{className:"w-3.5 h-3.5"})})]}),f.jsx("div",{className:"flex flex-col gap-2.5",children:o.length===0?f.jsx("div",{className:"text-center py-8 text-xs text-[#888888] dark:text-[#555555]",children:"暂无配图素材,点击上方按钮上传或插入"}):o.map((A,X)=>f.jsxs("div",{className:"bg-[#fafafa] dark:bg-[#0f0f0f] border border-[#eaeaea] dark:border-[#222222] rounded-lg p-2.5 flex flex-col gap-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("img",{src:A.src,alt:A.alt,className:"w-12 h-12 object-cover rounded bg-[#eeeeee] dark:bg-[#1a1a1a] border border-[#e5e5e5] dark:border-[#262626] shrink-0"}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[f.jsxs("span",{className:"text-[10px] px-1 rounded bg-[#eaeaea] dark:bg-[#262626] font-mono text-[#555555] dark:text-[#aaaaaa] font-semibold shrink-0",children:["#",X+1]}),f.jsx("span",{className:"text-xs font-medium text-[#171717] dark:text-white truncate max-w-[120px]",children:A.caption||A.alt||`配图 #${X+1}`}),f.jsxs("span",{className:"text-[10px] px-1.5 py-0.2 rounded bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20 font-medium shrink-0",children:["第 ",A.pageIndex||1," 页"]})]}),f.jsxs("div",{className:"text-[10px] text-[#888888] dark:text-[#666666] font-mono mt-0.5",children:[A.width," × ",A.height,"px · X: ",A.x??0,", Y: ",A.y??0]})]}),f.jsxs("div",{className:"flex items-center gap-0.5",children:[f.jsx("button",{onClick:()=>m?.(A.id,"up"),disabled:X===0,className:"p-1 text-[#888888] hover:text-black dark:hover:text-white disabled:opacity-20 rounded hover:bg-[#eeeeee] dark:hover:bg-[#1f1f1f]",title:"上移顺序 (调整在同一页中的先后次序)",children:f.jsx(np,{className:"w-3.5 h-3.5"})}),f.jsx("button",{onClick:()=>m?.(A.id,"down"),disabled:X===o.length-1,className:"p-1 text-[#888888] hover:text-black dark:hover:text-white disabled:opacity-20 rounded hover:bg-[#eeeeee] dark:hover:bg-[#1f1f1f]",title:"下移顺序 (调整在同一页中的先后次序)",children:f.jsx(tp,{className:"w-3.5 h-3.5"})}),f.jsx("button",{onClick:()=>y(A.id),className:"p-1 text-[#888888] hover:text-red-500 rounded hover:bg-[#eeeeee] dark:hover:bg-[#1f1f1f]",title:"删除该图",children:f.jsx(vh,{className:"w-3.5 h-3.5"})})]})]}),f.jsxs("div",{className:"flex bg-[#eeeeee] dark:bg-[#1a1a1a] p-0.5 rounded text-[11px] font-medium pt-1 border-t border-[#eeeeee] dark:border-[#1a1a1a]",children:[f.jsx("button",{onClick:()=>v(A.id,{isAbsolute:!1}),className:`flex-1 py-1 rounded transition-all text-center ${A.isAbsolute?"text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-white":"bg-white dark:bg-[#262626] text-black dark:text-white shadow-sm font-semibold"}`,children:"绕排避让 (Flow)"}),f.jsx("button",{onClick:()=>v(A.id,{isAbsolute:!0,layoutPreset:"custom",zIndex:A.zIndex??15,rotate:A.rotate??0,opacity:A.opacity??1}),className:`flex-1 py-1 rounded transition-all text-center ${A.isAbsolute?"bg-white dark:bg-[#262626] text-black dark:text-white shadow-sm font-semibold":"text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-white"}`,children:"自由图层 (Absolute)"})]}),f.jsxs("div",{className:"flex flex-col gap-2 text-[11px]",children:[f.jsxs("label",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",checked:A.templateAssetKey!==void 0,onChange:D=>v(A.id,{templateAssetKey:D.target.checked?`asset_${A.id.replace(/[^a-zA-Z0-9_-]/g,"_")}`:void 0,repeatEveryPage:!1})}),"固定模板素材"]}),A.templateAssetKey!==void 0&&f.jsxs(f.Fragment,{children:[f.jsxs("label",{className:"flex flex-col gap-1",children:["素材标识",f.jsx("input",{"aria-label":"素材标识",value:A.templateAssetKey,onChange:D=>v(A.id,{templateAssetKey:D.target.value}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1"})]}),o.some(D=>D.id!==A.id&&D.templateAssetKey===A.templateAssetKey)&&f.jsx("span",{role:"alert",className:"text-red-600",children:"素材标识不能重复"}),f.jsxs("label",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",disabled:!A.isAbsolute,checked:!!(A.isAbsolute&&A.repeatEveryPage),onChange:D=>v(A.id,{repeatEveryPage:D.target.checked})}),"每页重复"]}),!A.isAbsolute&&f.jsx("span",{className:"text-[#888888]",children:"每页重复仅支持自由图层,避免阻塞文字排版。"}),f.jsx("span",{className:"text-[#888888]",children:"默认保留此图,仅按素材标识明确替换。"})]}),A.isAbsolute&&f.jsxs("label",{className:"flex items-center gap-2",children:[f.jsx("input",{type:"checkbox",checked:b.includes(A.id),onChange:D=>d(A.id,D.target.checked)}),"设为整页背景"]}),f.jsx("button",{type:"button",onClick:()=>h(A.id),title:"恢复上传或应用模板时的尺寸、位置和图层设置",className:"rounded border border-[#d4d4d4] dark:border-[#333333] px-2 py-1.5 hover:bg-[#eeeeee] dark:hover:bg-[#222222]",children:"重置布局"})]}),A.isAbsolute?f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"text-[10px] text-blue-600 dark:text-blue-400 bg-blue-500/10 p-1.5 rounded flex items-center gap-1 font-medium",children:[f.jsx(bo,{className:"w-3 h-3 shrink-0"}),f.jsx("span",{children:"自由定位图层:脱离文本流,不触发障碍物绕排"})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"所属页面"}),f.jsx("select",{value:A.pageIndex||1,onChange:D=>v(A.id,{pageIndex:parseInt(D.target.value,10)||1}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] focus:outline-none",children:Array.from({length:Math.max(p,2)},(D,$)=>$+1).map(D=>f.jsxs("option",{value:D,children:["第 ",D," 页 ",D===1?"(首页/封面)":""]},D))})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex justify-between text-[#666666] mb-1",children:[f.jsx("span",{children:"层级 (Z-Index)"}),f.jsx("span",{className:"font-mono text-black dark:text-white font-semibold",children:A.zIndex??15})]}),f.jsx("div",{className:"flex gap-1",children:[{label:"底",val:0,title:"底层背景"},{label:"文字",val:10,title:"正文同层"},{label:"顶",val:20,title:"置顶贴纸"}].map(D=>f.jsx("button",{onClick:()=>v(A.id,{zIndex:D.val}),title:D.title,className:`flex-1 py-0.5 text-[10px] rounded border ${(A.zIndex??15)===D.val?"bg-black dark:bg-white text-white dark:text-black border-transparent font-bold":"border-[#d4d4d4] dark:border-[#262626] text-[#666666] dark:text-[#888888]"}`,children:D.label},D.val))})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex justify-between text-[#666666] mb-1",children:[f.jsxs("span",{className:"flex items-center gap-0.5",children:[f.jsx(bp,{className:"w-2.5 h-2.5"})," 旋转角度"]}),f.jsxs("span",{className:"font-mono text-black dark:text-white font-semibold",children:[A.rotate??0,"°"]})]}),f.jsx("input",{type:"range",min:"-45",max:"45",step:"1",value:A.rotate??0,onChange:D=>v(A.id,{rotate:parseInt(D.target.value,10)}),className:"w-full h-1.5 bg-[#e5e5e5] dark:bg-[#222222] rounded cursor-pointer mt-1"})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex justify-between text-[#666666] mb-1",children:[f.jsx("span",{children:"不透明度"}),f.jsxs("span",{className:"font-mono text-black dark:text-white font-semibold",children:[Math.round((A.opacity??1)*100),"%"]})]}),f.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:A.opacity??1,onChange:D=>v(A.id,{opacity:parseFloat(D.target.value)}),className:"w-full h-1.5 bg-[#e5e5e5] dark:bg-[#222222] rounded cursor-pointer mt-1"})]})]}),f.jsxs("div",{className:"text-[11px]",children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"圆角半径 (px)"}),f.jsx("input",{type:"number",min:"0",step:"4",value:A.borderRadius??12,onChange:D=>v(A.id,{borderRadius:parseInt(D.target.value,10)||0}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"横向 X"}),f.jsx("input",{type:"number",step:"10",value:A.x??0,onChange:D=>v(A.id,{x:parseInt(D.target.value,10)||0}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"纵向 Y"}),f.jsx("input",{type:"number",step:"10",value:A.y??0,onChange:D=>v(A.id,{y:parseInt(D.target.value,10)||0}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"宽度 (W)"}),f.jsx("input",{type:"number",step:"10",value:A.width??420,onChange:D=>v(A.id,{width:Math.max(20,parseInt(D.target.value,10)||20)}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"高度 (H)"}),f.jsx("input",{type:"number",step:"10",value:A.height??280,onChange:D=>v(A.id,{height:Math.max(20,parseInt(D.target.value,10)||20)}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]})]})]}):f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"排版预设"}),f.jsxs("select",{value:A.layoutPreset||"auto",onChange:D=>v(A.id,{layoutPreset:D.target.value}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] focus:outline-none",children:[f.jsx("option",{value:"auto",children:"自适应 (Auto)"}),f.jsx("option",{value:"mid-left",children:"居左浮动 (Left)"}),f.jsx("option",{value:"mid-right",children:"居右浮动 (Right)"}),f.jsx("option",{value:"center",children:"居中横幅 (Center)"}),f.jsx("option",{value:"staggered",children:"交错排版 (Staggered)"}),f.jsx("option",{value:"corner-soft",children:"角落软着陆 (Corner)"}),f.jsx("option",{value:"fill",children:"底部填满 (Fill)"}),f.jsx("option",{value:"custom",children:"自定义坐标 (Custom)"})]})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"所属页面"}),f.jsx("select",{value:A.pageIndex||1,onChange:D=>v(A.id,{pageIndex:parseInt(D.target.value,10)||1}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] focus:outline-none",children:Array.from({length:Math.max(p,2)},(D,$)=>$+1).map(D=>f.jsxs("option",{value:D,children:["第 ",D," 页 ",D===1?"(首页/封面)":""]},D))})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"宽度 (W)"}),f.jsx("input",{type:"number",min:"50",step:"10",value:A.width??420,onChange:D=>v(A.id,{width:Math.max(50,parseInt(D.target.value,10)||50)}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"高度 (H)"}),f.jsx("input",{type:"number",min:"50",step:"10",value:A.height??280,onChange:D=>v(A.id,{height:Math.max(50,parseInt(D.target.value,10)||50)}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px]",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"纵向位置 Y"}),f.jsx("input",{type:"number",step:"20",value:A.y??300,onChange:D=>v(A.id,{y:parseInt(D.target.value,10)||0,layoutPreset:"custom"}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] block mb-1",children:"横向坐标 X"}),f.jsx("input",{type:"number",step:"10",value:A.x??16,onChange:D=>v(A.id,{x:parseInt(D.target.value,10)||0,layoutPreset:"custom"}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-1.5 py-1 text-black dark:text-white text-[11px] font-mono focus:outline-none"})]})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] text-[11px] block mb-1",children:"图片说明 (Caption)"}),f.jsx("input",{type:"text",placeholder:"下方说明文字...",value:A.caption||"",onChange:D=>v(A.id,{caption:D.target.value}),className:"w-full bg-white dark:bg-[#181818] border border-[#d4d4d4] dark:border-[#262626] rounded px-2 py-1 text-black dark:text-white text-[11px] focus:outline-none"})]})]})]},A.id))})]}),V==="highlights"&&f.jsxs("div",{className:"flex-1 flex flex-col p-3 gap-3 overflow-y-auto",children:[f.jsx("div",{className:"text-xs text-[#666666] dark:text-[#888888] leading-relaxed",children:"在正文中出现的高亮词,将被算法自动匹配并渲染为品牌强调色。"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx("input",{type:"text",placeholder:"新增高亮关键词...",value:L,onChange:A=>U(A.target.value),onKeyDown:A=>A.key==="Enter"&&ee(),className:"flex-1 bg-white dark:bg-[#0d0d0d] border border-[#d4d4d4] dark:border-[#222222] rounded-lg px-2.5 py-1.5 text-xs text-black dark:text-white placeholder-[#888888] dark:placeholder-[#555555] focus:outline-none focus:border-black dark:focus:border-[#444444]"}),f.jsx("button",{onClick:ee,className:"px-3 py-1.5 bg-black dark:bg-[#1f1f1f] hover:bg-[#262626] text-white rounded-lg text-xs font-medium",children:"添加"})]}),f.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:g.map(A=>f.jsxs("span",{className:"flex items-center gap-1 px-2.5 py-1 rounded-md bg-[#f0fdf4] dark:bg-[#161616] border border-[#bbf7d0] dark:border-[#262626] text-xs text-emerald-700 dark:text-emerald-400 font-medium",children:[f.jsx(bo,{className:"w-3 h-3"}),f.jsx("span",{children:A}),f.jsx("button",{onClick:()=>G(A),className:"hover:text-red-500 ml-1",children:"×"})]},A))})]})]})},Rp=[{id:"wechat-cover-2.35",label:"微信封面",ratioTag:"2.35:1"},{id:"longform-3-4",label:"通用长图文",ratioTag:"3:4"},{id:"wide-16-9",label:"通用宽屏",ratioTag:"16:9"},{id:"square-1-1",label:"通用正方形",ratioTag:"1:1"}],Lp=({currentRatio:u,onSelectRatio:c,zoom:o,onZoomChange:r,onAutoFit:d,isAutoFit:h,onOpenTemplates:b,onOpenAuth:v,onExport:y,isExporting:m,isAuthed:p,pageCount:g,themeMode:N,onToggleThemeMode:C})=>f.jsxs("header",{className:"h-14 border-b border-[#eaeaea] dark:border-[#222222] bg-white/80 dark:bg-[#000000]/80 backdrop-blur-md px-4 flex items-center justify-between select-none z-30 shrink-0 transition-colors",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsxs("div",{className:"flex items-center gap-2 font-semibold text-[#171717] dark:text-white tracking-tight text-sm",children:[f.jsx("span",{className:"flex items-center justify-center w-6 h-6 rounded bg-black dark:bg-white text-white dark:text-black font-black text-xs shadow-sm",children:"▲"}),f.jsx("span",{children:"Typeset Studio"})]}),f.jsx("span",{className:"text-xs text-[#888888] dark:text-[#555555] font-mono hidden md:inline",children:"v0.2.5"}),f.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-[#f5f5f5] dark:bg-[#111111] border border-[#e5e5e5] dark:border-[#222222] text-[11px] text-emerald-600 dark:text-[#00e676]",children:[f.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 dark:bg-[#00e676] animate-pulse"}),f.jsx("span",{className:"font-mono",children:"Ready"})]})]}),f.jsx("div",{className:"flex items-center bg-[#f5f5f5] dark:bg-[#0a0a0a] border border-[#eaeaea] dark:border-[#222222] rounded-lg p-0.5 shadow-inner",children:Rp.map(V=>{const W=u===V.id;return f.jsxs("button",{onClick:()=>c(V.id),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-all ${W?"bg-white dark:bg-[#1f1f1f] text-black dark:text-white shadow-sm font-semibold":"text-[#666666] dark:text-[#888888] hover:text-[#171717] dark:hover:text-[#cccccc] hover:bg-[#eaeaea] dark:hover:bg-[#141414]"}`,children:[f.jsx("span",{children:V.label}),f.jsx("span",{className:`text-[10px] font-mono px-1 py-0.2 rounded ${W?"bg-[#eaeaea] dark:bg-[#333333] text-black dark:text-white font-semibold":"bg-[#e5e5e5] dark:bg-[#181818] text-[#777777] dark:text-[#666666]"}`,children:V.ratioTag})]},V.id)})}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"flex items-center bg-[#f5f5f5] dark:bg-[#0a0a0a] border border-[#eaeaea] dark:border-[#222222] rounded-lg p-0.5 text-xs text-[#666666] dark:text-[#888888]",children:[f.jsx("button",{onClick:()=>r(Math.max(.2,Number((o-.05).toFixed(2)))),className:"p-1 hover:text-black dark:hover:text-white rounded hover:bg-[#e8e8e8] dark:hover:bg-[#1f1f1f]",title:"缩小",children:f.jsx(wp,{className:"w-3.5 h-3.5"})}),f.jsxs("span",{onDoubleClick:d,className:"w-11 text-center font-mono text-[11px] text-[#333333] dark:text-[#cccccc] cursor-pointer hover:underline select-none",title:"双击恢复自适应",children:[Math.round(o*100),"%"]}),f.jsx("button",{onClick:()=>r(Math.min(1.5,Number((o+.05).toFixed(2)))),className:"p-1 hover:text-black dark:hover:text-white rounded hover:bg-[#e8e8e8] dark:hover:bg-[#1f1f1f]",title:"放大",children:f.jsx(Ah,{className:"w-3.5 h-3.5"})}),d&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"w-[1px] h-3 bg-[#e0e0e0] dark:bg-[#262626] mx-0.5"}),f.jsxs("button",{onClick:d,className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] transition-all ${h?"bg-white dark:bg-[#1f1f1f] text-black dark:text-white shadow-xs font-semibold":"hover:text-black dark:hover:text-white hover:bg-[#e8e8e8] dark:hover:bg-[#1f1f1f]"}`,title:g>1?"缩放至视口内完整排列多张图片(瀑布流平铺)":"自适应画布大小",children:[f.jsx(mp,{className:"w-3 h-3"}),f.jsx("span",{children:g>1?"多图平铺":"自适应"})]})]})]}),f.jsx("button",{onClick:C,className:"p-2 rounded-lg border border-[#eaeaea] dark:border-[#222222] bg-white dark:bg-[#0a0a0a] hover:bg-[#f5f5f5] dark:hover:bg-[#161616] text-[#444444] dark:text-[#cccccc] transition-all btn-vercel",title:N==="light"?"切换至深色模式":"切换至浅色模式",children:N==="light"?f.jsx(gp,{className:"w-3.5 h-3.5 text-[#555555]"}):f.jsx(Ap,{className:"w-3.5 h-3.5 text-amber-400"})}),f.jsxs("button",{onClick:b,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg border border-[#eaeaea] dark:border-[#222222] bg-white dark:bg-[#0a0a0a] hover:bg-[#f5f5f5] dark:hover:bg-[#161616] text-xs text-[#333333] dark:text-[#cccccc] hover:text-black dark:hover:text-white transition-all btn-vercel",children:[f.jsx(cp,{className:"w-3.5 h-3.5 text-[#777777] dark:text-[#888888]"}),f.jsx("span",{children:"模板库"})]}),f.jsxs("button",{onClick:y,disabled:m,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-black text-white hover:bg-[#262626] dark:bg-white dark:text-black dark:hover:bg-[#eaeaea] text-xs font-semibold transition-all btn-vercel shadow-sm disabled:opacity-50",children:[m?f.jsx(ih,{className:"w-3.5 h-3.5 animate-spin"}):f.jsx(ip,{className:"w-3.5 h-3.5"}),f.jsx("span",{children:m?"导出中...":"导出图片"}),g>1&&f.jsxs("span",{className:"text-[10px] bg-white/20 dark:bg-black text-white px-1.5 py-0.2 rounded font-mono",children:[g,"P"]})]}),f.jsx("button",{onClick:v,className:`p-1.5 rounded-lg border transition-all btn-vercel ${p?"border-[#eaeaea] dark:border-[#222222] bg-white dark:bg-[#0a0a0a] text-[#777777] dark:text-[#888888] hover:text-black dark:hover:text-white hover:bg-[#f5f5f5] dark:hover:bg-[#161616]":"border-amber-500/50 bg-amber-500/10 text-amber-600 dark:text-amber-400"}`,title:p?"超管密钥已就绪":"配置超管密钥",children:f.jsx(W1,{className:"w-3.5 h-3.5"})})]})]});function Hp(){const[u,c]=me.useState([]),[o,r]=me.useState(!1),d=me.useCallback(async(h=!1)=>{try{r(!0);const b=await fetch(`/api/fonts${h?"?refresh=1":""}`);if(!b.ok)return;const v=await b.json();if(!v.ok||!Array.isArray(v.fonts))return;c(v.fonts);let y=!1;if(typeof window<"u"&&"FontFace"in window&&document.fonts)for(const m of v.fonts)try{let p=!1;const g=[];if(document.fonts.forEach(N=>{(N.family===m.family||N.family===`"${m.family}"`)&&(p=!0,g.push(N))}),h&&(g.forEach(N=>document.fonts.delete(N)),p=!1),!p){const C=await new FontFace(m.family,`url(${m.url}${h?`?v=${Date.now()}`:""})`).load();document.fonts.add(C),y=!0}}catch(p){console.warn(`[useLocalFonts] Failed to load web font ${m.family}:`,p)}y&&window.dispatchEvent(new Event("typeset-fonts-loaded"))}catch(b){console.warn("[useLocalFonts] Failed to fetch local fonts:",b)}finally{r(!1)}},[]);return me.useEffect(()=>{d()},[d]),{fonts:u,loading:o,refreshFonts:()=>d(!0)}}const g1=[{label:"苹方 / 极简黑体 (默认清爽)",value:"PingFang SC"},{label:"思源黑体 (现代极简·粗黑)",value:"Noto Sans SC"},{label:"典雅宋体 (经典报刊·书卷)",value:"Songti SC"},{label:"思源宋体 (高阶报刊·典雅)",value:"Noto Serif SC"},{label:"人文楷体 (温润随笔·手写)",value:"Kaiti SC"},{label:"柔和圆体 (亲和灵动·现代)",value:"Yuanti SC"},{label:"Inter / 国际西文无衬线",value:"Inter"},{label:"Georgia / 文艺西文衬线",value:"Georgia"}],Up=({config:u,onUpdateAlgorithm:c,onUpdateTheme:o,onUpdateTypography:r,onUpdateSafeArea:d,onUpdateBranding:h,onUpdateChrome:b})=>{const{algorithm:v,theme:y,typography:m}=u,{fonts:p,loading:g,refreshFonts:N}=Hp();return f.jsxs("aside",{className:"w-80 border-l border-[#eaeaea] dark:border-[#222222] bg-white dark:bg-[#0a0a0a] flex flex-col shrink-0 select-none overflow-y-auto transition-colors",children:[f.jsxs("div",{className:"p-3.5 border-b border-[#f0f0f0] dark:border-[#1c1c1c]",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[#171717] dark:text-white mb-3",children:[f.jsx(lp,{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400"}),f.jsx("span",{children:"文字对齐与空间居中"})]}),f.jsxs("div",{className:"flex flex-col gap-3 text-xs",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] dark:text-[#888888] text-[11px] block mb-1.5 font-medium",children:"垂直排版对齐 (封面必备)"}),f.jsx("div",{className:"grid grid-cols-3 gap-1 bg-[#f5f5f5] dark:bg-[#141414] p-1 rounded-lg border border-[#e5e5e5] dark:border-[#262626]",children:[{id:"top",label:"顶端对齐"},{id:"center",label:"垂直居中"},{id:"bottom",label:"底端对齐"}].map(C=>f.jsx("button",{onClick:()=>c({verticalAlign:C.id}),className:`py-1 text-[11px] rounded transition-all font-medium ${(v.verticalAlign||"top")===C.id?"bg-white dark:bg-[#262626] text-black dark:text-white shadow-sm font-semibold":"text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-white"}`,children:C.label},C.id))})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] dark:text-[#888888] text-[11px] block mb-1.5 font-medium",children:"水平排版对齐"}),f.jsxs("div",{className:"grid grid-cols-3 gap-1 bg-[#f5f5f5] dark:bg-[#141414] p-1 rounded-lg border border-[#e5e5e5] dark:border-[#262626]",children:[f.jsxs("button",{onClick:()=>c({textAlign:"left"}),className:`py-1 flex items-center justify-center gap-1 text-[11px] rounded transition-all font-medium ${(v.textAlign||"left")==="left"?"bg-white dark:bg-[#262626] text-black dark:text-white shadow-sm font-semibold":"text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-white"}`,children:[f.jsx(kp,{className:"w-3 h-3"}),f.jsx("span",{children:"居左"})]}),f.jsxs("button",{onClick:()=>c({textAlign:"center"}),className:`py-1 flex items-center justify-center gap-1 text-[11px] rounded transition-all font-medium ${v.textAlign==="center"?"bg-white dark:bg-[#262626] text-black dark:text-white shadow-sm font-semibold":"text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-white"}`,children:[f.jsx(Mp,{className:"w-3 h-3"}),f.jsx("span",{children:"居中"})]}),f.jsxs("button",{onClick:()=>c({textAlign:"right"}),className:`py-1 flex items-center justify-center gap-1 text-[11px] rounded transition-all font-medium ${v.textAlign==="right"?"bg-white dark:bg-[#262626] text-black dark:text-white shadow-sm font-semibold":"text-[#666666] dark:text-[#888888] hover:text-black dark:hover:text-white"}`,children:[f.jsx(Cp,{className:"w-3 h-3"}),f.jsx("span",{children:"居右"})]})]})]})]})]}),f.jsxs("div",{className:"p-3.5 border-b border-[#f0f0f0] dark:border-[#1c1c1c]",children:[f.jsxs("div",{className:"flex items-center justify-between text-xs font-semibold text-[#171717] dark:text-white mb-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Fp,{className:"w-3.5 h-3.5 text-indigo-500 dark:text-indigo-400"}),f.jsx("span",{children:"字体与排版字阶"})]}),f.jsx("button",{onClick:()=>N(),disabled:g,title:"重新扫描 public/fonts 目录",className:"p-1 text-[#888888] hover:text-black dark:hover:text-white rounded hover:bg-[#eaeaea] dark:hover:bg-[#222222] transition-colors",children:f.jsx(ih,{className:`w-3 h-3 ${g?"animate-spin text-blue-500":""}`})})]}),f.jsxs("div",{className:"flex flex-col gap-3 text-xs",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] dark:text-[#888888] text-[11px] block mb-1",children:"标题字体 (Heading Font)"}),f.jsxs("select",{value:m.headingFont,onChange:C=>r({headingFont:C.target.value}),className:"w-full bg-[#fafafa] dark:bg-[#141414] border border-[#d4d4d4] dark:border-[#262626] rounded-md px-2 py-1.5 text-black dark:text-white text-xs focus:outline-none",children:[p.length>0&&f.jsx("optgroup",{label:"✨ 项目本地字体 (public/fonts)",children:p.map(C=>f.jsx("option",{value:C.family,children:C.label},`head-local-${C.family}`))}),f.jsx("optgroup",{label:"🌐 系统 / 云端预设",children:g1.map(C=>f.jsx("option",{value:C.value,children:C.label},`head-preset-${C.value}`))})]})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#666666] dark:text-[#888888] text-[11px] block mb-1",children:"正文字体 (Body Font)"}),f.jsxs("select",{value:m.bodyFont,onChange:C=>r({bodyFont:C.target.value}),className:"w-full bg-[#fafafa] dark:bg-[#141414] border border-[#d4d4d4] dark:border-[#262626] rounded-md px-2 py-1.5 text-black dark:text-white text-xs focus:outline-none",children:[p.length>0&&f.jsx("optgroup",{label:"✨ 项目本地字体 (public/fonts)",children:p.map(C=>f.jsx("option",{value:C.family,children:C.label},`body-local-${C.family}`))}),f.jsx("optgroup",{label:"🌐 系统 / 云端预设",children:g1.map(C=>f.jsx("option",{value:C.value,children:C.label},`body-preset-${C.value}`))})]})]}),p.length===0?f.jsx("div",{className:"text-[10px] text-[#888888] dark:text-[#666666] flex items-center justify-between pt-1 border-t border-[#f5f5f5] dark:border-[#1a1a1a]",children:f.jsxs("span",{children:["💡 将 .ttf / .otf 放入 ",f.jsx("code",{children:"public/fonts/"})," 即可识别"]})}):f.jsx("div",{className:"text-[10px] text-emerald-600 dark:text-emerald-400 flex items-center justify-between pt-1 border-t border-[#f5f5f5] dark:border-[#1a1a1a]",children:f.jsxs("span",{children:["✨ 已加载 ",p.length," 个项目本地字体"]})})]})]}),f.jsxs("div",{className:"p-3.5 border-b border-[#f0f0f0] dark:border-[#1c1c1c]",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[#171717] dark:text-white mb-3",children:[f.jsx(Ep,{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400"}),f.jsx("span",{children:"字号与比例参数"})]}),f.jsxs("div",{className:"flex flex-col gap-3.5 text-xs",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex justify-between text-[#666666] dark:text-[#888888] mb-1 font-mono text-[11px]",children:[f.jsx("span",{children:"基准字号 (Base Size)"}),f.jsxs("span",{className:"text-[#171717] dark:text-white font-semibold",children:[v.baseFontSize,"px"]})]}),f.jsx("input",{type:"range",min:"24",max:"96",step:"1",value:v.baseFontSize,onChange:C=>c({baseFontSize:parseInt(C.target.value,10)}),className:"w-full h-1.5 bg-[#e5e5e5] dark:bg-[#222222] rounded-lg cursor-pointer"})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex justify-between text-[#666666] dark:text-[#888888] mb-1 font-mono text-[11px]",children:[f.jsx("span",{children:"比例字阶系数 (大标题倍率)"}),f.jsxs("span",{className:"text-[#171717] dark:text-white font-semibold",children:[v.scaleRatio.toFixed(2),"x"]})]}),f.jsx("input",{type:"range",min:"1.15",max:"1.6",step:"0.01",value:v.scaleRatio,onChange:C=>c({scaleRatio:parseFloat(C.target.value)}),className:"w-full h-1.5 bg-[#e5e5e5] dark:bg-[#222222] rounded-lg cursor-pointer"})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex justify-between text-[#666666] dark:text-[#888888] mb-1 font-mono text-[11px]",children:[f.jsx("span",{children:"行高舒展倍率"}),f.jsx("span",{className:"text-[#171717] dark:text-white font-semibold",children:v.lineHeightMultiplier.toFixed(2)})]}),f.jsx("input",{type:"range",min:"1.2",max:"1.8",step:"0.02",value:v.lineHeightMultiplier,onChange:C=>c({lineHeightMultiplier:parseFloat(C.target.value)}),className:"w-full h-1.5 bg-[#e5e5e5] dark:bg-[#222222] rounded-lg cursor-pointer"})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex justify-between text-[#666666] dark:text-[#888888] mb-1 font-mono text-[11px]",children:[f.jsx("span",{children:"配图避让间隙 (Gap)"}),f.jsxs("span",{className:"text-[#171717] dark:text-white font-semibold",children:[v.obstacleGap,"px"]})]}),f.jsx("input",{type:"range",min:"12",max:"48",step:"2",value:v.obstacleGap,onChange:C=>c({obstacleGap:parseInt(C.target.value,10)}),className:"w-full h-1.5 bg-[#e5e5e5] dark:bg-[#222222] rounded-lg cursor-pointer"})]})]})]}),f.jsxs("div",{className:"p-3.5 border-b border-[#f0f0f0] dark:border-[#1c1c1c]",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[#171717] dark:text-white mb-3",children:[f.jsx(Sp,{className:"w-3.5 h-3.5 text-emerald-600 dark:text-emerald-400"}),f.jsx("span",{children:"版心安全边距"})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[11px] font-mono",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[#777777] dark:text-[#666666] block mb-1",children:"上边距 (Top)"}),f.jsx("input",{type:"number",value:v.safeArea.top,onChange:C=>d({top:parseInt(C.target.value,10)||0}),className:"w-full bg-[#fafafa] dark:bg-[#141414] border border-[#d4d4d4] dark:border-[#262626] rounded px-2 py-1 text-black dark:text-white"})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#777777] dark:text-[#666666] block mb-1",children:"下边距 (Bottom)"}),f.jsx("input",{type:"number",value:v.safeArea.bottom,onChange:C=>d({bottom:parseInt(C.target.value,10)||0}),className:"w-full bg-[#fafafa] dark:bg-[#141414] border border-[#d4d4d4] dark:border-[#262626] rounded px-2 py-1 text-black dark:text-white"})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#777777] dark:text-[#666666] block mb-1",children:"左边距 (Left)"}),f.jsx("input",{type:"number",value:v.safeArea.left,onChange:C=>d({left:parseInt(C.target.value,10)||0}),className:"w-full bg-[#fafafa] dark:bg-[#141414] border border-[#d4d4d4] dark:border-[#262626] rounded px-2 py-1 text-black dark:text-white"})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[#777777] dark:text-[#666666] block mb-1",children:"右边距 (Right)"}),f.jsx("input",{type:"number",value:v.safeArea.right,onChange:C=>d({right:parseInt(C.target.value,10)||0}),className:"w-full bg-[#fafafa] dark:bg-[#141414] border border-[#d4d4d4] dark:border-[#262626] rounded px-2 py-1 text-black dark:text-white"})]})]})]}),f.jsxs("div",{className:"p-3.5 border-b border-[#f0f0f0] dark:border-[#1c1c1c]",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[#171717] dark:text-white mb-3",children:[f.jsx(pp,{className:"w-3.5 h-3.5 text-purple-600 dark:text-purple-400"}),f.jsx("span",{children:"视觉色彩主题"})]}),f.jsxs("div",{className:"flex flex-col gap-2.5 text-xs",children:[f.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[f.jsx("button",{onClick:()=>o({bgColor:"#ffffff",textColor:"#171717",headingColor:"#171717",accentColor:"#059669",quoteColor:"#525252",cardBg:"#f5f5f5"}),className:"w-6 h-6 rounded-full bg-[#ffffff] border-2 border-emerald-500 shadow-sm hover:scale-105 transition-all",title:"素白雅致 (推荐)"}),f.jsx("button",{onClick:()=>o({bgColor:"#f9fcfa",textColor:"#22201d",headingColor:"#0f2e22",accentColor:"#1d4f39",quoteColor:"#474038",cardBg:"#ffffff"}),className:"w-6 h-6 rounded-full bg-[#f9fcfa] border border-[#ccc] shadow-sm hover:scale-105 transition-all",title:"纸白浅草"}),f.jsx("button",{onClick:()=>o({bgColor:"#0a0a0a",textColor:"#ededed",headingColor:"#ffffff",accentColor:"#00e676",quoteColor:"#a0a0a0",cardBg:"#121212"}),className:"w-6 h-6 rounded-full bg-[#0a0a0a] border border-[#444] shadow-sm hover:scale-105 transition-all",title:"深邃暗夜"}),f.jsx("button",{onClick:()=>o({bgColor:"#09090b",textColor:"#fafafa",headingColor:"#ffffff",accentColor:"#3b82f6",quoteColor:"#a1a1aa",cardBg:"#18181b"}),className:"w-6 h-6 rounded-full bg-[#09090b] border border-blue-500 shadow-sm hover:scale-105 transition-all",title:"数码蓝暗黑"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-[#666666] dark:text-[#888888] font-medium",children:"标题颜色 (Heading)"}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("input",{type:"color",value:y.headingColor||y.textColor,onChange:C=>o({headingColor:C.target.value}),className:"w-6 h-6 rounded cursor-pointer bg-transparent border-0"}),f.jsx("span",{className:"font-mono text-[11px] text-[#444444] dark:text-[#cccccc]",children:y.headingColor||y.textColor})]})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-[#666666] dark:text-[#888888]",children:"正文字色 (Text)"}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("input",{type:"color",value:y.textColor,onChange:C=>o({textColor:C.target.value}),className:"w-6 h-6 rounded cursor-pointer bg-transparent border-0"}),f.jsx("span",{className:"font-mono text-[11px] text-[#444444] dark:text-[#cccccc]",children:y.textColor})]})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-[#666666] dark:text-[#888888]",children:"重点强调色 (Accent)"}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("input",{type:"color",value:y.accentColor,onChange:C=>o({accentColor:C.target.value}),className:"w-6 h-6 rounded cursor-pointer bg-transparent border-0"}),f.jsx("span",{className:"font-mono text-[11px] text-[#444444] dark:text-[#cccccc]",children:y.accentColor})]})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-[#666666] dark:text-[#888888]",children:"背景底色 (Canvas)"}),f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("input",{type:"color",value:y.bgColor,onChange:C=>o({bgColor:C.target.value}),className:"w-6 h-6 rounded cursor-pointer bg-transparent border-0"}),f.jsx("span",{className:"font-mono text-[11px] text-[#444444] dark:text-[#cccccc]",children:y.bgColor})]})]})]})]}),f.jsxs("div",{className:"p-3.5",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[#171717] dark:text-white mb-3",children:[f.jsx(ap,{className:"w-3.5 h-3.5 text-amber-500 dark:text-amber-400"}),f.jsx("span",{children:"页眉页脚与版式装饰 (Chrome)"})]}),f.jsxs("div",{className:"flex flex-col gap-3 text-xs",children:[f.jsxs("div",{className:"bg-[#f9f9f9] dark:bg-[#141414] p-2.5 rounded-lg border border-[#eaeaea] dark:border-[#222222] flex flex-col gap-2",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"font-semibold text-[#333333] dark:text-[#cccccc] text-[11px]",children:"顶部栏 (Header)"}),f.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:u.chrome?.showHeader??!!u.watermarkText?.trim(),onChange:C=>b({showHeader:C.target.checked}),className:"rounded text-emerald-500 accent-emerald-500 cursor-pointer"}),f.jsx("span",{className:"text-[10px] text-[#666666] dark:text-[#888888]",children:"启用"})]})]}),(u.chrome?.showHeader??!!u.watermarkText?.trim())&&f.jsxs("div",{className:"flex flex-col gap-2 pl-2 border-l-2 border-[#e0e0e0] dark:border-[#2a2a2a] mt-1",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-1",children:[f.jsx("span",{className:"text-[#777777] dark:text-[#888888] text-[10px]",children:"水印 / 品牌标识"}),f.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-[#666666] dark:text-[#888888] cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:u.chrome?.showWatermark??!0,onChange:C=>b({showWatermark:C.target.checked}),className:"rounded accent-emerald-500 cursor-pointer"}),f.jsx("span",{children:"显示"})]})]}),f.jsx("input",{type:"text",value:u.watermarkText,onChange:C=>h(u.footerText,C.target.value),placeholder:"作者水印/标识文本...",className:"w-full bg-white dark:bg-[#0a0a0a] border border-[#d4d4d4] dark:border-[#262626] rounded px-2 py-1 text-black dark:text-white text-[11px]"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-[#777777] dark:text-[#888888] text-[10px]",children:"页码角标 (P.01)"}),f.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-[#666666] dark:text-[#888888] cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:u.chrome?.showPageNumber??u.aspectRatio==="longform-3-4",onChange:C=>b({showPageNumber:C.target.checked}),className:"rounded accent-emerald-500 cursor-pointer"}),f.jsx("span",{children:"显示"})]})]})]})]}),f.jsxs("div",{className:"bg-[#f9f9f9] dark:bg-[#141414] p-2.5 rounded-lg border border-[#eaeaea] dark:border-[#222222] flex flex-col gap-2",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"font-semibold text-[#333333] dark:text-[#cccccc] text-[11px]",children:"底部栏 (Footer)"}),f.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:u.chrome?.showFooter??!!u.footerText?.trim(),onChange:C=>b({showFooter:C.target.checked}),className:"rounded text-emerald-500 accent-emerald-500 cursor-pointer"}),f.jsx("span",{className:"text-[10px] text-[#666666] dark:text-[#888888]",children:"启用"})]})]}),(u.chrome?.showFooter??!!u.footerText?.trim())&&f.jsxs("div",{className:"flex flex-col gap-2 pl-2 border-l-2 border-[#e0e0e0] dark:border-[#2a2a2a] mt-1",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-1",children:[f.jsx("span",{className:"text-[#777777] dark:text-[#888888] text-[10px]",children:"页脚署名 / 版权"}),f.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-[#666666] dark:text-[#888888] cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:u.chrome?.showFooterText??!0,onChange:C=>b({showFooterText:C.target.checked}),className:"rounded accent-emerald-500 cursor-pointer"}),f.jsx("span",{children:"显示"})]})]}),f.jsx("input",{type:"text",value:u.footerText,onChange:C=>h(C.target.value,u.watermarkText),placeholder:"页脚版权/署名...",className:"w-full bg-white dark:bg-[#0a0a0a] border border-[#d4d4d4] dark:border-[#262626] rounded px-2 py-1 text-black dark:text-white text-[11px]"})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-[#777777] dark:text-[#888888] text-[10px]",children:"顶部分割细线"}),f.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-[#666666] dark:text-[#888888] cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:u.chrome?.showFooterDivider??!!u.footerText?.trim(),onChange:C=>b({showFooterDivider:C.target.checked}),className:"rounded accent-emerald-500 cursor-pointer"}),f.jsx("span",{children:"显示"})]})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-[#777777] dark:text-[#888888] text-[10px]",children:"算法填充率提示"}),f.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-[#666666] dark:text-[#888888] cursor-pointer",children:[f.jsx("input",{type:"checkbox",checked:u.chrome?.showFillRatio??!1,onChange:C=>b({showFillRatio:C.target.checked}),className:"rounded accent-emerald-500 cursor-pointer"}),f.jsx("span",{children:"显示"})]})]})]})]})]})]})]})};function Ac(u=[]){if(!Array.isArray(u))throw new RangeError("模板图片必须是数组");const c=new Set;for(const o of u){if(!o||typeof o!="object")throw new RangeError("无效的模板图片");if(o.templateAssetKey===void 0)continue;const r=o.templateAssetKey;if(o.repeatEveryPage!==void 0&&typeof o.repeatEveryPage!="boolean")throw new RangeError(`素材 ${r} 的每页重复开关必须是布尔值`);if(typeof r!="string"||!/^[a-zA-Z0-9_-]+$/.test(r))throw new RangeError("素材标识只能包含字母、数字、下划线和短横线");if(o.repeatEveryPage&&!o.isAbsolute)throw new RangeError(`素材 ${r} 的每页重复仅支持自由定位模式`);if(c.has(r))throw new RangeError(`重复的模板素材标识:${r}`);c.add(r)}}function qp(u,c=[],o={}){if(Ac(c),!o||typeof o!="object"||Array.isArray(o))throw new RangeError("素材替换必须是标识到图片地址的映射");const r=c.filter(v=>v.templateAssetKey);for(const[v,y]of Object.entries(o)){if(!r.some(m=>m.templateAssetKey===v))throw new RangeError(`未知模板素材:${v}`);if(typeof y!="string"||!y.trim())throw new RangeError(`素材 ${v} 的替换图片不能为空`)}const d=u.filter(v=>!v.templateAssetKey),h=c.filter(v=>!v.templateAssetKey);return[...d.length===0?h.map(v=>({...v,id:`img_${crypto.randomUUID()}`})):d.map((v,y)=>{const m=h[y];return m?{...v,layoutPreset:m.layoutPreset??v.layoutPreset,isAbsolute:m.isAbsolute??v.isAbsolute,x:m.x??v.x,y:m.y??v.y,width:m.width??v.width,height:m.height??v.height,rotate:m.rotate??v.rotate,opacity:m.opacity??v.opacity,zIndex:m.zIndex??v.zIndex,borderRadius:m.borderRadius??v.borderRadius,captionHeight:m.captionHeight??v.captionHeight,pageIndex:m.pageIndex??v.pageIndex}:v}),...r.map(v=>({...v,src:Object.hasOwn(o,v.templateAssetKey)?o[v.templateAssetKey]:v.src}))]}const Gp=({isOpen:u,onClose:c,currentConfig:o,onApplyTemplate:r,adminKey:d})=>{const[h,b]=me.useState([]),[v,y]=me.useState({}),[m,p]=me.useState("default"),[g,N]=me.useState("all"),[C,V]=me.useState(!1),[W,L]=me.useState(""),[U,te]=me.useState(()=>o.aspectRatio==="wechat-cover-2.35"?"article_cover":"newspic_content"),[le,oe]=me.useState(!1),[ce,Z]=me.useState(null),ee=async(Y=m)=>{try{const ae=await fetch(`/api/templates/slots?account=${encodeURIComponent(Y)}`,{headers:{"x-admin-key":d}}),j=await ae.json();if(!ae.ok||!j.ok)throw new Error(j.message||j.error||"获取槽位失败");j.ok&&j.slots&&y(j.slots)}catch(ae){Z(ae instanceof Error?ae.message:"模板请求失败")}},G=async(Y,ae)=>{try{const j=await fetch("/api/templates/slots",{method:"POST",headers:{"Content-Type":"application/json",...d?{"x-admin-key":d}:{}},body:JSON.stringify({slot:Y,templateId:ae,account:m})}),B=await j.json();if(!j.ok||!B.ok)throw new Error(B.message||B.error||"设置默认模板失败");B.ok&&await ee(m)}catch(j){Z(j instanceof Error?j.message:"模板请求失败")}},A=async()=>{V(!0),Z(null);try{const Y=await fetch("/api/templates",{headers:d?{"x-admin-key":d}:{}}),ae=await Y.json();Y.ok&&ae.ok&&Array.isArray(ae.templates)?b(ae.templates):Z(ae.message||"获取模板失败,请检查密钥")}catch{Z("连接后端服务失败")}finally{V(!1)}};me.useEffect(()=>{u&&(A(),ee(m),L(o.name?`${o.name} 副本`:"我的自定义模板"),te(o.aspectRatio==="wechat-cover-2.35"?"article_cover":"newspic_content"))},[u,m,d]);const X=async()=>{if(W.trim()){oe(!0);try{Ac(o.images);const Y={...o,id:void 0,name:W.trim(),slot:U!=="none"?U:void 0},ae=await fetch("/api/templates",{method:"POST",headers:{"Content-Type":"application/json",...d?{"x-admin-key":d}:{}},body:JSON.stringify(Y)}),j=await ae.json();ae.ok&&j.ok?(await A(),await ee(m)):Z(j.message||j.error||"保存模板失败")}catch(Y){Z(Y instanceof Error?Y.message:"保存模板请求异常")}finally{oe(!1)}}},D=async Y=>{try{const ae=await fetch(`/api/templates/${encodeURIComponent(Y)}`,{method:"DELETE",headers:d?{"x-admin-key":d}:{}}),j=await ae.json();if(!ae.ok||!j.ok)throw new Error(j.message||j.error||"删除模板失败");b(B=>B.filter(k=>k.id!==Y)),await ee(m)}catch(ae){Z(ae instanceof Error?ae.message:"模板请求失败")}};if(!u)return null;const $=h.filter(Y=>g==="all"?!0:Y.slot===g);return f.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 dark:bg-black/70 backdrop-blur-sm flex items-center justify-center p-4",children:f.jsxs("div",{className:"bg-white dark:bg-[#0f0f0f] border border-[#eaeaea] dark:border-[#262626] rounded-xl w-full max-w-xl flex flex-col shadow-2xl overflow-hidden animate-in fade-in zoom-in-95 duration-150 transition-colors",children:[f.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-[#eaeaea] dark:border-[#222222]",children:[f.jsxs("div",{className:"flex items-center gap-2 font-semibold text-sm text-[#171717] dark:text-white",children:[f.jsx(bo,{className:"w-4 h-4 text-emerald-500 dark:text-emerald-400"}),f.jsx("span",{children:"排版模板中心"})]}),f.jsx("button",{onClick:c,className:"text-[#888888] hover:text-black dark:hover:text-white p-1 rounded-md hover:bg-[#f5f5f5] dark:hover:bg-[#1a1a1a]",children:f.jsx(Sh,{className:"w-4 h-4"})})]}),f.jsxs("div",{className:"p-5 flex flex-col gap-4 max-h-[75vh] overflow-y-auto",children:[f.jsxs("div",{className:"bg-[#f9f9f9] dark:bg-[#141414] border border-[#eaeaea] dark:border-[#222222] rounded-lg p-3 flex flex-col gap-2.5",children:[f.jsx("span",{className:"text-xs text-[#666666] dark:text-[#888888] font-medium",children:"将当前参数另存为模板"}),f.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[f.jsx("input",{type:"text",value:W,onChange:Y=>L(Y.target.value),placeholder:"模板名称...",className:"flex-1 bg-white dark:bg-[#0a0a0a] border border-[#d4d4d4] dark:border-[#2a2a2a] rounded px-3 py-1.5 text-xs text-black dark:text-white focus:outline-none focus:border-black dark:focus:border-[#444444]"}),f.jsxs("select",{value:U,onChange:Y=>te(Y.target.value),className:"bg-white dark:bg-[#0a0a0a] border border-[#d4d4d4] dark:border-[#2a2a2a] rounded px-2 py-1.5 text-xs text-black dark:text-white focus:outline-none focus:border-black dark:focus:border-[#444444]",children:[f.jsx("option",{value:"article_cover",children:"槽位: 文章封面 (2.35:1)"}),f.jsx("option",{value:"newspic_cover",children:"槽位: 贴图封面 (3:4)"}),f.jsx("option",{value:"newspic_content",children:"槽位: 贴图内容 (3:4)"}),f.jsx("option",{value:"none",children:"槽位: 通用模板"})]}),f.jsxs("button",{onClick:X,disabled:le,className:"flex items-center justify-center gap-1.5 px-3 py-1.5 bg-black text-white hover:bg-[#262626] dark:bg-white dark:text-black dark:hover:bg-[#eaeaea] text-xs font-semibold rounded transition-all btn-vercel disabled:opacity-50 shrink-0",children:[f.jsx(rp,{className:"w-3.5 h-3.5"}),f.jsx("span",{children:le?"保存中...":"保存模板"})]})]})]}),ce&&f.jsx("div",{className:"text-xs text-amber-600 dark:text-amber-400 bg-amber-500/10 border border-amber-500/20 px-3 py-2 rounded-lg",children:ce}),f.jsxs("div",{className:"flex flex-col gap-2 pt-1 border-t border-[#eaeaea] dark:border-[#222222]",children:[f.jsx("div",{className:"flex items-center justify-between text-xs",children:f.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-[#666666] dark:text-[#888888]",children:[f.jsx("span",{children:"默认槽位配置账号:"}),f.jsxs("select",{value:m,onChange:Y=>p(Y.target.value),className:"bg-white dark:bg-[#141414] border border-[#d4d4d4] dark:border-[#2a2a2a] rounded px-2 py-0.5 text-xs text-black dark:text-white focus:outline-none font-mono",children:[f.jsx("option",{value:"default",children:"default (主账号)"}),f.jsx("option",{value:"ancientone",children:"ancientone"})]})]})}),f.jsxs("div",{className:"flex items-center gap-1.5 text-xs overflow-x-auto pb-1",children:[f.jsx("button",{onClick:()=>N("all"),className:`px-2.5 py-1 rounded text-xs transition-colors font-medium ${g==="all"?"bg-black text-white dark:bg-white dark:text-black":"text-[#666666] dark:text-[#888888] hover:bg-[#f5f5f5] dark:hover:bg-[#1c1c1c]"}`,children:"全部"}),f.jsx("button",{onClick:()=>N("article_cover"),className:`px-2.5 py-1 rounded text-xs transition-colors font-medium ${g==="article_cover"?"bg-black text-white dark:bg-white dark:text-black":"text-[#666666] dark:text-[#888888] hover:bg-[#f5f5f5] dark:hover:bg-[#1c1c1c]"}`,children:"文章封面"}),f.jsx("button",{onClick:()=>N("newspic_cover"),className:`px-2.5 py-1 rounded text-xs transition-colors font-medium ${g==="newspic_cover"?"bg-black text-white dark:bg-white dark:text-black":"text-[#666666] dark:text-[#888888] hover:bg-[#f5f5f5] dark:hover:bg-[#1c1c1c]"}`,children:"贴图封面"}),f.jsx("button",{onClick:()=>N("newspic_content"),className:`px-2.5 py-1 rounded text-xs transition-colors font-medium ${g==="newspic_content"?"bg-black text-white dark:bg-white dark:text-black":"text-[#666666] dark:text-[#888888] hover:bg-[#f5f5f5] dark:hover:bg-[#1c1c1c]"}`,children:"贴图内容"})]})]}),f.jsx("div",{className:"flex flex-col gap-2",children:C?f.jsx("div",{className:"text-center py-8 text-xs text-[#888888] dark:text-[#555555]",children:"正在加载模板..."}):$.length===0?f.jsx("div",{className:"text-center py-8 text-xs text-[#888888] dark:text-[#555555]",children:"暂无匹配模板"}):$.map(Y=>{const ae=v.article_cover?.id===Y.id,j=v.newspic_cover?.id===Y.id,B=v.newspic_content?.id===Y.id;return f.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between p-3 rounded-lg bg-[#fafafa] dark:bg-[#141414] border border-[#eaeaea] dark:border-[#222222] hover:border-[#cccccc] dark:hover:border-[#333333] transition-all gap-2 group",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-5 h-5 rounded border border-[#d4d4d4] dark:border-[#333333] shrink-0",style:{backgroundColor:Y.theme.bgColor}}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[f.jsx("span",{className:"text-xs font-semibold text-[#171717] dark:text-white",children:Y.name}),Y.slot&&f.jsx("span",{className:"text-[10px] px-1.5 py-0.2 rounded bg-blue-500/10 text-blue-600 dark:text-blue-400 border border-blue-500/20 font-medium",children:Y.slot==="article_cover"?"文章封面":Y.slot==="newspic_cover"?"贴图封面":"贴图内容"}),ae&&f.jsxs("span",{className:"text-[10px] px-1.5 py-0.2 rounded bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20 font-medium flex items-center gap-0.5",children:[f.jsx(fo,{className:"w-2.5 h-2.5 fill-amber-500"})," 文章封面默认"]}),j&&f.jsxs("span",{className:"text-[10px] px-1.5 py-0.2 rounded bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20 font-medium flex items-center gap-0.5",children:[f.jsx(fo,{className:"w-2.5 h-2.5 fill-amber-500"})," 贴图封面默认"]}),B&&f.jsxs("span",{className:"text-[10px] px-1.5 py-0.2 rounded bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20 font-medium flex items-center gap-0.5",children:[f.jsx(fo,{className:"w-2.5 h-2.5 fill-emerald-500"})," 贴图内容默认"]})]}),f.jsxs("div",{className:"text-[10px] text-[#888888] dark:text-[#666666] font-mono mt-0.5",children:[Y.aspectRatio," • 字号: ",Y.algorithm.baseFontSize,"px",Y.images&&Y.images.length>0&&` • 配图: ${Y.images.length}个`]})]})]}),f.jsxs("div",{className:"flex items-center gap-2 self-end sm:self-auto",children:[Y.id&&f.jsxs("select",{value:"",onChange:k=>{k.target.value&&G(k.target.value,Y.id)},className:"text-[11px] bg-white dark:bg-[#1a1a1a] border border-[#d4d4d4] dark:border-[#333333] text-[#666666] dark:text-[#aaaaaa] rounded px-2 py-1 focus:outline-none",title:"为此账号设为某个槽位的默认模板",children:[f.jsx("option",{value:"",children:"设为槽位默认..."}),f.jsx("option",{value:"article_cover",children:"设为「文章封面默认」"}),f.jsx("option",{value:"newspic_cover",children:"设为「贴图封面默认」"}),f.jsx("option",{value:"newspic_content",children:"设为「贴图内容默认」"})]}),f.jsxs("button",{onClick:()=>{r(Y),c()},className:"flex items-center gap-1 px-2.5 py-1 bg-white dark:bg-[#1f1f1f] hover:bg-emerald-50 dark:hover:bg-emerald-500/20 text-[#333333] dark:text-[#cccccc] hover:text-emerald-700 dark:hover:text-emerald-400 border border-[#d4d4d4] dark:border-[#2a2a2a] hover:border-emerald-500/40 rounded text-xs transition-all font-medium",children:[f.jsx(q1,{className:"w-3 h-3"}),f.jsx("span",{children:"套用"})]}),Y.id&&!Y.id.startsWith("tpl_wechat_")&&!Y.id.startsWith("tpl_longform_")&&!Y.id.startsWith("tpl_square_")&&!Y.id.startsWith("tpl_wide_")&&f.jsx("button",{onClick:()=>D(Y.id),className:"p-1 text-[#888888] dark:text-[#555555] hover:text-red-500 rounded hover:bg-[#f0f0f0] dark:hover:bg-[#1f1f1f]",title:"删除自定义模板",children:f.jsx(vh,{className:"w-3.5 h-3.5"})})]})]},Y.id)})})]})]})})},xo="typeset_studio_admin_key";function Yp(){const[u,c]=me.useState(()=>localStorage.getItem(xo)||""),[o,r]=me.useState(null),[d,h]=me.useState(!1),b=async y=>{if(!y)return r(!1),!1;h(!0);try{const g=!!(await(await fetch("/api/auth/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:y})})).json()).ok;return r(g),g}catch{return r(!1),!1}finally{h(!1)}},v=y=>{localStorage.setItem(xo,y),c(y),b(y)};return me.useEffect(()=>{(async()=>{let m=u;if(!m)try{const g=await(await fetch("/api/auth/current-key")).json();g.ok&&g.key&&(m=g.key,c(g.key),localStorage.setItem(xo,g.key))}catch{}m?b(m):r(!1)})()},[]),{adminKey:u,setAdminKey:v,isVerified:o,isVerifying:d,verifyKey:b}}const Xp=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","BN","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],p1=[[697,698,"ON"],[706,719,"ON"],[722,735,"ON"],[741,749,"ON"],[751,767,"ON"],[768,879,"NSM"],[884,885,"ON"],[894,894,"ON"],[900,901,"ON"],[903,903,"ON"],[1014,1014,"ON"],[1155,1161,"NSM"],[1418,1418,"ON"],[1421,1422,"ON"],[1423,1423,"ET"],[1424,1424,"R"],[1425,1469,"NSM"],[1470,1470,"R"],[1471,1471,"NSM"],[1472,1472,"R"],[1473,1474,"NSM"],[1475,1475,"R"],[1476,1477,"NSM"],[1478,1478,"R"],[1479,1479,"NSM"],[1480,1535,"R"],[1536,1541,"AN"],[1542,1543,"ON"],[1544,1544,"AL"],[1545,1546,"ET"],[1547,1547,"AL"],[1548,1548,"CS"],[1549,1549,"AL"],[1550,1551,"ON"],[1552,1562,"NSM"],[1563,1610,"AL"],[1611,1631,"NSM"],[1632,1641,"AN"],[1642,1642,"ET"],[1643,1644,"AN"],[1645,1647,"AL"],[1648,1648,"NSM"],[1649,1749,"AL"],[1750,1756,"NSM"],[1757,1757,"AN"],[1758,1758,"ON"],[1759,1764,"NSM"],[1765,1766,"AL"],[1767,1768,"NSM"],[1769,1769,"ON"],[1770,1773,"NSM"],[1774,1775,"AL"],[1776,1785,"EN"],[1786,1808,"AL"],[1809,1809,"NSM"],[1810,1839,"AL"],[1840,1866,"NSM"],[1867,1957,"AL"],[1958,1968,"NSM"],[1969,1983,"AL"],[1984,2026,"R"],[2027,2035,"NSM"],[2036,2037,"R"],[2038,2041,"ON"],[2042,2044,"R"],[2045,2045,"NSM"],[2046,2069,"R"],[2070,2073,"NSM"],[2074,2074,"R"],[2075,2083,"NSM"],[2084,2084,"R"],[2085,2087,"NSM"],[2088,2088,"R"],[2089,2093,"NSM"],[2094,2136,"R"],[2137,2139,"NSM"],[2140,2143,"R"],[2144,2191,"AL"],[2192,2193,"AN"],[2194,2198,"AL"],[2199,2207,"NSM"],[2208,2249,"AL"],[2250,2273,"NSM"],[2274,2274,"AN"],[2275,2306,"NSM"],[2362,2362,"NSM"],[2364,2364,"NSM"],[2369,2376,"NSM"],[2381,2381,"NSM"],[2385,2391,"NSM"],[2402,2403,"NSM"],[2433,2433,"NSM"],[2492,2492,"NSM"],[2497,2500,"NSM"],[2509,2509,"NSM"],[2530,2531,"NSM"],[2546,2547,"ET"],[2555,2555,"ET"],[2558,2558,"NSM"],[2561,2562,"NSM"],[2620,2620,"NSM"],[2625,2626,"NSM"],[2631,2632,"NSM"],[2635,2637,"NSM"],[2641,2641,"NSM"],[2672,2673,"NSM"],[2677,2677,"NSM"],[2689,2690,"NSM"],[2748,2748,"NSM"],[2753,2757,"NSM"],[2759,2760,"NSM"],[2765,2765,"NSM"],[2786,2787,"NSM"],[2801,2801,"ET"],[2810,2815,"NSM"],[2817,2817,"NSM"],[2876,2876,"NSM"],[2879,2879,"NSM"],[2881,2884,"NSM"],[2893,2893,"NSM"],[2901,2902,"NSM"],[2914,2915,"NSM"],[2946,2946,"NSM"],[3008,3008,"NSM"],[3021,3021,"NSM"],[3059,3064,"ON"],[3065,3065,"ET"],[3066,3066,"ON"],[3072,3072,"NSM"],[3076,3076,"NSM"],[3132,3132,"NSM"],[3134,3136,"NSM"],[3142,3144,"NSM"],[3146,3149,"NSM"],[3157,3158,"NSM"],[3170,3171,"NSM"],[3192,3198,"ON"],[3201,3201,"NSM"],[3260,3260,"NSM"],[3276,3277,"NSM"],[3298,3299,"NSM"],[3328,3329,"NSM"],[3387,3388,"NSM"],[3393,3396,"NSM"],[3405,3405,"NSM"],[3426,3427,"NSM"],[3457,3457,"NSM"],[3530,3530,"NSM"],[3538,3540,"NSM"],[3542,3542,"NSM"],[3633,3633,"NSM"],[3636,3642,"NSM"],[3647,3647,"ET"],[3655,3662,"NSM"],[3761,3761,"NSM"],[3764,3772,"NSM"],[3784,3790,"NSM"],[3864,3865,"NSM"],[3893,3893,"NSM"],[3895,3895,"NSM"],[3897,3897,"NSM"],[3898,3901,"ON"],[3953,3966,"NSM"],[3968,3972,"NSM"],[3974,3975,"NSM"],[3981,3991,"NSM"],[3993,4028,"NSM"],[4038,4038,"NSM"],[4141,4144,"NSM"],[4146,4151,"NSM"],[4153,4154,"NSM"],[4157,4158,"NSM"],[4184,4185,"NSM"],[4190,4192,"NSM"],[4209,4212,"NSM"],[4226,4226,"NSM"],[4229,4230,"NSM"],[4237,4237,"NSM"],[4253,4253,"NSM"],[4957,4959,"NSM"],[5008,5017,"ON"],[5120,5120,"ON"],[5760,5760,"WS"],[5787,5788,"ON"],[5906,5908,"NSM"],[5938,5939,"NSM"],[5970,5971,"NSM"],[6002,6003,"NSM"],[6068,6069,"NSM"],[6071,6077,"NSM"],[6086,6086,"NSM"],[6089,6099,"NSM"],[6107,6107,"ET"],[6109,6109,"NSM"],[6128,6137,"ON"],[6144,6154,"ON"],[6155,6157,"NSM"],[6158,6158,"BN"],[6159,6159,"NSM"],[6277,6278,"NSM"],[6313,6313,"NSM"],[6432,6434,"NSM"],[6439,6440,"NSM"],[6450,6450,"NSM"],[6457,6459,"NSM"],[6464,6464,"ON"],[6468,6469,"ON"],[6622,6655,"ON"],[6679,6680,"NSM"],[6683,6683,"NSM"],[6742,6742,"NSM"],[6744,6750,"NSM"],[6752,6752,"NSM"],[6754,6754,"NSM"],[6757,6764,"NSM"],[6771,6780,"NSM"],[6783,6783,"NSM"],[6832,6877,"NSM"],[6880,6891,"NSM"],[6912,6915,"NSM"],[6964,6964,"NSM"],[6966,6970,"NSM"],[6972,6972,"NSM"],[6978,6978,"NSM"],[7019,7027,"NSM"],[7040,7041,"NSM"],[7074,7077,"NSM"],[7080,7081,"NSM"],[7083,7085,"NSM"],[7142,7142,"NSM"],[7144,7145,"NSM"],[7149,7149,"NSM"],[7151,7153,"NSM"],[7212,7219,"NSM"],[7222,7223,"NSM"],[7376,7378,"NSM"],[7380,7392,"NSM"],[7394,7400,"NSM"],[7405,7405,"NSM"],[7412,7412,"NSM"],[7416,7417,"NSM"],[7616,7679,"NSM"],[8125,8125,"ON"],[8127,8129,"ON"],[8141,8143,"ON"],[8157,8159,"ON"],[8173,8175,"ON"],[8189,8190,"ON"],[8192,8202,"WS"],[8203,8205,"BN"],[8207,8207,"R"],[8208,8231,"ON"],[8232,8232,"WS"],[8233,8233,"B"],[8234,8238,"BN"],[8239,8239,"CS"],[8240,8244,"ET"],[8245,8259,"ON"],[8260,8260,"CS"],[8261,8286,"ON"],[8287,8287,"WS"],[8288,8303,"BN"],[8304,8304,"EN"],[8308,8313,"EN"],[8314,8315,"ES"],[8316,8318,"ON"],[8320,8329,"EN"],[8330,8331,"ES"],[8332,8334,"ON"],[8352,8399,"ET"],[8400,8432,"NSM"],[8448,8449,"ON"],[8451,8454,"ON"],[8456,8457,"ON"],[8468,8468,"ON"],[8470,8472,"ON"],[8478,8483,"ON"],[8485,8485,"ON"],[8487,8487,"ON"],[8489,8489,"ON"],[8494,8494,"ET"],[8506,8507,"ON"],[8512,8516,"ON"],[8522,8525,"ON"],[8528,8543,"ON"],[8585,8587,"ON"],[8592,8721,"ON"],[8722,8722,"ES"],[8723,8723,"ET"],[8724,9013,"ON"],[9083,9108,"ON"],[9110,9257,"ON"],[9280,9290,"ON"],[9312,9351,"ON"],[9352,9371,"EN"],[9450,9899,"ON"],[9901,10239,"ON"],[10496,11123,"ON"],[11126,11263,"ON"],[11493,11498,"ON"],[11503,11505,"NSM"],[11513,11519,"ON"],[11647,11647,"NSM"],[11744,11775,"NSM"],[11776,11869,"ON"],[11904,11929,"ON"],[11931,12019,"ON"],[12032,12245,"ON"],[12272,12287,"ON"],[12288,12288,"WS"],[12289,12292,"ON"],[12296,12320,"ON"],[12330,12333,"NSM"],[12336,12336,"ON"],[12342,12343,"ON"],[12349,12351,"ON"],[12441,12442,"NSM"],[12443,12444,"ON"],[12448,12448,"ON"],[12539,12539,"ON"],[12736,12773,"ON"],[12783,12783,"ON"],[12829,12830,"ON"],[12880,12895,"ON"],[12924,12926,"ON"],[12977,12991,"ON"],[13004,13007,"ON"],[13175,13178,"ON"],[13278,13279,"ON"],[13311,13311,"ON"],[19904,19967,"ON"],[42128,42182,"ON"],[42509,42511,"ON"],[42607,42610,"NSM"],[42611,42611,"ON"],[42612,42621,"NSM"],[42622,42623,"ON"],[42654,42655,"NSM"],[42736,42737,"NSM"],[42752,42785,"ON"],[42888,42888,"ON"],[43010,43010,"NSM"],[43014,43014,"NSM"],[43019,43019,"NSM"],[43045,43046,"NSM"],[43048,43051,"ON"],[43052,43052,"NSM"],[43064,43065,"ET"],[43124,43127,"ON"],[43204,43205,"NSM"],[43232,43249,"NSM"],[43263,43263,"NSM"],[43302,43309,"NSM"],[43335,43345,"NSM"],[43392,43394,"NSM"],[43443,43443,"NSM"],[43446,43449,"NSM"],[43452,43453,"NSM"],[43493,43493,"NSM"],[43561,43566,"NSM"],[43569,43570,"NSM"],[43573,43574,"NSM"],[43587,43587,"NSM"],[43596,43596,"NSM"],[43644,43644,"NSM"],[43696,43696,"NSM"],[43698,43700,"NSM"],[43703,43704,"NSM"],[43710,43711,"NSM"],[43713,43713,"NSM"],[43756,43757,"NSM"],[43766,43766,"NSM"],[43882,43883,"ON"],[44005,44005,"NSM"],[44008,44008,"NSM"],[44013,44013,"NSM"],[64285,64285,"R"],[64286,64286,"NSM"],[64287,64296,"R"],[64297,64297,"ES"],[64298,64335,"R"],[64336,64450,"AL"],[64451,64466,"ON"],[64467,64829,"AL"],[64830,64847,"ON"],[64848,64911,"AL"],[64912,64913,"ON"],[64914,64967,"AL"],[64968,64975,"ON"],[64976,65007,"BN"],[65008,65020,"AL"],[65021,65023,"ON"],[65024,65039,"NSM"],[65040,65049,"ON"],[65056,65071,"NSM"],[65072,65103,"ON"],[65104,65104,"CS"],[65105,65105,"ON"],[65106,65106,"CS"],[65108,65108,"ON"],[65109,65109,"CS"],[65110,65118,"ON"],[65119,65119,"ET"],[65120,65121,"ON"],[65122,65123,"ES"],[65124,65126,"ON"],[65128,65128,"ON"],[65129,65130,"ET"],[65131,65131,"ON"],[65136,65278,"AL"],[65279,65279,"BN"],[65281,65282,"ON"],[65283,65285,"ET"],[65286,65290,"ON"],[65291,65291,"ES"],[65292,65292,"CS"],[65293,65293,"ES"],[65294,65295,"CS"],[65296,65305,"EN"],[65306,65306,"CS"],[65307,65312,"ON"],[65339,65344,"ON"],[65371,65381,"ON"],[65504,65505,"ET"],[65506,65508,"ON"],[65509,65510,"ET"],[65512,65518,"ON"],[65520,65528,"BN"],[65529,65533,"ON"],[65534,65535,"BN"],[65793,65793,"ON"],[65856,65932,"ON"],[65936,65948,"ON"],[65952,65952,"ON"],[66045,66045,"NSM"],[66272,66272,"NSM"],[66273,66299,"EN"],[66422,66426,"NSM"],[67584,67870,"R"],[67871,67871,"ON"],[67872,68096,"R"],[68097,68099,"NSM"],[68100,68100,"R"],[68101,68102,"NSM"],[68103,68107,"R"],[68108,68111,"NSM"],[68112,68151,"R"],[68152,68154,"NSM"],[68155,68158,"R"],[68159,68159,"NSM"],[68160,68324,"R"],[68325,68326,"NSM"],[68327,68408,"R"],[68409,68415,"ON"],[68416,68863,"R"],[68864,68899,"AL"],[68900,68903,"NSM"],[68904,68911,"AL"],[68912,68921,"AN"],[68922,68927,"AL"],[68928,68937,"AN"],[68938,68968,"R"],[68969,68973,"NSM"],[68974,68974,"ON"],[68975,69215,"R"],[69216,69246,"AN"],[69247,69290,"R"],[69291,69292,"NSM"],[69293,69311,"R"],[69312,69327,"AL"],[69328,69336,"ON"],[69337,69369,"AL"],[69370,69375,"NSM"],[69376,69423,"R"],[69424,69445,"AL"],[69446,69456,"NSM"],[69457,69487,"AL"],[69488,69505,"R"],[69506,69509,"NSM"],[69510,69631,"R"],[69633,69633,"NSM"],[69688,69702,"NSM"],[69714,69733,"ON"],[69744,69744,"NSM"],[69747,69748,"NSM"],[69759,69761,"NSM"],[69811,69814,"NSM"],[69817,69818,"NSM"],[69826,69826,"NSM"],[69888,69890,"NSM"],[69927,69931,"NSM"],[69933,69940,"NSM"],[70003,70003,"NSM"],[70016,70017,"NSM"],[70070,70078,"NSM"],[70089,70092,"NSM"],[70095,70095,"NSM"],[70191,70193,"NSM"],[70196,70196,"NSM"],[70198,70199,"NSM"],[70206,70206,"NSM"],[70209,70209,"NSM"],[70367,70367,"NSM"],[70371,70378,"NSM"],[70400,70401,"NSM"],[70459,70460,"NSM"],[70464,70464,"NSM"],[70502,70508,"NSM"],[70512,70516,"NSM"],[70587,70592,"NSM"],[70606,70606,"NSM"],[70608,70608,"NSM"],[70610,70610,"NSM"],[70625,70626,"NSM"],[70712,70719,"NSM"],[70722,70724,"NSM"],[70726,70726,"NSM"],[70750,70750,"NSM"],[70835,70840,"NSM"],[70842,70842,"NSM"],[70847,70848,"NSM"],[70850,70851,"NSM"],[71090,71093,"NSM"],[71100,71101,"NSM"],[71103,71104,"NSM"],[71132,71133,"NSM"],[71219,71226,"NSM"],[71229,71229,"NSM"],[71231,71232,"NSM"],[71264,71276,"ON"],[71339,71339,"NSM"],[71341,71341,"NSM"],[71344,71349,"NSM"],[71351,71351,"NSM"],[71453,71453,"NSM"],[71455,71455,"NSM"],[71458,71461,"NSM"],[71463,71467,"NSM"],[71727,71735,"NSM"],[71737,71738,"NSM"],[71995,71996,"NSM"],[71998,71998,"NSM"],[72003,72003,"NSM"],[72148,72151,"NSM"],[72154,72155,"NSM"],[72160,72160,"NSM"],[72193,72198,"NSM"],[72201,72202,"NSM"],[72243,72248,"NSM"],[72251,72254,"NSM"],[72263,72263,"NSM"],[72273,72278,"NSM"],[72281,72283,"NSM"],[72330,72342,"NSM"],[72344,72345,"NSM"],[72544,72544,"NSM"],[72546,72548,"NSM"],[72550,72550,"NSM"],[72752,72758,"NSM"],[72760,72765,"NSM"],[72850,72871,"NSM"],[72874,72880,"NSM"],[72882,72883,"NSM"],[72885,72886,"NSM"],[73009,73014,"NSM"],[73018,73018,"NSM"],[73020,73021,"NSM"],[73023,73029,"NSM"],[73031,73031,"NSM"],[73104,73105,"NSM"],[73109,73109,"NSM"],[73111,73111,"NSM"],[73459,73460,"NSM"],[73472,73473,"NSM"],[73526,73530,"NSM"],[73536,73536,"NSM"],[73538,73538,"NSM"],[73562,73562,"NSM"],[73685,73692,"ON"],[73693,73696,"ET"],[73697,73713,"ON"],[78912,78912,"NSM"],[78919,78933,"NSM"],[90398,90409,"NSM"],[90413,90415,"NSM"],[92912,92916,"NSM"],[92976,92982,"NSM"],[94031,94031,"NSM"],[94095,94098,"NSM"],[94178,94178,"ON"],[94180,94180,"NSM"],[113821,113822,"NSM"],[113824,113827,"BN"],[117760,117973,"ON"],[118e3,118009,"EN"],[118010,118012,"ON"],[118016,118451,"ON"],[118458,118480,"ON"],[118496,118512,"ON"],[118528,118573,"NSM"],[118576,118598,"NSM"],[119143,119145,"NSM"],[119155,119162,"BN"],[119163,119170,"NSM"],[119173,119179,"NSM"],[119210,119213,"NSM"],[119273,119274,"ON"],[119296,119361,"ON"],[119362,119364,"NSM"],[119365,119365,"ON"],[119552,119638,"ON"],[120513,120513,"ON"],[120539,120539,"ON"],[120571,120571,"ON"],[120597,120597,"ON"],[120629,120629,"ON"],[120655,120655,"ON"],[120687,120687,"ON"],[120713,120713,"ON"],[120745,120745,"ON"],[120771,120771,"ON"],[120782,120831,"EN"],[121344,121398,"NSM"],[121403,121452,"NSM"],[121461,121461,"NSM"],[121476,121476,"NSM"],[121499,121503,"NSM"],[121505,121519,"NSM"],[122880,122886,"NSM"],[122888,122904,"NSM"],[122907,122913,"NSM"],[122915,122916,"NSM"],[122918,122922,"NSM"],[123023,123023,"NSM"],[123184,123190,"NSM"],[123566,123566,"NSM"],[123628,123631,"NSM"],[123647,123647,"ET"],[124140,124143,"NSM"],[124398,124399,"NSM"],[124643,124643,"NSM"],[124646,124646,"NSM"],[124654,124655,"NSM"],[124661,124661,"NSM"],[124928,125135,"R"],[125136,125142,"NSM"],[125143,125251,"R"],[125252,125258,"NSM"],[125259,126063,"R"],[126064,126143,"AL"],[126144,126207,"R"],[126208,126287,"AL"],[126288,126463,"R"],[126464,126703,"AL"],[126704,126705,"ON"],[126706,126719,"AL"],[126720,126975,"R"],[126976,127019,"ON"],[127024,127123,"ON"],[127136,127150,"ON"],[127153,127167,"ON"],[127169,127183,"ON"],[127185,127221,"ON"],[127232,127242,"EN"],[127243,127247,"ON"],[127279,127279,"ON"],[127338,127343,"ON"],[127405,127405,"ON"],[127584,127589,"ON"],[127744,128728,"ON"],[128732,128748,"ON"],[128752,128764,"ON"],[128768,128985,"ON"],[128992,129003,"ON"],[129008,129008,"ON"],[129024,129035,"ON"],[129040,129095,"ON"],[129104,129113,"ON"],[129120,129159,"ON"],[129168,129197,"ON"],[129200,129211,"ON"],[129216,129217,"ON"],[129232,129240,"ON"],[129280,129623,"ON"],[129632,129645,"ON"],[129648,129660,"ON"],[129664,129674,"ON"],[129678,129734,"ON"],[129736,129736,"ON"],[129741,129756,"ON"],[129759,129770,"ON"],[129775,129784,"ON"],[129792,129938,"ON"],[129940,130031,"ON"],[130032,130041,"EN"],[130042,130042,"ON"],[131070,131071,"BN"],[196606,196607,"BN"],[262142,262143,"BN"],[327678,327679,"BN"],[393214,393215,"BN"],[458750,458751,"BN"],[524286,524287,"BN"],[589822,589823,"BN"],[655358,655359,"BN"],[720894,720895,"BN"],[786430,786431,"BN"],[851966,851967,"BN"],[917502,917759,"BN"],[917760,917999,"NSM"],[918e3,921599,"BN"],[983038,983039,"BN"],[1048574,1048575,"BN"],[1114110,1114111,"BN"]];function Qp(u){if(u<=255)return Xp[u];let c=0,o=p1.length-1;for(;c<=o;){const r=c+o>>1,d=p1[r];if(u<d[0]){o=r-1;continue}if(u>d[1]){c=r+1;continue}return d[2]}return"L"}function Vp(u){const c=u.length;if(c===0)return null;const o=new Array(c);let r=!1;for(let m=0;m<c;){const p=u.charCodeAt(m);let g=p,N=1;if(p>=55296&&p<=56319&&m+1<c){const V=u.charCodeAt(m+1);V>=56320&&V<=57343&&(g=(p-55296<<10)+(V-56320)+65536,N=2)}const C=Qp(g);(C==="R"||C==="AL"||C==="AN")&&(r=!0);for(let V=0;V<N;V++)o[m+V]=C;m+=N}if(!r)return null;let d=0;for(let m=0;m<c;m++){const p=o[m];if(p==="L"){d=0;break}if(p==="R"||p==="AL"){d=1;break}}const h=new Int8Array(c);for(let m=0;m<c;m++)h[m]=d;const b=d&1?"R":"L",v=b;let y=v;for(let m=0;m<c;m++)o[m]==="NSM"?o[m]=y:y=o[m];y=v;for(let m=0;m<c;m++){const p=o[m];p==="EN"?o[m]=y==="AL"?"AN":"EN":(p==="R"||p==="L"||p==="AL")&&(y=p)}for(let m=0;m<c;m++)o[m]==="AL"&&(o[m]="R");for(let m=1;m<c-1;m++)o[m]==="ES"&&o[m-1]==="EN"&&o[m+1]==="EN"&&(o[m]="EN"),o[m]==="CS"&&(o[m-1]==="EN"||o[m-1]==="AN")&&o[m+1]===o[m-1]&&(o[m]=o[m-1]);for(let m=0;m<c;m++){if(o[m]!=="EN")continue;let p;for(p=m-1;p>=0&&o[p]==="ET";p--)o[p]="EN";for(p=m+1;p<c&&o[p]==="ET";p++)o[p]="EN"}for(let m=0;m<c;m++){const p=o[m];(p==="WS"||p==="ES"||p==="ET"||p==="CS")&&(o[m]="ON")}y=v;for(let m=0;m<c;m++){const p=o[m];p==="EN"?o[m]=y==="L"?"L":"EN":(p==="R"||p==="L")&&(y=p)}for(let m=0;m<c;m++){if(o[m]!=="ON")continue;let p=m+1;for(;p<c&&o[p]==="ON";)p++;const g=m>0?o[m-1]:v,N=p<c?o[p]:v,C=g!=="L"?"R":"L";if(C===(N!=="L"?"R":"L"))for(let W=m;W<p;W++)o[W]=C;m=p-1}for(let m=0;m<c;m++)o[m]==="ON"&&(o[m]=b);for(let m=0;m<c;m++){const p=o[m];(h[m]&1)===0?p==="R"?h[m]++:(p==="AN"||p==="EN")&&(h[m]+=2):(p==="L"||p==="AN"||p==="EN")&&h[m]++}return h}function Zp(u,c){const o=Vp(u);if(o===null)return null;const r=new Int8Array(c.length);for(let d=0;d<c.length;d++)r[d]=o[c[d]];return r}const Kp=/[ \t\n\r\f]+/g,Jp=/[\t\n\r\f]| {2,}|^ | $/;function Ip(u){const c=u??"normal";return c==="pre-wrap"?{mode:c,preserveOrdinarySpaces:!0,preserveHardBreaks:!0}:{mode:c,preserveOrdinarySpaces:!1,preserveHardBreaks:!1}}function Wp(u){if(!Jp.test(u))return u;let c=u.replace(Kp," ");return c.charCodeAt(0)===32&&(c=c.slice(1)),c.length>0&&c.charCodeAt(c.length-1)===32&&(c=c.slice(0,-1)),c}function $p(u){return/[\r\f]/.test(u)?u.replace(/\r\n/g,`
|
|
293
293
|
`).replace(/[\r\f]/g,`
|
|
294
294
|
`):u}let pc=null,Pp;function ev(){return pc===null&&(pc=new Intl.Segmenter(Pp,{granularity:"word"})),pc}function tv(){pc=null}const lv=/\p{Script=Arabic}/u,cn=/\p{M}/u,Fo=/\p{Nd}/u;function v1(u){return lv.test(u)}function b1(u){return u>=19968&&u<=40959||u>=13312&&u<=19903||u>=131072&&u<=173791||u>=173824&&u<=177983||u>=177984&&u<=178207||u>=178208&&u<=183983||u>=183984&&u<=191471||u>=191472&&u<=192093||u>=194560&&u<=195103||u>=196608&&u<=201551||u>=201552&&u<=205743||u>=205744&&u<=210041||u>=63744&&u<=64255||u>=12288&&u<=12351||u>=12352&&u<=12447||u>=12448&&u<=12543||u>=12592&&u<=12687||u>=44032&&u<=55215||u>=65280&&u<=65519}function dl(u){for(let c=0;c<u.length;c++){const o=u.charCodeAt(c);if(!(o<12288)){if(o>=55296&&o<=56319&&c+1<u.length){const r=u.charCodeAt(c+1);if(r>=56320&&r<=57343){const d=(o-55296<<10)+(r-56320)+65536;if(b1(d))return!0;c++;continue}}if(b1(o))return!0}}return!1}function nv(u){const c=ji(u);return c!==null&&(To.has(c)||_n.has(c))}const av=new Set([" "," ","","\uFEFF"]),iv=new Set(["-","‐","–","—"]);function uv(u){const c=ji(u);return c!==null&&av.has(c)}function cv(u){const c=ji(u);return c!==null&&iv.has(c)}function Mh(u,c){return uv(u)?!1:c?!(nv(u)||cv(u)):!0}const To=new Set([",",".","!",":",";","?","、","。","・",")","〕","〉","》","」","』","】","〗","〙","〛","ー","々","〻","ゝ","ゞ","ヽ","ヾ"]),Cc=new Set(['"',"(","[","{","¡","¿","“","‘","‚","„","«","‹","⸘","(","〔","〈","《","「","『","【","〖","〘","〚"]),wo=new Set(["'","’"]),_n=new Set([".",",","!","?",":",";","،","؛","؟","।","॥","၊","။","၌","၍","၏",")","]","}","%",'"',"”","’","»","›","…"]),rv=new Set([":",".","،","؛"]),sv=new Set(["၏"]),ov=new Set(["”","’","»","›","」","』","】","》","〉","〕",")"]);function fv(u){if(Do(u))return!0;let c=!1;for(const o of u){if(_n.has(o)||kc(o)){c=!0;continue}if(!(c&&cn.test(o)))return!1}return c}function dv(u){for(const c of u)if(!To.has(c)&&!_n.has(c))return!1;return u.length>0}function xv(u){if(Do(u))return!0;for(const c of u)if(!Cc.has(c)&&!wo.has(c)&&!cn.test(c)&&!kc(c))return!1;return u.length>0}function Do(u){let c=!1;for(const o of u)if(!(o==="\\"||cn.test(o))){if(Cc.has(o)||_n.has(o)||wo.has(o)){c=!0;continue}return!1}return c}function Mc(u,c){const o=c-1;if(o<=0)return Math.max(o,0);const r=u.charCodeAt(o);if(r<56320||r>57343)return o;const d=o-1;if(d<0)return o;const h=u.charCodeAt(d);return h>=55296&&h<=56319?d:o}function ji(u){if(u.length===0)return null;const c=Mc(u,u.length);return u.slice(c)}function hv(u){for(const c of u)if(!cn.test(c))return c;return null}function mv(u){for(let c=u.length;c>0;){const o=Mc(u,c),r=u.slice(o,c);if(!cn.test(r))return r;c=o}return null}const gv=[36,37,43,43,92,92,162,165,176,177,1423,1423,1545,1547,1642,1642,2046,2047,2546,2547,2553,2555,2801,2801,3065,3065,3449,3449,3647,3647,6107,6107,8240,8247,8279,8279,8352,8399,8451,8451,8457,8457,8470,8470,8722,8723,43064,43064,65020,65020,65129,65130,65284,65285,65504,65505,65509,65510,73693,73696,123647,123647,126124,126124,126128,126128];function pv(u,c){for(let o=0;o<c.length;o+=2)if(u>=c[o]&&u<=c[o+1])return!0;return!1}function kc(u){const c=u.codePointAt(0);return c!==void 0&&pv(c,gv)}function vv(u){const c=mv(u);return c!==null&&kc(c)}function bv(u){const c=hv(u);return c!==null&&Fo.test(c)}function yv(u){const c=Array.from(u);let o=c.length;for(;o>0;){const r=c[o-1];if(cn.test(r)){o--;continue}if(Cc.has(r)||wo.has(r)){o--;continue}break}return o<=0||o===c.length?null:{head:c.slice(0,o).join(""),tail:c.slice(o).join("")}}function Nv(u,c,o){return o==="text"&&!c&&u.length===1&&u!=="-"&&u!=="—"?u:null}function y1(u,c,o,r){const d=c[r],h=u[r];if(d==null)return h;const b=o[r];if(h.length===b)return h;const v=d.repeat(b);return u[r]=v,v}function N1(u,c){return u&&c!==null&&rv.has(c)}function Sv(u){const c=ji(u);return c!==null&&sv.has(c)}function Ev(u){if(u.length<2||u[0]!==" ")return null;const c=u.slice(1);return/^\p{M}+$/u.test(c)?{space:" ",marks:c}:null}function yo(u){let c=u.length;for(;c>0;){const o=Mc(u,c),r=u.slice(o,c);if(ov.has(r))return!0;if(!_n.has(r))return!1;c=o}return!1}function Av(u,c){if(c.preserveOrdinarySpaces||c.preserveHardBreaks){if(u===" ")return"preserved-space";if(u===" ")return"tab";if(c.preserveHardBreaks&&u===`
|
|
295
295
|
`)return"hard-break"}return u===" "?"space":u===" "||u===" "||u===""||u==="\uFEFF"?"glue":u===""?"zero-width-break":u===""?"soft-hyphen":"text"}const Cv=/[\x20\t\n\xA0\xAD\u200B\u202F\u2060\uFEFF]/;function Pt(u){return u.length===1?u[0]:u.join("")}function Mv(u,c){const o=[];for(let r=u.length-1;r>=0;r--)o.push(u[r]);return o.push(c),Pt(o)}function kv(u,c,o,r){if(!Cv.test(u))return[{text:u,isWordLike:c,kind:"text",start:o}];const d=[];let h=null,b=[],v=o,y=!1,m=0;for(const p of u){const g=Av(p,r),N=g==="text"&&c;if(h!==null&&g===h&&N===y){b.push(p),m+=p.length;continue}h!==null&&d.push({text:Pt(b),isWordLike:y,kind:h,start:v}),h=g,b=[p],v=o+m,y=N,m+=p.length}return h!==null&&d.push({text:Pt(b),isWordLike:y,kind:h,start:v}),d}function No(u){return u==="space"||u==="preserved-space"||u==="zero-width-break"||u==="hard-break"}const Fv=/^[A-Za-z][A-Za-z0-9+.-]*:$/;function Tv(u,c){const o=u.texts[c];return o.startsWith("www.")?!0:Fv.test(o)&&c+1<u.len&&u.kinds[c+1]==="text"&&u.texts[c+1]==="//"}function wv(u){return u.includes("?")&&(u.includes("://")||u.startsWith("www."))}function Dv(u){const c=u.texts.slice(),o=u.isWordLike.slice(),r=u.kinds.slice(),d=u.starts.slice();for(let b=0;b<u.len;b++){if(r[b]!=="text"||!Tv(u,b))continue;const v=[c[b]];let y=b+1;for(;y<u.len&&!No(r[y]);){v.push(c[y]),o[b]=!0;const m=c[y].includes("?");if(r[y]="text",c[y]="",y++,m)break}c[b]=Pt(v)}let h=0;for(let b=0;b<c.length;b++){const v=c[b];v.length!==0&&(h!==b&&(c[h]=v,o[h]=o[b],r[h]=r[b],d[h]=d[b]),h++)}return c.length=h,o.length=h,r.length=h,d.length=h,{len:h,texts:c,isWordLike:o,kinds:r,starts:d}}function Bv(u){const c=[],o=[],r=[],d=[];for(let h=0;h<u.len;h++){const b=u.texts[h];if(c.push(b),o.push(u.isWordLike[h]),r.push(u.kinds[h]),d.push(u.starts[h]),!wv(b))continue;const v=h+1;if(v>=u.len||No(u.kinds[v]))continue;const y=[],m=u.starts[v];let p=v;for(;p<u.len&&!No(u.kinds[p]);)y.push(u.texts[p]),p++;y.length>0&&(c.push(Pt(y)),o.push(!0),r.push("text"),d.push(m),h=p-1)}return{len:c.length,texts:c,isWordLike:o,kinds:r,starts:d}}const Ov=new Set([":","-","/","×",",",".","+","–","—"]),jv=/[\p{P}\p{S}\p{Co}]/u,zv=/\p{Emoji_Presentation}/u,_v=new Set(["?","֊","-","‐","‒","–","—","…","‼","‽","⁉"]);function Rv(u){return u>=33&&u<=47&&u!==45||u>=58&&u<=64&&u!==63||u>=91&&u<=96||u>=123&&u<=126}function kh(u){const c=u.charCodeAt(0);return c<128?Rv(c):!_v.has(u)&&!zv.test(u)&&jv.test(u)}function S1(u){let c=!1;for(const o of u)if(!cn.test(o)){if(!kh(o))return!1;c=!0}return c}function Lv(u){for(let c=u.length;c>0;){const o=Mc(u,c),r=u.slice(o,c);if(cn.test(r)){c=o;continue}return kh(r)||kc(r)}return!1}function Hv(u,c,o,r){const d=!c&&S1(u),h=!r&&S1(o),b=vv(u),v=(c||b)&&Lv(u);return!d&&!h&&!v||dl(u)||dl(o)?!1:(c||d||b)&&(r||h)}function Fh(u){for(const c of u)if(Fo.test(c))return!0;return!1}function Nc(u){if(u.length===0)return!1;for(const c of u)if(!(Fo.test(c)||Ov.has(c)))return!1;return!0}function Uv(u){const c=[],o=[],r=[],d=[];for(let h=0;h<u.len;h++){const b=u.texts[h],v=u.kinds[h];if(v==="text"&&Nc(b)&&Fh(b)){const y=[b];let m=h+1;for(;m<u.len&&u.kinds[m]==="text"&&Nc(u.texts[m]);)y.push(u.texts[m]),m++;c.push(Pt(y)),o.push(!0),r.push("text"),d.push(u.starts[h]),h=m-1;continue}c.push(b),o.push(u.isWordLike[h]),r.push(v),d.push(u.starts[h])}return{len:c.length,texts:c,isWordLike:o,kinds:r,starts:d}}function qv(u){const c=[],o=[],r=[],d=[];let h=0;for(;h<u.len;){const b=u.texts[h],v=u.kinds[h],y=u.isWordLike[h];if(v==="text"){const m=[b];let p=h+1,g=y;for(;p<u.len&&u.kinds[p]==="text"&&Hv(u.texts[p-1],u.isWordLike[p-1],u.texts[p],u.isWordLike[p]);){const N=u.texts[p];m.push(N),g=g||u.isWordLike[p],p++}if(p>h+1){c.push(Pt(m)),o.push(g),r.push("text"),d.push(u.starts[h]),h=p;continue}}c.push(b),o.push(y),r.push(v),d.push(u.starts[h]),h++}return{len:c.length,texts:c,isWordLike:o,kinds:r,starts:d}}function Gv(u){const c=[],o=[],r=[],d=[];for(let h=0;h<u.len;h++){const b=u.texts[h];if(u.kinds[h]==="text"&&b.includes("-")){const v=b.split("-");let y=v.length>1;for(let m=0;m<v.length;m++){const p=v[m];if(!y)break;(p.length===0||!Fh(p)||!Nc(p))&&(y=!1)}if(y){let m=0;for(let p=0;p<v.length;p++){const g=v[p],N=p<v.length-1?`${g}-`:g;c.push(N),o.push(!0),r.push("text"),d.push(u.starts[h]+m),m+=N.length}continue}}c.push(b),o.push(u.isWordLike[h]),r.push(u.kinds[h]),d.push(u.starts[h])}return{len:c.length,texts:c,isWordLike:o,kinds:r,starts:d}}function Yv(u){const c=[],o=[],r=[],d=[];let h=0;for(;h<u.len;){const b=[u.texts[h]];let v=u.isWordLike[h],y=u.kinds[h],m=u.starts[h];if(y==="glue"){const p=[b[0]],g=m;for(h++;h<u.len&&u.kinds[h]==="glue";)p.push(u.texts[h]),h++;const N=Pt(p);if(h<u.len&&u.kinds[h]==="text")b[0]=N,b.push(u.texts[h]),v=u.isWordLike[h],y="text",m=g,h++;else{c.push(N),o.push(!1),r.push("glue"),d.push(g);continue}}else h++;if(y==="text")for(;h<u.len&&u.kinds[h]==="glue";){const p=[];for(;h<u.len&&u.kinds[h]==="glue";)p.push(u.texts[h]),h++;const g=Pt(p);if(h<u.len&&u.kinds[h]==="text"){b.push(g,u.texts[h]),v=v||u.isWordLike[h],h++;continue}b.push(g)}c.push(Pt(b)),o.push(v),r.push(y),d.push(m)}return{len:c.length,texts:c,isWordLike:o,kinds:r,starts:d}}function Xv(u){const c=u.texts.slice(),o=u.isWordLike.slice(),r=u.kinds.slice(),d=u.starts.slice();for(let h=0;h<c.length-1;h++){if(r[h]!=="text"||r[h+1]!=="text"||!dl(c[h])||!dl(c[h+1]))continue;const b=yv(c[h]);b!==null&&(c[h]=b.head,c[h+1]=b.tail+c[h+1],d[h+1]=d[h]+b.head.length)}return{len:c.length,texts:c,isWordLike:o,kinds:r,starts:d}}function Qv(u,c,o){const r=ev();let d=0;const h=[],b=[],v=[],y=[],m=[],p=[],g=[],N=[],C=[],V=[],W=[],L=[];for(const Z of r.segment(u))for(const ee of kv(Z.segment,Z.isWordLike??!1,Z.index,o)){let B=function(){p[j]!==null&&(b[j]=[y1(h,p,g,j)],p[j]=null),b[j].push(ee.text),v[j]=v[j]||ee.isWordLike,N[j]=N[j]||X,C[j]=C[j]||D,V[j]=Y,W[j]=ae,L[j]=N1(C[j],$)};const G=ee.kind==="text",A=Nv(ee.text,ee.isWordLike,ee.kind),X=dl(ee.text),D=v1(ee.text),$=ji(ee.text),Y=yo(ee.text),ae=Sv(ee.text),j=d-1;c.carryCJKAfterClosingQuote&&G&&d>0&&y[j]==="text"&&X&&N[j]&&V[j]||G&&d>0&&y[j]==="text"&&dv(ee.text)&&N[j]||G&&d>0&&y[j]==="text"&&W[j]?B():G&&d>0&&y[j]==="text"&&ee.isWordLike&&D&&L[j]?(B(),v[j]=!0):A!==null&&d>0&&y[j]==="text"&&p[j]===A?g[j]=(g[j]??1)+1:G&&!ee.isWordLike&&d>0&&y[j]==="text"&&!N[j]&&(fv(ee.text)||ee.text==="-"&&v[j])?B():(h[d]=ee.text,b[d]=[ee.text],v[d]=ee.isWordLike,y[d]=ee.kind,m[d]=ee.start,p[d]=A,g[d]=A===null?0:1,N[d]=X,C[d]=D,V[d]=Y,W[d]=ae,L[d]=N1(D,$),d++)}for(let Z=0;Z<d;Z++){if(p[Z]!==null){h[Z]=y1(h,p,g,Z);continue}h[Z]=Pt(b[Z])}for(let Z=1;Z<d;Z++)y[Z]==="text"&&!v[Z]&&Do(h[Z])&&y[Z-1]==="text"&&!N[Z-1]&&(h[Z-1]+=h[Z],v[Z-1]=v[Z-1]||v[Z],h[Z]="");const U=Array.from({length:d},()=>null);let te=-1;for(let Z=d-1;Z>=0;Z--){const ee=h[Z];if(ee.length!==0){if(y[Z]==="text"&&!v[Z]&&te>=0&&y[te]==="text"&&(xv(ee)||ee==="-"&&bv(h[te]))){const G=U[te]??[];G.push(ee),U[te]=G,m[te]=m[Z],h[Z]="";continue}te=Z}}for(let Z=0;Z<d;Z++){const ee=U[Z];ee!=null&&(h[Z]=Mv(ee,h[Z]))}let le=0;for(let Z=0;Z<d;Z++){const ee=h[Z];ee.length!==0&&(le!==Z&&(h[le]=ee,v[le]=v[Z],y[le]=y[Z],m[le]=m[Z]),le++)}h.length=le,v.length=le,y.length=le,m.length=le;const oe=Yv({len:le,texts:h,isWordLike:v,kinds:y,starts:m}),ce=Xv(qv(Gv(Uv(Bv(Dv(oe))))));for(let Z=0;Z<ce.len-1;Z++){const ee=Ev(ce.texts[Z]);ee!==null&&(ce.kinds[Z]!=="space"&&ce.kinds[Z]!=="preserved-space"||ce.kinds[Z+1]!=="text"||!v1(ce.texts[Z+1])||(ce.texts[Z]=ee.space,ce.isWordLike[Z]=!1,ce.kinds[Z]=ce.kinds[Z]==="preserved-space"?"preserved-space":"space",ce.texts[Z+1]=ee.marks+ce.texts[Z+1],ce.starts[Z+1]=ce.starts[Z]+ee.space.length))}return ce}function Vv(u,c){if(u.len===0)return[];if(!c.preserveHardBreaks)return[{startSegmentIndex:0,endSegmentIndex:u.len,consumedEndSegmentIndex:u.len}];const o=[];let r=0;for(let d=0;d<u.len;d++)u.kinds[d]==="hard-break"&&(o.push({startSegmentIndex:r,endSegmentIndex:d,consumedEndSegmentIndex:d+1}),r=d+1);return r<u.len&&o.push({startSegmentIndex:r,endSegmentIndex:u.len,consumedEndSegmentIndex:u.len}),o}function Zv(u,c,o){if(c.len<=1)return c;const r=[],d=[],h=[],b=[];let v=-1,y=!1;function m(N){r.push(c.texts[N]),d.push(c.isWordLike[N]),h.push("text"),b.push(c.starts[N])}function p(N,C){let V=!1;for(let U=N;U<C;U++)V=V||c.isWordLike[U];const W=c.starts[N],L=C<c.len?c.starts[C]:u.length;r.push(u.slice(W,L)),d.push(V),h.push("text"),b.push(W)}function g(N){if(!(v<0)){if(y)v+1===N?m(v):p(v,N);else for(let C=v;C<N;C++)m(C);v=-1,y=!1}}for(let N=0;N<c.len;N++){const C=c.texts[N],V=c.kinds[N];if(V==="text"){v>=0&&!Mh(c.texts[N-1],o)&&g(N),v<0&&(v=N),y=y||dl(C);continue}g(N),r.push(C),d.push(c.isWordLike[N]),h.push(V),b.push(c.starts[N])}return g(c.len),{len:r.length,texts:r,isWordLike:d,kinds:h,starts:b}}function Kv(u,c,o="normal",r="normal"){const d=Ip(o),h=d.mode==="pre-wrap"?$p(u):Wp(u);if(h.length===0)return{normalized:h,chunks:[],len:0,texts:[],isWordLike:[],kinds:[],starts:[]};const b=Qv(h,c,d),v=r==="keep-all"?Zv(h,b,c.breakKeepAllAfterPunctuation):b;return{normalized:h,chunks:Vv(v,d),...v}}let Da=null;const So=new Map;let Ba=null;const Jv=96,Iv=/\p{Emoji_Presentation}/u,Wv=/[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\uFE0F\u20E3]/u;let vc=null;const Eo=new Map;function Bo(){if(Da!==null)return Da;if(typeof OffscreenCanvas<"u")return Da=new OffscreenCanvas(1,1).getContext("2d"),Da;if(typeof document<"u")return Da=document.createElement("canvas").getContext("2d"),Da;throw new Error("Text measurement requires OffscreenCanvas or a DOM canvas context.")}function $v(u){let c=So.get(u);return c||(c=new Map,So.set(u,c)),c}function un(u,c){let o=c.get(u);return o===void 0&&(o={width:Bo().measureText(u).width,containsCJK:dl(u)},c.set(u,o)),o}function Ra(){if(Ba!==null)return Ba;if(typeof navigator>"u")return Ba={lineFitEpsilon:.005,carryCJKAfterClosingQuote:!1,breakKeepAllAfterPunctuation:!0,preferPrefixWidthsForBreakableRuns:!1,preferEarlySoftHyphenBreak:!1},Ba;const u=navigator.userAgent,o=navigator.vendor==="Apple Computer, Inc."&&u.includes("Safari/")&&!u.includes("Chrome/")&&!u.includes("Chromium/")&&!u.includes("CriOS/")&&!u.includes("FxiOS/")&&!u.includes("EdgiOS/"),r=u.includes("Chrome/")||u.includes("Chromium/")||u.includes("CriOS/")||u.includes("Edg/");return Ba={lineFitEpsilon:o?1/64:.005,carryCJKAfterClosingQuote:r,breakKeepAllAfterPunctuation:!o,preferPrefixWidthsForBreakableRuns:o,preferEarlySoftHyphenBreak:o},Ba}function Pv(u){const c=u.match(/(\d+(?:\.\d+)?)\s*px/);return c?parseFloat(c[1]):16}function Th(){return vc===null&&(vc=new Intl.Segmenter(void 0,{granularity:"grapheme"})),vc}function eb(u){return Iv.test(u)||u.includes("️")}function tb(u){return Wv.test(u)}function lb(u,c){let o=Eo.get(u);if(o!==void 0)return o;const r=Bo();r.font=u;const d=r.measureText("😀").width;if(o=0,d>c+.5&&typeof document<"u"&&document.body!==null){const h=document.createElement("span");h.style.font=u,h.style.display="inline-block",h.style.visibility="hidden",h.style.position="absolute",h.textContent="😀",document.body.appendChild(h);const b=h.getBoundingClientRect().width;document.body.removeChild(h),d-b>.5&&(o=d-b)}return Eo.set(u,o),o}function nb(u){let c=0;const o=Th();for(const r of o.segment(u))eb(r.segment)&&c++;return c}function ab(u,c){return c.emojiCount===void 0&&(c.emojiCount=nb(u)),c.emojiCount}function zn(u,c,o){return o===0?c.width:c.width-ab(u,c)*o}function ib(u,c,o,r,d){if(c.breakableFitAdvances!==void 0&&c.breakableFitMode===d)return c.breakableFitAdvances;c.breakableFitMode=d;const h=Th(),b=[];for(const p of h.segment(u))b.push(p.segment);if(b.length<=1)return c.breakableFitAdvances=null,c.breakableFitAdvances;if(d==="sum-graphemes"){const p=[];for(const g of b){const N=un(g,o);p.push(zn(g,N,r))}return c.breakableFitAdvances=p,c.breakableFitAdvances}if(d==="pair-context"||b.length>Jv){const p=[];let g=null,N=0;for(const C of b){const V=un(C,o),W=zn(C,V,r);if(g===null)p.push(W);else{const L=g+C,U=un(L,o);p.push(zn(L,U,r)-N)}g=C,N=W}return c.breakableFitAdvances=p,c.breakableFitAdvances}const v=[];let y="",m=0;for(const p of b){y+=p;const g=un(y,o),N=zn(y,g,r);v.push(N-m),m=N}return c.breakableFitAdvances=v,c.breakableFitAdvances}function ub(u,c){const o=Bo();o.font=u;const r=$v(u),d=Pv(u),h=c?lb(u,d):0;return{cache:r,fontSize:d,emojiCorrection:h}}function cb(){So.clear(),Eo.clear(),vc=null}function rb(u){return u==="space"||u==="zero-width-break"||u==="soft-hyphen"}function Fc(u){return u==="space"||u==="preserved-space"||u==="tab"||u==="zero-width-break"||u==="soft-hyphen"}function Oo(u,c,o=u.widths.length){for(;c<o;){const r=u.kinds[c];if(!rb(r))break;c++}return c}function wh(u,c){if(c<=0)return 0;const o=u%c;return Math.abs(o)<=1e-6?c:c-o}function Dh(u,c,o){return u.letterSpacing!==0&&c&&u.spacingGraphemeCounts[o]>0?u.letterSpacing:0}function jo(u,c){return c===0?0:u+c}function sb(u,c){return u.letterSpacing!==0&&u.spacingGraphemeCounts[c]>0?u.letterSpacing:0}function Bh(u,c,o,r,d){const h=c==="tab"?d+sb(u,o):u.lineEndFitAdvances[o];return jo(r,h)}function Sc(u,c,o,r){const d=c==="tab"?0:u.lineEndFitAdvances[o];return jo(r,d)}function Ec(u,c,o,r,d){const h=c==="tab"?d:u.lineEndPaintAdvances[o];return jo(r,h)}function Oh(u,c,o){return u.letterSpacing!==0&&c?o+u.letterSpacing:o}function jh(u,c){return u.letterSpacing===0?c:c+u.letterSpacing}function _a(u,c,o){let r=c;for(;r<u.length&&u[r]<o;)r++;return r}function ob(u,c,o,r,d){if(u.letterSpacing===0)return 0;if(d>0)return u.spacingGraphemeCounts[r]>0?u.letterSpacing:0;for(let h=r-1;h>=c;h--){const b=u.kinds[h];if(!(b==="space"||b==="zero-width-break"||b==="hard-break")){if(b==="soft-hyphen"){if(h===r-1)return 0;continue}return h===c&&o>0||u.spacingGraphemeCounts[h]>0?u.letterSpacing:0}}return 0}function zh(u,c,o,r,d,h){return c+ob(u,o,r,d,h)}function fb(u,c){let o=0,r=u.chunks.length;for(;o<r;){const d=Math.floor((o+r)/2);c<u.chunks[d].consumedEndSegmentIndex?r=d:o=d+1}return o<u.chunks.length?o:-1}function db(u,c,o){let r=o.segmentIndex;if(o.graphemeIndex>0)return c;const d=u.chunks[c];return d.startSegmentIndex===d.endSegmentIndex&&r===d.startSegmentIndex||(r<d.startSegmentIndex&&(r=d.startSegmentIndex),r=Oo(u,r,d.endSegmentIndex),r<d.endSegmentIndex)?(o.segmentIndex=r,o.graphemeIndex=0,c):d.consumedEndSegmentIndex>=u.widths.length?-1:(o.segmentIndex=d.consumedEndSegmentIndex,o.graphemeIndex=0,c+1)}function xb(u,c){if(c.segmentIndex>=u.widths.length)return-1;const o=fb(u,c.segmentIndex);return o<0?-1:db(u,o,c)}function hb(u,c,o){const{widths:r,kinds:d,breakableFitAdvances:h,breakablePreferredBreaks:b}=u;if(r.length===0)return 0;const y=Ra().lineFitEpsilon,m=c+y;let p=0,g=0,N=!1,C=0,V=0,W=0,L=0,U=-1,te=0;function le(){U=-1,te=0}function oe(X=W,D=L,$=g){p++,o?.($,C,V,X,D),g=0,N=!1,le()}function ce(X,D){N=!0,C=X,V=0,W=X+1,L=0,g=D}function Z(X,D,$){N=!0,C=X,V=D,W=X,L=D+1,g=$}function ee(X,D){if(!N){ce(X,D);return}g+=D,W=X+1,L=0}function G(X,D){const $=h[X],Y=b[X]??null;let ae=Y===null?-1:_a(Y,0,D+1),j=-1,B=0,k=D;for(;k<$.length;){const O=$[k];if(!N)Z(X,k,O);else if(g+O>m){if(Y!==null&&j>D){oe(X,j,B),k=j,ae=_a(Y,ae,k+1),j=-1,B=0;continue}oe(),Z(X,k,O)}else g+=O,W=X,L=k+1;const Q=k+1;Y!==null&&Y[ae]===Q&&(j=Q,B=g,ae++),k++}N&&W===X&&L===$.length&&(W=X+1,L=0)}let A=0;for(;A<r.length&&!(!N&&(A=Oo(u,A),A>=r.length));){const X=r[A],D=d[A],$=Fc(D);if(!N){X>m&&h[A]!==null?G(A,0):ce(A,X),$&&(U=A+1,te=g-X),A++;continue}if(g+X>m){if($){ee(A,X),oe(A+1,0,g-X),A++;continue}if(U>=0){if(W>U||W===U&&L>0){oe();continue}oe(U,0,te);continue}if(X>m&&h[A]!==null){oe(),G(A,0),A++;continue}oe();continue}ee(A,X),$&&(U=A+1,te=g-X),A++}return N&&oe(),p}function mb(u,c,o){if(u.simpleLineWalkFastPath)return hb(u,c,o);const{widths:r,kinds:d,breakableFitAdvances:h,breakablePreferredBreaks:b,discretionaryHyphenWidth:v,chunks:y}=u;if(r.length===0||y.length===0)return 0;const m=Ra(),p=m.lineFitEpsilon,g=c+p;let N=0,C=0,V=!1,W=0,L=0,U=0,te=0,le=-1,oe=0,ce=0,Z=null;function ee(){le=-1,oe=0,ce=0,Z=null}function G(){return Z==="soft-hyphen"&&le===U&&te===0?ce:C}function A(B=U,k=te,O){N++,o!==void 0&&o(zh(u,O??G(),W,L,B,k),W,L,B,k),C=0,V=!1,ee()}function X(B,k){V=!0,W=B,L=0,U=B+1,te=0,C=k}function D(B,k,O){V=!0,W=B,L=k,U=B,te=k+1,C=O}function $(B,k){if(!V){X(B,k);return}C+=k,U=B+1,te=0}function Y(B,k,O,Q,P,re){if(!k)return;const ne=Sc(u,B,O,P),ie=Ec(u,B,O,P,Q);le=O+1,oe=C-re+ne,ce=C-re+ie,Z=B}function ae(B,k){const O=h[B],Q=b[B]??null;let P=Q===null?-1:_a(Q,0,k+1),re=-1,ne=0,ie=k;for(;ie<O.length;){const S=O[ie];if(!V)D(B,ie,S);else{const q=Oh(u,!0,S),I=C+q;if(jh(u,I)>g){if(Q!==null&&re>k){A(B,re,ne),ie=re,P=_a(Q,P,ie+1),re=-1,ne=0;continue}A(),D(B,ie,S)}else C=I,U=B,te=ie+1}const H=ie+1;Q!==null&&Q[P]===H&&(re=H,ne=C,P++),ie++}V&&U===B&&te===O.length&&(U=B+1,te=0)}function j(B){N++,o?.(0,B.startSegmentIndex,0,B.consumedEndSegmentIndex,0),ee()}for(let B=0;B<y.length;B++){const k=y[B];if(k.startSegmentIndex===k.endSegmentIndex){j(k);continue}V=!1,C=0,W=k.startSegmentIndex,L=0,U=k.startSegmentIndex,te=0,ee();let O=k.startSegmentIndex;for(;O<k.endSegmentIndex&&!(!V&&(O=Oo(u,O,k.endSegmentIndex),O>=k.endSegmentIndex));){const Q=d[O],P=Fc(Q),re=Dh(u,V,O),ne=Q==="tab"?wh(C+re,u.tabStopAdvance):r[O],ie=re+ne,S=Bh(u,Q,O,re,ne);if(Q==="soft-hyphen"){V&&(U=O+1,te=0,le=O+1,oe=C+v,ce=C+v,Z=Q),O++;continue}if(!V){S>g&&h[O]!==null?ae(O,0):X(O,ne),Y(Q,P,O,ne,re,ie),O++;continue}if(C+S>g){const q=C+Sc(u,Q,O,re),I=C+Ec(u,Q,O,re,ne);if(Z==="soft-hyphen"&&m.preferEarlySoftHyphenBreak&&oe<=g){A(le,0,ce);continue}if(P&&q<=g){$(O,ie),A(O+1,0,I),O++;continue}if(le>=0&&oe<=g){if(U>le||U===le&&te>0){A();continue}const ge=le;A(ge,0,ce),O=ge;continue}if(S>g&&h[O]!==null){A(),ae(O,0),O++;continue}A();continue}$(O,ie),Y(Q,P,O,ne,re,ie),O++}if(V){const Q=le===k.consumedEndSegmentIndex?ce:C;A(k.consumedEndSegmentIndex,0,Q)}}return N}function gb(u,c,o,r){const d=u.chunks[o];if(d.startSegmentIndex===d.endSegmentIndex)return c.segmentIndex=d.consumedEndSegmentIndex,c.graphemeIndex=0,0;const{widths:h,kinds:b,breakableFitAdvances:v,breakablePreferredBreaks:y,discretionaryHyphenWidth:m}=u,p=Ra(),g=p.lineFitEpsilon,N=r+g,C=c.segmentIndex,V=c.graphemeIndex;let W=0,L=!1,U=c.segmentIndex,te=c.graphemeIndex,le=-1,oe=0,ce=0,Z=null;function ee(){return Z==="soft-hyphen"&&le===U&&te===0?ce:W}function G(j=U,B=te,k=ee()){return L?(c.segmentIndex=j,c.graphemeIndex=B,zh(u,k,C,V,j,B)):null}function A(j,B){L=!0,U=j+1,te=0,W=B}function X(j,B,k){L=!0,U=j,te=B+1,W=k}function D(j,B){if(!L){A(j,B);return}W+=B,U=j+1,te=0}function $(j,B,k,O,Q,P){if(!B)return;const re=Sc(u,j,k,Q),ne=Ec(u,j,k,Q,O);le=k+1,oe=W-P+re,ce=W-P+ne,Z=j}function Y(j,B){const k=v[j],O=y[j]??null;let Q=O===null?-1:_a(O,0,B+1),P=-1,re=0;for(let ne=B;ne<k.length;ne++){const ie=k[ne];if(!L)X(j,ne,ie);else{const H=Oh(u,!0,ie),q=W+H;if(jh(u,q)>N)return O!==null&&P>B?G(j,P,re):G();W=q,U=j,te=ne+1}const S=ne+1;O!==null&&O[Q]===S&&(P=S,re=W,Q++)}return L&&U===j&&te===k.length&&(U=j+1,te=0),null}function ae(){return Z!=="soft-hyphen"||le<0?null:oe<=N?G(le,0,ce):null}for(let j=c.segmentIndex;j<d.endSegmentIndex;j++){const B=b[j],k=Fc(B),O=j===c.segmentIndex?c.graphemeIndex:0,Q=Dh(u,L,j),P=B==="tab"?wh(W+Q,u.tabStopAdvance):h[j],re=Q+P,ne=Bh(u,B,j,Q,P);if(B==="soft-hyphen"&&O===0){L&&(U=j+1,te=0,le=j+1,oe=W+m,ce=W+m,Z=B);continue}if(!L){if(O>0){const S=Y(j,O);if(S!==null)return S}else if(ne>N&&v[j]!==null){const S=Y(j,0);if(S!==null)return S}else A(j,P);$(B,k,j,P,Q,re);continue}if(W+ne>N){const S=W+Sc(u,B,j,Q),H=W+Ec(u,B,j,Q,P);if(Z==="soft-hyphen"&&p.preferEarlySoftHyphenBreak&&oe<=N)return G(le,0,ce);const q=ae();if(q!==null)return q;if(k&&S<=N)return D(j,re),G(j+1,0,H);if(le>=0&&oe<=N)return U>le||U===le&&te>0?G():G(le,0,ce);if(ne>N&&v[j]!==null){const I=G();if(I!==null)return I;const ge=Y(j,0);if(ge!==null)return ge}return G()}D(j,re),$(B,k,j,P,Q,re)}return le===d.consumedEndSegmentIndex&&te===0?G(d.consumedEndSegmentIndex,0,ce):G(d.consumedEndSegmentIndex,0,W)}function pb(u,c,o){const{widths:r,kinds:d,breakableFitAdvances:h,breakablePreferredBreaks:b}=u,y=Ra().lineFitEpsilon,m=o+y;let p=0,g=!1,N=c.segmentIndex,C=c.graphemeIndex,V=-1,W=0;for(let L=c.segmentIndex;L<r.length;L++){const U=d[L],te=Fc(U),le=L===c.segmentIndex?c.graphemeIndex:0,oe=h[L],ce=r[L];if(!g){if(le>0||ce>m&&oe!==null){const Z=oe,ee=b[L]??null;let G=ee===null?-1:_a(ee,0,le+1),A=-1,X=0;const D=Z[le];g=!0,p=D,N=L,C=le+1,ee!==null&&ee[G]===C&&(A=C,X=p,G++);for(let $=le+1;$<Z.length;$++){const Y=Z[$];if(p+Y>m)return ee!==null&&A>le?(c.segmentIndex=L,c.graphemeIndex=A,X):(c.segmentIndex=N,c.graphemeIndex=C,p);p+=Y,N=L,C=$+1,ee!==null&&ee[G]===C&&(A=C,X=p,G++)}N===L&&C===Z.length&&(N=L+1,C=0)}else g=!0,p=ce,N=L+1,C=0;te&&(V=L+1,W=p-ce);continue}if(p+ce>m)return te?(c.segmentIndex=L+1,c.graphemeIndex=0,p):V>=0?N>V||N===V&&C>0?(c.segmentIndex=N,c.graphemeIndex=C,p):(c.segmentIndex=V,c.graphemeIndex=0,W):(c.segmentIndex=N,c.graphemeIndex=C,p);p+=ce,N=L+1,C=0,te&&(V=L+1,W=p-ce)}return g?(c.segmentIndex=N,c.graphemeIndex=C,p):null}function vb(u,c,o,r){return u.simpleLineWalkFastPath?pb(u,c,r):gb(u,c,o,r)}function Ao(u,c,o){const r=xb(u,c);return r<0?null:vb(u,c,r,o)}let bc=null,Co=new WeakMap;function bb(){return bc===null&&(bc=new Intl.Segmenter(void 0,{granularity:"grapheme"})),bc}function E1(u,c,o){let r=o.get(u);if(r!==void 0)return r;r=[];const d=bb();for(const h of d.segment(c[u]))r.push(h.segment);return o.set(u,r),r}function yb(u,c,o){return o>c&&u[o-1]==="soft-hyphen"}function A1(u,c,o,r){for(let d=o;d<r;d++)u+=c[d];return u}function Nb(u){let c=Co.get(u);return c!==void 0||(c=new Map,Co.set(u,c)),c}function Sb(u,c,o,r,d,h){let b="";const v=yb(u.kinds,o,d);for(let y=o;y<d;y++)if(!(u.kinds[y]==="soft-hyphen"||u.kinds[y]==="hard-break"))if(y===o&&r>0){const m=E1(y,u.segments,c);b=A1(b,m,r,m.length)}else b+=u.segments[y];if(h>0){v&&(b+="-");const y=E1(d,u.segments,c);b=A1(b,y,o===d?r:0,h)}else v&&(b+="-");return b}function Eb(){bc=null,Co=new WeakMap}let yc=null;function zo(){return yc===null&&(yc=new Intl.Segmenter(void 0,{granularity:"grapheme"})),yc}function Ab(u){return{widths:[],lineEndFitAdvances:[],lineEndPaintAdvances:[],kinds:[],simpleLineWalkFastPath:!0,segLevels:null,breakableFitAdvances:[],breakablePreferredBreaks:[],letterSpacing:0,spacingGraphemeCounts:[],discretionaryHyphenWidth:0,tabStopAdvance:0,chunks:[],segments:[]}}function Cb(u,c){const o=[];let r=[],d=0,h=!1,b=!1,v=!1;function y(){r.length!==0&&(o.push({text:r.length===1?r[0]:r.join(""),start:d}),r=[],h=!1,b=!1,v=!1)}function m(g,N,C){r=[g],d=N,h=C,b=yo(g),v=Cc.has(g)}function p(g,N){r.push(g),h=h||N;const C=yo(g);g.length===1&&_n.has(g)?b=b||C:b=C,v=!1}for(const g of zo().segment(u)){const N=g.segment,C=dl(N);if(r.length===0){m(N,g.index,C);continue}if(v||To.has(N)||_n.has(N)||c.carryCJKAfterClosingQuote&&C&&b){p(N,C);continue}if(!h&&!C){p(N,C);continue}y(),m(N,g.index,C)}return y(),o}function Mb(u,c,o){if(c.length<=1)return c;const r=[];let d=-1,h=!1;function b(y,m){const p=c[y].start,g=m<c.length?c[m].start:u.length;r.push({text:u.slice(p,g),start:p})}function v(y){if(!(d<0)){if(h)d+1===y?r.push(c[d]):b(d,y);else for(let m=d;m<y;m++)r.push(c[m]);d=-1,h=!1}}for(let y=0;y<c.length;y++){const m=c[y];d>=0&&!Mh(c[y-1].text,o)&&v(y),d<0&&(d=y),h=h||dl(m.text)}return v(c.length),r}function C1(u,c){if(c==="zero-width-break"||c==="soft-hyphen"||c==="hard-break")return 0;if(c==="tab")return 1;let o=0;const r=zo();for(const d of r.segment(u))o++;return o}function kb(u){return u==="-"||u==="֊"||u==="‐"||u==="‒"||u==="–"||u==="—"}function Fb(u){if(!/[-\u058A\u2010\u2012\u2013\u2014]/u.test(u))return null;const c=[];let o=0;for(const r of zo().segment(u))o++,kb(r.segment)&&c.push(o);return c.length===0?null:c}function Tb(u,c,o){return c>1?u+(c-1)*o:u}function wb(u,c,o,r,d){const h=Ra(),{cache:b,emojiCorrection:v}=ub(c,tb(u.normalized)),y=zn("-",un("-",b),v)+(d===0?0:d*2),p=zn(" ",un(" ",b),v)*8,g=d!==0;if(u.len===0)return Ab();const N=[],C=[],V=[],W=[];let L=u.chunks.length<=1&&!g;const U=o?[]:null,te=[],le=[],oe=[],ce=o?[]:null,Z=Array.from({length:u.len});function ee(D,$,Y,ae,j,B,k,O,Q){j!=="text"&&j!=="space"&&j!=="zero-width-break"&&(L=!1),N.push($),C.push(Y),V.push(ae),W.push(j),U?.push(B),te.push(k),le.push(O),g&&oe.push(Q),ce!==null&&ce.push(D)}function G(D,$,Y,ae,j){const B=un(D,b),k=g?C1(D,$):0,O=Tb(zn(D,B,v),k,d),Q=$==="space"||$==="preserved-space"||$==="zero-width-break"?0:O,P=Q===0?0:Q+(k>0?d:0),re=$==="space"||$==="zero-width-break"?0:O;if(j&&ae&&D.length>1){let ne="sum-graphemes";d!==0?ne="segment-prefixes":Nc(D)?ne="pair-context":h.preferPrefixWidthsForBreakableRuns&&(ne="segment-prefixes");const ie=ib(D,B,b,v,ne),S=ie===null||r==="keep-all"?null:Fb(D);ee(D,O,P,re,$,Y,ie,S,k);return}ee(D,O,P,re,$,Y,null,null,k)}for(let D=0;D<u.len;D++){Z[D]=N.length;const $=u.texts[D],Y=u.isWordLike[D],ae=u.kinds[D],j=u.starts[D];if(ae==="soft-hyphen"){ee($,0,y,y,ae,j,null,null,0);continue}if(ae==="hard-break"){ee($,0,0,0,ae,j,null,null,0);continue}if(ae==="tab"){ee($,0,0,0,ae,j,null,null,g?C1($,ae):0);continue}const B=un($,b);if(ae==="text"&&B.containsCJK){const k=Cb($,h),O=r==="keep-all"?Mb($,k,h.breakKeepAllAfterPunctuation):k;for(let Q=0;Q<O.length;Q++){const P=O[Q];G(P.text,"text",j+P.start,Y,r==="keep-all"||!dl(P.text))}continue}G($,ae,j,Y,!0)}const A=Db(u.chunks,Z,N.length),X=U===null?null:Zp(u.normalized,U);return ce!==null?{widths:N,lineEndFitAdvances:C,lineEndPaintAdvances:V,kinds:W,simpleLineWalkFastPath:L,segLevels:X,breakableFitAdvances:te,breakablePreferredBreaks:le,letterSpacing:d,spacingGraphemeCounts:oe,discretionaryHyphenWidth:y,tabStopAdvance:p,chunks:A,segments:ce}:{widths:N,lineEndFitAdvances:C,lineEndPaintAdvances:V,kinds:W,simpleLineWalkFastPath:L,segLevels:X,breakableFitAdvances:te,breakablePreferredBreaks:le,letterSpacing:d,spacingGraphemeCounts:oe,discretionaryHyphenWidth:y,tabStopAdvance:p,chunks:A}}function Db(u,c,o){const r=[];for(let d=0;d<u.length;d++){const h=u[d],b=h.startSegmentIndex<c.length?c[h.startSegmentIndex]:o,v=h.endSegmentIndex<c.length?c[h.endSegmentIndex]:o,y=h.consumedEndSegmentIndex<c.length?c[h.consumedEndSegmentIndex]:o;r.push({startSegmentIndex:b,endSegmentIndex:v,consumedEndSegmentIndex:y})}return r}function Bb(u,c,o,r){const d=r?.wordBreak??"normal",h=r?.letterSpacing??0,b=Kv(u,Ra(),r?.whiteSpace,d);return wb(b,c,o,d,h)}function Mo(u,c,o){return Bb(u,c,!0,o)}function M1(u){let c=0;return mb(u,Number.POSITIVE_INFINITY,o=>{o>c&&(c=o)}),c}function Ob(){tv(),yc=null,Eb(),cb()}function fc(u){return u.replace(/[ \t]+/g," ")}function jb(u,c=[]){const o=[],r=c.filter(m=>m.length>0).map(m=>m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),d=r.length?new RegExp(`(${r.join("|")})`,"g"):null,h=/(\*\*[^*]+\*\*|\*[^*]+\*|==[^=]+==)/g;let b=0,v;function y(m,p={}){if(!m)return;if(!d){o.push({text:m,...p});return}d.lastIndex=0;let g=0,N;for(;(N=d.exec(m))!==null;)N.index>g&&o.push({text:m.slice(g,N.index),...p}),o.push({text:N[0],...p,highlight:!0}),g=N.index+N[0].length;g<m.length&&o.push({text:m.slice(g),...p})}for(;(v=h.exec(u))!==null;){v.index>b&&y(u.slice(b,v.index));const m=v[0];m.startsWith("**")&&m.endsWith("**")?y(m.slice(2,-2),{bold:!0}):m.startsWith("*")&&m.endsWith("*")?y(m.slice(1,-1),{italic:!0}):m.startsWith("==")&&m.endsWith("==")&&o.push({text:m.slice(2,-2),highlight:!0,bold:!0}),b=v.index+m.length}return b<u.length&&y(u.slice(b)),o.length>0?o:[{text:u}]}function zb(u){const c=u.replaceAll(`\r
|
package/dist/index.html
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
rel="stylesheet"
|
|
12
12
|
/>
|
|
13
13
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lxgw-wenkai-screen-web/style.css" />
|
|
14
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-De-aHsvp.js"></script>
|
|
15
15
|
<link rel="stylesheet" crossorigin href="/assets/index-3Ko1UCBU.css">
|
|
16
16
|
</head>
|
|
17
17
|
<body class="bg-[#fafafa] dark:bg-[#000000] text-[#171717] dark:text-[#ededed] antialiased selection:bg-[#eaeaea] selection:text-[#000000] dark:selection:bg-[#333333] dark:selection:text-[#ffffff] overflow-hidden">
|
package/dist/lib/adapter.js
CHANGED
|
@@ -131,7 +131,7 @@ async function renderLocalBatch(body, outputDir, route, kind) {
|
|
|
131
131
|
}
|
|
132
132
|
var typesetStudioAdapter = {
|
|
133
133
|
name: "typeset-studio",
|
|
134
|
-
version: "0.2.
|
|
134
|
+
version: "0.2.5",
|
|
135
135
|
async doctor() {
|
|
136
136
|
const checks = [];
|
|
137
137
|
const REMOTE_STUDIO_URL = remoteStudioUrl();
|
package/dist/lib/index.js
CHANGED
package/package.json
CHANGED
package/src/adapter.ts
CHANGED
|
@@ -266,7 +266,7 @@ async function renderLocalBatch(
|
|
|
266
266
|
|
|
267
267
|
export const typesetStudioAdapter: ImageRenderPlugin = {
|
|
268
268
|
name: "typeset-studio",
|
|
269
|
-
version: "0.2.
|
|
269
|
+
version: "0.2.5",
|
|
270
270
|
|
|
271
271
|
async doctor(): Promise<PipelinePluginDoctorCheck[]> {
|
|
272
272
|
const checks: PipelinePluginDoctorCheck[] = [];
|
package/src/server/index.ts
CHANGED
|
@@ -52,7 +52,7 @@ export const Header: React.FC<HeaderProps> = ({
|
|
|
52
52
|
</span>
|
|
53
53
|
<span>Typeset Studio</span>
|
|
54
54
|
</div>
|
|
55
|
-
<span className="text-xs text-[#888888] dark:text-[#555555] font-mono hidden md:inline">v0.2.
|
|
55
|
+
<span className="text-xs text-[#888888] dark:text-[#555555] font-mono hidden md:inline">v0.2.5</span>
|
|
56
56
|
<div className="flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-[#f5f5f5] dark:bg-[#111111] border border-[#e5e5e5] dark:border-[#222222] text-[11px] text-emerald-600 dark:text-[#00e676]">
|
|
57
57
|
<span className="w-1.5 h-1.5 rounded-full bg-emerald-500 dark:bg-[#00e676] animate-pulse" />
|
|
58
58
|
<span className="font-mono">Ready</span>
|